Methods Summary |
---|
void | addNewPolicyReference(ModelNode node)Adds new policy reference to the policy source model. The method is used by
the ModelNode instances of type POLICY_REFERENCE that need to register themselves
as policy references in the model.
if (node.getType() != ModelNode.Type.POLICY_REFERENCE) {
throw new IllegalArgumentException(LocalizationMessages.WSP_0042_POLICY_REFERENCE_NODE_EXPECTED_INSTEAD_OF(node.getType()));
}
references.add(node);
|
protected com.sun.xml.ws.policy.sourcemodel.PolicySourceModel | clone()
final PolicySourceModel clone = (PolicySourceModel) super.clone();
clone.rootNode = this.rootNode.clone();
try {
clone.rootNode.setParentModel(this);
} catch (IllegalAccessException e) {
throw LOGGER.logSevereException(new CloneNotSupportedException(LocalizationMessages.WSP_0013_UNABLE_TO_SET_PARENT_MODEL_ON_ROOT()), e);
}
return clone;
|
public boolean | containsPolicyReferences()Returns a boolean value indicating whether this policy source model contains references to another policy source models.
Every source model that references other policies must be expanded before it can be translated into a Policy objects. See
{@link #expand(PolicySourceModelContext)} and {@link #isExpanded()} for more details.
return !references.isEmpty();
|
public static com.sun.xml.ws.policy.sourcemodel.PolicySourceModel | createPolicySourceModel()Factory method that creates new policy source model instance.
return new PolicySourceModel();
|
public static com.sun.xml.ws.policy.sourcemodel.PolicySourceModel | createPolicySourceModel(java.lang.String policyId, java.lang.String policyName)Factory method that creates new policy source model instance and initializes it according to parameters provided.
return new PolicySourceModel(policyId, policyName);
|
public boolean | equals(java.lang.Object obj)An {@code Object.equals(Object obj)} method override.
When child nodes are tested for equality, the parent policy source model is not considered. Thus two different
policy source models instances may be equal based on their node content.
if (this == obj) {
return true;
}
if (!(obj instanceof PolicySourceModel)) {
return false;
}
boolean result = true;
final PolicySourceModel that = (PolicySourceModel) obj;
result = result && ((this.policyId == null) ? that.policyId == null : this.policyId.equals(that.policyId));
result = result && ((this.policyName == null) ? that.policyName == null : this.policyName.equals(that.policyName));
result = result && this.rootNode.equals(that.rootNode);
// result = result && ((this.xxx == null) ? that.xxx == null : this.xxx.equals(that.xxx));
return result;
|
public synchronized void | expand(PolicySourceModelContext context)Expands current policy model. This means, that if this model contains any (unexpanded) policy references, then the method expands those
references by placing the content of the referneced policy source models under the policy reference nodes. This operation merely creates
a link between this and referenced policy source models. Thus any change in the referenced models will be visible wihtin this model as well.
Please, notice that the method does not check if the referenced models are already expanded nor does the method try to expand unexpanded
referenced models. This must be preformed manually within client's code. Consecutive calls of this method will have no effect.
Every source model that references other policies must be expanded before it can be translated into a Policy object. See
{@link #isExpanded()} and {@link #containsPolicyReferences()} for more details.
if (!isExpanded()) {
for (ModelNode reference : references) {
final PolicyReferenceData refData = reference.getPolicyReferenceData();
final String digest = refData.getDigest();
PolicySourceModel referencedModel;
if (digest == null) {
referencedModel = context.retrieveModel(refData.getReferencedModelUri());
} else {
referencedModel = context.retrieveModel(refData.getReferencedModelUri(), refData.getDigestAlgorithmUri(), digest);
}
reference.setReferencedModel(referencedModel);
}
expanded = true;
}
|
private java.lang.String | getDefaultPrefix(java.lang.String namespace)Method retrieves default prefix for given namespace. Method returns null if
no default prefix is defined..
return defaultNamespaceToPrefixMap.get(namespace);
|
java.util.Map | getNamespaceToPrefixMapping()Provides information about how namespaces used in this {@link PolicySourceModel}
instance should be mapped to thier default prefixes when marshalled.
final Map<String, String> nsToPrefixMap = new HashMap<String, String>();
final Collection<String> namespaces = getUsedNamespaces();
for (String namespace : namespaces) {
final String prefix = getDefaultPrefix(namespace);
if (prefix != null) {
nsToPrefixMap.put(namespace, prefix);
}
}
return nsToPrefixMap;
|
public java.lang.String | getPolicyId()Returns a policy ID of this policy source model.
return policyId;
|
public java.lang.String | getPolicyName()Returns a policy name of this policy source model.
return policyName;
|
public ModelNode | getRootNode()Returns a root node of this policy source model. It is allways of POLICY type.
return rootNode;
|
private java.util.Collection | getUsedNamespaces()Iterates through policy vocabulary and extracts set of namespaces used in
the policy expression.
final Set<String> namespaces = new HashSet<String>();
namespaces.add(PolicyConstants.POLICY_NAMESPACE_URI);
if (this.policyId != null) {
namespaces.add(PolicyConstants.WSU_NAMESPACE_URI);
}
final Queue<ModelNode> nodesToBeProcessed = new LinkedList<ModelNode>();
nodesToBeProcessed.add(rootNode);
ModelNode processedNode;
while ((processedNode = nodesToBeProcessed.poll()) != null) {
for (ModelNode child : processedNode.getContent()) {
if (child.hasChildren()) {
nodesToBeProcessed.offer(child);
}
if (child.isAssertionRelatedNode()) {
final AssertionData nodeData = child.getNodeData();
namespaces.add(nodeData.getName().getNamespaceURI());
if (nodeData.isPrivateAttributeSet()) {
namespaces.add(PolicyConstants.SUN_POLICY_NAMESPACE_URI);
}
for (Entry<QName, String> attribute : nodeData.getAttributesSet()) {
namespaces.add(attribute.getKey().getNamespaceURI());
}
}
}
}
return namespaces;
|
public int | hashCode()An {@code Object.hashCode()} method override.
int result = 17;
result = 37 * result + ((this.policyId == null) ? 0 : this.policyId.hashCode());
result = 37 * result + ((this.policyName == null) ? 0 : this.policyName.hashCode());
result = 37 * result + this.rootNode.hashCode();
// result = 37 * result + ((this.xxx == null) ? 0 : this.xxx.hashCode());
return result;
|
private boolean | isExpanded()Returns a boolean value indicating whether this policy source model contains is already expanded (i.e. contains no unexpanded
policy references) or not. This means that if model does not originally contain any policy references, it is considered as expanded,
thus this method returns {@code true} in such case. Also this method does not check whether the references policy source models are expanded
as well, so after expanding this model a value of {@code true} is returned even if referenced models are not expanded yet. Thus each model
can be considered to be fully expanded only if all policy source models stored in PolicySourceModelContext instance are expanded, provided the
PolicySourceModelContext instance contains full set of policy source models.
Every source model that references other policies must be expanded before it can be translated into a Policy object. See
{@link #expand(PolicySourceModelContext)} and {@link #containsPolicyReferences()} for more details.
return references.isEmpty() || expanded;
|
public java.lang.String | toString()Returns a string representation of the object. In general, the toString method
returns a string that "textually represents" this object.
final String innerIndent = PolicyUtils.Text.createIndent(1);
final StringBuffer buffer = new StringBuffer(60);
buffer.append("Policy source model {").append(PolicyUtils.Text.NEW_LINE);
buffer.append(innerIndent).append("policy id = '").append(policyId).append('\'").append(PolicyUtils.Text.NEW_LINE);
buffer.append(innerIndent).append("policy name = '").append(policyName).append('\'").append(PolicyUtils.Text.NEW_LINE);
rootNode.toString(1, buffer).append(PolicyUtils.Text.NEW_LINE).append('}");
return buffer.toString();
|