[wsas-java-dev] svn commit r307 - in wsas/java/trunk: .
modules/core/src/org/wso2/wsas/services/version/META-INF
modules/wsf-common-core
modules/wsf-common-core/src/org/wso2/wsf/common/mex
modules/wsf-common-core/src/org/wso2/wsf/common/transfer
modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module
modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/META-INF
svn at wso2.com
svn at wso2.com
Tue Jan 2 01:54:30 PST 2007
Author: sanka
Date: Tue Jan 2 01:54:30 2007
New Revision: 307
Added:
wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/
wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/
wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/META-INF/
wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/META-INF/module.xml
wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/WSTransferConstants.java
wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/WSTransferHandler.java
wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/WSTransferMessageReceiver.java
wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/WSTransferModule.java
wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/WSTransferUtil.java
Modified:
wsas/java/trunk/maven.xml
wsas/java/trunk/modules/core/src/org/wso2/wsas/services/version/META-INF/services.xml
wsas/java/trunk/modules/wsf-common-core/maven.xml
wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/mex/MetadataConstants.java
wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/mex/MetadataExchangeMessageReceiver.java
wsas/java/trunk/project.xml
Log:
Added the WS-Transfer module.
Modified: wsas/java/trunk/maven.xml
==============================================================================
--- wsas/java/trunk/maven.xml (original)
+++ wsas/java/trunk/maven.xml Tue Jan 2 01:54:30 2007
@@ -966,6 +966,9 @@
<ant:copy
tofile="${dist.temp.dir}/repository/modules/mex-${wso2wsas.version}.mar"
file="modules/wsf-common-core/target/mex-${wso2wsas.version}.mar"/>
+ <ant:copy
+ tofile="${dist.temp.dir}/repository/modules/transfer-${wso2wsas.version}.mar"
+ file="modules/wsf-common-core/target/transfer-${wso2wsas.version}.mar" />
<ant:move toDir="${dist.temp.dir}/repository/modules">
<ant:fileset dir="${dist.temp.dir}/lib">
Modified: wsas/java/trunk/modules/core/src/org/wso2/wsas/services/version/META-INF/services.xml
==============================================================================
--- wsas/java/trunk/modules/core/src/org/wso2/wsas/services/version/META-INF/services.xml (original)
+++ wsas/java/trunk/modules/core/src/org/wso2/wsas/services/version/META-INF/services.xml Tue Jan 2 01:54:30 2007
@@ -6,7 +6,7 @@
This service outputs the version of WSO2 WSAS it is deployed on.
</description>
- <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+ <wsp:Policy Name="urn:version" wsu:Id="urn:version" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<intf:ServicePolicyTestAssertion1 xmlns:intf="http://test.policy.org/wsas" marker="2" />
</wsp:Policy>
Modified: wsas/java/trunk/modules/wsf-common-core/maven.xml
==============================================================================
--- wsas/java/trunk/modules/wsf-common-core/maven.xml (original)
+++ wsas/java/trunk/modules/wsf-common-core/maven.xml Tue Jan 2 01:54:30 2007
@@ -69,6 +69,15 @@
</jar>
<copy file="target/mex-${wso2wsas.version}.mar"
tofile="${maven.repo.local}/org.wso2.wsf/mars/mex-${wso2wsas.version}.mar"/>
+
+ <!-- Transfer module -->
+ <property name="transfer.module.dir" value="target/transfer/module" />
+ <mkdir dir="${transfer.module.dir}/META-INF" />
+ <copy tofile="${transfer.module.dir}/META-INF/module.xml"
+ file="src/org/wso2/wsf/common/transfer/module/META-INF/module.xml" />
+ <jar jarfile="target/transfer-${wso2wsas.version}.mar" basedir="${transfer.module.dir}" />
+ <copy file="target/transfer-${wso2wsas.version}.mar"
+ tofile="${maven.repo.local}/org.wso2.wsf/mars/transfer-${wso2wsas.version}.mar" />
</postGoal>
@@ -88,4 +97,4 @@
</goal>
-</project>
\ No newline at end of file
+</project>
Modified: wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/mex/MetadataConstants.java
==============================================================================
--- wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/mex/MetadataConstants.java (original)
+++ wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/mex/MetadataConstants.java Tue Jan 2 01:54:30 2007
@@ -17,6 +17,9 @@
import javax.xml.namespace.QName;
+/**
+ * Defines the set of Constants for MEX module.
+ */
public class MetadataConstants {
public static final String URI_MEX_NS = "http://schemas.xmlsoap.org/ws/2004/09/mex/";
Modified: wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/mex/MetadataExchangeMessageReceiver.java
==============================================================================
--- wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/mex/MetadataExchangeMessageReceiver.java (original)
+++ wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/mex/MetadataExchangeMessageReceiver.java Tue Jan 2 01:54:30 2007
@@ -29,6 +29,12 @@
import org.wso2.wsf.common.mex.model.MetadataSection;
import org.wso2.wsf.common.mex.util.MetadataUtil;
+/**
+ * MetadataExchangeMessageReceiver processes any incoming WSTransfer requests
+ * for meatadata of for a service that the module is engaged. It also process
+ * any mex:GetMetadata requests and provided the requested metadata.
+ *
+ */
public class MetadataExchangeMessageReceiver extends
AbstractInOutSyncMessageReceiver {
@@ -41,9 +47,22 @@
if (MetadataConstants.URI_MEX_TRANSFER_ACTION.equals(wsaAction)) {
EndpointReference epr = inMsgCtx.getTo();
+ /*
+ * if the EPR ends with 'metadata' we constract the default metadata
+ * response message and send it to the requester.
+ *
+ * i.e. http://localhost:9762/soap/Foo/metadata
+ */
if (epr.getAddress().endsWith("metadata")) {
handleWSTransferMetadataRequest(inMsgCtx, outMsgCtx);
+ /*
+ * if the EPR contains with 'policy' we know that is request to
+ * fetch a specified policy. In that case we send back only that
+ * policy to the requester.
+ *
+ * i.e. http://localhost:9762/soap/Foo/policy/policy-identifier
+ */
} else if (epr.getAddress().indexOf("/policy") > -1) {
handleWSTransferPolicyRequest(inMsgCtx, outMsgCtx);
}
@@ -55,8 +74,10 @@
private void handleWSTransferMetadataRequest(MessageContext inMsgCtx,
MessageContext outMsgCtx) throws AxisFault {
+
String address = inMsgCtx.getTo().getAddress();
SOAPEnvelope inMsgEnvelope = inMsgCtx.getEnvelope();
+
SOAPFactory factory = (SOAPFactory) inMsgEnvelope.getOMFactory();
SOAPEnvelope outMsgEnvelope = factory.getDefaultEnvelope();
@@ -91,9 +112,9 @@
// create the default reponse ..
Metadata metadata = new Metadata();
- MetadataSection metadataSection = MetadataUtil.getMetadataSection(
- MetadataConstants.DIALECT_POLICY, identifier, inMsgCtx,
- factory);
+ MetadataSection metadataSection = MetadataUtil
+ .getMetadataSection(MetadataConstants.DIALECT_POLICY,
+ identifier, inMsgCtx, factory);
if (metadataSection != null) {
metadata.addMetadataSection(metadataSection);
Added: wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/META-INF/module.xml
==============================================================================
--- (empty file)
+++ wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/META-INF/module.xml Tue Jan 2 01:54:30 2007
@@ -0,0 +1,3 @@
+<module name="transfer" class="org.wso2.wsf.common.transfer.module.WSTransferModule">
+ <Description>This module is an implementation of WS-Transfer</Description>
+</module>
\ No newline at end of file
Added: wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/WSTransferConstants.java
==============================================================================
--- (empty file)
+++ wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/WSTransferConstants.java Tue Jan 2 01:54:30 2007
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2001-2004 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.wso2.wsf.common.transfer.module;
+
+public class WSTransferConstants {
+
+ public static final String NS_URI_WXF = "http://schemas.xmlsoap.org/ws/2004/08/transfer";
+
+ public static final String ATTR_WXF = "wxf";
+
+ public static final String ACTION_URI_GET = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Get";
+
+ public static final String ACTION_URI_GET_RESPONSE = "http://schemas.xmlsoap.org/ws/2004/09/transfer/GetResponse";
+
+ public static final String ACTION_URI_PUT = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Put";
+
+ public static final String ACTION_URI_PUT_RESPONSE = "http://schemas.xmlsoap.org/ws/2004/09/transfer/PutResponse";
+
+ public static final String ACTION_URI_DELETE = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Delete";
+
+ public static final String ACTION_URI_DELETE_RESPONSE = "http://schemas.xmlsoap.org/ws/2004/09/transfer/DeleteResponse";
+
+ public static final String ACTION_URI_CREATE = "http://schemas.xmlsoap.org/ws/2004/09/transfer/Create";
+
+ public static final String ACTION_URI_CREATE_RESPONSE = "http://schemas.xmlsoap.org/ws/2004/09/transfer/CreateResponse";
+
+ public static final String FAULT_INVALID_REPRESENTATION = "InvaildRepresentation";
+
+ public static final String INVALID_REPRESENTATION_DETAIL = "InvalidRepresentationDetail";
+
+ public static final String FAULT_INVALID_REPRESENTATION_REASON = "The XML content was invaild";
+
+ public static final String FAULT_INVALID_VALUES = "http://schemas.xmlsoap.org/ws/2005/06/management/faultDetail/InvalidValues";
+
+ public static final String FAULT_MISSING_VALUES = "http://schemas.xmlsoap.org/ws/2005/06/management/faultDetail/MissingValues";
+
+ public static final String FAULT_INVALID_NS = "http://schemas.xmlsoap.org/ws/2005/06/management/faultDetail/InvalidNamespace";
+
+ public static final String FAULT_INVALID_FRAGMENT = "http://schemas.xmlsoap.org/ws/2005/06/management/faultDetail/InvalidFragment";
+
+ public static final String ELEM_MESSAGE_ID = "MessageID";
+
+ public static final String NS_URI_WSMAN = "http://schemas.xmlsoap.org/ws/2005/06/management";
+
+ public static final String FAULT_DATAIL = "FaultDetail";
+
+ public static final String ATTR_WSMA = "wsma";
+
+
+}
Added: wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/WSTransferHandler.java
==============================================================================
--- (empty file)
+++ wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/WSTransferHandler.java Tue Jan 2 01:54:30 2007
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2001-2004 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.wso2.wsf.common.transfer.module;
+
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.handlers.AbstractHandler;
+
+public class WSTransferHandler extends AbstractHandler {
+
+ public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
+ return InvocationResponse.CONTINUE;
+ }
+
+
+}
Added: wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/WSTransferMessageReceiver.java
==============================================================================
--- (empty file)
+++ wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/WSTransferMessageReceiver.java Tue Jan 2 01:54:30 2007
@@ -0,0 +1,220 @@
+/*
+ * Copyright 2001-2004 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.wso2.wsf.common.transfer.module;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
+
+public class WSTransferMessageReceiver extends AbstractInOutSyncMessageReceiver {
+
+ public void invokeBusinessLogic(MessageContext inMessageContext,
+ MessageContext outMessageContext) throws AxisFault {
+
+ Object serviceImplObject = getTheImplementationObject(inMessageContext);
+ Class serviceImplClass = serviceImplObject.getClass();
+
+ AxisService axisService = inMessageContext.getAxisService();
+ AxisOperation axisOperation = inMessageContext.getAxisOperation();
+
+ String methodName = axisOperation.getName().getLocalPart();
+
+ Method method = null;
+
+ try {
+
+ if ("put".equals(methodName)) {
+
+ method = serviceImplClass.getDeclaredMethod(methodName,
+ new Class[] { OMElement.class });
+
+ SOAPBody soapBody = inMessageContext.getEnvelope().getBody();
+ OMElement firstChild = soapBody.getFirstElement();
+
+ if (firstChild == null) {
+ WSTransferUtil.triggerInvalidRepresentationFault(
+ inMessageContext,
+ WSTransferConstants.FAULT_MISSING_VALUES);
+ }
+
+ OMElement resultElement = (OMElement) method.invoke(
+ serviceImplObject, new Object[] { firstChild });
+
+ SOAPEnvelope outSoapEnvelope = getSoapEnvelop(inMessageContext);
+
+ /*
+ * Here we assumes that if the method returns null, then the
+ * resource specified had not been changed during the method
+ * invocation. Therefore we leave the SOAP body empty in the
+ * response message.
+ */
+ if (resultElement != null) {
+ resultElement.declareNamespace(axisService
+ .getTargetNamespace(), axisService
+ .getTargetNamespacePrefix());
+ outSoapEnvelope.getBody().addChild(resultElement);
+ }
+
+ outMessageContext.setEnvelope(outSoapEnvelope);
+
+ } else if ("get".equals(methodName)) {
+
+ String messageId = inMessageContext.getMessageID();
+
+ if (messageId == null) {
+ WSTransferUtil.triggerMessageInfoHeaderRequiredFault(
+ inMessageContext,
+ WSTransferConstants.ELEM_MESSAGE_ID);
+ }
+
+ method = serviceImplClass.getDeclaredMethod(methodName,
+ new Class[] { String.class });
+
+ OMElement resultElement = (OMElement) method.invoke(
+ serviceImplObject, new Object[] { messageId });
+
+ /*
+ * We throw an AxisFault if there is no resource associated with
+ * the Message Id.
+ */
+ if (resultElement == null) {
+ WSTransferUtil.triggerInvalidMessageInfoHeaderFault(
+ inMessageContext,
+ WSTransferConstants.ELEM_MESSAGE_ID);
+ }
+
+ resultElement.declareNamespace(
+ axisService.getTargetNamespace(), axisService
+ .getTargetNamespacePrefix());
+
+ SOAPEnvelope outSoapEnvelope = getSoapEnvelop(inMessageContext);
+
+ outSoapEnvelope.getBody().addChild(resultElement);
+ outMessageContext.setEnvelope(outSoapEnvelope);
+
+ } else if ("delete".equals(methodName)) {
+
+ String messageId = inMessageContext.getMessageID();
+
+ if (messageId == null) {
+ WSTransferUtil.triggerMessageInfoHeaderRequiredFault(
+ outMessageContext,
+ WSTransferConstants.ELEM_MESSAGE_ID);
+ }
+
+ method = serviceImplClass.getDeclaredMethod(methodName,
+ new Class[] { String.class });
+
+ try {
+ Boolean success = (Boolean) method
+ .invoke(serviceImplObject,
+ new Object[] { messageId });
+
+ if (!success.booleanValue()) {
+ // TODO throw a proper Exception
+ throw new AxisFault("Delete operation was unsuccessful");
+ }
+
+ } catch (InvocationTargetException ex) {
+
+ if (ex.getCause() instanceof IllegalArgumentException) {
+ WSTransferUtil.triggerInvalidMessageInfoHeaderFault(
+ inMessageContext,
+ WSTransferConstants.ELEM_MESSAGE_ID);
+ }
+
+ throw ex;
+ }
+
+ SOAPEnvelope outSoapEnvelope = getSoapEnvelop(inMessageContext);
+ outMessageContext.setEnvelope(outSoapEnvelope);
+
+
+ } else if ("create".equals(methodName)) {
+
+ method = serviceImplClass.getDeclaredMethod(methodName,
+ new Class[] { OMElement.class });
+
+ SOAPBody soapBody = inMessageContext.getEnvelope().getBody();
+ OMElement firstChild = soapBody.getFirstElement();
+
+ if (firstChild == null) {
+ WSTransferUtil.triggerInvalidRepresentationFault(
+ inMessageContext, WSTransferConstants.FAULT_MISSING_VALUES);
+ }
+
+ OMElement resultElement = (OMElement) method.invoke(
+ serviceImplObject, new Object[] { firstChild });
+
+ SOAPEnvelope outSoapEnvelope = getSoapEnvelop(inMessageContext);
+
+ /*
+ * Here we assumes that if the method returns null, then the
+ * resource specified has created without any changes to its
+ * initial XML infoset representation.
+ */
+ if (resultElement != null) {
+ resultElement.declareNamespace(axisService
+ .getTargetNamespace(), axisService
+ .getTargetNamespacePrefix());
+ outSoapEnvelope.getBody().addChild(resultElement);
+ }
+
+ outMessageContext.setEnvelope(outSoapEnvelope);
+
+ } else {
+
+ // should never reach this bock
+ throw new AxisFault("should nerver reach this bock");
+ }
+
+ } catch (Exception ex) {
+ handleError(inMessageContext, ex);
+ }
+ }
+
+ private void handleError(MessageContext messageContext, Exception ex)
+ throws AxisFault {
+
+ if (ex instanceof AxisFault) {
+ throw (AxisFault) ex;
+
+ } else if (ex instanceof InvocationTargetException) {
+ Throwable cause = ex.getCause();
+
+ if (cause instanceof IllegalArgumentException) {
+ WSTransferUtil.triggerInvalidRepresentationFault(
+ messageContext, WSTransferConstants.FAULT_INVALID_VALUES);
+ }
+ }
+ throw new AxisFault(ex);
+ }
+
+ private SOAPEnvelope getSoapEnvelop(MessageContext inMessageContext)
+ throws AxisFault {
+ SOAPFactory soapFactory = getSOAPFactory(inMessageContext);
+ return soapFactory.getDefaultEnvelope();
+ }
+}
\ No newline at end of file
Added: wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/WSTransferModule.java
==============================================================================
--- (empty file)
+++ wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/WSTransferModule.java Tue Jan 2 01:54:30 2007
@@ -0,0 +1,185 @@
+/*
+ * Copyright 2001-2004 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.wso2.wsf.common.transfer.module;
+
+import java.lang.reflect.Method;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.description.AxisDescription;
+import org.apache.axis2.description.AxisModule;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.modules.Module;
+import org.apache.neethi.Assertion;
+import org.apache.neethi.Policy;
+
+public class WSTransferModule implements Module {
+
+ private static final String ATTR_SERVICE_CLASS = "ServiceClass";
+
+ private static final String OP_NAME_PUT = "put";
+
+ private static final String OP_NAME_GET = "get";
+
+ private static final String OP_NAME_CREATE = "create";
+
+ private static final String OP_NAME_DELETE = "delete";
+
+ public void init(ConfigurationContext configContext, AxisModule module)
+ throws AxisFault {
+ // TODO Auto-generated method stub
+ }
+
+ public void engageNotify(AxisDescription axisDescription) throws AxisFault {
+
+ if (axisDescription instanceof AxisService) {
+ try {
+
+ AxisService axisService = (AxisService) axisDescription;
+ String implClassName = (String) axisService
+ .getParameterValue(WSTransferModule.ATTR_SERVICE_CLASS);
+
+ ClassLoader classLoader = axisService.getClassLoader();
+ Class implClass = classLoader.loadClass(implClassName);
+
+ processAxisService(axisService, implClass);
+
+ } catch (Exception ex) {
+ throw new AxisFault(ex);
+ }
+ }
+ }
+
+ private void processAxisService(AxisService axisService, Class implClass) {
+ Method[] declaredMethods = implClass.getDeclaredMethods();
+
+ Method method;
+ String methodName;
+
+ Class[] parameterTypes;
+ AxisOperation op;
+
+ for (int i = 0; i < declaredMethods.length; i++) {
+ method = declaredMethods[i];
+ methodName = method.getName();
+
+ if (OP_NAME_GET.equals(methodName)) {
+
+ if (! (org.apache.axiom.om.OMElement.class.equals(method.getReturnType()))) {
+ continue;
+ }
+
+ parameterTypes = method.getParameterTypes();
+
+ if (!(parameterTypes.length == 1
+ && java.lang.String.class.equals(parameterTypes[0]))) {
+ continue;
+ }
+
+ op = axisService.getOperation(new QName(OP_NAME_GET));
+
+ setSoapAction(WSTransferConstants.ACTION_URI_GET, op);
+ op.setOutputAction(WSTransferConstants.ACTION_URI_GET_RESPONSE);
+
+ op.setMessageReceiver(new WSTransferMessageReceiver());
+
+ } else if (OP_NAME_PUT.equals(methodName)) {
+
+ if (! (org.apache.axiom.om.OMElement.class.equals(method.getReturnType()))) {
+ continue;
+ }
+
+ parameterTypes = method.getParameterTypes();
+
+ if (!(parameterTypes.length == 1 && org.apache.axiom.om.OMElement.class.equals(parameterTypes[0]))) {
+ continue;
+ }
+
+ op = axisService.getOperation(new QName(OP_NAME_PUT));
+
+ setSoapAction(WSTransferConstants.ACTION_URI_PUT, op);
+ op.setOutputAction(WSTransferConstants.ACTION_URI_PUT_RESPONSE);
+
+ op.setMessageReceiver(new WSTransferMessageReceiver());
+
+ } else if (OP_NAME_DELETE.equals(methodName)) {
+
+ if (! (Boolean.TYPE.equals(method.getReturnType()))) {
+ continue;
+ }
+
+ parameterTypes = method.getParameterTypes();
+
+ if (!(parameterTypes.length == 1 && java.lang.String.class.equals(parameterTypes[0]))) {
+ continue;
+ }
+
+ op = axisService.getOperation(new QName(OP_NAME_DELETE));
+
+ setSoapAction(WSTransferConstants.ACTION_URI_DELETE, op);
+ op.setOutputAction(WSTransferConstants.ACTION_URI_DELETE_RESPONSE);
+
+ op.setMessageReceiver(new WSTransferMessageReceiver());
+
+ } else if (OP_NAME_CREATE.equals(methodName)) {
+
+ if (! (OMElement.class.equals(method.getReturnType()))) {
+ continue;
+ }
+
+ parameterTypes = method.getParameterTypes();
+
+ if (!(parameterTypes.length == 1 && OMElement.class.equals(parameterTypes[0]))) {
+ continue;
+ }
+
+ op = axisService.getOperation(new QName(OP_NAME_CREATE));
+
+ setSoapAction(WSTransferConstants.ACTION_URI_CREATE, op);
+ op.setOutputAction(WSTransferConstants.ACTION_URI_CREATE_RESPONSE);
+
+ op.setMessageReceiver(new WSTransferMessageReceiver());
+ }
+ }
+ }
+
+ public boolean canSupportAssertion(Assertion assertion) {
+ return false;
+ }
+
+ public void applyPolicy(Policy policy, AxisDescription axisDescription)
+ throws AxisFault {
+ }
+
+ public void shutdown(ConfigurationContext configurationContext)
+ throws AxisFault {
+ }
+
+ private void setSoapAction(String soapAction, AxisOperation op) {
+ AxisService service = (AxisService) op.getParent();
+ String oldSoapAction = op.getInputAction();
+
+ // effectively removing the old mapping
+ service.mapActionToOperation(oldSoapAction, null);
+
+ op.setSoapAction(soapAction);
+ service.mapActionToOperation(soapAction, op);
+ }
+}
Added: wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/WSTransferUtil.java
==============================================================================
--- (empty file)
+++ wsas/java/trunk/modules/wsf-common-core/src/org/wso2/wsf/common/transfer/module/WSTransferUtil.java Tue Jan 2 01:54:30 2007
@@ -0,0 +1,137 @@
+/*
+ * Copyright 2001-2004 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.wso2.wsf.common.transfer.module;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.soap.SOAP12Constants;
+import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPFaultCode;
+import org.apache.axiom.soap.SOAPFaultDetail;
+import org.apache.axiom.soap.SOAPFaultSubCode;
+import org.apache.axiom.soap.SOAPFaultValue;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingFaultsHelper;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.context.OperationContext;
+
+public class WSTransferUtil {
+
+ public static void triggerMessageInfoHeaderRequiredFault(
+ MessageContext messageContext, String missingHeaderName)
+ throws AxisFault {
+
+ AddressingFaultsHelper.triggerMessageAddressingRequiredFault(
+ messageContext, missingHeaderName);
+ }
+
+ public static void triggerInvalidMessageInfoHeaderFault(
+ MessageContext messageContext, String invalidHeader) throws AxisFault {
+
+ AddressingFaultsHelper.triggerInvalidCardinalityFault(messageContext, invalidHeader);
+ }
+
+ public static void triggerInvalidRepresentationFault(MessageContext messageContext,
+ String detail) throws AxisFault {
+
+ QName faultCode = new QName(
+ SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI,
+ SOAP12Constants.FAULT_CODE_SENDER,
+ SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX);
+
+ QName faultSubcode = new QName(WSTransferConstants.NS_URI_WXF,
+ WSTransferConstants.FAULT_INVALID_REPRESENTATION,
+ WSTransferConstants.ATTR_WXF);
+
+ if (!messageContext.isSOAP11()) {
+ SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
+ SOAPFaultDetail soapFaultDetail = factory.createSOAPFaultDetail();
+
+ OMElement faultDetailElement = factory.createOMElement(WSTransferConstants.FAULT_DATAIL, WSTransferConstants.NS_URI_WSMAN,WSTransferConstants.ATTR_WSMA);
+ faultDetailElement.setText(detail);
+
+ soapFaultDetail.addChild(faultDetailElement);
+ messageContext.setProperty(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME, soapFaultDetail);
+ }
+
+ triggerAxisFault(messageContext, WSTransferConstants.INVALID_REPRESENTATION_DETAIL, detail , faultCode, faultSubcode, WSTransferConstants.FAULT_INVALID_REPRESENTATION_REASON);
+
+ }
+
+
+ public static void triggerAxisFault(MessageContext msgCtx,
+ String faultInfoKey, String faultInfoValue, QName faultCode,
+ QName faultSubcode, String faultReason) throws AxisFault {
+
+ if (faultInfoKey != null) {
+
+ Map faultInfoForHeaders = (Map) msgCtx
+ .getProperty(Constants.FAULT_INFORMATION_FOR_HEADERS);
+
+ if (faultInfoForHeaders == null) {
+ faultInfoForHeaders = new HashMap();
+ msgCtx.setProperty(Constants.FAULT_INFORMATION_FOR_HEADERS,
+ faultInfoForHeaders);
+ }
+
+ faultInfoForHeaders.put(faultInfoKey, faultInfoValue);
+ }
+ /*
+ *
+ */
+ if (!msgCtx.isSOAP11()) {
+ setFaultCodeForSOAP12(msgCtx, faultCode, faultSubcode);
+ }
+
+ OperationContext opCtx = msgCtx.getOperationContext();
+
+ opCtx.setProperty(
+ Constants.Configuration.SEND_STACKTRACE_DETAILS_WITH_FAULTS,
+ Boolean.FALSE);
+
+ throw new AxisFault(faultReason, faultSubcode);
+ }
+
+ private static void setFaultCodeForSOAP12(MessageContext msgContext,
+ QName faultCode, QName faultSubcode) throws AxisFault {
+
+ SOAPFactory factory = OMAbstractFactory.getSOAP12Factory();
+
+ SOAPFaultCode soapFaultCode = factory.createSOAPFaultCode();
+ SOAPFaultValue soapFaultValue = factory.createSOAPFaultValue(soapFaultCode);
+
+ soapFaultValue.setText(faultCode.getPrefix() + ":"
+ + faultCode.getLocalPart());
+
+ SOAPFaultSubCode soapFaultSubCode = factory
+ .createSOAPFaultSubCode(soapFaultCode);
+ SOAPFaultValue soapFaultSubCodeValue = factory
+ .createSOAPFaultValue(soapFaultSubCode);
+
+ soapFaultSubCodeValue.setText(faultSubcode.getPrefix() + ":"
+ + faultSubcode.getLocalPart());
+
+ msgContext.setProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME,
+ soapFaultCode);
+
+ }
+}
Modified: wsas/java/trunk/project.xml
==============================================================================
--- wsas/java/trunk/project.xml (original)
+++ wsas/java/trunk/project.xml Tue Jan 2 01:54:30 2007
@@ -269,6 +269,11 @@
<artifactId>axis2-spring</artifactId>
<version>${axis2.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.axis2</groupId>
+ <artifactId>axis2-addressing</artifactId>
+ <version>${axis2.version}</version>
+ </dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
More information about the Wsas-java-dev
mailing list