private void loadProperties(final OMElement iaasElt, final Map<String, String> propertyMap) { Iterator<?> it = iaasElt.getChildrenWithName(new QName(CloudControllerConstants.PROPERTY_ELEMENT)); while (it.hasNext()) { OMElement prop = (OMElement) it.next(); if (prop.getAttribute(new QName(CloudControllerConstants.PROPERTY_NAME_ATTR)) == null || prop.getAttribute(new QName(CloudControllerConstants.PROPERTY_VALUE_ATTR)) == null) { String msg = "Property element's, name and value attributes should be specified " + "in " + xmlSource; handleException(msg); } propertyMap.put( prop.getAttribute(new QName(CloudControllerConstants.PROPERTY_NAME_ATTR)) .getAttributeValue(), prop.getAttribute(new QName(CloudControllerConstants.PROPERTY_VALUE_ATTR)) .getAttributeValue()); } }
public ReportParameters[] getReportParam(String reportName) throws ReportingException, XMLStreamException { String reportContent = getReportResources(null, reportName); List<ReportParameters> parameterList = new ArrayList<ReportParameters>(); ReportParameters[] parametersArray; if (reportContent != null) { OMElement reportTemplateOmElement = OMElementHandler.createOMElement(reportContent); if (reportTemplateOmElement != null) { Iterator iterator = reportTemplateOmElement.getChildrenWithName(new QName("parameter")); if (iterator != null) { while (iterator.hasNext()) { ReportParameters parameter = new ReportParameters(); OMElement omElement = (OMElement) iterator.next(); String paramName = omElement.getAttribute(new QName("name")).getAttributeValue(); parameter.setParamName(paramName); String paramValue = omElement.getAttribute(new QName("class")).getAttributeValue(); parameter.setParamValue(paramValue); parameterList.add(parameter); } } } parametersArray = parameterList.toArray(new ReportParameters[parameterList.size()]); } else { log.error("Did not find a report called " + reportName); return null; } return parametersArray; }
private void processKeyStoreElement( OMElement bamServerConfig, BAMServerProfile bamServerProfile) { OMElement keyStoreElement = bamServerConfig.getFirstChildWithName( new QName(BPELConstants.BAM_SERVER_PROFILE_NS, "KeyStore")); if (keyStoreElement != null) { OMAttribute locationAttr = keyStoreElement.getAttribute(new QName("location")); OMAttribute passwordAttr = keyStoreElement.getAttribute(new QName("password")); if (locationAttr != null && passwordAttr != null && !locationAttr.getAttributeValue().equals("") && !passwordAttr.getAttributeValue().equals("")) { bamServerProfile.setKeyStoreLocation(locationAttr.getAttributeValue()); bamServerProfile.setKeyStorePassword(passwordAttr.getAttributeValue()); } else { String errMsg = "Key store details location or password not found for BAM " + "server profile: " + profileLocation; handleError(errMsg); } } else { String errMsg = "Key store element not found for BAM server profile: " + profileLocation; handleError(errMsg); } }
private void processCredentialElement( OMElement bamServerConfig, BAMServerProfile bamServerProfile) throws CryptoException { OMElement credentialElement = bamServerConfig.getFirstChildWithName( new QName(BPELConstants.BAM_SERVER_PROFILE_NS, "Credential")); if (credentialElement != null) { OMAttribute userNameAttr = credentialElement.getAttribute(new QName("userName")); OMAttribute passwordAttr = credentialElement.getAttribute(new QName("password")); // OMAttribute secureAttr = credentialElement.getAttribute(new QName("secure")); if (userNameAttr != null && passwordAttr != null && /*secureAttr != null &&*/ !userNameAttr.getAttributeValue().equals("") && !passwordAttr.getAttributeValue().equals("") /*&& !secureAttr.getAttributeValue().equals("")*/ ) { bamServerProfile.setUserName(userNameAttr.getAttributeValue()); bamServerProfile.setPassword( new String( CryptoUtil.getDefaultCryptoUtil() .base64DecodeAndDecrypt(passwordAttr.getAttributeValue()))); } else { String errMsg = "Username or Password not found for BAM server profile: " + profileLocation; handleError(errMsg); } } else { String errMsg = "Credentials not found for BAM server profile: " + profileLocation; handleError(errMsg); } }
/** * Make sure that the endpoints created by the factory has a name * * @param epConfig OMElement containing the endpoint configuration. * @param anonymousEndpoint false if the endpoint has a name. true otherwise. * @param properties bag of properties to pass in any information to the factory * @return Endpoint implementation for the given configuration. */ private Endpoint createEndpointWithName( OMElement epConfig, boolean anonymousEndpoint, Properties properties) { Endpoint ep = createEndpoint(epConfig, anonymousEndpoint, properties); OMElement descriptionElem = epConfig.getFirstChildWithName(DESCRIPTION_Q); if (descriptionElem != null) { ep.setDescription(descriptionElem.getText()); } // if the endpoint doesn't have a name we will generate a unique name. if (anonymousEndpoint && ep.getName() == null) { String uuid = UIDGenerator.generateUID(); uuid = uuid.replace(':', '_'); ep.setName(ENDPOINT_NAME_PREFIX + uuid); if (ep instanceof AbstractEndpoint) { ((AbstractEndpoint) ep).setAnonymous(true); } } OMAttribute onFaultAtt = epConfig.getAttribute(ON_FAULT_Q); if (onFaultAtt != null) { ep.setErrorHandler(onFaultAtt.getAttributeValue()); } return ep; }
public static Query fromOM(OMElement queryElement) { Query query = new Query(); String name = queryElement.getAttribute(new QName(CEPConstants.CEP_CONF_ATTR_NAME)).getAttributeValue(); query.setName(name); Iterator iterator = queryElement.getChildrenWithName(new QName(CEPConstants.CEP_CONF_QUERY_IP)); while (iterator != null && iterator.hasNext()) { OMElement ipElement = (OMElement) iterator.next(); String ip = ipElement.getText(); query.addIP(ip); } OMElement expressionElement = queryElement.getFirstChildWithName( new QName(CEPConstants.CEP_CONF_NAMESPACE, CEPConstants.CEP_CONF_ELE_EXPRESSION)); if (expressionElement != null) { query.setExpression(ExpressionHelper.fromOM(expressionElement)); } OMElement outputOmElement = queryElement.getFirstChildWithName( new QName(CEPConstants.CEP_CONF_NAMESPACE, CEPConstants.CEP_CONF_ELE_OUTPUT)); if (expressionElement != null && outputOmElement != null) { query.setOutput(OutputHelper.fromOM(outputOmElement)); } return query; }
private void processMessages(Iterator messages, AxisOperation operation) throws DeploymentException { while (messages.hasNext()) { OMElement messageElement = (OMElement) messages.next(); OMAttribute label = messageElement.getAttribute(new QName(TAG_LABEL)); if (label == null) { throw new DeploymentException(Messages.getMessage("messagelabelcannotfound")); } AxisMessage message = operation.getMessage(label.getAttributeValue()); Iterator parameters = messageElement.getChildrenWithName(new QName(TAG_PARAMETER)); // processing <wsp:Policy> .. </..> elements Iterator policyElements = messageElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY)); if (policyElements != null) { processPolicyElements(policyElements, message.getPolicySubject()); } // processing <wsp:PolicyReference> .. </..> elements Iterator policyRefElements = messageElement.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF)); if (policyRefElements != null) { processPolicyRefElements(policyRefElements, message.getPolicySubject()); } processParameters(parameters, message, operation); } }
private OMElement resolveImports( OMElement grammarsElement, String wadlBaseUri, String wadlVersion) throws RegistryException { String wadlNamespace = grammarsElement.getNamespace().getNamespaceURI(); Iterator<OMElement> grammarElements = grammarsElement.getChildrenWithName(new QName(wadlNamespace, "include")); while (grammarElements.hasNext()) { OMElement childElement = grammarElements.next(); OMAttribute refAttr = childElement.getAttribute(new QName("href")); String importUrl = refAttr.getAttributeValue(); if (importUrl.endsWith(".xsd")) { if (!importUrl.startsWith("http")) { if (registry.resourceExists(importUrl)) { continue; } else { if (wadlBaseUri != null) { importUrl = wadlBaseUri + importUrl; } } } String schemaPath = saveSchema(importUrl, wadlVersion); importedSchemas.add(schemaPath); refAttr.setAttributeValue(schemaPath); childElement.addAttribute(refAttr); } } return grammarsElement; }
/** * This static method will be used to build the Target from the specified element * * @param elem - OMElement describing the xml configuration of the target * @return Target built by parsing the given element */ public static Target createTarget(OMElement elem) { if (!TARGET_Q.equals(elem.getQName())) { handleException("Element does not match with the target QName"); } Target target = new Target(); OMAttribute toAttr = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "to")); if (toAttr != null && toAttr.getAttributeValue() != null) { target.setToAddress(toAttr.getAttributeValue()); } OMAttribute soapAction = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "soapAction")); if (soapAction != null && soapAction.getAttributeValue() != null) { target.setSoapAction(soapAction.getAttributeValue()); } OMAttribute sequenceAttr = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "sequence")); if (sequenceAttr != null && sequenceAttr.getAttributeValue() != null) { target.setSequenceRef(sequenceAttr.getAttributeValue()); } OMAttribute endpointAttr = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "endpoint")); if (endpointAttr != null && endpointAttr.getAttributeValue() != null) { target.setEndpointRef(endpointAttr.getAttributeValue()); } OMElement sequence = elem.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "sequence")); if (sequence != null) { SequenceMediatorFactory fac = new SequenceMediatorFactory(); target.setSequence(fac.createAnonymousSequence(sequence)); } OMElement endpoint = elem.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "endpoint")); if (endpoint != null) { target.setEndpoint(EndpointFactory.getEndpointFromElement(endpoint, true)); } return target; }
public void build(OMElement elem) { OMAttribute bean = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "bean")); OMAttribute key = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "key")); if (bean == null) { throw new MediatorException( "The 'bean' attribute is required for a Spring mediator definition"); } else if (key == null) { throw new MediatorException("A 'key' attribute is required for a Spring mediator definition"); } else { // after successfully creating the mediator // set its common attributes such as tracing etc processAuditStatus(this, elem); this.beanName = bean.getAttributeValue(); this.configKey = key.getAttributeValue(); } }
@SuppressWarnings({"UnusedDeclaration"}) public static MessageStore createMessageStore(OMElement elem, Properties properties) { OMAttribute clss = elem.getAttribute(CLASS_Q); MessageStore messageStore; if (clss != null) { String clssName = clss.getAttributeValue(); // Make synapse configuration backward compatible if (Constants.DEPRECATED_INMEMORY_CLASS.equals(clssName)) { clssName = InMemoryStore.class.getName(); } else if (Constants.DEPRECATED_JMS_CLASS.equals(clssName)) { clssName = JmsStore.class.getName(); } try { Class cls = Class.forName(clssName); messageStore = (MessageStore) cls.newInstance(); } catch (Exception e) { handleException("Error while instantiating the message store", e); return null; } } else { messageStore = new InMemoryStore(); } OMAttribute nameAtt = elem.getAttribute(NAME_Q); if (nameAtt != null) { messageStore.setName(nameAtt.getAttributeValue()); } else { handleException("Message Store name not specified"); } OMElement descriptionElem = elem.getFirstChildWithName(DESCRIPTION_Q); if (descriptionElem != null) { messageStore.setDescription(descriptionElem.getText()); } messageStore.setParameters(getParameters(elem)); log.info("Successfully created Message Store: " + nameAtt.getAttributeValue()); return messageStore; }
private void processBAMServerProfileName( OMElement bamServerConfig, BAMServerProfile bamServerProfile) { OMAttribute name = bamServerConfig.getAttribute(new QName("name")); if (name != null) { bamServerProfile.setName(name.getAttributeValue()); } else { String errMsg = "Name attribute not found for BAM server profile: " + profileLocation; handleError(errMsg); } }
/* * process data locator configuration for data retrieval. */ private void processDataLocatorConfig(OMElement dataLocatorElement, AxisService service) { OMAttribute serviceOverallDataLocatorclass = dataLocatorElement.getAttribute(new QName(DRConstants.CLASS_ATTRIBUTE)); if (serviceOverallDataLocatorclass != null) { String className = serviceOverallDataLocatorclass.getAttributeValue(); service.addDataLocatorClassNames(DRConstants.SERVICE_LEVEL, className); } Iterator iterator = dataLocatorElement.getChildrenWithName(new QName(DRConstants.DIALECT_LOCATOR_ELEMENT)); while (iterator.hasNext()) { OMElement locatorElement = (OMElement) iterator.next(); OMAttribute dialect = locatorElement.getAttribute(new QName(DRConstants.DIALECT_ATTRIBUTE)); OMAttribute dialectclass = locatorElement.getAttribute(new QName(DRConstants.CLASS_ATTRIBUTE)); service.addDataLocatorClassNames( dialect.getAttributeValue(), dialectclass.getAttributeValue()); } }
private void processStreamElement(OMElement streamElement, BAMServerProfile bamServerProfile) { OMAttribute nameAttr = streamElement.getAttribute(new QName("name")); OMAttribute versionAttr = streamElement.getAttribute(new QName("version")); OMAttribute nickNameAttr = streamElement.getAttribute(new QName("nickName")); OMAttribute descriptionAttr = streamElement.getAttribute(new QName("description")); if (nameAttr != null && nickNameAttr != null && descriptionAttr != null && !nameAttr.getAttributeValue().equals("") && !nickNameAttr.getAttributeValue().equals("") && !descriptionAttr.getAttributeValue().equals("")) { BAMStreamConfiguration streamConfiguration = new BAMStreamConfiguration( nameAttr.getAttributeValue(), nickNameAttr.getAttributeValue(), descriptionAttr.getAttributeValue(), versionAttr.getAttributeValue()); OMElement dataElement = streamElement.getFirstChildWithName( new QName(BPELConstants.BAM_SERVER_PROFILE_NS, "Data")); if (dataElement == null) { String errMsg = "Data element is not available for BAM server profile: " + profileLocation; handleError(errMsg); } Iterator itr = dataElement.getChildrenWithName(new QName(BPELConstants.BAM_SERVER_PROFILE_NS, "Key")); OMElement keyElement; while (itr.hasNext()) { keyElement = (OMElement) itr.next(); processKeyElement(keyElement, streamConfiguration); } bamServerProfile.addBAMStreamConfiguration( streamConfiguration.getName(), streamConfiguration); } else { String errMsg = "One or many of the attributes of Stream element is not available " + "for BAM server profile: " + profileLocation; handleError(errMsg); } }
private void processConnectionElement( OMElement bamServerConfig, BAMServerProfile bamServerProfile) { OMElement connectionElement = bamServerConfig.getFirstChildWithName( new QName(BPELConstants.BAM_SERVER_PROFILE_NS, "Connection")); if (connectionElement != null) { OMAttribute secureAttr = connectionElement.getAttribute(new QName("secure")); OMAttribute ipAttr = connectionElement.getAttribute(new QName("ip")); OMAttribute authenticationPortAttr = connectionElement.getAttribute(new QName("authPort")); OMAttribute receiverPortAttr = connectionElement.getAttribute(new QName("receiverPort")); if (ipAttr != null && secureAttr != null && authenticationPortAttr != null && receiverPortAttr != null && !ipAttr.getAttributeValue().equals("") && !secureAttr.getAttributeValue().equals("") && !authenticationPortAttr.getAttributeValue().equals("") && !receiverPortAttr.getAttributeValue().equals("")) { bamServerProfile.setIp(ipAttr.getAttributeValue()); if ("true".equals(secureAttr.getAttributeValue())) { bamServerProfile.setSecurityEnabled(true); } else if ("false".equals(secureAttr.getAttributeValue())) { bamServerProfile.setSecurityEnabled(false); } else { String errMsg = "Invalid value found for secure element in BAM server profile: " + profileLocation; handleError(errMsg); } bamServerProfile.setAuthenticationPort(authenticationPortAttr.getAttributeValue()); bamServerProfile.setReceiverPort(receiverPortAttr.getAttributeValue()); } else { String errMsg = "Connection details are missing for BAM server profile: " + profileLocation; handleError(errMsg); } } else { String errMsg = "Connection details not found for BAM server profile: " + profileLocation; handleError(errMsg); } }
private static boolean nodeType(String elementName, OMElement element) throws ManagementConfigurationException { OMAttribute attribute = element.getAttribute(new QName(elementName)); if (attribute != null) { return attribute.getAttributeValue().equalsIgnoreCase("True"); } else { throw new ManagementConfigurationException( "Invalid XML. No attribute with name " + ConfigurationConstants.PROCESSING_MODE_NAME_ATTRIBUTE + " found in file " + ConfigurationConstants.CEP_MANAGEMENT_XML); } }
@Override protected Mediator createSpecificMediator(OMElement elem, Properties properties) { MessageStoreMediator messageStoreMediator = new MessageStoreMediator(); OMAttribute nameAtt = elem.getAttribute(ATT_NAME); if (nameAtt != null) { messageStoreMediator.setName(nameAtt.getAttributeValue()); } OMAttribute messageStoreNameAtt = elem.getAttribute(ATT_MESSAGE_STORE); if (messageStoreNameAtt != null) { messageStoreMediator.setMessageStoreName(messageStoreNameAtt.getAttributeValue()); } else { throw new SynapseException("Message Store mediator must have a Message store defined"); } OMAttribute sequenceAtt = elem.getAttribute(ATT_SEQUENCE); if (sequenceAtt != null) { messageStoreMediator.setOnStoreSequence(sequenceAtt.getAttributeValue()); } return messageStoreMediator; }
@BeforeClass(alwaysRun = true) public void setEnvironment() throws Exception { init(); String urlAxis2Xml = getESBResourceLocation() + "/mediatorconfig/callout/client_repo/conf"; String uriSynapse = getESBResourceLocation() + "/mediatorconfig/callout/ValidPath_Axis2Repo.xml"; OMElement lineItem = AXIOMUtil.stringToOM(FileManager.readFile(uriSynapse)); Iterator sequenceElements = lineItem.getChildElements(); // get all sequence elements while (sequenceElements.hasNext()) { OMElement sequenceElement = (OMElement) sequenceElements.next(); Iterator callOutElements = sequenceElement.getChildrenWithLocalName("callout"); // get all callout elements while (callOutElements.hasNext()) { OMElement callOutElement = (OMElement) callOutElements.next(); Iterator configElments = callOutElement.getChildrenWithLocalName("configuration"); // get configuration elements while (configElments.hasNext()) { OMElement configElment = (OMElement) configElments.next(); // this is the configuration element configElment .getAttribute(new QName("repository")) .setAttributeValue( urlAxis2Xml); // gets the attribute of repository and changes it to a different // path } } } updateESBConfiguration(lineItem); }
protected void processServiceModuleConfig( Iterator moduleConfigs, ParameterInclude parent, AxisService service) throws DeploymentException { while (moduleConfigs.hasNext()) { OMElement moduleConfig = (OMElement) moduleConfigs.next(); OMAttribute moduleName_att = moduleConfig.getAttribute(new QName(ATTRIBUTE_NAME)); if (moduleName_att == null) { throw new DeploymentException( Messages.getMessage(DeploymentErrorMsgs.INVALID_MODULE_CONFIG)); } else { String module = moduleName_att.getAttributeValue(); ModuleConfiguration moduleConfiguration = new ModuleConfiguration(module, parent); Iterator parameters = moduleConfig.getChildrenWithName(new QName(TAG_PARAMETER)); processParameters(parameters, moduleConfiguration, parent); service.addModuleConfig(moduleConfiguration); } } }
/** * Gets the list of modules that is required to be engaged globally. * * @param moduleRefs <code>java.util.Iterator</code> * @throws DeploymentException <code>DeploymentException</code> */ protected void processModuleRefs(Iterator moduleRefs) throws DeploymentException { // try { while (moduleRefs.hasNext()) { OMElement moduleref = (OMElement) moduleRefs.next(); OMAttribute moduleRefAttribute = moduleref.getAttribute(new QName(TAG_REFERENCE)); if (moduleRefAttribute != null) { String refName = moduleRefAttribute.getAttributeValue(); service.addModuleref(refName); // if (axisConfig.getModule(refName) == null) { // throw new DeploymentException(Messages.getMessage( // DeploymentErrorMsgs.MODULE_NOT_FOUND, refName)); // } else { // service.addModuleref(refName); // } } } // } catch (AxisFault axisFault) { // throw new DeploymentException(axisFault); // } }
private static Map<String, Object> getParameters(OMElement elem) { Iterator params = elem.getChildrenWithName(PARAMETER_Q); Map<String, Object> parameters = new HashMap<String, Object>(); while (params.hasNext()) { Object o = params.next(); if (o instanceof OMElement) { OMElement prop = (OMElement) o; OMAttribute paramName = prop.getAttribute(NAME_Q); String paramValue = prop.getText(); if (paramName != null) { if (paramValue != null) { parameters.put(paramName.getAttributeValue(), paramValue); } } else { handleException("Invalid MessageStore parameter - Parameter must have a name "); } } } return parameters; }
void validate_internal_classifications(OMElement e) throws MetadataValidationException, MetadataException { String e_id = e.getAttributeValue(MetadataSupport.id_qname); if (e_id == null || e_id.equals("")) return; for (Iterator it = e.getChildElements(); it.hasNext(); ) { OMElement child = (OMElement) it.next(); OMAttribute classified_object_att = child.getAttribute(MetadataSupport.classified_object_qname); if (classified_object_att != null) { String value = classified_object_att.getAttributeValue(); if (!e_id.equals(value)) { throw new MetadataValidationException( "Classification " + m.getIdentifyingString(child) + "\n is nested inside " + m.getIdentifyingString(e) + "\n but classifies object " + m.getIdentifyingString(value)); } } } }
/** * Populates service from corresponding OM. * * @param service_element an OMElement for the <service> tag * @return a filled-in AxisService, configured from the passed XML * @throws DeploymentException if there is a problem */ public AxisService populateService(OMElement service_element) throws DeploymentException { try { // Determine whether service should be activated. String serviceActivate = service_element.getAttributeValue(new QName(ATTRIBUTE_ACTIVATE)); if (serviceActivate != null) { if ("true".equals(serviceActivate)) { service.setActive(true); } else if ("false".equals(serviceActivate)) { service.setActive(false); } } // Processing service level parameters OMAttribute serviceNameatt = service_element.getAttribute(new QName(ATTRIBUTE_NAME)); // If the service name is explicitly specified in the services.xml // then use that as the service name if (serviceNameatt != null) { if (!"".equals(serviceNameatt.getAttributeValue().trim())) { AxisService wsdlService = wsdlServiceMap.get(serviceNameatt.getAttributeValue()); if (wsdlService != null) { wsdlService.setClassLoader(service.getClassLoader()); wsdlService.setParent(service.getAxisServiceGroup()); service = wsdlService; service.setWsdlFound(true); service.setCustomWsdl(true); } service.setName(serviceNameatt.getAttributeValue()); // To be on the safe side if (service.getDocumentation() == null) { service.setDocumentation(serviceNameatt.getAttributeValue()); } } } Iterator itr = service_element.getChildrenWithName(new QName(TAG_PARAMETER)); processParameters(itr, service, service.getParent()); Parameter childFirstClassLoading = service.getParameter(Constants.Configuration.ENABLE_CHILD_FIRST_CLASS_LOADING); if (childFirstClassLoading != null) { ClassLoader cl = service.getClassLoader(); if (cl instanceof DeploymentClassLoader) { DeploymentClassLoader deploymentClassLoader = (DeploymentClassLoader) cl; if (JavaUtils.isTrueExplicitly(childFirstClassLoading.getValue())) { deploymentClassLoader.setChildFirstClassLoading(true); } else if (JavaUtils.isFalseExplicitly(childFirstClassLoading.getValue())) { deploymentClassLoader.setChildFirstClassLoading(false); } } } // If multiple services in one service group have different values // for the PARENT_FIRST // parameter then the final value become the value specified by the // last service in the group // Parameter parameter = // service.getParameter(DeploymentClassLoader.PARENT_FIRST); // if (parameter !=null && "false".equals(parameter.getValue())) { // ClassLoader serviceClassLoader = service.getClassLoader(); // ((DeploymentClassLoader)serviceClassLoader).setParentFirst(false); // } // process service description OMElement descriptionElement = service_element.getFirstChildWithName(new QName(TAG_DESCRIPTION)); if (descriptionElement != null) { OMElement descriptionValue = descriptionElement.getFirstElement(); if (descriptionValue != null) { service.setDocumentation(descriptionValue); } else { service.setDocumentation(descriptionElement.getText()); } } else { serviceNameatt = service_element.getAttribute(new QName(ATTRIBUTE_NAME)); if (serviceNameatt != null) { if (!"".equals(serviceNameatt.getAttributeValue().trim()) && service.getDocumentation() == null) { service.setDocumentation(serviceNameatt.getAttributeValue()); } } } if (service.getParameter("ServiceClass") == null) { log.debug("The Service " + service.getName() + " does not specify a Service Class"); } // Process WS-Addressing flag attribute OMAttribute addressingRequiredatt = service_element.getAttribute(new QName(ATTRIBUTE_WSADDRESSING)); if (addressingRequiredatt != null) { String addressingRequiredString = addressingRequiredatt.getAttributeValue(); AddressingHelper.setAddressingRequirementParemeterValue(service, addressingRequiredString); } // Setting service target namespace if any OMAttribute targetNameSpace = service_element.getAttribute(new QName(TARGET_NAME_SPACE)); if (targetNameSpace != null) { String nameSpeceVale = targetNameSpace.getAttributeValue(); if (nameSpeceVale != null && !"".equals(nameSpeceVale)) { service.setTargetNamespace(nameSpeceVale); } } else { if (service.getTargetNamespace() == null || "".equals(service.getTargetNamespace())) { service.setTargetNamespace(Java2WSDLConstants.DEFAULT_TARGET_NAMESPACE); } } // Processing service lifecycle attribute OMAttribute serviceLifeCycleClass = service_element.getAttribute(new QName(TAG_CLASS_NAME)); if (serviceLifeCycleClass != null) { String className = serviceLifeCycleClass.getAttributeValue(); loadServiceLifeCycleClass(className); } // Setting schema namespece if any OMElement schemaElement = service_element.getFirstChildWithName(new QName(SCHEMA)); if (schemaElement != null) { OMAttribute schemaNameSpace = schemaElement.getAttribute(new QName(SCHEMA_NAME_SPACE)); if (schemaNameSpace != null) { String nameSpeceVale = schemaNameSpace.getAttributeValue(); if (nameSpeceVale != null && !"".equals(nameSpeceVale)) { service.setSchemaTargetNamespace(nameSpeceVale); } } OMAttribute elementFormDefault = schemaElement.getAttribute(new QName(SCHEMA_ELEMENT_QUALIFIED)); if (elementFormDefault != null) { String value = elementFormDefault.getAttributeValue(); if ("true".equals(value)) { service.setElementFormDefault(true); } else if ("false".equals(value)) { service.setElementFormDefault(false); } } // package to namespace mapping. This will be an element that // maps pkg names to a namespace // when this is doing AxisService.getSchemaTargetNamespace will // be overridden // This will be <mapping/> with @namespace and @package Iterator mappingIterator = schemaElement.getChildrenWithName(new QName(MAPPING)); if (mappingIterator != null) { Map<String, String> pkg2nsMap = new Hashtable<String, String>(); while (mappingIterator.hasNext()) { OMElement mappingElement = (OMElement) mappingIterator.next(); OMAttribute namespaceAttribute = mappingElement.getAttribute(new QName(ATTRIBUTE_NAMESPACE)); OMAttribute packageAttribute = mappingElement.getAttribute(new QName(ATTRIBUTE_PACKAGE)); if (namespaceAttribute != null && packageAttribute != null) { String namespaceAttributeValue = namespaceAttribute.getAttributeValue(); String packageAttributeValue = packageAttribute.getAttributeValue(); if (namespaceAttributeValue != null && packageAttributeValue != null) { pkg2nsMap.put(packageAttributeValue.trim(), namespaceAttributeValue.trim()); } else { log.warn( "Either value of @namespce or @packagename not available. Thus, generated will be selected."); } } else { log.warn( "Either @namespce or @packagename not available. Thus, generated will be selected."); } } service.setP2nMap(pkg2nsMap); } } // processing Default Message receivers OMElement messageReceiver = service_element.getFirstChildWithName(new QName(TAG_MESSAGE_RECEIVERS)); if (messageReceiver != null) { HashMap<String, MessageReceiver> mrs = processMessageReceivers(service.getClassLoader(), messageReceiver); for (Map.Entry<String, MessageReceiver> entry : mrs.entrySet()) { service.addMessageReceiver(entry.getKey(), entry.getValue()); } } // Removing exclude operations OMElement excludeOperations = service_element.getFirstChildWithName(new QName(TAG_EXCLUDE_OPERATIONS)); ArrayList<String> excludeops = null; if (excludeOperations != null) { excludeops = processExcludeOperations(excludeOperations); } if (excludeops == null) { excludeops = new ArrayList<String>(); } Utils.addExcludeMethods(excludeops); // <schema targetNamespace="http://x.y.z"/> // setting the PolicyInclude // processing <wsp:Policy> .. </..> elements Iterator policyElements = service_element.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY)); if (policyElements != null && policyElements.hasNext()) { processPolicyElements(policyElements, service.getPolicySubject()); } // processing <wsp:PolicyReference> .. </..> elements Iterator policyRefElements = service_element.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF)); if (policyRefElements != null && policyRefElements.hasNext()) { processPolicyRefElements(policyRefElements, service.getPolicySubject()); } // processing service scope String sessionScope = service_element.getAttributeValue(new QName(ATTRIBUTE_SCOPE)); if (sessionScope != null) { service.setScope(sessionScope); } // processing service-wide modules which required to engage globally Iterator moduleRefs = service_element.getChildrenWithName(new QName(TAG_MODULE)); processModuleRefs(moduleRefs); // processing transports OMElement transports = service_element.getFirstChildWithName(new QName(TAG_TRANSPORTS)); if (transports != null) { Iterator transport_itr = transports.getChildrenWithName(new QName(TAG_TRANSPORT)); ArrayList<String> trs = new ArrayList<String>(); while (transport_itr.hasNext()) { OMElement trsEle = (OMElement) transport_itr.next(); String transportName = trsEle.getText().trim(); if (axisConfig.getTransportIn(transportName) == null) { log.warn( "Service [ " + service.getName() + "] is trying to expose in a transport : " + transportName + " and which is not available in Axis2"); } else { trs.add(transportName); } } if (trs.isEmpty()) { throw new AxisFault( "Service [" + service.getName() + "] is trying expose in tranpsorts: " + transports + " and which is/are not available in Axis2"); } service.setExposedTransports(trs); } // processing operations Iterator operationsIterator = service_element.getChildrenWithName(new QName(TAG_OPERATION)); ArrayList ops = processOperations(operationsIterator); for (int i = 0; i < ops.size(); i++) { AxisOperation operationDesc = (AxisOperation) ops.get(i); ArrayList wsamappings = operationDesc.getWSAMappingList(); if (wsamappings == null) { continue; } if (service.getOperation(operationDesc.getName()) == null) { service.addOperation(operationDesc); } for (int j = 0; j < wsamappings.size(); j++) { String mapping = (String) wsamappings.get(j); if (mapping.length() > 0) { service.mapActionToOperation(mapping, operationDesc); } } } String objectSupplierValue = (String) service.getParameterValue(TAG_OBJECT_SUPPLIER); if (objectSupplierValue != null) { loadObjectSupplierClass(objectSupplierValue); } // Set the default message receiver for the operations that were // not listed in the services.xml setDefaultMessageReceivers(); Utils.processBeanPropertyExclude(service); if (!service.isUseUserWSDL()) { // Generating schema for the service if the impl class is Java if (!service.isWsdlFound()) { // trying to generate WSDL for the service using JAM and // Java reflection try { if (generateWsdl(service)) { Utils.fillAxisService(service, axisConfig, excludeops, null); } else { ArrayList nonRpcOperations = getNonRPCMethods(service); Utils.fillAxisService(service, axisConfig, excludeops, nonRpcOperations); } } catch (Exception e) { throw new DeploymentException( Messages.getMessage("errorinschemagen", e.getMessage()), e); } } } if (service.isCustomWsdl()) { OMElement mappingElement = service_element.getFirstChildWithName(new QName(TAG_PACKAGE2QNAME)); if (mappingElement != null) { processTypeMappings(mappingElement); } } for (String opName : excludeops) { service.removeOperation(new QName(opName)); } // Need to call the same logic towice setDefaultMessageReceivers(); Iterator moduleConfigs = service_element.getChildrenWithName(new QName(TAG_MODULE_CONFIG)); processServiceModuleConfig(moduleConfigs, service, service); // Loading Data Locator(s) configured OMElement dataLocatorElement = service_element.getFirstChildWithName(new QName(DRConstants.DATA_LOCATOR_ELEMENT)); if (dataLocatorElement != null) { processDataLocatorConfig(dataLocatorElement, service); } processEndpoints(service); processPolicyAttachments(service_element, service); } catch (AxisFault axisFault) { throw new DeploymentException(axisFault); } startupServiceLifecycle(); return service; }
private ArrayList<AxisOperation> processOperations(Iterator operationsIterator) throws AxisFault { ArrayList<AxisOperation> operations = new ArrayList<AxisOperation>(); while (operationsIterator.hasNext()) { OMElement operation = (OMElement) operationsIterator.next(); // getting operation name OMAttribute op_name_att = operation.getAttribute(new QName(ATTRIBUTE_NAME)); if (op_name_att == null) { throw new DeploymentException( Messages.getMessage( Messages.getMessage(DeploymentErrorMsgs.INVALID_OP, "operation name missing"))); } // setting the MEP of the operation OMAttribute op_mep_att = operation.getAttribute(new QName(TAG_MEP)); String mepurl = null; if (op_mep_att != null) { mepurl = op_mep_att.getAttributeValue(); } String opname = op_name_att.getAttributeValue(); AxisOperation op_descrip = null; // getting the namesapce from the attribute. OMAttribute operationNamespace = operation.getAttribute(new QName(ATTRIBUTE_NAMESPACE)); if (operationNamespace != null) { String namespace = operationNamespace.getAttributeValue(); op_descrip = service.getOperation(new QName(namespace, opname)); } if (op_descrip == null) { op_descrip = service.getOperation(new QName(opname)); } if (op_descrip == null) { op_descrip = service.getOperation(new QName(service.getTargetNamespace(), opname)); } if (op_descrip == null) { if (mepurl == null) { // assumed MEP is in-out op_descrip = new InOutAxisOperation(); op_descrip.setParent(service); } else { op_descrip = AxisOperationFactory.getOperationDescription(mepurl); } op_descrip.setName(new QName(opname)); String MEP = op_descrip.getMessageExchangePattern(); if (WSDL2Constants.MEP_URI_IN_ONLY.equals(MEP) || WSDL2Constants.MEP_URI_IN_OPTIONAL_OUT.equals(MEP) || WSDL2Constants.MEP_URI_OUT_OPTIONAL_IN.equals(MEP) || WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY.equals(MEP) || WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(MEP) || WSDL2Constants.MEP_URI_IN_OUT.equals(MEP)) { AxisMessage inaxisMessage = op_descrip.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE); if (inaxisMessage != null) { inaxisMessage.setName(opname + Java2WSDLConstants.MESSAGE_SUFFIX); } } if (WSDL2Constants.MEP_URI_OUT_ONLY.equals(MEP) || WSDL2Constants.MEP_URI_OUT_OPTIONAL_IN.equals(MEP) || WSDL2Constants.MEP_URI_IN_OPTIONAL_OUT.equals(MEP) || WSDL2Constants.MEP_URI_ROBUST_OUT_ONLY.equals(MEP) || WSDL2Constants.MEP_URI_IN_OUT.equals(MEP)) { AxisMessage outAxisMessage = op_descrip.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE); if (outAxisMessage != null) { outAxisMessage.setName(opname + Java2WSDLConstants.RESPONSE); } } } // setting the PolicyInclude // processing <wsp:Policy> .. </..> elements Iterator policyElements = operation.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY)); if (policyElements != null && policyElements.hasNext()) { processPolicyElements(policyElements, op_descrip.getPolicySubject()); } // processing <wsp:PolicyReference> .. </..> elements Iterator policyRefElements = operation.getChildrenWithName(new QName(POLICY_NS_URI, TAG_POLICY_REF)); if (policyRefElements != null && policyRefElements.hasNext()) { processPolicyRefElements(policyRefElements, op_descrip.getPolicySubject()); } // Operation Parameters Iterator parameters = operation.getChildrenWithName(new QName(TAG_PARAMETER)); processParameters(parameters, op_descrip, service); // To process wsamapping; processActionMappings(operation, op_descrip); // loading the message receivers OMElement receiverElement = operation.getFirstChildWithName(new QName(TAG_MESSAGE_RECEIVER)); if (receiverElement != null) { MessageReceiver messageReceiver = loadMessageReceiver(service.getClassLoader(), receiverElement); op_descrip.setMessageReceiver(messageReceiver); } else { // setting default message receiver MessageReceiver msgReceiver = loadDefaultMessageReceiver(op_descrip.getMessageExchangePattern(), service); op_descrip.setMessageReceiver(msgReceiver); } // Process Module Refs Iterator modules = operation.getChildrenWithName(new QName(TAG_MODULE)); processOperationModuleRefs(modules, op_descrip); // processing Messages Iterator messages = operation.getChildrenWithName(new QName(TAG_MESSAGE)); processMessages(messages, op_descrip); // setting Operation phase if (axisConfig != null) { PhasesInfo info = axisConfig.getPhasesInfo(); info.setOperationPhases(op_descrip); } Iterator moduleConfigs = operation.getChildrenWithName(new QName(TAG_MODULE_CONFIG)); processOperationModuleConfig(moduleConfigs, op_descrip, op_descrip); // adding the operation operations.add(op_descrip); } return operations; }
public void build(OMElement elem) { OMAttribute mediaType = elem.getAttribute(ATT_MEDIA); if (mediaType != null) { this.type = mediaType.getAttributeValue(); } OMElement formatElem = elem.getFirstChildWithName(FORMAT_Q); if (formatElem != null) { OMAttribute n = formatElem.getAttribute(ATT_KEY); if (n == null) { if (type != null && (type.contains(JSON_TYPE) || type.contains(TEXT_TYPE))) { this.format = formatElem.getText(); } else { this.format = formatElem.getFirstElement().toString(); } } else { this.formatKey = n.getAttributeValue(); this.dynamic = true; } } else { handleException("format element of payloadFactoryMediator is required"); } OMElement argumentsElem = elem.getFirstChildWithName(ARGS_Q); if (argumentsElem != null) { Iterator itr = argumentsElem.getChildElements(); while (itr.hasNext()) { OMElement argElem = (OMElement) itr.next(); Argument arg = new Argument(); String attrValue; String deepCheckValue; if ((deepCheckValue = argElem.getAttributeValue(ATT_DEEP_CHECK)) != null) { if (deepCheckValue.equalsIgnoreCase("false")) { arg.setDeepCheck(false); } else { arg.setDeepCheck(true); } } if ((attrValue = argElem.getAttributeValue(ATT_VALUE)) != null) { arg.setValue(attrValue); argumentList.add(arg); } else if ((attrValue = argElem.getAttributeValue(ATT_EXPRN)) != null) { if (attrValue.trim().length() == 0) { handleException("Attribute value for expression cannot be empty"); } else { try { String evaluator; if ((evaluator = argElem.getAttributeValue(ATT_EVAL)) != null && evaluator.contains(JSON_TYPE)) { arg.setEvaluator(evaluator); arg.setJsonPath(SynapseJsonPathFactory.getSynapseJsonPath(attrValue)); argumentList.add(arg); } else { if (evaluator != null && evaluator.equals(XML_TYPE)) { arg.setEvaluator(XML_TYPE); } arg.setExpression(SynapseXPathFactory.getSynapseXPath(argElem, ATT_EXPRN)); argumentList.add(arg); } } catch (JaxenException e) { handleException( "Invalid XPath expression for attribute expression : " + attrValue, e); } } } else { handleException("Unsupported arg type or expression attribute required"); } /// argumentList.add(arg); values and args all get added to this. // need to change this part of the cord. } } // set its common attributes such as tracing etc processAuditStatus(this, elem); }
/** * This method is used to load custom security scenarios used inside Identity STS componsnts. * * @throws Exception */ private void loadSecurityScenarios() throws Exception { Registry registry = registryService.getConfigSystemRegistry(); try { // Scenarios are listed in resources/scenario-config.xml URL resource = bundleContext.getBundle().getResource("scenario-config.xml"); XmlConfiguration xmlConfiguration = new XmlConfiguration(resource.openStream(), SecurityConstants.SECURITY_NAMESPACE); OMElement[] elements = xmlConfiguration.getElements("//ns:Scenario"); boolean transactionStarted = Transaction.isStarted(); if (!transactionStarted) { registry.beginTransaction(); } for (OMElement scenarioEle : elements) { SecurityScenario scenario = new SecurityScenario(); String scenarioId = scenarioEle.getAttribute(SecurityConstants.ID_QN).getAttributeValue(); scenario.setScenarioId(scenarioId); scenario.setSummary( scenarioEle.getFirstChildWithName(SecurityConstants.SUMMARY_QN).getText()); scenario.setDescription( scenarioEle.getFirstChildWithName(SecurityConstants.DESCRIPTION_QN).getText()); scenario.setCategory( scenarioEle.getFirstChildWithName(SecurityConstants.CATEGORY_QN).getText()); scenario.setWsuId(scenarioEle.getFirstChildWithName(SecurityConstants.WSUID_QN).getText()); scenario.setType(scenarioEle.getFirstChildWithName(SecurityConstants.TYPE_QN).getText()); OMElement genPolicyElem = scenarioEle.getFirstChildWithName(SecurityConstants.IS_GEN_POLICY_QN); if (genPolicyElem != null && genPolicyElem.getText().equals("false")) { scenario.setGeneralPolicy(false); } String resourceUri = SecurityConstants.SECURITY_POLICY + "/" + scenarioId; for (Iterator modules = scenarioEle.getFirstChildWithName(SecurityConstants.MODULES_QN).getChildElements(); modules.hasNext(); ) { String module = ((OMElement) modules.next()).getText(); scenario.addModule(module); } // Save it in the DB SecurityScenarioDatabase.put(scenarioId, scenario); // Store the scenario in the Registry if (!scenarioId.equals(SecurityConstants.SCENARIO_DISABLE_SECURITY) && !scenarioId.equals(SecurityConstants.POLICY_FROM_REG_SCENARIO)) { Resource scenarioResource = new ResourceImpl(); scenarioResource.setContentStream( bundleContext.getBundle().getResource(scenarioId + "-policy.xml").openStream()); if (!registry.resourceExists(resourceUri)) { registry.put(resourceUri, scenarioResource); } } } if (!transactionStarted) { registry.commitTransaction(); } } catch (Exception e) { registry.rollbackTransaction(); throw e; } }
public List<ServiceContext> getServiceContexts() { List<ServiceContext> serviceContextList = new ArrayList<ServiceContext>(); // services can be found from this XPATH String xpath = CloudControllerConstants.SERVICES_ELEMENT_XPATH; List<?> serviceNodes = getMatchingNodes(xpath, documentElement); if (serviceNodes == null || serviceNodes.isEmpty()) { // or from this XPATH xpath = CloudControllerConstants.SERVICE_ELEMENT_XPATH; serviceNodes = getMatchingNodes(xpath, documentElement); } if (serviceNodes == null || serviceNodes.isEmpty()) { log.warn("No service found in this configuration file : " + xmlSource.getPath()); return serviceContextList; } for (Object obj : serviceNodes) { ServiceContext serviceCtxt = new ServiceContext(); // set the definition file serviceCtxt.setFile(xmlSource); if (obj instanceof OMNode) { OMNode serviceNode = (OMNode) obj; if (serviceNode.getType() == OMNode.ELEMENT_NODE) { OMElement node = (OMElement) serviceNode; if (node.getAttribute(new QName(CloudControllerConstants.SERVICE_DOMAIN_ATTR)) == null) { String msg = "Essential '" + CloudControllerConstants.SERVICE_DOMAIN_ATTR + "' " + "attribute of '" + CloudControllerConstants.SERVICE_ELEMENT + "' element cannot be found in " + xmlSource; handleException(msg); } // set domain name serviceCtxt.setDomainName( node.getAttribute(new QName(CloudControllerConstants.SERVICE_DOMAIN_ATTR)) .getAttributeValue()); // set sub domain serviceCtxt.setSubDomainName( node.getAttribute(new QName(CloudControllerConstants.SERVICE_SUB_DOMAIN_ATTR)) .getAttributeValue()); // set tenant range serviceCtxt.setTenantRange( node.getAttribute(new QName(CloudControllerConstants.SERVICE_TENANT_RANGE_ATTR)) .getAttributeValue()); OMNode cartridgeNode = getFirstMatchingNode(xpath + CloudControllerConstants.CARTRIDGE_ELEMENT_XPATH, node); if (cartridgeNode != null && cartridgeNode.getType() == OMNode.ELEMENT_NODE) { OMElement cartridgeElt = (OMElement) cartridgeNode; String type = cartridgeElt .getAttribute(new QName(CloudControllerConstants.TYPE_ATTR)) .getAttributeValue(); if ("".equals(type)) { String msg = "Essential '" + CloudControllerConstants.TYPE_ATTR + "' " + " attribute of '" + CloudControllerConstants.CARTRIDGE_ELEMENT + "' of '" + CloudControllerConstants.SERVICE_ELEMENT + "' element cannot be found in " + xmlSource; handleException(msg); } // set Cartridge type serviceCtxt.setCartridgeType(type); } if (serviceCtxt.getCartridgeType() == null) { String msg = "Essential '" + CloudControllerConstants.CARTRIDGE_ELEMENT + "' element" + " has not specified in " + xmlSource; handleException(msg); } // load payload loadPayload( getMatchingNodes(xpath + CloudControllerConstants.PAYLOAD_ELEMENT_XPATH, node), serviceCtxt); // load host name loadHostName( getMatchingNodes(xpath + CloudControllerConstants.HOST_ELEMENT_XPATH, node), serviceCtxt); // load properties loadProperties(node, serviceCtxt.getProperties()); } } FasterLookUpDataHolder.getInstance().addServiceContext(serviceCtxt); // add each domain specific template to list serviceContextList.add(serviceCtxt); } return serviceContextList; }
private IaasProvider getIaasProvider(final OMNode item, List<IaasProvider> iaases) { IaasProvider iaas = null; if (item.getType() == OMNode.ELEMENT_NODE) { OMElement iaasElt = (OMElement) item; if (iaases != null) { // check whether this is a reference to a predefined IaaS. for (IaasProvider iaasProvider : iaases) { if (iaasProvider .getType() .equals( iaasElt .getAttribute(new QName(CloudControllerConstants.TYPE_ATTR)) .getAttributeValue())) { iaas = new IaasProvider(iaasProvider); break; } } } if (iaas == null) { iaas = new IaasProvider(); } if (iaas.getType() == null) { iaas.setType( iaasElt .getAttribute(new QName(CloudControllerConstants.TYPE_ATTR)) .getAttributeValue()); } if ("".equals(iaas.getType())) { String msg = "'" + CloudControllerConstants.IAAS_PROVIDER_ELEMENT + "' element's '" + CloudControllerConstants.TYPE_ATTR + "' attribute should be specified!"; handleException(msg); } // this is not mandatory String name = (iaasElt.getAttribute(new QName(CloudControllerConstants.NAME_ATTR)) == null) ? iaas.getName() : iaasElt.getAttributeValue(new QName(CloudControllerConstants.NAME_ATTR)); iaas.setName(name); String xpath = CloudControllerConstants.IAAS_PROVIDER_ELEMENT_XPATH; // load other elements loadClassName(iaas, iaasElt); loadMaxInstanceLimit(iaas, iaasElt); loadProperties(iaasElt, iaas.getProperties()); loadTemplate(iaas, iaasElt); loadScalingOrders(iaas, iaasElt); loadProvider(iaas, iaasElt); loadIdentity(iaas, iaasElt); loadCredentials(iaas, iaasElt, xpath); } return iaas; }
/** * Sets content of the given WSDL artifact to the given resource on the registry. * * @param wsdl the WSDL artifact. * @param wsdlResource the content resource. * @throws GovernanceException if the operation failed. */ protected void setContent(Wsdl wsdl, Resource wsdlResource) throws GovernanceException { if (wsdl.getWsdlElement() != null) { OMElement contentElement = wsdl.getWsdlElement().cloneOMElement(); try { for (String importType : new String[] {"import", "include"}) { List<OMElement> wsdlImports = GovernanceUtils.evaluateXPathToElements("//wsdl:" + importType, contentElement); for (OMElement wsdlImport : wsdlImports) { OMAttribute location = wsdlImport.getAttribute(new QName("location")); if (location != null) { String path = location.getAttributeValue(); if (path.indexOf(";version:") > 0) { location.setAttributeValue(path.substring(0, path.lastIndexOf(";version:"))); } } } } for (String importType : new String[] {"import", "include", "redefine"}) { List<OMElement> schemaImports = GovernanceUtils.evaluateXPathToElements("//xsd:" + importType, contentElement); for (OMElement schemaImport : schemaImports) { OMAttribute location = schemaImport.getAttribute(new QName("schemaLocation")); if (location != null) { String path = location.getAttributeValue(); if (path.indexOf(";version:") > 0) { location.setAttributeValue(path.substring(0, path.lastIndexOf(";version:"))); } } } } } catch (JaxenException ignore) { } String wsdlContent = contentElement.toString(); try { wsdlResource.setContent(wsdlContent); } catch (RegistryException e) { String msg = "Error in setting the content from wsdl, wsdl id: " + wsdl.getId() + ", wsdl path: " + wsdl.getPath() + "."; log.error(msg, e); throw new GovernanceException(msg, e); } } // and set all the attributes as properties. String[] attributeKeys = wsdl.getAttributeKeys(); if (attributeKeys != null) { Properties properties = new Properties(); for (String attributeKey : attributeKeys) { String[] attributeValues = wsdl.getAttributes(attributeKey); if (attributeValues != null) { // The list obtained from the Arrays#asList method is // immutable. Therefore, // we create a mutable object out of it before adding it as // a property. properties.put(attributeKey, new ArrayList<String>(Arrays.asList(attributeValues))); } } wsdlResource.setProperties(properties); } wsdlResource.setUUID(wsdl.getId()); }
/** {@inheritDoc} */ public void build(OMElement elem) { getList().clear(); OMAttribute attRemoteServiceUri = elem.getAttribute(PROP_NAME_SERVICE_EPR); OMAttribute attRemoteServiceUserName = elem.getAttribute(PROP_NAME_USER); OMAttribute attRemoteServicePassword = elem.getAttribute(PROP_NAME_PASSWORD); OMAttribute attCallbackClass = elem.getAttribute(PROP_NAME_CALLBACK_CLASS); OMAttribute attThriftHost = elem.getAttribute(PROP_NAME_THRIFT_HOST); OMAttribute attThriftPort = elem.getAttribute(PROP_NAME_THRIFT_PORT); OMAttribute attClient = elem.getAttribute(PROP_NAME_CLIENT_CLASS); this.onAcceptSeqKey = null; this.onRejectSeqKey = null; this.adviceSeqKey = null; this.obligationsSeqKey = null; if (attRemoteServiceUri != null) { remoteServiceUrl = attRemoteServiceUri.getAttributeValue(); } else { throw new MediatorException( "The 'remoteServiceUrl' attribute is required for the Entitlement mediator"); } if (attRemoteServiceUserName != null) { remoteServiceUserName = attRemoteServiceUserName.getAttributeValue(); } else { throw new MediatorException( "The 'remoteServiceUserName' attribute is required for the Entitlement mediator"); } if (attRemoteServicePassword != null) { remoteServicePassword = attRemoteServicePassword.getAttributeValue(); } else { throw new MediatorException( "The 'remoteServicePassword' attribute is required for the Entitlement mediator"); } if (attCallbackClass != null) { callbackClass = attCallbackClass.getAttributeValue(); } if (attClient != null) { client = attClient.getAttributeValue(); } if (attThriftHost != null) { thriftHost = attThriftHost.getAttributeValue(); } if (attThriftPort != null) { thriftPort = attThriftPort.getAttributeValue(); } OMAttribute onReject = elem.getAttribute( new QName(XMLConfigConstants.NULL_NAMESPACE, XMLConfigConstants.ONREJECT)); if (onReject != null) { String onRejectValue = onReject.getAttributeValue(); if (onRejectValue != null) { onRejectSeqKey = onRejectValue.trim(); } } else { OMElement onRejectMediatorElement = elem.getFirstChildWithName( new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, XMLConfigConstants.ONREJECT)); if (onRejectMediatorElement != null) { OnRejectMediator onRejectMediator = new OnRejectMediator(); onRejectMediator.build(onRejectMediatorElement); addChild(onRejectMediator); } } OMAttribute onAccept = elem.getAttribute( new QName(XMLConfigConstants.NULL_NAMESPACE, XMLConfigConstants.ONACCEPT)); if (onAccept != null) { String onAcceptValue = onAccept.getAttributeValue(); if (onAcceptValue != null) { onAcceptSeqKey = onAcceptValue; } } else { OMElement onAcceptMediatorElement = elem.getFirstChildWithName( new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, XMLConfigConstants.ONACCEPT)); if (onAcceptMediatorElement != null) { OnAcceptMediator onAcceptMediator = new OnAcceptMediator(); onAcceptMediator.build(onAcceptMediatorElement); addChild(onAcceptMediator); } } OMAttribute advice = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, ADVICE)); if (advice != null) { String adviceValue = advice.getAttributeValue(); if (adviceValue != null) { adviceSeqKey = adviceValue; } } else { OMElement adviceMediatorElement = elem.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, ADVICE)); if (adviceMediatorElement != null) { AdviceMediator adviceMediator = new AdviceMediator(); adviceMediator.build(adviceMediatorElement); addChild(adviceMediator); } } OMAttribute obligations = elem.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, OBLIGATIONS)); if (obligations != null) { String obligationsValue = obligations.getAttributeValue(); if (obligationsValue != null) { onAcceptSeqKey = obligationsValue; } } else { OMElement obligationsMediatorElement = elem.getFirstChildWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, OBLIGATIONS)); if (obligationsMediatorElement != null) { ObligationsMediator obligationsMediator = new ObligationsMediator(); obligationsMediator.build(obligationsMediatorElement); addChild(obligationsMediator); } } }