Example usage for javax.xml.stream XMLStreamException getMessage

List of usage examples for javax.xml.stream XMLStreamException getMessage

Introduction

In this page you can find the example usage for javax.xml.stream XMLStreamException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.wso2.carbon.event.output.adaptor.manager.core.internal.CarbonOutputEventAdaptorManagerService.java

@Override
public void editInactiveOutputEventAdaptorConfiguration(String eventAdaptorConfiguration, String filename,
        AxisConfiguration axisConfiguration) throws OutputEventAdaptorManagerConfigurationException {
    try {/*from   w  ww  .j a v a2s  .  com*/
        OMElement omElement = AXIOMUtil.stringToOM(eventAdaptorConfiguration);
        omElement.toString();
        int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
        OutputEventAdaptorConfiguration eventAdaptorConfigurationObject = OutputEventAdaptorConfigurationHelper
                .fromOM(omElement);
        if (checkAdaptorValidity(tenantId, eventAdaptorConfigurationObject.getName())) {
            if (OutputEventAdaptorConfigurationHelper
                    .validateEventAdaptorConfiguration(eventAdaptorConfigurationObject)) {
                undeployInactiveOutputEventAdaptorConfiguration(filename, axisConfiguration);
                OutputEventAdaptorConfigurationFilesystemInvoker.save(omElement,
                        eventAdaptorConfigurationObject.getName(), filename, axisConfiguration);
            } else {
                log.error("There is no Output Event Adaptor type called "
                        + eventAdaptorConfigurationObject.getType() + " is available");
                throw new OutputEventAdaptorManagerConfigurationException(
                        "There is no Output Event Adaptor type called "
                                + eventAdaptorConfigurationObject.getType() + " is available ");
            }
        } else {
            throw new OutputEventAdaptorManagerConfigurationException(
                    "There is a Output Event Adaptor with the same name");
        }
    } catch (XMLStreamException e) {
        log.error("Error while creating the xml object");
        throw new OutputEventAdaptorManagerConfigurationException("Not a valid xml object " + e.getMessage(),
                e);
    }
}

From source file:org.wso2.carbon.event.output.adaptor.soap.SoapEventAdaptorType.java

@Override
public void testConnection(OutputEventAdaptorConfiguration outputEventAdaptorConfiguration, int tenantId) {
    String testMessage = " <eventAdaptorConfigurationTest>\n"
            + "   <message>This is a test message.</message>\n" + "   </eventAdaptorConfigurationTest>";
    try {//from  w w w.j av  a 2s  .  c om
        XMLStreamReader reader1 = StAXUtils
                .createXMLStreamReader(new ByteArrayInputStream(testMessage.getBytes()));
        StAXOMBuilder builder1 = new StAXOMBuilder(reader1);
        OutputEventAdaptorMessageConfiguration outputEventAdaptorMessageConfiguration = new OutputEventAdaptorMessageConfiguration();
        Map<String, String> propertyList = new ConcurrentHashMap<String, String>();
        outputEventAdaptorMessageConfiguration.setOutputMessageProperties(propertyList);
        publish(outputEventAdaptorMessageConfiguration, builder1.getDocumentElement(),
                outputEventAdaptorConfiguration, tenantId);

    } catch (XMLStreamException e) {
        throw new OutputEventAdaptorEventProcessingException(e.getMessage());
    } catch (OutputEventAdaptorEventProcessingException e) {
        throw new OutputEventAdaptorEventProcessingException(e);
    }

}

From source file:org.wso2.carbon.event.processor.core.internal.storm.StormTopologyManager.java

public void submitTopology(ExecutionPlanConfiguration configuration, List<String> importStreams,
        List<String> exportStreams, int tenantId, int resubmitRetryInterval)
        throws StormDeploymentException, ExecutionPlanConfigurationException {
    String executionPlanName = configuration.getName();
    TopologyBuilder builder;/*from   w w  w .  j  av  a 2  s.  c om*/
    String topologyName = getTopologyName(executionPlanName, tenantId);

    try {
        Document document = StormQueryPlanBuilder.constructStormQueryPlanXML(configuration, importStreams,
                exportStreams);
        String stormQueryPlan = getStringQueryPlan(document);
        if (log.isDebugEnabled()) {
            log.debug("Following is the generated Storm query plan for execution plan: "
                    + configuration.getName() + "\n" + stormQueryPlan);
        }
        builder = StormTopologyConstructor.constructTopologyBuilder(stormQueryPlan, executionPlanName, tenantId,
                EventProcessorValueHolder.getStormDeploymentConfiguration());
    } catch (XMLStreamException e) {
        throw new StormDeploymentException(
                "Invalid Config for Execution Plan " + executionPlanName + " for tenant " + tenantId, e);
    } catch (TransformerException e) {
        throw new StormDeploymentException("Error while converting to storm query plan string. "
                + "Execution plan: " + executionPlanName + " Tenant: " + tenantId, e);
    } catch (StormQueryConstructionException e) {
        throw new StormDeploymentException("Error while converting to XML storm query plan. "
                + "Execution plan: " + executionPlanName + " Tenant: " + tenantId + ". " + e.getMessage(), e);
    }

    TopologySubmitter topologySubmitter = new TopologySubmitter(executionPlanName, builder.createTopology(),
            tenantId, resubmitRetryInterval);
    synchronized (toDeployTopologies) {
        toDeployTopologies.put(topologyName, topologySubmitter);
    }

    Thread deploymentThread = topologyManagerThreadFactory.newThread(topologySubmitter);
    deploymentThread.start();

}

From source file:org.wso2.carbon.event.processor.core.internal.storm.TopologyManager.java

public static void submitTopology(ExecutionPlanConfiguration configuration, List<String> importStreams,
        List<String> exportStreams, int tenantId, int resubmitRetryInterval)
        throws StormDeploymentException, ExecutionPlanConfigurationException {
    String executionPlanName = configuration.getName();
    TopologyBuilder builder;//ww  w.  j av  a2 s.co m
    try {
        Document document = StormQueryPlanBuilder.constructStormQueryPlanXML(configuration, importStreams,
                exportStreams);
        String stormQueryPlan = getStringQueryPlan(document);
        if (log.isDebugEnabled()) {
            log.debug("Following is the generated Storm query plan for execution plan: "
                    + configuration.getName() + "\n" + stormQueryPlan);
        }
        builder = StormTopologyConstructor.constructTopologyBuilder(stormQueryPlan, executionPlanName, tenantId,
                EventProcessorValueHolder.getStormDeploymentConfig());
    } catch (XMLStreamException e) {
        throw new StormDeploymentException(
                "Invalid Config for Execution Plan " + executionPlanName + " for tenant " + tenantId, e);
    } catch (TransformerException e) {
        throw new StormDeploymentException("Error while converting to storm query plan string. "
                + "Execution plan: " + executionPlanName + " Tenant: " + tenantId, e);
    } catch (StormQueryConstructionException e) {
        throw new StormDeploymentException("Error while converting to XML storm query plan. "
                + "Execution plan: " + executionPlanName + " Tenant: " + tenantId + ". " + e.getMessage(), e);
    }

    String uploadedJarLocation = StormSubmitter.submitJar(stormConfig, jarLocation);

    try {
        String jsonConf = JSONValue.toJSONString(stormConfig);
        client.submitTopology(getTopologyName(executionPlanName, tenantId), uploadedJarLocation, jsonConf,
                builder.createTopology());
        log.info(
                "Successfully submitted storm topology '" + getTopologyName(executionPlanName, tenantId) + "'");

        waitForTopologyToBeActive(getTopologyName(executionPlanName, tenantId));
    } catch (AlreadyAliveException e) {
        log.warn("Topology '" + getTopologyName(executionPlanName, tenantId) + "' already existing", e);
        Thread retryThread = new Thread(new TopologySubmitter(executionPlanName, uploadedJarLocation,
                builder.createTopology(), tenantId, true, resubmitRetryInterval));
        retryThread.start();
    } catch (TException e) {
        log.warn("Error connecting to storm when trying to submit topology '"
                + getTopologyName(executionPlanName, tenantId) + "'", e);
        Thread retryThread = new Thread(new TopologySubmitter(executionPlanName, uploadedJarLocation,
                builder.createTopology(), tenantId, false, resubmitRetryInterval));
        retryThread.start();
    } catch (InvalidTopologyException e) {
        // No point in retrying to submit if the topology is invalid. Therefore, throwing an exception without retrying.
        throw new ExecutionPlanConfigurationException(
                "Invalid Execution Plan " + executionPlanName + " for tenant " + tenantId, e);
    }
}

From source file:org.wso2.carbon.event.publisher.core.internal.CarbonEventPublisherService.java

private void editEventPublisherConfiguration(String filename, String eventPublisherConfigurationXml,
        String originalEventPublisherName) throws EventPublisherConfigurationException {
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    try {/*from ww w .j av  a  2  s. c  om*/
        OMElement omElement = AXIOMUtil.stringToOM(eventPublisherConfigurationXml);
        omElement.build();
        EventPublisherConfigurationHelper.validateEventPublisherConfiguration(omElement);
        String mappingType = EventPublisherConfigurationHelper.getOutputMappingType(omElement);
        if (mappingType != null) {
            EventPublisherConfiguration eventPublisherConfigurationObject = EventPublisherConfigurationBuilder
                    .getEventPublisherConfiguration(omElement, mappingType, true, tenantId);
            if (!(eventPublisherConfigurationObject.getEventPublisherName()
                    .equals(originalEventPublisherName))) {
                if (!isEventPublisherAlreadyExists(tenantId,
                        eventPublisherConfigurationObject.getEventPublisherName())) {
                    EventPublisherConfigurationFilesystemInvoker.delete(filename);
                    EventPublisherConfigurationFilesystemInvoker.encryptAndSave(omElement, filename);
                } else {
                    throw new EventPublisherConfigurationException("There is already a Event Publisher "
                            + eventPublisherConfigurationObject.getEventPublisherName()
                            + " with the same name");
                }
            } else {
                EventPublisherConfigurationFilesystemInvoker.delete(filename);
                EventPublisherConfigurationFilesystemInvoker.encryptAndSave(omElement, filename);
            }
        } else {
            throw new EventPublisherConfigurationException(
                    "Mapping type of the Event Publisher " + originalEventPublisherName + " cannot be null");
        }
    } catch (XMLStreamException e) {
        throw new EventPublisherConfigurationException(
                "Error while building XML configuration :" + e.getMessage(), e);
    }
}

From source file:org.wso2.carbon.event.publisher.core.internal.type.xml.XMLOutputMapper.java

private String validateXML(String text) throws EventPublisherConfigurationException {
    try {//from   w w  w.ja va2 s.  c  om
        //Parsing and converting back to string to discover parse exceptions early.
        OMElement mappingOMElement = AXIOMUtil.stringToOM(text);
        return mappingOMElement.toString();
    } catch (XMLStreamException e) {
        throw new EventPublisherConfigurationException("Could not parse the mapping text:" + e.getMessage(), e);
    }
}

From source file:org.wso2.carbon.event.receiver.core.internal.CarbonEventReceiverService.java

private void editEventReceiverConfiguration(String filename, String eventReceiverConfigurationXml,
        String originalEventReceiverName) throws EventReceiverConfigurationException {
    int tenantId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId();
    try {//from  w w w .  j  av a  2 s.  c om
        OMElement omElement = AXIOMUtil.stringToOM(eventReceiverConfigurationXml);
        omElement.build();
        EventReceiverConfigurationHelper.validateEventReceiverConfiguration(omElement);
        String mappingType = EventReceiverConfigurationHelper.getInputMappingType(omElement);
        if (mappingType != null) {
            EventReceiverConfiguration eventReceiverConfigurationObject = EventReceiverConfigurationBuilder
                    .getEventReceiverConfiguration(omElement, mappingType, true, tenantId);
            if (!(eventReceiverConfigurationObject.getEventReceiverName().equals(originalEventReceiverName))) {
                if (!isEventReceiverAlreadyExists(tenantId,
                        eventReceiverConfigurationObject.getEventReceiverName())) {
                    EventReceiverConfigurationFileSystemInvoker.delete(filename);
                    EventReceiverConfigurationFileSystemInvoker.encryptAndSave(omElement, filename);
                } else {
                    throw new EventReceiverConfigurationException("There is already a Event Receiver "
                            + eventReceiverConfigurationObject.getEventReceiverName() + " with the same name");
                }
            } else {
                EventReceiverConfigurationFileSystemInvoker.delete(filename);
                EventReceiverConfigurationFileSystemInvoker.encryptAndSave(omElement, filename);
            }
        } else {
            throw new EventReceiverConfigurationException(
                    "Mapping type of the Event Receiver " + originalEventReceiverName + " cannot be null");
        }
    } catch (XMLStreamException e) {
        throw new EventReceiverConfigurationException(
                "Error while building XML configuration: " + e.getMessage(), e);
    }
}

From source file:org.wso2.carbon.event.receiver.core.internal.type.xml.XMLInputMapper.java

private Event[] processMultipleEvents(Object obj) {
    if (obj instanceof String) {
        String textMessage = (String) obj;
        try {/*from   w  w  w  .  j ava2s . c o m*/
            obj = AXIOMUtil.stringToOM(textMessage);
        } catch (XMLStreamException e) {
            throw new EventReceiverProcessingException("Error parsing incoming XML event : " + e.getMessage(),
                    e);
        }
    }
    if (obj instanceof OMElement) {
        OMElement events;
        try {
            events = (OMElement) this.parentSelectorXpath.selectSingleNode(obj);
        } catch (JaxenException e) {
            throw new EventReceiverProcessingException(
                    "Unable to parse XPath for parent selector: " + e.getMessage(), e);
        }
        if (events == null) {
            throw new EventReceiverProcessingException("Parent Selector XPath \""
                    + parentSelectorXpath.toString() + "\" cannot be processed on event:" + obj.toString());
        }

        List<Event> objArrayList = new ArrayList<Event>();
        Iterator childIterator = events.getChildElements();
        while (childIterator.hasNext()) {
            Object eventObj = childIterator.next();
            try {
                objArrayList.add(processSingleEvent(eventObj));
            } catch (EventReceiverProcessingException e) {
                log.error("Dropping event. Error processing event : ", e);
            }
            /**
             * 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();
        }
        return objArrayList.toArray(new Event[objArrayList.size()]);
    }
    return null;
}

From source file:org.wso2.carbon.event.receiver.core.internal.type.xml.XMLInputMapper.java

private Event processSingleEvent(Object obj) throws EventReceiverProcessingException {
    Object[] outObjArray = null;//from w  w w.  ja  v  a 2s.c  o  m
    StreamDefinition outStreamDefinition = this.streamDefinition;
    int metaDataCount = outStreamDefinition.getMetaData() != null ? outStreamDefinition.getMetaData().size()
            : 0;
    int correlationDataCount = outStreamDefinition.getCorrelationData() != null
            ? outStreamDefinition.getCorrelationData().size()
            : 0;
    int payloadDataCount = outStreamDefinition.getPayloadData() != null
            ? outStreamDefinition.getPayloadData().size()
            : 0;
    Object[] metaDataArray = new Object[metaDataCount];
    Object[] correlationDataArray = new Object[correlationDataCount];
    Object[] payloadDataArray = new Object[payloadDataCount];
    OMElement eventOMElement = null;
    if (obj instanceof String) {
        String textMessage = (String) obj;
        try {
            eventOMElement = AXIOMUtil.stringToOM(textMessage);
        } catch (XMLStreamException e) {
            throw new EventReceiverProcessingException("Error parsing incoming XML event : " + e.getMessage(),
                    e);
        }
    } else if (obj instanceof OMElement) {
        eventOMElement = (OMElement) obj;
    }

    if (eventOMElement != null) {
        OMNamespace omNamespace = null;
        if (this.xPathDefinitions == null || this.xPathDefinitions.isEmpty()) {
            omNamespace = eventOMElement.getNamespace();
        }
        List<Object> objList = new ArrayList<Object>();
        for (XPathData xpathData : attributeXpathList) {
            AXIOMXPath xpath = xpathData.getXpath();
            OMElement omElementResult = null;
            OMAttribute omAttributeResult = null;
            Object returnedObj = null;
            String type = xpathData.getType();
            try {
                if (omNamespace != null) {
                    xpath.addNamespaces(eventOMElement);
                }
                Object element = xpath.selectSingleNode(eventOMElement);
                Class<?> beanClass = Class.forName(type);
                if (element instanceof OMElement) {
                    omElementResult = (OMElement) element;
                    if (omElementResult.getFirstElement() != null) {
                        returnedObj = omElementResult.toString();
                    } else {
                        returnedObj = BeanUtil.deserialize(beanClass, omElementResult,
                                reflectionBasedObjectSupplier, null);
                    }
                } else if (element instanceof OMAttribute) {
                    omAttributeResult = (OMAttribute) element;
                    if (omAttributeResult.getAttributeValue() != null) {
                        returnedObj = EventReceiverUtil
                                .convertToAttributeType(omAttributeResult.getAttributeValue(), beanClass);
                    }
                }
                if (returnedObj == null) {
                    if (xpathData.getDefaultValue() != null) {
                        if (!beanClass.equals(String.class)) {
                            Class<?> stringClass = String.class;
                            Method valueOfMethod = beanClass.getMethod("valueOf", stringClass);
                            returnedObj = valueOfMethod.invoke(null, xpathData.getDefaultValue());
                        } else {
                            returnedObj = xpathData.getDefaultValue();
                        }
                    } else if (!type.equals(EventReceiverConstants.CLASS_FOR_STRING)) {
                        if (omElementResult == null) {
                            throw new EventReceiverProcessingException(
                                    "Unable to parse XPath " + xpathData.getXpath()
                                            + " to retrieve required attribute, hence dropping the event "
                                            + obj.toString());
                        } else {
                            throw new EventReceiverProcessingException("Valid attribute value not found for "
                                    + xpathData.getXpath() + ", hence dropping the event " + obj.toString());
                        }
                    }
                }
                objList.add(returnedObj);
            } catch (JaxenException e) {
                throw new EventReceiverProcessingException("Error parsing xpath for " + xpath, e);
            } catch (ClassNotFoundException e) {
                throw new EventReceiverProcessingException("Cannot find specified class for type " + type);
            } catch (AxisFault axisFault) {
                throw new EventReceiverProcessingException("Error de-serializing OMElement " + omElementResult,
                        axisFault);
            } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
                throw new EventReceiverProcessingException(
                        "Error trying to convert default value to specified target type.", e);
            }
        }
        outObjArray = objList.toArray(new Object[objList.size()]);
    }
    return EventReceiverUtil.getEventFromArray(outObjArray, outStreamDefinition, metaDataArray,
            correlationDataArray, payloadDataArray);
}

From source file:org.wso2.carbon.governance.list.operations.CreateOperation.java

public MessageContext process(MessageContext requestMessageContext) throws AxisFault {
    OMElement content = null;// w  w  w .  jav  a2  s.  c  o m
    try {
        OMElement info;
        if ((info = requestMessageContext.getEnvelope().getBody().getFirstElement()
                .getFirstChildWithName(new QName(namespace, "info"))) != null) {
            content = AXIOMUtil.stringToOM(info.getText());
        }
        if (content == null) {
            String msg = "Content of the resource should be in correct format";
            log.error(msg);
            OperationUtil.handleException(msg);
        }
    } catch (XMLStreamException e) {
        String msg = "Error occured while reading the content of the SOAP message";
        log.error(msg);
        OperationUtil.handleException(msg, e);
    }

    try {
        GenericArtifactManager artifactManager = new GenericArtifactManager(governanceSystemRegistry, rxtKey);
        GenericArtifact artifact = artifactManager.newGovernanceArtifact(content);
        artifactManager.addGenericArtifact(artifact);
        artifactId = artifact.getId();
    } catch (RegistryException e) {
        String msg = e.getMessage();
        log.error(msg);
        OperationUtil.handleException(msg, e);
    }

    return getAbstractResponseMessageContext(requestMessageContext);
}