Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMElement


            }

            Iterator messageStores = FileUtils.iterateFiles(messageStoresDir, extensions, false);
            while (messageStores.hasNext()) {
                File file = (File) messageStores.next();
                OMElement document = getOMElement(file);
                MessageStore messageStore = SynapseXMLConfigurationFactory.defineMessageStore(
                        synapseConfig, document, properties);
                if (messageStore != null) {
                    messageStore.setFileName(file.getName());
                    synapseConfig.getArtifactDeploymentStore().addArtifact(file.getAbsolutePath(),
View Full Code Here


            }

            Iterator messageProcessors = FileUtils.iterateFiles(messageProcessorDir, extensions, false);
            while (messageProcessors.hasNext()) {
                File file = (File) messageProcessors.next();
                OMElement document = getOMElement(file);
                MessageProcessor messageProcessor = SynapseXMLConfigurationFactory.defineMessageProcessor(
                        synapseConfig, document, properties);
                if (messageProcessor != null) {
                    messageProcessor.setFileName(file.getName());
                    synapseConfig.getArtifactDeploymentStore().addArtifact(file.getAbsolutePath(),
View Full Code Here

    }


    private static OMElement getOMElement(File file) {
        FileInputStream is;
        OMElement document = null;

        try {
            is = FileUtils.openInputStream(file);
        } catch (IOException e) {
            handleException("Error while opening the file: " + file.getName() + " for reading", e);
            return null;
        }

        try {
            document = OMXMLBuilderFactory.createOMBuilder(is).getDocumentElement();
            document.build();
            is.close();
        } catch (OMException e) {
            handleException("Error while parsing the content of the file: " + file.getName(), e);
        } catch (IOException e) {
            log.warn("Error while closing the input stream from the file: " + file.getName(), e);
View Full Code Here

                String soap = (String) o;
                try {
                    XMLStreamReader xmlReader =
                            StAXUtils.createXMLStreamReader(new ByteArrayInputStream(soap.getBytes()));
                    StAXBuilder builder = new StAXSOAPModelBuilder(xmlReader);
                    OMElement elem = builder.getDocumentElement();
                    elem.build();
                    if (elem instanceof SOAPEnvelope) {
                        SOAPEnvelope soapEnvelope = (SOAPEnvelope) elem;
                        String soapNamespace = soapEnvelope.getNamespace().getNamespaceURI();
                        if (soapEnvelope.getHeader() == null) {
                            SOAPFactory soapFactory;
                            if (soapNamespace.equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
                                soapFactory = OMAbstractFactory.getSOAP12Factory();
                            } else {
                                soapFactory = OMAbstractFactory.getSOAP11Factory();
                            }
                            soapFactory.createSOAPHeader(soapEnvelope);
                        }
                        sourceNodeList.add(soapEnvelope);
                    } else {
                        sourceNodeList.add(elem);
                    }
                } catch (XMLStreamException e) {
                    synLog.error("Source Property cannot be parsed : " + e.getStackTrace().toString());
                }
            } else if (o instanceof ArrayList) {
                ArrayList nodesList = (ArrayList) o;
                for (Object node : nodesList) {
                    if (node instanceof OMElement) {
                        if (node instanceof SOAPEnvelope) {
                            SOAPEnvelope soapEnvelope = (SOAPEnvelope) node;
                            String soapNamespace = null;

                            if (soapEnvelope.getNamespace() != null) {
                                soapNamespace = soapEnvelope.getNamespace().getNamespaceURI();
                            }
                            if (soapEnvelope.getHeader() == null && soapNamespace != null) {
                                SOAPFactory soapFactory;
                                if (soapNamespace.equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
                                    soapFactory = OMAbstractFactory.getSOAP12Factory();
                                } else {
                                    soapFactory = OMAbstractFactory.getSOAP11Factory();
                                }
                                soapFactory.createSOAPHeader(soapEnvelope);
                            }
                            sourceNodeList.add(soapEnvelope);
                        } else {
                            OMElement ele = (OMElement) node;
                            sourceNodeList.add(ele);
                        }
                    } else if (node instanceof OMText) {
                        sourceNodeList.add((OMText) node);
                    }
                }
            } else {
                synLog.error("Invalid source property type.");
            }
        } else if (sourceType == EnrichMediator.INLINE) {
            if (inlineOMNode instanceof OMElement) {
                OMElement inlineOMElement = (OMElement) inlineOMNode;
                if (inlineOMElement.getQName().getLocalPart().equals("Envelope")) {
                    SOAPEnvelope soapEnvelope = getSOAPEnvFromOM(inlineOMElement);
                    if (soapEnvelope != null) {
                        sourceNodeList.add(soapEnvelope);
                    } else {
                        synLog.error("Inline Source is not a valid SOAPEnvelope.");
                    }
                } else {
                    sourceNodeList.add(inlineOMElement.cloneOMElement());
                }
            } else if (inlineOMNode instanceof OMText) {
                sourceNodeList.add(inlineOMNode);
            } else if (inlineKey != null) {
                Object inlineObj = synCtx.getEntry(inlineKey);
View Full Code Here

            handleException("Unsupported mediator passed in for serialization : " + m.getType());
            return null;
        }

        URLRewriteMediator mediator = (URLRewriteMediator) m;
        OMElement rewrite = fac.createOMElement("rewrite", synNS);       
       
        String inProperty = mediator.getInputProperty();
        String outProperty = mediator.getOutputProperty();
       
        if (inProperty != null) {
          rewrite.addAttribute(fac.createOMAttribute("inProperty", nullNS,
                                                        inProperty));
        }
        if (outProperty != null) {
          rewrite.addAttribute(fac.createOMAttribute("outProperty", nullNS,
                                                        outProperty));
        }

        saveTracingState(rewrite, mediator);
       
        List<RewriteRule> rules = mediator.getRules();
        try {
            for (RewriteRule r : rules) {
                OMElement rule = serializeRule(r);
                rewrite.addChild(rule);
            }
        } catch (EvaluatorException e) {
            handleException("Error while serializing the rewrite rule", e);
        }
View Full Code Here

        return rewrite;
    }

    private OMElement serializeRule(RewriteRule r) throws EvaluatorException {
        OMElement rule = fac.createOMElement("rewriterule", synNS);
        Evaluator condition = r.getCondition();
        if (condition != null) {
            OMElement conditionElt = fac.createOMElement("condition", synNS);
            EvaluatorSerializer serializer = EvaluatorSerializerFinder.getInstance().
                    getSerializer(condition.getName());
            serializer.serialize(conditionElt, condition);
            rule.addChild(conditionElt);
        }

        List<RewriteAction> actions = r.getActions();
        for (RewriteAction a : actions) {
            OMElement action = serializeAction(a);
            rule.addChild(action);
        }

        return rule;
    }
View Full Code Here

        return rule;
    }

    private OMElement serializeAction(RewriteAction a) {
        OMElement action = fac.createOMElement("action", synNS);
        if (a.getValue() != null) {
            action.addAttribute("value", a.getValue(), null);
        } else if (a.getXpath() != null) {
            action.addAttribute("xpath", a.getXpath().toString(), null);
        }

        if (a.getRegex() != null) {
            action.addAttribute("regex", a.getRegex(), null);
        }

        int type = a.getActionType();
        String typeStr;
        switch (type) {
            case RewriteAction.ACTION_APPEND:
                typeStr = URLRewriteMediatorFactory.ACTION_APPEND;
                break;

            case RewriteAction.ACTION_PREPEND:
                typeStr = URLRewriteMediatorFactory.ACTION_PREPEND;
                break;

            case RewriteAction.ACTION_REPLACE:
                typeStr = URLRewriteMediatorFactory.ACTION_REPLACE;
                break;

            case RewriteAction.ACTION_REMOVE:
                typeStr = URLRewriteMediatorFactory.ACTION_REMOVE;
                break;

            default:
                typeStr = URLRewriteMediatorFactory.ACTION_SET;
        }
        action.addAttribute("type", typeStr, null);

        int fragment = a.getFragmentIndex();
        String fragmentStr;
        switch (fragment) {
            case URIFragments.PROTOCOL:
                fragmentStr = URLRewriteMediatorFactory.FRAGMENT_PROTOCOL;
                break;

            case URIFragments.USER_INFO:
                fragmentStr = URLRewriteMediatorFactory.FRAGMENT_USER_INFO;
                break;

            case URIFragments.HOST:
                fragmentStr = URLRewriteMediatorFactory.FRAGMENT_HOST;
                break;

            case URIFragments.PORT:
                fragmentStr = URLRewriteMediatorFactory.FRAGMENT_PORT;
                break;

            case URIFragments.PATH:
                fragmentStr = URLRewriteMediatorFactory.FRAGMENT_PATH;
                break;

            case URIFragments.QUERY:
                fragmentStr = URLRewriteMediatorFactory.FRAGMENT_QUERY;
                break;

            case URIFragments.REF:
                fragmentStr = URLRewriteMediatorFactory.FRAGMENT_REF;
                break;

            default:
                fragmentStr = URLRewriteMediatorFactory.FRAGMENT_FULL_URI;
        }
        action.addAttribute("fragment", fragmentStr, null);
       
        return action;
    }
View Full Code Here

        if (wsRMEnabled) {
            // if a WS-RM policy is specified, use it
            if (wsRMPolicyKey != null) {
                Object property = synapseOutMessageContext.getEntry(wsRMPolicyKey);
                if (property instanceof OMElement) {
                    OMElement policyOMElement = (OMElement) property;
                    RMAssertionBuilder builder = new RMAssertionBuilder();
                    SandeshaPolicyBean sandeshaPolicyBean = (SandeshaPolicyBean) builder.build(policyOMElement, null);
                    Parameter policyParam = new Parameter(Sandesha2Constants.SANDESHA_PROPERTY_BEAN, sandeshaPolicyBean);
                    anoymousService.addParameter(policyParam);
                }
View Full Code Here

            processor.setMessageStoreName(storeAtt.getAttributeValue());
        } else {
            handleException("Can't create message processor with out a message processor");
        }

        OMElement descriptionElem = elem.getFirstChildWithName(DESCRIPTION_Q);
        if (descriptionElem != null) {
            assert processor != null;
            processor.setDescription(descriptionElem.getText());
        }

        assert processor != null;
        processor.setParameters(getParameters(elem));
View Full Code Here

        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 {
View Full Code Here

TOP

Related Classes of org.apache.axiom.om.OMElement

Copyright © 2015 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.