From da4bee436177b981a03705c166555fe0f78ddc59 Mon Sep 17 00:00:00 2001 From: Purodha Blissenbach Date: Tue, 27 Nov 2012 12:12:11 +0100 Subject: [PATCH 1/3] Abstractproperty introduced for domainproperties --- hsarweb/src/de/hsadmin/web/AbstractModule.java | 2 +- hsarweb/src/de/hsadmin/web/DatabaseModule.java | 2 +- hsarweb/src/de/hsadmin/web/DeleteAble.java | 2 +- hsarweb/src/de/hsadmin/web/GenericModule.java | 16 ++++++++-------- hsarweb/src/de/hsadmin/web/HomeModule.java | 12 ++++++------ hsarweb/src/de/hsadmin/web/InsertAble.java | 2 +- hsarweb/src/de/hsadmin/web/Remote.java | 13 ++++++------- hsarweb/src/de/hsadmin/web/UpdateAble.java | 2 +- .../hsadmin/web/config/PropertyFieldFactory.java | 3 ++- .../web/vaadin/DatePropertyFieldFactory.java | 6 ++++-- .../web/vaadin/DefaultPropertyFieldFactory.java | 6 ++++-- .../vaadin/EMailTargetPropertyFieldFactory.java | 6 ++++-- .../src/de/hsadmin/web/vaadin/GenericForm.java | 10 ++++++---- .../web/vaadin/PasswordPropertyFieldFactory.java | 6 ++++-- .../web/vaadin/SelectPropertyFieldFactory.java | 6 ++++-- .../web/vaadin/TableComponentFactory.java | 10 ++++++---- 16 files changed, 59 insertions(+), 45 deletions(-) diff --git a/hsarweb/src/de/hsadmin/web/AbstractModule.java b/hsarweb/src/de/hsadmin/web/AbstractModule.java index 4b37670..d211bca 100644 --- a/hsarweb/src/de/hsadmin/web/AbstractModule.java +++ b/hsarweb/src/de/hsadmin/web/AbstractModule.java @@ -70,7 +70,7 @@ public abstract class AbstractModule implements Module, Serializable { public void buttonClick(ClickEvent event) { application.getMainWindow().removeWindow(childWindow); try { - Map map = new HashMap(); + Map map = new HashMap(); genericForm.transferToHash(map, form); ((InsertAble) thisModule).insertRow(map); componentFactory.loadData(); diff --git a/hsarweb/src/de/hsadmin/web/DatabaseModule.java b/hsarweb/src/de/hsadmin/web/DatabaseModule.java index 3ccea15..d0d6fc7 100644 --- a/hsarweb/src/de/hsadmin/web/DatabaseModule.java +++ b/hsarweb/src/de/hsadmin/web/DatabaseModule.java @@ -142,7 +142,7 @@ public abstract class DatabaseModule extends GenericModule { public List getDatabaseUsers() { ArrayList list = new ArrayList(); try { - Object callSearch = getApplication().getRemote().callSearch(getUserModuleIdent(), new HashMap()); + Object callSearch = getApplication().getRemote().callSearch(getUserModuleIdent(), new HashMap()); if (callSearch instanceof Object[]) { for (Object row : ((Object[])callSearch)) { if (row instanceof Map) { diff --git a/hsarweb/src/de/hsadmin/web/DeleteAble.java b/hsarweb/src/de/hsadmin/web/DeleteAble.java index 650e102..938c12f 100644 --- a/hsarweb/src/de/hsadmin/web/DeleteAble.java +++ b/hsarweb/src/de/hsadmin/web/DeleteAble.java @@ -4,6 +4,6 @@ import java.util.Map; public interface DeleteAble { - public void deleteRow(Map paramHash) throws HsarwebException; + public void deleteRow(Map paramHash) throws HsarwebException; } diff --git a/hsarweb/src/de/hsadmin/web/GenericModule.java b/hsarweb/src/de/hsadmin/web/GenericModule.java index 4e1bcb1..f754624 100644 --- a/hsarweb/src/de/hsadmin/web/GenericModule.java +++ b/hsarweb/src/de/hsadmin/web/GenericModule.java @@ -12,16 +12,16 @@ public abstract class GenericModule extends AbstractModule implements InsertAble private static final long serialVersionUID = 1L; - public void insertRow(Map paramHash) throws HsarwebException { + public void insertRow(Map paramHash) throws HsarwebException { getApplication().getRemote().callAdd(getModuleConfig().getRemoteName(), paramHash); } - public void deleteRow(Map paramHash) throws HsarwebException { + public void deleteRow(Map paramHash) throws HsarwebException { getApplication().getRemote().callDelete(getModuleConfig().getRemoteName(), paramHash); } - public void updateRow(Map paramHash) throws HsarwebException { - Map whereHash = new HashMap(); + public void updateRow(Map paramHash) throws HsarwebException { + Map whereHash = new HashMap(); String idKey = findIdKey(); whereHash.put(idKey, paramHash.get(idKey)); getApplication().getRemote().callUpdate(getModuleConfig().getRemoteName(), paramHash, whereHash); @@ -43,7 +43,7 @@ public abstract class GenericModule extends AbstractModule implements InsertAble public List getUsers() { ArrayList list = new ArrayList(); try { - Object callSearch = getApplication().getRemote().callSearch("user", new HashMap()); + Object callSearch = getApplication().getRemote().callSearch("user", new HashMap()); if (callSearch instanceof Object[]) { for (Object row : ((Object[])callSearch)) { if (row instanceof Map) { @@ -64,7 +64,7 @@ public abstract class GenericModule extends AbstractModule implements InsertAble public List getEMailAliases() { ArrayList list = new ArrayList(); try { - Object callSearch = getApplication().getRemote().callSearch("emailalias", new HashMap()); + Object callSearch = getApplication().getRemote().callSearch("emailalias", new HashMap()); if (callSearch instanceof Object[]) { for (Object row : ((Object[])callSearch)) { if (row instanceof Map) { @@ -85,7 +85,7 @@ public abstract class GenericModule extends AbstractModule implements InsertAble public List getDomains() { ArrayList list = new ArrayList(); try { - Object callSearch = getApplication().getRemote().callSearch("domain", new HashMap()); + Object callSearch = getApplication().getRemote().callSearch("domain", new HashMap()); if (callSearch instanceof Object[]) { for (Object row : ((Object[])callSearch)) { if (row instanceof Map) { @@ -106,7 +106,7 @@ public abstract class GenericModule extends AbstractModule implements InsertAble public List getPackets() { ArrayList list = new ArrayList(); try { - Object callSearch = getApplication().getRemote().callSearch("pac", new HashMap()); + Object callSearch = getApplication().getRemote().callSearch("pac", new HashMap()); if (callSearch instanceof Object[]) { for (Object row : ((Object[])callSearch)) { if (row instanceof Map) { diff --git a/hsarweb/src/de/hsadmin/web/HomeModule.java b/hsarweb/src/de/hsadmin/web/HomeModule.java index d71e536..47c07f9 100644 --- a/hsarweb/src/de/hsadmin/web/HomeModule.java +++ b/hsarweb/src/de/hsadmin/web/HomeModule.java @@ -35,8 +35,8 @@ public class HomeModule extends AbstractModule implements ComponentFactory, Upda setComponentFactory(this); } - public void updateRow(Map paramHash) throws HsarwebException { - Map whereHash = new HashMap(); + public void updateRow(Map paramHash) throws HsarwebException { + Map whereHash = new HashMap(); String idKey = findIdKey(); whereHash.put(idKey, paramHash.get(idKey)); paramHash.remove(idKey); @@ -94,8 +94,8 @@ public class HomeModule extends AbstractModule implements ComponentFactory, Upda Button button = new Button(moduleConfig.getLabel("change_password")); ThemeResource icon = new ThemeResource(moduleConfig.getLabel("change_password_icon")); button.setIcon(icon); - Map whereHash = new HashMap(); - whereHash.put("name", application.getLogin()); + Map whereHash = new HashMap(); + whereHash.put("name", new StringProperty (application.getLogin())); Long key = -1L; try { Object object = application.getRemote().callSearch(moduleConfig.getRemoteName(), whereHash); @@ -130,8 +130,8 @@ public class HomeModule extends AbstractModule implements ComponentFactory, Upda public void buttonClick(ClickEvent event) { application.getMainWindow().removeWindow(childWindow); try { - Map map = new HashMap(); - map.put("id", ((Long) event.getButton().getData()).toString()); + Map map = new HashMap(); + map.put("id", new StringProperty(((Long) event.getButton().getData()).toString())); Iterator componentIterator = form.getLayout().getComponentIterator(); while (componentIterator.hasNext()) { Component component = (Component) componentIterator.next(); diff --git a/hsarweb/src/de/hsadmin/web/InsertAble.java b/hsarweb/src/de/hsadmin/web/InsertAble.java index 3c49771..c7af5a0 100644 --- a/hsarweb/src/de/hsadmin/web/InsertAble.java +++ b/hsarweb/src/de/hsadmin/web/InsertAble.java @@ -4,6 +4,6 @@ import java.util.Map; public interface InsertAble { - public void insertRow(Map paramHash) throws HsarwebException; + public void insertRow(Map paramHash) throws HsarwebException; } diff --git a/hsarweb/src/de/hsadmin/web/Remote.java b/hsarweb/src/de/hsadmin/web/Remote.java index 512d7de..078fca3 100644 --- a/hsarweb/src/de/hsadmin/web/Remote.java +++ b/hsarweb/src/de/hsadmin/web/Remote.java @@ -18,23 +18,23 @@ public class Remote { this.app = application; } - public Object callSearch(String module, Map where) throws HsarwebException { + public Object callSearch(String module, Map where) throws HsarwebException { return xmlrpcCall(module, "search", where); } - public void callAdd(String module, Map set) throws HsarwebException { + public void callAdd(String module, Map set) throws HsarwebException { xmlrpcCall(module, "add", set); } - public void callUpdate(String module, Map set, Map where) throws HsarwebException { + public void callUpdate(String module, Map set, Map where) throws HsarwebException { xmlrpcCall(module, "update", set, where); } - public void callDelete(String module, Map where) throws HsarwebException { + public void callDelete(String module, Map where) throws HsarwebException { xmlrpcCall(module, "delete", where); } - private Object xmlrpcCall(String module, String operation, Map param1) throws HsarwebException { + private Object xmlrpcCall(String module, String operation, Map param1) throws HsarwebException { Object[] params = new Object[3]; params[0] = app.getLogin(); params[1] = app.getProxyTicket(); @@ -42,7 +42,7 @@ public class Remote { return xmlrpcCall(module + "." + operation, params); } - private Object xmlrpcCall(String module, String operation, Map param1, Map param2) throws HsarwebException { + private Object xmlrpcCall(String module, String operation, Map param1, Map param2) throws HsarwebException { Object[] params = new Object[4]; params[0] = app.getLogin(); params[1] = app.getProxyTicket(); @@ -77,5 +77,4 @@ public class Remote { return client; } - } diff --git a/hsarweb/src/de/hsadmin/web/UpdateAble.java b/hsarweb/src/de/hsadmin/web/UpdateAble.java index e9aaaae..1753c09 100644 --- a/hsarweb/src/de/hsadmin/web/UpdateAble.java +++ b/hsarweb/src/de/hsadmin/web/UpdateAble.java @@ -4,6 +4,6 @@ import java.util.Map; public interface UpdateAble { - public void updateRow(Map paramHash) throws HsarwebException; + public void updateRow(Map paramHash) throws HsarwebException; } diff --git a/hsarweb/src/de/hsadmin/web/config/PropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/config/PropertyFieldFactory.java index 90fc176..95d7cd0 100644 --- a/hsarweb/src/de/hsadmin/web/config/PropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/config/PropertyFieldFactory.java @@ -1,12 +1,13 @@ package de.hsadmin.web.config; +import de.hsadmin.web.AbstractProperty; import de.hsadmin.web.HsarwebException; public interface PropertyFieldFactory { public Object createFieldComponent(PropertyConfig prop, Object value); - public String getValue(PropertyConfig prop, Object component) throws HsarwebException; + public AbstractProperty getValue(PropertyConfig prop, Object component) throws HsarwebException; public void setReadOnly(boolean readOnly); diff --git a/hsarweb/src/de/hsadmin/web/vaadin/DatePropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/DatePropertyFieldFactory.java index 626f1d8..c973d70 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/DatePropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/DatePropertyFieldFactory.java @@ -10,6 +10,8 @@ import com.vaadin.terminal.Sizeable; import com.vaadin.ui.DateField; import com.vaadin.ui.PopupDateField; +import de.hsadmin.web.AbstractProperty; +import de.hsadmin.web.StringProperty; import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyFieldFactory; @@ -41,9 +43,9 @@ public class DatePropertyFieldFactory implements PropertyFieldFactory { } @Override - public String getValue(PropertyConfig prop, Object component) { + public AbstractProperty getValue(PropertyConfig prop, Object component) { if (component instanceof DateField) { - return serverDf.format((Date) ((DateField) component).getValue()); + return (new StringProperty(serverDf.format((Date) ((DateField) component).getValue()))); // TODO: besser DateProperty ? } return null; } diff --git a/hsarweb/src/de/hsadmin/web/vaadin/DefaultPropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/DefaultPropertyFieldFactory.java index 02d1c45..1089fe3 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/DefaultPropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/DefaultPropertyFieldFactory.java @@ -3,6 +3,8 @@ package de.hsadmin.web.vaadin; import com.vaadin.terminal.Sizeable; import com.vaadin.ui.TextField; +import de.hsadmin.web.AbstractProperty; +import de.hsadmin.web.StringProperty; import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyFieldFactory; @@ -22,9 +24,9 @@ public class DefaultPropertyFieldFactory implements PropertyFieldFactory { } @Override - public String getValue(PropertyConfig prop, Object component) { + public AbstractProperty getValue(PropertyConfig prop, Object component) { if (component instanceof TextField) { - return (String) ((TextField) component).getValue(); + return new StringProperty((String) ((TextField) component).getValue()); } return null; } diff --git a/hsarweb/src/de/hsadmin/web/vaadin/EMailTargetPropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/EMailTargetPropertyFieldFactory.java index 94c3c91..b6a4d98 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/EMailTargetPropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/EMailTargetPropertyFieldFactory.java @@ -15,9 +15,11 @@ import com.vaadin.ui.Select; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; +import de.hsadmin.web.AbstractProperty; import de.hsadmin.web.GenericModule; import de.hsadmin.web.HsarwebException; import de.hsadmin.web.Module; +import de.hsadmin.web.StringProperty; import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyFieldFactory; @@ -92,7 +94,7 @@ public class EMailTargetPropertyFieldFactory implements PropertyFieldFactory { } @Override - public String getValue(PropertyConfig prop, Object component) throws HsarwebException { + public AbstractProperty getValue(PropertyConfig prop, Object component) throws HsarwebException { StringBuffer target = new StringBuffer(); boolean insertKomma = false; for (Integer key : targets.keySet()) { @@ -106,7 +108,7 @@ public class EMailTargetPropertyFieldFactory implements PropertyFieldFactory { insertKomma = true; } } - return target.toString(); + return new StringProperty(target.toString()); } @Override diff --git a/hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java b/hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java index a854c29..3db7527 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java @@ -10,9 +10,11 @@ import com.vaadin.ui.Component; import com.vaadin.ui.Form; import com.vaadin.ui.Layout; +import de.hsadmin.web.AbstractProperty; import de.hsadmin.web.HsarwebException; import de.hsadmin.web.MainApplication; import de.hsadmin.web.Module; +import de.hsadmin.web.StringProperty; import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyFieldFactory; @@ -46,8 +48,8 @@ public class GenericForm { try { MainApplication application = module.getApplication(); ModuleConfig config = module.getModuleConfig(); - Map where = new HashMap(); - where.put(findIdKey(), entityId.toString()); + Map where = new HashMap(); + where.put(findIdKey(), new StringProperty(entityId.toString())); Object searchResult = application.getRemote().callSearch(config.getRemoteName(), where); if (searchResult instanceof Object[]) { Map row = (Map) (((Object[]) searchResult)[0]); @@ -88,11 +90,11 @@ public class GenericForm { return idKey; } - public void transferToHash(Map map, Form form) throws HsarwebException { + public void transferToHash(Map map, Form form) throws HsarwebException { Iterator iterator = form.getLayout().getComponentIterator(); Object formData = form.getData(); if (formData != null && formData instanceof Long) { - map.put(findIdKey(), ((Long) formData).toString()); + map.put(findIdKey(), new StringProperty(((Long) formData).toString())); } while (iterator.hasNext()) { Component component = (Component) iterator.next(); diff --git a/hsarweb/src/de/hsadmin/web/vaadin/PasswordPropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/PasswordPropertyFieldFactory.java index e5ccbf3..260e682 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/PasswordPropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/PasswordPropertyFieldFactory.java @@ -4,8 +4,10 @@ import com.vaadin.terminal.Sizeable; import com.vaadin.ui.PasswordField; import com.vaadin.ui.VerticalLayout; +import de.hsadmin.web.AbstractProperty; import de.hsadmin.web.HsarwebException; import de.hsadmin.web.Module; +import de.hsadmin.web.StringProperty; import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyFieldFactory; @@ -42,13 +44,13 @@ public class PasswordPropertyFieldFactory implements PropertyFieldFactory { } @Override - public String getValue(PropertyConfig prop, Object component) throws HsarwebException { + public AbstractProperty getValue(PropertyConfig prop, Object component) throws HsarwebException { if (component instanceof VerticalLayout) { VerticalLayout layout = (VerticalLayout) component; PasswordField pw1 = (PasswordField) layout.getComponent(0); PasswordField pw2 = (PasswordField) layout.getComponent(1); if (pw1.getValue().equals(pw2.getValue())) { - return (String) pw1.getValue(); + return new StringProperty((String) pw1.getValue()); } else { throw new HsarwebException("password mismatch"); } diff --git a/hsarweb/src/de/hsadmin/web/vaadin/SelectPropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/SelectPropertyFieldFactory.java index 446b61f..6850a1d 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/SelectPropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/SelectPropertyFieldFactory.java @@ -5,7 +5,9 @@ import java.util.Map; import com.vaadin.terminal.Sizeable; import com.vaadin.ui.Select; +import de.hsadmin.web.AbstractProperty; import de.hsadmin.web.HsarwebException; +import de.hsadmin.web.StringProperty; import de.hsadmin.web.config.PropertyConfig; import de.hsadmin.web.config.PropertyFieldFactory; @@ -33,10 +35,10 @@ public class SelectPropertyFieldFactory implements PropertyFieldFactory { } @Override - public String getValue(PropertyConfig prop, Object component) + public AbstractProperty getValue(PropertyConfig prop, Object component) throws HsarwebException { if (component instanceof Select) { - return (String) ((Select) component).getValue(); + return new StringProperty((String) ((Select) component).getValue()); } return null; } diff --git a/hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java index fd98b01..78f287d 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/TableComponentFactory.java @@ -22,10 +22,12 @@ import com.vaadin.ui.Window; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.themes.BaseTheme; +import de.hsadmin.web.AbstractProperty; import de.hsadmin.web.DeleteAble; import de.hsadmin.web.HsarwebException; import de.hsadmin.web.MainApplication; import de.hsadmin.web.Module; +import de.hsadmin.web.StringProperty; import de.hsadmin.web.UpdateAble; import de.hsadmin.web.config.ComponentFactory; import de.hsadmin.web.config.LocaleConfig; @@ -107,7 +109,7 @@ public class TableComponentFactory implements ComponentFactory, Serializable { table.removeAllItems(); try { ModuleConfig moduleConfig = module.getModuleConfig(); - Object callSearch = module.getApplication().getRemote().callSearch(moduleConfig.getRemoteName(), new HashMap()); + Object callSearch = module.getApplication().getRemote().callSearch(moduleConfig.getRemoteName(), new HashMap()); List propertyList = moduleConfig.getPropertyList(); if (callSearch instanceof Object[]) { for (Object row : ((Object[])callSearch)) { @@ -229,7 +231,7 @@ public class TableComponentFactory implements ComponentFactory, Serializable { public void buttonClick(ClickEvent event) { application.getMainWindow().removeWindow(childWindow); try { - Map map = new HashMap(); + Map map = new HashMap(); genericForm.transferToHash(map, form); ((UpdateAble) module).updateRow(map); loadData(); @@ -285,8 +287,8 @@ public class TableComponentFactory implements ComponentFactory, Serializable { public void buttonClick(ClickEvent event) { application.getMainWindow().removeWindow(childWindow); try { - Map map = new HashMap(); - map.put(findIdKey(), ((Long) button.getData()).toString()); + Map map = new HashMap(); + map.put(findIdKey(), new StringProperty(((Long) button.getData()).toString())); ((DeleteAble) module).deleteRow(map); loadData(); } catch (HsarwebException e) { From 5767f4ff1ea5c77d85c05a8e19aee839f03a0133 Mon Sep 17 00:00:00 2001 From: Purodha Blissenbach Date: Tue, 18 Dec 2012 13:26:16 +0100 Subject: [PATCH 2/3] Adding branch with trial stuff for domain options to hsarweb + possibly applying recent changes of Peter Hormanns to DomainProcessorfactory. --- .../mods/dom/DomainProcessorFactory.java | 100 ++++++--------- .../src/de/hsadmin/web/AbstractProperty.java | 5 + .../de/hsadmin/web/ListOfStringsProperty.java | 15 +++ .../src/de/hsadmin/web/StringProperty.java | 10 ++ .../DomainOptionsPropertyFieldFactory.java | 116 ++++++++++++++++++ 5 files changed, 183 insertions(+), 63 deletions(-) create mode 100644 hsarweb/src/de/hsadmin/web/AbstractProperty.java create mode 100644 hsarweb/src/de/hsadmin/web/ListOfStringsProperty.java create mode 100644 hsarweb/src/de/hsadmin/web/StringProperty.java create mode 100644 hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java index 2cb54a1..f4b05b1 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -53,13 +53,13 @@ public class DomainProcessorFactory implements EntityProcessorFactory { templateVars.put("DOM_IPNUMBEREX", getOldIPAddress(pac)); WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(createHiveDNSSetupProcessor(domName, templateVars)); mainProcessor.appendProcessor(hiveName, createHiveEMailSetupProcessor(em, domName), "Setup EMail"); - String pacInetAddr = pac.getCurINetAddr().getInetAddr(); + String hiveInetAddr = pac.getHive().getInetAddr().getInetAddr(); Config config = Config.getInstance(); for (String queueName : config.getProperty("queues.dns").split(",")) { - mainProcessor.appendProcessor(queueName, createDNSServerSetupProcessor(domName, pacInetAddr), queueName + ".hostsharing.net"); + mainProcessor.appendProcessor(queueName, createDNSServerSetupProcessor(domName, hiveInetAddr), queueName + ".hostsharing.net"); } for (String queueName : config.getProperty("queues.mail").split(",")) { - mainProcessor.appendProcessor(queueName, createMailinSetupProcessor(em, domName, pac), queueName + ".hostsharing.net"); + mainProcessor.appendProcessor(queueName, createMailinSetupProcessor(em, dom, pac), queueName + ".hostsharing.net"); } templateVars = new HashMap(); templateVars.put("PAC", pacName); @@ -71,10 +71,8 @@ public class DomainProcessorFactory implements EntityProcessorFactory { templateVars.put("DOM_IPNUMBEREX", getOldIPAddress(pac)); templateVars.put("DOMAIN", domName); templateVars.put("USER_NAME", domUser.getComment()); + mainProcessor.appendProcessor(hiveName, createDomainDirectoriesProcessor(dom, templateVars), "Setup Domain Directories"); mainProcessor.appendProcessor(hiveName, createApacheVHostSetupProcessor(em, dom, templateVars), "Setup Apache VHost"); - if (dom.isPacDomain()) { - mainProcessor.appendProcessor(hiveName, createMovePacDomainContent(em, dom), "Move pac domain content"); - } return mainProcessor; } @@ -97,7 +95,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory { WaitingTasksProcessor processor = new WaitingTasksProcessor(createApacheVHostSetupProcessor(em, dom, templateVars)); Config config = Config.getInstance(); for (String queueName : config.getProperty("queues.mail").split(",")) { - processor.appendProcessor(queueName, createPostgreyConfiguration(em), queueName + ".hostsharing.net"); + processor.appendProcessor(queueName, createMailinSetupProcessor(em, dom, pac), queueName + ".hostsharing.net"); } return processor; } @@ -113,8 +111,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory { mainProcessor.appendProcessor(queueName, createDNSServerRemoveProcessor(domName), queueName + ".hostsharing.net"); } for (String queueName : config.getProperty("queues.mail").split(",")) { - mainProcessor.appendProcessor(queueName, createMailinDeleteProcessor(domName), queueName + ".hostsharing.net"); - mainProcessor.appendProcessor(queueName, createPostgreyConfiguration(em), queueName + ".hostsharing.net"); + mainProcessor.appendProcessor(queueName, createMailinUnsetupProcessor(em, dom), queueName + ".hostsharing.net"); } mainProcessor.appendProcessor(dom.getHiveName(), createApacheVHostDeleteProcessor(dom), "remove apache vhost"); return mainProcessor; @@ -160,10 +157,10 @@ public class DomainProcessorFactory implements EntityProcessorFactory { return emailAdrProcessor; } - private Processor createDNSServerSetupProcessor(String domName, String pacInetAddr) { + private Processor createDNSServerSetupProcessor(String domName, String hiveInetAddr) { Processor seczonesFileProcessor; seczonesFileProcessor = - new ShellProcessor("echo 'zone \"" + domName + "\" { type slave; file \"sec." + domName + "\"; masters { " + pacInetAddr + "; }; };' >>/etc/bind/named-hsh.conf" + + new ShellProcessor("echo 'zone \"" + domName + "\" { type slave; file \"sec." + domName + "\"; masters { " + hiveInetAddr + "; }; };' >>/etc/bind/named-hsh.conf" + " && sort /etc/bind/named-hsh.conf | uniq >/etc/bind/named-hsh.conf.tmp" + " && mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf" + " && invoke-rc.d bind9 reload"); @@ -178,17 +175,30 @@ public class DomainProcessorFactory implements EntityProcessorFactory { " && invoke-rc.d bind9 reload"); } - private Processor createMailinSetupProcessor(EntityManager em, String domName, Pac pac) throws ProcessorException { + private Processor createMailinSetupProcessor(EntityManager em, Domain dom, Pac pac) throws ProcessorException { String inetAddr = pac.getCurINetAddr().getInetAddr(); - return new CompoundProcessor( + CompoundProcessor cp = new CompoundProcessor( createPostgreyConfiguration(em), new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains", - domName + " anything\n" + - "." + domName + " anything\n"), - new ShellProcessor("postmap -r -i /etc/postfix-mailin/transport", - domName + " smtp:" + inetAddr + ":225\n" + - "." + domName + " smtp:" + inetAddr + ":225\n") - ); + dom.getName() + " anything\n" + + "." + dom.getName() + " anything\n")); + Query query = em.createQuery("SELECT d FROM Domains d WHERE d.domainoptions.name = :option AND d.name = :domname"); + query.setParameter("domname", dom.getName()); + query.setParameter("option", "backupmxforexternalmx"); + if (query.getResultList().isEmpty()) { + cp.appendProcessor( + new ShellProcessor("postmap -r -i /etc/postfix-mailin/transport", + dom.getName() + " smtp:" + inetAddr + ":225\n" + + "." + dom.getName() + " smtp:" + inetAddr + ":225\n") + ); + } else { + cp.appendProcessor( + new ShellProcessor( + "postmap -d '" + dom.getName() + "' /etc/postfix-mailin/transport && " + + "postmap -d '." + dom.getName() + "' /etc/postfix-mailin/transport") + ); + } + return cp; } private Processor createPostgreyConfiguration(EntityManager em) throws ProcessorException { @@ -215,12 +225,14 @@ public class DomainProcessorFactory implements EntityProcessorFactory { ); } - private Processor createMailinDeleteProcessor(String domName) { - Processor mailQueueProcessor = new ShellProcessor( - "postmap -d '" + domName + "' /etc/postfix-mailin/relaydomains && " + - "postmap -d '" + domName + "' /etc/postfix-mailin/transport && " + - "postmap -d '." + domName + "' /etc/postfix-mailin/relaydomains && " + - "postmap -d '." + domName + "' /etc/postfix-mailin/transport"); + private Processor createMailinUnsetupProcessor(EntityManager em, Domain dom) throws ProcessorException { + Processor mailQueueProcessor = new CompoundProcessor( + createPostgreyConfiguration(em), + new ShellProcessor( + "postmap -d '" + dom.getName() + "' /etc/postfix-mailin/relaydomains && " + + "postmap -d '" + dom.getName() + "' /etc/postfix-mailin/transport && " + + "postmap -d '." + dom.getName() + "' /etc/postfix-mailin/relaydomains && " + + "postmap -d '." + dom.getName() + "' /etc/postfix-mailin/transport")); return mailQueueProcessor; } @@ -343,7 +355,6 @@ public class DomainProcessorFactory implements EntityProcessorFactory { } Processor domSetupProcessor = new CompoundProcessor( - createDomainDirectoriesProcessor(dom, templateVars), new CreateFileProcessor(selectVHostTemplate(dom), templateVars, "/etc/apache2/sites-available/" + domName + ".tmp", "root", "root", "644", true), new ShellProcessor("ls /etc/apache2/pems/" + pac + ".pem >/dev/null 2>&1" + " && sed -i '/SSLCertificate.*default/d' " + "/etc/apache2/sites-available/" + domName + ".tmp" + @@ -372,43 +383,6 @@ public class DomainProcessorFactory implements EntityProcessorFactory { return vhostDelProcessor; } - private Processor createMovePacDomainContent(EntityManager em, Domain dom) { - Pac pac = dom.getUser().getPac(); - String pacName = pac.getName(); - String pacDir = "/home/pacs/" + pacName; - String domDir = pacDir + "/doms/" + pacName + ".hostsharing.net"; - String[] sourceDirs = new String[] { "web", "web-ssl", "cgi", "cgi-ssl", "fastcgi", "fastcgi-ssl" } ; - String[] targetDirs = new String[] { "htdocs", "htdocs-ssl", "cgi", "cgi-ssl", "fastcgi", "fastcgi-ssl" } ; - CompoundProcessor processor = new CompoundProcessor(); - for (int idx = 0; idx < targetDirs.length; idx++) { - processor.appendProcessor( - new ShellProcessor("rm -rf " + domDir + "/" + targetDirs[idx])); - } - for (int idx = 0; idx < sourceDirs.length; idx++) { - processor.appendProcessor( - new ShellProcessor("shopt -s dotglob && ls " + pacDir + "/" + sourceDirs[idx] + " >/dev/null 2>&1" + - " && mv " + pacDir + "/" + sourceDirs[idx] + " " + domDir + "/" + targetDirs[idx] + - " || echo 'directory " + pacDir + "/" + sourceDirs[idx] + " not found'")); - } - processor.appendProcessor( - new ShellProcessor("test -L " + domDir + "/htdocs" + - " && test $( stat -c '%N' " + domDir + "/htdocs |sed -e\"s/[\\`']//g\" |cut -d ' ' -f 3 ) = web-ssl " + - " && cd " + domDir + - " && rm " + domDir + "/htdocs" + - " && ln -sf htdocs-ssl htdocs" + - " && chown -h " + pacName + ":" + pacName + " " + domDir + "/htdocs" + - " || echo 'link htdocs not found'")); - processor.appendProcessor( - new ShellProcessor("test -L " + domDir + "/htdocs-ssl" + - " && test $( stat -c '%N' " + domDir + "/htdocs-ssl |sed -e\"s/[\\`']//g\" |cut -d ' ' -f 3 ) = web " + - " && cd " + domDir + - " && rm " + domDir + "/htdocs-ssl" + - " && ln -sf htdocs htdocs-ssl" + - " && chown -h " + pacName + ":" + pacName + " " + domDir + "/htdocs-ssl" + - " || echo 'link htdocs-ssl not found'")); - return processor; - } - private String selectVHostTemplate(Domain dom) { String domName = dom.getName(); UnixUser user = dom.getUser(); diff --git a/hsarweb/src/de/hsadmin/web/AbstractProperty.java b/hsarweb/src/de/hsadmin/web/AbstractProperty.java new file mode 100644 index 0000000..1527a0f --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/AbstractProperty.java @@ -0,0 +1,5 @@ +package de.hsadmin.web; + +public class AbstractProperty { + +} diff --git a/hsarweb/src/de/hsadmin/web/ListOfStringsProperty.java b/hsarweb/src/de/hsadmin/web/ListOfStringsProperty.java new file mode 100644 index 0000000..92f111f --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/ListOfStringsProperty.java @@ -0,0 +1,15 @@ +package de.hsadmin.web; + +import java.util.List; + +public class ListOfStringsProperty extends AbstractProperty { + public List properties; + + public ListOfStringsProperty(){ +// ?? this.properties = new List(); + } + + public boolean Add(String string){ + return properties.add(string); + } +} diff --git a/hsarweb/src/de/hsadmin/web/StringProperty.java b/hsarweb/src/de/hsadmin/web/StringProperty.java new file mode 100644 index 0000000..4c3e9e2 --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/StringProperty.java @@ -0,0 +1,10 @@ +package de.hsadmin.web; + +public class StringProperty extends AbstractProperty { + public String property ; + + public StringProperty(String property) { + this.property = property; + } + +} diff --git a/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java new file mode 100644 index 0000000..876e641 --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java @@ -0,0 +1,116 @@ +/** + * + */ +package de.hsadmin.web.vaadin; + +import java.util.HashMap; +import java.util.Map; + +import com.vaadin.data.Property; +import com.vaadin.data.Property.ValueChangeEvent; +import com.vaadin.terminal.Sizeable; +import com.vaadin.ui.AbstractField; +import com.vaadin.ui.HorizontalLayout; +import com.vaadin.ui.Select; +import com.vaadin.ui.VerticalLayout; + +import de.hsadmin.web.AbstractProperty; +import de.hsadmin.web.HsarwebException; +import de.hsadmin.web.ListOfStringsProperty; +import de.hsadmin.web.config.PropertyConfig; +import de.hsadmin.web.config.PropertyFieldFactory; + +/** + * @author pblissenbach + * + */ +public class DomainOptionsPropertyFieldFactory implements PropertyFieldFactory { + private Map optionTypes ; // TODO: auf Vorrat hier + private ListOfStringsProperty setOptions ; + private boolean readOnly = false; + private boolean writeOnce = false; + private VerticalLayout layout; + + public DomainOptionsPropertyFieldFactory() { + // TODO: besorge Options und ihre Typen aus der DB + optionTypes = new HashMap() ; + optionTypes.put("backupmxforexternalmx", null); + optionTypes.put("greylisting", null); + optionTypes.put("htdocsfallback", null); + optionTypes.put("includes", null); + optionTypes.put("indexes", null); + optionTypes.put("multiviews", null); + optionTypes.put("nonexistiondomainoptionfortesting", null); // TESTCASE + optionTypes.put("php", null); + // TODO: besorge Options .... Ende +// setOptions = null ; + setOptions = new ListOfStringsProperty() ; + // TODO Auto-generated constructor stub + } + + @Override + public Object createFieldComponent(PropertyConfig prop, Object value) { + // TODO Auto-generated method stub + return null; + } + + @Override + public AbstractProperty getValue(PropertyConfig prop, Object component) + throws HsarwebException { + return setOptions; + } + + @Override + public void setReadOnly(boolean readOnly) { + this.readOnly = readOnly; + } + + @Override + public boolean isReadOnly() { + return readOnly; + } + + @Override + public void setWriteOnce(boolean writeOnce) { + this.writeOnce = writeOnce; + } + + @Override + public boolean isWriteOnce() { + return writeOnce; + } + + class SingleDomainOption { + private HorizontalLayout targetLine; + private HorizontalLayout leftPart; + private HorizontalLayout rightPart; + private int index; + private String optionName; + private DomainOptionsPropertyFieldFactory owner; + + protected SingleDomainOption(DomainOptionsPropertyFieldFactory owner, int key, String optionName, Object optionValue) { + this.owner = owner; + this.index = key; + this.optionName = optionName; + targetLine = new HorizontalLayout(); + targetLine.setWidth(480.0f, Sizeable.UNITS_PIXELS); + leftPart = new HorizontalLayout(); + leftPart.setWidth(100.0f, Sizeable.UNITS_PIXELS); + leftPart.setCaption(optionName); + rightPart = new HorizontalLayout(); + rightPart.setWidth(380.0f, Sizeable.UNITS_PIXELS); + // ToDO: Fallunterscheidungen nach Optionsart. Z.Z. nur Boolean. + } + + public String getValue() { + String value = null; + if (rightPart.getComponentCount() > 0) { + Object object = ((AbstractField) rightPart.getComponent(0)).getValue(); + if (object != null && object instanceof String) { + value = ((String) object).trim(); + } + } + return value; + } + } +} \ No newline at end of file From f6c5ba676268cd5d95941324213ddc4f36f78e5d Mon Sep 17 00:00:00 2001 From: Purodha Blissenbach Date: Tue, 18 Dec 2012 13:36:01 +0100 Subject: [PATCH 3/3] Testing Autocrlf --- .../de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java | 1 + 1 file changed, 1 insertion(+) diff --git a/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java b/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java index 876e641..cd0d3d5 100644 --- a/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java +++ b/hsarweb/src/de/hsadmin/web/vaadin/DomainOptionsPropertyFieldFactory.java @@ -86,6 +86,7 @@ public class DomainOptionsPropertyFieldFactory implements PropertyFieldFactory { private HorizontalLayout rightPart; private int index; private String optionName; + private String testunusedoptionName; private DomainOptionsPropertyFieldFactory owner; protected SingleDomainOption(DomainOptionsPropertyFieldFactory owner, int key, String optionName, Object optionValue) {