List of usage examples for javax.xml.bind JAXBException getMessage
public String getMessage()
From source file:org.jasig.portlet.courses.dao.xml.Jaxb2CourseSummaryHttpMessageConverter.java
/** * Returns a {@link JAXBContext} for the given class. * * @param clazz the class to return the context for * @return the {@code JAXBContext}/* w ww . j a va 2s . co m*/ * @throws HttpMessageConversionException in case of JAXB errors */ protected final JAXBContext getWrapperJaxbContext(Class clazz) { Assert.notNull(clazz, "'clazz' must not be null"); JAXBContext jaxbContext = jaxbContexts.get(clazz); if (jaxbContext == null) { try { jaxbContext = JAXBContext.newInstance(clazz); jaxbContexts.putIfAbsent(clazz, jaxbContext); } catch (JAXBException ex) { throw new HttpMessageConversionException( "Could not instantiate JAXBContext for class [" + clazz + "]: " + ex.getMessage(), ex); } } return jaxbContext; }
From source file:com.xerox.amazonws.sqs.QueueService.java
/** * Retrieves a list of message queues. A maximum of 1,000 queue URLs are returned. * If a value is specified for the optional queueNamePrefix parameter, only those queues * with a queue name beginning with the value specified are returned. The queue name is * specified in the QueueName parameter when a queue is created. * * @param queueNamePrefix the optional prefix for filtering results. can be null. * @return a list of objects representing the message queues defined for this account *//*w ww .j av a 2 s. c om*/ public List<MessageQueue> listMessageQueues(String queueNamePrefix) throws SQSException { Map<String, String> params = new HashMap<String, String>(); if (queueNamePrefix != null && !queueNamePrefix.trim().equals("")) { params.put("QueueNamePrefix", queueNamePrefix); } GetMethod method = new GetMethod(); try { ListQueuesResponse response = makeRequest(method, "ListQueues", params, ListQueuesResponse.class); return MessageQueue.createList(response.getQueueUrls().toArray(new String[] {}), getAwsAccessKeyId(), getSecretAccessKey(), isSecure(), getServer(), getHttpClient()); } catch (JAXBException ex) { throw new SQSException("Problem parsing returned message.", ex); } catch (HttpException ex) { throw new SQSException(ex.getMessage(), ex); } catch (IOException ex) { throw new SQSException(ex.getMessage(), ex); } finally { method.releaseConnection(); } }
From source file:com.eurelis.opencms.workflows.workflows.WorkflowConfigManager.java
/** * This method initialize the Workflow Right Manager. It loads the list of * available workflows and parse the associated files so as to obtain the * associated rights.// w ww. j ava2s . c om */ private void initialize() { // The workflow Collector so as to get the list of workflows to manage I_AvailableWorkflowCollector workflowCollector = AvailableWorkflowCollectorFactory.getInstance(); // get map of associated workflows Map<WorkflowKey, DescriptionContainer> listOfAvailablesWorkflows = workflowCollector .get_mapOfAvailableWorkflows(); /* * for each workflows, get the right file path and parse the file to * collect the informations */ Iterator<Entry<WorkflowKey, DescriptionContainer>> listOfAvailablesWorkflowsIterator = listOfAvailablesWorkflows .entrySet().iterator(); while (listOfAvailablesWorkflowsIterator.hasNext()) { Entry<WorkflowKey, DescriptionContainer> entry = listOfAvailablesWorkflowsIterator.next(); // get right file path String filePath = entry.getValue().get_rightsFilePath(); // parse right file and store result try { _mapsOfParameterPerWorkflows.put(entry.getKey(), this.extractWorkflowParameterFromCongifAndRightFile(filePath)); } catch (JAXBException e) { LOGGER.warn("An error occurs during the parsing of " + filePath + " (" + e.getMessage() + ")"); } } }
From source file:net.ageto.gyrex.impex.persistence.cassandra.storage.CassandraRepositoryImpl.java
/** * Persist process configuration./*from w ww . j av a 2s.c o m*/ * * @param process */ public void insertOrUpdateProcess(IProcessConfig process) { JAXBContext context; ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try { context = JAXBContext.newInstance(ProcessConfig.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); // process / process step configuration xml formatted m.marshal(process, outputStream); } catch (JAXBException e) { throw new IllegalArgumentException(e.getMessage()); } Mutator<String> mutator = HFactory.createMutator(getImpexKeyspace(), StringSerializer.get()); // insert process configuration mutator.insert(process.getId(), columnFamilyProcesses, HFactory.createStringColumn(columnNameProcess, outputStream.toString())); }
From source file:com.mc.printer.model.panel.task.BuildModelTask.java
@Override public Object doBackgrounp() { javax.swing.JTabbedPane tabs = AutoPrinterApp.getMainView().getMainWorkPanel(); if (tabs != null) { if (tabs.getSelectedIndex() >= 0) { Component selectedcom = tabs.getSelectedComponent(); if (selectedcom instanceof CanvasWork) { CanvasWork selectPanel = (CanvasWork) selectedcom; FormBeans beansForm = selectPanel.getBeansForm(); /**/ if (beansForm.getHeightcm() == 0 || beansForm.getWidthcm() == 0) { int res = BaseMessage.CONFIRM( "?\r\nA4."); if (res != JOptionPane.OK_OPTION) { return null; }/*from w w w. j a v a2s . c o m*/ } String imagePath = beansForm.getImgpath(); HashMap<String, ComponentBean> parameterMap = selectPanel.getSavedForms(); if (parameterMap.size() > 0) { Set set = parameterMap.keySet(); boolean foundKey = false; //??? List<ComponentBean> beans = new ArrayList(); Iterator it = set.iterator(); while (it.hasNext()) { ComponentBean com = parameterMap.get(it.next().toString()); beans.add(com); if (com.isIskey()) { foundKey = true; } } beansForm.setElements(beans); // // if (!foundKey) { // BaseMessage.ERROR("PRIMARY KEY."); // return null; // } BaseFileChoose fileChoose = new BaseFileChoose("?", new String[] { Constants.MODEL_SUFFIX }, AutoPrinterApp.getMainFrame()); String selectedPath = fileChoose.showSaveDialog(); if (!selectedPath.trim().equals("")) { //get formname selectedPath = selectedPath + File.separator + beansForm.getFormname(); //String time=DateHelper.format(new Date(), "yyyyMMddHHmmss"); String finalZip = selectedPath; if (!selectedPath.endsWith("." + Constants.MODEL_SUFFIX)) { finalZip = selectedPath + "." + Constants.MODEL_SUFFIX; } String tempDir = selectedPath + File.separator + Constants.MODEL_TEMP_DIR; File imageFile = new File(imagePath); String xmlPath = tempDir + File.separator + imageFile.getName() + ".xml"; XMLHelper helper = new XMLHelper(xmlPath, beansForm); try { helper.write(); } catch (JAXBException ex) { ex.printStackTrace(); logger.error(ex.getMessage()); return ex; } File paramFile = new File(xmlPath); if (paramFile.isFile() && paramFile.exists()) { try { FileUtils.copyFileToDirectory(imageFile, new File(tempDir)); ZipHelper.createZip(tempDir, finalZip); return "??.\r\n" + finalZip; } catch (IOException ex) { ex.printStackTrace(); logger.error(ex.getMessage()); return ex; } finally { try { FileUtils.deleteDirectory(new File(selectedPath)); } catch (IOException ex) { ex.printStackTrace(); logger.error(ex.getMessage()); return ex; } } } } } else { return "??."; } } else { return "??????."; } } else { return "."; } } else { return "."; } return null; }
From source file:com.xerox.amazonws.sqs2.QueueService.java
/** * Retrieves a list of message queues. A maximum of 1,000 queue URLs are returned. * If a value is specified for the optional queueNamePrefix parameter, only those queues * with a queue name beginning with the value specified are returned. The queue name is * specified in the QueueName parameter when a queue is created. * * @param queueNamePrefix the optional prefix for filtering results. can be null. * @return a list of objects representing the message queues defined for this account *///from w w w. java2 s . c o m public List<MessageQueue> listMessageQueues(String queueNamePrefix) throws SQSException { Map<String, String> params = new HashMap<String, String>(); if (queueNamePrefix != null && !queueNamePrefix.trim().equals("")) { params.put("QueueNamePrefix", queueNamePrefix); } GetMethod method = new GetMethod(); try { ListQueuesResponse response = makeRequest(method, "ListQueues", params, ListQueuesResponse.class); List<String> urls = response.getListQueuesResult().getQueueUrls(); if (urls == null) { return new ArrayList<MessageQueue>(); } else { return MessageQueue.createList(urls.toArray(new String[] {}), getAwsAccessKeyId(), getSecretAccessKey(), isSecure(), getServer(), getHttpClient()); } } catch (JAXBException ex) { throw new SQSException("Problem parsing returned message.", ex); } catch (HttpException ex) { throw new SQSException(ex.getMessage(), ex); } catch (IOException ex) { throw new SQSException(ex.getMessage(), ex); } finally { method.releaseConnection(); } }
From source file:net.ageto.gyrex.impex.persistence.cassandra.storage.CassandraRepositoryImpl.java
/** * Find process by the given id.// w w w . ja va 2 s .com * * @param id * @return */ public IProcessConfig findProcessById(String id) { ColumnQuery<String, String, String> columnQuery = HFactory.createStringColumnQuery(getImpexKeyspace()); columnQuery.setColumnFamily(columnFamilyProcesses).setKey(id).setName(columnNameProcess); QueryResult<HColumn<String, String>> result = columnQuery.execute(); HColumn<String, String> column = result.get(); IProcessConfig process = null; if (column != null) { try { JAXBContext context = JAXBContext.newInstance(ProcessConfig.class); Unmarshaller u = context.createUnmarshaller(); StringReader reader = new StringReader(column.getValue()); // create process from xml process = (ProcessConfig) u.unmarshal(reader); } catch (JAXBException e) { throw new IllegalArgumentException(e.getMessage()); } } return process; }
From source file:com.xerox.amazonws.sqs.QueueService.java
/** * Creates a new message queue. The queue name must be unique within the scope of the * queues you own. Optionaly, you can supply a queue that might be one that belongs to * another user that has granted you access to the queue. In that case, supply the fully * qualified queue name (i.e. "/A98KKI3K0RJ7Q/grantedQueue"). * * @param queueName name of queue to be created * @return object representing the message queue *//*from w w w . j a va 2s .co m*/ public MessageQueue getOrCreateMessageQueue(String queueName) throws SQSException { if ((queueName.charAt(0) == '/' && queueName.lastIndexOf('/') > 0) || queueName.startsWith("http")) { return getMessageQueue(queueName); } else { Map<String, String> params = new HashMap<String, String>(); params.put("QueueName", queueName); GetMethod method = new GetMethod(); try { CreateQueueResponse response = makeRequest(method, "CreateQueue", params, CreateQueueResponse.class); MessageQueue mq = new MessageQueue(response.getQueueUrl(), getAwsAccessKeyId(), getSecretAccessKey(), isSecure(), getServer()); mq.setHttpClient(getHttpClient()); return mq; } catch (JAXBException ex) { throw new SQSException("Problem parsing returned message.", ex); } catch (HttpException ex) { throw new SQSException(ex.getMessage(), ex); } catch (IOException ex) { throw new SQSException(ex.getMessage(), ex); } finally { method.releaseConnection(); } } }
From source file:com.cws.esolutions.agent.AgentDaemon.java
public void init(final DaemonContext dContext) throws DaemonInitException { final String methodName = AgentDaemon.CNAME + "#init(final DaemonContext dContext) throws DaemonInitException"; if (DEBUG) {/* w w w . j a v a 2 s . c o m*/ DEBUGGER.debug(methodName); DEBUGGER.debug("DaemonContext: {}", dContext); } JAXBContext context = null; Unmarshaller marshaller = null; final File xmlFile = new File( AgentConstants.CURRENT_DIRECTORY + System.getProperty(AgentDaemon.APP_CONFIG)); if (DEBUG) { DEBUGGER.debug("xmlFile: {}", xmlFile); } try { if (!(xmlFile.canRead())) { throw new DaemonInitException("No configuration file was located. Shutting down !"); } // set the app configuration context = JAXBContext.newInstance(ConfigurationData.class); marshaller = context.createUnmarshaller(); ConfigurationData configData = (ConfigurationData) marshaller.unmarshal(xmlFile); if (DEBUG) { DEBUGGER.debug("ConfigurationData: {}", configData); } String osName = System.getProperty("os.name").toLowerCase(); if (DEBUG) { DEBUGGER.debug("osName: {}", osName); } if (osName.indexOf("win") >= 0) { AgentDaemon.agentBean.setOsType(OSType.WINDOWS); } else if (osName.indexOf("mac") >= 0) { AgentDaemon.agentBean.setOsType(OSType.MAC); } else if ((osName.indexOf("nix") >= 0) || (osName.indexOf("sunos") >= 0) || (osName.indexOf("aix") >= 0)) { AgentDaemon.agentBean.setOsType(OSType.UNIX); } AgentDaemon.agentBean.setHostName(InetAddress.getLocalHost().getHostName()); AgentDaemon.agentBean.setConfigData(configData); } catch (JAXBException jx) { ERROR_RECORDER.error(jx.getMessage(), jx); this.exitCode = 1; stop(); } catch (UnknownHostException uhx) { ERROR_RECORDER.error(uhx.getMessage(), uhx); this.exitCode = 1; stop(); } }
From source file:com.xerox.amazonws.sqs2.QueueService.java
/** * Creates a new message queue. The queue name must be unique within the scope of the * queues you own. Optionaly, you can supply a queue that might be one that belongs to * another user that has granted you access to the queue. In that case, supply the fully * qualified queue name (i.e. "/A98KKI3K0RJ7Q/grantedQueue"). * * @param queueName name of queue to be created * @return object representing the message queue *///from w w w.j av a 2 s.c o m public MessageQueue getOrCreateMessageQueue(String queueName) throws SQSException { if ((queueName.charAt(0) == '/' && queueName.lastIndexOf('/') > 0) || queueName.startsWith("http")) { return getMessageQueue(queueName); } else { Map<String, String> params = new HashMap<String, String>(); params.put("QueueName", queueName); GetMethod method = new GetMethod(); try { CreateQueueResponse response = makeRequest(method, "CreateQueue", params, CreateQueueResponse.class); MessageQueue ret = new MessageQueue(response.getCreateQueueResult().getQueueUrl(), getAwsAccessKeyId(), getSecretAccessKey(), isSecure(), getServer()); ret.setHttpClient(getHttpClient()); return ret; } catch (JAXBException ex) { throw new SQSException("Problem parsing returned message.", ex); } catch (HttpException ex) { throw new SQSException(ex.getMessage(), ex); } catch (IOException ex) { throw new SQSException(ex.getMessage(), ex); } finally { method.releaseConnection(); } } }