diff --git a/hsarweb/WebContent/WEB-INF/lib/vaadin-6.4.8.jar b/hsarweb/WebContent/WEB-INF/lib/vaadin-6.4.8.jar deleted file mode 100644 index f1bd9cf..0000000 Binary files a/hsarweb/WebContent/WEB-INF/lib/vaadin-6.4.8.jar and /dev/null differ diff --git a/hsarweb/WebContent/WEB-INF/lib/vaadin-6.5.3.jar b/hsarweb/WebContent/WEB-INF/lib/vaadin-6.5.3.jar new file mode 100644 index 0000000..d111b5c Binary files /dev/null and b/hsarweb/WebContent/WEB-INF/lib/vaadin-6.5.3.jar differ diff --git a/hsarweb/src/de/hsadmin/web/DomainModule.java b/hsarweb/src/de/hsadmin/web/DomainModule.java index 3c44001..b32a045 100644 --- a/hsarweb/src/de/hsadmin/web/DomainModule.java +++ b/hsarweb/src/de/hsadmin/web/DomainModule.java @@ -1,9 +1,18 @@ package de.hsadmin.web; +import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.PropertyConfig; +import de.hsadmin.web.config.PropertyDefaultValue; +import de.hsadmin.web.config.PropertyFormField; +import de.hsadmin.web.config.PropertySelectValues; +import de.hsadmin.web.config.PropertyTableColumn; public class DomainModule extends GenericModule { @@ -11,14 +20,55 @@ public class DomainModule extends GenericModule { private ModuleConfig moduleConfig; - public DomainModule() { + @Override + protected void initModule() { moduleConfig = new ModuleConfig("domain"); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, true, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "name", String.class)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "user", String.class)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "hive", String.class, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "since", Date.class)); + moduleConfig.setUpdateAble(false); + String login = getApplication().getLogin(); + final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; + PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY, PropertyFormField.INTERNAL_KEY); + PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class, PropertyFormField.WRITEONCE); + PropertyConfig userProp = new PropertyConfig(moduleConfig, "user", String.class, PropertyFormField.WRITEONCE); + userProp.setDefaultValue(new PropertyDefaultValue() { + @Override + public String getDefaultValue() { + return pac; + } + }); + userProp.setSelectValues(new PropertySelectValues() { + @Override + public boolean newItemsAllowed() { + return false; + } + @Override + public boolean hasSelectList() { + return true; + } + @Override + public Map getSelectValues() { + List list = getUsers(); + TreeMap map = new TreeMap(); + for (String usr : list) { + map.put(usr, usr); + } + return map; + } + }); + PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, PropertyFormField.READONLY); + pacProp.setDefaultValue(new PropertyDefaultValue() { + @Override + public String getDefaultValue() { + return pac; + } + }); + PropertyConfig hiveProp = new PropertyConfig(moduleConfig, "hive", String.class, PropertyTableColumn.HIDDEN, PropertyFormField.NONE); + PropertyConfig sinceProp = new PropertyConfig(moduleConfig, "since", Date.class, PropertyFormField.READONLY); + moduleConfig.addProperty(idProp); + moduleConfig.addProperty(nameProp); + moduleConfig.addProperty(userProp); + moduleConfig.addProperty(pacProp); + moduleConfig.addProperty(hiveProp); + moduleConfig.addProperty(sinceProp); } @Override @@ -26,4 +76,25 @@ public class DomainModule extends GenericModule { return moduleConfig; } + public List getUsers() { + ArrayList list = new ArrayList(); + try { + Object callSearch = getApplication().getRemote().callSearch("user", new HashMap()); + if (callSearch instanceof Object[]) { + for (Object row : ((Object[])callSearch)) { + if (row instanceof Map) { + Object object = ((Map) row).get("name"); + if (object instanceof String) { + list.add((String) object); + } + } + } + } + } catch (HsarwebException e) { + e.printStackTrace(); + getApplication().showSystemException(e); + } + return list; + } + } diff --git a/hsarweb/src/de/hsadmin/web/EMailAddressModule.java b/hsarweb/src/de/hsadmin/web/EMailAddressModule.java index 0c8f4b8..c2bd6c2 100644 --- a/hsarweb/src/de/hsadmin/web/EMailAddressModule.java +++ b/hsarweb/src/de/hsadmin/web/EMailAddressModule.java @@ -1,7 +1,17 @@ package de.hsadmin.web; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.PropertyConfig; +import de.hsadmin.web.config.PropertyDefaultValue; +import de.hsadmin.web.config.PropertyFormField; +import de.hsadmin.web.config.PropertySelectValues; +import de.hsadmin.web.config.PropertyTableColumn; public class EMailAddressModule extends GenericModule { @@ -9,17 +19,47 @@ public class EMailAddressModule extends GenericModule { private ModuleConfig moduleConfig; - public EMailAddressModule() { + @Override + protected void initModule() { moduleConfig = new ModuleConfig("emailaddress"); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, true, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "emailaddress", String.class)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "localpart", String.class, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "subdomain", String.class, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "domain", String.class, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "target", String.class)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "admin", String.class, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "fulldomain", String.class, true)); + String login = getApplication().getLogin(); + final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY, PropertyFormField.INTERNAL_KEY)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "emailaddress", String.class, PropertyFormField.NONE)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "localpart", String.class, PropertyTableColumn.HIDDEN, PropertyFormField.WRITEONCE)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "subdomain", String.class, PropertyTableColumn.HIDDEN, PropertyFormField.WRITEONCE)); + PropertyConfig DomainProp = new PropertyConfig(moduleConfig, "domain", String.class, PropertyTableColumn.HIDDEN, PropertyFormField.WRITEONCE); + DomainProp.setSelectValues(new PropertySelectValues() { + @Override + public boolean newItemsAllowed() { + return false; + } + @Override + public boolean hasSelectList() { + return true; + } + @Override + public Map getSelectValues() { + Map map = new TreeMap(); + List list = getDomains(); + for (String dom : list) { + map.put(dom, dom); + } + return map; + } + }); + moduleConfig.addProperty(DomainProp); + PropertyConfig targetProp = new PropertyConfig(moduleConfig, "target", String.class); + targetProp.setDefaultValue(new PropertyDefaultValue() { + @Override + public String getDefaultValue() { + return pac + "-"; + } + }); + moduleConfig.addProperty(targetProp); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "admin", String.class, PropertyTableColumn.HIDDEN, PropertyFormField.NONE)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, PropertyFormField.NONE)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "fulldomain", String.class, PropertyTableColumn.HIDDEN, PropertyFormField.NONE)); } @Override @@ -27,4 +67,25 @@ public class EMailAddressModule extends GenericModule { return moduleConfig; } + public List getDomains() { + ArrayList list = new ArrayList(); + try { + Object callSearch = getApplication().getRemote().callSearch("domain", new HashMap()); + if (callSearch instanceof Object[]) { + for (Object row : ((Object[])callSearch)) { + if (row instanceof Map) { + Object object = ((Map) row).get("name"); + if (object instanceof String) { + list.add((String) object); + } + } + } + } + } catch (HsarwebException e) { + e.printStackTrace(); + getApplication().showSystemException(e); + } + return list; + } + } diff --git a/hsarweb/src/de/hsadmin/web/EMailAliasModule.java b/hsarweb/src/de/hsadmin/web/EMailAliasModule.java index 0c437ac..ca656f4 100644 --- a/hsarweb/src/de/hsadmin/web/EMailAliasModule.java +++ b/hsarweb/src/de/hsadmin/web/EMailAliasModule.java @@ -2,6 +2,9 @@ package de.hsadmin.web; import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.PropertyConfig; +import de.hsadmin.web.config.PropertyDefaultValue; +import de.hsadmin.web.config.PropertyFormField; +import de.hsadmin.web.config.PropertyTableColumn; public class EMailAliasModule extends GenericModule { @@ -9,12 +12,42 @@ public class EMailAliasModule extends GenericModule { private ModuleConfig moduleConfig; - public EMailAliasModule() { + @Override + protected void initModule() { moduleConfig = new ModuleConfig("emailalias"); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, true, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "name", String.class)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "target", String.class)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "pac", String.class, true)); + String login = getApplication().getLogin(); + final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY, PropertyFormField.INTERNAL_KEY)); + PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class); + nameProp.setDefaultValue(new PropertyDefaultValue() { + @Override + public String getDefaultValue() { + if (pac.length() >= 5) { + return pac + "-"; + } + return ""; + } + }); + moduleConfig.addProperty(nameProp); + PropertyConfig targetProp = new PropertyConfig(moduleConfig, "target", String.class); + targetProp.setDefaultValue(new PropertyDefaultValue() { + @Override + public String getDefaultValue() { + if (pac.length() >= 5) { + return pac + "-"; + } + return ""; + } + }); + moduleConfig.addProperty(targetProp); + PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, PropertyFormField.READONLY); + pacProp.setDefaultValue(new PropertyDefaultValue() { + @Override + public String getDefaultValue() { + return pac; + } + }); + moduleConfig.addProperty(pacProp); } @Override diff --git a/hsarweb/src/de/hsadmin/web/GenericModule.java b/hsarweb/src/de/hsadmin/web/GenericModule.java index 2a77045..08c51c3 100644 --- a/hsarweb/src/de/hsadmin/web/GenericModule.java +++ b/hsarweb/src/de/hsadmin/web/GenericModule.java @@ -14,6 +14,7 @@ import com.vaadin.data.Property; import com.vaadin.terminal.ExternalResource; import com.vaadin.terminal.Sizeable; import com.vaadin.terminal.ThemeResource; +import com.vaadin.ui.AbstractTextField; import com.vaadin.ui.Button; import com.vaadin.ui.Component; import com.vaadin.ui.Form; @@ -21,6 +22,8 @@ import com.vaadin.ui.HorizontalLayout; import com.vaadin.ui.Label; import com.vaadin.ui.Layout; import com.vaadin.ui.Link; +import com.vaadin.ui.PasswordField; +import com.vaadin.ui.Select; import com.vaadin.ui.Table; import com.vaadin.ui.TextField; import com.vaadin.ui.VerticalLayout; @@ -31,6 +34,8 @@ import com.vaadin.ui.themes.BaseTheme; import de.hsadmin.web.config.LocaleConfig; import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.PropertyConfig; +import de.hsadmin.web.config.PropertyFormField; +import de.hsadmin.web.config.PropertyTableColumn; public abstract class GenericModule implements Serializable { @@ -43,12 +48,19 @@ public abstract class GenericModule implements Serializable { public void setApplication(MainApplication app) throws HsarwebException { application = app; + initModule(); initTable(); initLayout(); } + + public MainApplication getApplication() { + return application; + } public abstract ModuleConfig getModuleConfig(); + protected abstract void initModule(); + public Component getComponent() { return layout; } @@ -61,6 +73,7 @@ public abstract class GenericModule implements Serializable { layout = new VerticalLayout(); layout.setSizeFull(); final ModuleConfig moduleConfig = getModuleConfig(); + final LocaleConfig localeConfig = application.getLocaleConfig(); if (moduleConfig.isSearchAble() || moduleConfig.isAddAble()) { HorizontalLayout toolbar = new HorizontalLayout(); if (moduleConfig.isAddAble()) { @@ -73,7 +86,6 @@ public abstract class GenericModule implements Serializable { @Override public void buttonClick(ClickEvent event) { final Form form = createForm(); - LocaleConfig localeConfig = application.getLocaleConfig(); childWindow = new Window(localeConfig.getText("new")); childWindow.setWidth(640.0f, Sizeable.UNITS_PIXELS); VerticalLayout vLayout = new VerticalLayout(); @@ -120,7 +132,7 @@ public abstract class GenericModule implements Serializable { } layout.addComponent(table); layout.setExpandRatio(table, 1.0f); - layout.addComponent(new Link("Impressum", new ExternalResource("http://www.hostsharing.net/impressum"))); + layout.addComponent(new Link(localeConfig.getText("impressum.label"), new ExternalResource(localeConfig.getText("impressum.link")))); } private void initTable() throws HsarwebException { @@ -142,15 +154,21 @@ public abstract class GenericModule implements Serializable { try { table.setWidth(100.0f, Sizeable.UNITS_PERCENTAGE); table.setHeight(100.0f, Sizeable.UNITS_PERCENTAGE); - table.setSelectable(true); + table.setSelectable(false); table.setImmediate(true); table.setColumnCollapsingAllowed(true); table.setColumnReorderingAllowed(true); for (PropertyConfig prop : getModuleConfig().getPropertyList()) { - table.addContainerProperty(prop.getId(), prop.getType(), prop.getDefaultValue()); - table.setColumnHeader(prop.getId(), prop.getLabel()); - if (prop.isHidden()) { - table.setColumnCollapsed(prop.getId(), true); + PropertyTableColumn propTableColumn = prop.getPropTableColumn(); + if (propTableColumn != PropertyTableColumn.NONE) { + table.addContainerProperty(prop.getId(), prop.getType(), prop.getDefaultValue()); + table.setColumnHeader(prop.getId(), prop.getLabel()); + if (propTableColumn == PropertyTableColumn.HIDDEN) { + table.setColumnCollapsed(prop.getId(), true); + } + if (propTableColumn == PropertyTableColumn.INTERNAL_KEY) { + table.setColumnCollapsed(prop.getId(), true); + } } } if (getModuleConfig().isUpdateAble()) { @@ -171,52 +189,57 @@ public abstract class GenericModule implements Serializable { private void loadTable() throws HsarwebException { table.removeAllItems(); try { - Object callSearch = application.getRemote().callSearch(getModuleConfig().getName(), new HashMap()); - List propertyList = getModuleConfig().getPropertyList(); + ModuleConfig moduleConfig = getModuleConfig(); + Object callSearch = application.getRemote().callSearch(moduleConfig.getName(), new HashMap()); + List propertyList = moduleConfig.getPropertyList(); if (callSearch instanceof Object[]) { for (Object row : ((Object[])callSearch)) { long oid = -1L; if (row instanceof Map) { int numOfcolumns = propertyList.size(); - if (getModuleConfig().isUpdateAble()) { + if (moduleConfig.isUpdateAble()) { numOfcolumns++; } - if (getModuleConfig().isDeleteAble()) { + if (moduleConfig.isDeleteAble()) { numOfcolumns++; } + numOfcolumns = moduleConfig.getNumOfColumns(); Object[] itemData = new Object[numOfcolumns]; int idx = 0; for (PropertyConfig prop : propertyList) { - Object valueObject = ((Map) row).get(prop.getId()); - if (valueObject != null && valueObject instanceof String) { - if (Long.class.equals(prop.getType())) { - itemData[idx] = Long.parseLong((String) valueObject); - } - if (Date.class.equals(prop.getType())) { - try { - itemData[idx] = df.parse((String) valueObject); - } catch (ParseException e) { - Calendar cal = Calendar.getInstance(); - cal.clear(); - itemData[idx] = cal.getTime(); - } - } - if (String.class.equals(prop.getType())) { - itemData[idx] = (String) valueObject; - } - if (prop.isIdent() && Long.class.equals(prop.getType())) { - if (valueObject instanceof String) { - oid = Long.parseLong((String) valueObject); + PropertyTableColumn propTableColumn = prop.getPropTableColumn(); + if (propTableColumn != PropertyTableColumn.NONE) { + Object valueObject = ((Map) row).get(prop.getId()); + if (valueObject != null && valueObject instanceof String) { + if (Long.class.equals(prop.getType())) { + itemData[idx] = Long.parseLong((String) valueObject); + } + if (Date.class.equals(prop.getType())) { + try { + itemData[idx] = df.parse((String) valueObject); + } catch (ParseException e) { + Calendar cal = Calendar.getInstance(); + cal.clear(); + itemData[idx] = cal.getTime(); + } + } + if (String.class.equals(prop.getType())) { + itemData[idx] = (String) valueObject; + } + if (propTableColumn == PropertyTableColumn.INTERNAL_KEY && Long.class.equals(prop.getType())) { + if (valueObject instanceof String) { + oid = Long.parseLong((String) valueObject); + } } } + idx++; } - idx++; } - if (getModuleConfig().isUpdateAble()) { + if (moduleConfig.isUpdateAble()) { itemData[idx] = createEditButton(oid); idx++; } - if (getModuleConfig().isDeleteAble()) { + if (moduleConfig.isDeleteAble()) { itemData[idx] = createDeleteButton(oid); idx++; } @@ -244,12 +267,7 @@ public abstract class GenericModule implements Serializable { Iterator componentIterator = form.getLayout().getComponentIterator(); while (componentIterator.hasNext()) { Component c = componentIterator.next(); - if (c instanceof TextField) { - TextField tf = (TextField) c; - Object data = tf.getData(); - Object value = tf.getValue(); - setHash.put((String) data, (String) value); - } + transferToHash(setHash, c); } application.getRemote().callUpdate(getModuleConfig().getName(), setHash, whereHash); loadTable(); @@ -260,22 +278,33 @@ public abstract class GenericModule implements Serializable { Iterator componentIterator = form.getLayout().getComponentIterator(); while (componentIterator.hasNext()) { Component c = componentIterator.next(); - if (c instanceof TextField) { - TextField tf = (TextField) c; - Object data = tf.getData(); - Object value = tf.getValue(); - setHash.put((String) data, (String) value); - } + transferToHash(setHash, c); } application.getRemote().callAdd(getModuleConfig().getName(), setHash); loadTable(); } + private void transferToHash(Map setHash, Component c) { + if (c instanceof AbstractTextField) { + AbstractTextField tf = (AbstractTextField) c; + Object data = tf.getData(); + Object value = tf.getValue(); + setHash.put((String) data, (String) value); + } + if (c instanceof Select) { + Select sel = (Select) c; + Object data = sel.getData(); + Object value = sel.getValue(); + setHash.put((String) data, (String) value); + } + } + private String findIdKey() { List propertyList = getModuleConfig().getPropertyList(); String idKey = null; for (PropertyConfig propConf : propertyList) { - if (propConf.isIdent()) { + PropertyTableColumn propTableColumn = propConf.getPropTableColumn(); + if (PropertyTableColumn.INTERNAL_KEY == propTableColumn) { idKey = propConf.getId(); return idKey; } @@ -398,13 +427,34 @@ public abstract class GenericModule implements Serializable { f.setData(key); Layout layout = f.getLayout(); for (PropertyConfig prop : getModuleConfig().getPropertyList()) { - if (!prop.isIdent()) { - TextField tf = new TextField(prop.getLabel()); - tf.setData(prop.getId()); - tf.setWidth(480.0f, Sizeable.UNITS_PIXELS); - Object value = row.get(prop.getId()); - tf.setValue(value != null ? value : ""); - layout.addComponent(tf); + PropertyFormField propFormField = prop.getPropFormField(); + if (propFormField != PropertyFormField.INTERNAL_KEY && propFormField != PropertyFormField.NONE) { + if (prop.hasSelectList()) { + Select sel = new Select(prop.getLabel()); + sel.setData(prop.getId()); + sel.setNullSelectionAllowed(false); + sel.setNewItemsAllowed(prop.newItemsAllowed()); + Map selectValues = prop.getSelectValues(); + for (Object skey : selectValues.keySet()) { + sel.addItem(skey); + sel.setItemCaption(skey, selectValues.get(skey)); + } + sel.setWidth(480.0f, Sizeable.UNITS_PIXELS); + Object value = row.get(prop.getId()); + sel.setValue(value != null ? value : prop.getDefaultValue()); + sel.setReadOnly(PropertyFormField.READONLY == propFormField || PropertyFormField.WRITEONCE == propFormField); + layout.addComponent(sel); + } else { + if (propFormField != PropertyFormField.PASSWORD) { + TextField tf = new TextField(prop.getLabel()); + tf.setData(prop.getId()); + tf.setWidth(480.0f, Sizeable.UNITS_PIXELS); + Object value = row.get(prop.getId()); + tf.setValue(value != null ? value : prop.getDefaultValue()); + tf.setReadOnly(PropertyFormField.READONLY == propFormField || PropertyFormField.WRITEONCE == propFormField); + layout.addComponent(tf); + } + } } } return f; @@ -421,12 +471,41 @@ public abstract class GenericModule implements Serializable { f.setCaption(getModuleConfig().getLabel("new")); Layout layout = f.getLayout(); for (PropertyConfig prop : getModuleConfig().getPropertyList()) { - if (!prop.isIdent()) { - TextField tf = new TextField(prop.getLabel()); - tf.setData(prop.getId()); - tf.setWidth(480.0f, Sizeable.UNITS_PIXELS); - tf.setValue(""); - layout.addComponent(tf); + PropertyFormField propFormField = prop.getPropFormField(); + if (PropertyFormField.READWRITE == propFormField || PropertyFormField.WRITEONCE == propFormField || PropertyFormField.PASSWORD == propFormField) { + if (prop.hasSelectList()) { + Select sel = new Select(prop.getLabel()); + sel.setData(prop.getId()); + sel.setNullSelectionAllowed(false); + sel.setNewItemsAllowed(prop.newItemsAllowed()); + Map selectValues = prop.getSelectValues(); + for (Object key : selectValues.keySet()) { + sel.addItem(key); + sel.setItemCaption(key, selectValues.get(key)); + } + sel.setWidth(480.0f, Sizeable.UNITS_PIXELS); + sel.setValue(prop.getDefaultValue()); + layout.addComponent(sel); + } else { + if (PropertyFormField.PASSWORD == propFormField) { + PasswordField tf1 = new PasswordField(getModuleConfig().getLabel(prop.getId() + "1")); + tf1.setData(prop.getId()); + tf1.setWidth(480.0f, Sizeable.UNITS_PIXELS); + tf1.setValue(prop.getDefaultValue()); + layout.addComponent(tf1); + PasswordField tf2 = new PasswordField(getModuleConfig().getLabel(prop.getId() + "2")); + tf2.setData(prop.getId()); + tf2.setWidth(480.0f, Sizeable.UNITS_PIXELS); + tf2.setValue(prop.getDefaultValue()); + layout.addComponent(tf2); + } else { + TextField tf = new TextField(prop.getLabel()); + tf.setData(prop.getId()); + tf.setWidth(480.0f, Sizeable.UNITS_PIXELS); + tf.setValue(prop.getDefaultValue()); + layout.addComponent(tf); + } + } } } return f; diff --git a/hsarweb/src/de/hsadmin/web/MainApplication.java b/hsarweb/src/de/hsadmin/web/MainApplication.java index 4641cee..01c1016 100644 --- a/hsarweb/src/de/hsadmin/web/MainApplication.java +++ b/hsarweb/src/de/hsadmin/web/MainApplication.java @@ -95,7 +95,7 @@ public class MainApplication extends Application implements HttpServletRequestLi return servletContext.getInitParameter(string); } - public Object getLogin() { + public String getLogin() { return userPrincipal.getName(); } diff --git a/hsarweb/src/de/hsadmin/web/QueueTaskModule.java b/hsarweb/src/de/hsadmin/web/QueueTaskModule.java index b541500..1c0c3d8 100644 --- a/hsarweb/src/de/hsadmin/web/QueueTaskModule.java +++ b/hsarweb/src/de/hsadmin/web/QueueTaskModule.java @@ -4,6 +4,7 @@ import java.util.Date; import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.PropertyConfig; +import de.hsadmin.web.config.PropertyTableColumn; public class QueueTaskModule extends GenericModule { @@ -11,20 +12,21 @@ public class QueueTaskModule extends GenericModule { private ModuleConfig moduleConfig; - public QueueTaskModule() { + @Override + protected void initModule() { moduleConfig = new ModuleConfig("q"); moduleConfig.setUpdateAble(false); moduleConfig.setDeleteAble(false); moduleConfig.setAddAble(false); moduleConfig.setSearchAble(false); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, true, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "title", String.class)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "status", String.class)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "started", Date.class)); moduleConfig.addProperty(new PropertyConfig(moduleConfig, "finished", Date.class)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "user", String.class, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "details", String.class, true)); - moduleConfig.addProperty(new PropertyConfig(moduleConfig, "exception", String.class, true)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "user", String.class, PropertyTableColumn.HIDDEN)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "details", String.class, PropertyTableColumn.HIDDEN)); + moduleConfig.addProperty(new PropertyConfig(moduleConfig, "exception", String.class, PropertyTableColumn.HIDDEN)); } @Override diff --git a/hsarweb/src/de/hsadmin/web/UnixUserModule.java b/hsarweb/src/de/hsadmin/web/UnixUserModule.java index 4d374e8..b4f69b0 100644 --- a/hsarweb/src/de/hsadmin/web/UnixUserModule.java +++ b/hsarweb/src/de/hsadmin/web/UnixUserModule.java @@ -1,7 +1,14 @@ package de.hsadmin.web; +import java.util.Map; +import java.util.TreeMap; + import de.hsadmin.web.config.ModuleConfig; import de.hsadmin.web.config.PropertyConfig; +import de.hsadmin.web.config.PropertyDefaultValue; +import de.hsadmin.web.config.PropertyFormField; +import de.hsadmin.web.config.PropertySelectValues; +import de.hsadmin.web.config.PropertyTableColumn; public class UnixUserModule extends GenericModule { @@ -9,28 +16,89 @@ public class UnixUserModule extends GenericModule { private ModuleConfig moduleConfig; - public UnixUserModule() { + @Override + protected void initModule() { moduleConfig = new ModuleConfig("user"); - PropertyConfig propId = new PropertyConfig(moduleConfig, "id", Long.class, true, true); - moduleConfig.addProperty(propId); - PropertyConfig propUserId = new PropertyConfig(moduleConfig, "userid", Long.class, true); - moduleConfig.addProperty(propUserId); - PropertyConfig propUserName = new PropertyConfig(moduleConfig, "name", String.class); - moduleConfig.addProperty(propUserName); - PropertyConfig propUserComment = new PropertyConfig(moduleConfig, "comment", String.class); - moduleConfig.addProperty(propUserComment); - PropertyConfig propShell = new PropertyConfig(moduleConfig, "shell", String.class); - moduleConfig.addProperty(propShell); - PropertyConfig propHomeDir = new PropertyConfig(moduleConfig, "homedir", String.class, true); - moduleConfig.addProperty(propHomeDir); - PropertyConfig propPacket = new PropertyConfig(moduleConfig, "pac", String.class, true); - moduleConfig.addProperty(propPacket); - PropertyConfig propSoftQuota = new PropertyConfig(moduleConfig, "quota_softlimit", Long.class, true); - moduleConfig.addProperty(propSoftQuota); - PropertyConfig propHardQuota = new PropertyConfig(moduleConfig, "quota_hardlimit", Long.class, true); - moduleConfig.addProperty(propHardQuota); + String login = getApplication().getLogin(); + final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; + PropertyConfig useridProp = new PropertyConfig(moduleConfig, "userid", Long.class, PropertyTableColumn.HIDDEN, PropertyFormField.READONLY); + PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY, PropertyFormField.INTERNAL_KEY); + PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class, PropertyFormField.WRITEONCE); + nameProp.setDefaultValue(new PropertyDefaultValue() { + @Override + public String getDefaultValue() { + if (pac.length() > 0) { + return pac + "-"; + } + return ""; + } + }); + PropertyConfig passwordProp = new PropertyConfig(moduleConfig, "password", String.class, PropertyTableColumn.NONE, PropertyFormField.PASSWORD); + PropertyConfig commentProp = new PropertyConfig(moduleConfig, "comment", String.class); + PropertyConfig shellProp = new PropertyConfig(moduleConfig, "shell", String.class); + shellProp.setDefaultValue(new PropertyDefaultValue() { + @Override + public String getDefaultValue() { + return "/usr/bin/passwd"; + } + }); + shellProp.setSelectValues(new PropertySelectValues() { + @Override + public boolean newItemsAllowed() { + return false; + } + @Override + public Map getSelectValues() { + Map map = new TreeMap(); + map.put("/usr/bin/passwd", "/usr/bin/passwd"); + map.put("/bin/bash", "/bin/bash"); + map.put("/bin/dash", "/bin/dash"); + map.put("/bin/csh", "/bin/csh"); + map.put("/bin/tcsh", "/bin/tcsh"); + map.put("/bin/ksh", "/bin/ksh"); + map.put("/bin/zsh", "/bin/zsh"); + map.put("/usr/bin/scponly", "/usr/bin/scponly"); + return map; + } + @Override + public boolean hasSelectList() { + return true; + } + }); + PropertyConfig homedirProp = new PropertyConfig(moduleConfig, "homedir", String.class, PropertyTableColumn.HIDDEN, PropertyFormField.READONLY); + PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, PropertyFormField.READONLY); + pacProp.setDefaultValue(new PropertyDefaultValue() { + @Override + public String getDefaultValue() { + return pac; + } + }); + PropertyConfig softQuotaProp = new PropertyConfig(moduleConfig, "quota_softlimit", Long.class, PropertyTableColumn.HIDDEN); + softQuotaProp.setDefaultValue(new PropertyDefaultValue() { + @Override + public String getDefaultValue() { + return "0"; + } + }); + PropertyConfig hardQuotaProp = new PropertyConfig(moduleConfig, "quota_hardlimit", Long.class, PropertyTableColumn.HIDDEN); + hardQuotaProp.setDefaultValue(new PropertyDefaultValue() { + @Override + public String getDefaultValue() { + return "0"; + } + }); + moduleConfig.addProperty(idProp); + moduleConfig.addProperty(useridProp); + moduleConfig.addProperty(nameProp); + moduleConfig.addProperty(passwordProp); + moduleConfig.addProperty(commentProp); + moduleConfig.addProperty(shellProp); + moduleConfig.addProperty(homedirProp); + moduleConfig.addProperty(pacProp); + moduleConfig.addProperty(softQuotaProp); + moduleConfig.addProperty(hardQuotaProp); } - + @Override public ModuleConfig getModuleConfig() { return moduleConfig; diff --git a/hsarweb/src/de/hsadmin/web/config/ModuleConfig.java b/hsarweb/src/de/hsadmin/web/config/ModuleConfig.java index ac5e3f5..762c67b 100644 --- a/hsarweb/src/de/hsadmin/web/config/ModuleConfig.java +++ b/hsarweb/src/de/hsadmin/web/config/ModuleConfig.java @@ -83,5 +83,21 @@ public class ModuleConfig implements Serializable { public void setSearchAble(boolean searchAble) { this.searchAble = searchAble; } + + public int getNumOfColumns() { + int numOfCols = 0; + for (PropertyConfig prop : propertyList) { + if (prop.getPropTableColumn() != PropertyTableColumn.NONE) { + numOfCols++; + } + } + if (isUpdateAble()) { + numOfCols++; + } + if (isDeleteAble()) { + numOfCols++; + } + return numOfCols; + } } diff --git a/hsarweb/src/de/hsadmin/web/config/PropertyConfig.java b/hsarweb/src/de/hsadmin/web/config/PropertyConfig.java index e4ee6b9..372303c 100644 --- a/hsarweb/src/de/hsadmin/web/config/PropertyConfig.java +++ b/hsarweb/src/de/hsadmin/web/config/PropertyConfig.java @@ -1,53 +1,65 @@ package de.hsadmin.web.config; import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; -public class PropertyConfig implements Serializable { +public class PropertyConfig implements Serializable, PropertyDefaultValue, PropertySelectValues { private static final long serialVersionUID = 1L; private ModuleConfig moduleConfig; private String id; private Class type; - private String defaultValue; - private boolean hidden; - private boolean ident; + private PropertyTableColumn propTableColumn; + private PropertyFormField propFormField; + private PropertyDefaultValue defaultValue; + private PropertySelectValues selectValues; public PropertyConfig(ModuleConfig moduleConfig, String id, Class clasz) { this.moduleConfig = moduleConfig; this.id = id; this.type = clasz; - this.defaultValue = ""; - this.setHidden(false); - this.setIdent(false); + this.propTableColumn = PropertyTableColumn.DISPLAY; + this.propFormField = PropertyFormField.READWRITE; + this.defaultValue = null; + this.selectValues = null; } - public PropertyConfig(ModuleConfig moduleConfig, String id, Class clasz, boolean hidden) { + public PropertyConfig(ModuleConfig moduleConfig, String id, Class clasz, PropertyFormField formField) { this.moduleConfig = moduleConfig; this.id = id; this.type = clasz; - this.defaultValue = ""; - this.setHidden(hidden); - this.setIdent(false); + this.propTableColumn = PropertyTableColumn.DISPLAY; + this.propFormField = formField; + this.defaultValue = null; + this.selectValues = null; } - public PropertyConfig(ModuleConfig moduleConfig, String id, Class clasz, boolean hidden, boolean ident) { + public PropertyConfig(ModuleConfig moduleConfig, String id, Class clasz, PropertyTableColumn tablecolumn) { this.moduleConfig = moduleConfig; this.id = id; this.type = clasz; - this.defaultValue = ""; - this.setHidden(hidden); - this.setIdent(ident); + this.propTableColumn = tablecolumn; + this.propFormField = PropertyFormField.READWRITE; + this.defaultValue = null; + this.selectValues = null; + } + + public PropertyConfig(ModuleConfig moduleConfig, String id, Class clasz, PropertyTableColumn tablecolumn, PropertyFormField formField) { + this.moduleConfig = moduleConfig; + this.id = id; + this.type = clasz; + this.propTableColumn = tablecolumn; + this.propFormField = formField; + this.defaultValue = null; + this.selectValues = null; } public String getId() { return id; } - public void setId(String id) { - this.id = id; - } - public String getLabel() { return moduleConfig.getLabel(id); } @@ -56,32 +68,49 @@ public class PropertyConfig implements Serializable { return type; } - public void setType(Class type) { - this.type = type; + public PropertyTableColumn getPropTableColumn() { + return propTableColumn; } - public String getDefaultValue() { - return defaultValue; + public PropertyFormField getPropFormField() { + return propFormField; } - public void setDefaultValue(String defaultValue) { + public void setDefaultValue(PropertyDefaultValue defaultValue) { this.defaultValue = defaultValue; } - public void setHidden(boolean hidden) { - this.hidden = hidden; + public void setSelectValues(PropertySelectValues selectValues) { + this.selectValues = selectValues; } - public boolean isHidden() { - return hidden; + public String getDefaultValue() { + if (defaultValue != null) { + return defaultValue.getDefaultValue(); + } + return ""; } - public void setIdent(boolean ident) { - this.ident = ident; + public Map getSelectValues() { + if (selectValues != null) { + return selectValues.getSelectValues(); + } + return new HashMap(); + } + + public boolean newItemsAllowed() { + if (selectValues != null) { + return selectValues.newItemsAllowed(); + } + return propFormField == PropertyFormField.READWRITE || propFormField == PropertyFormField.WRITEONCE; } - public boolean isIdent() { - return ident; + @Override + public boolean hasSelectList() { + if (selectValues != null) { + return selectValues.hasSelectList(); + } + return false; } - + } diff --git a/hsarweb/src/de/hsadmin/web/config/PropertyDefaultValue.java b/hsarweb/src/de/hsadmin/web/config/PropertyDefaultValue.java new file mode 100644 index 0000000..0abfbf1 --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/config/PropertyDefaultValue.java @@ -0,0 +1,7 @@ +package de.hsadmin.web.config; + +public interface PropertyDefaultValue { + + public abstract String getDefaultValue(); + +} diff --git a/hsarweb/src/de/hsadmin/web/config/PropertyFormField.java b/hsarweb/src/de/hsadmin/web/config/PropertyFormField.java new file mode 100644 index 0000000..cc0da81 --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/config/PropertyFormField.java @@ -0,0 +1,10 @@ +package de.hsadmin.web.config; + +public enum PropertyFormField { + INTERNAL_KEY, + READWRITE, + WRITEONCE, + READONLY, + PASSWORD, + NONE +} diff --git a/hsarweb/src/de/hsadmin/web/config/PropertySelectValues.java b/hsarweb/src/de/hsadmin/web/config/PropertySelectValues.java new file mode 100644 index 0000000..de64070 --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/config/PropertySelectValues.java @@ -0,0 +1,13 @@ +package de.hsadmin.web.config; + +import java.util.Map; + +public interface PropertySelectValues { + + public abstract Map getSelectValues(); + + public abstract boolean newItemsAllowed(); + + public abstract boolean hasSelectList(); + +} diff --git a/hsarweb/src/de/hsadmin/web/config/PropertyTableColumn.java b/hsarweb/src/de/hsadmin/web/config/PropertyTableColumn.java new file mode 100644 index 0000000..7b6821c --- /dev/null +++ b/hsarweb/src/de/hsadmin/web/config/PropertyTableColumn.java @@ -0,0 +1,8 @@ +package de.hsadmin.web.config; + +public enum PropertyTableColumn { + INTERNAL_KEY, + DISPLAY, + HIDDEN, + NONE +} diff --git a/hsarweb/src/texts/domain.properties b/hsarweb/src/texts/domain.properties index 09ccef3..6f6b42c 100644 --- a/hsarweb/src/texts/domain.properties +++ b/hsarweb/src/texts/domain.properties @@ -6,4 +6,5 @@ hive=host since=connected since moduletitle=domains moduleicon=../runo/icons/16/document-web.png -new=configure domain \ No newline at end of file +new=configure domain +update=update domain \ No newline at end of file diff --git a/hsarweb/src/texts/domain_de.properties b/hsarweb/src/texts/domain_de.properties index c3cf973..b6f93f3 100644 --- a/hsarweb/src/texts/domain_de.properties +++ b/hsarweb/src/texts/domain_de.properties @@ -6,4 +6,5 @@ hive=Server since=aufgeschaltet seit moduletitle=Domains moduleicon=../runo/icons/16/document-web.png -new=Domain konfigurieren \ No newline at end of file +new=Domain konfigurieren +update=Domaindaten ändern \ No newline at end of file diff --git a/hsarweb/src/texts/emailaddress.properties b/hsarweb/src/texts/emailaddress.properties index da1ec4c..c307618 100644 --- a/hsarweb/src/texts/emailaddress.properties +++ b/hsarweb/src/texts/emailaddress.properties @@ -9,4 +9,5 @@ pac=packet fulldomain=full domain moduletitle=email addresses moduleicon=../runo/icons/16/email.png -new=create address \ No newline at end of file +new=create address +update=update address \ No newline at end of file diff --git a/hsarweb/src/texts/emailaddress_de.properties b/hsarweb/src/texts/emailaddress_de.properties index 9e73654..20fef93 100644 --- a/hsarweb/src/texts/emailaddress_de.properties +++ b/hsarweb/src/texts/emailaddress_de.properties @@ -9,4 +9,5 @@ pac=Paket fulldomain=volle Domain moduletitle=EMail Adressen moduleicon=../runo/icons/16/email.png -new=EMail-Adresse anlegen \ No newline at end of file +new=EMail-Adresse anlegen +update=EMail-Adresse ändern \ No newline at end of file diff --git a/hsarweb/src/texts/emailalias.properties b/hsarweb/src/texts/emailalias.properties index 8fc13f7..9f07ec9 100644 --- a/hsarweb/src/texts/emailalias.properties +++ b/hsarweb/src/texts/emailalias.properties @@ -4,4 +4,5 @@ target=target(s) pac=packet moduletitle=email aliases moduleicon=../runo/icons/16/email-send.png -new=create alias \ No newline at end of file +new=create alias +update=update alias \ No newline at end of file diff --git a/hsarweb/src/texts/emailalias_de.properties b/hsarweb/src/texts/emailalias_de.properties index b2d5671..ec50929 100644 --- a/hsarweb/src/texts/emailalias_de.properties +++ b/hsarweb/src/texts/emailalias_de.properties @@ -4,4 +4,5 @@ target=Ziel(e) pac=Paket moduletitle=EMail Aliases moduleicon=../runo/icons/16/email-send.png -new=EMail-Alias anlegen \ No newline at end of file +new=EMail-Alias anlegen +update=EMail-Alias ändern \ No newline at end of file diff --git a/hsarweb/src/texts/main.properties b/hsarweb/src/texts/main.properties index e654477..2eff361 100644 --- a/hsarweb/src/texts/main.properties +++ b/hsarweb/src/texts/main.properties @@ -3,4 +3,7 @@ update=update delete=delete confirmdelete=confirm delete save=save -abort=abort \ No newline at end of file +abort=abort +new=new +impressum.label=Published by +impressum.link=http://www.hostsharing.net/impressum \ No newline at end of file diff --git a/hsarweb/src/texts/main_de.properties b/hsarweb/src/texts/main_de.properties index 9a1e627..9ab358d 100644 --- a/hsarweb/src/texts/main_de.properties +++ b/hsarweb/src/texts/main_de.properties @@ -3,4 +3,7 @@ update=bearbeiten delete=löschen confirmdelete=Diesen Eintrag löschen? save=speichern -abort=abbrechen \ No newline at end of file +abort=abbrechen +new=Eintrag anlegen +impressum.label=Impressum +impressum.link=http://www.hostsharing.net/impressum \ No newline at end of file diff --git a/hsarweb/src/texts/user.properties b/hsarweb/src/texts/user.properties index 9401245..9ca404b 100644 --- a/hsarweb/src/texts/user.properties +++ b/hsarweb/src/texts/user.properties @@ -1,5 +1,7 @@ id=identifier name=username +password1=password +password2=repeat password comment=comment shell=shell userid=numeric userid @@ -9,4 +11,5 @@ quota_softlimit=quota soft limit quota_hardlimit=quota hard limit moduletitle=unix user new=create user +update=update user moduleicon=../runo/icons/16/users.png \ No newline at end of file diff --git a/hsarweb/src/texts/user_de.properties b/hsarweb/src/texts/user_de.properties index 500dac5..c95ffdd 100644 --- a/hsarweb/src/texts/user_de.properties +++ b/hsarweb/src/texts/user_de.properties @@ -1,5 +1,7 @@ id=Schlüssel name=Benutzername +password1=Passwort +password2=Passwort (Wdhlg.) comment=Kommentar shell=Shell userid=Benutzerkennung @@ -9,4 +11,5 @@ quota_softlimit=Soft-Quota [MB] quota_hardlimit=Hard-Quota [MB] moduletitle=Unix User moduleicon=../runo/icons/16/users.png -new=Benutzer anlegen \ No newline at end of file +new=Benutzer anlegen +update=Benutzer ändern \ No newline at end of file