You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by dk...@apache.org on 2011/02/12 03:24:09 UTC
svn commit: r1070012 - in /webservices/commons/trunk/modules/neethi/src:
main/java/org/apache/neethi/ main/java/org/apache/neethi/builders/
main/java/org/apache/neethi/builders/converters/
main/java/org/apache/neethi/builders/xml/ main/java/org/apache/...
Author: dkulp
Date: Sat Feb 12 02:24:08 2011
New Revision: 1070012
URL: http://svn.apache.org/viewvc?rev=1070012&view=rev
Log:
Code cleanup, formatting, import cleanup, etc...
Modified:
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AbstractPolicyOperator.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/All.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Assertion.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AssertionBuilderFactory.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Constants.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/ExactlyOne.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Policy.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyComponent.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyOperator.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyReference.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyRegistry.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyRegistryImpl.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/AssertionBuilder.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/PolicyContainingPrimitiveAssertion.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/PrimitiveAssertion.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/AbstractDOMConverter.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/AbstractOMConverter.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/ConverterRegistry.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/DOMToDOMConverter.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/DOMToOMConverter.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/DOMToStaxConverter.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/OMToDOMConverter.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/OMToOMConverter.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/OMToStaxConverter.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/StaxToDOMConverter.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/xml/XMLPrimitiveAssertionBuilder.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/xml/XmlPrimitiveAssertion.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/PolicyComparator.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/PolicyIntersector.java
webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/Service.java
webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/IntersectTest.java
webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/MergeTest.java
webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/Normalize2Test.java
webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/NormalizeTest.java
webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/PolicyTestCase.java
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AbstractPolicyOperator.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AbstractPolicyOperator.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AbstractPolicyOperator.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AbstractPolicyOperator.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -84,11 +84,12 @@ public abstract class AbstractPolicyOper
}
- result.addPolicyComponent(normalizeOperator(policy,reg, deep));
+ result.addPolicyComponent(normalizeOperator(policy, reg, deep));
return result;
}
- private static PolicyComponent normalizeOperator(PolicyOperator operator, PolicyRegistry reg, boolean deep) {
+ private static PolicyComponent normalizeOperator(PolicyOperator operator,
+ PolicyRegistry reg, boolean deep) {
short type = operator.getType();
@@ -139,7 +140,8 @@ public abstract class AbstractPolicyOper
childComponentsList.add(AbstractPolicyOperator.normalizeOperator(all, reg, deep));
} else {
- childComponentsList.add(AbstractPolicyOperator.normalizeOperator((PolicyOperator) policyComponent, reg, deep));
+ childComponentsList.add(AbstractPolicyOperator
+ .normalizeOperator((PolicyOperator)policyComponent, reg, deep));
}
}
@@ -171,7 +173,8 @@ public abstract class AbstractPolicyOper
for (; iter.hasNext();) {
currentExactlyOne = (ExactlyOne) iter.next();
if (currentExactlyOne.isEmpty()) {
- // if this is empty, this is an not admissible policy and total result is equivalent to that
+ // if this is empty, this is an not admissible policy and total
+ // result is equivalent to that
exactlyOne = currentExactlyOne;
break;
} else {
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/All.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/All.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/All.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/All.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -19,7 +19,6 @@
package org.apache.neethi;
-import java.util.Iterator;
import java.util.List;
import javax.xml.stream.XMLStreamException;
@@ -68,7 +67,7 @@ public class All extends AbstractPolicyO
writer.writeStartElement(namespace, Constants.ELEM_ALL);
}
- for (PolicyComponent policyComponent : getPolicyComponents()){
+ for (PolicyComponent policyComponent : getPolicyComponents()) {
policyComponent.serialize(writer);
}
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Assertion.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Assertion.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Assertion.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Assertion.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -35,14 +35,14 @@ public interface Assertion extends Polic
*
* @return QName the QName of the Root Element of this Assertion.
*/
- public QName getName();
+ QName getName();
/**
* Returns true if this Assertion is optional. Returns false otherwise.
*
* @return true if the assertion is optional.
*/
- public boolean isOptional();
+ boolean isOptional();
/**
@@ -50,15 +50,15 @@ public interface Assertion extends Polic
*
* @return true if the assertion is ignorable.
*/
- public boolean isIgnorable();
+ boolean isIgnorable();
/**
* Serialize this Assertion into its XML infoset using XMLStreamWriter.
*/
- public void serialize(XMLStreamWriter writer) throws XMLStreamException;
+ void serialize(XMLStreamWriter writer) throws XMLStreamException;
/**
* Returns a new PolicyComponent that is the normalized version of this.
*/
- public PolicyComponent normalize();
+ PolicyComponent normalize();
}
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AssertionBuilderFactory.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AssertionBuilderFactory.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AssertionBuilderFactory.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/AssertionBuilderFactory.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -19,25 +19,14 @@
package org.apache.neethi;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
import javax.xml.namespace.QName;
import org.apache.neethi.builders.AssertionBuilder;
-import org.apache.neethi.builders.converters.Converter;
import org.apache.neethi.builders.converters.ConverterRegistry;
-import org.apache.neethi.builders.converters.DOMToDOMConverter;
-import org.apache.neethi.builders.converters.DOMToStaxConverter;
-import org.apache.neethi.builders.converters.StaxToDOMConverter;
-import org.apache.neethi.builders.converters.StaxToStaxConverter;
import org.apache.neethi.builders.xml.XMLPrimitiveAssertionBuilder;
import org.apache.neethi.util.Service;
@@ -57,7 +46,8 @@ public class AssertionBuilderFactory {
public static final String ALL = "All";
- private Map<QName, AssertionBuilder> registeredBuilders = new ConcurrentHashMap<QName, AssertionBuilder>();
+ private Map<QName, AssertionBuilder> registeredBuilders
+ = new ConcurrentHashMap<QName, AssertionBuilder>();
private AssertionBuilder defaultBuilder;
private final ConverterRegistry converters;
private final PolicyEngine engine;
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Constants.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Constants.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Constants.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Constants.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -28,7 +28,7 @@ import javax.xml.stream.XMLStreamWriter;
* framework.
*
*/
-public class Constants {
+public final class Constants {
public static final String ATTR_NAME = "Name";
@@ -43,7 +43,8 @@ public class Constants {
public static final String URI_POLICY_NS = "http://schemas.xmlsoap.org/ws/2004/09/policy";
public static final String URI_POLICY_15_NS = "http://www.w3.org/ns/ws-policy";
- public static final String URI_WSU_NS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
+ public static final String URI_WSU_NS
+ = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd";
public static final String ELEM_POLICY = "Policy";
@@ -80,6 +81,10 @@ public class Constants {
public static final QName Q_ELEM_IGNORABLE_15_ATTR
= new QName(Constants.URI_POLICY_15_NS, "Ignorable", Constants.ATTR_WSP);
+ private Constants() {
+ //utility class, never constructed
+ }
+
public static boolean isInPolicyNS(QName q) {
String ns = q.getNamespaceURI();
return URI_POLICY_NS.equals(ns)
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/ExactlyOne.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/ExactlyOne.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/ExactlyOne.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/ExactlyOne.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Policy.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Policy.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Policy.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/Policy.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -231,7 +231,7 @@ public class Policy extends All {
}
private class PolicyIterator implements Iterator<List<PolicyComponent>> {
- Iterator<PolicyComponent> alternatives = null;
+ Iterator<PolicyComponent> alternatives;
public PolicyIterator(Policy policy, PolicyRegistry reg) {
policy = policy.normalize(reg, false);
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyComponent.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyComponent.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyComponent.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyComponent.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -34,7 +34,7 @@ public interface PolicyComponent {
* @throws XMLStreamException if an errors in the process of serialization of the
* PolicyComponent.
*/
- public void serialize(XMLStreamWriter writer) throws XMLStreamException;
+ void serialize(XMLStreamWriter writer) throws XMLStreamException;
/**
* Returns a short value which uniquely identify the type of the
@@ -45,7 +45,7 @@ public interface PolicyComponent {
* Constants.TYPE_ALL for All type PolicyComponent
* Constants.TYPE_ASSERTION for Assertion type PolicyComponent
*/
- public short getType();
+ short getType();
/**
* Returns true if the argument is equal to self.
@@ -54,5 +54,5 @@ public interface PolicyComponent {
* logically equal or not
* @return true if the argument is equal to self.
*/
- public boolean equal(PolicyComponent policyComponent);
+ boolean equal(PolicyComponent policyComponent);
}
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyEngine.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -19,18 +19,20 @@
package org.apache.neethi;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.neethi.builders.AssertionBuilder;
-import org.apache.neethi.builders.converters.ConverterRegistry;
-import org.w3c.dom.Element;
-import javax.xml.namespace.QName;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamReader;
import java.io.InputStream;
import java.util.Iterator;
import java.util.Map;
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamReader;
+
+import org.w3c.dom.Element;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.neethi.builders.AssertionBuilder;
+import org.apache.neethi.builders.converters.ConverterRegistry;
/**
* PolicyEngine provides set of methods to create a Policy object from an
@@ -41,7 +43,7 @@ import java.util.Map;
*/
public class PolicyEngine {
- private static final Log log = LogFactory.getLog(PolicyEngine.class);
+ private static final Log LOG = LogFactory.getLog(PolicyEngine.class);
private ConverterRegistry converters = new ConverterRegistry();
private AssertionBuilderFactory factory = new AssertionBuilderFactory(this, converters);
@@ -195,8 +197,8 @@ public class PolicyEngine {
if (childElement == null || qn == null
|| qn.getNamespaceURI() == null) {
- if (log.isDebugEnabled()) {
- log.debug("Skipping bad policy element " + childElement);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Skipping bad policy element " + childElement);
}
} else if (Constants.isInPolicyNS(qn)) {
if (Constants.ELEM_POLICY.equals(qn.getLocalPart())) {
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyOperator.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyOperator.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyOperator.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyOperator.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -34,19 +34,19 @@ public interface PolicyOperator extends
*
* @param component
*/
- public void addPolicyComponent(PolicyComponent component);
+ void addPolicyComponent(PolicyComponent component);
/**
* Returns a List of PolicyComponents which this PolicyOperator contains.
*
* @return the List of PolicyComponents that this PolicyOperator contains.
*/
- public List<PolicyComponent> getPolicyComponents();
+ List<PolicyComponent> getPolicyComponents();
/**
* Returns true if the PolicyOperator doesn't contain any PolicyComponents.
*
* @return true if this PolicyOperator doesn't contain any PolicyComponenets
*/
- public boolean isEmpty();
+ boolean isEmpty();
}
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyReference.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyReference.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyReference.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyReference.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -19,18 +19,13 @@
package org.apache.neethi;
-import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
-import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
/**
@@ -41,10 +36,10 @@ public class PolicyReference implements
private String uri;
private PolicyEngine engine;
- public PolicyReference(){
+ public PolicyReference() {
}
- public PolicyReference(PolicyEngine p){
+ public PolicyReference(PolicyEngine p) {
engine = p;
}
@@ -52,8 +47,8 @@ public class PolicyReference implements
* Sets the Policy URI
* @param uri the Policy URI
*/
- public void setURI(String uri) {
- this.uri = uri;
+ public void setURI(String ur) {
+ this.uri = ur;
}
/**
@@ -69,9 +64,9 @@ public class PolicyReference implements
return false;
}
- String URI = ((PolicyReference) policyComponent).getURI();
- if (URI != null && URI.length() != 0) {
- return URI.equals(this.uri);
+ String u = ((PolicyReference)policyComponent).getURI();
+ if (u != null && u.length() != 0) {
+ return u.equals(this.uri);
}
return false;
@@ -108,8 +103,8 @@ public class PolicyReference implements
int pos = key.indexOf("#");
if (pos == 0) {
key = key.substring(1);
- }else if(pos > 0){
- key = key.substring(0, pos);
+ } else if (pos > 0) {
+ key = key.substring(0, pos);
}
Policy policy = reg.lookup(key);
@@ -117,8 +112,8 @@ public class PolicyReference implements
if (policy == null) {
policy = getRemoteReferencedPolicy(key);
- if (policy == null){
- throw new RuntimeException(key + " can't be resolved" );
+ if (policy == null) {
+ throw new RuntimeException(key + " can't be resolved");
}
reg.register(key, policy);
}
@@ -142,27 +137,27 @@ public class PolicyReference implements
writer.writeEndElement();
}
- public Policy getRemoteReferencedPolicy(String uri) {
- try {
- //create java.net URL pointing to remote resource
- URL url = new URL(uri);
- URLConnection connection = url.openConnection();
- connection.setDoInput(true);
-
- InputStream in = connection.getInputStream();
- try {
- PolicyEngine pe = engine;
- if (pe == null) {
- pe = new PolicyEngine();
- }
- return pe.getPolicy(connection.getInputStream());
- } finally {
- in.close();
- }
- } catch(MalformedURLException mue) {
- throw new RuntimeException("Malformed uri: " + uri);
- } catch(IOException ioe) {
- throw new RuntimeException("Cannot reach remote resource: " + uri);
- }
+ public Policy getRemoteReferencedPolicy(String u) {
+ try {
+ //create java.net URL pointing to remote resource
+ URL url = new URL(u);
+ URLConnection connection = url.openConnection();
+ connection.setDoInput(true);
+
+ InputStream in = connection.getInputStream();
+ try {
+ PolicyEngine pe = engine;
+ if (pe == null) {
+ pe = new PolicyEngine();
+ }
+ return pe.getPolicy(connection.getInputStream());
+ } finally {
+ in.close();
+ }
+ } catch (MalformedURLException mue) {
+ throw new RuntimeException("Malformed uri: " + u);
+ } catch (IOException ioe) {
+ throw new RuntimeException("Cannot reach remote resource: " + u);
+ }
}
}
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyRegistry.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyRegistry.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyRegistry.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyRegistry.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -34,7 +34,7 @@ public interface PolicyRegistry {
* @param policy
* the policy to be associated with the key
*/
- public void register(String key, Policy policy);
+ void register(String key, Policy policy);
/**
* Returns the Policy that the specified key is mapped. Returns null if no
@@ -44,7 +44,7 @@ public interface PolicyRegistry {
* the key whose associated Policy is to be returned.
* @return the policy associated with the specified key.
*/
- public Policy lookup(String key);
+ Policy lookup(String key);
/**
* Removes the mapping for this key if present.
@@ -52,6 +52,6 @@ public interface PolicyRegistry {
* @param key
* the key whose mapping is to be removed
*/
- public void remove(String key);
+ void remove(String key);
}
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyRegistryImpl.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyRegistryImpl.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyRegistryImpl.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/PolicyRegistryImpl.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -27,7 +27,7 @@ import java.util.concurrent.ConcurrentHa
*/
public class PolicyRegistryImpl implements PolicyRegistry {
- private PolicyRegistry parent = null;
+ private PolicyRegistry parent;
private Map<String, Policy> reg = new ConcurrentHashMap<String, Policy>();
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/AssertionBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/AssertionBuilder.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/AssertionBuilder.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/AssertionBuilder.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -55,7 +55,7 @@ public interface AssertionBuilder<T> {
* if the given element is malformed
*/
Assertion build(T element, AssertionBuilderFactory factory)
- throws IllegalArgumentException;
+ throws IllegalArgumentException;
/**
* Returns an array of QNames of elements from which assertion can be
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/PolicyContainingPrimitiveAssertion.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/PolicyContainingPrimitiveAssertion.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/PolicyContainingPrimitiveAssertion.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/PolicyContainingPrimitiveAssertion.java Sat Feb 12 02:24:08 2011
@@ -20,18 +20,13 @@
package org.apache.neethi.builders;
-import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-import java.util.ResourceBundle;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
import org.apache.neethi.All;
import org.apache.neethi.Assertion;
import org.apache.neethi.Constants;
@@ -39,7 +34,6 @@ import org.apache.neethi.ExactlyOne;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyComponent;
import org.apache.neethi.PolicyContainingAssertion;
-import org.apache.neethi.PolicyOperator;
import org.apache.neethi.util.PolicyIntersector;
/**
@@ -47,7 +41,10 @@ import org.apache.neethi.util.PolicyInte
* of type Policy (as does for examples the wsam:Addressing assertion).
*
*/
-public class PolicyContainingPrimitiveAssertion extends PrimitiveAssertion implements PolicyContainingAssertion {
+public class PolicyContainingPrimitiveAssertion
+ extends PrimitiveAssertion
+ implements PolicyContainingAssertion {
+
private Policy nested;
public PolicyContainingPrimitiveAssertion(QName name, boolean optional, boolean ignorable, Policy p) {
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/PrimitiveAssertion.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/PrimitiveAssertion.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/PrimitiveAssertion.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/PrimitiveAssertion.java Sat Feb 12 02:24:08 2011
@@ -20,8 +20,6 @@
package org.apache.neethi.builders;
-import java.util.Collection;
-
import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/AbstractDOMConverter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/AbstractDOMConverter.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/AbstractDOMConverter.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/AbstractDOMConverter.java Sat Feb 12 02:24:08 2011
@@ -26,10 +26,6 @@ import java.util.List;
import java.util.Map;
import javax.xml.namespace.QName;
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.transform.dom.DOMSource;
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
@@ -50,7 +46,7 @@ public abstract class AbstractDOMConvert
public Map<QName, String> getAttributes(Element s) {
Map<QName, String> mp = new HashMap<QName, String>();
NamedNodeMap attrs = s.getAttributes();
- for (int x = 0 ; x < attrs.getLength(); x++) {
+ for (int x = 0; x < attrs.getLength(); x++) {
Attr attr = (Attr)attrs.item(x);
mp.put(new QName(attr.getNamespaceURI(), attr.getLocalName()), attr.getValue());
}
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/AbstractOMConverter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/AbstractOMConverter.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/AbstractOMConverter.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/AbstractOMConverter.java Sat Feb 12 02:24:08 2011
@@ -25,12 +25,8 @@ import java.util.Map;
import javax.xml.namespace.QName;
-import org.w3c.dom.Element;
-
import org.apache.axiom.om.OMAttribute;
import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
/**
*
@@ -50,7 +46,7 @@ public abstract class AbstractOMConverte
attr.getAttributeValue());
} else {
mp.put(new QName(attr.getNamespace().getNamespaceURI(), attr.getLocalName()),
- attr.getAttributeValue());
+ attr.getAttributeValue());
}
}
return mp;
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/ConverterRegistry.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/ConverterRegistry.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/ConverterRegistry.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/ConverterRegistry.java Sat Feb 12 02:24:08 2011
@@ -37,9 +37,9 @@ import javax.xml.namespace.QName;
*/
public class ConverterRegistry {
private static class ConverterKey {
- public Class<?> src;
- public Class<?> target;
- public Converter converter;
+ Class<?> src;
+ Class<?> target;
+ Converter converter;
}
private List<ConverterKey> registeredConverters = new CopyOnWriteArrayList<ConverterKey>();
@@ -61,7 +61,8 @@ public class ConverterRegistry {
private void registerConverter(String name) {
try {
- Converter c = (Converter)Class.forName(name, true, Converter.class.getClassLoader()).newInstance();
+ Converter c = (Converter)Class.forName(name, true,
+ Converter.class.getClassLoader()).newInstance();
registerConverter(c);
} catch (Throwable e) {
//likely due to Axiom not available, we're OK with that. There
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/DOMToDOMConverter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/DOMToDOMConverter.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/DOMToDOMConverter.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/DOMToDOMConverter.java Sat Feb 12 02:24:08 2011
@@ -19,18 +19,7 @@
package org.apache.neethi.builders.converters;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.transform.dom.DOMSource;
-
-import org.w3c.dom.Attr;
import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
/**
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/DOMToOMConverter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/DOMToOMConverter.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/DOMToOMConverter.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/DOMToOMConverter.java Sat Feb 12 02:24:08 2011
@@ -19,9 +19,6 @@
package org.apache.neethi.builders.converters;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
import javax.xml.stream.FactoryConfigurationError;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/DOMToStaxConverter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/DOMToStaxConverter.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/DOMToStaxConverter.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/DOMToStaxConverter.java Sat Feb 12 02:24:08 2011
@@ -19,9 +19,7 @@
package org.apache.neethi.builders.converters;
-import javax.xml.stream.FactoryConfigurationError;
import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.transform.dom.DOMSource;
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/OMToDOMConverter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/OMToDOMConverter.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/OMToDOMConverter.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/OMToDOMConverter.java Sat Feb 12 02:24:08 2011
@@ -19,8 +19,6 @@
package org.apache.neethi.builders.converters;
-import javax.xml.namespace.QName;
-
import org.w3c.dom.Element;
import org.apache.axiom.om.OMElement;
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/OMToOMConverter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/OMToOMConverter.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/OMToOMConverter.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/OMToOMConverter.java Sat Feb 12 02:24:08 2011
@@ -19,11 +19,8 @@
package org.apache.neethi.builders.converters;
-import javax.xml.namespace.QName;
import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
/**
*
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/OMToStaxConverter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/OMToStaxConverter.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/OMToStaxConverter.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/OMToStaxConverter.java Sat Feb 12 02:24:08 2011
@@ -19,14 +19,10 @@
package org.apache.neethi.builders.converters;
-import javax.xml.namespace.QName;
import javax.xml.stream.XMLStreamReader;
-import org.w3c.dom.Element;
import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
/**
*
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/StaxToDOMConverter.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/StaxToDOMConverter.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/StaxToDOMConverter.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/converters/StaxToDOMConverter.java Sat Feb 12 02:24:08 2011
@@ -22,7 +22,6 @@ package org.apache.neethi.builders.conve
import java.util.Stack;
import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/xml/XMLPrimitiveAssertionBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/xml/XMLPrimitiveAssertionBuilder.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/xml/XMLPrimitiveAssertionBuilder.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/xml/XMLPrimitiveAssertionBuilder.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -19,8 +19,6 @@
package org.apache.neethi.builders.xml;
-import java.util.Iterator;
-
import javax.xml.namespace.QName;
import org.w3c.dom.Attr;
@@ -30,8 +28,6 @@ import org.w3c.dom.Node;
import org.apache.neethi.Assertion;
import org.apache.neethi.AssertionBuilderFactory;
import org.apache.neethi.Constants;
-import org.apache.neethi.Policy;
-import org.apache.neethi.PolicyEngine;
import org.apache.neethi.builders.AssertionBuilder;
import org.apache.neethi.builders.PolicyContainingPrimitiveAssertion;
import org.apache.neethi.builders.PrimitiveAssertion;
@@ -39,7 +35,8 @@ import org.apache.neethi.builders.Primit
public class XMLPrimitiveAssertionBuilder implements AssertionBuilder<Element> {
public Assertion build(Element element, AssertionBuilderFactory factory)
- throws IllegalArgumentException {
+ throws IllegalArgumentException {
+
Node nd = element.getFirstChild();
int count = 0;
int policyCount = 0;
@@ -60,7 +57,8 @@ public class XMLPrimitiveAssertionBuilde
isOptional(element), isIgnorable(element));
} else if (policyCount == 1 && count == 1) {
- return new PolicyContainingPrimitiveAssertion(new QName(element.getNamespaceURI(), element.getLocalName()),
+ return new PolicyContainingPrimitiveAssertion(new QName(element.getNamespaceURI(),
+ element.getLocalName()),
isOptional(element), isIgnorable(element),
factory.getPolicyEngine().getPolicy(policyEl));
}
@@ -81,7 +79,7 @@ public class XMLPrimitiveAssertionBuilde
}
public QName[] getKnownElements() {
- return new QName[] { new QName("UnknownElement") };
+ return new QName[] {new QName("UnknownElement")};
}
}
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/xml/XmlPrimitiveAssertion.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/xml/XmlPrimitiveAssertion.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/xml/XmlPrimitiveAssertion.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/builders/xml/XmlPrimitiveAssertion.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -23,7 +23,6 @@ import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLEventWriter;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
@@ -44,7 +43,6 @@ import org.apache.neethi.Constants;
import org.apache.neethi.ExactlyOne;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyComponent;
-import org.apache.neethi.PolicyRegistry;
/**
* XmlPrimitiveAssertion wraps an Element s.t. any unknown elements can be
@@ -84,8 +82,8 @@ public class XmlPrimitiveAssertion imple
* @param element
* the Element to be set as wrapped
*/
- public void setValue(Element element) {
- this.element = element;
+ public void setValue(Element el) {
+ this.element = el;
}
/**
@@ -122,16 +120,16 @@ public class XmlPrimitiveAssertion imple
ExactlyOne exactlyOne = new ExactlyOne();
All all = new All();
- Element element = (Element)this.element.cloneNode(true);
- Attr attr = element.getAttributeNodeNS(Constants.URI_POLICY_NS, Constants.ATTR_OPTIONAL);
+ Element el = (Element)this.element.cloneNode(true);
+ Attr attr = el.getAttributeNodeNS(Constants.URI_POLICY_NS, Constants.ATTR_OPTIONAL);
if (attr != null) {
- element.removeAttributeNode(attr);
+ el.removeAttributeNode(attr);
}
- attr = element.getAttributeNodeNS(Constants.URI_POLICY_15_NS, Constants.ATTR_OPTIONAL);
+ attr = el.getAttributeNodeNS(Constants.URI_POLICY_15_NS, Constants.ATTR_OPTIONAL);
if (attr != null) {
- element.removeAttributeNode(attr);
+ el.removeAttributeNode(attr);
}
- all.addPolicyComponent(new XmlPrimitiveAssertion(element));
+ all.addPolicyComponent(new XmlPrimitiveAssertion(el));
exactlyOne.addPolicyComponent(all);
exactlyOne.addPolicyComponent(new All());
@@ -172,8 +170,7 @@ public class XmlPrimitiveAssertion imple
attribute = element2.getAttributeNodeNS(Constants.URI_POLICY_15_NS, Constants.ATTR_OPTIONAL);
}
if (attribute != null) {
- this.optional = (new Boolean(attribute.getValue())
- .booleanValue());
+ this.optional = Boolean.parseBoolean(attribute.getValue());
} else {
this.optional = false;
@@ -182,9 +179,7 @@ public class XmlPrimitiveAssertion imple
private void setIgnorability(Element element2) {
Attr attribute = element2.getAttributeNodeNS(Constants.URI_POLICY_15_NS, Constants.ATTR_IGNORABLE);
if (attribute != null) {
- this.ignorable = (new Boolean(attribute.getValue())
- .booleanValue());
-
+ this.ignorable = Boolean.parseBoolean(attribute.getValue());
} else {
this.ignorable = false;
}
@@ -244,8 +239,8 @@ public class XmlPrimitiveAssertion imple
writer.writeAttribute(name.getPrefix(), name.getNamespaceURI(),
name.getLocalPart(), attr.getValue());
}
+ break;
}
- break;
case XMLEvent.CHARACTERS: {
Characters ch = event.asCharacters();
@@ -255,16 +250,16 @@ public class XmlPrimitiveAssertion imple
} else {
writer.writeCharacters(text);
}
- }
- break;
-
+ break;
+ }
case XMLEvent.CDATA:
writer.writeCData(event.asCharacters().getData());
break;
case XMLEvent.COMMENT:
writer.writeComment(((Comment) event).getText());
- break;
+ break;
+ default:
}
}
}
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/PolicyComparator.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/PolicyComparator.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/PolicyComparator.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/PolicyComparator.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -19,7 +19,6 @@
package org.apache.neethi.util;
-import java.util.Iterator;
import java.util.List;
import org.apache.neethi.All;
@@ -33,7 +32,10 @@ import org.apache.neethi.PolicyComponent
* PolicyComponents.
*
*/
-public class PolicyComparator {
+public final class PolicyComparator {
+ private PolicyComparator() {
+ //utility class
+ }
/**
* Returns <tt>true</tt> if the two policies have the same semantics
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/PolicyIntersector.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/PolicyIntersector.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/PolicyIntersector.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/PolicyIntersector.java Sat Feb 12 02:24:08 2011
@@ -26,12 +26,10 @@ import java.util.List;
import org.apache.neethi.All;
import org.apache.neethi.Assertion;
-import org.apache.neethi.AssertionBuilderFactory;
import org.apache.neethi.ExactlyOne;
import org.apache.neethi.IntersectableAssertion;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyComponent;
-import org.apache.neethi.builders.AssertionBuilder;
/**
* This class contains methods dealing with policy intersection.
@@ -124,7 +122,7 @@ public class PolicyIntersector {
all.addPolicyComponent(assertion);
} else if (!strict && ((Assertion)a1).isIgnorable()) {
all.addPolicyComponent(a1);
- } else if (strict || !((Assertion)a1).isIgnorable()){
+ } else if (strict || !((Assertion)a1).isIgnorable()) {
return null;
}
}
@@ -138,7 +136,7 @@ public class PolicyIntersector {
all.addPolicyComponent(assertion);
} else if (!strict && ((Assertion)a2).isIgnorable()) {
all.addPolicyComponent(a2);
- } else if (strict || !((Assertion)a2).isIgnorable()){
+ } else if (strict || !((Assertion)a2).isIgnorable()) {
return null;
}
}
Modified: webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/Service.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/Service.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/Service.java (original)
+++ webservices/commons/trunk/modules/neethi/src/main/java/org/apache/neethi/util/Service.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -28,7 +28,6 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -44,11 +43,15 @@ import java.util.Map;
* @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
* @version $Id$
*/
-public class Service {
+public final class Service {
// Remember providers we have looked up before.
static Map<String, List<?>> instanceMap = new HashMap<String, List<?>>();
+ private Service() {
+ //not constructed
+ }
+
@SuppressWarnings("unchecked")
private static <T> List<T> cast(List<?> p) {
return (List<T>)p;
@@ -84,11 +87,17 @@ public class Service {
// Ooops! can't get his class loader.
}
// Can always request your own class loader. But it might be 'null'.
- if (cl == null) cl = Service.class.getClassLoader();
- if (cl == null) cl = ClassLoader.getSystemClassLoader();
+ if (cl == null) {
+ cl = Service.class.getClassLoader();
+ }
+ if (cl == null) {
+ cl = ClassLoader.getSystemClassLoader();
+ }
// No class loader so we can't find 'serviceFile'.
- if (cl == null) return l;
+ if (cl == null) {
+ return l;
+ }
Enumeration<URL> e;
try {
@@ -112,8 +121,9 @@ public class Service {
try {
// First strip any comment...
int idx = line.indexOf('#');
- if (idx != -1)
+ if (idx != -1) {
line = line.substring(0, idx);
+ }
// Trim whitespace.
line = line.trim();
Modified: webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/IntersectTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/IntersectTest.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/IntersectTest.java (original)
+++ webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/IntersectTest.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -20,15 +20,11 @@
package org.apache.neethi;
import java.io.File;
-import java.io.FileOutputStream;
-
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamWriter;
import org.apache.neethi.util.PolicyComparator;
public class IntersectTest extends PolicyTestCase {
- int failCount = 0;
+ int failCount;
public IntersectTest() {
super("IntersectTest");
@@ -62,7 +58,9 @@ public class IntersectTest extends Polic
File intersected = new File(testResourceDir, intersectedDir);
File[] files = intersected.listFiles();
- String f, f1, f2;
+ String f;
+ String f1;
+ String f2;
for (int i = 0; i < files.length; i++) {
f = files[i].getName();
@@ -97,19 +95,16 @@ public class IntersectTest extends Polic
String f1, String f2, String f,
boolean strict,
int type) throws Exception {
- Policy p1, p2, p3, p4;
- String r1, r2, r3;
-
- r1 = base + File.separator + "Policy" + f1 + ".xml";
- r2 = base + File.separator + "Policy" + f2 + ".xml";
- r3 = intersectedDir + File.separator + f;
-
- p1 = getPolicy(r1, type);
- p2 = getPolicy(r2, type);
- p3 = getPolicy(r3, type);
+ String r1 = base + File.separator + "Policy" + f1 + ".xml";
+ String r2 = base + File.separator + "Policy" + f2 + ".xml";
+ String r3 = intersectedDir + File.separator + f;
+
+ Policy p1 = getPolicy(r1, type);
+ Policy p2 = getPolicy(r2, type);
+ Policy p3 = getPolicy(r3, type);
// result
- p4 = (Policy)p1.intersect(p2, strict);
+ Policy p4 = (Policy)p1.intersect(p2, strict);
if (p4 == null || !PolicyComparator.compare(p4, p3)) {
/*
@@ -121,7 +116,8 @@ public class IntersectTest extends Polic
+ f2 + ", " + strict + ") FAILED");
/*
} else {
- System.out.println("Pass: " + base + File.separator + "Policy" + f1 + ".intersect(Policy" + f2 + ", "
+ System.out.println("Pass: " + base + File.separator + "Policy" + f1
+ + ".intersect(Policy" + f2 + ", "
+ strict +")");
*/
}
Modified: webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/MergeTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/MergeTest.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/MergeTest.java (original)
+++ webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/MergeTest.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -47,39 +47,35 @@ public class MergeTest extends PolicyTes
}
public void doTest(String base, String merged, int type) throws Exception {
- String r1, r2, r3;
- Policy p1, p2, p3, p4;
File samples2 = new File(testResourceDir, merged);
File[] files = samples2.listFiles();
- String f, f1, f2;
-
for (int i = 0; i < files.length; i++) {
if (files[i].isHidden()) {
continue;
}
- f = files[i].getName();
+ String f = files[i].getName();
if (f.startsWith(".")) {
continue;
}
- f1 = f.substring(f.indexOf('y') + 1, f.indexOf('-'));
- f2 = f.substring(f.indexOf('-') + 1, f.indexOf('.'));
+ String f1 = f.substring(f.indexOf('y') + 1, f.indexOf('-'));
+ String f2 = f.substring(f.indexOf('-') + 1, f.indexOf('.'));
- r1 = base + File.separator + "Policy" + f1 + ".xml";
- r2 = base + File.separator + "Policy" + f2 + ".xml";
- r3 = merged + File.separator + f;
-
- p1 = getPolicy(r1, type);
- p2 = getPolicy(r2, type);
- p3 = getPolicy(r3, type);
+ String r1 = base + File.separator + "Policy" + f1 + ".xml";
+ String r2 = base + File.separator + "Policy" + f2 + ".xml";
+ String r3 = merged + File.separator + f;
+
+ Policy p1 = getPolicy(r1, type);
+ Policy p2 = getPolicy(r2, type);
+ Policy p3 = getPolicy(r3, type);
// result
- p4 = (Policy)p1.merge(p2);
+ Policy p4 = (Policy)p1.merge(p2);
p4 = (Policy)p4.normalize(true);
Modified: webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/Normalize2Test.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/Normalize2Test.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/Normalize2Test.java (original)
+++ webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/Normalize2Test.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -42,18 +42,16 @@ public class Normalize2Test extends Poli
}
public void doTest(int type) throws Exception {
- String r1, r2;
- Policy p1, p2;
for (int i = 1; i < 21; i++) {
- r1 = "samples2" + File.separator + "Policy" + i + ".xml";
- r2 = "normalized2" + File.separator + "Policy" + i + ".xml";
+ String r1 = "samples2" + File.separator + "Policy" + i + ".xml";
+ String r2 = "normalized2" + File.separator + "Policy" + i + ".xml";
- p1 = getPolicy(r1, type);
+ Policy p1 = getPolicy(r1, type);
p1 = (Policy)p1.normalize(true);
- p2 = getPolicy(r2, type);
+ Policy p2 = getPolicy(r2, type);
if (!PolicyComparator.compare(p1, p2)) {
fail("samples2" + File.separator + "Policy" + i + ".normalize() FAILED");
Modified: webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/NormalizeTest.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/NormalizeTest.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/NormalizeTest.java (original)
+++ webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/NormalizeTest.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -22,8 +22,6 @@ package org.apache.neethi;
import java.io.File;
import java.io.StringWriter;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import javax.xml.stream.XMLOutputFactory;
@@ -66,9 +64,6 @@ public class NormalizeTest extends Polic
}
public void doTest(String base, String normalized, int type,
List<String> excludes) throws Exception {
- String r1, r2;
- Policy p1, p2;
-
File file = new File(testResourceDir + File.separator + normalized);
for (String name : file.list()) {
if (excludes.contains(name)) {
@@ -78,12 +73,12 @@ public class NormalizeTest extends Polic
continue;
}
- r1 = base + File.separator + name;
- r2 = normalized + File.separator + name;
+ String r1 = base + File.separator + name;
+ String r2 = normalized + File.separator + name;
- p1 = getPolicy(r1, type);
+ Policy p1 = getPolicy(r1, type);
p1 = (Policy) p1.normalize(true);
- p2 = getPolicy(r2, type);
+ Policy p2 = getPolicy(r2, type);
if (!PolicyComparator.compare(p1, p2)) {
XMLStreamWriter writer;
Modified: webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/PolicyTestCase.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/PolicyTestCase.java?rev=1070012&r1=1070011&r2=1070012&view=diff
==============================================================================
--- webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/PolicyTestCase.java (original)
+++ webservices/commons/trunk/modules/neethi/src/test/java/org/apache/neethi/PolicyTestCase.java Sat Feb 12 02:24:08 2011
@@ -1,4 +1,4 @@
-/*
+/**
* 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
@@ -44,7 +44,7 @@ import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMXMLBuilderFactory;
-public abstract class PolicyTestCase extends TestCase{
+public abstract class PolicyTestCase extends TestCase {
protected String baseDir = System.getProperty("basedir");
protected String testResourceDir = "src" + File.separator + "test" + File.separator + "test-resources";