Felder fuer: Passwort, Auswahl, Read-Only etc.

Update der Vaadin-Lib auf 6.5.3
This commit is contained in:
Peter Hormanns 2011-03-18 19:45:27 +00:00
parent a1c1b35b83
commit fea45e7c91
25 changed files with 565 additions and 150 deletions

Binary file not shown.

View File

@ -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<String, String> getSelectValues() {
List<String> list = getUsers();
TreeMap<String,String> map = new TreeMap<String, String>();
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<String> getUsers() {
ArrayList<String> list = new ArrayList<String>();
try {
Object callSearch = getApplication().getRemote().callSearch("user", new HashMap<String, String>());
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;
}
}

View File

@ -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<String, String> getSelectValues() {
Map<String, String> map = new TreeMap<String, String>();
List<String> 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<String> getDomains() {
ArrayList<String> list = new ArrayList<String>();
try {
Object callSearch = getApplication().getRemote().callSearch("domain", new HashMap<String, String>());
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;
}
}

View File

@ -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

View File

@ -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<String, String>());
List<PropertyConfig> propertyList = getModuleConfig().getPropertyList();
ModuleConfig moduleConfig = getModuleConfig();
Object callSearch = application.getRemote().callSearch(moduleConfig.getName(), new HashMap<String, String>());
List<PropertyConfig> 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<Component> 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<Component> 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<String, String> 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<PropertyConfig> 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<String, String> 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<String, String> 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;

View File

@ -95,7 +95,7 @@ public class MainApplication extends Application implements HttpServletRequestLi
return servletContext.getInitParameter(string);
}
public Object getLogin() {
public String getLogin() {
return userPrincipal.getName();
}

View File

@ -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

View File

@ -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<String, String> getSelectValues() {
Map<String,String> map = new TreeMap<String, String>();
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;

View File

@ -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;
}
}

View File

@ -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<String, String> getSelectValues() {
if (selectValues != null) {
return selectValues.getSelectValues();
}
return new HashMap<String, String>();
}
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;
}
}

View File

@ -0,0 +1,7 @@
package de.hsadmin.web.config;
public interface PropertyDefaultValue {
public abstract String getDefaultValue();
}

View File

@ -0,0 +1,10 @@
package de.hsadmin.web.config;
public enum PropertyFormField {
INTERNAL_KEY,
READWRITE,
WRITEONCE,
READONLY,
PASSWORD,
NONE
}

View File

@ -0,0 +1,13 @@
package de.hsadmin.web.config;
import java.util.Map;
public interface PropertySelectValues {
public abstract Map<String, String> getSelectValues();
public abstract boolean newItemsAllowed();
public abstract boolean hasSelectList();
}

View File

@ -0,0 +1,8 @@
package de.hsadmin.web.config;
public enum PropertyTableColumn {
INTERNAL_KEY,
DISPLAY,
HIDDEN,
NONE
}

View File

@ -6,4 +6,5 @@ hive=host
since=connected since
moduletitle=domains
moduleicon=../runo/icons/16/document-web.png
new=configure domain
new=configure domain
update=update domain

View File

@ -6,4 +6,5 @@ hive=Server
since=aufgeschaltet seit
moduletitle=Domains
moduleicon=../runo/icons/16/document-web.png
new=Domain konfigurieren
new=Domain konfigurieren
update=Domaindaten ändern

View File

@ -9,4 +9,5 @@ pac=packet
fulldomain=full domain
moduletitle=email addresses
moduleicon=../runo/icons/16/email.png
new=create address
new=create address
update=update address

View File

@ -9,4 +9,5 @@ pac=Paket
fulldomain=volle Domain
moduletitle=EMail Adressen
moduleicon=../runo/icons/16/email.png
new=EMail-Adresse anlegen
new=EMail-Adresse anlegen
update=EMail-Adresse ändern

View File

@ -4,4 +4,5 @@ target=target(s)
pac=packet
moduletitle=email aliases
moduleicon=../runo/icons/16/email-send.png
new=create alias
new=create alias
update=update alias

View File

@ -4,4 +4,5 @@ target=Ziel(e)
pac=Paket
moduletitle=EMail Aliases
moduleicon=../runo/icons/16/email-send.png
new=EMail-Alias anlegen
new=EMail-Alias anlegen
update=EMail-Alias ändern

View File

@ -3,4 +3,7 @@ update=update
delete=delete
confirmdelete=confirm delete
save=save
abort=abort
abort=abort
new=new
impressum.label=Published by
impressum.link=http://www.hostsharing.net/impressum

View File

@ -3,4 +3,7 @@ update=bearbeiten
delete=löschen
confirmdelete=Diesen Eintrag löschen?
save=speichern
abort=abbrechen
abort=abbrechen
new=Eintrag anlegen
impressum.label=Impressum
impressum.link=http://www.hostsharing.net/impressum

View File

@ -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

View File

@ -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
new=Benutzer anlegen
update=Benutzer ändern