Domain createprocessor works with domainoptions
1 files added
6 files modified
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <classpath> |
| | | <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="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/xmlrpc-client-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="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> |
| | | <classpathentry kind="output" path="bin"/> |
| | | </classpath> |
| | |
| | | package de.hsadmin.core.qserv; |
| | | |
| | | import java.util.Iterator; |
| | | import java.util.Map; |
| | | |
| | | public class CreateFileProcessor extends AbstractProcessor { |
| | | |
| | | 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 { |
| | | 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 = |
| | | new ShellProcessor( |
| | | "chown " + owner + ":" + group + " " + targetPath + " && " + |
| | | "chmod " + modeMask + " " + targetPath); |
| | | compoundProcessor = new CompoundProcessor(templateProcessor, shellProcessor); |
| | | return new CompoundProcessor(templateProcessor, shellProcessor); |
| | | } |
| | | |
| | | @Override |
| | |
| | | templateVars.put("DOM_IPNUMBEREX", getOldIPAddress(pac)); |
| | | templateVars.put("DOMAIN", domName); |
| | | 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()) { |
| | | mainProcessor.appendProcessor(hiveName, createMovePacDomainContent(em, dom), "Move pac domain content"); |
| | | } |
| | |
| | | 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.setParameter("option", "nogreylisting"); |
| | | List<Domain> result = query.getResultList(); |
| | | for (Domain dom : result) { |
| | | HashMap<String, String> hashMap = new HashMap<String, String>(); |
| | | domsMaps.add(hashMap); |
| | | List<?> result = query.getResultList(); |
| | | for (Object dom : result) { |
| | | if (dom instanceof Domain) { |
| | | HashMap<String, String> hashMap = new HashMap<String, String>(); |
| | | hashMap.put("DOM", ((Domain) dom).getName()); |
| | | domsMaps.add(hashMap); |
| | | } |
| | | } |
| | | return new CompoundProcessor( |
| | | new TemplateProcessor("/de/hdsadmin/mods/dom/postgrey-whitelist-recipients.jtpl", |
| | | hashMap, domsMaps.iterator(), "/etc/postgeay/whitelist_recipients", true), |
| | | new TemplateProcessor("/de/hsadmin/mods/dom/postgrey-whitelist-recipients.jtpl", |
| | | new HashMap<String, String>(), |
| | | domsMaps.iterator(), "/etc/postgrey/whitelist_recipients", true), |
| | | new ShellProcessor("invoke-rc.d postgrey reload"), |
| | | new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains", |
| | | domName + " anything\n" + |
| | |
| | | return domDirsProcessor; |
| | | } |
| | | |
| | | private Processor createApacheVHostSetupProcessor(Domain dom, Map<String, String> templateVars) |
| | | private Processor createApacheVHostSetupProcessor(EntityManager em, Domain dom, Map<String, String> templateVars) |
| | | throws ProcessorException { |
| | | String domName = dom.getName(); |
| | | int level = domName.split("\\.").length; |
| | | String linkPrefix = Integer.toString(100 - level); |
| | | 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( |
| | | createDomainDirectoriesProcessor(dom, templateVars), |
| | | new CreateFileProcessor(selectVHostTemplate(dom), templateVars, "/etc/apache2/sites-available/" + domName, "root", "root", "644", true), |
| | |
| | | RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} -d |
| | | 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 %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:80)?$ [novary] |
| | | RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} !-d |
| | | RewriteRule ^(.*) - [redirect=404,last] |
| | | |
| | | <!-- END: nosubdomainfallbackforhttp --> AddType application/x-httpd-php .php .php5 .php4 .php3 |
| | | <!-- END: iterate --> |
| | | AddType application/x-httpd-php .php .php5 .php4 .php3 |
| | | Action application/x-httpd-php /fastcgi-bin/phpstub |
| | | |
| | | </VirtualHost> |
| | |
| | | RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} -d |
| | | 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 |
| | | RewriteRule ^(.*) - [redirect=404,last] |
| | | |
| | | <!-- END: nosubdomainfallbackforhttp --></VirtualHost> |
| | | <!-- END: iterate --> |
| | | </VirtualHost> |
| | | |
| | | <VirtualHost {DOM_IPNUMBER}:443 {DOM_IPNUMBEREX}:443> |
| | | |
| | |
| | | Map<String, Object> setParams = new HashMap<String, Object>(); |
| | | Map<String, String> whereParams = new HashMap<String, String>(); |
| | | List<String> optionslist = new ArrayList<String>(); |
| | | optionslist.add("greylisting"); |
| | | optionslist.add("nogreylisting"); |
| | | setParams.put("domainoptions", optionslist); |
| | | whereParams.put("name", "example01.org"); |
| | | Object[] params = new Object[] { user, |
| | |
| | | Map<String, Object> setParams = new HashMap<String, Object>(); |
| | | Map<String, String> whereParams = new HashMap<String, String>(); |
| | | List<String> optionslist = new ArrayList<String>(); |
| | | optionslist.add("htdocsfallback"); |
| | | optionslist.add("greylisting"); |
| | | optionslist.add("nohtdocsfallback"); |
| | | optionslist.add("nogreylisting"); |
| | | setParams.put("domainoptions", optionslist); |
| | | whereParams.put("name", "example01.org"); |
| | | Object[] params = new Object[] { user, |