Domain createprocessor works with domainoptions
This commit is contained in:
parent
a1d97ed10f
commit
b9f140d19d
@ -1,6 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<classpath>
|
<classpath>
|
||||||
<classpathentry kind="src" path="src"/>
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="src" path="test"/>
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||||
<classpathentry kind="lib" path="lib/activemq-core-5.4.2.jar"/>
|
<classpathentry kind="lib" path="lib/activemq-core-5.4.2.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/commons-beanutils-1.8.3.jar"/>
|
<classpathentry kind="lib" path="lib/commons-beanutils-1.8.3.jar"/>
|
||||||
@ -26,5 +27,6 @@
|
|||||||
<classpathentry kind="lib" path="lib/xmlrpc-client-3.1.3.jar"/>
|
<classpathentry kind="lib" path="lib/xmlrpc-client-3.1.3.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/xmlrpc-common-3.1.3.jar"/>
|
<classpathentry kind="lib" path="lib/xmlrpc-common-3.1.3.jar"/>
|
||||||
<classpathentry kind="lib" path="lib/xmlrpc-server-3.1.3.jar"/>
|
<classpathentry kind="lib" path="lib/xmlrpc-server-3.1.3.jar"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
2
hsarback/.gitignore
vendored
Normal file
2
hsarback/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/build
|
||||||
|
/webapp
|
@ -1,20 +1,31 @@
|
|||||||
package de.hsadmin.core.qserv;
|
package de.hsadmin.core.qserv;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class CreateFileProcessor extends AbstractProcessor {
|
public class CreateFileProcessor extends AbstractProcessor {
|
||||||
|
|
||||||
private static final long serialVersionUID = -2947609532975712444L;
|
private static final long serialVersionUID = -2947609532975712444L;
|
||||||
|
|
||||||
private CompoundProcessor compoundProcessor;
|
private Processor compoundProcessor;
|
||||||
|
|
||||||
public CreateFileProcessor(String templateName, Map<String, String> templateValues, String targetPath, String owner, String group, String modeMask, boolean overwriteTarget) throws ProcessorException {
|
public CreateFileProcessor(String templateName, Map<String, String> templateValues, String targetPath, String owner, String group, String modeMask, boolean overwriteTarget) throws ProcessorException {
|
||||||
TemplateProcessor templateProcessor = new TemplateProcessor(templateName, templateValues, targetPath, overwriteTarget);
|
TemplateProcessor templateProcessor = new TemplateProcessor(templateName, templateValues, targetPath, overwriteTarget);
|
||||||
|
compoundProcessor = createCompound(targetPath, owner, group, modeMask, templateProcessor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CreateFileProcessor(String templateName, Map<String, String> templateValues, Iterator<Map<String, String>> iterateValues, String targetPath, String owner, String group, String modeMask, boolean overwriteTarget) throws ProcessorException {
|
||||||
|
TemplateProcessor templateProcessor = new TemplateProcessor(templateName, templateValues, iterateValues, targetPath, overwriteTarget);
|
||||||
|
compoundProcessor = createCompound(targetPath, owner, group, modeMask, templateProcessor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Processor createCompound(String targetPath, String owner, String group,
|
||||||
|
String modeMask, TemplateProcessor templateProcessor) {
|
||||||
ShellProcessor shellProcessor =
|
ShellProcessor shellProcessor =
|
||||||
new ShellProcessor(
|
new ShellProcessor(
|
||||||
"chown " + owner + ":" + group + " " + targetPath + " && " +
|
"chown " + owner + ":" + group + " " + targetPath + " && " +
|
||||||
"chmod " + modeMask + " " + targetPath);
|
"chmod " + modeMask + " " + targetPath);
|
||||||
compoundProcessor = new CompoundProcessor(templateProcessor, shellProcessor);
|
return new CompoundProcessor(templateProcessor, shellProcessor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -66,7 +66,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
templateVars.put("DOM_IPNUMBEREX", getOldIPAddress(pac));
|
templateVars.put("DOM_IPNUMBEREX", getOldIPAddress(pac));
|
||||||
templateVars.put("DOMAIN", domName);
|
templateVars.put("DOMAIN", domName);
|
||||||
templateVars.put("USER_NAME", domUser.getComment());
|
templateVars.put("USER_NAME", domUser.getComment());
|
||||||
mainProcessor.appendProcessor(hiveName, createApacheVHostSetupProcessor(dom, templateVars), "Setup Apache VHost");
|
mainProcessor.appendProcessor(hiveName, createApacheVHostSetupProcessor(em, dom, templateVars), "Setup Apache VHost");
|
||||||
if (dom.isPacDomain()) {
|
if (dom.isPacDomain()) {
|
||||||
mainProcessor.appendProcessor(hiveName, createMovePacDomainContent(em, dom), "Move pac domain content");
|
mainProcessor.appendProcessor(hiveName, createMovePacDomainContent(em, dom), "Move pac domain content");
|
||||||
}
|
}
|
||||||
@ -167,14 +167,18 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
ArrayList<Map<String, String>> domsMaps = new ArrayList<Map<String, String>>();
|
ArrayList<Map<String, String>> domsMaps = new ArrayList<Map<String, String>>();
|
||||||
Query query = em.createQuery("SELECT d FROM Domains d WHERE d.domainoptions.name = :option");
|
Query query = em.createQuery("SELECT d FROM Domains d WHERE d.domainoptions.name = :option");
|
||||||
query.setParameter("option", "nogreylisting");
|
query.setParameter("option", "nogreylisting");
|
||||||
List<Domain> result = query.getResultList();
|
List<?> result = query.getResultList();
|
||||||
for (Domain dom : result) {
|
for (Object dom : result) {
|
||||||
|
if (dom instanceof Domain) {
|
||||||
HashMap<String, String> hashMap = new HashMap<String, String>();
|
HashMap<String, String> hashMap = new HashMap<String, String>();
|
||||||
|
hashMap.put("DOM", ((Domain) dom).getName());
|
||||||
domsMaps.add(hashMap);
|
domsMaps.add(hashMap);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return new CompoundProcessor(
|
return new CompoundProcessor(
|
||||||
new TemplateProcessor("/de/hdsadmin/mods/dom/postgrey-whitelist-recipients.jtpl",
|
new TemplateProcessor("/de/hsadmin/mods/dom/postgrey-whitelist-recipients.jtpl",
|
||||||
hashMap, domsMaps.iterator(), "/etc/postgeay/whitelist_recipients", true),
|
new HashMap<String, String>(),
|
||||||
|
domsMaps.iterator(), "/etc/postgrey/whitelist_recipients", true),
|
||||||
new ShellProcessor("invoke-rc.d postgrey reload"),
|
new ShellProcessor("invoke-rc.d postgrey reload"),
|
||||||
new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains",
|
new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains",
|
||||||
domName + " anything\n" +
|
domName + " anything\n" +
|
||||||
@ -263,12 +267,20 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
return domDirsProcessor;
|
return domDirsProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Processor createApacheVHostSetupProcessor(Domain dom, Map<String, String> templateVars)
|
private Processor createApacheVHostSetupProcessor(EntityManager em, Domain dom, Map<String, String> templateVars)
|
||||||
throws ProcessorException {
|
throws ProcessorException {
|
||||||
String domName = dom.getName();
|
String domName = dom.getName();
|
||||||
int level = domName.split("\\.").length;
|
int level = domName.split("\\.").length;
|
||||||
String linkPrefix = Integer.toString(100 - level);
|
String linkPrefix = Integer.toString(100 - level);
|
||||||
String pac = dom.getUser().getPac().getName();
|
String pac = dom.getUser().getPac().getName();
|
||||||
|
Query query = em.createQuery("SELECT d FROM Domains d WHERE d.domainoptions.name = :option AND d.name = :domname");
|
||||||
|
query.setParameter("option", "nohtdocsfallback");
|
||||||
|
query.setParameter("domname", dom.getName());
|
||||||
|
List<?> result = query.getResultList();
|
||||||
|
List<Map<String, String>> iterateMaps = new ArrayList<Map<String, String>>();
|
||||||
|
if (!result.isEmpty()) {
|
||||||
|
iterateMaps.add(new HashMap<String, String>());
|
||||||
|
}
|
||||||
Processor domSetupProcessor = new CompoundProcessor(
|
Processor domSetupProcessor = new CompoundProcessor(
|
||||||
createDomainDirectoriesProcessor(dom, templateVars),
|
createDomainDirectoriesProcessor(dom, templateVars),
|
||||||
new CreateFileProcessor(selectVHostTemplate(dom), templateVars, "/etc/apache2/sites-available/" + domName, "root", "root", "644", true),
|
new CreateFileProcessor(selectVHostTemplate(dom), templateVars, "/etc/apache2/sites-available/" + domName, "root", "root", "644", true),
|
||||||
|
@ -38,13 +38,13 @@
|
|||||||
RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} -d
|
RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} -d
|
||||||
RewriteRule ^(.*) /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1}$1 [last]
|
RewriteRule ^(.*) /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1}$1 [last]
|
||||||
|
|
||||||
<!-- BEGIN: nosubdomainfallbackforhttp --> RewriteCond %{REQUEST_URI} !^/cgi-bin/
|
<!-- BEGIN: iterate --> RewriteCond %{REQUEST_URI} !^/cgi-bin/
|
||||||
RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
|
RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
|
||||||
RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:80)?$ [novary]
|
RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:80)?$ [novary]
|
||||||
RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} !-d
|
RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} !-d
|
||||||
RewriteRule ^(.*) - [redirect=404,last]
|
RewriteRule ^(.*) - [redirect=404,last]
|
||||||
|
<!-- END: iterate -->
|
||||||
<!-- END: nosubdomainfallbackforhttp --> 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
|
||||||
|
|
||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
@ -31,11 +31,11 @@
|
|||||||
RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} -d
|
RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} -d
|
||||||
RewriteRule ^(.*) /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1}$1 [last]
|
RewriteRule ^(.*) /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1}$1 [last]
|
||||||
|
|
||||||
<!-- BEGIN: nosubdomainfallbackforhttp --> RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:80)?$ [novary]
|
<!-- BEGIN: iterate --> RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:80)?$ [novary]
|
||||||
RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} !-d
|
RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} !-d
|
||||||
RewriteRule ^(.*) - [redirect=404,last]
|
RewriteRule ^(.*) - [redirect=404,last]
|
||||||
|
<!-- END: iterate -->
|
||||||
<!-- END: nosubdomainfallbackforhttp --></VirtualHost>
|
</VirtualHost>
|
||||||
|
|
||||||
<VirtualHost {DOM_IPNUMBER}:443 {DOM_IPNUMBEREX}:443>
|
<VirtualHost {DOM_IPNUMBER}:443 {DOM_IPNUMBEREX}:443>
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ public class DomainTest {
|
|||||||
Map<String, Object> setParams = new HashMap<String, Object>();
|
Map<String, Object> setParams = new HashMap<String, Object>();
|
||||||
Map<String, String> whereParams = new HashMap<String, String>();
|
Map<String, String> whereParams = new HashMap<String, String>();
|
||||||
List<String> optionslist = new ArrayList<String>();
|
List<String> optionslist = new ArrayList<String>();
|
||||||
optionslist.add("greylisting");
|
optionslist.add("nogreylisting");
|
||||||
setParams.put("domainoptions", optionslist);
|
setParams.put("domainoptions", optionslist);
|
||||||
whereParams.put("name", "example01.org");
|
whereParams.put("name", "example01.org");
|
||||||
Object[] params = new Object[] { user,
|
Object[] params = new Object[] { user,
|
||||||
@ -176,8 +176,8 @@ public class DomainTest {
|
|||||||
Map<String, Object> setParams = new HashMap<String, Object>();
|
Map<String, Object> setParams = new HashMap<String, Object>();
|
||||||
Map<String, String> whereParams = new HashMap<String, String>();
|
Map<String, String> whereParams = new HashMap<String, String>();
|
||||||
List<String> optionslist = new ArrayList<String>();
|
List<String> optionslist = new ArrayList<String>();
|
||||||
optionslist.add("htdocsfallback");
|
optionslist.add("nohtdocsfallback");
|
||||||
optionslist.add("greylisting");
|
optionslist.add("nogreylisting");
|
||||||
setParams.put("domainoptions", optionslist);
|
setParams.put("domainoptions", optionslist);
|
||||||
whereParams.put("name", "example01.org");
|
whereParams.put("name", "example01.org");
|
||||||
Object[] params = new Object[] { user,
|
Object[] params = new Object[] { user,
|
||||||
|
Loading…
Reference in New Issue
Block a user