summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x
diff options
context:
space:
mode:
authorbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-07-26 04:40:48 +0000
committerbdaniel <bdaniel@13f79535-47bb-0310-9956-ffa450edef68>2010-07-26 04:40:48 +0000
commit7a90e1e94462b35ad2c4c4799ad9c676d4586ed5 (patch)
tree3fdb164afa458ac9935d47d03c9b6d85d4299586 /sca-java-2.x
parenta1cb50c30445cd5a1266351fe7729ff3dcdf2767 (diff)
Fix up appliesTo processing. Need to save each separate composite document as a dom and check endpoints
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@979157 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x')
-rw-r--r--sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAppliesToBuilderImpl.java70
1 files changed, 37 insertions, 33 deletions
diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAppliesToBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAppliesToBuilderImpl.java
index 2417940b1c..c0da5ad33b 100644
--- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAppliesToBuilderImpl.java
+++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/PolicyAppliesToBuilderImpl.java
@@ -83,44 +83,47 @@ public class PolicyAppliesToBuilderImpl extends PolicyAttachmentBuilderImpl {
}
}
- private Composite checkAppliesTo(Document document, Map<PolicySet, List<PolicySubject>> appliesToSubjects, Composite composite, BuilderContext context) throws Exception {
- // look at policies recursively
- for (Component component : composite.getComponents()) {
- Implementation implementation = component.getImplementation();
- if (implementation instanceof Composite) {
- checkAppliesTo(document, appliesToSubjects, (Composite)implementation, context);
- }
- }
+ private Composite checkAppliesTo(Document document, Map<PolicySet, List<PolicySubject>> appliesToSubjects, Composite topComposite, BuilderContext context) throws Exception {
+
+ for ( Component component : topComposite.getComponents() ) {
+ if ( component.getImplementation() instanceof Composite ) {
+ Composite nested = (Composite) component.getImplementation();
+ checkAppliesTo(saveAsDOM(nested),new HashMap<PolicySet, List<PolicySubject>>(), nested, context );
+ }
+ }
- for (Component component : composite.getComponents()) {
+ for (Component component : topComposite.getComponents()) {
- for (ComponentService componentService : component.getServices()) {
- for (Endpoint ep : componentService.getEndpoints()) {
- if (ep.getBinding() instanceof PolicySubject) {
- checkAppliesToSubject(document, appliesToSubjects, composite, (PolicySubject)ep.getBinding(), ep.getPolicySets());
- }
- }
- }
+ for (ComponentService componentService : component.getServices()) {
+ for (Endpoint ep : componentService.getEndpoints()) {
+ checkAppliesToSubject(document, appliesToSubjects, topComposite, (PolicySubject)ep, ep.getPolicySets());
+ if (ep.getBinding() instanceof PolicySubject) {
+ checkAppliesToSubject(document, appliesToSubjects, topComposite, (PolicySubject)ep.getBinding(), ep.getPolicySets());
+ }
+ }
+ }
- for (ComponentReference componentReference : component.getReferences()) {
- for (EndpointReference epr : componentReference.getEndpointReferences()) {
- if (epr.getBinding() instanceof PolicySubject) {
- checkAppliesToSubject(document, appliesToSubjects, composite, (PolicySubject)epr.getBinding(), epr.getPolicySets());
- }
- }
- }
+ for (ComponentReference componentReference : component.getReferences()) {
+ for (EndpointReference epr : componentReference.getEndpointReferences()) {
+ checkAppliesToSubject(document, appliesToSubjects, topComposite, (PolicySubject)epr, epr.getPolicySets());
+ if (epr.getBinding() instanceof PolicySubject) {
+ checkAppliesToSubject(document, appliesToSubjects, topComposite, (PolicySubject)epr.getBinding(), epr.getPolicySets());
+ }
+ }
+ }
- Implementation implementation = component.getImplementation();
- if (implementation != null &&
- implementation instanceof PolicySubject) {
- checkAppliesToSubject(document, appliesToSubjects, composite, implementation, implementation.getPolicySets());
- }
- }
-
- return composite;
+ Implementation implementation = component.getImplementation();
+ if (implementation != null &&
+ implementation instanceof PolicySubject) {
+ checkAppliesToSubject(document, appliesToSubjects, topComposite, implementation, implementation.getPolicySets());
+ }
+ }
+
+ return topComposite;
}
- /**
+
+ /**
* Checks that all the provided policy sets apply to the provided policy subject
*
* @param document
@@ -150,7 +153,8 @@ public class PolicyAppliesToBuilderImpl extends PolicyAttachmentBuilderImpl {
Node node = nodes.item(i);
String index = getStructuralURI(node);
PolicySubject subject = lookup(composite, index);
- subjects.add(subject);
+ if ( subject != null )
+ subjects.add(subject);
}
}
}