Prechádzať zdrojové kódy

jasperserver axis接口初步结构

sunyj 9 rokov pred
rodič
commit
526d0458a7
19 zmenil súbory, kde vykonal 877 pridanie a 0 odobranie
  1. 21 0
      src/main/java/com/uas/report/axis/authority/PermissionsManagement.java
  2. 10 0
      src/main/java/com/uas/report/axis/authority/PermissionsManagementService.java
  3. 26 0
      src/main/java/com/uas/report/axis/authority/PermissionsManagementServiceImpl.java
  4. 42 0
      src/main/java/com/uas/report/axis/authority/UserAndRoleManagement.java
  5. 18 0
      src/main/java/com/uas/report/axis/authority/UserAndRoleManagementService.java
  6. 50 0
      src/main/java/com/uas/report/axis/authority/UserAndRoleManagementServiceImpl.java
  7. 5 0
      src/main/java/com/uas/report/axis/authority/WSObjectPermission.java
  8. 5 0
      src/main/java/com/uas/report/axis/authority/WSRole.java
  9. 5 0
      src/main/java/com/uas/report/axis/authority/WSRoleSearchCriteria.java
  10. 5 0
      src/main/java/com/uas/report/axis/authority/WSUser.java
  11. 5 0
      src/main/java/com/uas/report/axis/authority/WSUserSearchCriteria.java
  12. 5 0
      src/main/java/com/uas/report/axis/scheduling/Job.java
  13. 5 0
      src/main/java/com/uas/report/axis/scheduling/JobSummary.java
  14. 37 0
      src/main/java/com/uas/report/axis/scheduling/ReportSchedulerManagement.java
  15. 18 0
      src/main/java/com/uas/report/axis/scheduling/ReportSchedulerManagementService.java
  16. 50 0
      src/main/java/com/uas/report/axis/scheduling/ReportSchedulerManagementServiceImpl.java
  17. 263 0
      src/main/java/com/uas/report/axis/util/Marshaller.java
  18. 26 0
      src/main/java/com/uas/report/axis/util/StreamUtil.java
  19. 281 0
      src/main/java/com/uas/report/axis/util/Unmarshaller.java

+ 21 - 0
src/main/java/com/uas/report/axis/authority/PermissionsManagement.java

@@ -0,0 +1,21 @@
+package com.uas.report.axis.authority;
+
+import com.uas.report.util.ContextUtils;
+
+public class PermissionsManagement {
+
+	private PermissionsManagementService permissionsManagementService = ContextUtils
+			.getBean(PermissionsManagementService.class);
+
+	public WSObjectPermission[] getPermissionsForObject(String targetURI) {
+		return permissionsManagementService.getPermissionsForObject(targetURI);
+	}
+
+	public WSObjectPermission putPermission(WSObjectPermission objectPermission) {
+		return permissionsManagementService.putPermission(objectPermission);
+	}
+
+	public void deletePermission(WSObjectPermission objectPermission) {
+		permissionsManagementService.deletePermission(objectPermission);
+	}
+}

+ 10 - 0
src/main/java/com/uas/report/axis/authority/PermissionsManagementService.java

@@ -0,0 +1,10 @@
+package com.uas.report.axis.authority;
+
+public interface PermissionsManagementService {
+
+	public WSObjectPermission[] getPermissionsForObject(String targetURI);
+
+	public WSObjectPermission putPermission(WSObjectPermission objectPermission);
+
+	public void deletePermission(WSObjectPermission objectPermission);
+}

+ 26 - 0
src/main/java/com/uas/report/axis/authority/PermissionsManagementServiceImpl.java

@@ -0,0 +1,26 @@
+package com.uas.report.axis.authority;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class PermissionsManagementServiceImpl implements PermissionsManagementService {
+
+	@Override
+	public WSObjectPermission[] getPermissionsForObject(String targetURI) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public WSObjectPermission putPermission(WSObjectPermission objectPermission) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public void deletePermission(WSObjectPermission objectPermission) {
+		// TODO Auto-generated method stub
+
+	}
+
+}

+ 42 - 0
src/main/java/com/uas/report/axis/authority/UserAndRoleManagement.java

@@ -0,0 +1,42 @@
+package com.uas.report.axis.authority;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class UserAndRoleManagement {
+
+	private Logger logger = LoggerFactory.getLogger(getClass());
+
+	public WSUser[] findUsers(WSUserSearchCriteria criteria) {
+		logger.info(criteria.toString());
+		return null;
+	}
+
+	public WSUser putUser(WSUser user) {
+		logger.info(user.toString());
+		return null;
+	}
+
+	public void deleteUser(WSUser user) {
+		logger.info(user.toString());
+	}
+
+	public WSRole[] findRoles(WSRoleSearchCriteria criteria) {
+		logger.info(criteria.toString());
+		return null;
+	}
+
+	public WSRole putRole(WSRole role) {
+		logger.info(role.toString());
+		return null;
+	}
+
+	public WSRole updateRoleName(WSRole oldRole, String newName) {
+		logger.info(oldRole.toString(), newName);
+		return null;
+	}
+
+	public void deleteRole(WSRole role) {
+		logger.info(role.toString());
+	}
+}

+ 18 - 0
src/main/java/com/uas/report/axis/authority/UserAndRoleManagementService.java

@@ -0,0 +1,18 @@
+package com.uas.report.axis.authority;
+
+public interface UserAndRoleManagementService {
+
+	public WSUser[] findUsers(WSUserSearchCriteria criteria);
+
+	public WSUser putUser(WSUser user);
+
+	public void deleteUser(WSUser user);
+
+	public WSRole[] findRoles(WSRoleSearchCriteria criteria);
+
+	public WSRole putRole(WSRole role);
+
+	public WSRole updateRoleName(WSRole oldRole, String newName);
+
+	public void deleteRole(WSRole role);
+}

+ 50 - 0
src/main/java/com/uas/report/axis/authority/UserAndRoleManagementServiceImpl.java

@@ -0,0 +1,50 @@
+package com.uas.report.axis.authority;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class UserAndRoleManagementServiceImpl implements UserAndRoleManagementService {
+
+	@Override
+	public WSUser[] findUsers(WSUserSearchCriteria criteria) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public WSUser putUser(WSUser user) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public void deleteUser(WSUser user) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public WSRole[] findRoles(WSRoleSearchCriteria criteria) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public WSRole putRole(WSRole role) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public WSRole updateRoleName(WSRole oldRole, String newName) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public void deleteRole(WSRole role) {
+		// TODO Auto-generated method stub
+
+	}
+
+}

+ 5 - 0
src/main/java/com/uas/report/axis/authority/WSObjectPermission.java

@@ -0,0 +1,5 @@
+package com.uas.report.axis.authority;
+
+public class WSObjectPermission {
+
+}

+ 5 - 0
src/main/java/com/uas/report/axis/authority/WSRole.java

@@ -0,0 +1,5 @@
+package com.uas.report.axis.authority;
+
+public class WSRole {
+
+}

+ 5 - 0
src/main/java/com/uas/report/axis/authority/WSRoleSearchCriteria.java

@@ -0,0 +1,5 @@
+package com.uas.report.axis.authority;
+
+public class WSRoleSearchCriteria {
+
+}

+ 5 - 0
src/main/java/com/uas/report/axis/authority/WSUser.java

@@ -0,0 +1,5 @@
+package com.uas.report.axis.authority;
+
+public class WSUser {
+
+}

+ 5 - 0
src/main/java/com/uas/report/axis/authority/WSUserSearchCriteria.java

@@ -0,0 +1,5 @@
+package com.uas.report.axis.authority;
+
+public class WSUserSearchCriteria {
+
+}

+ 5 - 0
src/main/java/com/uas/report/axis/scheduling/Job.java

@@ -0,0 +1,5 @@
+package com.uas.report.axis.scheduling;
+
+public class Job {
+
+}

+ 5 - 0
src/main/java/com/uas/report/axis/scheduling/JobSummary.java

@@ -0,0 +1,5 @@
+package com.uas.report.axis.scheduling;
+
+public class JobSummary {
+
+}

+ 37 - 0
src/main/java/com/uas/report/axis/scheduling/ReportSchedulerManagement.java

@@ -0,0 +1,37 @@
+package com.uas.report.axis.scheduling;
+
+import com.uas.report.util.ContextUtils;
+
+public class ReportSchedulerManagement {
+
+	private ReportSchedulerManagementService reportSchedulerManagementService = ContextUtils
+			.getBean(ReportSchedulerManagementService.class);
+
+	public Job getJob(long id) {
+		return reportSchedulerManagementService.getJob(id);
+	}
+
+	public Job scheduleJob(Job job) {
+		return reportSchedulerManagementService.scheduleJob(job);
+	}
+
+	public Job updateJob(Job job) {
+		return reportSchedulerManagementService.updateJob(job);
+	}
+
+	public void deleteJob(long id) {
+		reportSchedulerManagementService.deleteJob(id);
+	}
+
+	public void deleteJobs(long[] ids) {
+		reportSchedulerManagementService.deleteJobs(ids);
+	}
+
+	public JobSummary[] getAllJobs() {
+		return reportSchedulerManagementService.getAllJobs();
+	}
+
+	public JobSummary[] getReportJobs(String reportURI) {
+		return reportSchedulerManagementService.getReportJobs(reportURI);
+	}
+}

+ 18 - 0
src/main/java/com/uas/report/axis/scheduling/ReportSchedulerManagementService.java

@@ -0,0 +1,18 @@
+package com.uas.report.axis.scheduling;
+
+public interface ReportSchedulerManagementService {
+
+	public Job getJob(long id);
+
+	public Job scheduleJob(Job job);
+
+	public Job updateJob(Job job);
+
+	public void deleteJob(long id);
+
+	public void deleteJobs(long[] ids);
+
+	public JobSummary[] getAllJobs();
+
+	public JobSummary[] getReportJobs(String reportURI);
+}

+ 50 - 0
src/main/java/com/uas/report/axis/scheduling/ReportSchedulerManagementServiceImpl.java

@@ -0,0 +1,50 @@
+package com.uas.report.axis.scheduling;
+
+import org.springframework.stereotype.Service;
+
+@Service
+public class ReportSchedulerManagementServiceImpl implements ReportSchedulerManagementService {
+
+	@Override
+	public Job getJob(long id) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Job scheduleJob(Job job) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public Job updateJob(Job job) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public void deleteJob(long id) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public void deleteJobs(long[] ids) {
+		// TODO Auto-generated method stub
+
+	}
+
+	@Override
+	public JobSummary[] getAllJobs() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public JobSummary[] getReportJobs(String reportURI) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+}

+ 263 - 0
src/main/java/com/uas/report/axis/util/Marshaller.java

@@ -0,0 +1,263 @@
+package com.uas.report.axis.util;
+
+import com.uas.report.axis.Argument;
+import com.uas.report.axis.ListItem;
+import com.uas.report.axis.OperationResult;
+import com.uas.report.axis.Request;
+import com.uas.report.axis.ResourceDescriptor;
+import com.uas.report.axis.ResourceProperty;
+
+public class Marshaller {
+	private String currentIndentation = "";
+
+	/*
+	 * This method generate the XML rapresentation of the request or the
+	 * operationResult. The default encoding used is UTF-8.
+	 */
+	public static void marshal(Object obj, java.io.StringWriter out) {
+		Marshaller marshaller = new Marshaller();
+		if (obj instanceof Request) {
+			out.write(marshaller.marshal((Request) obj));
+		} else if (obj instanceof OperationResult) {
+			out.write(marshaller.marshal((OperationResult) obj));
+		}
+	}
+
+	public static final String[] special_chars = new String[] { "&", "&amp;", "\"", "&quot;", "'", "&apos;", "<",
+			"&lt;", ">", "&gt;" };
+
+	private String encoding = "UTF-8";
+
+	/** Creates a new instance of XMLMarchaller */
+	public Marshaller() {
+	}
+
+	/**
+	 * Replave invalid xml chars according to the following table: & => &amp; "
+	 * => &quot; ' => &apos; < => &lt; > => &gt;
+	 */
+	public static String xmlEscape(String text) {
+		if (text == null)
+			return "";
+		int i = 0;
+		for (i = 0; i < special_chars.length; i += 2) {
+			text = string_replace(special_chars[i + 1], special_chars[i], text);
+			// text = string_replace(special_chars[i], special_chars[i+1],
+			// text);
+		}
+
+		return text;
+	}
+
+	/**
+	 * Replace s2 with s1 in s3
+	 **/
+	public static String string_replace(String s1, String s2, String s3) {
+		String string = "";
+		string = "";
+
+		if (s2 == null || s3 == null || s2.length() == 0)
+			return s3;
+
+		int pos_i = 0; // posizione corrente.
+		int pos_f = 0; // posizione corrente finale
+
+		int len = s2.length();
+		while ((pos_f = s3.indexOf(s2, pos_i)) >= 0) {
+			string += s3.substring(pos_i, pos_f) + s1;
+			// +string.substring(pos+ s2.length());
+			pos_f = pos_i = pos_f + len;
+
+		}
+
+		string += s3.substring(pos_i);
+
+		return string;
+	}
+
+	/*
+	 * This method generate the XML rapresentation of the request. The default
+	 * encoding used is UTF-8.
+	 */
+	public String marshal(Request request) {
+		StringBuffer xml = new StringBuffer();
+		xml.append("<?xml version=\"1.0\" encoding=\"" + getEncoding() + "\"?>\n");
+		xml.append("<request operationName=\"" + request.getOperationName() + "\"");
+
+		if (request.getLocale() != null)
+			xml.append(" locale=\"" + request.getLocale() + "\"");
+		xml.append(">\n");
+
+		currentIndentation = "\t";
+
+		for (int i = 0; i < request.getArguments().size(); ++i) {
+			Argument a = (Argument) request.getArguments().get(i);
+			String value = (a.getValue() == null) ? "/>" : "><![CDATA[" + a.getValue() + "]]></argument>";
+			xml.append(currentIndentation + "<argument name=\"" + xmlEscape(a.getName()) + "\"" + value + "\n");
+		}
+
+		xml.append(writeResourceDescriptor(request.getResourceDescriptor()));
+
+		xml.append("</request>\n");
+		return xml.toString();
+	}
+
+	public String writeResourceDescriptor(ResourceDescriptor rd) {
+		if (rd == null)
+			return "";
+
+		StringBuffer xml = new StringBuffer();
+		xml.append(currentIndentation + "<resourceDescriptor");
+
+		if (rd.getName() != null && !rd.getName().equals(""))
+			xml.append(" name=\"" + xmlEscape(rd.getName()) + "\"");
+
+		if (rd.getWsType() != null && !rd.getWsType().equals("")) {
+			xml.append(" wsType=\"" + xmlEscape(rd.getWsType()) + "\"");
+			if (rd.getWsType().equals(ResourceDescriptor.TYPE_REFERENCE) && rd.getReferenceType() != null
+					&& !rd.getReferenceType().equals("")) {
+				xml.append(" " + ResourceDescriptor.REFERENCE_TYPE + "=\"" + xmlEscape(rd.getReferenceType()) + "\"");
+			}
+		}
+
+		if (rd.getUriString() != null && !rd.getUriString().equals(""))
+			xml.append(" uriString=\"" + xmlEscape(rd.getUriString()) + "\"");
+
+		xml.append(" isNew=\"" + rd.isNew() + "\"");
+		xml.append(">\n");
+
+		currentIndentation += "\t";
+
+		if (rd.getLabel() != null && !rd.getLabel().equals(""))
+			xml.append(currentIndentation + "<label><![CDATA[" + rd.getLabel() + "]]></label>\n");
+
+		if (rd.getDescription() != null && rd.getDescription().length() > 0) {
+			xml.append(currentIndentation + "<description><![CDATA[" + rd.getDescription() + "]]></description>\n");
+		}
+
+		if (rd.getCreationDate() != null) {
+			xml.append(currentIndentation);
+			xml.append("<creationDate>");
+			writeCreationDateText(rd, xml);
+			xml.append("</creationDate>\n");
+		}
+
+		if (rd.getProperties() != null) {
+			for (int i = 0; i < rd.getProperties().size(); i++) {
+
+				ResourceProperty rp = (ResourceProperty) rd.getProperties().get(i);
+
+				String s = writeResourceProperty(rd, rp);
+				xml.append(s);
+			}
+		}
+
+		if (rd.getChildren() != null) {
+			for (int i = 0; i < rd.getChildren().size(); ++i) {
+				ResourceDescriptor rdchild = (ResourceDescriptor) rd.getChildren().get(i);
+				xml.append(writeResourceDescriptor(rdchild));
+			}
+		}
+
+		if (rd.getParameters() != null) {
+			for (int i = 0; i < rd.getParameters().size(); ++i) {
+				ListItem rdchild = (ListItem) rd.getParameters().get(i);
+				xml.append(writeResourceParameter(rdchild));
+			}
+		}
+
+		currentIndentation = currentIndentation.substring(0, currentIndentation.length() - 1);
+		xml.append(currentIndentation + "</resourceDescriptor>\n");
+		return xml.toString();
+	}
+
+	protected void writeCreationDateText(ResourceDescriptor rd, StringBuffer xml) {
+		// serializing as timestamp
+		long timestamp = rd.getCreationDate().getTime();
+		xml.append(timestamp);
+	}
+
+	public String getEncoding() {
+		return encoding;
+	}
+
+	public void setEncoding(String encoding) {
+		this.encoding = encoding;
+	}
+
+	private String writeResourceProperty(ResourceDescriptor rd, ResourceProperty rp) {
+
+		StringBuffer xml = new StringBuffer();
+		xml.append(currentIndentation + "<resourceProperty name=\"" + xmlEscape(rp.getName()) + "\">\n");
+
+		currentIndentation += "\t";
+		if (rp.getValue() != null) {
+			xml.append(currentIndentation + "<value><![CDATA[" + rp.getValue() + "]]></value>\n");
+		}
+
+		for (int i = 0; i < rp.getProperties().size(); i++) {
+			ResourceProperty rpChild = (ResourceProperty) rp.getProperties().get(i);
+			xml.append(writeResourceProperty(rd, rpChild));
+		}
+
+		currentIndentation = currentIndentation.substring(0, currentIndentation.length() - 1);
+		xml.append(currentIndentation + "</resourceProperty>\n");
+
+		// if
+		// (rp.getName().equals(ResourceDescriptor.PROP_FILERESOURCE_HAS_DATA)
+		// && rd.getData()!=null){
+		// xml.append(currentIndentation + "<resourceProperty name=\"" +
+		// ResourceDescriptor.PROP_DATA + "\">\n");
+		//
+		// xml.append(currentIndentation + "<value><![CDATA[" +
+		// Base64.encodeBase64String(rd.getData()) + "]]></value>\n");
+		// xml.append(currentIndentation + "</resourceProperty>\n");
+		// }
+
+		return xml.toString();
+	}
+
+	private String writeResourceParameter(ListItem rp) {
+
+		StringBuffer xml = new StringBuffer();
+		xml.append(currentIndentation + "<parameter name=\"" + xmlEscape(rp.getLabel()) + "\"");
+		if (rp.isListItem()) {
+			xml.append(" isListItem=\"true\"");
+		}
+
+		xml.append("><![CDATA[");
+		if (rp.getValue() != null) {
+			xml.append(rp.getValue());
+		}
+		xml.append("]]></parameter>\n");
+
+		return xml.toString();
+	}
+
+	public String marshal(OperationResult response) {
+		StringBuffer xml = new StringBuffer();
+		xml.append("<?xml version=\"1.0\" encoding=\"" + getEncoding() + "\"?>\n");
+		xml.append("<operationResult version=\"" + response.getVersion() + "\">\n");
+
+		currentIndentation = "\t";
+
+		xml.append(currentIndentation + "<returnCode><![CDATA[" + response.getReturnCode() + "]]></returnCode>\n");
+
+		if (response.getMessage() != null && response.getMessage().length() > 0) {
+			xml.append(
+					currentIndentation + "<returnMessage><![CDATA[" + response.getMessage() + "]]></returnMessage>\n");
+		}
+
+		if (response.getResourceDescriptors() != null) {
+			for (int i = 0; i < response.getResourceDescriptors().size(); ++i) {
+				ResourceDescriptor rd = (ResourceDescriptor) response.getResourceDescriptors().get(i);
+				xml.append(writeResourceDescriptor(rd));
+			}
+		}
+
+		currentIndentation = currentIndentation.substring(0, currentIndentation.length() - 1);
+		xml.append("</operationResult>\n");
+		return xml.toString();
+	}
+
+}

+ 26 - 0
src/main/java/com/uas/report/axis/util/StreamUtil.java

@@ -0,0 +1,26 @@
+package com.uas.report.axis.util;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class StreamUtil {
+
+	private static final int READ_STREAM_BUFFER_SIZE = 10000;
+
+	public static byte[] readData(InputStream is) throws IOException {
+		if (is == null) {
+			return null;
+		}
+
+		ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+		byte[] bytes = new byte[READ_STREAM_BUFFER_SIZE];
+		int ln = 0;
+		while ((ln = is.read(bytes)) > 0) {
+			baos.write(bytes, 0, ln);
+		}
+
+		return baos.toByteArray();
+	}
+}

+ 281 - 0
src/main/java/com/uas/report/axis/util/Unmarshaller.java

@@ -0,0 +1,281 @@
+package com.uas.report.axis.util;
+
+import java.io.StringReader;
+import java.util.Date;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+import com.uas.report.axis.Argument;
+import com.uas.report.axis.ListItem;
+import com.uas.report.axis.OperationResult;
+import com.uas.report.axis.Request;
+import com.uas.report.axis.ResourceDescriptor;
+import com.uas.report.axis.ResourceProperty;
+
+public class Unmarshaller {
+
+	private static final Log logger = LogFactory.getLog(Unmarshaller.class);
+
+	public static String readPCDATA(Node textNode) {
+		return readPCDATA(textNode, true);
+	}
+
+	public static String readPCDATA(Node textNode, boolean trim) {
+		NodeList list_child = textNode.getChildNodes();
+		for (int ck = 0; ck < list_child.getLength(); ck++) {
+			Node child_child = (Node) list_child.item(ck);
+
+			// --- start solution: if there is another node this should be the
+			// PCDATA-node
+			Node ns = child_child.getNextSibling();
+			if (ns != null)
+				child_child = ns;
+			// --- end solution
+
+			final short nt = child_child.getNodeType();
+
+			// 1. look for a CDATA first...
+			if (nt == Node.CDATA_SECTION_NODE) {
+				if (trim)
+					return ((String) child_child.getNodeValue()).trim();
+				return (String) child_child.getNodeValue();
+			}
+		}
+
+		for (int ck = 0; ck < list_child.getLength(); ck++) {
+			Node child_child = (Node) list_child.item(ck);
+
+			// --- start solution: if there is another node this should be the
+			// PCDATA-node
+			Node ns = child_child.getNextSibling();
+			if (ns != null)
+				child_child = ns;
+			// --- end solution
+
+			final short nt = child_child.getNodeType();
+			// 1. look for a CDATA first...
+			if (nt == Node.TEXT_NODE) {
+				if (trim)
+					return ((String) child_child.getNodeValue()).trim();
+				return (String) child_child.getNodeValue();
+			}
+		}
+
+		return "";
+	}
+
+	/*
+	 * This method unmarshall the xml. If the xml rapresents an OperationResult,
+	 * an OperationResult will be retun, otherwise it will return a
+	 * ResourceDescritor... The default encoding used is UTF-8.
+	 */
+	public static Object unmarshal(StringReader reader) throws Exception {
+		try {
+			// Use parser defined at the Java level, not a specific parser
+
+			DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+			DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+
+			InputSource input_source = new InputSource(reader);
+			Document document = docBuilder.parse(input_source);
+
+			Node rootNode = document.getDocumentElement();
+
+			if (rootNode.getNodeName().equals("request")) {
+				return readRequest(rootNode);
+			} else if (rootNode.getNodeName().equals("operationResult")) {
+				return readOperationResult(rootNode);
+			}
+
+		} catch (Exception e) {
+			logger.error(e);
+			throw e;
+		}
+
+		return null;
+	}
+
+	private static Request readRequest(Node requestNode) {
+
+		Request request = new Request();
+
+		NamedNodeMap nodeAttributes = requestNode.getAttributes();
+
+		if (nodeAttributes.getNamedItem("operationName") != null)
+			request.setOperationName(nodeAttributes.getNamedItem("operationName").getNodeValue());
+
+		if (nodeAttributes.getNamedItem("locale") != null)
+			request.setLocale(nodeAttributes.getNamedItem("locale").getNodeValue());
+
+		NodeList childsOfChild = requestNode.getChildNodes();
+		for (int c_count = 0; c_count < childsOfChild.getLength(); c_count++) {
+			Node child_child = (Node) childsOfChild.item(c_count);
+
+			if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("argument")) {
+				request.getArguments().add(readArgument(child_child));
+			}
+
+			if (child_child.getNodeType() == Node.ELEMENT_NODE
+					&& child_child.getNodeName().equals("resourceDescriptor")) {
+				request.setResourceDescriptor(readResourceDescriptor((Element) child_child));
+			}
+
+		}
+		return request;
+	}
+
+	private static Argument readArgument(Node argumentNode) {
+		Argument argument = new Argument();
+		NamedNodeMap nodeAttributes = argumentNode.getAttributes();
+
+		if (nodeAttributes.getNamedItem("name") != null)
+			argument.setName(nodeAttributes.getNamedItem("name").getNodeValue());
+
+		argument.setValue(readPCDATA(argumentNode));
+
+		return argument;
+	}
+
+	public static ResourceDescriptor readResourceDescriptor(Element rpNode) {
+
+		ResourceDescriptor rd = new ResourceDescriptor();
+		NamedNodeMap nodeAttributes;
+
+		if (rpNode instanceof Element) {
+			nodeAttributes = rpNode.getAttributes();
+		} else {
+			// the current implementation currently rely on rpNode being an
+			// Element
+			throw new IllegalStateException("repNode is not an Element");
+		}
+
+		if (nodeAttributes.getNamedItem("name") != null)
+			rd.setName(nodeAttributes.getNamedItem("name").getNodeValue());
+		if (nodeAttributes.getNamedItem("wsType") != null)
+			rd.setWsType(nodeAttributes.getNamedItem("wsType").getNodeValue());
+		if (nodeAttributes.getNamedItem(ResourceDescriptor.REFERENCE_TYPE) != null)
+			rd.setReferenceType(nodeAttributes.getNamedItem(ResourceDescriptor.REFERENCE_TYPE).getNodeValue());
+		if (nodeAttributes.getNamedItem("uriString") != null)
+			rd.setUriString(nodeAttributes.getNamedItem("uriString").getNodeValue());
+		if (nodeAttributes.getNamedItem("isNew") != null)
+			rd.setIsNew(nodeAttributes.getNamedItem("isNew").getNodeValue().equals("true"));
+
+		NodeList childsOfChild = rpNode.getChildNodes();
+		for (int c_count = 0; c_count < childsOfChild.getLength(); c_count++) {
+			Node child_child = (Node) childsOfChild.item(c_count);
+
+			if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("label")) {
+				rd.setLabel(readPCDATA(child_child));
+			} else if (child_child.getNodeType() == Node.ELEMENT_NODE
+					&& child_child.getNodeName().equals("description")) {
+				rd.setDescription(readPCDATA(child_child));
+			} else if (child_child.getNodeType() == Node.ELEMENT_NODE
+					&& child_child.getNodeName().equals("creationDate")) {
+				Date creationDate = readCreationDate(child_child);
+				if (creationDate != null) {
+					rd.setCreationDate(creationDate);
+				}
+			} else if (child_child.getNodeType() == Node.ELEMENT_NODE
+					&& child_child.getNodeName().equals("resourceProperty")) {
+				rd.setResourceProperty(readResourceProperty(child_child));
+			} else if (child_child.getNodeType() == Node.ELEMENT_NODE
+					&& child_child.getNodeName().equals("resourceDescriptor")) {
+				rd.getChildren().add(readResourceDescriptor((Element) child_child));
+			} else if (child_child.getNodeType() == Node.ELEMENT_NODE
+					&& child_child.getNodeName().equals("parameter")) {
+				rd.getParameters().add(readResourceParameter(child_child));
+			}
+		}
+
+		return rd;
+	}
+
+	protected static Date readCreationDate(Node node) {
+		Date creationDate = null;
+		String dateStr = readPCDATA(node, true);
+		if (dateStr.length() > 0) {
+			try {
+				// deserializing timestamp
+				long timestamp = Long.parseLong(dateStr);
+				creationDate = new Date(timestamp);
+			} catch (NumberFormatException e) {
+				throw new RuntimeException("Error parsing resource creation date timestamp \"" + dateStr + "\"");
+			}
+		}
+		return creationDate;
+	}
+
+	private static ResourceProperty readResourceProperty(Node rpNode) {
+
+		ResourceProperty rp = new ResourceProperty(null);
+		NamedNodeMap nodeAttributes = rpNode.getAttributes();
+
+		if (nodeAttributes.getNamedItem("name") != null)
+			rp.setName(nodeAttributes.getNamedItem("name").getNodeValue());
+
+		NodeList childsOfChild = rpNode.getChildNodes();
+		for (int c_count = 0; c_count < childsOfChild.getLength(); c_count++) {
+			Node child_child = (Node) childsOfChild.item(c_count);
+
+			if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("value")) {
+				rp.setValue(readPCDATA(child_child));
+			} else if (child_child.getNodeType() == Node.ELEMENT_NODE
+					&& child_child.getNodeName().equals("resourceProperty")) {
+				rp.getProperties().add(readResourceProperty(child_child));
+			}
+		}
+		return rp;
+	}
+
+	private static ListItem readResourceParameter(Node rpNode) {
+
+		ListItem rp = new ListItem();
+		NamedNodeMap nodeAttributes = rpNode.getAttributes();
+
+		if (nodeAttributes.getNamedItem("name") != null)
+			rp.setLabel(nodeAttributes.getNamedItem("name").getNodeValue());
+
+		if (nodeAttributes.getNamedItem("isListItem") != null)
+			rp.setIsListItem(nodeAttributes.getNamedItem("isListItem").getNodeValue().equals("true"));
+
+		rp.setValue(readPCDATA(rpNode));
+
+		return rp;
+	}
+
+	private static OperationResult readOperationResult(Node operationResultNode) {
+		OperationResult or = new OperationResult();
+
+		NamedNodeMap nodeAttributes = operationResultNode.getAttributes();
+
+		if (nodeAttributes.getNamedItem("version") != null)
+			or.setVersion(nodeAttributes.getNamedItem("version").getNodeValue());
+
+		NodeList childsOfChild = operationResultNode.getChildNodes();
+		for (int c_count = 0; c_count < childsOfChild.getLength(); c_count++) {
+			Node child_child = (Node) childsOfChild.item(c_count);
+
+			if (child_child.getNodeType() == Node.ELEMENT_NODE && child_child.getNodeName().equals("returnCode")) {
+				or.setReturnCode(Integer.parseInt(readPCDATA(child_child)));
+			} else if (child_child.getNodeType() == Node.ELEMENT_NODE
+					&& child_child.getNodeName().equals("returnMessage")) {
+				or.setMessage(readPCDATA(child_child));
+			} else if (child_child.getNodeType() == Node.ELEMENT_NODE
+					&& child_child.getNodeName().equals("resourceDescriptor")) {
+				or.getResourceDescriptors().add(readResourceDescriptor((Element) child_child));
+			}
+		}
+
+		return or;
+	}
+}