Exit pac processor factory when processing "unknown" pac types.
Renamed DW/B and SW/B to PAC/DB and PAC/SW. Introduced new pac type PAC/WEB. Fixed tests.
This commit is contained in:
parent
e9fd3e2170
commit
953f0320d2
@ -180,4 +180,13 @@ public class Domain extends AbstractEntity {
|
|||||||
this.domainoptions = domainOptions;
|
this.domainoptions = domainOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDynamic() {
|
||||||
|
String pacType = getUser().getPac().getBasepac().getName();
|
||||||
|
return isPacDomain() || (pacType == "PAC/WEB") || (pacType == "PAC/DW");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isStatic() {
|
||||||
|
return !isDynamic();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,12 @@ import de.hsadmin.mods.pac.Pac;
|
|||||||
import de.hsadmin.mods.user.UnixUser;
|
import de.hsadmin.mods.user.UnixUser;
|
||||||
|
|
||||||
public class DomainProcessorFactory implements EntityProcessorFactory {
|
public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||||
|
|
||||||
private static final String[] DW_STRUCTURE = new String[] {
|
private static final String[] DYNAMIC_STRUCTURE = new String[] {
|
||||||
"htdocs", "htdocs-ssl", "subs", "subs/www", "subs-ssl", "subs-ssl/www", "cgi", "fastcgi", "cgi-ssl", "fastcgi-ssl", "etc", "var"
|
"htdocs", "htdocs-ssl", "subs", "subs/www", "subs-ssl", "subs-ssl/www", "cgi", "fastcgi", "cgi-ssl", "fastcgi-ssl", "etc", "var"
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final String[] SW_STRUCTURE = new String[] {
|
private static final String[] STATIC_STRUCTURE = new String[] {
|
||||||
"htdocs", "htdocs-ssl", "subs", "subs/www", "subs-ssl", "subs-ssl/www", "etc", "var"
|
"htdocs", "htdocs-ssl", "subs", "subs/www", "subs-ssl", "subs-ssl/www", "etc", "var"
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -205,13 +205,12 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
UnixUser domUser = dom.getUser();
|
UnixUser domUser = dom.getUser();
|
||||||
String domName = dom.getName();
|
String domName = dom.getName();
|
||||||
Pac pac = domUser.getPac();
|
Pac pac = domUser.getPac();
|
||||||
boolean dynamicWeb = pac.isDynamicWeb() || dom.isPacDomain();
|
|
||||||
String pacName = pac.getName();
|
String pacName = pac.getName();
|
||||||
String homeDir = domUser.getHomedir();
|
String homeDir = domUser.getHomedir();
|
||||||
String domsDir = homeDir + "/doms";
|
String domsDir = homeDir + "/doms";
|
||||||
String userName = domUser.getName();
|
String userName = domUser.getName();
|
||||||
String domainDir = domsDir + "/" + dom.getName();
|
String domainDir = domsDir + "/" + dom.getName();
|
||||||
String[] subDirs = dynamicWeb ? DW_STRUCTURE : SW_STRUCTURE;
|
String[] subDirs = dom.isDynamic() ? DYNAMIC_STRUCTURE : STATIC_STRUCTURE;
|
||||||
String httpdRights = "";
|
String httpdRights = "";
|
||||||
if (pacName != userName) {
|
if (pacName != userName) {
|
||||||
httpdRights =
|
httpdRights =
|
||||||
@ -248,7 +247,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
domDirsProcessor.appendProcessor(
|
domDirsProcessor.appendProcessor(
|
||||||
new CreateFileProcessor("/de/hsadmin/mods/dom/index.html.vm", templateVars, dom, domainDir + "/subs-ssl/www/index.html", userName, pacName, "644", false)
|
new CreateFileProcessor("/de/hsadmin/mods/dom/index.html.vm", templateVars, dom, domainDir + "/subs-ssl/www/index.html", userName, pacName, "644", false)
|
||||||
);
|
);
|
||||||
if (dynamicWeb) {
|
if (dom.isDynamic()) {
|
||||||
domDirsProcessor.appendProcessor(
|
domDirsProcessor.appendProcessor(
|
||||||
new CreateFileProcessor("/de/hsadmin/mods/dom/test.cgi.vm", templateVars, dom, domainDir + "/cgi/test.cgi", userName, pacName, "755", false)
|
new CreateFileProcessor("/de/hsadmin/mods/dom/test.cgi.vm", templateVars, dom, domainDir + "/cgi/test.cgi", userName, pacName, "755", false)
|
||||||
);
|
);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
DocumentRoot /home/doms/${dom.name}/htdocs
|
DocumentRoot /home/doms/${dom.name}/htdocs
|
||||||
|
|
||||||
#if( ${pac.dynamicWeb} || ${dom.pacDomain} )
|
#if( ${dom.isDynamic} )
|
||||||
Alias /cgi-bin/ /home/doms/${dom.name}/cgi/
|
Alias /cgi-bin/ /home/doms/${dom.name}/cgi/
|
||||||
Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi/
|
Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi/
|
||||||
#end
|
#end
|
||||||
@ -26,7 +26,7 @@
|
|||||||
AllowOverride AuthConfig FileInfo Indexes Limit
|
AllowOverride AuthConfig FileInfo Indexes Limit
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
#if( ${pac.dynamicWeb} || ${dom.pacDomain} )
|
#if( ${dom.isDynamic} )
|
||||||
<Location /cgi-bin/>
|
<Location /cgi-bin/>
|
||||||
SetHandler cgi-script
|
SetHandler cgi-script
|
||||||
Options +ExecCGI ${includes} -Indexes -MultiViews +SymLinksIfOwnerMatch
|
Options +ExecCGI ${includes} -Indexes -MultiViews +SymLinksIfOwnerMatch
|
||||||
@ -63,7 +63,7 @@
|
|||||||
RewriteRule ^(.*) - [redirect=404,last]
|
RewriteRule ^(.*) - [redirect=404,last]
|
||||||
#end
|
#end
|
||||||
|
|
||||||
#if( ${pac.dynamicWeb} || ${dom.pacDomain} )
|
#if( ${dom.isDynamic} )
|
||||||
AddType application/x-httpd-php .php .php5 .php4 .php3
|
AddType application/x-httpd-php .php .php5 .php4 .php3
|
||||||
Action application/x-httpd-php /fastcgi-bin/phpstub
|
Action application/x-httpd-php /fastcgi-bin/phpstub
|
||||||
#end
|
#end
|
||||||
|
@ -294,10 +294,6 @@ public class Pac extends AbstractEntity implements Serializable {
|
|||||||
|| super.isReadAllowedFor(loginUser);
|
|| super.isReadAllowedFor(loginUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDynamicWeb() {
|
|
||||||
return getBasepac().getName().startsWith("DW");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String restriction() {
|
public static String restriction() {
|
||||||
return
|
return
|
||||||
// all pacs of customer
|
// all pacs of customer
|
||||||
|
@ -23,11 +23,12 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
|||||||
public <T extends AbstractEntity> Processor createCreateProcessor(
|
public <T extends AbstractEntity> Processor createCreateProcessor(
|
||||||
EntityManager em, T entity) throws ProcessorException {
|
EntityManager em, T entity) throws ProcessorException {
|
||||||
Pac pac = (Pac) entity;
|
Pac pac = (Pac) entity;
|
||||||
String pacName = pac.getName();
|
if (pac.getBasepac().getName().startsWith("PAC/")) {
|
||||||
Hive hive = pac.getHive();
|
String pacName = pac.getName();
|
||||||
UnixUser unixUser = getPacAdminUser(pac);
|
Hive hive = pac.getHive();
|
||||||
String password = PasswordTool.generatePassword();
|
UnixUser unixUser = getPacAdminUser(pac);
|
||||||
return new CompoundProcessor(
|
String password = PasswordTool.generatePassword();
|
||||||
|
return new CompoundProcessor(
|
||||||
createAddUserProc(pacName, unixUser, password),
|
createAddUserProc(pacName, unixUser, password),
|
||||||
createSetQuotaProc(pac),
|
createSetQuotaProc(pac),
|
||||||
createEtcHostsProc(hive),
|
createEtcHostsProc(hive),
|
||||||
@ -39,6 +40,9 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
|||||||
createIfUp(pacName),
|
createIfUp(pacName),
|
||||||
createHttpdVirtualProc(hive),
|
createHttpdVirtualProc(hive),
|
||||||
createAccountingRulesProc());
|
createAccountingRulesProc());
|
||||||
|
} else {
|
||||||
|
return new ShellProcessor("exit 0"); //TODO: Nothing should happen here.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Processor createAccountingRulesProc() {
|
private Processor createAccountingRulesProc() {
|
||||||
@ -72,15 +76,20 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
|||||||
public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em, T entity)
|
public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em, T entity)
|
||||||
throws ProcessorException {
|
throws ProcessorException {
|
||||||
Pac pac = (Pac) entity;
|
Pac pac = (Pac) entity;
|
||||||
return createSetQuotaProc(pac);
|
if (pac.getBasepac().getName().startsWith("PAC/")) {
|
||||||
|
return createSetQuotaProc(pac);
|
||||||
|
} else {
|
||||||
|
return new ShellProcessor("exit 0"); //TODO: Nothing should happen here.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) throws ProcessorException {
|
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) throws ProcessorException {
|
||||||
Pac pac = (Pac) entity;
|
Pac pac = (Pac) entity;
|
||||||
Hive hive = pac.getHive();
|
if (pac.getBasepac().getName().startsWith("PAC/")) {
|
||||||
WaitingTasksProcessor waiting = new WaitingTasksProcessor(createDelUserProc(pac.getName()));
|
Hive hive = pac.getHive();
|
||||||
waiting.appendProcessor(pac.getHiveName(), new CompoundProcessor(
|
WaitingTasksProcessor waiting = new WaitingTasksProcessor(createDelUserProc(pac.getName()));
|
||||||
|
waiting.appendProcessor(pac.getHiveName(), new CompoundProcessor(
|
||||||
createIfDown(pac.getName()),
|
createIfDown(pac.getName()),
|
||||||
createEtcHostsProc(hive),
|
createEtcHostsProc(hive),
|
||||||
createNetworkInterfacesProc(hive),
|
createNetworkInterfacesProc(hive),
|
||||||
@ -88,7 +97,10 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
|||||||
createProftpdConfProc(hive),
|
createProftpdConfProc(hive),
|
||||||
createHttpdVirtualProc(hive),
|
createHttpdVirtualProc(hive),
|
||||||
createAccountingRulesProc()), "remove packet");
|
createAccountingRulesProc()), "remove packet");
|
||||||
return waiting;
|
return waiting;
|
||||||
|
} else {
|
||||||
|
return new ShellProcessor("exit 0"); //TODO: Nothing should happen here.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Processor createEtcHostsProc(Hive hive) throws ProcessorException {
|
private Processor createEtcHostsProc(Hive hive) throws ProcessorException {
|
||||||
|
@ -34,11 +34,7 @@ public class RoleRemote implements IRemote {
|
|||||||
role = "HOSTMASTER";
|
role = "HOSTMASTER";
|
||||||
}
|
}
|
||||||
if (user.equals(pacName)) {
|
if (user.equals(pacName)) {
|
||||||
if (pac.isDynamicWeb()) {
|
role = "PAC_ADMIN";
|
||||||
role = "PAC_ADMIN_DW";
|
|
||||||
} else {
|
|
||||||
role = "PAC_ADMIN_SW";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (role.equals("USER")) {
|
if (role.equals("USER")) {
|
||||||
GenericModuleImpl module = new GenericModuleImpl(transaction);
|
GenericModuleImpl module = new GenericModuleImpl(transaction);
|
||||||
|
@ -69,7 +69,7 @@ public class PacProcessor {
|
|||||||
|
|
||||||
private BasePac findBasePacDW() {
|
private BasePac findBasePacDW() {
|
||||||
Query basepacQuery = entityManager.createQuery("SELECT b FROM BasePacs b WHERE b.name = :basepacName AND b.valid = :valid");
|
Query basepacQuery = entityManager.createQuery("SELECT b FROM BasePacs b WHERE b.name = :basepacName AND b.valid = :valid");
|
||||||
basepacQuery.setParameter("basepacName", "DW/B");
|
basepacQuery.setParameter("basepacName", "PAC/WEB");
|
||||||
basepacQuery.setParameter("valid", Boolean.TRUE);
|
basepacQuery.setParameter("valid", Boolean.TRUE);
|
||||||
return (BasePac) basepacQuery.getSingleResult();
|
return (BasePac) basepacQuery.getSingleResult();
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ public class InitDataTest {
|
|||||||
setParams.put("name", "aaa00");
|
setParams.put("name", "aaa00");
|
||||||
setParams.put("hive", "h99");
|
setParams.put("hive", "h99");
|
||||||
setParams.put("customer", "hsh00-aaa");
|
setParams.put("customer", "hsh00-aaa");
|
||||||
setParams.put("basepac", "DW/B");
|
setParams.put("basepac", "PAC/WEB");
|
||||||
setParams.put("curinetaddr", "176.9.242.74");
|
setParams.put("curinetaddr", "176.9.242.74");
|
||||||
Object[] params = new Object[] { user,
|
Object[] params = new Object[] { user,
|
||||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
||||||
|
@ -100,12 +100,12 @@ public class LongCustomerNameTest {
|
|||||||
pacParams.put("name", "p#");
|
pacParams.put("name", "p#");
|
||||||
pacParams.put("hive", "h99");
|
pacParams.put("hive", "h99");
|
||||||
pacParams.put("customer", customer);
|
pacParams.put("customer", customer);
|
||||||
pacParams.put("basepac", "DW/B");
|
pacParams.put("basepac", "WEB/PAC");
|
||||||
pacParams.put("curinetaddr", "176.9.242.76");
|
pacParams.put("curinetaddr", "176.9.242.76");
|
||||||
HashMap<String, String> pacComponents = new HashMap<String, String>();
|
HashMap<String, String> pacComponents = new HashMap<String, String>();
|
||||||
pacComponents.put("QUOTA", "512");
|
pacComponents.put("QUOTA", "512");
|
||||||
pacComponents.put("TRAFFIC", "8");
|
pacComponents.put("TRAFFIC", "5");
|
||||||
pacComponents.put("TOMCAT", "0");
|
pacComponents.put("DAEMON", "1");
|
||||||
pacParams.put("components", pacComponents);
|
pacParams.put("components", pacComponents);
|
||||||
Object[] pacCallBlock = new Object[] { user,
|
Object[] pacCallBlock = new Object[] { user,
|
||||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
||||||
|
@ -92,12 +92,12 @@ public class PacTest {
|
|||||||
setParams.put("name", "aaa01");
|
setParams.put("name", "aaa01");
|
||||||
setParams.put("hive", "h99");
|
setParams.put("hive", "h99");
|
||||||
setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
|
setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
|
||||||
setParams.put("basepac", "DW/B");
|
setParams.put("basepac", "PAC/WEB");
|
||||||
setParams.put("curinetaddr", "176.9.242.76");
|
setParams.put("curinetaddr", "176.9.242.76");
|
||||||
HashMap<String, String> components = new HashMap<String, String>();
|
HashMap<String, String> components = new HashMap<String, String>();
|
||||||
components.put("QUOTA", "512");
|
components.put("QUOTA", "512");
|
||||||
components.put("TRAFFIC", "8");
|
components.put("TRAFFIC", "5");
|
||||||
components.put("TOMCAT", "1");
|
components.put("DAEMON", "1");
|
||||||
setParams.put("components", components);
|
setParams.put("components", components);
|
||||||
Object[] params = new Object[] { user,
|
Object[] params = new Object[] { user,
|
||||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
||||||
|
@ -16,8 +16,8 @@ import org.junit.runners.Suite;
|
|||||||
EMailAliasTest.class,
|
EMailAliasTest.class,
|
||||||
DomainTest.class,
|
DomainTest.class,
|
||||||
EMailAddressTest.class,
|
EMailAddressTest.class,
|
||||||
|
LongCustomerNameTest.class
|
||||||
// CustomerTest.class,
|
// CustomerTest.class,
|
||||||
LongCustomerNameTest.class
|
|
||||||
// QueueTaskTest.class
|
// QueueTaskTest.class
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class RoleTest {
|
|||||||
Object[] result = (Object[]) execute;
|
Object[] result = (Object[]) execute;
|
||||||
assertTrue(result.length == 1);
|
assertTrue(result.length == 1);
|
||||||
String role = (String) ((Map<?, ?>) result[0]).get("role");
|
String role = (String) ((Map<?, ?>) result[0]).get("role");
|
||||||
assertEquals("PAC_ADMIN_DW", role);
|
assertEquals("PAC_ADMIN", role);
|
||||||
} catch (XmlRpcException e) {
|
} catch (XmlRpcException e) {
|
||||||
fail(e.getMessage());
|
fail(e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class SSLCertDomainTest {
|
|||||||
setParams.put("name", "aaa02");
|
setParams.put("name", "aaa02");
|
||||||
setParams.put("hive", "h99");
|
setParams.put("hive", "h99");
|
||||||
setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
|
setParams.put("customer", config.getProperty("accountprefix.customer") + "-aaa");
|
||||||
setParams.put("basepac", "DW/B");
|
setParams.put("basepac", "PAC/WEB");
|
||||||
setParams.put("curinetaddr", "176.9.242.77");
|
setParams.put("curinetaddr", "176.9.242.77");
|
||||||
Object[] params = new Object[] { user,
|
Object[] params = new Object[] { user,
|
||||||
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
|
||||||
|
Loading…
Reference in New Issue
Block a user