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 da...@apache.org on 2006/07/12 19:34:37 UTC

svn commit: r421336 - in /webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/impl: Messages.properties SimpleWsResource.java

Author: danj
Date: Wed Jul 12 10:34:35 2006
New Revision: 421336

URL: http://svn.apache.org/viewvc?rev=421336&view=rev
Log:
Added warning message for WSRF resource that do not offer a WSRP doc in their WSDL - this will 
reduce the function of the WSRF implementation and may also signal a simple error on the user's 
part (they may think they have a WSRP doc but they got the name wrong in the WSDL, etc.).

Modified:
    webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/impl/Messages.properties
    webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/impl/SimpleWsResource.java

Modified: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/impl/Messages.properties
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/impl/Messages.properties?rev=421336&r1=421335&r2=421336&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/impl/Messages.properties (original)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/impl/Messages.properties Wed Jul 12 10:34:35 2006
@@ -34,3 +34,4 @@
 ExistingResourceEPR = The unique EPR of this resource instance (object) has already been set - once a resource has an identifying EPR, it cannot be changed over its lifetime.
 NoRemoteCreate = The resource type at this endpoint cannot be instantiated by remote clients - all instances are (or have been) created through internal mechanisms. If this type is deployed with a service group, you can browse the group's wssg:Entry property to see what instances are already available.
 NoRequestContext = There was no context data for the current request. Every request for a touchpoint operation should have access to context data that allows the runtime to find the target EPR (resource). Make sure your service code uses Environment.addContext().
+NoWSRPDocument = The resource type at 'XXX' does not have a WSRP document defined in its WSDL - XXX. WSRF resources usually have a WSRP document to represent their state to clients, so if your WSDL is supposed to have one, make sure the QName of the WSRP document is correct. All WSRP requests will be approved by Muse's OpenPropertiesSchema.

Modified: webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/impl/SimpleWsResource.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/impl/SimpleWsResource.java?rev=421336&r1=421335&r2=421336&view=diff
==============================================================================
--- webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/impl/SimpleWsResource.java (original)
+++ webservices/muse/trunk/modules/muse-wsrf/src-impl/org/apache/muse/ws/resource/impl/SimpleWsResource.java Wed Jul 12 10:34:35 2006
@@ -16,22 +16,27 @@
 
 package org.apache.muse.ws.resource.impl;
 
-import javax.xml.namespace.QName;
-
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import org.apache.muse.core.Environment;
 import org.apache.muse.core.SimpleResource;
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.addressing.soap.SoapFault;
 import org.apache.muse.ws.resource.WsResource;
 import org.apache.muse.ws.resource.metadata.OpenMetadataDescriptor;
 import org.apache.muse.ws.resource.metadata.MetadataDescriptor;
+import org.apache.muse.ws.resource.metadata.WsrmdConstants;
+import org.apache.muse.ws.resource.metadata.impl.SimpleMetadataDescriptor;
+import org.apache.muse.ws.resource.metadata.impl.WsrmdUtils;
 import org.apache.muse.ws.resource.properties.ResourcePropertyCollection;
 import org.apache.muse.ws.resource.properties.impl.SimpleResourcePropertyCollection;
 import org.apache.muse.ws.resource.properties.impl.WsrpUtils;
 import org.apache.muse.ws.resource.properties.schema.OpenPropertiesSchema;
 import org.apache.muse.ws.resource.properties.schema.ResourcePropertiesSchema;
 import org.apache.muse.ws.resource.properties.schema.impl.SimpleResourcePropertiesSchema;
-import org.apache.muse.ws.addressing.soap.SoapFault;
 import org.apache.muse.ws.wsdl.WsdlUtils;
 
 /**
@@ -49,8 +54,62 @@
 
 public class SimpleWsResource extends SimpleResource implements WsResource
 {
+    //
+    // Used to look up all error messages
+    //
+    private static Messages _MESSAGES = MessagesFactory.get(SimpleResource.class);
+    
     private ResourcePropertyCollection _properties = null;
     
+    protected MetadataDescriptor createMetadataDescriptor(Document wsdl)
+    {
+        Element portTypeXML = WsdlUtils.getPortType(wsdl, getWsdlPortType());
+        
+        //
+        // get the location of the RMD file...
+        //
+        String rmdName = XmlUtils.getAttribute(portTypeXML, WsrmdConstants.DESCRIPTOR_ATTR_QNAME);
+        String rmdPath = XmlUtils.getAttribute(portTypeXML, WsrmdConstants.DESCRIPTOR_LOCATION_ATTR_QNAME);
+        
+        if (rmdName == null && rmdPath == null)
+            return OpenMetadataDescriptor.getInstance();
+        
+        if ((rmdName == null || rmdPath == null) && (rmdName != rmdPath))
+            throw new RuntimeException(_MESSAGES.get("IncompleteMetadataAttributes"));
+        
+        //
+        // load the doc and parse into a descriptor
+        //
+        Environment env = getEnvironment();
+        String path = env.createRelativePath(getWsdlPath(), rmdPath);        
+        Document rmdDoc = env.getDocument(path);
+        
+        Element descriptorXML = WsrmdUtils.getMetadataDescriptor(rmdDoc, rmdName);
+        
+        if (descriptorXML == null)
+        {
+            Object[] filler = { rmdPath, rmdName };
+            throw new RuntimeException(_MESSAGES.get("DescriptorNotFound", filler));
+        }
+        
+        return new SimpleMetadataDescriptor(descriptorXML);
+    }
+
+    protected ResourcePropertiesSchema createPropertiesSchema(Document wsdl)
+    {
+        Element wsrpDoc = WsrpUtils.getPropertiesDefinition(wsdl, getWsdlPortType());
+        
+        if (wsrpDoc == null) 
+        {
+            Object[] filler = { getContextPath(), getWsdlPath() };
+            getLog().warning(_MESSAGES.get("NoWSRPDocument", filler));
+            
+            return OpenPropertiesSchema.getInstance();
+        }
+        
+        return new SimpleResourcePropertiesSchema(wsrpDoc);
+    }
+    
     /**
      * 
      * This method returns the concrete WSRP state model - this is not 
@@ -73,7 +132,7 @@
     {
         return new SimpleResourcePropertyCollection();
     }
-
+    
     public final ResourcePropertyCollection getPropertyCollection()
     {
         return _properties;
@@ -106,11 +165,16 @@
         throws SoapFault
     {
         _properties = createPropertyCollection();
+
+        //
+        // get the WSDL, which has the WS-RP definition/schema
+        //
+        Document wsdl = WsdlUtils.createWSDL(getEnvironment(), getWsdlPath(), true);
         
-        ResourcePropertiesSchema schema = createPropertiesSchema();
+        ResourcePropertiesSchema schema = createPropertiesSchema(wsdl);
         _properties.setSchema(schema);
         
-        MetadataDescriptor metadata = createMetadataDescriptor();
+        MetadataDescriptor metadata = createMetadataDescriptor(wsdl);
         _properties.setMetadata(metadata);
         
         super.initialize();
@@ -119,30 +183,5 @@
 
         _properties.validateSchema();
         _properties.validateMetadata();
-    }
-    
-    protected ResourcePropertiesSchema createPropertiesSchema()
-    {
-        //
-        // get the WSDL, which has the WS-RP definition/schema
-        //
-        String path = getWsdlPath();
-        QName portType = getWsdlPortType();
-        Document wsdl = WsdlUtils.createWSDL(getEnvironment(), path, true);
-        Element wsrpDoc = WsrpUtils.getPropertiesDefinition(wsdl, portType);
-        
-        if (wsrpDoc == null) // FIXME: log message at WARNING level
-            return OpenPropertiesSchema.getInstance();
-        
-        return new SimpleResourcePropertiesSchema(wsrpDoc);
-    }
-    
-    protected MetadataDescriptor createMetadataDescriptor()
-    {
-        //
-        // FIXME: re-finish when WS-RMD spec is a) stable, and b) in 
-        //        public review (July-ish)
-        //
-        return OpenMetadataDescriptor.getInstance();
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org