axisOperation.getEngagedModules().clear();
Association[] associations = configRegistry.getAssociations(operationPath,
RegistryResources.Associations.ENGAGED_MODULES);
for (Association association : associations) {
AxisModule axisModule = getExistingAxisModule(association.getDestinationPath());
if (!isGloballyEngaged(association.getDestinationPath())) {
if (!axisService.isEngaged(axisModule)) {
axisOperation.engageModule(axisModule);
}
}
}
// Handle operation parameters
loadParameters(axisOperation, operationPath);
// Handle operation documentation
loadDocumentation(axisOperation, operationPath);
}
} else {
wsdlChangeDetected = true;
writeAxisDescription(axisOperation, axisOperation.getName().getLocalPart(),
PersistenceUtils.getResourcePath(axisOperation));
writeParameters(axisOperation.getParameters(),
PersistenceUtils.getResourcePath(axisOperation));
for (Object o : axisOperation.getEngagedModules()) {
AxisModule axisModule = (AxisModule) o;
String moduleResourcePath = PersistenceUtils.getResourcePath(axisModule);
if (!isGloballyEngaged(moduleResourcePath)
&& !axisService.getParent().isEngaged(axisModule.getName())
&& !axisService.isEngaged(axisModule.getName())) {
configRegistry.addAssociation(PersistenceUtils
.getResourcePath(axisOperation), moduleResourcePath,
RegistryResources.Associations.ENGAGED_MODULES);
}
}
}
}
// sync up the operations, required by the proxy services : Ruwan
String operationsPath = service.getPath() + RegistryResources.OPERATIONS;
if(configRegistry.resourceExists(operationsPath)){
Collection operationsCollection = (Collection) configRegistry.get(operationsPath);
for (String opPath : operationsCollection.getChildren()) {
String opName = opPath.substring(operationsPath.length()).replace("/", "");
if (axisService.getOperation(new QName(opName)) == null) {
wsdlChangeDetected = true;
// new service do not have the operation
configRegistry.delete(opPath);
}
}
}
// Fetch and attach Binding, Binding operation and their Message policies
Map endPointMap = axisService.getEndpoints();
for (Object o : endPointMap.entrySet()) {
Map.Entry entry = (Map.Entry) o;
AxisEndpoint point = (AxisEndpoint) entry.getValue();
AxisBinding currentAxisBinding = point.getBinding();
// Fetch binding policies
String bindingPath = serviceResourcePath + RegistryResources.ServiceProperties
.BINDINGS + currentAxisBinding.getName().getLocalPart();
if (configRegistry.resourceExists(bindingPath)) {
if (isProxyService) {
// This is to ensure that binding level policies applied from the UI
// get precedence over service level policies for proxy services
java.util.Collection<PolicyComponent> attachedPolicies = axisService.getPolicySubject().
getAttachedPolicyComponents();
if (attachedPolicies != null && !attachedPolicies.isEmpty()) {
List properties = getPropertyValues(bindingPath,
RegistryResources.ServiceProperties.POLICY_UUID);
if (properties != null && properties.size() > 0) {
List<String> removablePolicies = new ArrayList<String>();
for (PolicyComponent pc : attachedPolicies) {
if (pc instanceof Policy) {
String id = ((Policy) pc).getId();
if (properties.contains(id)) {
removablePolicies.add(id);
}
}
}
for (String id : removablePolicies) {
axisService.getPolicySubject().detachPolicyComponent(id);
}
}
}
}
loadPolicies(currentAxisBinding, getPropertyValues(bindingPath,
RegistryResources.ServiceProperties.POLICY_UUID),
serviceResourcePath);
Iterator operationsItr = currentAxisBinding.getChildren();
while (operationsItr.hasNext()) {
AxisBindingOperation bindingOp = (AxisBindingOperation) operationsItr.next();
// Fetch and attach binding operation policies
String bindingOpPath = PersistenceUtils
.getBindingOperationPath(serviceResourcePath, bindingOp);
if (configRegistry.resourceExists(bindingOpPath)) {
loadPolicies(bindingOp, getPropertyValues(bindingOpPath,
RegistryResources.ServiceProperties.POLICY_UUID),
serviceResourcePath);
// Fetch and attach MessageIn policies for this operation
loadPolicies(bindingOp.getChild(
WSDLConstants.MESSAGE_LABEL_IN_VALUE), getPropertyValues(
bindingOpPath, RegistryResources.ServiceProperties
.MESSAGE_IN_POLICY_UUID), serviceResourcePath);
// Fetch and attach MessageOut policies for this operation
loadPolicies(bindingOp.getChild(
WSDLConstants.MESSAGE_LABEL_OUT_VALUE), getPropertyValues(
bindingOpPath, RegistryResources.ServiceProperties
.MESSAGE_OUT_POLICY_UUID), serviceResourcePath);
} else {
writeAxisDescription(bindingOp, bindingOp.getName().getLocalPart(),
PersistenceUtils.getBindingOperationPath(
serviceResourcePath, bindingOp));
}
}
} else {
handleNewBindingAddition(serviceResourcePath, currentAxisBinding);
}
}
// Disengage all the statically engaged modules (i.e. those module
// engaged from the services.xml file)
axisService.getEngagedModules().clear();
// Engage modules to service
Association[] engModules = configRegistry.getAssociations(serviceResourcePath,
RegistryResources.Associations.ENGAGED_MODULES);
for (Association association : engModules) {
AxisModule axisModule = getExistingAxisModule(association.getDestinationPath());
if (!isGloballyEngaged(association.getDestinationPath())) {
axisService.disengageModule(axisModule);
axisService.engageModule(axisModule);
}
}