HSAdmin Backend Domains, E-Mail, Datenbanken
Peter Hormanns
2012-12-18 d9afe25155a68ee07c010e55a924aaa7a2e03457
merged ArstractProperty, pac-prefix editor everywhere
19 files modified
165 ■■■■ changed files
hsarweb/src/de/hsadmin/web/AbstractProperty.java 4 ●●● patch | view | raw | blame | history
hsarweb/src/de/hsadmin/web/DatabaseModule.java 28 ●●●● patch | view | raw | blame | history
hsarweb/src/de/hsadmin/web/DatabaseUserModule.java 30 ●●●● patch | view | raw | blame | history
hsarweb/src/de/hsadmin/web/HomeModule.java 12 ●●●● patch | view | raw | blame | history
hsarweb/src/de/hsadmin/web/ItemsReader.java 2 ●●● patch | view | raw | blame | history
hsarweb/src/de/hsadmin/web/ListOfStringsProperty.java 19 ●●●● patch | view | raw | blame | history
hsarweb/src/de/hsadmin/web/Remote.java 29 ●●●●● patch | view | raw | blame | history
hsarweb/src/de/hsadmin/web/StringProperty.java 6 ●●●●● patch | view | raw | blame | history
hsarweb/src/de/hsadmin/web/UnixUserModule.java 1 ●●●● patch | view | raw | blame | history
hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java 4 ●●●● patch | view | raw | blame | history
hsarweb/src/de/hsadmin/web/vaadin/PacPrefixedNamePropertyFieldFactory.java 6 ●●●●● patch | view | raw | blame | history
hsarweb/src/texts/mysqldb.properties 3 ●●●●● patch | view | raw | blame | history
hsarweb/src/texts/mysqldb_de.properties 3 ●●●●● patch | view | raw | blame | history
hsarweb/src/texts/mysqluser.properties 3 ●●●●● patch | view | raw | blame | history
hsarweb/src/texts/mysqluser_de.properties 3 ●●●●● patch | view | raw | blame | history
hsarweb/src/texts/postgresqldb.properties 3 ●●●●● patch | view | raw | blame | history
hsarweb/src/texts/postgresqldb_de.properties 3 ●●●●● patch | view | raw | blame | history
hsarweb/src/texts/postgresqluser.properties 3 ●●●●● patch | view | raw | blame | history
hsarweb/src/texts/postgresqluser_de.properties 3 ●●●●● patch | view | raw | blame | history
hsarweb/src/de/hsadmin/web/AbstractProperty.java
@@ -1,5 +1,7 @@
package de.hsadmin.web;
public class AbstractProperty {
public abstract class AbstractProperty {
    public abstract Object toXmlrpcParam();
    
}
hsarweb/src/de/hsadmin/web/DatabaseModule.java
@@ -11,6 +11,7 @@
import de.hsadmin.web.config.PropertyDefaultValue;
import de.hsadmin.web.config.PropertySelectValues;
import de.hsadmin.web.config.PropertyTableColumn;
import de.hsadmin.web.vaadin.PacPrefixedNamePropertyFieldFactory;
import de.hsadmin.web.vaadin.SelectPropertyFieldFactory;
public abstract class DatabaseModule extends GenericModule {
@@ -29,29 +30,10 @@
    protected void initModule() {
        MainApplication application = getApplication();
        moduleConfig = new ModuleConfig(getModuleIdent(), application.getLocale());
        String login = application.getRunAs();
        final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
        PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
        idProp.setReadOnly(true);
        PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class);
        nameProp.setDefaultValue(new PropertyDefaultValue() {
            @Override
            public String getDefaultValue() {
                if (pac.length() >= 5) {
                    return pac + "_";
                }
                return "";
            }
        });
        nameProp.setWriteOnce(true);
        PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory());
        pacProp.setDefaultValue(new PropertyDefaultValue() {
            @Override
            public String getDefaultValue() {
                return pac;
            }
        });
        pacProp.setSelectValues(new PropertySelectValues() {
        PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class, new PacPrefixedNamePropertyFieldFactory(this));
        nameProp.setSelectValues(new PropertySelectValues() {
            @Override
            public boolean newItemsAllowed() {
                return false;
@@ -70,7 +52,7 @@
                return map;
            }
        });
        pacProp.setWriteOnce(true);
        nameProp.setWriteOnce(true);
        PropertyConfig encodingProp = new PropertyConfig(moduleConfig, "encoding", String.class, new SelectPropertyFieldFactory());
        encodingProp.setDefaultValue(new PropertyDefaultValue() {
            @Override
@@ -125,10 +107,8 @@
            }
        });
        idProp.setShowInForm(false);
        pacProp.setShowInForm(false);
        encodingProp.setShowInForm(false);
        moduleConfig.addProperty(idProp);
        moduleConfig.addProperty(pacProp);
        moduleConfig.addProperty(nameProp);
        moduleConfig.addProperty(encodingProp);
        moduleConfig.addProperty(ownerProp);
hsarweb/src/de/hsadmin/web/DatabaseUserModule.java
@@ -6,11 +6,10 @@
import de.hsadmin.web.config.ModuleConfig;
import de.hsadmin.web.config.PropertyConfig;
import de.hsadmin.web.config.PropertyDefaultValue;
import de.hsadmin.web.config.PropertySelectValues;
import de.hsadmin.web.config.PropertyTableColumn;
import de.hsadmin.web.vaadin.PacPrefixedNamePropertyFieldFactory;
import de.hsadmin.web.vaadin.PasswordPropertyFieldFactory;
import de.hsadmin.web.vaadin.SelectPropertyFieldFactory;
public abstract class DatabaseUserModule extends GenericModule {
@@ -24,29 +23,10 @@
    protected void initModule() {
        MainApplication application = getApplication();
        moduleConfig = new ModuleConfig(getModuleIdent(), application.getLocale());
        String login = application.getRunAs();
        final String pac = login.length() >= 5 ? login.substring(0, 5) : "";
        PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY);
        idProp.setReadOnly(true);
        PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class);
        nameProp.setDefaultValue(new PropertyDefaultValue() {
            @Override
            public String getDefaultValue() {
                if (pac.length() >= 5) {
                    return pac + "_";
                }
                return "";
            }
        });
        nameProp.setWriteOnce(true);
        PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory());
        pacProp.setDefaultValue(new PropertyDefaultValue() {
            @Override
            public String getDefaultValue() {
                return pac;
            }
        });
        pacProp.setSelectValues(new PropertySelectValues() {
        PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class, new PacPrefixedNamePropertyFieldFactory(this));
        nameProp.setSelectValues(new PropertySelectValues() {
            @Override
            public boolean newItemsAllowed() {
                return false;
@@ -65,12 +45,10 @@
                return map;
            }
        });
        pacProp.setWriteOnce(true);
        nameProp.setWriteOnce(true);
        PropertyConfig passwordProp = new PropertyConfig(moduleConfig, "password", String.class, PropertyTableColumn.NONE, new PasswordPropertyFieldFactory(this));
        idProp.setShowInForm(false);
        pacProp.setShowInForm(false);
        moduleConfig.addProperty(idProp);
        moduleConfig.addProperty(pacProp);
        moduleConfig.addProperty(nameProp);
        moduleConfig.addProperty(passwordProp);
    }
hsarweb/src/de/hsadmin/web/HomeModule.java
@@ -35,8 +35,8 @@
        setComponentFactory(this);
    }
    
    public void updateRow(Map<String, String> paramHash) throws HsarwebException {
        Map<String, String> whereHash = new HashMap<String, String>();
    public void updateRow(Map<String, AbstractProperty> paramHash) throws HsarwebException {
        Map<String, AbstractProperty> whereHash = new HashMap<String, AbstractProperty>();
        String idKey = findIdKey();
        whereHash.put(idKey, paramHash.get(idKey));
        paramHash.remove(idKey);
@@ -94,8 +94,8 @@
        Button button = new Button(moduleConfig.getLabel("change_password"));
        ThemeResource icon = new ThemeResource(moduleConfig.getLabel("change_password_icon"));
        button.setIcon(icon);
        Map<String, String> whereHash = new HashMap<String, String>();
        whereHash.put("name", application.getRunAs());
        Map<String, AbstractProperty> whereHash = new HashMap<String, AbstractProperty>();
        whereHash.put("name", new StringProperty(application.getRunAs()));
        Long key = -1L;
        try {
            Object object = application.getRemote().callSearch(moduleConfig.getRemoteName(), whereHash);
@@ -130,8 +130,8 @@
                    public void buttonClick(ClickEvent event) {
                        application.getMainWindow().removeWindow(childWindow);
                        try {
                            Map<String, String> map = new HashMap<String, String>();
                            map.put("id", ((Long) event.getButton().getData()).toString());
                            Map<String, AbstractProperty> map = new HashMap<String, AbstractProperty>();
                            map.put("id", new StringProperty(((Long) event.getButton().getData()).toString()));
                            Iterator<Component> componentIterator = form.getLayout().getComponentIterator();
                            while (componentIterator.hasNext()) {
                                Component component = (Component) componentIterator.next();
hsarweb/src/de/hsadmin/web/ItemsReader.java
@@ -9,7 +9,7 @@
    
    public static List<Object>  readItemList(MainApplication app, String module, String property) throws HsarwebException {
        final List<Object> itemsList = new ArrayList<Object>();
        Object custListObj = app.getRemote().callSearch(module, new HashMap<String, String>());
        Object custListObj = app.getRemote().callSearch(module, new HashMap<String, AbstractProperty>());
        if (custListObj instanceof Object[]) {
            Object[] custList = (Object[]) custListObj;
            for (Object custObj : custList) {
hsarweb/src/de/hsadmin/web/ListOfStringsProperty.java
@@ -1,15 +1,28 @@
package de.hsadmin.web;
import java.util.ArrayList;
import java.util.List;
public class ListOfStringsProperty extends AbstractProperty {
    public List<String> properties;
    public final List<String> properties;
    
    public ListOfStringsProperty(){
// ??        this.properties = new List<String>();
        this.properties = new ArrayList<String>();
    }
    
    public boolean Add(String string){
    public boolean add(String string){
         return properties.add(string);
    }
    @Override
    public Object toXmlrpcParam() {
        String[] result = new String[properties.size()];
        int idx = 0;
        for (String prop : properties) {
            result[idx] = prop;
            idx++;
        }
        return result;
    }
}
hsarweb/src/de/hsadmin/web/Remote.java
@@ -19,35 +19,46 @@
    }
    public Object callSearch(String module, Map<String, AbstractProperty> where) throws HsarwebException {
        return xmlrpcCall(module, "search", where);
        return xmlrpcCall(module, "search", buildXmlrpcParam(where));
    }
    public void callAdd(String module, Map<String, AbstractProperty> set) throws HsarwebException {
        xmlrpcCall(module, "add", set);
        xmlrpcCall(module, "add", buildXmlrpcParam(set));
    }
    public void callUpdate(String module, Map<String, AbstractProperty> set, Map<String, AbstractProperty> where) throws HsarwebException {
        xmlrpcCall(module, "update", set, where);
        xmlrpcCall(module, "update", buildXmlrpcParam(set), buildXmlrpcParam(where));
    }
    public void callDelete(String module, Map<String, AbstractProperty> where) throws HsarwebException {
        xmlrpcCall(module, "delete", where);
        xmlrpcCall(module, "delete", buildXmlrpcParam(where));
    }
    private Object xmlrpcCall(String module, String operation, Map<String, AbstractProperty> param1) throws HsarwebException {
    private Map<String, Object> buildXmlrpcParam(Map<String, AbstractProperty> paramHash) {
        Map<String, Object> resultMap = new HashMap<String, Object>();
        if (paramHash == null) {
            return null;
        }
        for (String key : paramHash.keySet()) {
            resultMap.put(key, paramHash.get(key).toXmlrpcParam());
        }
        return resultMap;
    }
    private Object xmlrpcCall(String module, String operation, Map<String, Object> param1) throws HsarwebException {
        Object[] params = new Object[3];
        params[0] = app.getRunAs();
        params[1] = app.getProxyTicket();
        params[2] = param1 != null ? param1 : new HashMap<String, String>();
        params[2] = param1 != null ? param1 : new HashMap<String, Object>();
        return xmlrpcCall(module + "." + operation, params);
    }
    private Object xmlrpcCall(String module, String operation, Map<String, AbstractProperty> param1, Map<String, AbstractProperty> param2) throws HsarwebException {
    private Object xmlrpcCall(String module, String operation, Map<String, Object> param1, Map<String, Object> param2) throws HsarwebException {
        Object[] params = new Object[4];
        params[0] = app.getRunAs();
        params[1] = app.getProxyTicket();
        params[2] = param1 != null ? param1 : new HashMap<String, String>();
        params[3] = param2 != null ? param2 : new HashMap<String, String>();
        params[2] = param1 != null ? param1 : new HashMap<String, Object>();
        params[3] = param2 != null ? param2 : new HashMap<String, Object>();
        return xmlrpcCall(module + "." + operation, params);
    }
hsarweb/src/de/hsadmin/web/StringProperty.java
@@ -1,10 +1,16 @@
package de.hsadmin.web;
public class StringProperty extends AbstractProperty {
    public String property ;
    public StringProperty(String property) {
        this.property = property;
    }
    @Override
    public Object toXmlrpcParam() {
        return property;
    }
}
hsarweb/src/de/hsadmin/web/UnixUserModule.java
@@ -37,7 +37,6 @@
            public boolean hasSelectList() {
                return true;
            }
            @Override
            public Map<String, String> getSelectValues() {
                List<String> list = getPackets();
hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java
@@ -81,8 +81,8 @@
        try {
            MainApplication application = module.getApplication();
            ModuleConfig config = module.getModuleConfig();
            Map<String, String> where = new HashMap<String, String>();
            where.put(findIdKey(), entityId.toString());
            Map<String, AbstractProperty> where = new HashMap<String, AbstractProperty>();
            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]);
hsarweb/src/de/hsadmin/web/vaadin/PacPrefixedNamePropertyFieldFactory.java
@@ -7,8 +7,10 @@
import com.vaadin.ui.Select;
import com.vaadin.ui.TextField;
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;
@@ -67,14 +69,14 @@
    }
    @Override
    public String getValue(PropertyConfig prop, Object component) throws HsarwebException {
    public AbstractProperty getValue(PropertyConfig prop, Object component) throws HsarwebException {
        ModuleConfig config = module.getModuleConfig();
        HorizontalLayout layout = (HorizontalLayout) component;
        Select sel = (Select) layout.getComponent(0);
        TextField tf = (TextField) layout.getComponent(2);
        String pacPart = (String) sel.getValue();
        String userPart = (String) tf.getValue();
        return pacPart + config.getLabel(prop.getId() + ".separator") + userPart;
        return new StringProperty(pacPart + config.getLabel(prop.getId() + ".separator") + userPart);
    }
    @Override
hsarweb/src/texts/mysqldb.properties
@@ -1,5 +1,8 @@
id=identifier
name=database
name.pacprefix=packet
name.separator=_
name.postfix=databasepart
pac=packet
encoding=encoding
owner=owner
hsarweb/src/texts/mysqldb_de.properties
@@ -1,5 +1,8 @@
id=Schlüssel
name=MySQL Datenbank
name.pacprefix=Paket
name.separator=_
name.postfix=Datenbank-Postfix
pac=Paket
encoding=Zeichensatz
owner=Verwalter
hsarweb/src/texts/mysqluser.properties
@@ -1,5 +1,8 @@
id=identifier
name=database username
name.pacprefix=packet
name.separator=_
name.postfix=userpart
password=password
password1=new password
password2=repeat password
hsarweb/src/texts/mysqluser_de.properties
@@ -1,5 +1,8 @@
id=Schlüssel
name=MySQL User
name.pacprefix=Paket
name.separator=_
name.postfix=Benutzer-Postfix
password=Passwort
password1=neues Passwort
password2=Passwort-Wiederholung
hsarweb/src/texts/postgresqldb.properties
@@ -1,5 +1,8 @@
id=identifier
name=database
name.pacprefix=packet
name.separator=_
name.postfix=databasepart
pac=packet
encoding=encoding
owner=owner
hsarweb/src/texts/postgresqldb_de.properties
@@ -1,5 +1,8 @@
id=Schlüssel
name=Datenbank
name.pacprefix=Paket
name.separator=_
name.postfix=Datenbank-Postfix
pac=Paket
encoding=Zeichensatz
owner=Verwalter
hsarweb/src/texts/postgresqluser.properties
@@ -1,5 +1,8 @@
id=identifier
name=postgres username
name.pacprefix=packet
name.separator=_
name.postfix=userpart
password=password
password1=new password
password2=repeat password
hsarweb/src/texts/postgresqluser_de.properties
@@ -1,5 +1,8 @@
id=Schlüssel
name=PostgreSQL User
name.pacprefix=Paket
name.separator=_
name.postfix=Benutzer-Postfix
password=Passwort
password1=neues Passwort
password2=Passwort-Wiederholung