PolicyAttachment ordering for policies attached to SLDs

The SLAAttachment API (which is part of the policy service servlet) can return several <PolicyAttachment> elements depending on which policies are attached to the SLAs and SLDs that are related to a service version.

These <PolicyAttachment> elements are not returned in any specific order, and this can cause issues with some integrating products, such as IBM DataPower, which might require elements to be returned in a specific order, especially when multiple SLDs with attached policies are associated with a service version.

The built-in SLAAttachment service cannot specify the order of these <PolicyAttachment> elements for SLDs, but it can use the SLDPolicyWeight named query to return a weight for the <PolicyAttachment> elements for each of the SLDs associated with the service version. The weight value must be an integer in the range of 0 - 65535, where 0 is the lowest weight for the policy, and 65535 is the highest. Policies are weighted and returned in the order of highest to lowest weights.

A weight of 0 is applied under the following conditions:
  • An SLD does not have the specified property defined on it.
  • The query returns no value.
  • The query returns a non-integer value.

The order of the policies on SLDs is undetermined if multiple SLDs with the same weight value are associated with the same service version.

Example 1: Defining the SLDPolicyWeight named query

The following example illustrates how the SLDPolicyWeight named query can be used to return a user-defined policyWeight property value to order the <PolicyAttachment> elements that are returned.

<?xml version="1.0" encoding="UTF-8"?>
<!-- begin_generated_IBM_copyright_prolog -->
<!-- Licensed Materials - Property of IBM -->
<!-- 5724-N72 5655-WBS -->
<!-- (c) Copyright IBM Corp. 2010, 2011 All Rights Reserved -->
<!-- US Government Users Restricted Rights - Use, duplication or -->
<!-- disclosure restricted by GSA ADP Schedule Contract with IBM Corp. -->
<!-- end_generated_IBM_copyright_prolog -->

<query
  xmlns="http://www.ibm.com/xmlns/prod/serviceregistry/7/0/NamedQueryConfiguration"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ibm.com/xmlns/prod/serviceregistry/7/0/NamedQueryConfiguration ../../schemas/NamedQueryConfiguration.xsd" 
  type="propertyQuery">
  <xpath>//GenericObject[@bsrURI='%1']</xpath>
  <properties>
    <property>policyWeight</property>
  </properties>

</query>

The query must be of type propertyQuery, and the property that is used within the query can either be a user-defined property or a modelled property.

This configuration is typically performed by an administrator. Once configured, users can specify policy weight values for SLDs while using the dashboard. The following image shows an example of the PolicyWeight field in the Detail widget for an SLD named SLD2.

PolicyWeight field in the Detail widget for an SLD

Example 2: Using the SLDPolicyWeight named query to order <PolicyAttachment> elements

In this example, the named query defined in Example 1 is used to order the <PolicyAttachment> elements that are returned for two SLDs (SLD1 and SLD2), which are associated with a service version.

SLD1 has a policy named Policy1 attached to it, and has a value of 10 specified for the policyWeight property. SLD2 has a policy named Policy2 attached to it, and has a value of 20 specified for the policyWeight property.

Service Version with two related SLDs and two policy weights assigned

When the SLAAttachment API is called, it uses the SLDPolicyWeight named query to return the policyWeight property on the SLDs, and returns the policy attachments in the following order: Policy2 and then Policy1. The <PolicyAttachment> element for Policy2 is returned first because a higher policyWeight value was specified for SLD2. For example:
<mex:Metadata>
   <mex:MetadataSection Dialect="wsp:PolicyAttachment">
      <wsp:PolicyAttachment>
         <wsp:AppliesTo>
            <wsp:URI>http://example.com#wsdl11.port(Test2/Test2)</wsp:URI>
         </wsp:AppliesTo>
         <wsp:PolicyReference URI="urn:Policy2_0e21c1b0-31f5-11e5-aa4b-d6d44a5bd6bf_fd37288d-32ee-4504-86b9-36fa04548c96" bsrURI="93c96393-f384-448f.9c8b.d47a5fd48b6c"/>
      </wsp:PolicyAttachment>
   </mex:MetadataSection>
   <mex:MetadataSection Dialect="wsp:PolicyAttachment">
      <wsp:PolicyAttachment>
         <wsp:AppliesTo>
            <wsp:URI>http://example.com#wsdl11.port(Test/Test)</wsp:URI>
         </wsp:AppliesTo>
         <wsp:PolicyReference URI="urn:Policy1_c68a1eb0-31f4-11e5-aa4b-d6d44a5bd6bf_77cb7694-84a5-4694-85c7-a84b7af629cf" bsrURI="66cd4b66-dbea-4adb.ba70.f938a6f97033"/>
      </wsp:PolicyAttachment>
   </mex:MetadataSection>
</mex:Metadata>

Suppose another SLD (SLD3), which is associated with the service version, has a policy named Policy3 attached to it, but no specified policyWeight value.

Service Version with three related SLDs and only two policy weights assigned

When the SLAAttachment API is called, it will return the policy attachments in the following order: Policy2, Policy1, and then Policy3. In this case, the <PolicyAttachment> element for Policy3 is returned last because the policyWeight value of SLD3 defaults to 0 since no policyWeight value was specified for it. For example:
<mex:Metadata>
   <mex:MetadataSection Dialect="wsp:PolicyAttachment">
      <wsp:PolicyAttachment>
         <wsp:AppliesTo>
            <wsp:URI>http://example.com#wsdl11.port(Test2/Test2)</wsp:URI>
         </wsp:AppliesTo>
         <wsp:PolicyReference URI="urn:Policy2_0e21c1b0-31f5-11e5-aa4b-d6d44a5bd6bf_fd37288d-32ee-4504-86b9-36fa04548c96" bsrURI="93c96393-f384-448f.9c8b.d47a5fd48b6c"/>
      </wsp:PolicyAttachment>
   </mex:MetadataSection>
   <mex:MetadataSection Dialect="wsp:PolicyAttachment">
      <wsp:PolicyAttachment>
         <wsp:AppliesTo>
            <wsp:URI>http://example.com#wsdl11.port(Test/Test)</wsp:URI>
         </wsp:AppliesTo>
         <wsp:PolicyReference URI="urn:Policy1_c68a1eb0-31f4-11e5-aa4b-d6d44a5bd6bf_77cb7694-84a5-4694-85c7-a84b7af629cf" bsrURI="66cd4b66-dbea-4adb.ba70.f938a6f97033"/>
      </wsp:PolicyAttachment>
   </mex:MetadataSection>
   <mex:MetadataSection Dialect="wsp:PolicyAttachment">
      <wsp:PolicyAttachment>
         <wsp:AppliesTo>
            <wsp:URI>http://example.com#wsdl11.port(Test3/Test3)</wsp:URI>
         </wsp:AppliesTo>
         <wsp:PolicyReference URI="urn:Policy3_c34db0-5ef1-22a5-aa4b-d6d44a5bd6bf_77cb7694-84a5-4694-85c7-a84d7c456ea34" bsrURI="66cd4b66-dbea-4adb.ba70.f938a782acb4"/>
      </wsp:PolicyAttachment>
   </mex:MetadataSection>
</mex:Metadata>