You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-commits@ws.apache.org by wi...@apache.org on 2005/08/30 23:02:25 UTC

svn commit: r264858 - /webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/ManageableResourceImpl.java

Author: wire
Date: Tue Aug 30 14:02:22 2005
New Revision: 264858

URL: http://svn.apache.org/viewcvs?rev=264858&view=rev
Log: (empty)

Modified:
    webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/ManageableResourceImpl.java

Modified: webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/ManageableResourceImpl.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/ManageableResourceImpl.java?rev=264858&r1=264857&r2=264858&view=diff
==============================================================================
--- webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/ManageableResourceImpl.java (original)
+++ webservices/muse/trunk/src/examples/client/src/java/org/apache/ws/client/muse/client/impl/ManageableResourceImpl.java Tue Aug 30 14:02:22 2005
@@ -22,6 +22,8 @@
 import java.net.URISyntaxException;
 import java.net.URL;
 
+import javax.xml.namespace.QName;
+
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.addressing.EndpointReference;
@@ -34,6 +36,11 @@
 import org.apache.xmlbeans.XmlException;
 import org.apache.xmlbeans.XmlObject;
 import org.apache.xmlbeans.impl.values.XmlAnyUriImpl;
+import org.apache.xmlbeans.impl.values.XmlDoubleImpl;
+import org.apache.xmlbeans.impl.values.XmlStringImpl;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetMultipleResourcePropertiesDocument;
+import org.oasisOpen.docs.wsrf.x2004.x06.wsrfWSResourceProperties12Draft01.GetMultipleResourcePropertiesDocument.GetMultipleResourceProperties;
+import org.oasisOpen.docs.wsrf.x2004.x11.wsrfWSResourceProperties12Draft05.GetResourcePropertyDocumentDocument1;
 import org.xmlsoap.schemas.ws.x2004.x08.addressing.EndpointReferenceDocument;
 
 public class ManageableResourceImpl {
@@ -44,7 +51,7 @@
 
 	private ServiceStub ss;
 
-	private static Log LOG = LogFactory.getLog(ManageableResourceImpl.class);;
+	private static Log LOG = LogFactory.getLog(ManageableResourceImpl.class);
 
 	/**
 	 * Creates a ManageableResource from a class that implements
@@ -100,8 +107,7 @@
 	public String getId() throws FaultException,
 			UnexpectedServerResponseException, URISyntaxException, IOException,
 			XmlException {
-//		TODO Needs a more informative message
-		LOG.debug("Calling getId for " + this.epr.getAddress()); 
+		LOG.info("Calling getId on " + this.epr.getAddress()); 
 		XmlObject[] parts = rs
 				.getResourceProperty(IdentityCapability.PROP_NAME_RESOURCE_ID);
 		for (int i = 0; i < parts.length; i++) {
@@ -121,6 +127,21 @@
 				"Server returned either an unrecognizable response or no response at all");
 	}
 
+	public String getPropertyAsString(QName propertyName) throws FaultException, URISyntaxException, IOException, XmlException, UnexpectedServerResponseException{
+		LOG.info("getting property value  "+propertyName+" from " + this.epr.getAddress()); 
+		XmlObject[] parts = rs.getResourceProperty(propertyName);
+		for (int i = 0; i < parts.length; i++) {
+			XmlObject xmlObject = parts[i];
+			if (xmlObject instanceof XmlStringImpl) {
+				XmlStringImpl childElement = (XmlStringImpl) xmlObject;
+				String value = childElement.getStringValue();
+				return value;
+			}
+		}
+		throw new UnexpectedServerResponseException(
+				"Server returned either an unrecognizable response or no String type was returned as a response.");		
+	}
+	
 	public EndpointReference getEpr() {
 		return epr;
 	}
@@ -141,5 +162,56 @@
 				.parse(stream);
 		return new XmlBeansEndpointReference(eprd.getEndpointReference());
 	}
+
+	/* Returns a specific property value as a double.
+	 * 
+	 */
+	public double getPropertyAsDouble(QName propertyName) throws FaultException, URISyntaxException, IOException, XmlException, UnexpectedServerResponseException {
+		LOG.info("getting property value  "+propertyName+" from " + this.epr.getAddress()); 
+		XmlObject[] parts = rs.getResourceProperty(propertyName);
+		for (int i = 0; i < parts.length; i++) {
+			XmlObject xmlObject = parts[i];
+			if (xmlObject instanceof XmlDoubleImpl) {
+				XmlDoubleImpl childElement = (XmlDoubleImpl) xmlObject;
+				double value = childElement.getDoubleValue();
+				return value;
+			}
+		}
+		throw new UnexpectedServerResponseException(
+		"Server returned either an unrecognizable response or no String type was returned as a response.");		
+	}
+
+	/* Returns a specific property value as a untyped property as XMLObject[]. For clients
+	 * preferring to parse pure XML.
+	 * 
+	 */
+	public XmlObject[] getProperty(QName propertyName) throws FaultException, URISyntaxException, IOException, XmlException, UnexpectedServerResponseException {
+		LOG.info("getting property value  "+propertyName+" from " + this.epr.getAddress()); 
+		XmlObject[] parts = rs.getResourceProperty(propertyName);
+		return parts;
+	}
+
+	public PropertyInfoImpl[] getPropertyInfo() throws URISyntaxException, IOException, XmlException, UnexpectedServerResponseException {
+		GetMultipleResourcePropertiesDocument grpDocument = GetMultipleResourcePropertiesDocument.Factory.newInstance();
+		GetMultipleResourceProperties multi = grpDocument.addNewGetMultipleResourceProperties();
+		
+		
+        XmlObject parts = rs.sendRequest(grpDocument,"http://getresourcepropertydocument","M");									
+		return null;
+	}
+
+//	public XmlObject[] getMetric(QName testmetric) throws FaultException, URISyntaxException, IOException, XmlException, UnexpectedServerResponseException {
+//		LOG.info("getting Metric value  "+testmetric+" from " + this.epr.getAddress()); 
+//		XmlObject[] parts = rs.getResourceProperty(testmetric);
+//		if(parts==null||parts.length==0){
+//			throw new UnexpectedServerResponseException(
+//			"Server returned no metric values in response.");		
+//		}
+//		
+//		XmlObject part = parts[0];
+//		part.changeType();
+//		
+//		return parts;
+//	}
 
 }