1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 package org.ogf.graap.wsag.wsrf.sg.impl;
36
37 import org.apache.log4j.Logger;
38 import org.apache.muse.ws.addressing.EndpointReference;
39 import org.apache.xmlbeans.XmlObject;
40 import org.apache.xmlbeans.XmlOptions;
41 import org.ogf.graap.wsag.api.WsagConstants;
42 import org.w3.x2005.x08.addressing.EndpointReferenceType;
43 import org.w3.x2005.x08.addressing.ReferenceParametersType;
44 import org.w3c.dom.Element;
45
46
47
48
49
50
51
52 public class AgreementMembershipContentRule extends MembershipContentRule
53 {
54
55 private static final Logger LOG = Logger.getLogger( AgreementMembershipContentRule.class );
56
57
58
59
60 public AgreementMembershipContentRule()
61 {
62 super();
63 }
64
65
66
67
68
69
70
71
72 public AgreementMembershipContentRule( Element xml )
73 {
74 super( xml );
75 }
76
77
78
79
80
81
82
83
84 public boolean isMatch( EndpointReference memberEPR )
85 {
86 boolean result = super.isMatch( memberEPR );
87
88
89
90
91 if ( result )
92 {
93
94
95
96
97
98 EndpointReferenceType factoryEPR = MembershipContentRuleContext.getFactoryEPR();
99 EndpointReferenceType registryEPR = MembershipContentRuleContext.getRegistryEPR();
100
101 ReferenceParametersType factoryREF = factoryEPR.getReferenceParameters();
102 ReferenceParametersType registryREF = registryEPR.getReferenceParameters();
103
104
105
106
107
108 XmlObject[] factoryChildren = factoryREF.selectChildren( WsagConstants.WSAG4J_RESOURCE_ID_QNAME );
109 XmlObject[] registryChildren =
110 registryREF.selectChildren( WsagConstants.WSAG4J_RESOURCE_ID_QNAME );
111
112 if ( factoryChildren.length != 1 )
113 {
114 LOG.error( "Expected exacly one occurence of WSAG4J resource id in epr, but found "
115 + Integer.valueOf( factoryChildren.length ) );
116
117 if ( LOG.isDebugEnabled() )
118 {
119 LOG.debug( factoryEPR.xmlText( new XmlOptions().setSavePrettyPrint() ) );
120 }
121
122 return false;
123 }
124
125 if ( registryChildren.length != 1 )
126 {
127 LOG.error( "Expected exacly one occurence of WSAG4J resource id in epr, but found "
128 + Integer.valueOf( registryChildren.length ) );
129
130 if ( LOG.isDebugEnabled() )
131 {
132 LOG.debug( registryEPR.xmlText( new XmlOptions().setSavePrettyPrint() ) );
133 }
134
135 return false;
136 }
137
138 String factoryID = factoryChildren[0].getDomNode().getFirstChild().getNodeValue();
139 String registryID = registryChildren[0].getDomNode().getFirstChild().getNodeValue();
140
141 if ( factoryID == null )
142 {
143 LOG.error( "Factory resource id must not be null in reference parameters." );
144
145 if ( LOG.isDebugEnabled() )
146 {
147 LOG.debug( factoryEPR.xmlText( new XmlOptions().setSavePrettyPrint() ) );
148 }
149
150 return false;
151 }
152
153 if ( registryID == null )
154 {
155 LOG.error( "Registry resource id must not be null in reference parameters." );
156
157 if ( LOG.isDebugEnabled() )
158 {
159 LOG.debug( registryEPR.xmlText( new XmlOptions().setSavePrettyPrint() ) );
160 }
161
162 return false;
163 }
164
165 result = result && factoryID.equals( registryID );
166 }
167
168 return result;
169 }
170
171 }