move basepac names to hostsharing package

This commit is contained in:
Peter Hormanns 2013-05-23 12:26:15 +02:00
parent fa1c46949f
commit d305c64646
17 changed files with 52 additions and 37 deletions

View File

@ -0,0 +1,10 @@
package de.hsadmin.hostsharing;
public class BasePacType {
public static final String PAC_DW = "PAC/DW";
public static final String PAC_SW = "PAC/SW";
public static final String PAC_WEB = "PAC/WEB";
public static final String PAC_SRV = "SRV/MGD";
}

View File

@ -10,6 +10,7 @@ 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.BasePacType;
import de.hsadmin.hostsharing.MultiOption;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser;
@ -57,7 +58,7 @@ public class MySqlDatabaseModuleImpl extends AbstractModuleImpl {
}
//TODO: Needs better implementation
String pacType = pac.getBasepac().getName();
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW)) {
if (!pacType.equals(BasePacType.PAC_WEB) && !pacType.equals(BasePacType.PAC_DW)) {
throw new HSAdminException("not allowed for this packet type");
}
//TODO: Needs better implementation

View File

@ -10,6 +10,7 @@ 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.BasePacType;
import de.hsadmin.hostsharing.MultiOption;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser;
@ -38,7 +39,7 @@ public class MySqlUserModuleImpl extends AbstractModuleImpl {
}
//TODO: Needs better implementation
String pacType = pac.getBasepac().getName();
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW)) {
if (!pacType.equals(BasePacType.PAC_WEB) && !pacType.equals(BasePacType.PAC_DW)) {
throw new HSAdminException("not allowed for this packet type");
}
//TODO: Needs better implementation

View File

@ -10,6 +10,7 @@ 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.BasePacType;
import de.hsadmin.hostsharing.MultiOption;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser;
@ -56,7 +57,7 @@ public class PgSqlDatabaseModuleImpl extends AbstractModuleImpl {
}
//TODO: Needs better implementation
String pacType = pac.getBasepac().getName();
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW)) {
if (!pacType.equals(BasePacType.PAC_WEB) && !pacType.equals(BasePacType.PAC_DW)) {
throw new HSAdminException("not allowed for this packet type");
}
//TODO: Needs better implementation

View File

@ -9,6 +9,7 @@ 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.BasePacType;
import de.hsadmin.hostsharing.MultiOption;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser;
@ -33,7 +34,7 @@ public class PgSqlUserModuleImpl extends AbstractModuleImpl {
}
//TODO: Needs better implementation
String pacType = pac.getBasepac().getName();
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW)) {
if (!pacType.equals(BasePacType.PAC_WEB) && !pacType.equals(BasePacType.PAC_DW)) {
throw new HSAdminException("not allowed for this packet type");
}
//TODO: Needs better implementation

View File

@ -25,7 +25,7 @@ import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AnnFieldIO;
import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.core.model.ReadWriteAccess;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.mods.user.UnixUser;
@Entity(name = "Domains")
@ -183,7 +183,7 @@ public class Domain extends AbstractEntity {
public boolean isDynamic() {
String basepacName = getUser().getPac().getBasepac().getName();
return isPacDomain() || basepacName.equals(Pac.PAC_DW) || basepacName.equals(Pac.PAC_WEB);
return isPacDomain() || basepacName.equals(BasePacType.PAC_DW) || basepacName.equals(BasePacType.PAC_WEB);
}
public boolean isStatic() {

View File

@ -13,6 +13,7 @@ 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.BasePacType;
import de.hsadmin.mods.email.EMailAddress;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser;
@ -108,7 +109,7 @@ public class DomainModuleImpl extends AbstractModuleImpl {
admin = (UnixUser) userQuery.getSingleResult();
//TODO: Needs better implementation
String pacType = admin.getPac().getBasepac().getName();
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW) && !pacType.equals(Pac.PAC_SW)) {
if (!pacType.equals(BasePacType.PAC_WEB) && !pacType.equals(BasePacType.PAC_DW) && !pacType.equals(BasePacType.PAC_SW)) {
throw new HSAdminException("not allowed for this packet type");
}
// Standard domainoptions setzen. TODO: Alle defaults über eigene Klasse aus der Datenbank holen.

View File

@ -10,8 +10,8 @@ import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.Transaction;
import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.mods.dom.Domain;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser;
public class EMailAddressModuleImpl extends AbstractModuleImpl {
@ -56,7 +56,7 @@ public class EMailAddressModuleImpl extends AbstractModuleImpl {
}
//TODO: Needs better implementation
String pacType = dom.getUser().getPac().getBasepac().getName();
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW) && !pacType.equals(Pac.PAC_SW)) {
if (!pacType.equals(BasePacType.PAC_WEB) && !pacType.equals(BasePacType.PAC_DW) && !pacType.equals(BasePacType.PAC_SW)) {
throw new HSAdminException("not allowed for this packet type");
}
//TODO: Needs better implementation

View File

@ -10,6 +10,7 @@ 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.BasePacType;
import de.hsadmin.hostsharing.MultiOption;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.mods.user.UnixUser;
@ -47,7 +48,7 @@ public class EMailAliasModuleImpl extends AbstractModuleImpl {
}
//TODO: Needs better implementation
String pacType = pac.getBasepac().getName();
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW) && !pacType.equals(Pac.PAC_SW)) {
if (!pacType.equals(BasePacType.PAC_WEB) && !pacType.equals(BasePacType.PAC_DW) && !pacType.equals(BasePacType.PAC_SW)) {
throw new HSAdminException("not allowed for this packet type");
}
//TODO: Needs better implementation

View File

@ -26,6 +26,7 @@ import javax.persistence.TemporalType;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AnnModuleImpl;
import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.mods.cust.Customer;
import de.hsadmin.mods.user.UnixUser;
@ -39,11 +40,6 @@ public class Pac extends AbstractEntity implements Serializable {
public static final int UNDEFINED_QUANTITY = -1;
public static final String PAC_DW = "PAC/DW";
public static final String PAC_SW = "PAC/SW";
public static final String PAC_WEB = "PAC/WEB";
public static final String PAC_SRV = "SRV/MGD";
@Id
@GeneratedValue(strategy = SEQUENCE, generator = "PacsSeqGen")
@Column(name = "packet_id", columnDefinition = "integer")
@ -290,11 +286,11 @@ public class Pac extends AbstractEntity implements Serializable {
public boolean isDynamic() {
String basepacName = getBasepac().getName();
return PAC_DW.equals(basepacName) || PAC_WEB.equals(basepacName);
return BasePacType.PAC_DW.equals(basepacName) || BasePacType.PAC_WEB.equals(basepacName);
}
public boolean isManagedServer() {
String basepacName = getBasepac().getName();
return PAC_SRV.equals(basepacName);
return BasePacType.PAC_SRV.equals(basepacName);
}
}

View File

@ -16,6 +16,7 @@ import de.hsadmin.core.model.AuthorisationException;
import de.hsadmin.core.model.GenericModuleImpl;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.util.TextUtil;
import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.mods.cust.Contact;
import de.hsadmin.mods.cust.Customer;
import de.hsadmin.mods.dom.Domain;
@ -94,7 +95,7 @@ public class PacModuleImpl extends AbstractModuleImpl {
pac.setPacComponents(pacComponents);
AbstractEntity newPacEntity = null;
String pacType = pac.getBasepac().getName();
if (pacType.equals(Pac.PAC_WEB) || pacType.equals(Pac.PAC_DW) || pacType.equals(Pac.PAC_SW)) {
if (pacType.equals(BasePacType.PAC_WEB) || pacType.equals(BasePacType.PAC_DW) || pacType.equals(BasePacType.PAC_SW)) {
Set<UnixUser> users = new HashSet<UnixUser>();
pac.setUnixUser(users);
UnixUser admin = new UnixUser();
@ -196,7 +197,7 @@ public class PacModuleImpl extends AbstractModuleImpl {
throw new AuthorisationException(getTransaction().getLoginUser(), "delete", existingEntity);
}
String pacType = pac.getBasepac().getName();
if (pacType.equals(Pac.PAC_WEB) || pacType.equals(Pac.PAC_DW) || pacType.equals(Pac.PAC_SW)) {
if (pacType.equals(BasePacType.PAC_WEB) || pacType.equals(BasePacType.PAC_DW) || pacType.equals(BasePacType.PAC_SW)) {
GenericModuleImpl helperModule = new GenericModuleImpl(getTransaction());
String[] dependQueries = new String[] {

View File

@ -15,6 +15,7 @@ import de.hsadmin.core.qserv.ShellProcessor;
import de.hsadmin.core.qserv.VelocityProcessor;
import de.hsadmin.core.qserv.WaitingTasksProcessor;
import de.hsadmin.core.util.PasswordTool;
import de.hsadmin.hostsharing.BasePacType;
import de.hsadmin.mods.user.UnixUser;
@ -25,7 +26,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
EntityManager em, T entity) throws ProcessorException {
Pac pac = (Pac) entity;
String basepacName = pac.getBasepac().getName();
if (basepacName.equals(Pac.PAC_WEB) || basepacName.equals(Pac.PAC_DW) || basepacName.equals(Pac.PAC_SW)) {
if (basepacName.equals(BasePacType.PAC_WEB) || basepacName.equals(BasePacType.PAC_DW) || basepacName.equals(BasePacType.PAC_SW)) {
String pacName = pac.getName();
Hive hive = pac.getHive();
UnixUser unixUser = getPacAdminUser(pac);
@ -79,7 +80,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
throws ProcessorException {
Pac pac = (Pac) entity;
String basepacName = pac.getBasepac().getName();
if (basepacName.equals(Pac.PAC_WEB) || basepacName.equals(Pac.PAC_DW) || basepacName.equals(Pac.PAC_SW)) {
if (basepacName.equals(BasePacType.PAC_WEB) || basepacName.equals(BasePacType.PAC_DW) || basepacName.equals(BasePacType.PAC_SW)) {
return createSetQuotaProc(pac);
} else {
return new NullProcessor();
@ -90,7 +91,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) throws ProcessorException {
Pac pac = (Pac) entity;
String basepacName = pac.getBasepac().getName();
if (basepacName.equals(Pac.PAC_WEB) || basepacName.equals(Pac.PAC_DW) || basepacName.equals(Pac.PAC_SW)) {
if (basepacName.equals(BasePacType.PAC_WEB) || basepacName.equals(BasePacType.PAC_DW) || basepacName.equals(BasePacType.PAC_SW)) {
Hive hive = pac.getHive();
WaitingTasksProcessor waiting = new WaitingTasksProcessor(createDelUserProc(pac.getName()));
waiting.appendProcessor(pac.getHiveName(), new CompoundProcessor(

View File

@ -11,6 +11,7 @@ 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.BasePacType;
import de.hsadmin.hostsharing.MultiOption;
import de.hsadmin.mods.pac.Pac;
@ -128,7 +129,7 @@ public class UnixUserModuleImpl extends AbstractModuleImpl {
}
//TODO: Needs better implementation
String pacType = pac.getBasepac().getName();
if (!pacType.equals(Pac.PAC_WEB) && !pacType.equals(Pac.PAC_DW) && !pacType.equals(Pac.PAC_SW)) {
if (!pacType.equals(BasePacType.PAC_WEB) && !pacType.equals(BasePacType.PAC_DW) && !pacType.equals(BasePacType.PAC_SW)) {
throw new HSAdminException("not allowed for this packet type");
}
//TODO: Needs better implementation

View File

@ -13,7 +13,7 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.hostsharing.BasePacType;
public class InitDataTest {
@ -79,7 +79,7 @@ public class InitDataTest {
setParams.put("name", "aaa00");
setParams.put("hive", "h99");
setParams.put("customer", "hsh00-aaa");
setParams.put("basepac", Pac.PAC_WEB);
setParams.put("basepac", BasePacType.PAC_WEB);
setParams.put("curinetaddr", "176.9.242.74");
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),

View File

@ -15,7 +15,7 @@ import org.junit.Before;
import org.junit.Test;
import de.hsadmin.core.util.Config;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.hostsharing.BasePacType;
public class PacMigrationTest {
@ -47,7 +47,7 @@ public class PacMigrationTest {
setParams.put("name", "aaa04");
setParams.put("hive", "h99");
setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
setParams.put("basepac", Pac.PAC_DW);
setParams.put("basepac", BasePacType.PAC_DW);
setParams.put("curinetaddr", "176.9.242.77");
HashMap<String, String> components = new HashMap<String, String>();
components.put("QUOTA", "640");
@ -73,7 +73,7 @@ public class PacMigrationTest {
assertTrue(untypedResultArray[0] instanceof Map<?,?>);
@SuppressWarnings("unchecked")
Map<String, ?> pacResultMap = (Map<String, ?>) untypedResultArray[0];
assertEquals(Pac.PAC_DW, pacResultMap.get("basepac"));
assertEquals(BasePacType.PAC_DW, pacResultMap.get("basepac"));
Object compMapObj = pacResultMap.get("components");
assertTrue(compMapObj instanceof Map<?,?>);
@SuppressWarnings("unchecked")
@ -104,7 +104,7 @@ public class PacMigrationTest {
String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, Object> setParams = new HashMap<String, Object>();
Map<String, String> components = new HashMap<String, String>();
setParams.put("basepac", Pac.PAC_WEB);
setParams.put("basepac", BasePacType.PAC_WEB);
setParams.put("components", components);
// components.put("QUOTA", "2048"); // does not work till now
Map<String, String> whereParams = new HashMap<String, String>();
@ -126,7 +126,7 @@ public class PacMigrationTest {
assertTrue(untypedResultArray[0] instanceof Map<?,?>);
@SuppressWarnings("unchecked")
Map<String, ?> pacResultMap = (Map<String, ?>) untypedResultArray[0];
assertEquals(Pac.PAC_WEB, pacResultMap.get("basepac"));
assertEquals(BasePacType.PAC_WEB, pacResultMap.get("basepac"));
Object compMapObj = pacResultMap.get("components");
assertTrue(compMapObj instanceof Map<?,?>);
@SuppressWarnings("unchecked")

View File

@ -15,7 +15,7 @@ import org.junit.Before;
import org.junit.Test;
import de.hsadmin.core.util.Config;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.hostsharing.BasePacType;
public class PacTest {
@ -131,7 +131,7 @@ public class PacTest {
assertTrue(untypedResultArray[0] instanceof Map<?,?>);
@SuppressWarnings("unchecked")
Map<String, ?> pacResultMap = (Map<String, ?>) untypedResultArray[0];
assertEquals(Pac.PAC_WEB, pacResultMap.get("basepac"));
assertEquals(BasePacType.PAC_WEB, pacResultMap.get("basepac"));
Object compMapObj = pacResultMap.get("components");
assertTrue(compMapObj instanceof Map<?,?>);
@SuppressWarnings("unchecked")
@ -153,7 +153,7 @@ public class PacTest {
setParams.put("name", "aaa01");
setParams.put("hive", "h99");
setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
setParams.put("basepac", Pac.PAC_WEB);
setParams.put("basepac", BasePacType.PAC_WEB);
setParams.put("curinetaddr", "176.9.242.76");
HashMap<String, String> components = new HashMap<String, String>();
components.put("QUOTA", "512");
@ -193,7 +193,7 @@ public class PacTest {
setParams.put("name", "aaa90");
setParams.put("hive", "h99");
setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
setParams.put("basepac", Pac.PAC_SRV);
setParams.put("basepac", BasePacType.PAC_SRV);
setParams.put("curinetaddr", "176.9.242.76");
setParams.put("free", "true");
Object[] params = new Object[] { user,

View File

@ -15,7 +15,7 @@ import org.junit.Test;
import de.hsadmin.core.qserv.CommandShell;
import de.hsadmin.core.qserv.ShellException;
import de.hsadmin.core.util.Config;
import de.hsadmin.mods.pac.Pac;
import de.hsadmin.hostsharing.BasePacType;
public class SSLCertDomainTest {
@ -47,7 +47,7 @@ public class SSLCertDomainTest {
setParams.put("name", "aaa02");
setParams.put("hive", "h99");
setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
setParams.put("basepac", Pac.PAC_WEB);
setParams.put("basepac", BasePacType.PAC_WEB);
setParams.put("curinetaddr", "176.9.242.77");
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
@ -78,7 +78,7 @@ public class SSLCertDomainTest {
setParams.put("name", "aaa03");
setParams.put("hive", "h99");
setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
setParams.put("basepac", Pac.PAC_DW);
setParams.put("basepac", BasePacType.PAC_DW);
setParams.put("curinetaddr", "176.9.242.78");
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),