use of com.sun.xml.ws.policy.AssertionSet in project metro-jax-ws by eclipse-ee4j.
the class PolicyModelTranslator method translate.
/**
* The method translates {@link PolicySourceModel} structure into normalized {@link Policy} expression. The resulting Policy
* is disconnected from its model, thus any additional changes in model will have no effect on the Policy expression.
*
* @param model the model to be translated into normalized policy expression. Must not be {@code null}.
* @return translated policy expression in it's normalized form.
* @throws PolicyException in case of translation failure
*/
public Policy translate(final PolicySourceModel model) throws PolicyException {
LOGGER.entering(model);
if (model == null) {
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0043_POLICY_MODEL_TRANSLATION_ERROR_INPUT_PARAM_NULL()));
}
PolicySourceModel localPolicyModelCopy;
try {
localPolicyModelCopy = model.clone();
} catch (CloneNotSupportedException e) {
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0016_UNABLE_TO_CLONE_POLICY_SOURCE_MODEL(), e));
}
final String policyId = localPolicyModelCopy.getPolicyId();
final String policyName = localPolicyModelCopy.getPolicyName();
final Collection<AssertionSet> alternatives = createPolicyAlternatives(localPolicyModelCopy);
LOGGER.finest(LocalizationMessages.WSP_0052_NUMBER_OF_ALTERNATIVE_COMBINATIONS_CREATED(alternatives.size()));
Policy policy = null;
if (alternatives.size() == 0) {
policy = Policy.createNullPolicy(model.getNamespaceVersion(), policyName, policyId);
LOGGER.finest(LocalizationMessages.WSP_0055_NO_ALTERNATIVE_COMBINATIONS_CREATED());
} else if (alternatives.size() == 1 && alternatives.iterator().next().isEmpty()) {
policy = Policy.createEmptyPolicy(model.getNamespaceVersion(), policyName, policyId);
LOGGER.finest(LocalizationMessages.WSP_0026_SINGLE_EMPTY_ALTERNATIVE_COMBINATION_CREATED());
} else {
policy = Policy.createPolicy(model.getNamespaceVersion(), policyName, policyId, alternatives);
LOGGER.finest(LocalizationMessages.WSP_0057_N_ALTERNATIVE_COMBINATIONS_M_POLICY_ALTERNATIVES_CREATED(alternatives.size(), policy.getNumberOfAssertionSets()));
}
LOGGER.exiting(policy);
return policy;
}
use of com.sun.xml.ws.policy.AssertionSet in project metro-jax-ws by eclipse-ee4j.
the class MtomFeatureConfigurator method getFeatures.
/**
* process Mtom policy assertions and if found and is not optional then mtom is enabled on the
* {@link WSDLBoundPortType}
*
* @param key Key that identifies the endpoint scope
* @param policyMap Must be non-null
* @throws PolicyException If retrieving the policy triggered an exception
*/
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
final Collection<WebServiceFeature> features = new LinkedList<>();
if ((key != null) && (policyMap != null)) {
Policy policy = policyMap.getEndpointEffectivePolicy(key);
if (null != policy && policy.contains(EncodingConstants.OPTIMIZED_MIME_SERIALIZATION_ASSERTION)) {
Iterator<AssertionSet> assertions = policy.iterator();
while (assertions.hasNext()) {
AssertionSet assertionSet = assertions.next();
Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
while (policyAssertion.hasNext()) {
PolicyAssertion assertion = policyAssertion.next();
if (EncodingConstants.OPTIMIZED_MIME_SERIALIZATION_ASSERTION.equals(assertion.getName())) {
features.add(new MTOMFeature(true));
}
// end-if non optional mtom assertion found
}
// next assertion
}
// next alternative
}
// end-if policy contains mtom assertion
}
return features;
}
use of com.sun.xml.ws.policy.AssertionSet in project metro-jax-ws by eclipse-ee4j.
the class SelectOptimalEncodingFeatureConfigurator method getFeatures.
/**
* Process SelectOptimalEncoding policy assertions.
*
* @param key Key that identifies the endpoint scope.
* @param policyMap The policy map.
* @throws PolicyException If retrieving the policy triggered an exception.
*/
public Collection<WebServiceFeature> getFeatures(PolicyMapKey key, PolicyMap policyMap) throws PolicyException {
final Collection<WebServiceFeature> features = new LinkedList<>();
if ((key != null) && (policyMap != null)) {
Policy policy = policyMap.getEndpointEffectivePolicy(key);
if (null != policy && policy.contains(EncodingConstants.SELECT_OPTIMAL_ENCODING_ASSERTION)) {
Iterator<AssertionSet> assertions = policy.iterator();
while (assertions.hasNext()) {
AssertionSet assertionSet = assertions.next();
Iterator<PolicyAssertion> policyAssertion = assertionSet.iterator();
while (policyAssertion.hasNext()) {
PolicyAssertion assertion = policyAssertion.next();
if (EncodingConstants.SELECT_OPTIMAL_ENCODING_ASSERTION.equals(assertion.getName())) {
String value = assertion.getAttributeValue(enabled);
boolean isSelectOptimalEncodingEnabled = value == null || Boolean.parseBoolean(value.trim());
features.add(new SelectOptimalEncodingFeature(isSelectOptimalEncodingEnabled));
}
}
}
}
}
return features;
}
Aggregations