diff --git a/hsarjcli/src/de/hsadmin/jscli/JSONFormatter.java b/hsarjcli/src/de/hsadmin/jscli/JSONFormatter.java
index 96580ca..2f221fb 100644
--- a/hsarjcli/src/de/hsadmin/jscli/JSONFormatter.java
+++ b/hsarjcli/src/de/hsadmin/jscli/JSONFormatter.java
@@ -8,6 +8,23 @@ public class JSONFormatter {
private int indent = 1;
+ public String format(Object object) {
+ if (object == null) return "";
+ if (object instanceof List>) {
+ return formatList((List>) object);
+ }
+ if (object instanceof Map, ?>) {
+ return formatMap((Map, ?>) object);
+ }
+ if (object instanceof String) {
+ return formatString((String) object);
+ }
+ if (object instanceof Object[]) {
+ return formatArr((Object[]) object);
+ }
+ return "an instance of " + object.getClass().getCanonicalName();
+ }
+
public String formatMap(Map, ?> map) {
StringBuffer result = new StringBuffer();
result.append('{');
@@ -61,23 +78,6 @@ public class JSONFormatter {
return result.toString();
}
- public String format(Object object) {
- if (object == null) return "";
- if (object instanceof List>) {
- return formatList((List>) object);
- }
- if (object instanceof Map, ?>) {
- return formatMap((Map, ?>) object);
- }
- if (object instanceof String) {
- return formatString((String) object);
- }
- if (object instanceof Object[]) {
- return formatArr((Object[]) object);
- }
- return "an instance of " + object.getClass().getCanonicalName();
- }
-
private void incr() {
indent += 3;
}
diff --git a/hsarjcli/src/de/hsadmin/jscli/Main.java b/hsarjcli/src/de/hsadmin/jscli/Main.java
index 131047e..3452ee5 100644
--- a/hsarjcli/src/de/hsadmin/jscli/Main.java
+++ b/hsarjcli/src/de/hsadmin/jscli/Main.java
@@ -20,11 +20,13 @@ public class Main {
String file = cmdParser.getFile();
if (file != null && file.length() > 0) {
if ("-".equals(file)) {
- console.println(formatter.format(scriptClient.execute(new InputStreamReader(System.in))));
+ scriptClient.execute(new InputStreamReader(System.in));
+ console.println(formatter.format(scriptClient.getLastRpcResult()));
} else {
File fileHandle = new File(file);
try {
- console.println(formatter.format(scriptClient.execute(new FileReader(fileHandle))));
+ scriptClient.execute(new FileReader(fileHandle));
+ console.println(formatter.format(scriptClient.getLastRpcResult()));
} catch (FileNotFoundException e) {
System.err.println("File not found: " + file);
}
@@ -32,13 +34,15 @@ public class Main {
}
String expr = cmdParser.getExpression();
if (expr != null && expr.length() > 0) {
- console.println(formatter.format(scriptClient.execute(expr)));
+ scriptClient.execute(expr);
+ console.println(formatter.format(scriptClient.getLastRpcResult()));
}
if (cmdParser.isInteractive()) {
String command = console.readInput();
while (!("bye".equals(command.trim()) || "exit".equals(command.trim()) || "quit".equals(command.trim()))) {
try {
- console.println(formatter.format(scriptClient.execute(command)));
+ scriptClient.execute(command);
+ console.println(formatter.format(scriptClient.getLastRpcResult()));
} catch (Exception e) {
console.println("Error: " + e.getLocalizedMessage() + "\n");
}
diff --git a/hsarjcli/src/de/hsadmin/jscli/ScriptClient.java b/hsarjcli/src/de/hsadmin/jscli/ScriptClient.java
index adfc9ad..6bb0540 100644
--- a/hsarjcli/src/de/hsadmin/jscli/ScriptClient.java
+++ b/hsarjcli/src/de/hsadmin/jscli/ScriptClient.java
@@ -23,8 +23,16 @@ public class ScriptClient {
try {
engine.put("casgrantingticket", grantingTicket);
engine.put("xmlrpcclient", rpcClient);
+ engine.put("xmlrpcLastResult", null);
engine.eval("importClass(java.util.ArrayList);");
engine.eval("importClass(java.util.HashMap);");
+ engine.eval("function hsaParseParam(val) { " +
+ "if (val instanceof java.util.List) return val;" +
+ "if (val instanceof java.util.Map) return val;" +
+ "if (typeof val === 'object' && val.constructor === Array) { res = hsaParseParamArray(val); } " +
+ "else if (typeof val === 'object') { res = hsaParseParamObject(val); }; " +
+ "return res; " +
+ "}");
engine.eval("function hsaParseParamArray(o) { " +
"var lst = new ArrayList(); " +
"var val = ''; " +
@@ -45,6 +53,25 @@ public class ScriptClient {
" hsh.put(key, val); " +
"}; " +
"return hsh; " +
+ "}");
+ engine.eval("function hsaToNativeJSObject(val) { " +
+ "if (val instanceof java.util.List) {" +
+ " var res = [];" +
+ " for (i = 0; i < val.size(); i++) {" +
+ " res[i] = hsaToNativeJSObject(val.get(i));" +
+ " }" +
+ " return res;" +
+ "}" +
+ "if (val instanceof java.util.Map) {" +
+ " var res = {};" +
+ " var iter = val.keySet().iterator();" +
+ " while (iter.hasNext()) {" +
+ " var key = iter.next();" +
+ " res[key] = hsaToNativeJSObject(val.get(key));" +
+ " }" +
+ " return res;" +
+ "}" +
+ "return val;" +
"};");
} catch (ScriptException e) {
throw new JSCliException(e);
@@ -71,8 +98,9 @@ public class ScriptClient {
"params.add(casgrantingticket.getTicket()); " +
"if (typeof json === 'undefined') { json = { where:{}, set:{} } };" +
"if (fct == 'update' || fct == 'add') { params.add(hsaParseParamObject(json['set'])); }; " +
- "if (fct == 'update' || fct == 'delete' || fct == 'search') { params.add(hsaParseParamObject(json['where'])); }; " +
- "return xmlrpcclient.execute(mod + '.' + fct, params); " +
+ "if (fct == 'update' || fct == 'delete' || fct == 'search') { params.add(hsaParseParamObject(json['where'])); }; " +
+ "xmlrpcLastResult = xmlrpcclient.execute(mod + '.' + fct, params);" +
+ "return hsaToNativeJSObject(xmlrpcLastResult); " +
"};");
} catch (ScriptException e) {
e.printStackTrace();
@@ -94,6 +122,7 @@ public class ScriptClient {
public Object execute(String snippet) throws JSCliException {
try {
+ engine.put("xmlrpcLastResult", null);
return engine.eval(snippet);
} catch (ScriptException e) {
throw new JSCliException(e);
@@ -102,10 +131,15 @@ public class ScriptClient {
public Object execute(Reader rd) throws JSCliException {
try {
+ engine.put("xmlrpcLastResult", null);
return engine.eval(rd);
} catch (ScriptException e) {
throw new JSCliException(e);
}
}
+ public Object getLastRpcResult() {
+ return engine.get("xmlrpcLastResult");
+ }
+
}
diff --git a/hsarweb/.classpath b/hsarweb/.classpath
index d6cc4ef..d759f69 100644
--- a/hsarweb/.classpath
+++ b/hsarweb/.classpath
@@ -8,6 +8,6 @@
-
+
diff --git a/hsarweb/WebContent/WEB-INF/lib/vaadin-6.8.4.jar b/hsarweb/WebContent/WEB-INF/lib/vaadin-6.8.7.jar
similarity index 65%
rename from hsarweb/WebContent/WEB-INF/lib/vaadin-6.8.4.jar
rename to hsarweb/WebContent/WEB-INF/lib/vaadin-6.8.7.jar
index 0975d80..b1a676b 100644
Binary files a/hsarweb/WebContent/WEB-INF/lib/vaadin-6.8.4.jar and b/hsarweb/WebContent/WEB-INF/lib/vaadin-6.8.7.jar differ
diff --git a/hsarweb/src/de/hsadmin/web/AbstractModule.java b/hsarweb/src/de/hsadmin/web/AbstractModule.java
index 6e9d4f3..e76f7ab 100644
--- a/hsarweb/src/de/hsadmin/web/AbstractModule.java
+++ b/hsarweb/src/de/hsadmin/web/AbstractModule.java
@@ -82,7 +82,7 @@ public abstract class AbstractModule implements Module, Serializable {
public void buttonClick(ClickEvent event) {
application.getMainWindow().removeWindow(childWindow);
try {
- Map map = new HashMap();
+ Map map = new HashMap();
genericForm.transferToHash(map, form);
((InsertAble) thisModule).insertRow(map);
componentFactory.loadData();
diff --git a/hsarweb/src/de/hsadmin/web/AbstractProperty.java b/hsarweb/src/de/hsadmin/web/AbstractProperty.java
index 2c0455a..e3b894d 100644
--- a/hsarweb/src/de/hsadmin/web/AbstractProperty.java
+++ b/hsarweb/src/de/hsadmin/web/AbstractProperty.java
@@ -1,7 +1,10 @@
package de.hsadmin.web;
-public abstract class AbstractProperty {
+public abstract class AbstractProperty implements XmlrpcProperty {
+ @Override
public abstract Object toXmlrpcParam();
-
+
+ public abstract String toStringValue();
+
}
diff --git a/hsarweb/src/de/hsadmin/web/DatabaseModule.java b/hsarweb/src/de/hsadmin/web/DatabaseModule.java
index c62bba0..5a497fa 100644
--- a/hsarweb/src/de/hsadmin/web/DatabaseModule.java
+++ b/hsarweb/src/de/hsadmin/web/DatabaseModule.java
@@ -122,7 +122,7 @@ public abstract class DatabaseModule extends GenericModule {
public List getDatabaseUsers() {
ArrayList list = new ArrayList();
try {
- Object callSearch = getApplication().getRemote().callSearch(getUserModuleIdent(), new HashMap());
+ Object callSearch = getApplication().getRemote().callSearch(getUserModuleIdent(), new HashMap());
if (callSearch instanceof Object[]) {
for (Object row : ((Object[])callSearch)) {
if (row instanceof Map, ?>) {
diff --git a/hsarweb/src/de/hsadmin/web/DateProperty.java b/hsarweb/src/de/hsadmin/web/DateProperty.java
new file mode 100644
index 0000000..613da8b
--- /dev/null
+++ b/hsarweb/src/de/hsadmin/web/DateProperty.java
@@ -0,0 +1,40 @@
+package de.hsadmin.web;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.util.Date;
+
+public class DateProperty extends AbstractProperty {
+
+ public static final DateFormat serverDf = DateFormat.getDateInstance(DateFormat.SHORT);
+
+ final private Date property;
+
+ public DateProperty(Date propertyValue) {
+ this.property = propertyValue;
+ }
+
+ public DateProperty(String propertyValue) {
+ Date temp = null;
+ try {
+ temp = serverDf.parse(propertyValue);
+ } catch (ParseException e) {
+ }
+ property = temp;
+ }
+
+ @Override
+ public Object toXmlrpcParam() {
+ return serverDf.format(property);
+ }
+
+ @Override
+ public String toStringValue() {
+ return serverDf.format(property);
+ }
+
+ public Date getDateValue() {
+ return property;
+ }
+
+}
diff --git a/hsarweb/src/de/hsadmin/web/DeleteAble.java b/hsarweb/src/de/hsadmin/web/DeleteAble.java
index 938c12f..1227e30 100644
--- a/hsarweb/src/de/hsadmin/web/DeleteAble.java
+++ b/hsarweb/src/de/hsadmin/web/DeleteAble.java
@@ -4,6 +4,6 @@ import java.util.Map;
public interface DeleteAble {
- public void deleteRow(Map paramHash) throws HsarwebException;
+ public void deleteRow(Map paramHash) throws HsarwebException;
}
diff --git a/hsarweb/src/de/hsadmin/web/GenericModule.java b/hsarweb/src/de/hsadmin/web/GenericModule.java
index f754624..0bd5a17 100644
--- a/hsarweb/src/de/hsadmin/web/GenericModule.java
+++ b/hsarweb/src/de/hsadmin/web/GenericModule.java
@@ -12,16 +12,16 @@ public abstract class GenericModule extends AbstractModule implements InsertAble
private static final long serialVersionUID = 1L;
- public void insertRow(Map paramHash) throws HsarwebException {
+ public void insertRow(Map paramHash) throws HsarwebException {
getApplication().getRemote().callAdd(getModuleConfig().getRemoteName(), paramHash);
}
- public void deleteRow(Map paramHash) throws HsarwebException {
+ public void deleteRow(Map paramHash) throws HsarwebException {
getApplication().getRemote().callDelete(getModuleConfig().getRemoteName(), paramHash);
}
- public void updateRow(Map paramHash) throws HsarwebException {
- Map whereHash = new HashMap();
+ public void updateRow(Map paramHash) throws HsarwebException {
+ Map whereHash = new HashMap();
String idKey = findIdKey();
whereHash.put(idKey, paramHash.get(idKey));
getApplication().getRemote().callUpdate(getModuleConfig().getRemoteName(), paramHash, whereHash);
@@ -43,7 +43,7 @@ public abstract class GenericModule extends AbstractModule implements InsertAble
public List getUsers() {
ArrayList list = new ArrayList();
try {
- Object callSearch = getApplication().getRemote().callSearch("user", new HashMap());
+ Object callSearch = getApplication().getRemote().callSearch("user", new HashMap());
if (callSearch instanceof Object[]) {
for (Object row : ((Object[])callSearch)) {
if (row instanceof Map, ?>) {
@@ -64,7 +64,7 @@ public abstract class GenericModule extends AbstractModule implements InsertAble
public List getEMailAliases() {
ArrayList list = new ArrayList();
try {
- Object callSearch = getApplication().getRemote().callSearch("emailalias", new HashMap());
+ Object callSearch = getApplication().getRemote().callSearch("emailalias", new HashMap());
if (callSearch instanceof Object[]) {
for (Object row : ((Object[])callSearch)) {
if (row instanceof Map, ?>) {
@@ -85,7 +85,7 @@ public abstract class GenericModule extends AbstractModule implements InsertAble
public List getDomains() {
ArrayList list = new ArrayList();
try {
- Object callSearch = getApplication().getRemote().callSearch("domain", new HashMap());
+ Object callSearch = getApplication().getRemote().callSearch("domain", new HashMap());
if (callSearch instanceof Object[]) {
for (Object row : ((Object[])callSearch)) {
if (row instanceof Map, ?>) {
@@ -106,7 +106,7 @@ public abstract class GenericModule extends AbstractModule implements InsertAble
public List getPackets() {
ArrayList list = new ArrayList();
try {
- Object callSearch = getApplication().getRemote().callSearch("pac", new HashMap());
+ Object callSearch = getApplication().getRemote().callSearch("pac", new HashMap());
if (callSearch instanceof Object[]) {
for (Object row : ((Object[])callSearch)) {
if (row instanceof Map, ?>) {
diff --git a/hsarweb/src/de/hsadmin/web/HomeModule.java b/hsarweb/src/de/hsadmin/web/HomeModule.java
index 65031d5..a109e4d 100644
--- a/hsarweb/src/de/hsadmin/web/HomeModule.java
+++ b/hsarweb/src/de/hsadmin/web/HomeModule.java
@@ -35,8 +35,8 @@ public class HomeModule extends AbstractModule implements ComponentFactory, Upda
setComponentFactory(this);
}
- public void updateRow(Map paramHash) throws HsarwebException {
- Map whereHash = new HashMap();
+ public void updateRow(Map paramHash) throws HsarwebException {
+ Map whereHash = new HashMap();
String idKey = findIdKey();
whereHash.put(idKey, paramHash.get(idKey));
paramHash.remove(idKey);
@@ -94,7 +94,7 @@ public class HomeModule extends AbstractModule implements ComponentFactory, Upda
Button button = new Button(moduleConfig.getLabel("change_password"));
ThemeResource icon = new ThemeResource(moduleConfig.getLabel("change_password_icon"));
button.setIcon(icon);
- Map whereHash = new HashMap();
+ Map whereHash = new HashMap();
whereHash.put("name", new StringProperty(application.getRunAs()));
Long key = -1L;
try {
@@ -130,7 +130,7 @@ public class HomeModule extends AbstractModule implements ComponentFactory, Upda
public void buttonClick(ClickEvent event) {
application.getMainWindow().removeWindow(childWindow);
try {
- Map map = new HashMap();
+ Map map = new HashMap();
map.put("id", new StringProperty(((Long) event.getButton().getData()).toString()));
Iterator componentIterator = form.getLayout().getComponentIterator();
while (componentIterator.hasNext()) {
diff --git a/hsarweb/src/de/hsadmin/web/InsertAble.java b/hsarweb/src/de/hsadmin/web/InsertAble.java
index c7af5a0..f366617 100644
--- a/hsarweb/src/de/hsadmin/web/InsertAble.java
+++ b/hsarweb/src/de/hsadmin/web/InsertAble.java
@@ -4,6 +4,6 @@ import java.util.Map;
public interface InsertAble {
- public void insertRow(Map paramHash) throws HsarwebException;
+ public void insertRow(Map paramHash) throws HsarwebException;
}
diff --git a/hsarweb/src/de/hsadmin/web/ItemsReader.java b/hsarweb/src/de/hsadmin/web/ItemsReader.java
index d1c22d5..ffd372b 100644
--- a/hsarweb/src/de/hsadmin/web/ItemsReader.java
+++ b/hsarweb/src/de/hsadmin/web/ItemsReader.java
@@ -9,7 +9,7 @@ public class ItemsReader {
public static List