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.sonar.api.profiles.XMLProfileParser.java

public RulesProfile parse(Reader reader, ValidationMessages messages) {
    RulesProfile profile = RulesProfile.create();
    SMInputFactory inputFactory = initStax();
    try {/*from  w  ww.j  a  v a2  s.  com*/
        SMHierarchicCursor rootC = inputFactory.rootElementCursor(reader);
        rootC.advance(); // <profile>
        SMInputCursor cursor = rootC.childElementCursor();
        while (cursor.getNext() != null) {
            String nodeName = cursor.getLocalName();
            if (StringUtils.equals("rules", nodeName)) {
                SMInputCursor rulesCursor = cursor.childElementCursor("rule");
                processRules(rulesCursor, profile, messages);

            } else if (StringUtils.equals("alerts", nodeName)) {
                SMInputCursor alertsCursor = cursor.childElementCursor("alert");
                processAlerts(alertsCursor, profile, messages);

            } else if (StringUtils.equals("name", nodeName)) {
                profile.setName(StringUtils.trim(cursor.collectDescendantText(false)));

            } else if (StringUtils.equals("language", nodeName)) {
                profile.setLanguage(StringUtils.trim(cursor.collectDescendantText(false)));
            }
        }
    } catch (XMLStreamException e) {
        messages.addErrorText("XML is not valid: " + e.getMessage());
    }
    checkProfile(profile, messages);
    return profile;
}

From source file:org.sonar.core.technicaldebt.TechnicalDebtXMLImporter.java

public Model importXML(Reader xml, ValidationMessages messages, TechnicalDebtRuleCache repositoryCache) {
    Model model = Model.createByName(TechnicalDebtModel.MODEL_NAME);
    try {/*from  w w  w  . ja va  2  s  . co  m*/
        SMInputFactory inputFactory = initStax();
        SMHierarchicCursor cursor = inputFactory.rootElementCursor(xml);

        // advance to <sqale>
        cursor.advance();
        SMInputCursor chcCursor = cursor.childElementCursor(CHARACTERISTIC);

        while (chcCursor.getNext() != null) {
            processCharacteristic(model, chcCursor, messages, repositoryCache);
        }

        cursor.getStreamReader().closeCompletely();

    } catch (XMLStreamException e) {
        LOG.error("XML is not valid", e);
        messages.addErrorText("XML is not valid: " + e.getMessage());
    }
    return model;
}

From source file:org.sonar.plugins.ada.rules.AdaProfileImporter.java

/**
 * @see org.sonar.api.profiles.ProfileImporter#importProfile(java.io.Reader, org.sonar.api.utils.ValidationMessages)
 *//* ww w. j  a  v a2  s .c  o  m*/
@Override
public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
    SMInputFactory inputFactory = initStax();
    RulesProfile profile = RulesProfile.create();
    try {
        SMHierarchicCursor rootC = inputFactory.rootElementCursor(reader);
        rootC.advance(); // <module name="Checker">
        SMInputCursor rootModulesCursor = rootC.childElementCursor(MODULE_NODE);
        while (rootModulesCursor.getNext() != null) {
            String configKey = rootModulesCursor.getAttrValue("name");
            if (StringUtils.equals(TREEWALKER_MODULE, configKey)) {
                SMInputCursor treewalkerCursor = rootModulesCursor.childElementCursor(MODULE_NODE);
                while (treewalkerCursor.getNext() != null) {
                    processModule(profile, CHECKER_MODULE + "/" + TREEWALKER_MODULE + "/", treewalkerCursor,
                            messages);
                }
            } else {
                processModule(profile, CHECKER_MODULE + "/", rootModulesCursor, messages);
            }
        }
    } catch (XMLStreamException e) {
        messages.addErrorText("XML is not valid: " + e.getMessage());
    }
    return profile;
}

From source file:org.sonar.plugins.checkstyle.CheckstyleProfileImporter.java

@Override
public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
    SMInputFactory inputFactory = initStax();
    RulesProfile profile = RulesProfile.create();
    try {// w w w. j  a  va 2 s .  co m
        SMHierarchicCursor rootC = inputFactory.rootElementCursor(reader);
        rootC.advance(); // <module name="Checker">
        SMInputCursor rootModulesCursor = rootC.childElementCursor(MODULE_NODE);
        while (rootModulesCursor.getNext() != null) {
            String configKey = rootModulesCursor.getAttrValue("name");
            if (StringUtils.equals(TREEWALKER_MODULE, configKey)) {
                SMInputCursor treewalkerCursor = rootModulesCursor.childElementCursor(MODULE_NODE);
                while (treewalkerCursor.getNext() != null) {
                    processModule(profile, CHECKER_MODULE + "/" + TREEWALKER_MODULE + "/", treewalkerCursor,
                            messages);
                }
            } else {
                processModule(profile, CHECKER_MODULE + "/", rootModulesCursor, messages);
            }
        }
    } catch (XMLStreamException e) {
        messages.addErrorText("XML is not valid: " + e.getMessage());
    }
    return profile;
}

From source file:org.sonar.plugins.csharp.gendarme.profiles.GendarmeProfileImporter.java

/**
 * {@inheritDoc}//from  www.j av a  2  s.c o  m
 */
@Override
public RulesProfile importProfile(Reader reader, ValidationMessages messages) {
    RulesProfile profile = RulesProfile.create();
    profile.setLanguage(CSharpConstants.LANGUAGE_KEY);

    SMInputFactory inputFactory = initStax();
    try {
        SMHierarchicCursor cursor = inputFactory.rootElementCursor(reader);
        SMInputCursor rulesetCursor = cursor.advance().childElementCursor();

        parseRules(profile, rulesetCursor);

        cursor.getStreamReader().closeCompletely();
    } catch (XMLStreamException e) {
        messages.addErrorText("Failed to read the profile to import: " + e.getMessage());
    }

    return profile;
}

From source file:org.sonar.server.db.migrations.v50.FileSourceDto.java

/**
 * Parses data of {@link CoreMetrics#DUPLICATIONS_DATA}.
 *//*from w  w w .  ja  v a  2s .com*/
private static List<List<Block>> parseDuplicationData(String data) {
    try {
        ImmutableList.Builder<List<Block>> groups = ImmutableList.builder();
        StringReader reader = new StringReader(data);
        SMInputFactory inputFactory = initStax();
        SMHierarchicCursor rootC = inputFactory.rootElementCursor(reader);
        // <duplications>
        rootC.advance();
        SMInputCursor groupsCursor = rootC.childElementCursor("g");
        while (groupsCursor.getNext() != null) {
            // <g>
            SMInputCursor blocksCursor = groupsCursor.childElementCursor("b");
            ImmutableList.Builder<Block> group = ImmutableList.builder();
            while (blocksCursor.getNext() != null) {
                // <b>
                String resourceKey = blocksCursor.getAttrValue("r");
                int firstLine = getAttrIntValue(blocksCursor, "s");
                int numberOfLines = getAttrIntValue(blocksCursor, "l");

                group.add(new Block(resourceKey, firstLine, numberOfLines));
            }
            groups.add(group.build());
        }
        return groups.build();
    } catch (XMLStreamException e) {
        throw new SonarException(e.getMessage(), e);
    }
}

From source file:org.sonar.server.technicaldebt.XMLImporter.java

public Model importXML(Reader xml, ValidationMessages messages, RuleCache repositoryCache) {
    Model model = Model.createByName(RegisterTechnicalDebtModel.TECHNICAL_DEBT_MODEL);
    try {/*w w w . j a  va 2s  .  c  om*/
        SMInputFactory inputFactory = initStax();
        SMHierarchicCursor cursor = inputFactory.rootElementCursor(xml);

        // advance to <sqale>
        cursor.advance();
        SMInputCursor chcCursor = cursor.childElementCursor(CHARACTERISTIC);

        while (chcCursor.getNext() != null) {
            processCharacteristic(model, chcCursor, messages, repositoryCache);
        }

        cursor.getStreamReader().closeCompletely();

    } catch (XMLStreamException e) {
        LOG.error("XML is not valid", e);
        messages.addErrorText("XML is not valid: " + e.getMessage());
    }
    return model;
}

From source file:org.springframework.ws.soap.axiom.AxiomSoapMessageFactory.java

public AxiomSoapMessage createWebServiceMessage(InputStream inputStream) throws IOException {
    Assert.isInstanceOf(TransportInputStream.class, inputStream,
            "AxiomSoapMessageFactory requires a TransportInputStream");
    TransportInputStream transportInputStream = (TransportInputStream) inputStream;
    String contentType = getHeaderValue(transportInputStream, TransportConstants.HEADER_CONTENT_TYPE);
    if (!StringUtils.hasLength(contentType)) {
        if (logger.isDebugEnabled()) {
            logger.debug("TransportInputStream has no Content-Type header; defaulting to \""
                    + SoapVersion.SOAP_11.getContentType() + "\"");
        }//ww w.j a v  a 2s .  co  m
        contentType = SoapVersion.SOAP_11.getContentType();
    }
    String soapAction = getHeaderValue(transportInputStream, TransportConstants.HEADER_SOAP_ACTION);
    if (!StringUtils.hasLength(soapAction)) {
        soapAction = SoapUtils.extractActionFromContentType(contentType);
    }
    try {
        if (isMultiPartRelated(contentType)) {
            return createMultiPartAxiomSoapMessage(inputStream, contentType, soapAction);
        } else {
            return createAxiomSoapMessage(inputStream, contentType, soapAction);
        }
    } catch (XMLStreamException ex) {
        throw new AxiomSoapMessageCreationException("Could not parse request: " + ex.getMessage(), ex);
    } catch (OMException ex) {
        throw new AxiomSoapMessageCreationException("Could not create message: " + ex.getMessage(), ex);
    }
}

From source file:org.squidy.nodes.laserpointer.config.ConfigConnection.java

/**
 * //from  ww  w.j  av a2  s . c om
 */
public void close() {

    if (LOG.isInfoEnabled()) {
        LOG.info("Close config connection.");
    }

    running = false;
    interrupt();

    try {
        if (xmlEventReader != null) {
            xmlEventReader.close();
        }
    } catch (XMLStreamException e) {
        if (LOG.isErrorEnabled()) {
            LOG.error(e.getMessage(), e);
        }
    }

    try {
        if (xmlStreamWriter != null) {
            xmlStreamWriter.close();
        }
    } catch (XMLStreamException e) {
        if (LOG.isErrorEnabled()) {
            LOG.error(e.getMessage(), e);
        }
    }

    try {
        configManager.detach(this);
        socket.close();
    } catch (IOException e) {
        if (LOG.isErrorEnabled()) {
            LOG.error(e.getMessage(), e);
        }
    }
}

From source file:org.wso2.carbon.apimgt.impl.workflow.ApplicationCreationWSWorkflowExecutor.java

@Override
public void cleanUpPendingTask(String workflowExtRef) throws WorkflowException {
    String errorMsg;//from   www.j ava  2 s . c  o  m

    super.cleanUpPendingTask(workflowExtRef);
    try {
        String action = WorkflowConstants.DELETE_APPLICATION_WS_ACTION;
        ServiceClient client = getClient(action);

        String payload = "<p:CancelApplicationApprovalWorkflowProcessRequest "
                + "        xmlns:p=\"http://workflow.application.apimgt.carbon.wso2.org\">\n"
                + "           <p:workflowRef>" + workflowExtRef + "</p:workflowRef>\n"
                + "        </p:CancelApplicationApprovalWorkflowProcessRequest>";

        client.fireAndForget(AXIOMUtil.stringToOM(payload));
    } catch (AxisFault axisFault) {
        errorMsg = "Error sending out cancel pending application approval process message. cause: "
                + axisFault.getMessage();
        throw new WorkflowException(errorMsg, axisFault);
    } catch (XMLStreamException e) {
        errorMsg = "Error converting application cleanup String to OMElement. cause: " + e.getMessage();
        throw new WorkflowException(errorMsg, e);
    }
}