List of usage examples for javax.xml.bind JAXB marshal
public static void marshal(Object jaxbObject, Result xml)
From source file:org.apache.juddi.v3.tck.TckTModel.java
private TModel saveTModel(String authInfo, TModel tmIn, boolean force) { boolean exists = false; GetTModelDetail gt1 = new GetTModelDetail(); gt1.getTModelKey().add(tmIn.getTModelKey()); try {/*from w w w .ja v a 2 s.c o m*/ TModelDetail td1 = inquiry.getTModelDetail(gt1); if (td1 != null && !td1.getTModel().isEmpty()) { if (!td1.getTModel().get(0).isDeleted()) { exists = true; } else { logger.info("The tModel with key " + tmIn.getTModelKey() + " exists already, but is flagged as deleted. Overwritting"); } } } catch (Exception ex) { } if (!exists || force) // Add the tModel { try { SaveTModel st = new SaveTModel(); st.setAuthInfo(authInfo); st.getTModel().add(tmIn); publication.saveTModel(st); keyscreated.add(tmIn.getTModelKey()); // Now get the entity and check the values GetTModelDetail gt = new GetTModelDetail(); gt.getTModelKey().add(tmIn.getTModelKey()); TModelDetail td = inquiry.getTModelDetail(gt); List<org.uddi.api_v3.TModel> tmOutList = td.getTModel(); org.uddi.api_v3.TModel tmOut = tmOutList.get(0); assertEquals(tmIn.getTModelKey().toLowerCase(), tmOut.getTModelKey()); assertEquals(tmIn.getName().getLang(), tmOut.getName().getLang()); assertEquals(tmIn.getName().getValue(), tmOut.getName().getValue()); TckValidator.checkDescriptions(tmIn.getDescription(), tmOut.getDescription()); TckValidator.checkCategories(tmIn.getCategoryBag(), tmOut.getCategoryBag()); for (OverviewDoc overviewDoc : tmIn.getOverviewDoc()) { TckValidator.checkOverviewDocs(overviewDoc, tmOut.getOverviewDoc()); } logger.info("The TModel " + tmIn.getTModelKey() + " saved"); if (TckCommon.isDebug()) { JAXB.marshal(tmOut, System.out); } return tmOut; } catch (Exception e) { logger.error(e.getMessage(), e); Assert.fail("No exception should be thrown"); } } else { logger.info("The TModel " + tmIn.getTModelKey() + " exists already, skipping"); } return tmIn; }
From source file:org.apache.juddi.v3.tck.UDDI_090_SubscriptionListenerIntegrationBase.java
/** * joe wants updates on all services with wsdm qos tmi. mary updates a * binding to trigger the call back//from w w w . j a va 2 s . com * * @throws Exception */ @Test public void joePublisherUpdate_FIND_BINDING_BY_CATBAG() throws Exception { Assume.assumeTrue(TckPublisher.isEnabled()); Assume.assumeNotNull(getHostame()); Assume.assumeTrue(IsEnabled()); logger.info("joePublisherUpdate_" + getTransport() + "_FIND_BINDING_BY_CATBAG"); TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe); Holder<List<Subscription>> holder = null; try { reset(); String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe); tckTModelJoe.saveJoePublisherTmodel(authInfoJoe); tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3); tckTModelMary.saveMaryPublisherTmodel(authInfoMary); BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary); BusinessService bs = new BusinessService(); bs.setBusinessKey(saveMaryPublisherBusiness.getBusinessKey()); bs.setServiceKey(TckTModel.MARY_KEY_PREFIX + UUID.randomUUID().toString()); bs.getName().add(new Name("Mary's service for " + getTransport(), null)); bs.setBindingTemplates(new BindingTemplates()); BindingTemplate bt = new BindingTemplate(); bt.setAccessPoint(new AccessPoint("http://localhost", "endPoint")); bt.setBindingKey(TckTModel.MARY_KEY_PREFIX + UUID.randomUUID().toString()); bt.setServiceKey(bs.getServiceKey()); bt = UDDIClient.addSOAPtModels(bt); bs.getBindingTemplates().getBindingTemplate().add(bt); SaveService ss = new SaveService(); ss.getBusinessService().add(bs); ss.setAuthInfo(authInfoMary); bs = publicationMary.saveService(ss).getBusinessService().get(0); tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe); tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe); //Saving the Listener Service String bindingkey = tckSubscriptionListenerJoe.saveService(authInfoJoe, getXMLLocationOfServiceForDelivery(), getPort(), getHostame()); //Saving the Subscription holder = new Holder<List<Subscription>>(); holder.value = new ArrayList<Subscription>(); Subscription sub = new Subscription(); sub.setBindingKey(bindingkey); sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000)); sub.setSubscriptionFilter(new SubscriptionFilter()); sub.getSubscriptionFilter().setFindBinding(new FindBinding()); //At least one of either a tModelBag or a find_tModel argument SHOULD be supplied, unless a categoryBag based search is being used. sub.getSubscriptionFilter().getFindBinding().setCategoryBag(new CategoryBag()); sub.getSubscriptionFilter().getFindBinding().getCategoryBag().getKeyedReference() .add(new KeyedReference("uddi:uddi.org:categorization:types", UDDIConstants.CategorizationTypes_Cacheable, "Cacheable")); holder.value.add(sub); subscriptionJoe.saveSubscription(authInfoJoe, holder); logger.info("subscription saved for " + holder.value.get(0).getSubscriptionKey()); //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML); //Changing the service we subscribed to "JoePublisherService" Thread.sleep(1000); if (TckCommon.isDebug()) { logger.info("dumping mary's binding before.... "); JAXB.marshal(bs, System.out); } logger.info("updating Mary's binding ********** "); // BindingDetail after=new BindingDetail(); /*GetBindingDetail bindingDetail = new GetBindingDetail(); bindingDetail.setAuthInfo(authInfoMary); bindingDetail.getBindingKey().add(bs.getBindingTemplates().getBindingTemplate().get(0).getBindingKey());*/ BindingDetail bindingDetail1 = null;//inquiryMary.getBindingDetail(bindingDetail); bindingDetail1 = updatePublisherBindingAddCategory(authInfoMary, bt, publicationMary, new KeyedReference("uddi:uddi.org:categorization:types", UDDIConstants.CategorizationTypes_Cacheable, "Cacheable"), bindingDetail1); if (TckCommon.isDebug()) { logger.info("dumping mary's binding after.... "); JAXB.marshal(bindingDetail1, System.out); } boolean found = verifyDelivery(UDDIConstants.CategorizationTypes_Cacheable); if (!found) { logger.warn("Test failed, dumping business list"); logger.warn("BEFORE " + before); logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe)); TckCommon.PrintMarker(); Assert.fail("Notification does not contain the correct service."); } } catch (Exception e) { logger.error("No exceptions please."); TckCommon.PrintMarker(); e.printStackTrace(); Assert.fail(e.getMessage()); } finally { //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY); DeleteSubscription ds = new DeleteSubscription(); ds.setAuthInfo(authInfoJoe); ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey()); subscriptionJoe.deleteSubscription(ds); tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary); tckTModelMary.deleteMaryPublisherTmodel(authInfoMary); tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe); tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe); tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe); tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3); } }
From source file:org.apache.juddi.v3.tck.UDDI_141_JIRAIntegrationTest.java
/** * sets up a compelte publisher assertion * * @throws Exception//from ww w .j a va 2s .com */ @Test public void JUDDI_590() throws Exception { Assume.assumeTrue(TckPublisher.isEnabled()); //create two businesses System.out.println("JUDDI_590"); SaveBusiness sb = new SaveBusiness(); sb.setAuthInfo(authInfoJoe); BusinessEntity be = new BusinessEntity(); Name n = new Name(); n.setValue("JUDDI_590 Joe"); be.getName().add(n); sb.getBusinessEntity().add(be); String joeBiz = null; try { BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb); joeBiz = saveBusiness.getBusinessEntity().get(0).getBusinessKey(); //DeleteBusiness db = new DeleteBusiness(); //db.setAuthInfo(authInfoJoe); //db.getBusinessKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey()); //publicationJoe.deleteBusiness(db); //Assert.fail("request should have been rejected"); } catch (SOAPFaultException ex) { HandleException(ex); } sb = new SaveBusiness(); sb.setAuthInfo(authInfoSam); be = new BusinessEntity(); n = new Name(); n.setValue("JUDDI_590 Sam"); be.getName().add(n); sb.getBusinessEntity().add(be); String samBiz = null; try { BusinessDetail saveBusiness = publicationSam.saveBusiness(sb); samBiz = saveBusiness.getBusinessEntity().get(0).getBusinessKey(); //DeleteBusiness db = new DeleteBusiness(); //db.setAuthInfo(authInfoJoe); //db.getBusinessKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey()); //publicationJoe.deleteBusiness(db); //Assert.fail("request should have been rejected"); } catch (SOAPFaultException ex) { HandleException(ex); } //create an assertion on one end AddPublisherAssertions apa = new AddPublisherAssertions(); apa.setAuthInfo(authInfoJoe); apa.getPublisherAssertion().add(new PublisherAssertion()); apa.getPublisherAssertion().get(0).setFromKey(joeBiz); apa.getPublisherAssertion().get(0).setToKey(samBiz); KeyedReference kr = new KeyedReference(); kr.setKeyName("Subsidiary"); kr.setKeyValue("parent-child"); kr.setTModelKey("uddi:uddi.org:relationships"); apa.getPublisherAssertion().get(0).setKeyedReference(kr); publicationJoe.addPublisherAssertions(apa); //check get status is not null from 1 and from 2 boolean ok = true; String msg = ""; try { List<AssertionStatusItem> assertionStatusReport = publicationJoe.getAssertionStatusReport(authInfoJoe, CompletionStatus.STATUS_TO_KEY_INCOMPLETE); if (assertionStatusReport.isEmpty()) { msg = "Stage1: no result returned, expected at least 1"; ok = false; } for (int i = 0; i < assertionStatusReport.size(); i++) { JAXB.marshal(assertionStatusReport.get(i), System.out); if (assertionStatusReport.get(i).getToKey().equals(samBiz)) { if (!assertionStatusReport.get(i).getCompletionStatus() .equals(CompletionStatus.STATUS_TO_KEY_INCOMPLETE)) { ok = false; msg = "Stage1: status type mismatch"; } } } } catch (Exception ex) { ok = false; ex.printStackTrace(); } //aprove the assertion from sam apa = new AddPublisherAssertions(); apa.setAuthInfo(authInfoSam); apa.getPublisherAssertion().add(new PublisherAssertion()); apa.getPublisherAssertion().get(0).setFromKey(joeBiz); apa.getPublisherAssertion().get(0).setToKey(samBiz); kr = new KeyedReference(); kr.setKeyName("Subsidiary"); kr.setKeyValue("parent-child"); kr.setTModelKey("uddi:uddi.org:relationships"); apa.getPublisherAssertion().get(0).setKeyedReference(kr); publicationSam.addPublisherAssertions(apa); try { List<AssertionStatusItem> assertionStatusReport = publicationJoe.getAssertionStatusReport(authInfoJoe, CompletionStatus.STATUS_COMPLETE); if (assertionStatusReport.isEmpty()) { msg = "Stage2: no result returned, expected at least 1"; ok = false; } for (int i = 0; i < assertionStatusReport.size(); i++) { JAXB.marshal(assertionStatusReport.get(i), System.out); if (assertionStatusReport.get(i).getToKey().equals(samBiz)) { if (!assertionStatusReport.get(i).getCompletionStatus() .equals(CompletionStatus.STATUS_COMPLETE)) { ok = false; msg = "Stage2: status type mismatch"; } } } //test to see what the status actually is if (!ok) { assertionStatusReport = publicationJoe.getAssertionStatusReport(authInfoJoe, CompletionStatus.STATUS_FROM_KEY_INCOMPLETE); for (int i = 0; i < assertionStatusReport.size(); i++) { JAXB.marshal(assertionStatusReport.get(i), System.out); if (assertionStatusReport.get(i).getToKey().equals(samBiz)) { msg = "Stage3: status is " + assertionStatusReport.get(i).getCompletionStatus().toString() + " instead of complete"; } } assertionStatusReport = publicationJoe.getAssertionStatusReport(authInfoJoe, CompletionStatus.STATUS_TO_KEY_INCOMPLETE); for (int i = 0; i < assertionStatusReport.size(); i++) { JAXB.marshal(assertionStatusReport.get(i), System.out); if (assertionStatusReport.get(i).getToKey().equals(samBiz)) { msg = "Stage3: status is " + assertionStatusReport.get(i).getCompletionStatus().toString() + " instead of complete"; } } assertionStatusReport = publicationJoe.getAssertionStatusReport(authInfoJoe, CompletionStatus.STATUS_BOTH_INCOMPLETE); for (int i = 0; i < assertionStatusReport.size(); i++) { JAXB.marshal(assertionStatusReport.get(i), System.out); if (assertionStatusReport.get(i).getToKey().equals(samBiz)) { msg = "Stage3: status is " + assertionStatusReport.get(i).getCompletionStatus().toString() + " instead of complete"; } } } } catch (Exception ex) { ok = false; ex.printStackTrace(); } List<String> biz = new ArrayList<String>(); biz.add(samBiz); DeleteBusinesses(biz, authInfoSam, publicationSam); biz = new ArrayList<String>(); biz.add(joeBiz); DeleteBusinesses(biz, authInfoJoe, publicationJoe); Assert.assertTrue(msg, ok); }
From source file:org.apache.juddi.v3.tck.UDDI_141_JIRAIntegrationTest.java
/** * setups up a partial relationship and confirms its existence * * @throws Exception/* w w w. j av a 2 s . com*/ */ @Test public void JUDDI_590_1() throws Exception { Assume.assumeTrue(TckPublisher.isEnabled()); //create two businesses System.out.println("JUDDI_590_1"); SaveBusiness sb = new SaveBusiness(); sb.setAuthInfo(authInfoJoe); BusinessEntity be = new BusinessEntity(); Name n = new Name(); n.setValue("JUDDI_590 Joe"); be.getName().add(n); sb.getBusinessEntity().add(be); String joeBiz = null; try { BusinessDetail saveBusiness = publicationJoe.saveBusiness(sb); joeBiz = saveBusiness.getBusinessEntity().get(0).getBusinessKey(); //DeleteBusiness db = new DeleteBusiness(); //db.setAuthInfo(authInfoJoe); //db.getBusinessKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey()); //publicationJoe.deleteBusiness(db); //Assert.fail("request should have been rejected"); } catch (SOAPFaultException ex) { HandleException(ex); } sb = new SaveBusiness(); sb.setAuthInfo(authInfoSam); be = new BusinessEntity(); n = new Name(); n.setValue("JUDDI_590 Sam"); be.getName().add(n); sb.getBusinessEntity().add(be); String samBiz = null; try { BusinessDetail saveBusiness = publicationSam.saveBusiness(sb); samBiz = saveBusiness.getBusinessEntity().get(0).getBusinessKey(); //DeleteBusiness db = new DeleteBusiness(); //db.setAuthInfo(authInfoJoe); //db.getBusinessKey().add(saveBusiness.getBusinessEntity().get(0).getBusinessKey()); //publicationJoe.deleteBusiness(db); //Assert.fail("request should have been rejected"); } catch (SOAPFaultException ex) { HandleException(ex); } //create an assertion on one end AddPublisherAssertions apa = new AddPublisherAssertions(); apa.setAuthInfo(authInfoJoe); apa.getPublisherAssertion().add(new PublisherAssertion()); apa.getPublisherAssertion().get(0).setFromKey(joeBiz); apa.getPublisherAssertion().get(0).setToKey(samBiz); KeyedReference kr = new KeyedReference(); kr.setKeyName("Subsidiary"); kr.setKeyValue("parent-child"); kr.setTModelKey("uddi:uddi.org:relationships"); apa.getPublisherAssertion().get(0).setKeyedReference(kr); publicationJoe.addPublisherAssertions(apa); //ok so joe has asserted that he knows sam //check get status is not null from 1 and from 2 boolean ok = true; String msg = ""; try { List<AssertionStatusItem> assertionStatusReport = publicationJoe.getAssertionStatusReport(authInfoJoe, CompletionStatus.STATUS_TO_KEY_INCOMPLETE); if (assertionStatusReport.isEmpty()) { msg = "Stage1: no result returned, expected at least 1"; ok = false; } for (int i = 0; i < assertionStatusReport.size(); i++) { if (TckCommon.isDebug()) { JAXB.marshal(assertionStatusReport.get(i), System.out); } if (assertionStatusReport.get(i).getToKey().equals(samBiz)) { if (!assertionStatusReport.get(i).getCompletionStatus() .equals(CompletionStatus.STATUS_TO_KEY_INCOMPLETE)) { ok = false; msg = "Stage1: status type mismatch"; } } } } catch (Exception ex) { ok = false; ex.printStackTrace(); } //check that sam got the message try { List<AssertionStatusItem> assertionStatusReport = publicationSam.getAssertionStatusReport(authInfoSam, CompletionStatus.STATUS_TO_KEY_INCOMPLETE); if (assertionStatusReport.isEmpty()) { msg = "Stage2: no result returned, expected at least 1"; ok = false; } for (int i = 0; i < assertionStatusReport.size(); i++) { if (TckCommon.isDebug()) { JAXB.marshal(assertionStatusReport.get(i), System.out); } if (assertionStatusReport.get(i).getToKey().equals(samBiz)) { if (!assertionStatusReport.get(i).getCompletionStatus() .equals(CompletionStatus.STATUS_TO_KEY_INCOMPLETE)) { ok = false; msg = "Stage2: status type mismatch"; } } } } catch (Exception ex) { ok = false; ex.printStackTrace(); } List<String> biz = new ArrayList<String>(); biz.add(samBiz); DeleteBusinesses(biz, authInfoSam, publicationSam); biz = new ArrayList<String>(); biz.add(joeBiz); DeleteBusinesses(biz, authInfoJoe, publicationJoe); Assert.assertTrue(msg, ok); }
From source file:org.apache.juddi.webconsole.hub.UddiHub.java
private String SendAdvancedQueryInquiry(String method, Object request) { Object response = null;/*from ww w . j ava 2 s .c o m*/ try { if (method.equalsIgnoreCase("findBinding")) { ((FindBinding) request).setAuthInfo(GetToken()); try { response = inquiry.findBinding((FindBinding) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((FindBinding) request).setAuthInfo(GetToken()); response = inquiry.findBinding((FindBinding) request); } else { throw ex; } } } if (method.equalsIgnoreCase("findBusiness")) { ((FindBusiness) request).setAuthInfo(GetToken()); try { response = inquiry.findBusiness((FindBusiness) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((FindBusiness) request).setAuthInfo(GetToken()); response = inquiry.findBusiness((FindBusiness) request); } else { throw ex; } } } if (method.equalsIgnoreCase("findService")) { ((FindService) request).setAuthInfo(GetToken()); try { response = inquiry.findService((FindService) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((FindService) request).setAuthInfo(GetToken()); response = inquiry.findService((FindService) request); } else { throw ex; } } } if (method.equalsIgnoreCase("findRelatedBusines")) { ((FindRelatedBusinesses) request).setAuthInfo(GetToken()); try { response = inquiry.findRelatedBusinesses((FindRelatedBusinesses) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((FindRelatedBusinesses) request).setAuthInfo(GetToken()); response = inquiry.findRelatedBusinesses((FindRelatedBusinesses) request); } else { throw ex; } } } if (method.equalsIgnoreCase("findTModel")) { ((FindTModel) request).setAuthInfo(GetToken()); try { response = inquiry.findTModel((FindTModel) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((FindTModel) request).setAuthInfo(GetToken()); response = inquiry.findTModel((FindTModel) request); } else { throw ex; } } } if (method.equalsIgnoreCase("getBindingDetail")) { ((GetBindingDetail) request).setAuthInfo(GetToken()); try { response = inquiry.getBindingDetail((GetBindingDetail) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((GetBindingDetail) request).setAuthInfo(GetToken()); response = inquiry.getBindingDetail((GetBindingDetail) request); } else { throw ex; } } } if (method.equalsIgnoreCase("getBusinessDetail")) { ((GetBusinessDetail) request).setAuthInfo(GetToken()); try { response = inquiry.getBusinessDetail((GetBusinessDetail) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((GetBusinessDetail) request).setAuthInfo(GetToken()); response = inquiry.getBusinessDetail((GetBusinessDetail) request); } else { throw ex; } } } if (method.equalsIgnoreCase("getServiceDetail")) { ((GetServiceDetail) request).setAuthInfo(GetToken()); try { response = inquiry.getServiceDetail((GetServiceDetail) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((GetServiceDetail) request).setAuthInfo(GetToken()); response = inquiry.getServiceDetail((GetServiceDetail) request); } else { throw ex; } } } if (method.equalsIgnoreCase("getOperationalInfo")) { ((GetOperationalInfo) request).setAuthInfo(GetToken()); try { response = inquiry.getOperationalInfo((GetOperationalInfo) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; response = inquiry.getOperationalInfo((GetOperationalInfo) request); } else { throw ex; } } } if (method.equalsIgnoreCase("getTModelDetail")) { ((GetTModelDetail) request).setAuthInfo(GetToken()); try { response = inquiry.getTModelDetail((GetTModelDetail) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; response = inquiry.getTModelDetail((GetTModelDetail) request); } else { throw ex; } } } if (response == null) { return ResourceLoader.GetResource(session, "actions.success"); } StringWriter sw = new StringWriter(); JAXB.marshal(response, sw); return sw.toString(); } catch (Exception ex) { return HandleException(ex); } }
From source file:org.apache.juddi.webconsole.hub.UddiHub.java
private String SendAdvancedQueryPublish(String method, Object request) { Object response = null;/*from ww w . j av a2 s . co m*/ try { if (method.equalsIgnoreCase("addPublisherAssertions")) { ((AddPublisherAssertions) request).setAuthInfo(GetToken()); try { publish.addPublisherAssertions((AddPublisherAssertions) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((AddPublisherAssertions) request).setAuthInfo(GetToken()); publish.addPublisherAssertions((AddPublisherAssertions) request); } else { throw ex; } } } if (method.equalsIgnoreCase("deleteBinding")) { try { ((DeleteBinding) request).setAuthInfo(GetToken()); publish.deleteBinding((DeleteBinding) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((DeleteBinding) request).setAuthInfo(GetToken()); publish.deleteBinding((DeleteBinding) request); } else { throw ex; } } } if (method.equalsIgnoreCase("deleteBusiness")) { try { ((DeleteBusiness) request).setAuthInfo(GetToken()); publish.deleteBusiness((DeleteBusiness) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((DeleteBusiness) request).setAuthInfo(GetToken()); publish.deleteBusiness((DeleteBusiness) request); } else { throw ex; } } } if (method.equalsIgnoreCase("deletePublisherAssertions")) { try { ((DeletePublisherAssertions) request).setAuthInfo(GetToken()); publish.deletePublisherAssertions((DeletePublisherAssertions) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((DeleteBusiness) request).setAuthInfo(GetToken()); publish.deletePublisherAssertions((DeletePublisherAssertions) request); } else { throw ex; } } } if (method.equalsIgnoreCase("deleteService")) { try { ((DeleteService) request).setAuthInfo(GetToken()); publish.deleteService((DeleteService) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((DeleteBusiness) request).setAuthInfo(GetToken()); publish.deleteService((DeleteService) request); } else { throw ex; } } } if (method.equalsIgnoreCase("deleteTModel")) { try { ((DeleteTModel) request).setAuthInfo(GetToken()); publish.deleteTModel((DeleteTModel) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((DeleteTModel) request).setAuthInfo(GetToken()); publish.deleteTModel((DeleteTModel) request); } else { throw ex; } } } if (method.equalsIgnoreCase("getAssertionStatusReport")) { CompletionStatus stat = ((GetAssertionStatusReport) request).getCompletionStatus(); try { response = publish.getAssertionStatusReport(GetToken(), stat); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; response = publish.getAssertionStatusReport(GetToken(), stat); } else { throw ex; } } } if (method.equalsIgnoreCase("getPublisherAssertions")) { try { response = publish.getPublisherAssertions(GetToken()); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; response = publish.getPublisherAssertions(GetToken()); } else { throw ex; } } } if (method.equalsIgnoreCase("getRegisteredInfo")) { try { ((GetRegisteredInfo) request).setAuthInfo(GetToken()); response = publish.getRegisteredInfo((GetRegisteredInfo) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((GetRegisteredInfo) request).setAuthInfo(GetToken()); publish.getRegisteredInfo((GetRegisteredInfo) request); } else { throw ex; } } } if (method.equalsIgnoreCase("saveBinding")) { try { ((SaveBinding) request).setAuthInfo(GetToken()); response = publish.saveBinding((SaveBinding) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((SaveBinding) request).setAuthInfo(GetToken()); publish.saveBinding((SaveBinding) request); } else { throw ex; } } } if (method.equalsIgnoreCase("saveBusiness")) { try { ((SaveBusiness) request).setAuthInfo(GetToken()); response = publish.saveBusiness((SaveBusiness) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((SaveBusiness) request).setAuthInfo(GetToken()); publish.saveBusiness((SaveBusiness) request); } else { throw ex; } } } if (method.equalsIgnoreCase("saveTModel")) { try { ((SaveTModel) request).setAuthInfo(GetToken()); response = publish.saveTModel((SaveTModel) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((SaveTModel) request).setAuthInfo(GetToken()); publish.saveTModel((SaveTModel) request); } else { throw ex; } } } if (method.equalsIgnoreCase("saveService")) { try { ((SaveService) request).setAuthInfo(GetToken()); response = publish.saveService((SaveService) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((SaveService) request).setAuthInfo(GetToken()); publish.saveService((SaveService) request); } else { throw ex; } } } if (method.equalsIgnoreCase("setPublisherAssertions")) { Holder<List<PublisherAssertion>> list = new Holder<List<PublisherAssertion>>(); list.value = ((SetPublisherAssertions) request).getPublisherAssertion(); try { publish.setPublisherAssertions(GetToken(), list); response = list.value; } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((SetPublisherAssertions) request).setAuthInfo(GetToken()); publish.setPublisherAssertions(GetToken(), list); response = list.value; } else { throw ex; } } } if (response == null) { return "The operation completed without error"; } StringWriter sw = new StringWriter(); JAXB.marshal(response, sw); return sw.toString(); } catch (Exception ex) { return HandleException(ex); } }
From source file:org.apache.juddi.webconsole.hub.UddiHub.java
private String SendAdvancedQueryCustody(String method, Object request) { Object response = null;/*from www .ja v a2 s. c om*/ try { if (method.equalsIgnoreCase("discardTransferToken")) { try { ((DiscardTransferToken) request).setAuthInfo(GetToken()); custody.discardTransferToken((DiscardTransferToken) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((DiscardTransferToken) request).setAuthInfo(GetToken()); custody.discardTransferToken((DiscardTransferToken) request); } else { throw ex; } } } if (method.equalsIgnoreCase("getTransferToken")) { GetTransferToken r = ((GetTransferToken) request); TransferToken tt = new TransferToken(); Holder<String> node = new Holder<String>(); Holder<XMLGregorianCalendar> xcal = new Holder<XMLGregorianCalendar>(); Holder<byte[]> ttoken = new Holder<byte[]>(); try { custody.getTransferToken(GetToken(), r.getKeyBag(), node, xcal, ttoken); tt.setNodeID(node.value); tt.setOpaqueToken(ttoken.value); tt.setExpirationTime(xcal.value); response = tt; } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; custody.getTransferToken(GetToken(), r.getKeyBag(), node, xcal, ttoken); tt.setNodeID(node.value); tt.setOpaqueToken(ttoken.value); tt.setExpirationTime(xcal.value); response = tt; } else { throw ex; } } } if (method.equalsIgnoreCase("transferEntities")) { try { ((TransferEntities) request).setAuthInfo(GetToken()); custody.transferEntities((TransferEntities) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((TransferEntities) request).setAuthInfo(GetToken()); custody.transferEntities((TransferEntities) request); } else { throw ex; } } } if (response == null) { return "The operation completed without error"; } StringWriter sw = new StringWriter(); JAXB.marshal(response, sw); return sw.toString(); } catch (Exception ex) { return HandleException(ex); } }
From source file:org.apache.juddi.webconsole.hub.UddiHub.java
private String SendAdvancedQuerySubscription(String method, Object request) { Object response = null;/*from w w w.ja va 2 s. c o m*/ try { if (method.equalsIgnoreCase("deleteSubscription")) { try { ((DeleteSubscription) request).setAuthInfo(GetToken()); subscription.deleteSubscription((DeleteSubscription) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((DeleteSubscription) request).setAuthInfo(GetToken()); subscription.deleteSubscription((DeleteSubscription) request); } else { throw ex; } } } if (method.equalsIgnoreCase("getSubscriptionResults")) { try { ((GetSubscriptionResults) request).setAuthInfo(GetToken()); response = subscription.getSubscriptionResults((GetSubscriptionResults) request); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; ((GetSubscriptionResults) request).setAuthInfo(GetToken()); subscription.getSubscriptionResults((GetSubscriptionResults) request); } else { throw ex; } } } if (method.equalsIgnoreCase("getSubscriptions")) { try { response = subscription.getSubscriptions(GetToken()); } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; response = subscription.getSubscriptions(GetToken()); } else { throw ex; } } } if (method.equalsIgnoreCase("saveSubscription")) { SaveSubscription ss = (SaveSubscription) request; Holder<List<Subscription>> h = new Holder<List<Subscription>>(ss.getSubscription()); try { subscription.saveSubscription(GetToken(), h); response = h.value; } catch (Exception ex) { if (isExceptionExpiration(ex)) { token = null; subscription.saveSubscription(GetToken(), h); response = h.value; } else { throw ex; } } } if (response == null) { return "The operation completed without error"; } StringWriter sw = new StringWriter(); JAXB.marshal(response, sw); return sw.toString(); } catch (Exception ex) { return HandleException(ex); } }
From source file:org.codice.ddf.spatial.ogc.wfs.v1_0_0.catalog.common.TestWfs10JTStoGML200Converter.java
@Test public void testPolygonTypeToJAXB() throws JAXBException, SAXException, IOException, ParseException, NullPointerException { Polygon polygon = (Polygon) getGeometryFromWkt(POLYGON); assertThat(polygon == null, is(Boolean.FALSE)); String polygonGML = Wfs10JTStoGML200Converter.convertGeometryToGML(polygon); PolygonType polygonType = (PolygonType) Wfs10JTStoGML200Converter.convertGMLToGeometryType(polygonGML, Wfs10Constants.POLYGON);/*from ww w . j av a 2 s .co m*/ assertThat(null != polygonType, is(Boolean.TRUE)); JAXBElement<PolygonType> polygonTypeJAXBElement = (JAXBElement<PolygonType>) Wfs10JTStoGML200Converter .convertGeometryTypeToJAXB(polygonType); assertThat(polygonTypeJAXBElement.getName().getLocalPart().equals(Wfs10Constants.POLYGON.getLocalPart()), is(Boolean.TRUE)); assertThat(polygonTypeJAXBElement.getDeclaredType() == PolygonType.class, is(Boolean.TRUE)); JAXB.marshal(polygonTypeJAXBElement, writer); String xml = writer.toString(); Diff diff = XMLUnit.compareXML(xml, POLYGON_GML); assertTrue(XMLUNIT_SIMILAR, diff.similar()); assertThat(diff.similar(), is(Boolean.TRUE)); assertThat(diff.identical(), is(Boolean.FALSE)); }
From source file:org.codice.ddf.spatial.ogc.wfs.v1_0_0.catalog.common.TestWfs10JTStoGML200Converter.java
@Test public void testLineStringTypeToJAXB() throws JAXBException, SAXException, IOException, ParseException, NullPointerException { LineString lineString = (LineString) getGeometryFromWkt(LINESTRING); assertThat(lineString == null, is(Boolean.FALSE)); String lineStringGML = Wfs10JTStoGML200Converter.convertGeometryToGML(lineString); LineStringType lineStringType = (LineStringType) Wfs10JTStoGML200Converter .convertGMLToGeometryType(lineStringGML, Wfs10Constants.LINESTRING); JAXBElement<LineStringType> lineStringTypeJAXBElement = (JAXBElement<LineStringType>) Wfs10JTStoGML200Converter .convertGeometryTypeToJAXB(lineStringType); XMLUnit.setNormalizeWhitespace(Boolean.TRUE); JAXB.marshal(lineStringTypeJAXBElement, writer); String xml = writer.toString(); Diff diff = XMLUnit.compareXML(xml, LINESTRING_GML); assertTrue(XMLUNIT_SIMILAR, diff.similar()); assertThat(diff.similar(), is(Boolean.TRUE)); assertThat(diff.identical(), is(Boolean.FALSE)); }