List of usage examples for javax.xml.bind JAXBException printStackTrace
public void printStackTrace()
From source file:alter.vitro.vgw.service.resourceRegistry.ResourceAvailabilityService.java
public String createSynchConfirmationForVSPFromCurrentStatus_VGWInitiated() { String retStr = ""; try {//from w ww. ja v a 2 s.c o m EnableNodesRespType response; javax.xml.bind.JAXBContext jaxbContext = javax.xml.bind.JAXBContext .newInstance("alter.vitro.vgw.service.query.xmlmessages.enablednodessynch.fromvgw"); // create an object to marshal ObjectFactory theFactory = new ObjectFactory(); response = theFactory.createEnableNodesRespType(); if (response != null) { response.setVgwId(VitroGatewayService.getVitroGatewayService().getAssignedGatewayUniqueIdFromReg()); response.setMessageType(UserNodeResponse.COMMAND_TYPE_ENABLENODES_RESP); response.setTimestamp(Long.toString(new Date().getTime())); if (response.getConfirmedEnabledNodesList() == null) { ConfirmedEnabledNodesListType theConfirmListType = new ConfirmedEnabledNodesListType(); response.setConfirmedEnabledNodesList(theConfirmListType); for (String devId : getCachedDiscoveredDevices().keySet()) { CSmartDevice smDevTmp = getCachedDiscoveredDevices().get(devId); // AND CONSTRUCT THE CONFIRMATION MESSAGE! ConfirmedEnabledNodesListItemType confirmedItemTmp = new ConfirmedEnabledNodesListItemType(); confirmedItemTmp.setNodeId(smDevTmp.getId()); boolean updatedByVGW = smDevTmp.getRegistryProperties().isStatusWasDecidedByThisVGW(); boolean currStatus = smDevTmp.getRegistryProperties().isEnabled(); String updatedByVGWStr = updatedByVGW ? "1" : "0"; String currStatusStr = currStatus ? "enabled" : "disabled"; confirmedItemTmp.setStatus(currStatusStr); confirmedItemTmp.setGwInitFlag(updatedByVGWStr); confirmedItemTmp.setOfRemoteTimestamp(Long.toString( smDevTmp.getRegistryProperties().getTimeStampEnabledStatusRemotelySynch())); theConfirmListType.getConfirmedEnabledNodesListItem().add(confirmedItemTmp); } } javax.xml.bind.Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); JAXBElement<EnableNodesRespType> myResponseMsgEl = theFactory.createEnableNodesResp(response); ByteArrayOutputStream baos = new ByteArrayOutputStream(); marshaller.marshal(myResponseMsgEl, baos); retStr = baos.toString(HTTP.UTF_8); } } catch (javax.xml.bind.JAXBException je) { je.printStackTrace(); } catch (UnsupportedEncodingException e2) { e2.printStackTrace(); } logger.debug("Sending UPDATE FROM VGW (enable-disable): " + retStr); return retStr; }
From source file:at.ac.tuwien.dsg.cloud.salsa.engine.smartdeployment.QUELLE.QuelleService.java
public List<CloudProvider> loadCloudAllDescription() { List<CloudProvider> providers = new ArrayList<>(); CloudDataExtensionFilter filter = new CloudDataExtensionFilter(cloudDescriptionFileExtension); File dir = new File(SalsaConfiguration.getCloudProviderDescriptionDir()); if (dir.isDirectory() == false) { EngineLogger.logger.debug("Error: Cannot find the directory storing cloud descriptions"); return loadDefaultDescription(); }/* w w w. j a v a 2 s .c o m*/ String[] list = dir.list(filter); if (list.length == 0) { EngineLogger.logger.debug("No file with extension : " + cloudDescriptionFileExtension + " is found. No cloud provider description is load."); return loadDefaultDescription(); } for (String file : list) { String temp = new StringBuffer(SalsaConfiguration.getCloudProviderDescriptionDir()) .append(File.separator).append(file).toString(); EngineLogger.logger.debug("Loading cloud description in file: " + temp); File loadingFile = new File(temp); JAXBContext jaxbContext; try { jaxbContext = JAXBContext.newInstance(CloudProvider.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); CloudProvider provider = (CloudProvider) jaxbUnmarshaller.unmarshal(loadingFile); providers.add(provider); } catch (JAXBException ex) { EngineLogger.logger.debug("Cannot load cloud description file: " + temp); ex.printStackTrace(); } } return providers; }
From source file:at.ac.tuwien.dsg.cloud.salsa.engine.smartdeployment.QUELLE.QuelleService.java
public CloudProvider loadSpecificCloudProvider(String name) { File dir = new File(SalsaConfiguration.getCloudProviderDescriptionDir()); CloudDataExtensionFilter filter = new CloudDataExtensionFilter(cloudDescriptionFileExtension); if (dir.isDirectory() == false) { EngineLogger.logger.debug("Error: Cannot find the directory storing cloud descriptions"); return null; }//from w w w . j ava 2s . c om String[] list = dir.list(filter); if (list.length == 0) { EngineLogger.logger.debug("No file with extension : " + cloudDescriptionFileExtension + " is found. No cloud provider description is load."); return null; } for (String file : list) { String temp = new StringBuffer(SalsaConfiguration.getCloudProviderDescriptionDir()) .append(File.separator).append(file).toString(); EngineLogger.logger.debug("Loading cloud description in file: " + temp); File loadingFile = new File(temp); JAXBContext jaxbContext; try { jaxbContext = JAXBContext.newInstance(CloudProvider.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); CloudProvider provider = (CloudProvider) jaxbUnmarshaller.unmarshal(loadingFile); if (provider.getName().equals(name)) { EngineLogger.logger.debug("Found cloud provider with name: " + name + ". Load file: " + temp); return provider; } else { EngineLogger.logger.debug("Loaded file: " + temp + ", but the provider name is " + provider.getName() + " is not what we are looking for: " + name); } } catch (JAXBException ex) { EngineLogger.logger.debug("Cannot load cloud description file: " + temp); ex.printStackTrace(); } } EngineLogger.logger.debug("Found no cloud provider with name: " + name); return null; }
From source file:at.ac.tuwien.dsg.cloud.salsa.engine.smartdeployment.QUELLE.QuelleService.java
public List<CloudProvider> loadDefaultDescription() { List<CloudProvider> defaultList = new ArrayList<>(); String resourceFile = "/quelle_default/amazonDescription.xml"; EngineLogger.logger.debug("Loading default cloud description in the resource folder: " + resourceFile); InputStream is = QuelleService.class.getResourceAsStream(resourceFile); JAXBContext jaxbContext;/*from w w w .j a v a2 s . c o m*/ try { jaxbContext = JAXBContext.newInstance(CloudProvider.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); CloudProvider provider = (CloudProvider) jaxbUnmarshaller.unmarshal(is); if (provider != null) { EngineLogger.logger.debug("Default cloud provider load done: " + provider.getName()); } defaultList.add(provider); } catch (JAXBException ex) { EngineLogger.logger.debug("Cannot load cloud description file in resource folder: " + resourceFile); ex.printStackTrace(); } return defaultList; }
From source file:org.megam.deccanplato.provider.zoho.invoice.handler.InvoiceImpl.java
/** * this method creates an invoice in zoho invoice and returns that invoice details. * and it uses the business support class invoice, paymentgateway and invoiceitem to populate ZOHO invoice XML input * This method takes input as a MAP(contains json dada) and returns a MAP. * @param outMap // w w w . j a v a2s. co m */ private Map<String, String> create(Map<String, String> outMap) { final String ZOHO_INVOICE_INVOICE_CREATE_URL = "https://invoice.zoho.com/api/view/invoices/create"; Invoice invoice = new Invoice(); PaymentGateway paygate = new PaymentGateway(); InvoiceItem invoiceitem = new InvoiceItem(); invoice.setCustomerID(args.get(CUSTOMERID)); invoice.setInvoiceDate(args.get(INVOICE_DATE)); invoice.setPONumber(args.get(PONUMPER)); invoice.setExchangeRate(args.get(EXCHANGE_RATE)); invoice.setCustom_Body(args.get(CUSTOM_BODY)); invoice.setCustom_Subject(args.get(CUSTOM_SUBJECT)); paygate.setAuthorize_Net(args.get(AUTHORIZE_NET)); invoice.getPaymentGateways().add(paygate); invoiceitem.setProductID(args.get(PRODUCT_ID)); invoice.getInvoiceItem().add(invoiceitem); invoice.setNotes(args.get(NOTES)); invoice.setTerms(args.get(TERMS)); String xmlout = null; try { xmlout = invoice.toXMLString(); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } List<NameValuePair> createAttrList = new ArrayList<NameValuePair>(); createAttrList.add(new BasicNameValuePair(OAUTH_TOKEN, args.get(AUTHTOKEN))); createAttrList.add(new BasicNameValuePair(ZOHO_SCOPE, SCOPE)); createAttrList.add(new BasicNameValuePair(ZOHO_XMLSTRING, xmlout)); createAttrList.add(new BasicNameValuePair(APIKEY, args.get(APIKEY))); TransportTools tst = new TransportTools(ZOHO_INVOICE_INVOICE_CREATE_URL, createAttrList); String responseBody = null; TransportResponse response = null; try { response = TransportMachinery.post(tst); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } responseBody = response.entityToString(); outMap.put(OUTPUT, responseBody); return outMap; }
From source file:org.megam.deccanplato.provider.zoho.invoice.handler.InvoiceImpl.java
/** * this method update a particular invoice in zoho invoice and returns updated invoice details. * This method takes input as a MAP(contains json dada) and returns a MAP. * @param outMap /*from w ww .jav a2s. co m*/ */ private Map<String, String> update(Map<String, String> outMap) { final String ZOHO_INVOICE_INVOICE_UPDATE_URL = "https://invoice.zoho.com/api/view/invoices/update"; Invoice invoice = new Invoice(); PaymentGateway paygate = new PaymentGateway(); InvoiceItem invoiceitem = new InvoiceItem(Boolean.parseBoolean(args.get(DELETE_INVOICE))); invoice.setInvoiceID(args.get(ID)); invoice.setCustomerID(args.get(CUSTOMERID)); invoice.setInvoiceDate(args.get(INVOICE_DATE)); invoice.setPONumber(args.get(PONUMPER)); invoice.setExchangeRate(args.get(EXCHANGE_RATE)); invoice.setCustom_Body(args.get(CUSTOM_BODY)); invoice.setCustom_Subject(args.get(CUSTOM_SUBJECT)); paygate.setAuthorize_Net(args.get(AUTHORIZE_NET)); invoice.getPaymentGateways().add(paygate); invoiceitem.setProductID(args.get(PRODUCT_ID)); invoice.getInvoiceItem().add(invoiceitem); invoice.setNotes(args.get(NOTES)); invoice.setTerms(args.get(TERMS)); String xmlout = null; try { xmlout = invoice.toXMLString(); } catch (JAXBException e) { // TODO Auto-generated catch block e.printStackTrace(); } List<NameValuePair> updateAttrList = new ArrayList<NameValuePair>(); updateAttrList.add(new BasicNameValuePair(OAUTH_TOKEN, args.get(AUTHTOKEN))); updateAttrList.add(new BasicNameValuePair(ZOHO_SCOPE, SCOPE)); updateAttrList.add(new BasicNameValuePair(ZOHO_XMLSTRING, xmlout)); updateAttrList.add(new BasicNameValuePair(APIKEY, args.get(APIKEY))); TransportTools tst = new TransportTools(ZOHO_INVOICE_INVOICE_UPDATE_URL, updateAttrList); String responseBody = null; TransportResponse response = null; try { response = TransportMachinery.post(tst); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } responseBody = response.entityToString(); outMap.put(OUTPUT, responseBody); return outMap; }
From source file:alter.vitro.vgw.service.ContinuationOfProvisionService.java
/** * Processes synch updates to the sets of equivalency received from the VSP. *//*from ww w . java 2s .c o m*/ public String createSynchConfirmationForVSP(EquivListNodesReqType forRequest) { String retStr = ""; // todo check also the timestamp of the Request with the lastUpdatedTimeStamp // and update the lastUpdatedTimeStamp if needed. if (forRequest != null) { long receivedTimestamp = 0; try { receivedTimestamp = Long.valueOf(forRequest.getTimestamp()); } catch (Exception enmfrmtx) { logger.error("Exception while converting timestamp of synch message"); } if (receivedTimestamp < lastUpdatedTimeStamp) { //ignore the message logger.info("Ignoring synch message with old timestamp"); return null; } else { lastUpdatedTimeStamp = receivedTimestamp; // clean / purge existing cache of equivLists and replacements getCachedSetsOfEquivalency().clear(); getCachedReplacedResources().clear(); } } try { EquivListNodesRespType response; javax.xml.bind.JAXBContext jaxbContext = javax.xml.bind.JAXBContext .newInstance("alter.vitro.vgw.service.query.xmlmessages.equivlistsynch.fromvgw"); // create an object to marshal ObjectFactory theFactory = new ObjectFactory(); response = theFactory.createEquivListNodesRespType(); if (response != null && forRequest != null) { response.setVgwId(VitroGatewayService.getVitroGatewayService().getAssignedGatewayUniqueIdFromReg()); response.setMessageType(UserNodeResponse.COMMAND_TYPE_EQUIV_LIST_SYNCH_RESP); response.setTimestamp(Long.toString(new Date().getTime())); if (forRequest.getEquivNodesList() != null) { if (response.getConfirmedNodesList() == null) { ConfirmedNodesListType theConfirmListType = new ConfirmedNodesListType(); response.setConfirmedNodesList(theConfirmListType); } // if (forRequest.getEquivNodesList().getEquivNodesListItem() != null && !forRequest.getEquivNodesList().getEquivNodesListItem().isEmpty()) { // loop though items and confirm each one for (EquivNodesListItemType reqItem : forRequest.getEquivNodesList() .getEquivNodesListItem()) { ConfirmedNodesListItemType confirmedItemTmp = new ConfirmedNodesListItemType(); confirmedItemTmp.setListId(reqItem.getListId()); confirmedItemTmp.setOfRemoteTimestamp(reqItem.getOfRemoteTimestamp()); // process this addition to local cache handleVSPUpdateForSetsOfEquivalency(reqItem); response.getConfirmedNodesList().getConfirmedNodesListItem().add(confirmedItemTmp); } } } //javax.xml.bind.JAXBContext jaxbContext = javax.xml.bind.JAXBContext.newInstance("alter.vitro.vgw.service.query.xmlmessages.equivlistsynch.fromvgw"); //ObjectFactory theFactory = new ObjectFactory(); javax.xml.bind.Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); JAXBElement<EquivListNodesRespType> myResponseMsgEl = theFactory.createEquivListNodesResp(response); ByteArrayOutputStream baos = new ByteArrayOutputStream(); marshaller.marshal(myResponseMsgEl, baos); retStr = baos.toString(HTTP.UTF_8); } } catch (javax.xml.bind.JAXBException je) { je.printStackTrace(); } catch (UnsupportedEncodingException e2) { e2.printStackTrace(); } return retStr; }
From source file:edu.harvard.lib.lcloud.ItemDAO.java
/** * Returns SearchResultsSlim for a given SolrDocumentList. A "slimmer" results object without the * "items" wrapper element is created for better transform to json. * @param doc solr document list to build results * @return the SearchResultsSlim object for this solr result * @see SearchResultsSlim/*from w ww . j a va 2 s. co m*/ */ private SearchResultsSlim buildSlimResults(SolrDocumentList docs) { SearchResultsSlim results = new SearchResultsSlim(); Pagination pagination = new Pagination(); pagination.setNumFound(docs.getNumFound()); pagination.setStart(docs.getStart()); pagination.setRows(limit); //List<ModsType> modsTypes = new ArrayList<ModsType>(); List<Item> items = new ArrayList<Item>(); for (final SolrDocument doc : docs) { Item item = new Item(); ModsType modsType = null; try { modsType = (new ItemDAO()).getModsType(doc); } catch (JAXBException je) { log.error(je.getMessage()); je.printStackTrace(); } item.setModsType(modsType); items.add(item); } results.setItems(items); results.setPagination(pagination); if (facet != null) results.setFacet(facet); return results; }
From source file:edu.harvard.lib.lcloud.ItemDAO.java
/** * Returns SearchResults for a given SolrDocumentList. A full results object with an "items" wrapper * element around the mods items is used to logically separate pagination, items and facets in the XML * @param doc solr document list to build results * @return the SearchResults object for this solr result * @see SearchResults/*from w ww .j a v a 2 s. c om*/ */ private SearchResults buildFullResults(SolrDocumentList docs) { SearchResults results = new SearchResults(); Pagination pagination = new Pagination(); pagination.setNumFound(docs.getNumFound()); pagination.setStart(docs.getStart()); pagination.setRows(limit); //List<ModsType> modsTypes = new ArrayList<ModsType>(); ItemGroup itemGroup = new ItemGroup(); List<Item> items = new ArrayList<Item>(); for (final SolrDocument doc : docs) { Item item = new Item(); ModsType modsType = null; try { modsType = (new ItemDAO()).getModsType(doc); } catch (JAXBException je) { log.error(je.getMessage()); je.printStackTrace(); } //modsTypes.add(modsType); //items.add(item); item.setModsType(modsType); items.add(item); } //items.setModsType(modsType); itemGroup.setItems(items); results.setItemGroup(itemGroup); results.setPagination(pagination); if (facet != null) results.setFacet(facet); return results; }
From source file:alter.vitro.vgw.service.resourceRegistry.ResourceAvailabilityService.java
/** * Processes synch updates to the sets of enabled/disabled received from the VSP. * and create a message to confirm them//from w w w . j av a 2 s . c o m */ public String createSynchConfirmationForVSP(EnableNodesReqType forRequest) { String retStr = ""; // todo check also the timestamp of the Request with the lastUpdatedTimeStamp // and update the lastUpdatedTimeStamp if needed. if (forRequest != null) { long receivedTimestamp = 0; try { receivedTimestamp = Long.valueOf(forRequest.getTimestamp()); } catch (Exception enmfrmtx) { logger.error("Exception while converting timestamp of synch message"); } if (receivedTimestamp < lastRemotelyUpdatedEnableDisableStatusTimeStamp) { //ignore the message logger.info("Ignoring synch message with old timestamp"); return null; } else { lastRemotelyUpdatedEnableDisableStatusTimeStamp = receivedTimestamp; } } // clear the cache of last request: this.getCacheOfLastReceivedEnableDisableMessage().clear(); try { EnableNodesRespType response; javax.xml.bind.JAXBContext jaxbContext = javax.xml.bind.JAXBContext .newInstance("alter.vitro.vgw.service.query.xmlmessages.enablednodessynch.fromvgw"); // create an object to marshal ObjectFactory theFactory = new ObjectFactory(); response = theFactory.createEnableNodesRespType(); if (response != null && forRequest != null) { response.setVgwId(VitroGatewayService.getVitroGatewayService().getAssignedGatewayUniqueIdFromReg()); response.setMessageType(UserNodeResponse.COMMAND_TYPE_ENABLENODES_RESP); response.setTimestamp(Long.toString(new Date().getTime())); if (forRequest.getEnabledNodesList() != null) { if (response.getConfirmedEnabledNodesList() == null) { ConfirmedEnabledNodesListType theConfirmListType = new ConfirmedEnabledNodesListType(); response.setConfirmedEnabledNodesList(theConfirmListType); // if (forRequest.getEnabledNodesList().getEnabledNodesListItem() != null && !forRequest.getEnabledNodesList().getEnabledNodesListItem().isEmpty()) { // loop though items and confirm each one for (EnabledNodesListItemType reqItem : forRequest.getEnabledNodesList() .getEnabledNodesListItem()) { boolean reqStatus = (reqItem.getStatus().compareToIgnoreCase("enabled") == 0) ? true : false; boolean updatedByVGW = false; long reqRemoteTimestamp = 0; try { reqRemoteTimestamp = Long.valueOf(reqItem.getOfRemoteTimestamp()); } catch (Exception exftme1) { logger.error("Could not convert timestamp of remote synch enable request"); reqRemoteTimestamp = 0; } long localTimestampSynch = (new Date()).getTime(); //it does not matter ? // ALSO HANDLE EACH ONE OF THE REQUESTS (TODO: CAN WE CONFIRM ALL, BUT NOT CONFROM TO ALL REQUESTs ???) // // if (getCachedDiscoveredDevices() != null && !getCachedDiscoveredDevices().isEmpty() && getCachedDiscoveredDevices().containsKey(reqItem.getNodeId())) { CSmartDevice tmpSmDev = getCachedDiscoveredDevices().get(reqItem.getNodeId()); if (!tmpSmDev.getRegistryProperties().isEnabled() && tmpSmDev.getRegistryProperties().isStatusWasDecidedByThisVGW()) { // if it was disabled by the VGW, then ignore any requests/cached or not by the VSP to change its status. reqStatus = tmpSmDev.getRegistryProperties().isEnabled(); updatedByVGW = true; } else { tmpSmDev.getRegistryProperties().setEnabled(reqStatus); tmpSmDev.getRegistryProperties() .setTimeStampEnabledStatusRemotelySynch(reqRemoteTimestamp); tmpSmDev.getRegistryProperties() .setTimeStampEnabledStatusSynch(localTimestampSynch);//is this used? } } // // // AND STORE THE REQUEST TO THE CACHE OF LAST REQUEST, INDEPENDENTLY OF WHETHER WE CONFORMED // BUT IF WE DID NOT CONFORM, WE SEND BACK OUR (VGW) VALUES // ResourceProperties reqResProps = new ResourceProperties(reqItem.getNodeId()); reqResProps.setEnabled(reqStatus); reqResProps.setTimeStampEnabledStatusRemotelySynch(reqRemoteTimestamp); reqResProps.setTimeStampEnabledStatusSynch(localTimestampSynch); //it does not matter ?? reqResProps.setStatusWasDecidedByThisVGW(updatedByVGW); this.getCacheOfLastReceivedEnableDisableMessage().put(reqItem.getNodeId(), reqResProps); // AND CONSTRUCT THE CONFIRMATION MESSAGE! ConfirmedEnabledNodesListItemType confirmedItemTmp = new ConfirmedEnabledNodesListItemType(); confirmedItemTmp.setNodeId(reqItem.getNodeId()); String updatedByVGWStr = updatedByVGW ? "1" : "0"; String reqStatusStr = reqStatus ? "enabled" : "disabled"; confirmedItemTmp.setStatus(reqStatusStr); confirmedItemTmp.setGwInitFlag(updatedByVGWStr); confirmedItemTmp.setOfRemoteTimestamp(reqItem.getOfRemoteTimestamp()); theConfirmListType.getConfirmedEnabledNodesListItem().add(confirmedItemTmp); } } } } javax.xml.bind.Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); JAXBElement<EnableNodesRespType> myResponseMsgEl = theFactory.createEnableNodesResp(response); ByteArrayOutputStream baos = new ByteArrayOutputStream(); marshaller.marshal(myResponseMsgEl, baos); retStr = baos.toString(HTTP.UTF_8); } } catch (javax.xml.bind.JAXBException je) { je.printStackTrace(); } catch (UnsupportedEncodingException e2) { e2.printStackTrace(); } return retStr; }