diff --git a/hsarback/src/de/hsadmin/hostsharing/MultiOption.java b/hsarback/src/de/hsadmin/hostsharing/MultiOption.java new file mode 100644 index 0000000..5eb3abe --- /dev/null +++ b/hsarback/src/de/hsadmin/hostsharing/MultiOption.java @@ -0,0 +1,10 @@ +package de.hsadmin.hostsharing; + +public class MultiOption { + + public static final int DATABASEUSERS_PER_OPTION = 25; + public static final int DATABASES_PER_OPTION = 25; + public static final int EMAIL_ITEMS_PER_OPTION = 250; + public static final int UNIXUSERS_PER_OPTION = 50; + +} diff --git a/hsarback/src/de/hsadmin/mods/db/MySqlDatabaseModuleImpl.java b/hsarback/src/de/hsadmin/mods/db/MySqlDatabaseModuleImpl.java index 6da6e69..ba2a995 100644 --- a/hsarback/src/de/hsadmin/mods/db/MySqlDatabaseModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/db/MySqlDatabaseModuleImpl.java @@ -10,13 +10,12 @@ import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.model.Transaction; +import de.hsadmin.hostsharing.MultiOption; import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.user.UnixUser; public class MySqlDatabaseModuleImpl extends AbstractModuleImpl { - private static final int DBS_PER_MULTI_OPTION = 25; - @Override public List search(Class entityClass, String condition, String orderBy) throws HSAdminException { @@ -64,7 +63,7 @@ public class MySqlDatabaseModuleImpl extends AbstractModuleImpl { //TODO: Needs better implementation Query qDatabases = em.createQuery("SELECT obj FROM Database obj WHERE obj.pac.id = :pacId"); qDatabases.setParameter("pacId", pac.getId()); - if (qDatabases.getResultList().size() >= DBS_PER_MULTI_OPTION * pac.getQuantityByComponentName("MULTI")) { + if (qDatabases.getResultList().size() >= MultiOption.DATABASES_PER_OPTION * pac.getQuantityByComponentName("MULTI")) { throw new HSAdminException("included number of databases exceeded"); } database.setPac(pac); diff --git a/hsarback/src/de/hsadmin/mods/db/MySqlUserModuleImpl.java b/hsarback/src/de/hsadmin/mods/db/MySqlUserModuleImpl.java index cd101ce..f5f64d1 100644 --- a/hsarback/src/de/hsadmin/mods/db/MySqlUserModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/db/MySqlUserModuleImpl.java @@ -10,13 +10,12 @@ import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.model.Transaction; +import de.hsadmin.hostsharing.MultiOption; import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.user.UnixUser; public class MySqlUserModuleImpl extends AbstractModuleImpl { - private static final int DBUSERS_PER_MULTI_OPTION = 25; - @Override public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException { Transaction transaction = getTransaction(); @@ -45,7 +44,7 @@ public class MySqlUserModuleImpl extends AbstractModuleImpl { //TODO: Needs better implementation Query qDatabaseUsers = em.createQuery("SELECT obj FROM DatabaseUser obj WHERE obj.pac.id = :pacId"); qDatabaseUsers.setParameter("pacId", pac.getId()); - if (qDatabaseUsers.getResultList().size() >= DBUSERS_PER_MULTI_OPTION * pac.getQuantityByComponentName("MULTI")) { + if (qDatabaseUsers.getResultList().size() >= MultiOption.DATABASEUSERS_PER_OPTION * pac.getQuantityByComponentName("MULTI")) { throw new HSAdminException("included database users exceeded"); } user.setPac(pac); diff --git a/hsarback/src/de/hsadmin/mods/db/PgSqlDatabaseModuleImpl.java b/hsarback/src/de/hsadmin/mods/db/PgSqlDatabaseModuleImpl.java index 2fbb045..fd165a4 100644 --- a/hsarback/src/de/hsadmin/mods/db/PgSqlDatabaseModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/db/PgSqlDatabaseModuleImpl.java @@ -10,13 +10,12 @@ import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.model.Transaction; +import de.hsadmin.hostsharing.MultiOption; import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.user.UnixUser; public class PgSqlDatabaseModuleImpl extends AbstractModuleImpl { - private static final int DBS_PER_MULTI_OPTION = 25; - @Override public List search(Class entityClass, String condition, String orderBy) throws HSAdminException { if (orderBy == null || orderBy.length() == 0) { @@ -63,7 +62,7 @@ public class PgSqlDatabaseModuleImpl extends AbstractModuleImpl { //TODO: Needs better implementation Query qDatabases = em.createQuery("SELECT obj FROM Database obj WHERE obj.pac.id = :pacId"); qDatabases.setParameter("pacId", pac.getId()); - if (qDatabases.getResultList().size() >= DBS_PER_MULTI_OPTION * pac.getQuantityByComponentName("MULTI")) { + if (qDatabases.getResultList().size() >= MultiOption.DATABASES_PER_OPTION * pac.getQuantityByComponentName("MULTI")) { throw new HSAdminException("included databases exceeded"); } database.setPac(pac); diff --git a/hsarback/src/de/hsadmin/mods/db/PgSqlUserModuleImpl.java b/hsarback/src/de/hsadmin/mods/db/PgSqlUserModuleImpl.java index db7df69..802efe0 100644 --- a/hsarback/src/de/hsadmin/mods/db/PgSqlUserModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/db/PgSqlUserModuleImpl.java @@ -9,13 +9,12 @@ import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.HSAdminException; +import de.hsadmin.hostsharing.MultiOption; import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.user.UnixUser; public class PgSqlUserModuleImpl extends AbstractModuleImpl { - private static final int DBUSERS_PER_MULTI_OPTION = 5; - @Override public AbstractEntity add(AbstractEntity newEntity) throws HSAdminException { UnixUser loginUser = getTransaction().getLoginUser(); @@ -40,7 +39,7 @@ public class PgSqlUserModuleImpl extends AbstractModuleImpl { //TODO: Needs better implementation Query qDatabaseUsers = em.createQuery("SELECT obj FROM DatabaseUser obj WHERE obj.pac.id = :pacId"); qDatabaseUsers.setParameter("pacId", pac.getId()); - if (qDatabaseUsers.getResultList().size() >= DBUSERS_PER_MULTI_OPTION * pac.getQuantityByComponentName("MULTI")) { + if (qDatabaseUsers.getResultList().size() >= MultiOption.DATABASEUSERS_PER_OPTION * pac.getQuantityByComponentName("MULTI")) { throw new HSAdminException("included database users exceeded"); } user.setPac(pac); diff --git a/hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java b/hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java index 1cb4fb0..0587de2 100644 --- a/hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/email/EMailAliasModuleImpl.java @@ -10,13 +10,12 @@ import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.AuthorisationException; import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.model.Transaction; +import de.hsadmin.hostsharing.MultiOption; import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.user.UnixUser; public class EMailAliasModuleImpl extends AbstractModuleImpl { - private static final int UNIXUSERS_PER_MULTI_OPTION = 250; - @Override public List search(Class entityClass, String condition, String orderBy) throws HSAdminException { @@ -56,7 +55,7 @@ public class EMailAliasModuleImpl extends AbstractModuleImpl { qEmailAliases.setParameter("pacId", pac.getId()); Query qEmailAddresses = em.createQuery("SELECT obj FROM EMailAddresses obj WHERE obj.domain.user.pac.id = :pacId"); qEmailAddresses.setParameter("pacId", pac.getId()); - if (qEmailAliases.getResultList().size() + qEmailAddresses.getResultList().size() >= UNIXUSERS_PER_MULTI_OPTION * pac.getQuantityByComponentName("MULTI")) { + if (qEmailAliases.getResultList().size() + qEmailAddresses.getResultList().size() >= MultiOption.EMAIL_ITEMS_PER_OPTION * pac.getQuantityByComponentName("MULTI")) { throw new HSAdminException("included email addresses/aliases exceeded"); } alias.setPac(pac); diff --git a/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java b/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java index 28c014b..a8c2c20 100644 --- a/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java +++ b/hsarback/src/de/hsadmin/mods/user/UnixUserModuleImpl.java @@ -11,12 +11,11 @@ import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractModuleImpl; import de.hsadmin.core.model.HSAdminException; import de.hsadmin.core.model.Transaction; +import de.hsadmin.hostsharing.MultiOption; import de.hsadmin.mods.pac.Pac; public class UnixUserModuleImpl extends AbstractModuleImpl { - private static final int UNIXUSERS_PER_MULTI_OPTION = 50; - public UnixUserModuleImpl() { } @@ -135,7 +134,7 @@ public class UnixUserModuleImpl extends AbstractModuleImpl { //TODO: Needs better implementation Query qUnixUsers = em.createQuery("SELECT obj FROM UnixUsers obj WHERE obj.id = :pacId"); qUnixUsers.setParameter("pacId", pac.getId()); - if (qUnixUsers.getResultList().size() >= UNIXUSERS_PER_MULTI_OPTION * pac.getQuantityByComponentName("MULTI")) { + if (qUnixUsers.getResultList().size() >= MultiOption.UNIXUSERS_PER_OPTION * pac.getQuantityByComponentName("MULTI")) { throw new HSAdminException("included unix users exceeded"); } // don't move this up, it will update the new entity still with wrong