Example usage for javax.xml.stream XMLStreamException printStackTrace

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

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.pentaho.platform.dataaccess.client.ConnectionServiceClient.java

/**
 * Returns a specified connection. Returns null is the connection is not
 * defined in the server's configuration.
 * setHost(), setUserId() and setPassword() must be called before this
 * method is called./*from w  ww.j a va 2 s  .  c  om*/
 * @param connectionName The name of the connection to be returned
 * @return The connection requested
 */
public IConnection getConnectionByName(String connectionName) throws ConnectionServiceException {
    PostMethod callMethod = new PostMethod(serviceUrl + "/getConnectionByName"); //$NON-NLS-1$

    // add the xml to the request entity
    String xml = getRequestXml(new Parameter("name", connectionName)); //$NON-NLS-1$
    RequestEntity requestEntity = new StringRequestEntity(xml);
    callMethod.setRequestEntity(requestEntity);

    // get the result and parse de-serialize it
    Document resultDoc = getResultDocument(callMethod);

    try {
        return getResponseConnection(resultDoc.getRootElement());
    } catch (XMLStreamException e) {
        e.printStackTrace();
        throw new ConnectionServiceException(e);
    } catch (AxisFault e) {
        e.printStackTrace();
        throw new ConnectionServiceException(e);
    } catch (Exception e) {
        e.printStackTrace();
        throw new ConnectionServiceException(e);
    }
}

From source file:org.pentaho.platform.dataaccess.client.ConnectionServiceClient.java

/**
 * Returns a list of connections known to the server. Each one is an IConnection object.
 * Returns an empty list if no connections are defined.
 * setHost(), setUserId() and setPassword() must be called before this
 * method is called./*from   w w w. java2 s .c o  m*/
 * @return List of the connections
 */
public List<IConnection> getConnections() throws ConnectionServiceException {

    PostMethod callMethod = new PostMethod(serviceUrl + "/getConnections"); //$NON-NLS-1$

    String xml = getRequestXml();
    RequestEntity requestEntity = new StringRequestEntity(xml);
    callMethod.setRequestEntity(requestEntity);

    List<IConnection> connections = new ArrayList<IConnection>();

    // get the result and parse de-serialize it
    Document resultDoc = getResultDocument(callMethod);

    try {
        Object connectionArray[] = new Object[0];
        connectionArray = getResponseArray(Connection.class, resultDoc.getRootElement());
        for (Object connection : connectionArray) {
            connections.add((Connection) connection);
        }
    } catch (XMLStreamException e) {
        e.printStackTrace();
        throw new ConnectionServiceException(e);
    } catch (AxisFault e) {
        e.printStackTrace();
        throw new ConnectionServiceException(e);
    } catch (Exception e) {
        e.printStackTrace();
        throw new ConnectionServiceException(e);
    }

    return connections;
}

From source file:org.wso2.carbon.governance.generic.ui.utils.GenericUtil.java

public static OMElement getUIConfiguration(String filePath) {
    InputStream stream = GenericUIGenerator.class.getResourceAsStream(filePath);
    try {//from   w ww .  j ava 2  s .  c  o  m
        StAXOMBuilder builder = null;
        OMElement omElement = null;
        try {
            builder = new StAXOMBuilder(stream);
            omElement = builder.getDocumentElement();
        } catch (XMLStreamException e) {
            e.printStackTrace();
        }
        return omElement;
    } finally {
        try {
            stream.close();
        } catch (IOException ignore) {
        }
    }
}

From source file:org.wso2.carbon.java2wsdl.ui.client.Util.java

public static OMElement getJava2WsdlOptions() {
    InputStream stream = Util.class
            .getResourceAsStream("/org/wso2/carbon/java2wsdl/ui/client/java2wsdl-options.xml");
    OMElement omElement = null;//from  ww w  .  j  ava 2s .c  o m
    try {
        StAXOMBuilder builder = new StAXOMBuilder(stream);
        omElement = builder.getDocumentElement();
    } catch (XMLStreamException e) {
        e.printStackTrace();
    }
    return omElement;
}

From source file:org.wso2.carbon.ui.ComponentDeployer.java

public void layout(Map<Long, Component> componentMap) throws CarbonException {
    Collection<Component> componentCollection = componentMap.values();
    OMFactory fac = OMAbstractFactory.getOMFactory();
    OMElement componentEle = fac.createOMElement(new QName(COMPONENT_ELE));
    OMElement tagLibsEle = fac.createOMElement(new QName(TAG_LIBS_ELE));
    componentEle.addChild(tagLibsEle);/*from  ww w. j a  va  2s .c  o m*/
    OMElement jsFilesEle = fac.createOMElement(new QName(JS_FILES_ELE));
    OMElement generalEle = fac.createOMElement(new QName(GENERAL_ELE));
    componentEle.addChild(jsFilesEle);
    componentEle.addChild(generalEle);
    //        for (Component component : componentCollection) {
    //            constructIntermediateStruecte(component, tagLibsEle, jsFilesEle, fac);
    //        }
    //leveling the menus first before adding to ims
    List<Menu> menuList = new ArrayList<Menu>();
    for (Component component : componentCollection) {
        menuList.addAll(component.getMenusList());
    }
    Collections.sort(menuList, new Comparator<Menu>() {
        public int compare(Menu m1, Menu m2) {
            return m1.compareTo(m2);
        }
    });
    //        for (Menu menu : menuList) {
    //            OMElement menuEle = fac.createOMElement(new QName(MENUE_ELE));
    //            generalEle.addChild(menuEle);
    //            Action action = menu.getAction();
    //            menuEle.addAttribute(ACTION_REF_ATTR, action.getName(), fac.createOMNamespace("", ""));
    //            menuEle.addAttribute(NAME_ATTR, menu.getName(), fac.createOMNamespace("", ""));
    //            menuEle.addAttribute(LEVEL_ATTR, Integer.toString(menu.getLevel()),
    //                                 fac.createOMNamespace("", ""));
    //        }

    ByteArrayOutputStream bos = new ByteArrayOutputStream();

    if (log.isDebugEnabled()) {
        log.debug("intermediate : " + componentEle);
    }

    try {
        componentEle.serializeAndConsume(bos);
    } catch (XMLStreamException e) {
        e.printStackTrace();
        throw new CarbonException(e);
    }
    byte[] bytes = bos.toByteArray();

    try {
        // Transform
        for (String templatSuffix : mainTemplateSuffixes) {
            String xslResourceName = "ui/" + templatSuffix + ".xsl";
            URL xslResource = componentBundle.getResource(xslResourceName);
            if (xslResource == null) {
                throw new CarbonException(xslResourceName + " is not avaiable in component bundle");
            }
            ByteArrayOutputStream jspBos = new ByteArrayOutputStream();
            transform(new ByteArrayInputStream(bytes), xslResource.openStream(), jspBos);
            processedFileMap.put("web/" + templatSuffix + ".jsp", new String(jspBos.toByteArray()));
        }
    } catch (TransformerException e) {
        e.printStackTrace();
        throw new CarbonException(e);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        throw new CarbonException(e);
    } catch (IOException e) {
        e.printStackTrace();
        throw new CarbonException(e);
    }

}

From source file:org.wso2.carbon.wsdl2code.ui.client.Util.java

public static OMElement getCodegenOptions(String configFile) {
    InputStream stream = Util.class.getResourceAsStream(configFile);
    StAXOMBuilder builder = null;//from   www.ja v  a  2 s.co  m
    OMElement omElement = null;
    try {
        builder = new StAXOMBuilder(stream);
        omElement = builder.getDocumentElement();
    } catch (XMLStreamException e) {
        e.printStackTrace();
    }
    return omElement;
}

From source file:org.xronos.orcc.analysis.XronosDynamicWeights.java

public void getMeanWeights(String outputPath) {

    if (getModelsimWeights()) {
        XMLOutputFactory factory = XMLOutputFactory.newInstance();
        try {//from  ww w  . j  a  va 2 s  .com
            XMLStreamWriter writer = factory.createXMLStreamWriter(new FileWriter(
                    outputPath + File.separator + network.getSimpleName() + "_dynamicWeights.xml"));
            writer.writeStartDocument();
            writer.writeStartElement("actors");
            for (Actor actor : statistics.keySet()) {
                writer.writeStartElement("actor");
                writer.writeAttribute("name", actor.getSimpleName().toLowerCase());
                Map<Action, SummaryStatistics> actionWeight = statistics.get(actor);
                writer.writeStartElement("actions");
                for (Action action : actionWeight.keySet()) {
                    writer.writeStartElement("action");
                    writer.writeAttribute("name", action.getName().toLowerCase());

                    double min = Double.isNaN(actionWeight.get(action).getMin()) ? 0
                            : actionWeight.get(action).getMin();
                    double mean = Double.isNaN(actionWeight.get(action).getMean()) ? 0
                            : actionWeight.get(action).getMean();
                    double max = Double.isNaN(actionWeight.get(action).getMax()) ? 0
                            : actionWeight.get(action).getMax();
                    double variance = Double.isNaN(actionWeight.get(action).getVariance()) ? 0
                            : actionWeight.get(action).getVariance();

                    writer.writeAttribute("min", Double.toString(min));
                    writer.writeAttribute("mean", Double.toString(mean));
                    writer.writeAttribute("max", Double.toString(max));
                    writer.writeAttribute("variance", Double.toString(variance));

                    writer.writeEndElement();
                }
                writer.writeEndElement();
                writer.writeEndElement();
            }
            writer.writeEndElement();
            writer.writeEndDocument();

            writer.flush();
            writer.close();
        } catch (XMLStreamException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

From source file:uk.ac.ebi.metabolomes.webservices.EUtilsWebServiceConnection.java

/**
 * Queries the NCBI EUtils web service to retrieve through esearch.cgi all the associations existing in a database
 * (dbto) for the query term provided.//from w w w  .  j  ava2s.com
 *
 * @param db the list of string identifiers to search for
 * @param term    the database in Entrez corresponding to those identifiers
 * @return          set with all the one-to-many associations fromDB identifiers (keys) -to- toDB identifiers (values).
 * @throws javax.jws.WebService exception if more than the allowed number of entries were submitted.
 */
public Set<String> getDBIDsFromTermQuery(EntrezDB db, String term) throws WebServiceException {
    ClientResponse resp = getESearchClientResponse(db, term, MAX_RECORDS_PER_QUERY, 0);
    Set<String> ids = new HashSet<String>();
    ESearchXMLResponseParser parser = new ESearchXMLResponseParser();
    ESearchResult res;
    try {
        res = parser.parseESearchResult(resp.getEntityInputStream());
        ids.addAll(res.getIds());
        while (res.resultsMissing()) {
            res = parser.parseESearchResult(
                    getESearchClientResponse(db, term, MAX_RECORDS_PER_QUERY, res.getNextStart())
                            .getEntityInputStream());
            ids.addAll(res.getIds());
        }
    } catch (XMLStreamException e) {
        e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
    }

    return ids;
}

From source file:uk.ac.ebi.ricordo.rdfconverter.sbmltordf.SBMLtoRDFCreatorImpl.java

public void generateSBMLtoRDFFromURL(String modelId) {
    this.modelId = modelId;
    SBMLReader reader = new SBMLReader();
    SBMLDocument document = null;/*  www .  j av  a  2s . c  om*/
    try {
        URL url = new URL("http://www.ebi.ac.uk/biomodels-main/download?mid=" + modelId + "&anno=url");
        document = reader.readSBMLFromStream(url.openStream());
    } catch (XMLStreamException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    generateSBMLtoRDF(document);
}

From source file:uk.ac.ebi.ricordo.rdfconverter.sbmltordf.SBMLtoRDFCreatorImpl.java

public void generateSBMLtoRDFFromFile(String modelId, File file) {
    this.modelId = modelId;
    SBMLReader reader = new SBMLReader();
    SBMLDocument document = null;//  www .  ja  v a 2 s .  com
    try {
        document = reader.readSBML(file);
    } catch (XMLStreamException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    generateSBMLtoRDF(document);
}