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.governance.list.operations.UpdateOperation.java

public MessageContext process(MessageContext requestMessageContext) throws AxisFault {
    OMElement content = null;//from w  w w  . ja  v  a 2  s. c o  m
    try {
        OMElement info;
        if ((info = requestMessageContext.getEnvelope().getBody().getFirstElement()
                .getFirstChildWithName(new QName(namespace, "updatedInfo"))) != 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.updateGenericArtifact(artifact);
    } catch (RegistryException e) {
        String msg = e.getMessage();
        log.error(msg);
        OperationUtil.handleException(msg, e);
    }
    succeed = true;

    return getAbstractResponseMessageContext(requestMessageContext);
}

From source file:org.wso2.carbon.governance.metadata.provider.GenericMetadataProviderV1.java

@Override
public Resource buildResource(Base metadata, Resource resource) throws MetadataException {

    try {/*from   ww  w  . ja  v  a 2 s. c o m*/
        String content = getGeneratedMetadataOMElement(metadata).toStringWithConsume();
        resource.setContent(content);
        resource.setMediaType(metadata.getMediaType());
        resource.setUUID(metadata.getUUID());
    } catch (XMLStreamException e) {
        log.error("Xml stream exception occurred while building resource content " + e.getMessage());
        throw new MetadataException("Xml stream exception occurred while building resource content", e);
    } catch (RegistryException e) {
        throw new MetadataException(e.getMessage(), e);
    }
    return resource;
}

From source file:org.wso2.carbon.governance.metadata.provider.version.GenericVersionProviderV1.java

@Override
public Resource buildResource(VersionBase metadata, Resource resource) throws MetadataException {
    OMElement root = Util.getContentRoot();
    OMElement attributes = Util.getAttributeRoot();
    OMElement properties = Util.getPropertyRoot();

    createAttributesContent((GenericVersionV1) metadata, attributes);
    createPropertiesContent((GenericVersionV1) metadata, properties);
    root.addChild(properties);//from   w w  w.j ava2  s.  c o  m
    root.addChild(attributes);
    try {
        String content = root.toStringWithConsume();
        resource.setContent(content);
        resource.setMediaType(metadata.getMediaType());
        resource.setUUID(metadata.getUUID());
    } catch (XMLStreamException e) {
        log.error("Xml stream exception occurred while building resource content " + e.getMessage());
        throw new MetadataException("Xml stream exception occurred while building resource content", e);
    } catch (RegistryException e) {
        throw new MetadataException(e.getMessage(), e);
    }
    return resource;
}

From source file:org.wso2.carbon.governance.metadata.provider.version.ServiceVersionProviderV1.java

@Override
public Resource buildResource(VersionBase metadata, Resource resource) throws MetadataException {
    OMElement root = Util.getContentRoot();
    OMElement attributes = Util.getAttributeRoot();
    OMElement properties = Util.getPropertyRoot();

    createAttributesContent((ServiceVersionV1) metadata, attributes);
    createPropertiesContent((ServiceVersionV1) metadata, properties);
    root.addChild(properties);/*w  w  w  .ja va 2s  . c o  m*/
    root.addChild(attributes);
    try {
        String content = root.toStringWithConsume();
        resource.setContent(content);
        resource.setMediaType(metadata.getMediaType());
        resource.setUUID(metadata.getUUID());
    } catch (XMLStreamException e) {
        log.error("Xml stream exception occurred while building resource content " + e.getMessage());
        throw new MetadataException("Xml stream exception occurred while building resource content", e);
    } catch (RegistryException e) {
        throw new MetadataException(e.getMessage(), e);
    }
    return resource;
}

From source file:org.wso2.carbon.identity.application.common.config.IdentityApplicationConfig.java

public static IdentityApplicationConfig getInstance() {
    if (instance == null) {
        synchronized (IdentityApplicationConfig.class) {
            if (instance == null) {
                instance = new IdentityApplicationConfig();
                try {
                    instance.buildConfiguration();
                } catch (XMLStreamException e) {
                    log.error("Error occurred while building Identity Application Management configuration: "
                            + e.getMessage(), e);
                } catch (IOException e) {
                    log.error("Error occurred while building Identity Application Management configuration: "
                            + e.getMessage(), e);
                }/*  ww w.ja  va2s. c  om*/
            }
        }
    }
    return instance;
}

From source file:org.wso2.carbon.identity.entitlement.policy.publisher.CarbonBasicPolicyPublisherModule.java

private void doSend(String body) throws EntitlementException {

    if (serverUrl != null) {
        serverUrl = serverUrl.trim();//from  ww w  .ja v a2 s.  c om
        if (!serverUrl.endsWith("/")) {
            serverUrl += "/";
        }
    }

    String serverEndPoint = serverUrl + "EntitlementPolicyAdminService";
    ServiceClient client = null;
    try {
        MultiThreadedHttpConnectionManager httpConnectionManager = new MultiThreadedHttpConnectionManager();
        HttpClient httpClient = new HttpClient(httpConnectionManager);
        client = new ServiceClient(configCtx, null);
        Options option = client.getOptions();
        option.setManageSession(true);
        HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator();
        authenticator.setUsername(serverUserName);
        authenticator.setPassword(serverPassword);
        authenticator.setPreemptiveAuthentication(true);
        option.setProperty(org.apache.axis2.transport.http.HTTPConstants.AUTHENTICATE, authenticator);
        option.setProperty(Constants.Configuration.TRANSPORT_URL, serverEndPoint);
        option.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Constants.VALUE_TRUE);
        option.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
        client.sendRobust(AXIOMUtil.stringToOM(body));
    } catch (AxisFault axisFault) {
        log.error("Policy publish fails due : " + axisFault.getMessage(), axisFault);
        throw new EntitlementException("Policy publish fails due : " + axisFault.getMessage());
    } catch (XMLStreamException e) {
        log.error("Policy publish fails due : " + e.getMessage(), e);
        throw new EntitlementException("Policy publish fails due : " + e.getMessage());
    } finally {
        if (client != null) {
            try {
                client.cleanupTransport();
                client.cleanup();
            } catch (AxisFault axisFault) {
                log.error("Error while cleaning HTTP client", axisFault);
            }
        }
    }
}

From source file:org.wso2.carbon.inbound.CarbonInboundManagementService.java

/**
 * /* ww  w.  j av  a  2  s  . co m*/
 * Adds new inbound endpoint from XML Config
 * 
 * @param inboundElement
 */
public void addInboundEndpointFromXMLString(String inboundElement) {
    XMLStreamReader reader = null;
    try {
        reader = XMLInputFactory.newInstance().createXMLStreamReader(new StringReader(inboundElement));
    } catch (XMLStreamException e) {
        log.error(e.getMessage());
    }
    StAXOMBuilder builder = new StAXOMBuilder(reader);
    OMElement omElement = builder.getDocumentElement();
    SynapseConfiguration synapseConfiguration = getSynapseConfiguration();
    SynapseXMLConfigurationFactory.defineInboundEndpoint(synapseConfiguration, omElement,
            synapseConfiguration.getProperties());
    String name = omElement.getAttributeValue(new QName("name"));
    InboundEndpoint inboundEndpoint = null;
    try {
        inboundEndpoint = getInboundEndpoint(name);
    } catch (InboundManagementException e) {
        log.error(e.getMessage());
    }
    persistInboundEndpoint(inboundEndpoint);
    inboundEndpoint.init(getSynapseEnvironment());
}

From source file:org.wso2.carbon.mediation.configadmin.ConfigAdmin.java

/**
 * Get the current Synapse configuration serialized as an string
 *
 * @return return XML configuration serialized in to a string
 * @throws org.apache.axis2.AxisFault if an error occurs
 *///from   w ww  .ja v a  2s  . co  m
public String getConfiguration() throws AxisFault {
    final Lock lock = getLock();
    try {
        lock.lock();

        // ConfigurationFactoryAndSerializerFinder might not have been initialized
        // and hence we need to call the getInstance to load the factories and serializers
        ConfigurationFactoryAndSerializerFinder.getInstance();

        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        XMLConfigurationSerializer.serializeConfiguration(getSynapseConfiguration(), stream);
        XMLInputFactory factory = XMLInputFactory.newInstance();
        if (factory.isPropertySupported(PROP_REPORT_CDATA)) {
            factory.setProperty(PROP_REPORT_CDATA, Boolean.TRUE);
        }
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(stream.toByteArray());
        org.wso2.carbon.mediation.configadmin.util.XMLPrettyPrinter xmlPrettyPrinter = new org.wso2.carbon.mediation.configadmin.util.XMLPrettyPrinter(
                byteArrayInputStream);
        return xmlPrettyPrinter.xmlFormatWithComments();

    } catch (XMLStreamException e) {
        handleException("Error serializing the Synapse configuration : Error " + e.getMessage(), e);
    } catch (Exception e) {
        handleException("Error serializing the Synapse configuration : Error " + e.getMessage(), e);
    } finally {
        lock.unlock();
    }
    return "";
}

From source file:org.wso2.carbon.mediation.library.service.MediationLibraryAdminService.java

/**
 * Add the local entry/*from   ww  w  .  j  a v  a  2 s  . c  o  m*/
 * 
 * */
private boolean addEntry(String ele) {
    final Lock lock = getLock();
    try {
        lock.lock();
        OMElement elem;
        try {
            elem = LocalEntryUtil.nonCoalescingStringToOm(ele);
        } catch (XMLStreamException e) {
            log.error("Error while converting the file content : " + e.getMessage());
            return false;
        }

        if (elem.getQName().getLocalPart().equals(XMLConfigConstants.ENTRY_ELT.getLocalPart())) {

            String entryKey = elem.getAttributeValue(new QName("key"));
            entryKey = entryKey.trim();
            if (log.isDebugEnabled()) {
                log.debug("Adding local entry with key : " + entryKey);
            }
            if (getSynapseConfiguration().getLocalRegistry().containsKey(entryKey)) {
                log.error("An Entry with key " + entryKey + " is already used within the configuration");
            } else {
                Entry entry = EntryFactory.createEntry(elem, getSynapseConfiguration().getProperties());
                entry.setFileName(ServiceBusUtils.generateFileName(entry.getKey()));
                getSynapseConfiguration().addEntry(entryKey, entry);
                MediationPersistenceManager pm = ServiceBusUtils
                        .getMediationPersistenceManager(getAxisConfig());
                pm.saveItem(entry.getKey(), ServiceBusConstants.ITEM_TYPE_ENTRY);
            }
            if (log.isDebugEnabled()) {
                log.debug("Local registry entry : " + entryKey + " added to the configuration");
            }
            return true;
        } else {
            log.warn("Error adding local entry. Invalid definition");
        }
    } catch (SynapseException syne) {
        log.error("Unable to add local entry ", syne);
    } catch (OMException e) {
        log.error("Unable to add local entry. Invalid XML ", e);
    } catch (Exception e) {
        log.error("Unable to add local entry. Invalid XML ", e);
    } finally {
        lock.unlock();
    }
    return false;
}

From source file:org.wso2.carbon.mediation.library.service.MediationLibraryAdminService.java

/**
 * Remove the local entry//from  ww w .j a  v a2  s .c om
 * */
public boolean deleteEntry(String ele) {

    final Lock lock = getLock();
    String entryKey = null;
    try {
        lock.lock();
        OMElement elem;
        try {
            elem = LocalEntryUtil.nonCoalescingStringToOm(ele);
        } catch (XMLStreamException e) {
            log.error("Error while converting the file content : " + e.getMessage());
            return false;
        }

        if (elem.getQName().getLocalPart().equals(XMLConfigConstants.ENTRY_ELT.getLocalPart())) {

            entryKey = elem.getAttributeValue(new QName("key"));
            entryKey = entryKey.trim();
            log.debug("Adding local entry with key : " + entryKey);

            SynapseConfiguration synapseConfiguration = getSynapseConfiguration();
            Entry entry = synapseConfiguration.getDefinedEntries().get(entryKey);
            if (entry != null) {
                synapseConfiguration.removeEntry(entryKey);
                MediationPersistenceManager pm = ServiceBusUtils
                        .getMediationPersistenceManager(getAxisConfig());
                pm.deleteItem(entryKey, entry.getFileName(), ServiceBusConstants.ITEM_TYPE_ENTRY);
                if (log.isDebugEnabled()) {
                    log.debug("Deleted local entry with key : " + entryKey);
                }
                return true;
            } else {
                log.warn("No entry exists by the key : " + entryKey);
                return false;
            }
        }
    } catch (SynapseException syne) {
        log.error("Unable to delete the local entry : " + entryKey, syne);
    } catch (Exception e) {
        log.error("Unable to delete the local entry : " + entryKey, e);
    } finally {
        lock.unlock();
    }
    return false;
}