List of usage examples for javax.xml.bind JAXBException printStackTrace
public void printStackTrace()
From source file:org.pmedv.core.provider.ApplicationWindowConfigurationProviderImpl.java
public ApplicationWindowConfigurationProviderImpl() { try {/*from w ww . j a va 2 s.co m*/ InputStream is = Thread.currentThread().getContextClassLoader() .getResourceAsStream("application.properties"); Properties p = new Properties(); p.load(is); String inputDir = System.getProperty("user.home") + "/." + p.getProperty("app.name") + "/"; String inputFile = "appWindowConfig.xml"; JAXBContext c = JAXBContext.newInstance(ApplicationWindowConfiguration.class); Unmarshaller u = c.createUnmarshaller(); ApplicationWindowConfiguration appWindowConfig = (ApplicationWindowConfiguration) u .unmarshal(new FileInputStream(new File(inputDir + inputFile))); config = appWindowConfig; } catch (JAXBException e) { e.printStackTrace(); log.error("could not deserialize application window configuration."); throw new RuntimeException("could not deserialize application window configuration."); } catch (Exception e) { e.printStackTrace(); log.error("could not load application window configuration, creating new."); ApplicationWindowConfiguration c = new ApplicationWindowConfiguration(); config = c; } }
From source file:org.rifidi.designer.services.core.entities.EntitiesServiceImpl.java
/** * Helper method to convert the given SceneData into a saveable byte array. * //from www . j av a 2 s . c o m * @return */ @SuppressWarnings("unchecked") private byte[] toByteArray(SceneData sceneData) { ByteArrayOutputStream bo = new ByteArrayOutputStream(); BinaryExporter jmee = new BinaryExporter(); ByteArrayOutputStream fileOutput = new ByteArrayOutputStream(); try { jmee.save(sceneData.getRootNode(), bo); } catch (IOException e1) { e1.printStackTrace(); } try { sceneData.setNodeBytes(bo.toByteArray()); EntityLibraryRegistry.getInstance().getLibraries(); List<Class> classes = EntityLibraryRegistry.getInstance().getEntityClasses(); classes.add(org.rifidi.designer.entities.SceneData.class); classes.add(org.rifidi.designer.entities.VisualEntity.class); classes.add(org.rifidi.emulator.tags.impl.C0G1Tag.class); classes.add(org.rifidi.emulator.tags.impl.C1G1Tag.class); classes.add(org.rifidi.emulator.tags.impl.C1G2Tag.class); classes.add(org.rifidi.emulator.tags.impl.RifidiTag.class); JAXBContext context = JAXBContext.newInstance(classes.toArray(new Class[0])); Marshaller marshaller = context.createMarshaller(); marshaller.marshal(sceneData, fileOutput); } catch (JAXBException e) { e.printStackTrace(); } return fileOutput.toByteArray(); }
From source file:org.saiku.repository.ClassPathRepositoryManager.java
public List<DataSource> getAllDataSources() throws RepositoryException { List<DataSource> ds = new ArrayList<>(); String[] extensions = new String[1]; extensions[0] = "sds"; Collection<File> files = FileUtils.listFiles(new File(append), extensions, true); for (File file : files) { JAXBContext jaxbContext = null; Unmarshaller jaxbMarshaller = null; try {/*from w w w. jav a 2s. c o m*/ jaxbContext = JAXBContext.newInstance(DataSource.class); } catch (JAXBException e) { log.error("Could not read XML", e); } try { jaxbMarshaller = jaxbContext != null ? jaxbContext.createUnmarshaller() : null; } catch (JAXBException e) { log.error("Could not read XML", e); } InputStream stream = null; try { stream = (FileUtils.openInputStream(file)); } catch (IOException e) { e.printStackTrace(); } DataSource d = null; try { d = (DataSource) (jaxbMarshaller != null ? jaxbMarshaller.unmarshal(stream) : null); } catch (JAXBException e) { log.error("Could not read XML", e); } if (d != null) { d.setPath(file.getPath()); } if (file.getParentFile().isDirectory()) { String p = file.getParent(); p = p.replace("\\", "/"); String[] s = p.split("/"); log.debug("p split: " + p); String[] t = append.split("/"); if (!s[s.length - 2].equals(t[t.length - 1])) { d.setName(s[s.length - 2] + "_" + (d != null ? d.getName() : "")); } } ds.add(d); } return ds; }
From source file:org.saiku.repository.ClassPathRepositoryManager.java
public void saveDataSource(DataSource ds, String path, String user) throws RepositoryException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try {/* ww w . jav a 2 s . c o m*/ JAXBContext jaxbContext = JAXBContext.newInstance(DataSource.class); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); // output pretty printed jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); jaxbMarshaller.marshal(ds, baos); } catch (JAXBException e) { log.error("Could not read XML", e); } int pos = path.lastIndexOf(sep); String filename = "." + sep + path.substring(pos + 1, path.length()); //File n = getFolder(path.substring(0, pos)); File f = this.createNode(path); try { FileWriter fileWriter = new FileWriter(f); fileWriter.write(baos.toString()); fileWriter.flush(); fileWriter.close(); } catch (IOException e) { e.printStackTrace(); } }
From source file:org.sigmah.server.schedule.ReportMailerJob.java
private void mailReport(ReportSubscription sub, Date today) throws IOException, SAXException, EmailException { // apply the appropriate filters so the user // only views the reports they're meant to DomainFilters.applyUserFilter(sub.getUser(), em); // load the report definition Report report = null;//from www .j a va 2 s . co m try { report = ReportParserJaxb.parseXml(sub.getTemplate().getXml()); } catch (JAXBException e) { e.printStackTrace(); return; } // generate the report reportGenerator.generate(sub.getUser(), report, null, ReportMailerHelper.computeDateRange(report, today)); // render the report to a temporary path and create the // attachement File tempFile = File.createTempFile("report", ".rtf"); FileOutputStream rtf = new FileOutputStream(tempFile); rtfReportRenderer.render(report, rtf); rtf.close(); EmailAttachment attachment = new EmailAttachment(); attachment.setName(report.getContent().getFileName() + reportDateFormat.format(today) + ".rtf"); attachment.setDescription(report.getTitle()); attachment.setPath(tempFile.getAbsolutePath()); attachment.setDisposition(EmailAttachment.ATTACHMENT); // compose both a full html rendering of this report and a short text // message for email clients that can't read html // email MultiPartEmail email = new MultiPartEmail(); // email.setHtmlMsg(ReportMailerHelper.composeHtmlEmail(sub, report )); email.setMsg(ReportMailerHelper.composeTextEmail(sub, report)); email.addTo(sub.getUser().getEmail(), sub.getUser().getName()); email.setSubject("ActivityInfo: " + report.getTitle()); email.attach(attachment); mailer.send(email); }
From source file:org.squidy.designer.model.ModelViewHandler.java
public static void resetJAXBContext(Class<?> type) { // TODO [RR]: This is a DIRTY hack! // PackageScanner.CLASS_CACHE.clear(); if (!PackageScanner.CLASS_CACHE.contains(type)) { PackageScanner.CLASS_CACHE.add(type); }// ww w .ja v a2 s . co m String[] classes = PackageScanner.findAllClassNamesWithAnnotation(Processor.class); List<String> only = new ArrayList<String>(); for (String className : classes) { if (!type.getName().equals(className)) { only.add(className); System.out.println("IN: " + className); } else { System.out.println("REMOVED: " + className); } } try { context = null; ClassLoader classLoader = DynamicCodeClassLoader.DYNAMIC_CODE; context = JAXBContext .newInstance(ReflectionUtil.loadContextClasses(classLoader, only.toArray(new String[0]), type, Data.class, WorkspaceShape.class, Workspace.class, PipelineShape.class, Pipeline.class, NodeShape.class, Node.class, PipeShape.class, Pipe.class, LayerDemoShape.class)); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.squidy.manager.parser.ModelHandler.java
public static void resetJAXBContext(Class<?> type) { // TODO [RR]: This is a DIRTY hack! // PackageScanner.CLASS_CACHE.clear(); if (!PackageScanner.CLASS_CACHE.contains(type)) { PackageScanner.CLASS_CACHE.add(type); }/* ww w. j a va 2 s .c om*/ String[] classes = PackageScanner.findAllClassNamesWithAnnotation(Processor.class); List<String> only = new ArrayList<String>(); for (String className : classes) { if (!type.getName().equals(className)) { only.add(className); System.out.println("IN: " + className); } else { System.out.println("REMOVED: " + className); } } try { context = null; ClassLoader classLoader = DynamicCodeClassLoader.DYNAMIC_CODE; context = JAXBContext .newInstance(ReflectionUtil.loadContextClasses(classLoader, only.toArray(new String[0]), type, Data.class, Workspace.class, Pipeline.class, Node.class, Pipe.class)); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
From source file:org.telscenter.sail.webapp.domain.brainstorm.question.impl.JaxbQuestionImpl.java
/** * @param prompt the prompt to set// w ww. j a v a 2 s . com */ public void setPrompt(String prompt) { this.prompt = BrainstormUtils.replaceTags(prompt); if (blockInteractionType == null) { parseToQTI(this.body); } List<Serializable> blockContent = blockInteractionType.getPrompt().getContent(); if (blockContent != null) { blockContent.set(0, this.prompt); try { this.body = JaxbQtiMarshallingUtils.marshallAssessmentItemTypeToString(assessmentItemType); } catch (JAXBException e) { e.printStackTrace(); } } }
From source file:org.telscenter.sail.webapp.domain.brainstorm.question.impl.JaxbQuestionImpl.java
public void setNewChoices(String choiceList) { if (blockInteractionType == null) { parseToQTI(this.body); }//from w w w . j a v a 2 s.c o m List<SimpleChoiceType> copiedChoices = new LinkedList<SimpleChoiceType>(); copiedChoices.addAll(this.getChoices()); for (SimpleChoiceType choice : copiedChoices) { JaxbQtiCreationUtils.removeChoice(this.blockInteractionType, choice); } if (choiceList != null && choiceList != "") { Map<String, String> choiceMap = BrainstormUtils.parseChoices(choiceList); for (String key : choiceMap.keySet()) { this.addChoice(key, choiceMap.get(key)); } } try { this.body = JaxbQtiMarshallingUtils.marshallAssessmentItemTypeToString(assessmentItemType); } catch (JAXBException e) { e.printStackTrace(); } }
From source file:org.telscenter.sail.webapp.domain.brainstorm.question.impl.JaxbQuestionImpl.java
public void setCorrectChoice(String identifier) { if (blockInteractionType == null) { parseToQTI(this.body); }/* w ww . j a va 2 s .c o m*/ this.assessmentItemType.getResponseDeclaration().get(0).getCorrectResponse().getValue().get(0) .setValue(identifier); try { this.body = JaxbQtiMarshallingUtils.marshallAssessmentItemTypeToString(assessmentItemType); } catch (JAXBException e) { e.printStackTrace(); } }