From c1f04434a04d7469240dffab07503d4be78155e9 Mon Sep 17 00:00:00 2001
From: Purodha <bli00@hostsharing.net>
Date: Thu, 03 Jan 2013 23:12:52 +0100
Subject: [PATCH] Some minor fixes in moduleprop, som commented out debugging stuff. Bug null pointer exception when referredProps have indirect fields, i.e. dot notation.

---
 hsarback/src/de/hsadmin/mods/cust/Customer.java            |    5 +++++
 hsarback/src/de/hsadmin/remote/ModulePropertiesRemote.java |   35 ++++++++++++++++++-----------------
 2 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/hsarback/src/de/hsadmin/mods/cust/Customer.java b/hsarback/src/de/hsadmin/mods/cust/Customer.java
index 28f0bbf..c8d1eaa 100644
--- a/hsarback/src/de/hsadmin/mods/cust/Customer.java
+++ b/hsarback/src/de/hsadmin/mods/cust/Customer.java
@@ -23,6 +23,7 @@
 import javax.persistence.Transient;
 
 import de.hsadmin.core.model.AbstractEntity;
+import de.hsadmin.core.model.AnnFieldIO;
 import de.hsadmin.core.model.AnnModuleImpl;
 import de.hsadmin.mods.pac.Pac;
 import de.hsadmin.mods.user.UnixUser;
@@ -80,9 +81,13 @@
 	private Set<Contact> contacts;
 
 	@OneToOne(fetch = EAGER, cascade = ALL, mappedBy = "customer")
+	//@AnnFieldIO(referredProps = "customer")
+	//@AnnFieldIO(referredProps = "customer.CustomersTariffl")
+	//@AnnFieldIO(referredProps = "customer.CustomersTariff.domainDiscountUntil")
 	private BankAccount bankAccount;
 
 	@OneToOne(fetch = EAGER, cascade = ALL, mappedBy = "customer")
+	//@AnnFieldIO(referredProps = "domainDiscountUntil")
 	private CustomersTariff billData;
 
 	@OneToMany(fetch = LAZY, cascade = ALL, mappedBy = "customer")
diff --git a/hsarback/src/de/hsadmin/remote/ModulePropertiesRemote.java b/hsarback/src/de/hsadmin/remote/ModulePropertiesRemote.java
index 5aed461..af40d37 100644
--- a/hsarback/src/de/hsadmin/remote/ModulePropertiesRemote.java
+++ b/hsarback/src/de/hsadmin/remote/ModulePropertiesRemote.java
@@ -27,9 +27,8 @@
 			if (transaction.login(user, ticket)) {
 				InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream("org/apache/xmlrpc/webserver/XmlRpcServlet.properties");
 				Properties properties = new Properties();
-				properties.load(resourceAsStream);
-				
-				for (Object moduleKey : properties.entrySet()) {
+				properties.load(resourceAsStream);				
+				for (Object moduleKey : properties.keySet()) {
 					Class<?> remoteClass = Class.forName(properties.getProperty((String) moduleKey));
 					Object newInstance = remoteClass.newInstance();
 					if (newInstance instanceof AbstractRemote) {
@@ -42,20 +41,22 @@
 //						AnnFieldIO fieldIO = entityClass.getAnnotation(AnnFieldIO.class);
 						for (Field f: entityClass.getDeclaredFields()) {
 							HashMap<String, Object> propertyProperties = new HashMap<String, Object>();
-							propertiesList.add(propertyProperties);
 							AnnFieldIO fieldIO = f.getAnnotation(AnnFieldIO.class);
-							String fieldName = f.getName();
-							propertyProperties.put("property", fieldName);
-							String regExp = fieldIO.validation();
-							propertyProperties.put("validation", regExp);
-							ReadWriteAccess rw = fieldIO.rw();
-							propertyProperties.put("rw", rw.name());
-							String[] referredProps = fieldIO.referredProps();
-							propertyProperties.put("referredProps", referredProps);							
-							Class<?> declaringClass = f.getDeclaringClass();
-							for(String s : referredProps){					
-								String fullPropertyName = fieldName+"."+s;			
-								propertiesList.add(createReferredPropertyInfo(fullPropertyName, declaringClass, fullPropertyName));
+							if (fieldIO != null){
+								String fieldName = f.getName();
+								propertyProperties.put("property", fieldName);
+								String regExp = fieldIO.validation();
+								propertyProperties.put("validation", regExp);
+								ReadWriteAccess rw = fieldIO.rw();
+								propertyProperties.put("rw", rw.name());
+								String[] referredProps = fieldIO.referredProps();
+								propertyProperties.put("referredProps", referredProps);							
+								Class<?> declaringClass = f.getDeclaringClass();
+								for(String s : referredProps){					
+									String fullPropertyName = fieldName+"."+s;			
+									propertiesList.add(createReferredPropertyInfo(fullPropertyName, declaringClass, fullPropertyName));
+								}
+								propertiesList.add(propertyProperties);
 							}
 						}											
 						result.add(modMap);
@@ -77,7 +78,7 @@
 		int indexOfDot = propertyName.indexOf('.');
 		if (indexOfDot>=0) {
 			String prefix = propertyName.substring(0, indexOfDot);
-			String remainingPart = propertyName.substring(indexOfDot + 1);
+			String remainingPart = propertyName.substring(indexOfDot + 1);			
 			return createReferredPropertyInfo(fieldName, declaringClass.getDeclaredField(prefix).getDeclaringClass(), remainingPart);
 		} else {
 			Map<String, Object> result = new HashMap<String, Object>();

--
Gitblit v1.9.0-SNAPSHOT