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 2007/03/24 14:24:36 UTC
svn commit: r522026 [5/10] - in /webservices/muse/trunk/modules:
osgi-bundles/muse-complete/src/org/apache/muse/complete/
osgi-bundles/muse-util-all/src/org/apache/muse/util/osgi/
osgi-bundles/muse-wsa-soap/src/org/apache/muse/ws/addressing/osgi/ osgi-...
Modified: webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/addressing/WsrtSoapClient.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/addressing/WsrtSoapClient.java?view=diff&rev=522026&r1=522025&r2=522026
==============================================================================
--- webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/addressing/WsrtSoapClient.java (original)
+++ webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/addressing/WsrtSoapClient.java Sat Mar 24 06:24:32 2007
@@ -1,97 +1,101 @@
-/*=============================================================================*
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *=============================================================================*/
-
-package org.apache.muse.ws.resource.transfer.addressing;
-
-import org.apache.muse.util.xml.XmlUtils;
-import org.apache.muse.ws.addressing.EndpointReference;
-import org.apache.muse.ws.addressing.MessageHeaders;
-import org.apache.muse.ws.addressing.soap.SimpleSoapClient;
-import org.apache.muse.ws.addressing.soap.SoapConstants;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-/**
- * This is identical to SimpleSoapClient, except it uses WsrtMessageHeaders
- * instead of MessageHeaders, to ensure that the wsrt:ResourceTransfer
- * header exists on WS-RT requests.
- *
- * @author Mohammad Fakhar
- *
- */
-
-public class WsrtSoapClient extends SimpleSoapClient {
-
- /**
- *
- * Creates a valid SOAP message, including WS-A headers and WS-RT headers
- * that specify the destination and operation (action). The WS-A headers include
- * proper return/fault information for the recipient to use in response.
- *
- * @param source
- * @param destination
- * @param action
- * @param bodyElements
- *
- * @return A valid SOAP message that can be sent to the destination.
- *
- */
- protected Element createMessage(EndpointReference source,
- EndpointReference destination,
- String action,
- Element[] bodyElements)
- {
-
- Document doc = XmlUtils.createDocument();
- Element soapXML = XmlUtils.createElement(doc, SoapConstants.ENVELOPE_QNAME);
-
- //
- // add WS-Addressing headers
- //
- MessageHeaders headers = new WsrtMessageHeaders(destination, action);
-
- //
- // if there's a source EPR, we can provide a wsa:From
- //
- if (source != null)
- headers.setFromAddress(source);
-
- Element headersXML = headers.toXML(doc);
- soapXML.appendChild(headersXML);
-
- //
- // copy data into SOAP body
- //
- Element bodyXML = XmlUtils.createElement(doc, SoapConstants.BODY_QNAME);
- soapXML.appendChild(bodyXML);
-
- for (int n = 0; n < bodyElements.length; ++n)
- {
- if(bodyElements[n] != null)
- {
-
- if (bodyElements[n].getOwnerDocument() != doc)
- bodyElements[n] = (Element)doc.importNode(bodyElements[n], true);
-
- bodyXML.appendChild(bodyElements[n]);
- }
- }
-
- return soapXML;
- }
-
-
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.muse.ws.resource.transfer.addressing;
+
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.addressing.EndpointReference;
+import org.apache.muse.ws.addressing.MessageHeaders;
+import org.apache.muse.ws.addressing.soap.SimpleSoapClient;
+import org.apache.muse.ws.addressing.soap.SoapConstants;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+/**
+ * This is identical to SimpleSoapClient, except it uses WsrtMessageHeaders
+ * instead of MessageHeaders, to ensure that the wsrt:ResourceTransfer
+ * header exists on WS-RT requests.
+ *
+ * @author Mohammad Fakhar
+ *
+ */
+
+public class WsrtSoapClient extends SimpleSoapClient {
+
+ /**
+ *
+ * Creates a valid SOAP message, including WS-A headers and WS-RT headers
+ * that specify the destination and operation (action). The WS-A headers include
+ * proper return/fault information for the recipient to use in response.
+ *
+ * @param source
+ * @param destination
+ * @param action
+ * @param bodyElements
+ *
+ * @return A valid SOAP message that can be sent to the destination.
+ *
+ */
+ protected Element createMessage(EndpointReference source,
+ EndpointReference destination,
+ String action,
+ Element[] bodyElements)
+ {
+
+ Document doc = XmlUtils.createDocument();
+ Element soapXML = XmlUtils.createElement(doc, SoapConstants.ENVELOPE_QNAME);
+
+ //
+ // add WS-Addressing headers
+ //
+ MessageHeaders headers = new WsrtMessageHeaders(destination, action);
+
+ //
+ // if there's a source EPR, we can provide a wsa:From
+ //
+ if (source != null)
+ headers.setFromAddress(source);
+
+ Element headersXML = headers.toXML(doc);
+ soapXML.appendChild(headersXML);
+
+ //
+ // copy data into SOAP body
+ //
+ Element bodyXML = XmlUtils.createElement(doc, SoapConstants.BODY_QNAME);
+ soapXML.appendChild(bodyXML);
+
+ for (int n = 0; n < bodyElements.length; ++n)
+ {
+ if(bodyElements[n] != null)
+ {
+
+ if (bodyElements[n].getOwnerDocument() != doc)
+ bodyElements[n] = (Element)doc.importNode(bodyElements[n], true);
+
+ bodyXML.appendChild(bodyElements[n]);
+ }
+ }
+
+ return soapXML;
+ }
+
+
+
+}
Modified: webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/axishandlers/action/ActionOutHandler.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/axishandlers/action/ActionOutHandler.java?view=diff&rev=522026&r1=522025&r2=522026
==============================================================================
--- webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/axishandlers/action/ActionOutHandler.java (original)
+++ webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/axishandlers/action/ActionOutHandler.java Sat Mar 24 06:24:32 2007
@@ -1,90 +1,94 @@
-/*=============================================================================*
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *=============================================================================*/
-
-package org.apache.muse.ws.resource.transfer.axishandlers.action;
-
-
-
-import javax.xml.namespace.QName;
-
-import org.apache.axiom.soap.SOAPBody;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.engine.Handler;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.muse.ws.addressing.WsaConstants;
-
-/**
- * This is an axis2 handler that implements the Response scheme on wsa action uris, as axis2
- * by default does not implement such a scheme.
- * In cases where the operation results in a fault, a generic addressing fault action uri
- * is set on the response
- *
- * @author Mohammad Fakhar
- *
- */
-
-public class ActionOutHandler extends AbstractHandler
- implements Handler
-{
-
- private static final QName SOAP11FaultQName = new QName("http://schemas.xmlsoap.org/soap/envelope/", "Fault");
- private static final QName SOAP12FaultQName = new QName("http://www.w3.org/2003/05/soap-envelope", "Fault");
-
-
- public ActionOutHandler()
- {
- }
-
- public void invoke(MessageContext msgContext)
- throws AxisFault
- {
-
- // figure out if its a fault or not
- SOAPEnvelope env = msgContext.getEnvelope();
- SOAPBody body = env.getBody();
-
-
-
- if( (body.getFirstChildWithName(SOAP11FaultQName) != null) ||
- (body.getFirstChildWithName(SOAP12FaultQName) != null) )
- handleFault(msgContext);
- else
- handleResponse(msgContext);
-
- }
-
- private void handleResponse(MessageContext msgContext)
- {
- String replyAction = msgContext.getWSAAction();
-
- if(replyAction.endsWith("Request"))
- replyAction = replyAction.replaceAll("Request", "Response");
- else
- replyAction = replyAction + "Response";
-
- msgContext.setWSAAction(replyAction);
-
- }
-
- private void handleFault(MessageContext msgContext)
- {
- // just set the action uri to the default addressing fault;
- msgContext.setWSAAction(WsaConstants.FAULT_URI);
-
- }
- }
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.muse.ws.resource.transfer.axishandlers.action;
+
+
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.Handler;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.muse.ws.addressing.WsaConstants;
+
+/**
+ * This is an axis2 handler that implements the Response scheme on wsa action uris, as axis2
+ * by default does not implement such a scheme.
+ * In cases where the operation results in a fault, a generic addressing fault action uri
+ * is set on the response
+ *
+ * @author Mohammad Fakhar
+ *
+ */
+
+public class ActionOutHandler extends AbstractHandler
+ implements Handler
+{
+
+ private static final QName SOAP11FaultQName = new QName("http://schemas.xmlsoap.org/soap/envelope/", "Fault");
+ private static final QName SOAP12FaultQName = new QName("http://www.w3.org/2003/05/soap-envelope", "Fault");
+
+
+ public ActionOutHandler()
+ {
+ }
+
+ public void invoke(MessageContext msgContext)
+ throws AxisFault
+ {
+
+ // figure out if its a fault or not
+ SOAPEnvelope env = msgContext.getEnvelope();
+ SOAPBody body = env.getBody();
+
+
+
+ if( (body.getFirstChildWithName(SOAP11FaultQName) != null) ||
+ (body.getFirstChildWithName(SOAP12FaultQName) != null) )
+ handleFault(msgContext);
+ else
+ handleResponse(msgContext);
+
+ }
+
+ private void handleResponse(MessageContext msgContext)
+ {
+ String replyAction = msgContext.getWSAAction();
+
+ if(replyAction.endsWith("Request"))
+ replyAction = replyAction.replaceAll("Request", "Response");
+ else
+ replyAction = replyAction + "Response";
+
+ msgContext.setWSAAction(replyAction);
+
+ }
+
+ private void handleFault(MessageContext msgContext)
+ {
+ // just set the action uri to the default addressing fault;
+ msgContext.setWSAAction(WsaConstants.FAULT_URI);
+
+ }
+ }
Modified: webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/axishandlers/headers/WsrtInHeaderHandler.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/axishandlers/headers/WsrtInHeaderHandler.java?view=diff&rev=522026&r1=522025&r2=522026
==============================================================================
--- webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/axishandlers/headers/WsrtInHeaderHandler.java (original)
+++ webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/axishandlers/headers/WsrtInHeaderHandler.java Sat Mar 24 06:24:32 2007
@@ -1,68 +1,72 @@
-/*=============================================================================*
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *=============================================================================*/
-
-package org.apache.muse.ws.resource.transfer.axishandlers.headers;
-
-import java.util.Iterator;
-
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPHeader;
-import org.apache.axiom.soap.SOAPHeaderBlock;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.engine.Handler;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.muse.ws.resource.transfer.WsrtConstants;
-
-/**
- * This is an axis2 handler that processes the wsrt resource transfer header.
- *
- * @author Mohammad Fakhar
- *
- */
-
-public class WsrtInHeaderHandler extends AbstractHandler
-implements Handler
-{
-
- public WsrtInHeaderHandler()
- {
- }
-
- public void invoke(MessageContext msgContext)
- throws AxisFault
- {
-
- SOAPEnvelope env = msgContext.getEnvelope();
- SOAPHeader header = env.getHeader();
-
- Iterator i = header.examineAllHeaderBlocks();
-
- while(i.hasNext())
- {
- SOAPHeaderBlock block = (SOAPHeaderBlock) i.next();
- String localName = block.getLocalName();
-
- if(localName.equals(WsrtConstants.RESOURCE_TRANSFER_LOCALNAME) && block.getMustUnderstand())
- {
- block.setProcessed();
- break;
- }
- }
-
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.muse.ws.resource.transfer.axishandlers.headers;
+
+import java.util.Iterator;
+
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.engine.Handler;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.muse.ws.resource.transfer.WsrtConstants;
+
+/**
+ * This is an axis2 handler that processes the wsrt resource transfer header.
+ *
+ * @author Mohammad Fakhar
+ *
+ */
+
+public class WsrtInHeaderHandler extends AbstractHandler
+implements Handler
+{
+
+ public WsrtInHeaderHandler()
+ {
+ }
+
+ public void invoke(MessageContext msgContext)
+ throws AxisFault
+ {
+
+ SOAPEnvelope env = msgContext.getEnvelope();
+ SOAPHeader header = env.getHeader();
+
+ Iterator i = header.examineAllHeaderBlocks();
+
+ while(i.hasNext())
+ {
+ SOAPHeaderBlock block = (SOAPHeaderBlock) i.next();
+ String localName = block.getLocalName();
+
+ if(localName.equals(WsrtConstants.RESOURCE_TRANSFER_LOCALNAME) && block.getMustUnderstand())
+ {
+ block.setProcessed();
+ break;
+ }
+ }
+
+ }
+
+}
Modified: webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/axishandlers/headers/WsrtOutHeaderHandler.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/axishandlers/headers/WsrtOutHeaderHandler.java?view=diff&rev=522026&r1=522025&r2=522026
==============================================================================
--- webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/axishandlers/headers/WsrtOutHeaderHandler.java (original)
+++ webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/axishandlers/headers/WsrtOutHeaderHandler.java Sat Mar 24 06:24:32 2007
@@ -1,78 +1,82 @@
-/*=============================================================================*
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *=============================================================================*/
-
-package org.apache.muse.ws.resource.transfer.axishandlers.headers;
-
-import java.util.Iterator;
-
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPHeader;
-import org.apache.axiom.soap.SOAPHeaderBlock;
-import org.apache.axis2.AxisFault;
-import org.apache.axis2.context.MessageContext;
-import org.apache.axis2.context.OperationContext;
-import org.apache.axis2.engine.Handler;
-import org.apache.axis2.handlers.AbstractHandler;
-import org.apache.muse.ws.resource.transfer.WsrtConstants;
-
-/**
- * WS-RT requires that WS-RT responses be marked with the wsrt:ResourceTransfer
- * header. This handler checks an outgoing SOAP message for WS-RT presence
- * and then adds the wsrt:ResourceTransfer header.
- *
- * @author Mohammad Fakhar
- *
- */
-
-public class WsrtOutHeaderHandler extends AbstractHandler
-implements Handler
-{
-
- public WsrtOutHeaderHandler()
- {
- }
-
- public void invoke(MessageContext msgContext)
- throws AxisFault
- {
-
- SOAPEnvelope env = msgContext.getEnvelope();
-
- // get the request envelope
- OperationContext opctx = msgContext.getOperationContext();
- MessageContext inMsgctx = opctx.getMessageContext("In");
- SOAPEnvelope reqEnv = inMsgctx.getEnvelope();
-
- // if wsrt:ResourceTransefer header was in request envelope, place one in response too
- SOAPHeader header = reqEnv.getHeader();
- Iterator i = header.examineAllHeaderBlocks();
-
- while(i.hasNext())
- {
- SOAPHeaderBlock block = (SOAPHeaderBlock) i.next();
- OMNamespace ns = block.getNamespace();
-
- if(ns.getName().equals(WsrtConstants.WSRT_NAMESPACE_URI) &&
- ns.getPrefix().equals(WsrtConstants.WSRT_PREFIX))
- {
- SOAPHeader respHeader = env.getHeader();
- respHeader.addHeaderBlock(WsrtConstants.RESOURCE_TRANSFER_LOCALNAME, ns);
- break;
- }
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.muse.ws.resource.transfer.axishandlers.headers;
+
+import java.util.Iterator;
+
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+import org.apache.axis2.engine.Handler;
+import org.apache.axis2.handlers.AbstractHandler;
+import org.apache.muse.ws.resource.transfer.WsrtConstants;
+
+/**
+ * WS-RT requires that WS-RT responses be marked with the wsrt:ResourceTransfer
+ * header. This handler checks an outgoing SOAP message for WS-RT presence
+ * and then adds the wsrt:ResourceTransfer header.
+ *
+ * @author Mohammad Fakhar
+ *
+ */
+
+public class WsrtOutHeaderHandler extends AbstractHandler
+implements Handler
+{
+
+ public WsrtOutHeaderHandler()
+ {
+ }
+
+ public void invoke(MessageContext msgContext)
+ throws AxisFault
+ {
+
+ SOAPEnvelope env = msgContext.getEnvelope();
+
+ // get the request envelope
+ OperationContext opctx = msgContext.getOperationContext();
+ MessageContext inMsgctx = opctx.getMessageContext("In");
+ SOAPEnvelope reqEnv = inMsgctx.getEnvelope();
+
+ // if wsrt:ResourceTransefer header was in request envelope, place one in response too
+ SOAPHeader header = reqEnv.getHeader();
+ Iterator i = header.examineAllHeaderBlocks();
+
+ while(i.hasNext())
+ {
+ SOAPHeaderBlock block = (SOAPHeaderBlock) i.next();
+ OMNamespace ns = block.getNamespace();
+
+ if(ns.getName().equals(WsrtConstants.WSRT_NAMESPACE_URI) &&
+ ns.getPrefix().equals(WsrtConstants.WSRT_PREFIX))
+ {
+ SOAPHeader respHeader = env.getHeader();
+ respHeader.addHeaderBlock(WsrtConstants.RESOURCE_TRANSFER_LOCALNAME, ns);
+ break;
+ }
+ }
+ }
+}
Modified: webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/CreateHandler.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/CreateHandler.java?view=diff&rev=522026&r1=522025&r2=522026
==============================================================================
--- webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/CreateHandler.java (original)
+++ webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/CreateHandler.java Sat Mar 24 06:24:32 2007
@@ -1,189 +1,192 @@
-/*=============================================================================*
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *=============================================================================*/
-
-
-package org.apache.muse.ws.resource.transfer.create.impl;
-
-import javax.xml.namespace.QName;
-
-import org.apache.muse.core.routing.AbstractMessageHandler;
-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.EndpointReference;
-import org.apache.muse.ws.addressing.soap.SoapFault;
-import org.apache.muse.ws.resource.basefaults.BaseFault;
-import org.apache.muse.ws.resource.properties.ResourcePropertyCollection;
-import org.apache.muse.ws.resource.properties.WsrpConstants;
-import org.apache.muse.ws.resource.transfer.ExpressionFactory;
-import org.apache.muse.ws.resource.transfer.WsrtConstants;
-import org.apache.muse.ws.resource.transfer.create.ResourceData;
-import org.apache.muse.ws.resource.transfer.create.InvalidMetadataFault;
-import org.apache.muse.ws.resource.transfer.faults.UnsupportedDialectFault;
-import org.apache.muse.ws.resource.transfer.metadata.MetadataCapability;
-import org.apache.muse.ws.resource.transfer.put.PutModeUnsupportedFault;
-import org.apache.muse.ws.resource.transfer.put.PutValue;
-import org.apache.muse.ws.resource.transfer.put.impl.ElementPutValue;
-import org.apache.muse.ws.resource.transfer.put.impl.PutQNameRequest;
-import org.apache.muse.ws.resource.transfer.put.impl.PutRequest;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- * Parses metadata and resource value out of WS-RT create requests for
- * processing by create capability
- *
- * @author Mohammad Fakhar
- *
- */
-
-public class CreateHandler extends AbstractMessageHandler
-{
-
- //
- // Used to lookup all exception messages
- //
- private Messages _MESSAGES = MessagesFactory.get(CreateHandler.class);
-
- private ExpressionFactory _exprFactory = null;
-
- private MetadataCapability _wsrtMDCap = null;
-
- private ResourcePropertyCollection _rpCollection = null;
-
- public CreateHandler(ExpressionFactory exprFactory, MetadataCapability wsrtMDCap, ResourcePropertyCollection rpCollection)
- {
- super(WsrtConstants.CREATE_URI, WsrtConstants.CREATE_QNAME);
- _exprFactory = exprFactory;
- _wsrtMDCap = wsrtMDCap;
- _rpCollection = rpCollection;
- }
-
- public Object[] fromXML(Element xml) throws SoapFault
- {
- if (isWSRTCreate(xml))
- return handleWSRTCreate(xml);
- return handleWSTCreate(xml);
- }
-
- private Object[] handleWSRTCreate(Element xml) throws BaseFault, PutModeUnsupportedFault
- {
- Element firstElement = XmlUtils.getFirstElement(xml);
- ResourceData resourceData = new ResourceData();
-
- if (firstElement != null)
- {
- // if there is any metadata in create request, it has to be the
- // first element
- SimpleMetadata metadata = null;
- metadata = handleMetadata(firstElement);
- resourceData.setResourceMetadata(metadata);
-
- String dialect = xml.getAttribute(WsrtConstants.DIALECT_ATTR_NAME);
-
- if (dialect.equals(WsrtConstants.QNAME_DIALECT))
- {
- // each fragment in create operation with prop dialect is
- // equivalent to a
- // wsrt Put insert operation with prop dialect, therefore a
- // PutQNameRequest
- // object can handle this request
- PutQNameRequest propRequest = new PutQNameRequest(xml);
- PutValue value = propRequest.getPutValue();
- resourceData.setResourceValue(value);
- }
- else if (!dialect.equals(""))
- {
- // We need to look at wsrt metadata to determine if
- // dialect is supported or not.
- if (!_wsrtMDCap.isSupportedDialect(dialect))
- {
- throw new UnsupportedDialectFault(
- _MESSAGES.get("UnsupportedDialect", new Object[] {dialect}));
-
- }
-
- // each fragment in create operation with non-qname dialect
- // is equivalent to a
- // wsrt Put insert operation with on an empty wsrp doc,
- // therefore a PutRequest
- // object is used to handle this request
- Document doc = XmlUtils.createDocument();
- Element wsrpDocRoot = XmlUtils.createElement(doc, WsrpConstants.DEFAULT_DOCUMENT_QNAME);
- doc.appendChild(wsrpDocRoot);
-
- PutRequest xpathReq = new PutRequest(xml, _rpCollection, _exprFactory, dialect);
- PutValue value = xpathReq.applyFragsToWSRPDoc();
- resourceData.setResourceValue(value);
- }
- }
-
- return new Object[] { resourceData };
- }
-
- private Object[] handleWSTCreate(Element xml)
- {
- ResourceData resourceData = new ResourceData();
-
- if (xml != null)
- {
- PutValue value = new ElementPutValue(xml);
- resourceData.setResourceValue(value);
- }
-
- return new Object[] { resourceData };
- }
-
- private boolean isWSRTCreate(Element xml)
- {
- if (xml == null)
- return false;
-
- QName xmlQName = new QName(xml.getNamespaceURI(), xml.getLocalName(), xml.getPrefix());
- return xmlQName.equals(WsrtConstants.CREATE_QNAME);
- }
-
- private boolean isMetadata(Element xml)
- {
- QName qname = new QName(xml.getNamespaceURI(), xml.getLocalName(), xml.getPrefix());
- return qname.equals(WsrtConstants.METADATA_QNAME);
- }
-
- private SimpleMetadata handleMetadata(Element xml) throws InvalidMetadataFault
- {
- SimpleMetadata metadata = null;
-
- if (isMetadata(xml))
- {
- metadata = new SimpleMetadata(xml);
- }
-
- return metadata;
- }
-
- public Element toXML(Object result)
- {
- EndpointReference epr = (EndpointReference)result;
- Element resCreated = XmlUtils.createElement(WsrtConstants.RESOURCE_CREATED_QNAME);
- Element[] eprElements = XmlUtils.getAllElements(epr.toXML());
-
- for (int i = 0; i < eprElements.length; i++)
- resCreated.appendChild(eprElements[i]);
-
- return resCreated;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.muse.ws.resource.transfer.create.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.muse.core.routing.AbstractMessageHandler;
+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.EndpointReference;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.apache.muse.ws.resource.basefaults.BaseFault;
+import org.apache.muse.ws.resource.properties.ResourcePropertyCollection;
+import org.apache.muse.ws.resource.properties.WsrpConstants;
+import org.apache.muse.ws.resource.transfer.ExpressionFactory;
+import org.apache.muse.ws.resource.transfer.WsrtConstants;
+import org.apache.muse.ws.resource.transfer.create.ResourceData;
+import org.apache.muse.ws.resource.transfer.create.InvalidMetadataFault;
+import org.apache.muse.ws.resource.transfer.faults.UnsupportedDialectFault;
+import org.apache.muse.ws.resource.transfer.metadata.MetadataCapability;
+import org.apache.muse.ws.resource.transfer.put.PutModeUnsupportedFault;
+import org.apache.muse.ws.resource.transfer.put.PutValue;
+import org.apache.muse.ws.resource.transfer.put.impl.ElementPutValue;
+import org.apache.muse.ws.resource.transfer.put.impl.PutQNameRequest;
+import org.apache.muse.ws.resource.transfer.put.impl.PutRequest;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Parses metadata and resource value out of WS-RT create requests for
+ * processing by create capability
+ *
+ * @author Mohammad Fakhar
+ *
+ */
+
+public class CreateHandler extends AbstractMessageHandler
+{
+
+ //
+ // Used to lookup all exception messages
+ //
+ private Messages _MESSAGES = MessagesFactory.get(CreateHandler.class);
+
+ private ExpressionFactory _exprFactory = null;
+
+ private MetadataCapability _wsrtMDCap = null;
+
+ private ResourcePropertyCollection _rpCollection = null;
+
+ public CreateHandler(ExpressionFactory exprFactory, MetadataCapability wsrtMDCap, ResourcePropertyCollection rpCollection)
+ {
+ super(WsrtConstants.CREATE_URI, WsrtConstants.CREATE_QNAME);
+ _exprFactory = exprFactory;
+ _wsrtMDCap = wsrtMDCap;
+ _rpCollection = rpCollection;
+ }
+
+ public Object[] fromXML(Element xml) throws SoapFault
+ {
+ if (isWSRTCreate(xml))
+ return handleWSRTCreate(xml);
+ return handleWSTCreate(xml);
+ }
+
+ private Object[] handleWSRTCreate(Element xml) throws BaseFault, PutModeUnsupportedFault
+ {
+ Element firstElement = XmlUtils.getFirstElement(xml);
+ ResourceData resourceData = new ResourceData();
+
+ if (firstElement != null)
+ {
+ // if there is any metadata in create request, it has to be the
+ // first element
+ SimpleMetadata metadata = null;
+ metadata = handleMetadata(firstElement);
+ resourceData.setResourceMetadata(metadata);
+
+ String dialect = xml.getAttribute(WsrtConstants.DIALECT_ATTR_NAME);
+
+ if (dialect.equals(WsrtConstants.QNAME_DIALECT))
+ {
+ // each fragment in create operation with prop dialect is
+ // equivalent to a
+ // wsrt Put insert operation with prop dialect, therefore a
+ // PutQNameRequest
+ // object can handle this request
+ PutQNameRequest propRequest = new PutQNameRequest(xml);
+ PutValue value = propRequest.getPutValue();
+ resourceData.setResourceValue(value);
+ }
+ else if (!dialect.equals(""))
+ {
+ // We need to look at wsrt metadata to determine if
+ // dialect is supported or not.
+ if (!_wsrtMDCap.isSupportedDialect(dialect))
+ {
+ throw new UnsupportedDialectFault(
+ _MESSAGES.get("UnsupportedDialect", new Object[] {dialect}));
+
+ }
+
+ // each fragment in create operation with non-qname dialect
+ // is equivalent to a
+ // wsrt Put insert operation with on an empty wsrp doc,
+ // therefore a PutRequest
+ // object is used to handle this request
+ Document doc = XmlUtils.createDocument();
+ Element wsrpDocRoot = XmlUtils.createElement(doc, WsrpConstants.DEFAULT_DOCUMENT_QNAME);
+ doc.appendChild(wsrpDocRoot);
+
+ PutRequest xpathReq = new PutRequest(xml, _rpCollection, _exprFactory, dialect);
+ PutValue value = xpathReq.applyFragsToWSRPDoc();
+ resourceData.setResourceValue(value);
+ }
+ }
+
+ return new Object[] { resourceData };
+ }
+
+ private Object[] handleWSTCreate(Element xml)
+ {
+ ResourceData resourceData = new ResourceData();
+
+ if (xml != null)
+ {
+ PutValue value = new ElementPutValue(xml);
+ resourceData.setResourceValue(value);
+ }
+
+ return new Object[] { resourceData };
+ }
+
+ private boolean isWSRTCreate(Element xml)
+ {
+ if (xml == null)
+ return false;
+
+ QName xmlQName = new QName(xml.getNamespaceURI(), xml.getLocalName(), xml.getPrefix());
+ return xmlQName.equals(WsrtConstants.CREATE_QNAME);
+ }
+
+ private boolean isMetadata(Element xml)
+ {
+ QName qname = new QName(xml.getNamespaceURI(), xml.getLocalName(), xml.getPrefix());
+ return qname.equals(WsrtConstants.METADATA_QNAME);
+ }
+
+ private SimpleMetadata handleMetadata(Element xml) throws InvalidMetadataFault
+ {
+ SimpleMetadata metadata = null;
+
+ if (isMetadata(xml))
+ {
+ metadata = new SimpleMetadata(xml);
+ }
+
+ return metadata;
+ }
+
+ public Element toXML(Object result)
+ {
+ EndpointReference epr = (EndpointReference)result;
+ Element resCreated = XmlUtils.createElement(WsrtConstants.RESOURCE_CREATED_QNAME);
+ Element[] eprElements = XmlUtils.getAllElements(epr.toXML());
+
+ for (int i = 0; i < eprElements.length; i++)
+ resCreated.appendChild(eprElements[i]);
+
+ return resCreated;
+ }
+
+}
Modified: webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/SimpleCreateCapability.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/SimpleCreateCapability.java?view=diff&rev=522026&r1=522025&r2=522026
==============================================================================
--- webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/SimpleCreateCapability.java (original)
+++ webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/SimpleCreateCapability.java Sat Mar 24 06:24:32 2007
@@ -1,296 +1,299 @@
-/*=============================================================================*
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *=============================================================================*/
-
-
-package org.apache.muse.ws.resource.transfer.create.impl;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.lang.reflect.Method;
-import java.util.Map;
-
-import org.apache.muse.core.AbstractCapability;
-import org.apache.muse.core.Capability;
-import org.apache.muse.core.Resource;
-import org.apache.muse.core.ResourceManager;
-import org.apache.muse.core.routing.MessageHandler;
-import org.apache.muse.util.ReflectUtils;
-import org.apache.muse.util.messages.Messages;
-import org.apache.muse.util.messages.MessagesFactory;
-import org.apache.muse.ws.addressing.EndpointReference;
-import org.apache.muse.ws.addressing.soap.SoapFault;
-import org.apache.muse.ws.metadata.WsxConstants;
-import org.apache.muse.ws.resource.WsResource;
-import org.apache.muse.ws.resource.properties.set.faults.InvalidModificationFault;
-import org.apache.muse.ws.resource.transfer.WsrtConstants;
-import org.apache.muse.ws.resource.transfer.create.CreateFault;
-import org.apache.muse.ws.resource.transfer.create.CreateCapability;
-import org.apache.muse.ws.resource.transfer.create.Metadata;
-import org.apache.muse.ws.resource.transfer.create.ResourceData;
-import org.apache.muse.ws.resource.transfer.faults.InvalidExpressionFault;
-import org.apache.muse.ws.resource.transfer.impl.SimpleExpressionFactory;
-import org.apache.muse.ws.resource.transfer.metadata.MetadataCapability;
-import org.apache.muse.ws.resource.transfer.metadata.impl.SimpleMetadataCapability;
-import org.apache.muse.ws.resource.transfer.put.PutValue;
-import org.apache.muse.ws.resource.transfer.put.PutCapability;
-import org.apache.muse.ws.resource.transfer.put.impl.SimplePutCapability;
-
-/**
- *
- * This is the Muse capability implementation for the WS-RT Create operation.
- *
- * @author Mohammad Fakhar
- *
- */
-
-public class SimpleCreateCapability extends AbstractCapability implements CreateCapability
-{
- //
- // Used to lookup all exception messages
- //
- private Messages _MESSAGES = MessagesFactory.get(SimpleCreateCapability.class);
-
-
- // init param name of the resource type context parameter thats passed to
- // this capabiility
- protected static final String RES_TYPE_CONTEXT_PARAM = "resource-type-context-path";
-
- // this indicates what type of resource the capability creates and is set
- // during intialization
- protected String _resourceEndpoint = null;
-
- // the create capability delegates to wsrt metadata capability for handling
- // wsrt metadata received
- // on create requests.
- protected MetadataCapability _wsrtMDCap = null;
-
- protected MessageHandler createHandler() throws SoapFault
- {
- // the create handler uses a PutRequest to actually pre-process the wsrt
- // fragments
- // in create request on the resource document. And the PutRequest needs
- // the property collection of resource to do the put operation.
- // Therefore we create a temporary resource so we can pass the initial
- // property
- // collection of resource to the create handler.
- ResourceManager manager = getResource().getResourceManager();
- WsResource tempResource = null;
-
- try
- {
- tempResource = (WsResource)manager.createResource(_resourceEndpoint);
- }
- catch (ClassCastException e)
- {
- throw new RuntimeException(_MESSAGES.get("ResourceMustBeWSResource", new Object[] {e.getMessage()}));
-
- }
- tempResource.initialize();
-
- // TODO: make expr factory an init variable on capability for pluggable
- // dialects
- MessageHandler handler = new CreateHandler(new SimpleExpressionFactory(), _wsrtMDCap,
- tempResource.getPropertyCollection());
-
- Method method = ReflectUtils.getFirstMethod(getClass(), "create");
- handler.setMethod(method);
-
- // destroy temp resource
- tempResource.shutdown();
-
- return handler;
- }
-
- /**
- * This operation handles WS-RT create requests by acting on the resource
- * data passed in.
- *
- * @param resourceData
- * @see ResourceData
- */
- public EndpointReference create(ResourceData resourceData) throws InvalidExpressionFault, CreateFault, SoapFault
- {
- try
- {
- // create resource and initialize it
- ResourceManager resourceMgr = getResource().getResourceManager();
- Resource resource = resourceMgr.createResource(_resourceEndpoint);
- resource.initialize();
-
- Metadata metadata = resourceData.getResourceMetadata();
- PutValue value = resourceData.getResourceValue();
-
- if (metadata != null)
- handleMetadata(metadata, resource);
-
- if (value != null)
- {
- try
- {
- setResourceValue(value, resource);
- }
- catch (Exception e)
- {
- // if initial representation of resource couldn't be set,
- // then
- // the resource should be destroyed.
- resource.shutdown();
- throw e;
- }
- }
-
- resourceMgr.addResource(resource.getEndpointReference(), resource);
-
- return resource.getEndpointReference();
- }
- catch (Exception e)
- {
- // if they are put operation faults, let them through, otherwise
- // throw create fault
- if (e instanceof InvalidExpressionFault)
- throw (InvalidExpressionFault)e;
-
- else if (e instanceof InvalidModificationFault)
- throw (InvalidModificationFault)e;
-
- else
- {
- StringWriter sw = new StringWriter();
- e.printStackTrace(new PrintWriter(sw));
-
- throw new CreateFault(e, _MESSAGES.get("CreateOperationFailed", new Object[] {sw.toString()}));
- }
- }
- }
-
- private void setResourceValue(PutValue value, Resource resource) throws SoapFault
- {
- // use wsrt resource's put capability to set the value
- PutCapability putCap = (PutCapability)resource.getCapability(WsrtConstants.PUT_URI);
-
- // if put capability doesn't exist, temporartily add it to resource to
- // set
- // its initail representation
- boolean tempPutCap = false;
- if (putCap == null)
- {
- tempPutCap = true;
- putCap = new SimplePutCapability();
- resource.addCapability(putCap);
- putCap.initialize();
-
- }
-
- // set the values
- putCap.put(value);
-
- if (tempPutCap)
- // if put capability was temporarily added, remove it.
- putCap.shutdown();
- }
-
- private void handleMetadata(Metadata metadata, Resource resource) throws SoapFault
- {
- // use wsrt resource's metadata capability to set metadata, if
- // capability doesn't exist, throw exception
- Capability mdCap = resource.getCapability(WsxConstants.GET_METADATA_CAPABILITY);
-
- if (mdCap == null)
- throw new SoapFault(_MESSAGES.get("MDNotSupported"));
- else if (!(mdCap instanceof MetadataCapability))
- throw new SoapFault(_MESSAGES.get("MDNotWSRTType"));
- else
- {
- MetadataCapability wsrtMDCap = (MetadataCapability)mdCap;
- wsrtMDCap.setMetadata(metadata);
- }
- }
-
- public void initialize() throws SoapFault
- {
- super.initialize();
-
- setResourceEndpoint();
-
- initializeMetadataCap();
-
- setMessageHandler(createHandler());
- }
-
- /**
- * This method uses the RES_TYPE_CONTEXT_PARAM initialization parameter,
- * which is the implementation class name of the type of resource to be
- * created, to figure out what type of resources are going to be created by
- * this capability.
- */
- private void setResourceEndpoint() throws SoapFault
- {
-
- Map initParams = getInitializationParameters();
- String resType = null;
-
- if (initParams != null)
- // get the resource-type-context-path parameter that indicates
- // of the resource type that is created by this capability
- resType = (String)initParams.get(RES_TYPE_CONTEXT_PARAM);
-
- if (resType == null)
- throw new SoapFault(_MESSAGES.get("NoResTypeParam", new Object[] {RES_TYPE_CONTEXT_PARAM}));
-
- // get the class for resource type
- Class resTypeContextPath = null;
- try
- {
- resTypeContextPath = Class.forName(resType);
- }
- catch (ClassNotFoundException e)
- {
- throw new SoapFault(_MESSAGES.get("ClassLoadError", new Object[] {resType}));
- }
-
- // get resource manager and find the endpoint for the resource type
- ResourceManager resourceMgr = getResource().getResourceManager();
- _resourceEndpoint = resourceMgr.getResourceContextPath(resTypeContextPath);
-
- if (_resourceEndpoint == null)
- throw new SoapFault(_MESSAGES.get("EPNotFound", new Object[] {resTypeContextPath}));
- }
-
- private void initializeMetadataCap() throws SoapFault
- {
- // wsrt metadata will be handled by MetadataCapability.
- Capability metadataCap = getResource().getCapability(WsxConstants.GET_METADATA_CAPABILITY);
- _wsrtMDCap = null;
-
- if (metadataCap == null)
- {
- // add wsrt metadata capability
- _wsrtMDCap = new SimpleMetadataCapability();
- getResource().addCapability(_wsrtMDCap);
- _wsrtMDCap.initialize();
- }
- else if (!(metadataCap instanceof MetadataCapability))
- throw new RuntimeException(_MESSAGES.get("MDOfCreateCapNotWSRTType"));
- else
- _wsrtMDCap = (MetadataCapability)metadataCap;
- }
-
- public void shutdown() throws SoapFault
- {
- super.shutdown();
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.muse.ws.resource.transfer.create.impl;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Method;
+import java.util.Map;
+
+import org.apache.muse.core.AbstractCapability;
+import org.apache.muse.core.Capability;
+import org.apache.muse.core.Resource;
+import org.apache.muse.core.ResourceManager;
+import org.apache.muse.core.routing.MessageHandler;
+import org.apache.muse.util.ReflectUtils;
+import org.apache.muse.util.messages.Messages;
+import org.apache.muse.util.messages.MessagesFactory;
+import org.apache.muse.ws.addressing.EndpointReference;
+import org.apache.muse.ws.addressing.soap.SoapFault;
+import org.apache.muse.ws.metadata.WsxConstants;
+import org.apache.muse.ws.resource.WsResource;
+import org.apache.muse.ws.resource.properties.set.faults.InvalidModificationFault;
+import org.apache.muse.ws.resource.transfer.WsrtConstants;
+import org.apache.muse.ws.resource.transfer.create.CreateFault;
+import org.apache.muse.ws.resource.transfer.create.CreateCapability;
+import org.apache.muse.ws.resource.transfer.create.Metadata;
+import org.apache.muse.ws.resource.transfer.create.ResourceData;
+import org.apache.muse.ws.resource.transfer.faults.InvalidExpressionFault;
+import org.apache.muse.ws.resource.transfer.impl.SimpleExpressionFactory;
+import org.apache.muse.ws.resource.transfer.metadata.MetadataCapability;
+import org.apache.muse.ws.resource.transfer.metadata.impl.SimpleMetadataCapability;
+import org.apache.muse.ws.resource.transfer.put.PutValue;
+import org.apache.muse.ws.resource.transfer.put.PutCapability;
+import org.apache.muse.ws.resource.transfer.put.impl.SimplePutCapability;
+
+/**
+ *
+ * This is the Muse capability implementation for the WS-RT Create operation.
+ *
+ * @author Mohammad Fakhar
+ *
+ */
+
+public class SimpleCreateCapability extends AbstractCapability implements CreateCapability
+{
+ //
+ // Used to lookup all exception messages
+ //
+ private Messages _MESSAGES = MessagesFactory.get(SimpleCreateCapability.class);
+
+
+ // init param name of the resource type context parameter thats passed to
+ // this capabiility
+ protected static final String RES_TYPE_CONTEXT_PARAM = "resource-type-context-path";
+
+ // this indicates what type of resource the capability creates and is set
+ // during intialization
+ protected String _resourceEndpoint = null;
+
+ // the create capability delegates to wsrt metadata capability for handling
+ // wsrt metadata received
+ // on create requests.
+ protected MetadataCapability _wsrtMDCap = null;
+
+ protected MessageHandler createHandler() throws SoapFault
+ {
+ // the create handler uses a PutRequest to actually pre-process the wsrt
+ // fragments
+ // in create request on the resource document. And the PutRequest needs
+ // the property collection of resource to do the put operation.
+ // Therefore we create a temporary resource so we can pass the initial
+ // property
+ // collection of resource to the create handler.
+ ResourceManager manager = getResource().getResourceManager();
+ WsResource tempResource = null;
+
+ try
+ {
+ tempResource = (WsResource)manager.createResource(_resourceEndpoint);
+ }
+ catch (ClassCastException e)
+ {
+ throw new RuntimeException(_MESSAGES.get("ResourceMustBeWSResource", new Object[] {e.getMessage()}));
+
+ }
+ tempResource.initialize();
+
+ // TODO: make expr factory an init variable on capability for pluggable
+ // dialects
+ MessageHandler handler = new CreateHandler(new SimpleExpressionFactory(), _wsrtMDCap,
+ tempResource.getPropertyCollection());
+
+ Method method = ReflectUtils.getFirstMethod(getClass(), "create");
+ handler.setMethod(method);
+
+ // destroy temp resource
+ tempResource.shutdown();
+
+ return handler;
+ }
+
+ /**
+ * This operation handles WS-RT create requests by acting on the resource
+ * data passed in.
+ *
+ * @param resourceData
+ * @see ResourceData
+ */
+ public EndpointReference create(ResourceData resourceData) throws InvalidExpressionFault, CreateFault, SoapFault
+ {
+ try
+ {
+ // create resource and initialize it
+ ResourceManager resourceMgr = getResource().getResourceManager();
+ Resource resource = resourceMgr.createResource(_resourceEndpoint);
+ resource.initialize();
+
+ Metadata metadata = resourceData.getResourceMetadata();
+ PutValue value = resourceData.getResourceValue();
+
+ if (metadata != null)
+ handleMetadata(metadata, resource);
+
+ if (value != null)
+ {
+ try
+ {
+ setResourceValue(value, resource);
+ }
+ catch (Exception e)
+ {
+ // if initial representation of resource couldn't be set,
+ // then
+ // the resource should be destroyed.
+ resource.shutdown();
+ throw e;
+ }
+ }
+
+ resourceMgr.addResource(resource.getEndpointReference(), resource);
+
+ return resource.getEndpointReference();
+ }
+ catch (Exception e)
+ {
+ // if they are put operation faults, let them through, otherwise
+ // throw create fault
+ if (e instanceof InvalidExpressionFault)
+ throw (InvalidExpressionFault)e;
+
+ else if (e instanceof InvalidModificationFault)
+ throw (InvalidModificationFault)e;
+
+ else
+ {
+ StringWriter sw = new StringWriter();
+ e.printStackTrace(new PrintWriter(sw));
+
+ throw new CreateFault(e, _MESSAGES.get("CreateOperationFailed", new Object[] {sw.toString()}));
+ }
+ }
+ }
+
+ private void setResourceValue(PutValue value, Resource resource) throws SoapFault
+ {
+ // use wsrt resource's put capability to set the value
+ PutCapability putCap = (PutCapability)resource.getCapability(WsrtConstants.PUT_URI);
+
+ // if put capability doesn't exist, temporartily add it to resource to
+ // set
+ // its initail representation
+ boolean tempPutCap = false;
+ if (putCap == null)
+ {
+ tempPutCap = true;
+ putCap = new SimplePutCapability();
+ resource.addCapability(putCap);
+ putCap.initialize();
+
+ }
+
+ // set the values
+ putCap.put(value);
+
+ if (tempPutCap)
+ // if put capability was temporarily added, remove it.
+ putCap.shutdown();
+ }
+
+ private void handleMetadata(Metadata metadata, Resource resource) throws SoapFault
+ {
+ // use wsrt resource's metadata capability to set metadata, if
+ // capability doesn't exist, throw exception
+ Capability mdCap = resource.getCapability(WsxConstants.GET_METADATA_CAPABILITY);
+
+ if (mdCap == null)
+ throw new SoapFault(_MESSAGES.get("MDNotSupported"));
+ else if (!(mdCap instanceof MetadataCapability))
+ throw new SoapFault(_MESSAGES.get("MDNotWSRTType"));
+ else
+ {
+ MetadataCapability wsrtMDCap = (MetadataCapability)mdCap;
+ wsrtMDCap.setMetadata(metadata);
+ }
+ }
+
+ public void initialize() throws SoapFault
+ {
+ super.initialize();
+
+ setResourceEndpoint();
+
+ initializeMetadataCap();
+
+ setMessageHandler(createHandler());
+ }
+
+ /**
+ * This method uses the RES_TYPE_CONTEXT_PARAM initialization parameter,
+ * which is the implementation class name of the type of resource to be
+ * created, to figure out what type of resources are going to be created by
+ * this capability.
+ */
+ private void setResourceEndpoint() throws SoapFault
+ {
+
+ Map initParams = getInitializationParameters();
+ String resType = null;
+
+ if (initParams != null)
+ // get the resource-type-context-path parameter that indicates
+ // of the resource type that is created by this capability
+ resType = (String)initParams.get(RES_TYPE_CONTEXT_PARAM);
+
+ if (resType == null)
+ throw new SoapFault(_MESSAGES.get("NoResTypeParam", new Object[] {RES_TYPE_CONTEXT_PARAM}));
+
+ // get the class for resource type
+ Class resTypeContextPath = null;
+ try
+ {
+ resTypeContextPath = Class.forName(resType);
+ }
+ catch (ClassNotFoundException e)
+ {
+ throw new SoapFault(_MESSAGES.get("ClassLoadError", new Object[] {resType}));
+ }
+
+ // get resource manager and find the endpoint for the resource type
+ ResourceManager resourceMgr = getResource().getResourceManager();
+ _resourceEndpoint = resourceMgr.getResourceContextPath(resTypeContextPath);
+
+ if (_resourceEndpoint == null)
+ throw new SoapFault(_MESSAGES.get("EPNotFound", new Object[] {resTypeContextPath}));
+ }
+
+ private void initializeMetadataCap() throws SoapFault
+ {
+ // wsrt metadata will be handled by MetadataCapability.
+ Capability metadataCap = getResource().getCapability(WsxConstants.GET_METADATA_CAPABILITY);
+ _wsrtMDCap = null;
+
+ if (metadataCap == null)
+ {
+ // add wsrt metadata capability
+ _wsrtMDCap = new SimpleMetadataCapability();
+ getResource().addCapability(_wsrtMDCap);
+ _wsrtMDCap.initialize();
+ }
+ else if (!(metadataCap instanceof MetadataCapability))
+ throw new RuntimeException(_MESSAGES.get("MDOfCreateCapNotWSRTType"));
+ else
+ _wsrtMDCap = (MetadataCapability)metadataCap;
+ }
+
+ public void shutdown() throws SoapFault
+ {
+ super.shutdown();
+ }
+
+}
Modified: webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/SimpleLifetimeMetadata.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/SimpleLifetimeMetadata.java?view=diff&rev=522026&r1=522025&r2=522026
==============================================================================
--- webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/SimpleLifetimeMetadata.java (original)
+++ webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/SimpleLifetimeMetadata.java Sat Mar 24 06:24:32 2007
@@ -1,153 +1,156 @@
-/*=============================================================================*
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *=============================================================================*/
-
-
-package org.apache.muse.ws.resource.transfer.create.impl;
-
-import java.text.ParseException;
-import java.util.Date;
-
-import javax.xml.namespace.QName;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-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.util.xml.XsdUtils;
-import org.apache.muse.ws.resource.transfer.WsrtConstants;
-import org.apache.muse.ws.resource.transfer.create.LifetimeMetadata;
-
-/**
- *
- * This represents lifetime metadata of a WS-RT resource.
- *
- * @author Mohammad Fakhar
- *
- */
-
-public class SimpleLifetimeMetadata implements LifetimeMetadata
-{
- //
- // Used to lookup all exception messages
- //
- private Messages _MESSAGES = MessagesFactory.get(SimpleLifetimeMetadata.class);
-
- private Date _currentTime = new Date();
-
- private Date _terminateAt = null;
-
- private long _terminateAfter = -1;
-
- private long _terminateAfterIdle = -1;
-
- public SimpleLifetimeMetadata()
- {
- //
- // no initialization tasks required
- //
- }
-
- // we only handle terminate at lifetime metadata right now
- public SimpleLifetimeMetadata(Element xml)
- {
- Element[] ltChildren = XmlUtils.getAllElements(xml);
-
- for (int i = 0; i < ltChildren.length; i++)
- {
- Element ltChild = ltChildren[i];
- QName qname = new QName(ltChild.getNamespaceURI(), ltChild.getLocalName(),
- ltChild.getPrefix());
-
- if (qname.equals(WsrtConstants.WSRT_TERMINATEAT_QNAME))
- {
- String terminateAtStr = XmlUtils.extractText(ltChild);
- try
- {
- Date terminateDate = XsdUtils.getLocalTime(terminateAtStr);
- setTerminateAt(terminateDate);
- }
- catch (ParseException e)
- {
- throw new RuntimeException(_MESSAGES.get("ParseDateError", new Object[] {terminateAtStr}));
- }
- }
- }
- }
-
- public Date getCurrentTime()
- {
- return _currentTime;
- }
-
- public void setCurrentTime(Date currentTime)
- {
- _currentTime = currentTime;
- }
-
- public long getTerminateAfter()
- {
- return _terminateAfter;
- }
-
- public void setTerminateAfter(long terminateAfter)
- {
- _terminateAfter = terminateAfter;
- }
-
- public long getTerminateAfterIdle()
- {
- return _terminateAfterIdle;
- }
-
- public void setTerminateAfterIdle(long terminateAfterIdle)
- {
- _terminateAfterIdle = terminateAfterIdle;
- }
-
- public Date getTerminateAt()
- {
- return _terminateAt;
- }
-
- public void setTerminateAt(Date terminateAt)
- {
- _terminateAt = terminateAt;
- }
-
- public Element toXML()
- {
- return toXML(XmlUtils.EMPTY_DOC);
- }
-
- public Element toXML(Document factory)
- {
- Element ltXML = XmlUtils.createElement(factory, WsrtConstants.WSRT_LIFETIME_QNAME);
-
- if (_terminateAt != null)
- {
- Element termAtXML = XmlUtils.createElement(factory, WsrtConstants.WSRT_TERMINATEAT_QNAME);
- Node text = factory.createTextNode(XsdUtils.getLocalTimeString(_terminateAt));
- termAtXML.appendChild(text);
- ltXML.appendChild(termAtXML);
- }
-
- return ltXML;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.muse.ws.resource.transfer.create.impl;
+
+import java.text.ParseException;
+import java.util.Date;
+
+import javax.xml.namespace.QName;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+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.util.xml.XsdUtils;
+import org.apache.muse.ws.resource.transfer.WsrtConstants;
+import org.apache.muse.ws.resource.transfer.create.LifetimeMetadata;
+
+/**
+ *
+ * This represents lifetime metadata of a WS-RT resource.
+ *
+ * @author Mohammad Fakhar
+ *
+ */
+
+public class SimpleLifetimeMetadata implements LifetimeMetadata
+{
+ //
+ // Used to lookup all exception messages
+ //
+ private Messages _MESSAGES = MessagesFactory.get(SimpleLifetimeMetadata.class);
+
+ private Date _currentTime = new Date();
+
+ private Date _terminateAt = null;
+
+ private long _terminateAfter = -1;
+
+ private long _terminateAfterIdle = -1;
+
+ public SimpleLifetimeMetadata()
+ {
+ //
+ // no initialization tasks required
+ //
+ }
+
+ // we only handle terminate at lifetime metadata right now
+ public SimpleLifetimeMetadata(Element xml)
+ {
+ Element[] ltChildren = XmlUtils.getAllElements(xml);
+
+ for (int i = 0; i < ltChildren.length; i++)
+ {
+ Element ltChild = ltChildren[i];
+ QName qname = new QName(ltChild.getNamespaceURI(), ltChild.getLocalName(),
+ ltChild.getPrefix());
+
+ if (qname.equals(WsrtConstants.WSRT_TERMINATEAT_QNAME))
+ {
+ String terminateAtStr = XmlUtils.extractText(ltChild);
+ try
+ {
+ Date terminateDate = XsdUtils.getLocalTime(terminateAtStr);
+ setTerminateAt(terminateDate);
+ }
+ catch (ParseException e)
+ {
+ throw new RuntimeException(_MESSAGES.get("ParseDateError", new Object[] {terminateAtStr}));
+ }
+ }
+ }
+ }
+
+ public Date getCurrentTime()
+ {
+ return _currentTime;
+ }
+
+ public void setCurrentTime(Date currentTime)
+ {
+ _currentTime = currentTime;
+ }
+
+ public long getTerminateAfter()
+ {
+ return _terminateAfter;
+ }
+
+ public void setTerminateAfter(long terminateAfter)
+ {
+ _terminateAfter = terminateAfter;
+ }
+
+ public long getTerminateAfterIdle()
+ {
+ return _terminateAfterIdle;
+ }
+
+ public void setTerminateAfterIdle(long terminateAfterIdle)
+ {
+ _terminateAfterIdle = terminateAfterIdle;
+ }
+
+ public Date getTerminateAt()
+ {
+ return _terminateAt;
+ }
+
+ public void setTerminateAt(Date terminateAt)
+ {
+ _terminateAt = terminateAt;
+ }
+
+ public Element toXML()
+ {
+ return toXML(XmlUtils.EMPTY_DOC);
+ }
+
+ public Element toXML(Document factory)
+ {
+ Element ltXML = XmlUtils.createElement(factory, WsrtConstants.WSRT_LIFETIME_QNAME);
+
+ if (_terminateAt != null)
+ {
+ Element termAtXML = XmlUtils.createElement(factory, WsrtConstants.WSRT_TERMINATEAT_QNAME);
+ Node text = factory.createTextNode(XsdUtils.getLocalTimeString(_terminateAt));
+ termAtXML.appendChild(text);
+ ltXML.appendChild(termAtXML);
+ }
+
+ return ltXML;
+ }
+
+}
Modified: webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/SimpleMetadata.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/SimpleMetadata.java?view=diff&rev=522026&r1=522025&r2=522026
==============================================================================
--- webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/SimpleMetadata.java (original)
+++ webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/SimpleMetadata.java Sat Mar 24 06:24:32 2007
@@ -1,83 +1,86 @@
-/*=============================================================================*
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *=============================================================================*/
-
-
-package org.apache.muse.ws.resource.transfer.create.impl;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import org.apache.muse.util.xml.XmlUtils;
-import org.apache.muse.ws.resource.transfer.WsrtConstants;
-import org.apache.muse.ws.resource.transfer.create.InvalidMetadataFault;
-import org.apache.muse.ws.resource.transfer.create.Metadata;
-import org.apache.muse.ws.resource.transfer.create.MetadataSection;
-
-/**
- * This object represents metadata passed into WS-RT create requests
- *
- * @author Mohammad Fakhar
- *
- */
-public class SimpleMetadata implements org.apache.muse.ws.resource.transfer.create.Metadata
-{
- // metadata can have multiple sections
- private MetadataSection[] _sections = null;
-
- public SimpleMetadata()
- {
- //
- // no initialization tasks required
- //
- }
-
- public SimpleMetadata(Element xml) throws InvalidMetadataFault
- {
- Element[] sectionsXML = XmlUtils.getElements(xml, WsrtConstants.METADATA_SECTION_QNAME);
-
- _sections = new SimpleMetadataSection[sectionsXML.length];
-
- for (int i = 0; i < sectionsXML.length; i++)
- {
- _sections[i] = new SimpleMetadataSection(sectionsXML[i]);
- }
- }
-
- public MetadataSection[] getSections()
- {
- return _sections;
- }
-
- public void setSections(MetadataSection[] sections)
- {
- _sections = sections;
- }
-
- public Element toXML()
- {
- return toXML(XmlUtils.EMPTY_DOC);
- }
-
- public Element toXML(Document factory)
- {
- Element metadataXML = XmlUtils.createElement(factory, WsrtConstants.METADATA_QNAME);
-
- for (int i = 0; i < _sections.length; i++)
- metadataXML.appendChild(_sections[i].toXML(factory));
-
- return metadataXML;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.muse.ws.resource.transfer.create.impl;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import org.apache.muse.util.xml.XmlUtils;
+import org.apache.muse.ws.resource.transfer.WsrtConstants;
+import org.apache.muse.ws.resource.transfer.create.InvalidMetadataFault;
+import org.apache.muse.ws.resource.transfer.create.Metadata;
+import org.apache.muse.ws.resource.transfer.create.MetadataSection;
+
+/**
+ * This object represents metadata passed into WS-RT create requests
+ *
+ * @author Mohammad Fakhar
+ *
+ */
+public class SimpleMetadata implements org.apache.muse.ws.resource.transfer.create.Metadata
+{
+ // metadata can have multiple sections
+ private MetadataSection[] _sections = null;
+
+ public SimpleMetadata()
+ {
+ //
+ // no initialization tasks required
+ //
+ }
+
+ public SimpleMetadata(Element xml) throws InvalidMetadataFault
+ {
+ Element[] sectionsXML = XmlUtils.getElements(xml, WsrtConstants.METADATA_SECTION_QNAME);
+
+ _sections = new SimpleMetadataSection[sectionsXML.length];
+
+ for (int i = 0; i < sectionsXML.length; i++)
+ {
+ _sections[i] = new SimpleMetadataSection(sectionsXML[i]);
+ }
+ }
+
+ public MetadataSection[] getSections()
+ {
+ return _sections;
+ }
+
+ public void setSections(MetadataSection[] sections)
+ {
+ _sections = sections;
+ }
+
+ public Element toXML()
+ {
+ return toXML(XmlUtils.EMPTY_DOC);
+ }
+
+ public Element toXML(Document factory)
+ {
+ Element metadataXML = XmlUtils.createElement(factory, WsrtConstants.METADATA_QNAME);
+
+ for (int i = 0; i < _sections.length; i++)
+ metadataXML.appendChild(_sections[i].toXML(factory));
+
+ return metadataXML;
+ }
+}
Modified: webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/SimpleMetadataFactory.java
URL: http://svn.apache.org/viewvc/webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/SimpleMetadataFactory.java?view=diff&rev=522026&r1=522025&r2=522026
==============================================================================
--- webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/SimpleMetadataFactory.java (original)
+++ webservices/muse/trunk/modules/preview/muse-wsrt-impl/src/org/apache/muse/ws/resource/transfer/create/impl/SimpleMetadataFactory.java Sat Mar 24 06:24:32 2007
@@ -1,73 +1,76 @@
-/*=============================================================================*
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *=============================================================================*/
-
-
-package org.apache.muse.ws.resource.transfer.create.impl;
-
-import org.apache.muse.ws.resource.transfer.create.DialectMetadata;
-import org.apache.muse.ws.resource.transfer.create.LifetimeMetadata;
-import org.apache.muse.ws.resource.transfer.create.Metadata;
-import org.apache.muse.ws.resource.transfer.create.MetadataFactory;
-import org.apache.muse.ws.resource.transfer.create.MetadataSection;
-import org.apache.muse.ws.resource.transfer.create.WSRTMetadata;
-
-/**
- *
- * This is a factory class for creating WS-RT metadata. WS-RT specification
- * allows ws-rt specific metadata such as lifetime properties and supported
- * dialect properties to be passed on WS-RT create requests; this factory can be
- * used for creating such metadata on the requests. Wsrt specific metadata is
- * embedded in metadata exchange sections
- *
- * @author Mohammad Fakhar
- */
-public class SimpleMetadataFactory implements MetadataFactory
-{
-
- public MetadataSection createMetadataSection(WSRTMetadata[] wsrtMetadata)
- {
- MetadataSection section = new SimpleMetadataSection();
- section.setWsrtMetadata(wsrtMetadata);
-
- return section;
- }
-
- public WSRTMetadata createWSRTMetadata()
- {
- return new SimpleWSRTMetadata();
- }
-
- public LifetimeMetadata createLifetimeMetadata()
- {
- SimpleLifetimeMetadata ltMD = new SimpleLifetimeMetadata();
- return ltMD;
- }
-
- public Metadata createMetadata(MetadataSection[] sections)
- {
- Metadata metadata = new SimpleMetadata();
- metadata.setSections(sections);
-
- return metadata;
- }
-
- public DialectMetadata createDialectMetadata()
- {
- // dialect metadat not implemented yet
- return null;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.muse.ws.resource.transfer.create.impl;
+
+import org.apache.muse.ws.resource.transfer.create.DialectMetadata;
+import org.apache.muse.ws.resource.transfer.create.LifetimeMetadata;
+import org.apache.muse.ws.resource.transfer.create.Metadata;
+import org.apache.muse.ws.resource.transfer.create.MetadataFactory;
+import org.apache.muse.ws.resource.transfer.create.MetadataSection;
+import org.apache.muse.ws.resource.transfer.create.WSRTMetadata;
+
+/**
+ *
+ * This is a factory class for creating WS-RT metadata. WS-RT specification
+ * allows ws-rt specific metadata such as lifetime properties and supported
+ * dialect properties to be passed on WS-RT create requests; this factory can be
+ * used for creating such metadata on the requests. Wsrt specific metadata is
+ * embedded in metadata exchange sections
+ *
+ * @author Mohammad Fakhar
+ */
+public class SimpleMetadataFactory implements MetadataFactory
+{
+
+ public MetadataSection createMetadataSection(WSRTMetadata[] wsrtMetadata)
+ {
+ MetadataSection section = new SimpleMetadataSection();
+ section.setWsrtMetadata(wsrtMetadata);
+
+ return section;
+ }
+
+ public WSRTMetadata createWSRTMetadata()
+ {
+ return new SimpleWSRTMetadata();
+ }
+
+ public LifetimeMetadata createLifetimeMetadata()
+ {
+ SimpleLifetimeMetadata ltMD = new SimpleLifetimeMetadata();
+ return ltMD;
+ }
+
+ public Metadata createMetadata(MetadataSection[] sections)
+ {
+ Metadata metadata = new SimpleMetadata();
+ metadata.setSections(sections);
+
+ return metadata;
+ }
+
+ public DialectMetadata createDialectMetadata()
+ {
+ // dialect metadat not implemented yet
+ return null;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: muse-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-commits-help@ws.apache.org