/* * <LocalAndOutboundAuthenticationConfig> <AuthenticationSteps></AuthenticationSteps> * <AuthenticationType></AuthenticationType> * <AuthenticationStepForSubject></AuthenticationStepForSubject> * <AuthenticationStepForAttributes></AuthenticationStepForAttributes> * </LocalAndOutboundAuthenticationConfig> */ public static LocalAndOutboundAuthenticationConfig build( OMElement localAndOutboundAuthenticationConfigOM) { LocalAndOutboundAuthenticationConfig localAndOutboundAuthenticationConfig = new LocalAndOutboundAuthenticationConfig(); if (localAndOutboundAuthenticationConfigOM == null) { return localAndOutboundAuthenticationConfig; } Iterator<?> iter = localAndOutboundAuthenticationConfigOM.getChildElements(); while (iter.hasNext()) { OMElement member = (OMElement) iter.next(); if (member.getLocalName().equals("AuthenticationSteps")) { Iterator<?> authenticationStepsIter = member.getChildElements(); ArrayList<AuthenticationStep> authenticationStepsArrList = new ArrayList<AuthenticationStep>(); if (authenticationStepsIter != null) { while (authenticationStepsIter.hasNext()) { OMElement authenticationStepsElement = (OMElement) (authenticationStepsIter.next()); AuthenticationStep authStep = AuthenticationStep.build(authenticationStepsElement); if (authStep != null) { authenticationStepsArrList.add(authStep); } } } if (authenticationStepsArrList.size() > 0) { AuthenticationStep[] authenticationStepsArr = authenticationStepsArrList.toArray(new AuthenticationStep[0]); localAndOutboundAuthenticationConfig.setAuthenticationSteps(authenticationStepsArr); } } else if (member.getLocalName().equals("AuthenticationType")) { localAndOutboundAuthenticationConfig.setAuthenticationType(member.getText()); } else if (member.getLocalName().equals("AuthenticationStepForSubject")) { AuthenticationStep authStep = AuthenticationStep.build(member); if (authStep != null) { localAndOutboundAuthenticationConfig.setAuthenticationStepForSubject(authStep); } } else if (member.getLocalName().equals("AuthenticationStepForAttributes")) { AuthenticationStep authStep = AuthenticationStep.build(member); if (authStep != null) { localAndOutboundAuthenticationConfig.setAuthenticationStepForAttributes(authStep); } } else if (member.getLocalName().equals("alwaysSendBackAuthenticatedListOfIdPs")) { if (member.getText() != null && "true".equals(member.getText())) { localAndOutboundAuthenticationConfig.setAlwaysSendBackAuthenticatedListOfIdPs(true); } } else if (member.getLocalName().equals("subjectClaimUri")) { localAndOutboundAuthenticationConfig.setSubjectClaimUri(member.getText()); } } return localAndOutboundAuthenticationConfig; }
public void addIds( String strOperation, String strParamName, MessageContext synCtx, SynapseLog synLog) { SOAPEnvelope envelope = synCtx.getEnvelope(); OMFactory fac = OMAbstractFactory.getOMFactory(); SOAPBody body = envelope.getBody(); Iterator<OMElement> bodyChildElements = body.getChildrenWithLocalName(strOperation); if (bodyChildElements.hasNext()) { try { OMElement bodyElement = bodyChildElements.next(); Iterator<OMElement> cElements = bodyElement.getChildElements(); if (cElements != null && cElements.hasNext()) { cElements.next(); } String strSobject = (String) ConnectorUtils.lookupTemplateParamater(synCtx, strParamName); OMElement sObjects = AXIOMUtil.stringToOM(strSobject); Iterator<OMElement> sObject = sObjects.getChildElements(); OMNamespace omNsurn = fac.createOMNamespace("urn:partner.soap.sforce.com", "urn"); // Loops sObject while (sObject.hasNext()) { OMElement currentElement = sObject.next(); OMElement newElement = fac.createOMElement("ids", omNsurn); // Add the fields newElement.addChild(fac.createOMText(currentElement.getText())); bodyElement.addChild(newElement); } } catch (Exception e) { synLog.error("Saleforce adaptor - error injecting sObjects to payload : " + e); } } }
/** * this method creates the platform object * * @param nodeElement OMElement input from the xml reader */ public void createPlatformContext(OMElement nodeElement) { Iterator instanceGroupIterator = nodeElement.getChildElements(); OMElement instanceGroupNode; // Walk through the instance group list while (instanceGroupIterator.hasNext()) { ProductGroup productGroup = new ProductGroup(); instanceGroupNode = (OMElement) instanceGroupIterator.next(); // set the attributes of the current instance group String groupName = instanceGroupNode.getAttributeValue( QName.valueOf(ContextConstants.PLATFORM_CONTEXT_INSTANCE_GROUP_NAME)); Boolean clusteringEnabled = Boolean.parseBoolean( instanceGroupNode.getAttributeValue( QName.valueOf( ContextConstants.PLATFORM_CONTEXT_INSTANCE_GROUP_CLUSTERING_ENABLED))); productGroup.setGroupName(groupName); productGroup.setClusteringEnabled(clusteringEnabled); // walk through the instances in the instance group Iterator instances = instanceGroupNode.getChildElements(); OMElement instanceNode; while (instances.hasNext()) { // adding the instance to the instance group instanceNode = (OMElement) instances.next(); createInstance(instanceNode, productGroup); // addInstanceToTypeList(currentInstance, productGroup); } platformContext.addProductGroup(productGroup); } }
public void addSobjects( String strOperation, String strParamName, MessageContext synCtx, SynapseLog synLog, String strExternalId) { SOAPEnvelope envelope = synCtx.getEnvelope(); OMFactory fac = OMAbstractFactory.getOMFactory(); SOAPBody body = envelope.getBody(); Iterator<OMElement> bodyChildElements = body.getChildrenWithLocalName(strOperation); if (bodyChildElements.hasNext()) { try { OMElement bodyElement = bodyChildElements.next(); if (strExternalId != null) { OMNamespace omNs = fac.createOMNamespace("urn:partner.soap.sforce.com", "urn"); OMElement value = fac.createOMElement("externalIDFieldName", omNs); value.addChild(fac.createOMText(strExternalId)); bodyElement.addChild(value); } String strSobject = (String) ConnectorUtils.lookupTemplateParamater(synCtx, strParamName); OMElement sObjects = AXIOMUtil.stringToOM(strSobject); Iterator<OMElement> sObject = sObjects.getChildElements(); String strType = sObjects.getAttributeValue(new QName(SalesforceUtil.SALESFORCE_CREATE_SOBJECTTYPE)); OMElement tmpElement = null; OMNamespace omNsurn = fac.createOMNamespace("urn:partner.soap.sforce.com", "urn"); OMNamespace omNsurn1 = fac.createOMNamespace("urn:sobject.partner.soap.sforce.com", "urn1"); // Loops sObject while (sObject.hasNext()) { OMElement currentElement = sObject.next(); OMElement newElement = fac.createOMElement("sObjects", omNsurn); // Add Object type if (strType != null) { tmpElement = fac.createOMElement("type", omNsurn1); tmpElement.addChild(fac.createOMText(strType)); newElement.addChild(tmpElement); } // Add the fields Iterator<OMElement> sObjectFields = currentElement.getChildElements(); while (sObjectFields.hasNext()) { OMElement sObjectField = sObjectFields.next(); tmpElement = fac.createOMElement(sObjectField.getLocalName(), omNsurn1); tmpElement.addChild(fac.createOMText(sObjectField.getText())); newElement.addChild(tmpElement); } bodyElement.addChild(newElement); } } catch (Exception e) { synLog.error("Saleforce adaptor - error injecting sObjects to payload : " + e); } } }
public void parse(OMElement paramsTag) { if (log.isDebugEnabled() || log.isTraceEnabled()) { log.debug("Parse params"); } ValueFactory valueFactory = new ValueFactory(); this.type = paramsTag.getLocalName(); for (Iterator iterator = paramsTag.getChildElements(); iterator.hasNext(); ) { OMElement param = (OMElement) iterator.next(); if (AuditMediatorUtils.isTag(param, AuditMediatorUtils.PARAM_TAG_NAME)) { String name = param.getAttributeValue(AuditMediatorUtils.NAME_ATT_QNAME); Value value = valueFactory.createValue(AuditMediatorUtils.VALUE_ATT_NAME, param); if (StringUtils.isBlank(name) || value == null) { log.error("Error, attributes name and value required"); break; } params.add(new Param(name, value)); } else { log.error( "Unable to create the Audit mediator. " + "Unexpected element: " + param + " inside the Params TAG of Audit mediator configuration"); } } }
/* * <JustInTimeProvisioningConfig> <UserStoreClaimUri></UserStoreClaimUri> * <ProvisioningUserStore></ProvisioningUserStore> <ProvisioningEnabled></ProvisioningEnabled> * </JustInTimeProvisioningConfig> */ public static JustInTimeProvisioningConfig build(OMElement justInTimeProvisioningConfigOM) { JustInTimeProvisioningConfig justInTimeProvisioningConfig = new JustInTimeProvisioningConfig(); if (justInTimeProvisioningConfigOM == null) { return justInTimeProvisioningConfig; } Iterator<?> iter = justInTimeProvisioningConfigOM.getChildElements(); while (iter.hasNext()) { OMElement element = (OMElement) (iter.next()); String elementName = element.getLocalName(); if ("UserStoreClaimUri".equals(elementName)) { justInTimeProvisioningConfig.setUserStoreClaimUri(element.getText()); } else if ("ProvisioningUserStore".equals(elementName)) { justInTimeProvisioningConfig.setProvisioningUserStore(element.getText()); } else if ("IsProvisioningEnabled".equals(elementName)) { if (element.getText() != null && element.getText().trim().length() > 0) { justInTimeProvisioningConfig.setProvisioningEnabled( Boolean.parseBoolean(element.getText())); } } } return justInTimeProvisioningConfig; }
/** * Sends multiple entries of type Entry to the service. * * @param entries The entries to send. * @return The responses. * @exception FailureFaultException If an error communication with the service occurs. */ public String[] store(Entry[] entries) throws FailureFaultException { final String method = "store"; // Create a request OMElement request = XMLUtil.createScoreElements("StoreRequest", method, entries); // Print debug if system property "debug.messages" is set. printDebug("REQUEST", request); // Configure connection Options options = new Options(); options.setTo(new EndpointReference(url.toString())); options.setTransportInProtocol(Constants.TRANSPORT_HTTP); options.setAction(method); // Create a client try { ServiceClient client = new ServiceClient(); client.setOptions(options); // Could throw AxisFault OMElement response = client.sendReceive(request); // Debug printDebug("RESPONSE", response); // Return possible results from elements of type: // <xsd:element name="StoreResponse" type="tns:StoreResponseType"/> // StoreResponseType = <xsd:simpleType name="StoreResponseType"/> ArrayList<String> resultList = new ArrayList<String>(); @SuppressWarnings("unchecked") // Doesn't support generics Iterator<OMElement> elementIterator = response.getChildElements(); while (elementIterator.hasNext()) { OMElement ge = elementIterator.next(); @SuppressWarnings("unchecked") // Doesn't support generics Iterator<OMElement> it = ge.getChildElements(); String responseText = it.next().getText(); resultList.add(responseText); } String[] result = new String[resultList.size()]; resultList.toArray(result); return result; } catch (AxisFault e) { throw new FailureFaultException("Exception from service: ", e); } }
public void setSmartLifecycleLinks(OMElement locationConfiguration) throws RegistryException { Iterator confElements = locationConfiguration.getChildElements(); while (confElements.hasNext()) { OMElement confElement = (OMElement) confElements.next(); if (confElement.getQName().equals(new QName("key"))) { smartLifecycleLinks.add(confElement.getText()); } } }
public static boolean validateJsonEventMapping(OMElement omElement) { int count = 0; Iterator<OMElement> mappingIterator = omElement.getChildElements(); while (mappingIterator.hasNext()) { count++; mappingIterator.next(); } return count != 0; }
public void deserialize(OMElement throttlingConfigEle) throws ThrottlingException { OMElement throttlingManagerConfigs = null; Iterator childElements = throttlingConfigEle.getChildElements(); while (childElements.hasNext()) { Object configChildElement = childElements.next(); if (!(configChildElement instanceof OMElement)) { continue; } OMElement configChildOMElement = (OMElement) configChildElement; if (new QName(CONFIG_NS, "ThrottlingManagerTask", "") .equals(configChildOMElement.getQName())) { throttlingManagerConfigs = (OMElement) configChildElement; } } // Iterator throttlingConfigChildIt = throttlingConfigEle.getChildElements(); Iterator throttlingConfigChildIt = throttlingManagerConfigs.getChildElements(); while (throttlingConfigChildIt.hasNext()) { Object throttlingConfigChild = throttlingConfigChildIt.next(); if (!(throttlingConfigChild instanceof OMElement)) { continue; } OMElement throttlingConfigChildEle = (OMElement) throttlingConfigChild; if (new QName(CONFIG_NS, "tasks", "").equals(throttlingConfigChildEle.getQName())) { throttlingTaskConfigs = new ArrayList<ThrottlingTaskConfiguration>(); tasks = new ArrayList<Task>(); Iterator tasksConfigChildIt = throttlingConfigChildEle.getChildElements(); while (tasksConfigChildIt.hasNext()) { Object taskConfigChild = tasksConfigChildIt.next(); if (!(taskConfigChild instanceof OMElement)) { continue; } ThrottlingTaskConfiguration taskConfiguration = new ThrottlingTaskConfiguration((OMElement) taskConfigChild); throttlingTaskConfigs.add(taskConfiguration); tasks.add(taskConfiguration.getTask()); } } } }
public static FederatedAuthenticatorConfig build(OMElement federatedAuthenticatorConfigOM) { if (federatedAuthenticatorConfigOM == null) { return null; } FederatedAuthenticatorConfig federatedAuthenticatorConfig = new FederatedAuthenticatorConfig(); Iterator<?> iter = federatedAuthenticatorConfigOM.getChildElements(); while (iter.hasNext()) { OMElement element = (OMElement) (iter.next()); String elementName = element.getLocalName(); if ("Name".equals(elementName)) { federatedAuthenticatorConfig.setName(element.getText()); } else if ("DisplayName".equals(elementName)) { federatedAuthenticatorConfig.setDisplayName(element.getText()); } else if ("IsEnabled".equals(elementName)) { federatedAuthenticatorConfig.setEnabled(Boolean.parseBoolean(element.getText())); } else if ("Properties".equals(elementName)) { Iterator<?> propertiesIter = element.getChildElements(); List<Property> propertiesArrList = new ArrayList<Property>(); if (propertiesIter != null) { while (propertiesIter.hasNext()) { OMElement propertiesElement = (OMElement) (propertiesIter.next()); propertiesArrList.add(Property.build(propertiesElement)); } } if (CollectionUtils.isNotEmpty(propertiesArrList)) { Property[] propertiesArr = propertiesArrList.toArray(new Property[0]); federatedAuthenticatorConfig.setProperties(propertiesArr); } } } return federatedAuthenticatorConfig; }
/** * Replaces the payload format with property values from messageContext. * * @param format * @param resultCTX * @param synCtx */ private void replaceCTX(String format, StringBuffer resultCTX, MessageContext synCtx) { Matcher ctxMatcher; if (mediaType != null && (mediaType.equals(JSON_TYPE) || mediaType.equals(TEXT_TYPE))) { ctxMatcher = ctxPattern.matcher(format); } else { ctxMatcher = ctxPattern.matcher("<pfPadding>" + format + "</pfPadding>"); } while (ctxMatcher.find()) { String ctxMatchSeq = ctxMatcher.group(); String expressionTxt = ctxMatchSeq.substring(5, ctxMatchSeq.length()); String replaceValue = synCtx.getProperty(expressionTxt).toString(); if (mediaType.equals(JSON_TYPE) && inferReplacementType(replaceValue).equals(XML_TYPE)) { // XML to JSON conversion here try { replaceValue = "<jsonObject>" + replaceValue + "</jsonObject>"; OMElement omXML = AXIOMUtil.stringToOM(replaceValue); replaceValue = JsonUtil.toJsonString(omXML).toString(); } catch (XMLStreamException e) { handleException( "Error parsing XML for JSON conversion, please check your property values return valid XML: ", synCtx); } catch (AxisFault e) { handleException("Error converting XML to JSON", synCtx); } } else if (mediaType.equals(XML_TYPE) && inferReplacementType(replaceValue).equals(JSON_TYPE)) { // JSON to XML conversion here try { OMElement omXML = JsonUtil.toXml(IOUtils.toInputStream(replaceValue), false); if (JsonUtil.isAJsonPayloadElement(omXML)) { // remove <jsonObject/> from result. Iterator children = omXML.getChildElements(); String childrenStr = ""; while (children.hasNext()) { childrenStr += (children.next()).toString().trim(); } replaceValue = childrenStr; } else { replaceValue = omXML.toString(); } } catch (AxisFault e) { handleException( "Error converting JSON to XML, please check your property values return valid JSON: ", synCtx); } } ctxMatcher.appendReplacement(resultCTX, replaceValue); } ctxMatcher.appendTail(resultCTX); }
private boolean authenticateRemotely( String username, String password, String applicationName, AppFactoryConfiguration configuration) { try { String EPR = configuration.getFirstProperty("ServerUrls.AppFactory") + "RepositoryAuthenticationService"; // Create a service client ServiceClient client = new ServiceClient(); // Set the endpoint address client.getOptions().setTo(new EndpointReference(EPR)); client.getOptions().setAction("hasAccess"); CarbonUtils.setBasicAccessSecurityHeaders(username, password, client); // Make the request and get the response String payload = " <p:hasAccess xmlns:p=\"http://service.mgt.repository.appfactory.carbon.wso2.org\">\n" + " <!--0 to 1 occurrence-->\n" + " <xs:username xmlns:xs=\"http://service.mgt.repository.appfactory.carbon.wso2.org\">" + username + "</xs:username>\n" + " <!--0 to 1 occurrence-->\n" + " <xs:applicationId xmlns:xs=\"http://service.mgt.repository.appfactory.carbon.wso2.org\">" + applicationName + "</xs:applicationId>\n" + " </p:hasAccess>"; OMElement result = client.sendReceive( new StAXOMBuilder(new ByteArrayInputStream(payload.getBytes())).getDocumentElement()); Iterator iterator = result.getChildElements(); if (iterator.hasNext()) { OMElement object = (OMElement) iterator.next(); if (object.getText().equals("true")) { return true; } } } catch (AxisFault e) { e.printStackTrace(); } catch (XMLStreamException e) { } return false; }
private static boolean validateMapEventMapping(OMElement omElement) { int count = 0; Iterator<OMElement> mappingIterator = omElement.getChildElements(); while (mappingIterator.hasNext()) { OMElement childElement = mappingIterator.next(); String childTag = childElement.getLocalName(); if (!childTag.equals(EventFormatterConstants.EF_ELE_PROPERTY)) { return false; } count++; } return count != 0; }
public Property[] getProperties(QName parameter) throws IllegalArgumentException { OMElement e = _element.getFirstChildWithName(parameter); if (e == null) throw new IllegalArgumentException("Missing properties parameter: " + parameter); Iterator<OMElement> iter = e.getChildElements(); ArrayList<Property> props = new ArrayList<Property>(); while (iter.hasNext()) { OMElement prop = iter.next(); OMElement name = prop.getFirstChildWithName(Constants.NAME); if (name == null) throw new IllegalArgumentException("Missing property name: " + prop); OMElement value = prop.getFirstChildWithName(Constants.VALUE); if (value == null) throw new IllegalArgumentException("Missing property value: " + prop); props.add(new Property(name.getText(), value.getText())); } return props.toArray(new Property[props.size()]); }
@SuppressWarnings("unchecked") public static Map<String, String> extractProperties(OMElement propsParentEl) { Map<String, String> properties = new HashMap<String, String>(); OMElement propEl = null; Iterator<OMElement> itr = propsParentEl.getChildrenWithName(new QName(DBSFields.PROPERTY)); String text; while (itr.hasNext()) { propEl = itr.next(); if (propEl.getChildElements().hasNext()) { text = propEl.toString(); } else { text = propEl.getText(); } if (text != null && !text.equals("")) { properties.put(propEl.getAttributeValue(new QName(DBSFields.NAME)), text); } } return properties; }
@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); }
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)); } } } }
private void sendMultipleEvents(Object obj) { if (obj instanceof OMElement) { OMElement events = (OMElement) obj; if (eventBuilderConfiguration.isTraceEnabled()) { trace.info("[Event-Builder] Received batch of events as OMElement.\n" + events.toString()); } Iterator childIterator = events.getChildElements(); while (childIterator.hasNext()) { Object eventObj = childIterator.next(); sendEvent(eventObj); /** * Usually the global lookup '//' is used in the XPATH expression which works fine for * 'single event mode'. However, if global lookup is used, it will return the first element * from the whole document as specified in XPATH-2.0 Specification. Therefore the same XPATH * expression that works fine in 'single event mode' will always return the first element of * a batch in 'batch mode'. Therefore to return what the user expects, each child element is * removed after sending to simulate an iteration for the global lookup. */ childIterator.remove(); } } }
private NotificationConfig loadeNotificationConfig(String configFilename) { NotificationConfig config = new NotificationConfig(); File configFile = new File(configFilename); if (!configFile.exists()) { log.error("Configuration File is not present at: " + configFilename); return null; } try { XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(new FileInputStream(configFile)); StAXOMBuilder builder = new StAXOMBuilder(parser); OMElement documentElement = builder.getDocumentElement(); OMElement notificationConfig = documentElement.getFirstChildWithName(new QName("notificationConfiguration")); if (notificationConfig != null) { // registry.xml need an <notificationConfiguration> // </notificationConfiguration> entry to continue Iterator it = notificationConfig.getChildElements(); while (it.hasNext()) { OMElement element = (OMElement) it.next(); if ("class".equals(element.getLocalName())) { config.setConfigurationClass(element.getText()); } else if ("storeURL".equals(element.getLocalName())) { config.setStoreURL(element.getText()); } else if ("publisherURL".equals(element.getLocalName())) { config.setPublisherURL(element.getText()); } else if ("consoleURL".equals(element.getLocalName())) { config.setConsoleURL(element.getText()); } } } return config; } catch (Exception e) { String msg = "Error in loading configuration : " + configFilename + "."; log.error(msg, e); return null; } }
private Object readObject(ParameterType paramType, OMElement node, boolean client) throws Exception { switch (paramType.getType()) { case BOOLEAN: case DOUBLE: case FLOAT: case INT: case LONG: case STRING: case ENUM: case DATE: case BYTE: return node == null ? null : readSimpleObject(paramType, node.getLocalName(), node.getText(), client); case OBJECT: // descend - note possibly two levels if inside a collection recursion OMElement _copy = this.currentNode; currentNode = node; Transcribable t = (Transcribable) paramType.getImplementationClass().newInstance(); t.transcribe(this, TranscribableParams.getAll(), client); // ascend this.currentNode = _copy; return t; case MAP: Map map = new HashMap(); for (Iterator i = node.getChildElements(); i.hasNext(); ) { OMElement element = (OMElement) i.next(); Object key = readSimpleObject( paramType.getComponentTypes()[0], node.getLocalName(), element.getAttributeValue(keyAttName), client); map.put( key, readObject( paramType.getComponentTypes()[1], (OMElement) element.getChildElements().next(), client)); } return map; case LIST: if (paramType.getComponentTypes()[0].getType() == ParameterType.Type.BYTE) { try { return Base64Utils.decode(node.getText()); } catch (Exception e) { String message = "Unable to parse " + node.getText() + " as type " + paramType; logger.log(Level.FINER, message, e); throw CougarMarshallingException.unmarshallingException("soap", message, e, client); } } else { List list = new ArrayList(); for (Iterator i = node.getChildElements(); i.hasNext(); ) { list.add(readObject(paramType.getComponentTypes()[0], (OMElement) i.next(), client)); } return list; } case SET: Set set = new HashSet(); for (Iterator i = node.getChildElements(); i.hasNext(); ) { set.add(readObject(paramType.getComponentTypes()[0], (OMElement) i.next(), client)); } return set; } return null; }
/* this method create and returns the instance object */ protected void createInstance(OMElement instanceNode, ProductGroup productGroup) { Instance instance = new Instance(); String instanceName = instanceNode.getAttributeValue( QName.valueOf(ContextConstants.PLATFORM_CONTEXT_INSTANCE_NAME)); String instanceType = instanceNode.getAttributeValue( QName.valueOf(ContextConstants.PLATFORM_CONTEXT_INSTANCE_TYPE)); String instancePortType = instanceNode.getAttributeValue( QName.valueOf(ContextConstants.PLATFORM_CONTEXT_INSTANCE_PORT_TYPE)); instance.setName(instanceName); instance.setType(instanceType); instance.setServicePortType(instancePortType); Iterator instancePropertiesIterator = instanceNode.getChildElements(); OMElement instancePropertyNode; while (instancePropertiesIterator.hasNext()) { instancePropertyNode = (OMElement) instancePropertiesIterator.next(); // set the attribute values of the current instance String attribute = instancePropertyNode.getLocalName(); String attributeValue = instancePropertyNode.getText(); // set the property values of the current instance if (attribute.equals(ContextConstants.PLATFORM_CONTEXT_INSTANCE_HOST)) { instance.setHost(attributeValue); } else if (attribute.equals(ContextConstants.PLATFORM_CONTEXT_INSTANCE_HTTP_PORT)) { instance.setHttpPort(attributeValue); } else if (attribute.equals(ContextConstants.PLATFORM_CONTEXT_INSTANCE_HTTPS_PORT)) { instance.setHttpsPort(attributeValue); } else if (attribute.equals(ContextConstants.PLATFORM_CONTEXT_INSTANCE_WEB_CONTEXT)) { instance.setWebContext(attributeValue); } else if (attribute.equals(ContextConstants.PLATFORM_CONTEXT_INSTANCE_NHTTP_PORT)) { instance.setNhttpPort(attributeValue); } else if (attribute.equals(ContextConstants.PLATFORM_CONTEXT_INSTANCE_NHTTPS_PORT)) { instance.setNhttpsPort(attributeValue); } // add all the properties to the Map structure // this handles the unknown properties add by the user instance.addProperty(attribute, attributeValue); } if (instance.getType().equals(InstanceTypes.lb_worker_manager.name())) { LBWorkerManagerInstance lbWorkerManagerInstance = new LBWorkerManagerInstance(instance); lbWorkerManagerInstance.setWorkerHost( instance.getPropertyByKey(ContextConstants.PLATFORM_CONTEXT_INSTANCE_WORKER_HOST)); lbWorkerManagerInstance.setManagerHost( instance.getPropertyByKey(ContextConstants.PLATFORM_CONTEXT_INSTANCE_MANAGER_HOST)); productGroup.addLBWorkerManagerInstance(lbWorkerManagerInstance); } else if (instance.getType().equals(InstanceTypes.lb_worker.name())) { LBWorkerInstance lbWorkerInstance = new LBWorkerInstance(instance); lbWorkerInstance.setWorkerHost( instance.getPropertyByKey(ContextConstants.PLATFORM_CONTEXT_INSTANCE_WORKER_HOST)); productGroup.addLBWorkerInstance(lbWorkerInstance); } else if (instance.getType().equals(InstanceTypes.lb_manager.name())) { LBManagerInstance lbManagerInstance = new LBManagerInstance(instance); lbManagerInstance.setManagerHost( instance.getPropertyByKey(ContextConstants.PLATFORM_CONTEXT_INSTANCE_MANAGER_HOST)); productGroup.addLBManagerInstance(lbManagerInstance); } else if (instance.getType().equals(InstanceTypes.standalone.name())) { productGroup.addStandaloneInstance(instance); } else if (instance.getType().equals(InstanceTypes.manager.name())) { productGroup.addManagerInstance(instance); } else if (instance.getType().equals(InstanceTypes.worker.name())) { productGroup.addWorkerInstance(instance); } else if (instance.getType().equals(InstanceTypes.lb.name())) { productGroup.addLBInstance(instance); } }
/** * Replaces the payload format with SynapsePath arguments which are evaluated using * getArgValues(). * * @param format * @param result * @param synCtx */ private void replace(String format, StringBuffer result, MessageContext synCtx) { HashMap<String, String>[] argValues = getArgValues(synCtx); HashMap<String, String> replacement; Map.Entry<String, String> replacementEntry; String replacementValue = null; Matcher matcher; matcher = pattern.matcher(format); try { while (matcher.find()) { String matchSeq = matcher.group(); int argIndex; try { argIndex = Integer.parseInt(matchSeq.substring(1, matchSeq.length())); } catch (NumberFormatException e) { argIndex = Integer.parseInt(matchSeq.substring(2, matchSeq.length() - 1)); } replacement = argValues[argIndex - 1]; replacementEntry = replacement.entrySet().iterator().next(); if (mediaType.equals(JSON_TYPE) && inferReplacementType(replacementEntry).equals(XML_TYPE)) { // XML to JSON conversion here try { replacementValue = "<jsonObject>" + replacementEntry.getKey() + "</jsonObject>"; OMElement omXML = AXIOMUtil.stringToOM(replacementValue); replacementValue = JsonUtil.toJsonString(omXML) .toString() .replaceAll( ESCAPE_DOUBLE_QUOTE_WITH_FIVE_BACK_SLASHES, ESCAPE_DOUBLE_QUOTE_WITH_NINE_BACK_SLASHES) .replaceAll( ESCAPE_DOLLAR_WITH_TEN_BACK_SLASHES, ESCAPE_DOLLAR_WITH_SIX_BACK_SLASHES); replacementValue = JsonUtil.toJsonString(omXML).toString(); } catch (XMLStreamException e) { handleException( "Error parsing XML for JSON conversion, please check your xPath expressions return valid XML: ", synCtx); } catch (AxisFault e) { handleException("Error converting XML to JSON", synCtx); } } else if (mediaType.equals(XML_TYPE) && inferReplacementType(replacementEntry).equals(JSON_TYPE)) { // JSON to XML conversion here try { OMElement omXML = JsonUtil.toXml(IOUtils.toInputStream(replacementEntry.getKey()), false); if (JsonUtil.isAJsonPayloadElement(omXML)) { // remove <jsonObject/> from result. Iterator children = omXML.getChildElements(); String childrenStr = ""; while (children.hasNext()) { childrenStr += (children.next()).toString().trim(); } replacementValue = childrenStr; } else { /// ~ replacementValue = omXML.toString(); } // replacementValue = omXML.toString(); } catch (AxisFault e) { handleException( "Error converting JSON to XML, please check your JSON Path expressions return valid JSON: ", synCtx); } } else { // No conversion required, as path evaluates to regular String. replacementValue = replacementEntry.getKey(); // This is to replace " with \" and \\ with \\\\ if (mediaType.equals(JSON_TYPE) && inferReplacementType(replacementEntry).equals(STRING_TYPE) && (!replacementValue.startsWith("{") && !replacementValue.startsWith("["))) { replacementValue = replacementValue .replaceAll( Matcher.quoteReplacement("\\\\"), ESCAPE_BACK_SLASH_WITH_SIXTEEN_BACK_SLASHES) .replaceAll("\"", ESCAPE_DOUBLE_QUOTE_WITH_TEN_BACK_SLASHES); } else if ((mediaType.equals(JSON_TYPE) && inferReplacementType(replacementEntry).equals(JSON_TYPE)) && (!replacementValue.startsWith("{") && !replacementValue.startsWith("["))) { // This is to handle only the string value replacementValue = replacementValue.replaceAll("\"", ESCAPE_DOUBLE_QUOTE_WITH_TEN_BACK_SLASHES); } } matcher.appendReplacement(result, replacementValue); } } catch (ArrayIndexOutOfBoundsException e) { log.error("#replace. Mis-match detected between number of formatters and arguments", e); } matcher.appendTail(result); }
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); }
private static DistributedConfiguration getDistributedConfiguration(OMElement processingElement) { DistributedConfiguration stormDeploymentConfig = new DistributedConfiguration(); // Reading storm managers OMElement management = processingElement.getFirstChildWithName( new QName(ConfigurationConstants.MANAGEMENT_ELEMENT)); OMElement managers = management.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_MANAGERS_ELEMENT)); Iterator<OMElement> iterator = managers.getChildElements(); if (!iterator.hasNext()) { try { String hostName = Utils.findAddress("localhost"); int port = 8904; stormDeploymentConfig.addManager(hostName, port); log.info( "No storm managers are provided. Hence automatically electing " + hostName + ":" + port + " node as " + "manager"); } catch (SocketException e) { log.error( "Error while automatically populating storm managers. Please check the event-processor.xml" + " at CARBON_HOME/repository/conf", e); return null; } } while (iterator.hasNext()) { OMElement manager = iterator.next(); String hostName = manager .getFirstChildWithName(new QName(ConfigurationConstants.HOST_NAME_ELEMENT)) .getText(); int port = Integer.parseInt( manager .getFirstChildWithName(new QName(ConfigurationConstants.PORT_ELEMENT)) .getText()); stormDeploymentConfig.addManager(hostName, port); } if (management.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_HEARTBEAT_INTERVAL_ELEMENT)) != null) { stormDeploymentConfig.setManagementHeartbeatInterval( Integer.parseInt( management .getFirstChildWithName( new QName( ConfigurationConstants .DISTRIBUTED_NODE_CONFIG_HEARTBEAT_INTERVAL_ELEMENT)) .getText())); } else { log.info( "No heartbeat interval provided. Hence using default heartbeat interval " + stormDeploymentConfig.getManagementHeartbeatInterval()); } if (management.getFirstChildWithName( new QName(ConfigurationConstants.RECONNECTION_INTERVAL_ELEMENT)) != null) { stormDeploymentConfig.setManagementReconnectInterval( Integer.parseInt( management .getFirstChildWithName( new QName(ConfigurationConstants.RECONNECTION_INTERVAL_ELEMENT)) .getText())); } else { log.info( "No reconnection interval provided. Hence using default reconnection interval " + stormDeploymentConfig.getManagementReconnectInterval()); } if (management.getFirstChildWithName( new QName( ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_TOPOLOGY_RESUBMIT_INTERVAL_ELEMENT)) != null) { stormDeploymentConfig.setTopologySubmitRetryInterval( Integer.parseInt( management .getFirstChildWithName( new QName( ConfigurationConstants .DISTRIBUTED_NODE_CONFIG_TOPOLOGY_RESUBMIT_INTERVAL_ELEMENT)) .getText())); } else { log.info( "No topology resubmit interval provided. Hence using default topology resubmit interval " + stormDeploymentConfig.getTopologySubmitRetryInterval()); } // Reading transport OMElement transport = processingElement.getFirstChildWithName( new QName(ConfigurationConstants.TRANSPORT_ELEMENT)); OMElement portRange = transport.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_PORT_RANGE_ELEMENT)); if (portRange != null) { stormDeploymentConfig.setTransportMaxPort( Integer.parseInt(portRange.getFirstChildWithName(new QName("max")).getText())); stormDeploymentConfig.setTransportMinPort( Integer.parseInt(portRange.getFirstChildWithName(new QName("min")).getText())); } else { log.info( "No port information provided. Hence using default port range " + stormDeploymentConfig.getTransportMinPort() + " - " + stormDeploymentConfig.getTransportMaxPort()); } if (transport.getFirstChildWithName( new QName(ConfigurationConstants.RECONNECTION_INTERVAL_ELEMENT)) != null) { stormDeploymentConfig.setTransportReconnectInterval( Integer.parseInt( transport .getFirstChildWithName( new QName(ConfigurationConstants.RECONNECTION_INTERVAL_ELEMENT)) .getText())); } else { log.info( "No transport reconnection interval provided. Hence using default reconnection interval " + stormDeploymentConfig.getTransportReconnectInterval()); } if (transport.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_CEP_RECEIVER_QUEUE_SIZE)) != null) { int queueSize = Integer.parseInt( transport .getFirstChildWithName( new QName( ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_CEP_RECEIVER_QUEUE_SIZE)) .getText()); if (isPowerOfTwo(queueSize)) { stormDeploymentConfig.setCepReceiverOutputQueueSize(queueSize); } else { // Disruptor queue size only allows powers of two throw new IllegalArgumentException( ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_CEP_RECEIVER_QUEUE_SIZE + " must be a power of two."); } } else { log.info( "No CEP receiver output queue size specified. Hence using default queue size " + stormDeploymentConfig.getCepReceiverOutputQueueSize()); } if (transport.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_STORM_PUBLISHER_QUEUE_SIZE)) != null) { int queueSize = Integer.parseInt( transport .getFirstChildWithName( new QName( ConfigurationConstants .DISTRIBUTED_NODE_CONFIG_STORM_PUBLISHER_QUEUE_SIZE)) .getText()); if (isPowerOfTwo(queueSize)) { stormDeploymentConfig.setStormPublisherOutputQueueSize(queueSize); } else { // Disruptor queue size only allows powers of two throw new IllegalArgumentException( ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_CEP_RECEIVER_QUEUE_SIZE + " must be a power of two."); } } else { log.info( "No storm publisher output queue size specified. Hence using default queue size " + stormDeploymentConfig.getStormPublisherOutputQueueSize()); } if (transport.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_TCP_PUBLISHER_BUFFER_SIZE)) != null) { int bufferSize = Integer.parseInt( transport .getFirstChildWithName( new QName( ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_TCP_PUBLISHER_BUFFER_SIZE)) .getText()); stormDeploymentConfig.setTransportPublisherTcpSendBufferSize(bufferSize); } else { log.info( "No TCP publisher buffer size not specified. Hence using default buffer size " + stormDeploymentConfig.getTransportPublisherTcpSendBufferSize()); } if (transport.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_TCP_PUBLISHER_CHAR_SET)) != null) { String tcpEventPublisherCharSet = transport .getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_TCP_PUBLISHER_CHAR_SET)) .getText(); stormDeploymentConfig.setTransportPublisherCharSet(tcpEventPublisherCharSet); } else { log.info( "TCP event publisher Char-Set not set. Hence using default value " + stormDeploymentConfig.getTransportPublisherCharSet()); } if (transport.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_STORM_SPOUT_BUFFER_SIZE)) != null) { int bufferSize = Integer.parseInt( transport .getFirstChildWithName( new QName( ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_STORM_SPOUT_BUFFER_SIZE)) .getText()); stormDeploymentConfig.setStormSpoutBufferSize(bufferSize); } else { log.info( "No Storm Spout buffer size not specified. Hence using default buffer size " + stormDeploymentConfig.getStormSpoutBufferSize()); } if (transport.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_CON_STATUS_CHECK_INTERVAL)) != null) { int connectionStatusCheckInterval = Integer.parseInt( transport .getFirstChildWithName( new QName( ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_CON_STATUS_CHECK_INTERVAL)) .getText()); stormDeploymentConfig.setTransportPublisherConnectionStatusCheckInterval( connectionStatusCheckInterval); } else { log.info( "No transport connection status check interval specified. Hence using default interval " + stormDeploymentConfig.getTransportPublisherConnectionStatusCheckInterval() + "ms"); } // Reading node info OMElement node = processingElement.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_ELEMENT)); if (node != null) { OMElement worker = node.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_WORKER_ELEMENT)); if ("true" .equalsIgnoreCase( worker.getAttributeValue(new QName(ConfigurationConstants.ENABLE_ATTRIBUTE)))) { stormDeploymentConfig.setWorkerNode(true); } OMElement manager = node.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_MANAGER_ELEMENT)); if ("true" .equalsIgnoreCase( manager.getAttributeValue(new QName(ConfigurationConstants.ENABLE_ATTRIBUTE)))) { stormDeploymentConfig.setManagerNode(true); String hostName = manager .getFirstChildWithName(new QName(ConfigurationConstants.HOST_NAME_ELEMENT)) .getText(); int port = Integer.parseInt( manager .getFirstChildWithName(new QName(ConfigurationConstants.PORT_ELEMENT)) .getText()); stormDeploymentConfig.setLocalManagerConfig(hostName, port); } OMElement presenter = node.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_PRESENTER_ELEMENT)); if ("true" .equalsIgnoreCase( presenter.getAttributeValue(new QName(ConfigurationConstants.ENABLE_ATTRIBUTE)))) { stormDeploymentConfig.setPresenterNode(true); String hostName = presenter .getFirstChildWithName(new QName(ConfigurationConstants.HOST_NAME_ELEMENT)) .getText(); int port = Integer.parseInt( presenter .getFirstChildWithName(new QName(ConfigurationConstants.PORT_ELEMENT)) .getText()); stormDeploymentConfig.setLocalPresenterConfig(hostName, port); } } else { log.info( "No node type configurations provided. Hence using default node type configurations"); } OMElement distributedUI = processingElement.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_DISTRIBUTED_UI_URL_ELEMENT)); if (distributedUI != null) { String url = distributedUI.getText(); stormDeploymentConfig.setDistributedUIUrl(url); } OMElement memberUpdateCheckInterval = processingElement.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_MEMBER_UPDATE_CHECK_INTERVAL)); if (memberUpdateCheckInterval != null) { int interval = Integer.parseInt(memberUpdateCheckInterval.getText()); stormDeploymentConfig.setMemberUpdateCheckInterval(interval); } else { log.info( "No member update check interval specified. Hence using default interval " + stormDeploymentConfig.getMemberUpdateCheckInterval()); } // Get Jar name OMElement jar = processingElement.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_STORM_JAR_ELEMENT)); stormDeploymentConfig.setJar(jar.getText()); OMElement presentation = processingElement.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_PRESENTATION_ELEMENT)); if (presentation != null) { if (presentation.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_PRESENTER_QUEUE_SIZE)) != null) { int queueSize = Integer.parseInt( presentation .getFirstChildWithName( new QName( ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_PRESENTER_QUEUE_SIZE)) .getText()); if (isPowerOfTwo(queueSize)) { stormDeploymentConfig.setPresentationOutputQueueSize(queueSize); } else { // Disruptor queue size only allows powers of two throw new IllegalArgumentException( ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_PRESENTER_QUEUE_SIZE + " must be a power of two."); } } else { log.info( "No presentation output queue size provided. Hence using default queue size " + stormDeploymentConfig.getPresentationOutputQueueSize()); } if (presentation.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_TCP_PUBLISHER_BUFFER_SIZE)) != null) { int bufferSize = Integer.parseInt( transport .getFirstChildWithName( new QName( ConfigurationConstants .DISTRIBUTED_NODE_CONFIG_TCP_PUBLISHER_BUFFER_SIZE)) .getText()); stormDeploymentConfig.setPresentationPublisherTcpSendBufferSize(bufferSize); } else { log.info( "No TCP publisher buffer size not specified for presenter. Hence using default buffer size " + stormDeploymentConfig.getPresentationPublisherTcpSendBufferSize()); } if (presentation.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_TCP_PUBLISHER_CHAR_SET)) != null) { String tcpEventPublisherCharSet = transport .getFirstChildWithName( new QName( ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_TCP_PUBLISHER_CHAR_SET)) .getText(); stormDeploymentConfig.setPresentationPublisherCharSet(tcpEventPublisherCharSet); } else { log.info( "TCP event publisher Char-Set not set for presenter. Hence using default value " + stormDeploymentConfig.getPresentationPublisherCharSet()); } if (presentation.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_CON_STATUS_CHECK_INTERVAL)) != null) { int connectionStatusCheckInterval = Integer.parseInt( transport .getFirstChildWithName( new QName( ConfigurationConstants .DISTRIBUTED_NODE_CONFIG_CON_STATUS_CHECK_INTERVAL)) .getText()); stormDeploymentConfig.setPresentationPublisherConnectionStatusCheckInterval( connectionStatusCheckInterval); } else { log.info( "No transport connection status check interval specified for presenter. Hence using default interval " + stormDeploymentConfig.getPresentationPublisherConnectionStatusCheckInterval() + "ms"); } } else { log.info("No presentation configurations provided. Hence using default configurations"); } // Reading Status Monitor Info OMElement statusMonitor = processingElement.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_STATUS_MONITOR_ELEMENT)); if (statusMonitor != null) { OMElement lockTimeoutElement = statusMonitor.getFirstChildWithName( new QName( ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_STATUS_MONITOR_LOCK_TIMEOUT)); if (lockTimeoutElement != null) { int lockTimeout = Integer.parseInt(lockTimeoutElement.getText()); stormDeploymentConfig.setStatusLockTimeout(lockTimeout); } else { log.info( "No lockTimeout value specified in Status Monitor configurations. Hence using default lock timeout value: " + stormDeploymentConfig.getStatusLockTimeout() + " seconds."); } OMElement updateRateElement = statusMonitor.getFirstChildWithName( new QName(ConfigurationConstants.DISTRIBUTED_NODE_CONFIG_STATUS_MONITOR_UPDATE_RATE)); if (updateRateElement != null) { int updateRate = Integer.parseInt(updateRateElement.getText()); stormDeploymentConfig.setStatusUpdateInterval(updateRate); } else { log.info( "No updateRate value specified in Status Monitor configurations. Hence using default update rate: " + stormDeploymentConfig.getStatusUpdateInterval() + " milliseconds."); } } else { log.info( "No Status Monitor configurations provided. Hence using default Status Monitor configurations. Lock timeout: " + stormDeploymentConfig.getStatusLockTimeout() + " seconds, Update rate: " + stormDeploymentConfig.getStatusUpdateInterval() + " milliseconds."); } return stormDeploymentConfig; }