Example usage for javax.xml.bind JAXBException printStackTrace

List of usage examples for javax.xml.bind JAXBException printStackTrace

Introduction

In this page you can find the example usage for javax.xml.bind JAXBException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this JAXBException and its stack trace (including the stack trace of the linkedException if it is non-null) to System.err .

Usage

From source file:net.sourceforge.seqware.common.metadata.MetadataWS.java

/**
 * {@inheritDoc}//from   w  ww.  ja  v  a 2 s . c o  m
 */
@Override
public boolean linkWorkflowRunAndParent(int workflowRunId, int parentAccession) throws SQLException {
    JaxbObject<WorkflowRun> jow = new JaxbObject<WorkflowRun>();
    try {
        IUS ius = ll.existsIUS("/" + parentAccession);
        Lane lane = ll.existsLane("/" + parentAccession);
        // this one won't be able to get back lanes and ius
        WorkflowRun wr_withoutLanes = ll.findWorkflowRun("?id=" + workflowRunId /**+ "&show=lanes,ius"*/
        );
        // this will, but uses seqware accessions
        int accession = wr_withoutLanes.getSwAccession();
        WorkflowRun wr_withLanesAndIUS = ll.findWorkflowRun("/" + accession + "?show=lanes,ius");
        if (ius != null) {
            SortedSet<IUS> iuses = wr_withLanesAndIUS.getIus();
            if (iuses == null) {
                iuses = new TreeSet<IUS>();
            }
            iuses.add(ius);
            wr_withLanesAndIUS.setIus(iuses);

            ll.updateWorkflowRun("/" + accession, wr_withLanesAndIUS);

        } else if (lane != null) {
            SortedSet<Lane> lanes = wr_withLanesAndIUS.getLanes();
            if (lanes == null) {
                lanes = new TreeSet<Lane>();
            }
            lanes.add(lane);
            wr_withLanesAndIUS.setLanes(lanes);

            ll.updateWorkflowRun("/" + accession, wr_withLanesAndIUS);

        } else {
            Log.error("ERROR: SW Accession is neither a lane nor an IUS: " + parentAccession);
            return (false);
        }
    } catch (JAXBException e) {
        e.printStackTrace();
        return false;
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
    return (true);
}

From source file:openemr.main.FhirOpenemrConn.java

/**
 * Starting point for normal execution/*from w w w . j ava 2 s  .  c o m*/
 */
public static final void main(String[] args) {

    FhirContext context = new FhirContext();
    final FhirOpenemrConn pg = new FhirOpenemrConn();
    Bundle bundle;
    Patient patient;
    final String outputMediaType = "application/json+fhir";
    final String req = "get_all";
    String result = "";
    IParser parser = getParser(context, FHIRMediaType.getType(outputMediaType));
    parser.setPrettyPrint(true);

    try {

        PatientList patientList = null;
        File f = new File("D:/AllPatients.txt");
        patientList = pg.getPatientList(f);

        if (req.equalsIgnoreCase("get_all")) {

            System.out.println("Patient List... " + patientList);
            bundle = pg.getAllPatients(patientList);
            result = parser.encodeResourceToString(bundle);
        }
        /*else if(req.equalsIgnoreCase("get_single")){
           patient = pg.getSinglePatient(patientList,0);
           System.out.println("Patient in main.... " + patient.getId());
           result = parser.encodeResourceToString(patient);   
        }
        else
           result = null;*/

        System.out.println("Result....   " + result);

    } catch (JAXBException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }

    /*int status_code = 200;
    String reason = "OK";
    String errorMessage = null;
    String result = null;
    PatientList2 patientList;
    final FhirOpenemrConn conn = new FhirOpenemrConn();
    //String req = messageContext.getVariable("req");
    // Get the response received from server stored in apigee variable
            
            
    // Get the actual Content type of response and required content type.
    String outputMediaType = "application/json+fhir";
            
            
            
    FhirContext context = new FhirContext();
    try 
    {
       File f = new File("D:/patient.xml");;
       patientList = conn.getPatientList(f);
        Bundle bundle;
       Patient patient;
               
       IParser parser = getParser(context, FHIRMediaType.getType("application/json+fhir"));
       parser.setPrettyPrint(true);
               
       patient = conn.getSinglePatient(patientList,0);
       result = parser.encodeResourceToString(patient);
               
       bundle = conn.getAllPatients(patientList);
       result = parser.encodeResourceToString(bundle);
               
       System.out.println("Result...." + result);
            
    }
    catch (UnsupportedOperationException e) {
       status_code = 415;
       reason = "Unsupported media type";
       errorMessage = "Media type not supported.";
    } 
    catch (Throwable e) {
       status_code = 500;
       reason = "Internal Server Error";
       errorMessage = e.getMessage();
       System.out.println("Error... " + e);
    }
            
    if (status_code == 200) {
       // Set result and message variables for apigee flow if response converted successfully
       System.out.println("Valid Result");
    } 
    else {
       System.out.println("Error..!!");
    }
    */

}

From source file:opennlp.tools.similarity.apps.solr.WordDocBuilderEndNotes.java

public String buildWordDoc(List<HitBase> content, String title) {

    String outputDocFinename = absPath + "written/" + title.replace(' ', '_').replace('\"', ' ').trim()
            + ".docx";

    WordprocessingMLPackage wordMLPackage = null;

    List<String> imageURLs = getAllImageSearchResults(title);
    int count = 0;
    BigInteger refId = BigInteger.ONE;
    try {//from w  ww  .  j  a  v a2  s  .  c o  m
        wordMLPackage = WordprocessingMLPackage.createPackage();

        CTEndnotes endnotes = null;
        try {
            EndnotesPart ep = new EndnotesPart();
            endnotes = Context.getWmlObjectFactory().createCTEndnotes();
            ep.setJaxbElement(endnotes);
            wordMLPackage.getMainDocumentPart().addTargetPart(ep);
        } catch (InvalidFormatException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }

        wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Title", title.toUpperCase());
        for (HitBase para : content) {
            if (para.getFragments() == null || para.getFragments().size() < 1) // no found content in this hit
                continue;
            try {
                String processedParaTitle = processParagraphTitle(para.getTitle());

                if (processedParaTitle != null && !processedParaTitle.endsWith("..")
                        || StringUtils.isAlphanumeric(processedParaTitle)) {
                    wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Subtitle",
                            processedParaTitle);
                }
                String paraText = processParagraphText(para.getFragments().toString());
                wordMLPackage.getMainDocumentPart().addParagraphOfText(paraText);

                CTFtnEdn endnote = Context.getWmlObjectFactory().createCTFtnEdn();
                endnotes.getEndnote().add(endnote);

                endnote.setId(refId);
                refId.add(BigInteger.ONE);
                String url = para.getUrl();
                String endnoteBody = "<w:p xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ><w:pPr><w:pStyle w:val=\"EndnoteText\"/></w:pPr><w:r><w:rPr>"
                        + "<w:rStyle w:val=\"EndnoteReference\"/></w:rPr><w:endnoteRef/></w:r><w:r><w:t xml:space=\"preserve\"> "
                        + url + "</w:t></w:r></w:p>";
                try {
                    endnote.getEGBlockLevelElts().add(XmlUtils.unmarshalString(endnoteBody));
                } catch (JAXBException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                // Add the body text referencing it
                String docBody = "<w:p xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" ><w:r><w:t>"//+ paraText
                        /*+ refId.toString()*/ + "</w:t></w:r><w:r><w:rPr><w:rStyle w:val=\"EndnoteReference\"/></w:rPr><w:endnoteReference w:id=\""
                        + refId.toString() + "\"/></w:r></w:p>";

                try {
                    wordMLPackage.getMainDocumentPart().addParagraph(docBody);
                } catch (JAXBException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                try {
                    addImageByImageURLToPackage(count, wordMLPackage, imageURLs);
                } catch (Exception e) {
                    // no need to report issues
                    //e.printStackTrace();
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            count++;
        }
        // now add URLs
        wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Subtitle", "REFERENCES");
        for (HitBase para : content) {
            if (para.getFragments() == null || para.getFragments().size() < 1) // no found content in this hit
                continue;
            try {
                wordMLPackage.getMainDocumentPart().addStyledParagraphOfText("Subtitle", para.getTitle());
                String paraText = para.getUrl();
                wordMLPackage.getMainDocumentPart().addParagraphOfText(paraText);

            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        try {
            wordMLPackage.save(new File(outputDocFinename));
            System.out.println("Finished creating docx =" + outputDocFinename);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        try {
            String fileNameToDownload = "/var/www/wrt_latest/"
                    + title.replace(' ', '_').replace('\"', ' ').trim() + ".docx";
            wordMLPackage.save(new File(fileNameToDownload));
            System.out.println("Wrote a doc for download :" + fileNameToDownload);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    return outputDocFinename;
}

From source file:org.betaconceptframework.astroboa.model.jaxb.CmsEntitySerialization.java

private static JAXBContext initContext() {
    try {//  w  ww  .ja  v  a2s . c  om
        return JAXBContext.newInstance("org.betaconceptframework.astroboa.model.impl");
    } catch (JAXBException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:org.docx4j.convert.in.xhtml.XHTMLImporter.java

private void addNumbering(Element e, Map<String, CSSValue> cssMap) {
    if (ndp == null) {
        log.debug("No NumberingDefinitions part - so adding");
        try {/*w w w .  j a va2  s.c  om*/
            ndp = new NumberingDefinitionsPart();
            wordMLPackage.getMainDocumentPart().addTargetPart(ndp);
            ndp.setJaxbElement(Context.getWmlObjectFactory().createNumbering());
        } catch (InvalidFormatException e1) {
            // Won't happen
            e1.printStackTrace();
        }
    }
    Numbering.Num num = null;
    try {
        if (cssMap.get("list-style-type").getCssText().equals("decimal")) {
            num = listHelper.getOrderedList(ndp);
        }
        if (cssMap.get("list-style-type").getCssText().equals("disc")
                || cssMap.get("list-style-type").getCssText().equals("square")) {
            num = listHelper.getUnorderedList(ndp);
        }

        // TODO: support other list-style-type

        // TODO: generate list definitions based on CSS 
        // (and multiple list definitions)

    } catch (JAXBException je) {
        // Shouldn't happen
        je.printStackTrace();
        log.error("", e);
    }

    if (num == null) {
        log.warn("No support for list-style-type: " + cssMap.get("list-style-type").getCssText()); // eg decimal, disc

    } else {

        paraStillEmpty = false;

        // Create and add <w:numPr>
        NumPr numPr = Context.getWmlObjectFactory().createPPrBaseNumPr();
        currentP.getPPr().setNumPr(numPr);

        // The <w:numId> element
        NumId numIdElement = Context.getWmlObjectFactory().createPPrBaseNumPrNumId();
        numPr.setNumId(numIdElement);
        numIdElement.setVal(num.getNumId()); // point to the correct list

        // The <w:ilvl> element
        Ilvl ilvlElement = Context.getWmlObjectFactory().createPPrBaseNumPrIlvl();
        numPr.setIlvl(ilvlElement);
        ilvlElement.setVal(BigInteger.valueOf(0));

        // TMP: don't let this override our numbering
        currentP.getPPr().setInd(null);
    }
}

From source file:org.docx4j.org.apache.poi.poifs.crypt.agile.AgileEncryptionInfoBuilder.java

protected static CTEncryption parseDescriptor(String descriptor) {
    //        try {
    //            return EncryptionDocument.Factory.parse(descriptor);
    //        } catch (XmlException e) {
    //            throw new EncryptedDocumentException("Unable to parse encryption descriptor", e);
    //        }//ww  w . j  a  v a 2s .  c o  m

    log.error(descriptor);

    CTEncryption encryption = null;
    try {
        encryption = (CTEncryption) XmlUtils.unmarshalString(descriptor, Context.jcEncryption,
                CTEncryption.class);
    } catch (JAXBException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return encryption;

}

From source file:org.docx4j.org.apache.poi.poifs.crypt.agile.AgileEncryptionInfoBuilder.java

protected static CTEncryption parseDescriptor(InputStream descriptor) {
    //        try {
    //            return EncryptionDocument.Factory.parse(descriptor);
    //        } catch (Exception e) {
    //            throw new EncryptedDocumentException("Unable to parse encryption descriptor", e);
    //        }//from  w w w  .j  a  v a2s.  c  om

    //       try {
    //           descriptor.mark(0);
    //           System.out.println(IOUtils.toString(descriptor, "UTF-8") );
    //         descriptor.reset();
    //      } catch (IOException e1) {
    //         e1.printStackTrace();
    //      }

    CTEncryption encryption = null;
    try {
        encryption = (CTEncryption) XmlUtils.unwrap(XmlUtils.unmarshal(descriptor, Context.jcEncryption));
    } catch (JAXBException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return encryption;

}

From source file:org.docx4j.XmlUtils.java

public static String JAXBElementDebug(javax.xml.bind.JAXBElement o) {

    String prefix = null;/*from  w w w .j  a v a 2s. c om*/
    if (o.getName().getNamespaceURI() != null) {
        try {
            prefix = NamespacePrefixMapperUtils.getPreferredPrefix(o.getName().getNamespaceURI(), null, false);
        } catch (JAXBException e) {
            e.printStackTrace();
        }
    }
    if (prefix != null) {
        return prefix + ':' + o.getName().getLocalPart()
                + " is a javax.xml.bind.JAXBElement; it has declared type " + o.getDeclaredType().getName();
    } else {
        return o.getName() + " is a javax.xml.bind.JAXBElement; it has declared type "
                + o.getDeclaredType().getName();
    }

}

From source file:org.eclipse.winery.compliance.ToscaGraphIsomorphismTest.java

@Test
public void testServiceTemplateComplianceRuleChecker() throws IOException {
    HashMap<DefinitionsChildId, TExtensibleElements> allEntities = new HashMap<>();

    TServiceTemplate tServiceTemplate = createTServiceTemplate("ServiceTemplateTestId", TEST_TARGET_NAMESPACE);
    ComplianceRuleId crId1 = new ComplianceRuleId(new QName(TEST_TARGET_NAMESPACE, "test1"));
    ComplianceRuleId crId2 = new ComplianceRuleId(new QName(TEST_TARGET_NAMESPACE, "test2"));
    ComplianceRuleId crId3 = new ComplianceRuleId(new QName(TEST_TARGET_NAMESPACE, "test3"));

    //create NodeType
    NodeTypeId nodeTypeIdA = createNodeTypeId("IDA");
    NodeTypeId nodeTypeIdB = createNodeTypeId("IDB");
    NodeTypeId nodeTypeIdC = createNodeTypeId("IDC");
    NodeTypeId nodeTypeIdD = createNodeTypeId("IDD");

    TNodeType nodeTypeA = createTNodeType(nodeTypeIdA);
    allEntities.put(nodeTypeIdA, nodeTypeA);

    TNodeType nodeTypeB = createTNodeType(nodeTypeIdB);
    setDerivedFrom(nodeTypeIdA, nodeTypeB);
    allEntities.put(nodeTypeIdB, nodeTypeB);

    TNodeType nodeTypeC = createTNodeType(nodeTypeIdC);
    setDerivedFrom(nodeTypeIdA, nodeTypeC);
    allEntities.put(nodeTypeIdC, nodeTypeC);

    TNodeType nodeTypeD = createTNodeType(nodeTypeIdD);
    allEntities.put(nodeTypeIdD, nodeTypeD);

    TNodeTemplate ruleOneIdentifier = createTNodeTemplate("R1_I", nodeTypeIdA);
    TNodeTemplate ruleOneRequiredStructure = createTNodeTemplate("R1_RS", nodeTypeIdB);

    TNodeTemplate ruleTwoIdentifier = createTNodeTemplate("R2_I", nodeTypeIdA);
    TNodeTemplate ruleTwoRequiredStructure = createTNodeTemplate("R2_RS", nodeTypeIdC);

    TNodeTemplate ruleThreeIdentifier = createTNodeTemplate("R3_I", nodeTypeIdA);
    TNodeTemplate ruleThreeRequiredStructure = createTNodeTemplate("R3_RS", nodeTypeIdD);

    TNodeTemplate serviceTemplateTopology = createTNodeTemplate("ST", nodeTypeIdB);

    //satisfied/*from w  ww. ja  v  a2 s. c o  m*/
    TComplianceRule ruleOne = createTComplianceRule(crId1);
    ruleOne.setIdentifier(createTTopologyTemplate(Arrays.asList(ruleOneIdentifier), newArrayList()));
    ruleOne.setRequiredStructure(
            createTTopologyTemplate(Arrays.asList(ruleOneRequiredStructure), newArrayList()));
    allEntities.put(crId1, ruleOne);

    //unsatisfied
    TComplianceRule ruleTwo = createTComplianceRule(crId2);
    ruleTwo.setIdentifier(createTTopologyTemplate(Arrays.asList(ruleTwoIdentifier), newArrayList()));
    ruleTwo.setRequiredStructure(
            createTTopologyTemplate(Arrays.asList(ruleTwoRequiredStructure), newArrayList()));
    allEntities.put(crId2, ruleTwo);

    //invalid rule
    TComplianceRule ruleThree = createTComplianceRule(crId3);
    ruleThree.setIdentifier(createTTopologyTemplate(Arrays.asList(ruleThreeIdentifier), newArrayList()));
    ruleThree.setRequiredStructure(
            createTTopologyTemplate(Arrays.asList(ruleThreeRequiredStructure), newArrayList()));
    allEntities.put(crId3, ruleThree);
    tServiceTemplate.setTopologyTemplate(
            createTTopologyTemplate(Arrays.asList(serviceTemplateTopology), newArrayList()));

    persist(allEntities);

    ServiceTemplateComplianceRuleRuleChecker checker = new ServiceTemplateComplianceRuleRuleChecker(
            tServiceTemplate);

    assertEquals(3, checker.getRuleIds(tServiceTemplate).stream().count());
    assertEquals(3, checker.getRuleIds(tServiceTemplate).stream()
            .filter(id -> id.getQName().getLocalPart().matches("test1|test2|test3")).count());

    ServiceTemplateCheckingResult serviceTemplateCheckingResult = checker.checkComplianceRules();
    assertEquals(1, serviceTemplateCheckingResult.getSatisfied().size());
    assertEquals(1, serviceTemplateCheckingResult.getUnsatisfied().size());
    assertEquals(1, serviceTemplateCheckingResult.getException().size());

    JAXBContext jaxbContext = null;
    try {
        jaxbContext = JAXBContext.newInstance(ServiceTemplateCheckingResult.class);

        Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
        jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        StringWriter sw = new StringWriter();
        jaxbMarshaller.marshal(serviceTemplateCheckingResult, sw);
        System.out.println(sw.toString());
    } catch (JAXBException e) {
        e.printStackTrace();
    }
}

From source file:org.efaps.twoplan.test.ProjectTest.java

@Test
public void unmarschall() {
    final File file = FileUtils.getFile("src", "test", "resources", "2plan.prj");
    try {//ww w.j  a  v  a 2  s  . c  o  m
        if (file.exists()) {
            final JAXBContext jc = JAXBContext.newInstance(AbstractObject.class, Calendar.class, Entries.class,
                    Maps.class, Project.class, WorkPackage.class, DateTime.class);
            final Unmarshaller unmarshaller = jc.createUnmarshaller();
            final Object object = unmarshaller.unmarshal(file);
            if (object instanceof Project) {

            }
        }
    } catch (final JAXBException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}