Names of domainproperties are pulled from server before used.
HsarwebExeption got subclasses HsarwebUserExeption and HsarwebInternalException.
This commit is contained in:
parent
16134613b4
commit
bd2a2f21f9
@ -167,7 +167,7 @@ public abstract class AbstractModule implements Module, Serializable {
|
||||
initLayout();
|
||||
}
|
||||
|
||||
protected abstract void initModule();
|
||||
protected abstract void initModule() throws HsarwebException;
|
||||
|
||||
public MainApplication getApplication() {
|
||||
return application;
|
||||
|
@ -21,7 +21,7 @@ public class DomainModule extends GenericModule {
|
||||
private ModuleConfig moduleConfig;
|
||||
|
||||
@Override
|
||||
protected void initModule() {
|
||||
protected void initModule() throws HsarwebException {
|
||||
MainApplication application = getApplication();
|
||||
moduleConfig = new ModuleConfig("domain", application.getLocale());
|
||||
String login = application.getRunAs();
|
||||
|
@ -124,4 +124,42 @@ public abstract class GenericModule extends AbstractModule implements InsertAble
|
||||
return list;
|
||||
}
|
||||
|
||||
public Map<String,Map<String,Object>> getModuleProps() {
|
||||
Map<String,Map<String,Object>> moduleList = new HashMap<String,Map<String,Object>>();
|
||||
Object callSearch = null;
|
||||
try {
|
||||
callSearch = getApplication().getRemote().callSearch("moduleprop", new HashMap<String, XmlrpcProperty>());
|
||||
if (!(callSearch instanceof Object[])) {
|
||||
throw new HsarwebException("getModuleProps hat keine Liste bekommen.");
|
||||
}
|
||||
for (Object row : ((Object[])callSearch)) {
|
||||
if (row instanceof Map<?, ?>) {
|
||||
Map<?, ?> rowAsMap = (Map<?, ?>) row;
|
||||
Object moduleName = rowAsMap.get("module");
|
||||
if (moduleName instanceof String) {
|
||||
Object properties = rowAsMap.get("properties");
|
||||
if (properties instanceof Object[]) {
|
||||
Map<String,Object> propertyList = new HashMap<String,Object>();
|
||||
moduleList.put((String) moduleName, propertyList );
|
||||
for (Object property : (Object[]) properties){
|
||||
if (property instanceof Map<?,?>) {
|
||||
Object propertyName = ((Map<?, ?>) property).get("property");
|
||||
if (propertyName instanceof String) {
|
||||
propertyList.put((String) propertyName, property);
|
||||
// propertyList.put((String) propertyName, (Map<String,Object>) property);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* */
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (HsarwebException e) {
|
||||
e.printStackTrace();
|
||||
getApplication().showSystemException(e);
|
||||
}
|
||||
return moduleList;
|
||||
}
|
||||
|
||||
}
|
||||
|
19
hsarweb/src/de/hsadmin/web/HsarwebInternalException.java
Normal file
19
hsarweb/src/de/hsadmin/web/HsarwebInternalException.java
Normal file
@ -0,0 +1,19 @@
|
||||
package de.hsadmin.web;
|
||||
|
||||
public class HsarwebInternalException extends HsarwebException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public HsarwebInternalException(String string, Throwable e) {
|
||||
super(string, e);
|
||||
}
|
||||
|
||||
public HsarwebInternalException(Throwable e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
public HsarwebInternalException(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
}
|
19
hsarweb/src/de/hsadmin/web/HsarwebUserException.java
Normal file
19
hsarweb/src/de/hsadmin/web/HsarwebUserException.java
Normal file
@ -0,0 +1,19 @@
|
||||
package de.hsadmin.web;
|
||||
|
||||
public class HsarwebUserException extends HsarwebException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public HsarwebUserException(String string, Throwable e) {
|
||||
super(string, e);
|
||||
}
|
||||
|
||||
public HsarwebUserException(Throwable e) {
|
||||
super(e);
|
||||
}
|
||||
|
||||
public HsarwebUserException(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
}
|
@ -2,6 +2,7 @@ package de.hsadmin.web.vaadin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.vaadin.terminal.Sizeable;
|
||||
import com.vaadin.ui.Component;
|
||||
@ -10,7 +11,8 @@ import com.vaadin.ui.Label;
|
||||
import com.vaadin.ui.Select;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
|
||||
import de.hsadmin.web.HsarwebException;
|
||||
import de.hsadmin.web.DomainModule;
|
||||
import de.hsadmin.web.HsarwebInternalException;
|
||||
import de.hsadmin.web.ListOfStringsProperty;
|
||||
import de.hsadmin.web.Module;
|
||||
import de.hsadmin.web.XmlrpcProperty;
|
||||
@ -24,56 +26,85 @@ import de.hsadmin.web.config.PropertyFieldFactory;
|
||||
*/
|
||||
public class DomainOptionsPropertyFieldFactory implements PropertyFieldFactory {
|
||||
private final Module module;
|
||||
private final ModuleConfig config ;
|
||||
// TODO: besorge Options und ihre Typen aus der DB
|
||||
private static final String[] OPTION_NAMES = new String[] { "backupmxforexternalmx", "greylisting", "htdocsfallback", "includes", "indexes", "multiviews", "php"};
|
||||
// private final Map<String,AbstractProperty> optionTypes ; // TODO: auf Vorrat hier
|
||||
// TODO: besorge Options .... Ende
|
||||
private final ModuleConfig config;
|
||||
private static String[] OPTION_NAMES; // {"backupmxforexternalmx", "php", ...};
|
||||
// private final Map<String,AbstractProperty> optionTypes ; // TODO: auf Vorrat hier
|
||||
private boolean readOnly = false;
|
||||
private boolean writeOnce = false;
|
||||
private VerticalLayout layout;
|
||||
private final List<SingleDomainOption> optionLayout ;
|
||||
private final List<SingleDomainOption> optionLayout;
|
||||
|
||||
public DomainOptionsPropertyFieldFactory(Module module) {
|
||||
public DomainOptionsPropertyFieldFactory(Module module) throws HsarwebInternalException {
|
||||
this.module = module;
|
||||
this.config = module.getModuleConfig();
|
||||
optionLayout = new ArrayList<SingleDomainOption>() ;
|
||||
this.config = this.module.getModuleConfig();
|
||||
// Liste der Namen der Domainoptions besorgen
|
||||
DomainModule domainModule = (DomainModule) module;
|
||||
Map<String, Map<String, Object>> moduleProps = domainModule.getModuleProps();
|
||||
Object p1 = moduleProps.get("domain").get("domainoptions");
|
||||
Map<String, Object> p2 = (Map<String, Object>) p1;
|
||||
Object p3 = p2.get("selectableValues");
|
||||
if (p3 instanceof Map<?, ?>) {
|
||||
Map<String, Object> p4 = (Map<String, Object>) p3;
|
||||
if (p4.get("kind").equals("DOMAINOPTIONS")) {
|
||||
Object p5 = p4.get("values");
|
||||
if (p5 instanceof Object[]) {
|
||||
Object[] p6 = (Object[]) p5;
|
||||
OPTION_NAMES = new String[p6.length];
|
||||
int i = 0;
|
||||
for (Object p7 : p6) {
|
||||
if (p7 instanceof Map<?, ?>) {
|
||||
Map<String, ?> p8 = (Map<String, ?>) p7;
|
||||
OPTION_NAMES[i++] = p8.keySet().iterator().next();
|
||||
} else {
|
||||
throw new HsarwebInternalException("p7");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new HsarwebInternalException("p5");
|
||||
}
|
||||
} else {
|
||||
throw new HsarwebInternalException("p4");
|
||||
}
|
||||
} else {
|
||||
throw new HsarwebInternalException("p3");
|
||||
}
|
||||
optionLayout = new ArrayList<SingleDomainOption>();
|
||||
}
|
||||
|
||||
private void repaint() {
|
||||
layout.removeAllComponents();
|
||||
for (int idx=0 ; idx<OPTION_NAMES.length ; ++idx ) {
|
||||
for (int idx = 0; idx < OPTION_NAMES.length; ++idx) {
|
||||
layout.addComponent(optionLayout.get(idx).getComponent());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) throws HsarwebException {
|
||||
public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value)
|
||||
throws HsarwebInternalException {
|
||||
layout = new VerticalLayout();
|
||||
layout.setCaption(prop.getLabel());
|
||||
layout.setData(prop.getId());
|
||||
optionLayout.clear();
|
||||
if (value instanceof ListOfStringsProperty) {
|
||||
ListOfStringsProperty list = (ListOfStringsProperty) value;
|
||||
for (int idx=0 ; idx<OPTION_NAMES.length ; ++idx ) {
|
||||
optionLayout.add(new SingleDomainOption(this, OPTION_NAMES[idx], list.contains(OPTION_NAMES[idx]) ));
|
||||
for (int idx = 0; idx < OPTION_NAMES.length; ++idx) {
|
||||
optionLayout.add(new SingleDomainOption(this,
|
||||
OPTION_NAMES[idx], list.contains(OPTION_NAMES[idx])));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
// Eine leere Liste von Domainoptionen wird angezeigt werden.
|
||||
throw new HsarwebException("Keine Liste: ListOfStringsProperty");
|
||||
throw new HsarwebInternalException(
|
||||
"Keine Liste: ListOfStringsProperty");
|
||||
}
|
||||
repaint();
|
||||
return layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public XmlrpcProperty getValue(PropertyConfig prop, Object component) throws HsarwebException {
|
||||
ListOfStringsProperty setOptions = new ListOfStringsProperty() ;
|
||||
for (int idx=0 ; idx<OPTION_NAMES.length ; ++idx ) {
|
||||
if(Boolean.TRUE.equals(optionLayout.get(idx).getValue()))
|
||||
{
|
||||
public XmlrpcProperty getValue(PropertyConfig prop, Object component) {
|
||||
ListOfStringsProperty setOptions = new ListOfStringsProperty();
|
||||
for (int idx = 0; idx < OPTION_NAMES.length; ++idx) {
|
||||
if (Boolean.TRUE.equals(optionLayout.get(idx).getValue())) {
|
||||
setOptions.add(OPTION_NAMES[idx]);
|
||||
}
|
||||
}
|
||||
@ -104,17 +135,19 @@ public class DomainOptionsPropertyFieldFactory implements PropertyFieldFactory {
|
||||
private final DomainOptionsPropertyFieldFactory owner;
|
||||
private final String optionName;
|
||||
private HorizontalLayout targetLine;
|
||||
private Select select ;
|
||||
private Select select;
|
||||
|
||||
protected SingleDomainOption(DomainOptionsPropertyFieldFactory owner, String optionName, boolean optionValue) {
|
||||
protected SingleDomainOption(DomainOptionsPropertyFieldFactory owner,
|
||||
String optionName, boolean optionValue) {
|
||||
this.owner = owner;
|
||||
this.optionName = optionName;
|
||||
targetLine = new HorizontalLayout();
|
||||
targetLine.setWidth(500.0f, Sizeable.UNITS_PIXELS);
|
||||
HorizontalLayout leftPart = new HorizontalLayout();
|
||||
leftPart.setWidth(220.0f, Sizeable.UNITS_PIXELS);
|
||||
Label label = new Label(owner.config.getLabel("domainoption."+optionName),Label.CONTENT_RAW);
|
||||
leftPart.addComponent( label); // setCaption(owner.config.getLabel("domainoption."+optionName));
|
||||
Label label = new Label(owner.config.getLabel("domainoption."
|
||||
+ optionName), Label.CONTENT_RAW);
|
||||
leftPart.addComponent(label); // setCaption(owner.config.getLabel("domainoption."+optionName));
|
||||
HorizontalLayout rightPart = new HorizontalLayout();
|
||||
// ToDO: Fallunterscheidungen nach Optionsart. Z.Z. nur Boolean:
|
||||
{
|
||||
@ -124,9 +157,9 @@ public class DomainOptionsPropertyFieldFactory implements PropertyFieldFactory {
|
||||
this.select.setNewItemsAllowed(false);
|
||||
this.select.setNullSelectionAllowed(false);
|
||||
this.select.addItem("y");
|
||||
this.select.setItemCaption("y" , owner.config.getLabel("yes"));
|
||||
this.select.setItemCaption("y", owner.config.getLabel("yes"));
|
||||
this.select.addItem("n");
|
||||
this.select.setItemCaption("n" , owner.config.getLabel("no"));
|
||||
this.select.setItemCaption("n", owner.config.getLabel("no"));
|
||||
this.select.setValue(optionValue ? "y" : "n");
|
||||
rightPart.addComponent(this.select);
|
||||
}
|
||||
@ -141,8 +174,7 @@ public class DomainOptionsPropertyFieldFactory implements PropertyFieldFactory {
|
||||
public Boolean getValue() {
|
||||
Boolean value = null;
|
||||
String val = (String) this.select.getValue();
|
||||
if( val.equals("y") || val.equals("n") )
|
||||
{
|
||||
if (val.equals("y") || val.equals("n")) {
|
||||
value = (val.equals("y"));
|
||||
}
|
||||
return value;
|
||||
|
Loading…
Reference in New Issue
Block a user