You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by sa...@apache.org on 2008/03/04 15:31:52 UTC
svn commit: r633485 [7/7] - in /webservices/axis2/trunk/java/modules:
integration/test-resources/ integration/test-resources/ComplexDataTypes/
integration/test/org/apache/axis2/deployment/
integration/test/org/apache/axis2/engine/ integration/test/org/...
Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicySubject.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicySubject.java?rev=633485&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicySubject.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/PolicySubject.java Tue Mar 4 06:31:32 2008
@@ -0,0 +1,54 @@
+package org.apache.axis2.description;
+
+import java.util.HashMap;
+import java.util.Set;
+
+import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyComponent;
+import org.apache.neethi.PolicyReference;
+/*
+ * 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.
+ */
+public class PolicySubject {
+ private HashMap attachedPolicyComponents = new HashMap();
+
+ public void attachPolicy(Policy policy) {
+ String key = policy.getName();
+ if (key == null) {
+ key = policy.getId();
+ if (key == null) {
+ key = UUIDGenerator.getUUID();
+ policy.setId(key);
+ }
+ }
+ attachPolicyComponent(key, policy);
+ }
+
+ public void attachPolicyReference(PolicyReference reference) {
+ attachedPolicyComponents.put(reference.getURI(), reference);
+ }
+
+ public void attachPolicyComponent(String key, PolicyComponent policyComponent) {
+ attachedPolicyComponents.put(key, policyComponent);
+ }
+
+ public Set getAttachPolicyComponents() {
+ return attachedPolicyComponents.entrySet();
+ }
+}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java?rev=633485&r1=633484&r2=633485&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL11ToAxisServiceBuilder.java Tue Mar 4 06:31:32 2008
@@ -27,6 +27,7 @@
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.addressing.EndpointReferenceHelper;
import org.apache.axis2.addressing.wsdl.WSDL11ActionHelper;
+import org.apache.axis2.description.java2wsdl.Java2WSDLConstants;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.axis2.transport.http.util.RESTUtil;
import org.apache.axis2.util.LoggingControl;
@@ -681,7 +682,7 @@
axisBindingInMessage.setParent(axisBindingOperation);
axisBindingOperation
- .addChild(axisBindingInMessage.getDirection(), axisBindingInMessage);
+ .addChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE, axisBindingInMessage);
}
BindingOutput wsdl4jBindingOutput = wsdl4jBindingOperation.getBindingOutput();
@@ -722,7 +723,7 @@
axisBindingOutMessage.setParent(axisBindingOperation);
axisBindingOperation
- .addChild(axisBindingOutMessage.getDirection(), axisBindingOutMessage);
+ .addChild(WSDLConstants.MESSAGE_LABEL_OUT_VALUE, axisBindingOutMessage);
}
Map bindingFaultsMap = wsdl4jBindingOperation.getBindingFaults();
@@ -2188,19 +2189,21 @@
UnknownExtensibilityElement unknown =
(UnknownExtensibilityElement) (wsdl4jExtensibilityElement);
QName type = unknown.getElementType();
-
+
// <wsp:Policy>
if (WSDLConstants.WSDL11Constants.POLICY.equals(type)) {
if (isTraceEnabled) {
log.trace("copyExtensibleElements:: PolicyElement found " + unknown);
}
Policy policy = (Policy) PolicyUtil.getPolicyComponent(unknown.getElement());
- int attachmentScope =
- getPolicyAttachmentPoint(description, originOfExtensibilityElements);
- if (attachmentScope > -1) {
- description.getPolicyInclude().addPolicyElement(
- attachmentScope, policy);
- }
+ description.getPolicySubject().attachPolicy(policy);
+
+// int attachmentScope =
+// getPolicyAttachmentPoint(description, originOfExtensibilityElements);
+// if (attachmentScope > -1) {
+// description.getPolicyInclude().addPolicyElement(
+// attachmentScope, policy);
+// }
// <wsp:PolicyReference>
} else if (WSDLConstants.WSDL11Constants.POLICY_REFERENCE
.equals(type)) {
@@ -2209,12 +2212,14 @@
}
PolicyReference policyReference = (PolicyReference) PolicyUtil
.getPolicyComponent(unknown.getElement());
- int attachmentScope =
- getPolicyAttachmentPoint(description, originOfExtensibilityElements);
- if (attachmentScope > -1) {
- description.getPolicyInclude().addPolicyRefElement(
- attachmentScope, policyReference);
- }
+ description.getPolicySubject().attachPolicyReference(policyReference);
+
+// int attachmentScope =
+// getPolicyAttachmentPoint(description, originOfExtensibilityElements);
+// if (attachmentScope > -1) {
+// description.getPolicyInclude().addPolicyRefElement(
+// attachmentScope, policyReference);
+// }
} else if (AddressingConstants.Final.WSAW_USING_ADDRESSING
.equals(type)
|| AddressingConstants.Submission.WSAW_USING_ADDRESSING
@@ -2810,8 +2815,9 @@
policy = (Policy) PolicyUtil.getPolicyComponent(unknown.getElement());
String key;
if ((key = policy.getName()) != null || (key = policy.getId()) != null) {
- registry.register(key, policy);
- registry.register("#" + key, policy);
+ axisService.registerPolicy(key, policy);
+// registry.register(key, policy);
+// registry.register("#" + key, policy);
}
}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java?rev=633485&r1=633484&r2=633485&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/WSDL20ToAxisServiceBuilder.java Tue Mar 4 06:31:32 2008
@@ -898,7 +898,7 @@
httpBindingMessageReferenceExtensions.getHttpHeaders()));
axisBindingMessage.setProperty(WSDL2Constants.ATTR_WHTTP_CONTENT_ENCODING,
httpBindingMessageReferenceExtensions.getHttpContentEncoding());
- axisBindingOperation.addChild(axisMessage.getDirection(), axisBindingMessage);
+ axisBindingOperation.addChild(WSDLConstants.MESSAGE_LABEL_IN_VALUE, axisBindingMessage);
}
Added: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyLocator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyLocator.java?rev=633485&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyLocator.java (added)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyLocator.java Tue Mar 4 06:31:32 2008
@@ -0,0 +1,83 @@
+package org.apache.axis2.util;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.dataretrieval.DRConstants;
+import org.apache.axis2.dataretrieval.Data;
+import org.apache.axis2.dataretrieval.DataRetrievalException;
+import org.apache.axis2.dataretrieval.DataRetrievalRequest;
+import org.apache.axis2.description.AxisService;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyEngine;
+import org.apache.neethi.PolicyRegistry;
+
+/*
+ * 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.
+ */
+public class PolicyLocator implements PolicyRegistry {
+
+ private static final Log logger = LogFactory.getLog(PolicyLocator.class);
+
+ private AxisService service;
+
+ public PolicyLocator(AxisService service) {
+ this.service = service;
+ }
+
+ public Policy lookup(String identifier) {
+ Policy policy = service.lookupPolicy(identifier);
+ if (policy == null) {
+ try {
+ MessageContext msgContext = new MessageContext();
+ msgContext.setAxisService(service);
+
+ DataRetrievalRequest request = new DataRetrievalRequest();
+ request.putDialect(DRConstants.SPEC.DIALECT_TYPE_POLICY);
+ request.putIdentifier(identifier);
+
+ Data[] data = service.getData(request, msgContext);
+ if (data.length != 0) {
+ OMElement element = (OMElement) data[0].getData();
+
+ if (element != null) {
+ return PolicyEngine.getPolicy(element);
+ }
+ }
+
+ } catch (DataRetrievalException ex) {
+ logger.error("" + ex);
+ } catch (AxisFault ex) {
+ logger.error("" + ex);
+ }
+ }
+ return policy;
+ }
+
+ public void register(String identifier, Policy policy) {
+ throw new UnsupportedOperationException();
+
+ }
+
+ public void remove(String identifier) {
+ throw new UnsupportedOperationException();
+
+ }
+}
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java?rev=633485&r1=633484&r2=633485&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/PolicyUtil.java Tue Mar 4 06:31:32 2008
@@ -36,9 +36,6 @@
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
@@ -225,6 +222,31 @@
if (policy != null) {
policy = (Policy) policy.normalize(new AxisPolicyLocator(description), false);
+ }
+
+ return policy;
+ }
+
+ public static Policy getMergedPolicy(List policies, AxisService service) {
+
+ Policy policy = null;
+
+ for (Iterator iterator = policies.iterator(); iterator.hasNext(); ) {
+ Object policyElement = iterator.next()
+ ;
+ if (policyElement instanceof Policy) {
+ policy = (policy == null) ? (Policy) policyElement : (Policy) policy.merge((Policy) policyElement);
+
+ } else {
+ PolicyReference policyReference = (PolicyReference) policyElement;
+ Policy policy2 = (Policy) policyReference.normalize(new PolicyLocator(service), false);
+ policy = (policy == null) ? policy2 : (Policy) policy.merge(policy2);
+ }
+ }
+
+
+ if (policy != null) {
+ policy = (Policy) policy.normalize(new PolicyLocator(service), false);
}
return policy;
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org