List of usage examples for javax.xml.bind JAXBElement getValue
public T getValue()
Return the content model and attribute values for this element.
See #isNil() for a description of a property constraint when this value is null
From source file:com.samples.platform.service.iss.tech.support.GetSystemUserReportOperation.java
/** * @param message//from w w w . j a v a 2 s . c o m * the {@link JAXBElement} containing a * {@link GetSystemUserReportRequestType}. * @return the {@link JAXBElement} with a * {@link GetSystemUserReportResponseType}. */ @InsightEndPoint @ServiceActivator public final JAXBElement<GetSystemUserReportResponseType> getSystemUserReport( final JAXBElement<GetSystemUserReportRequestType> message) { this.logger.debug("+getSystemUserReport"); GetSystemUserReportResponseType response = this.of.createGetSystemUserReportResponseType(); long start = System.currentTimeMillis(); try { FlowContextImpl flowContext = new FlowContextImpl(); flowContext.setRequesterOperationName("GetSystemUserReport"); flowContext.setRequesterServiceName("iss.tech.support"); flowContext.setRequesterServiceVersion( this.properties.getProperty("eip.service.version", "unknown version")); flowContext.setRequesterUserName(message.getValue().getUserName()); SystemUserReportFlowRequestType in = new SystemUserReportFlowRequestType(); in.setIn(message.getValue()); SystemUserReportFlowResponseType out = this.flow.invokeFlow(in, flowContext); if (out != null) { response = out.getOut(); } } catch (Throwable e) { /* Add a not covered error to the response. */ this.logger.error(e.getMessage(), e); // response.getFailure().add( // FailureHandler.handleException(e, "E_ALL_NOT_KNOWN_ERROR", // this.logger); } finally { this.logger.debug(" getSystemUserReport duration {}", DateUtil.getDuration(start)); this.logger.debug("-getSystemUserReport #{}, #f{}", response/* .get() */ != null ? 1 : 0, response.getFailure().size()); } return this.of.createGetSystemUserReportResponse(response); }
From source file:edu.harvard.i2b2.eclipse.PmServiceController.java
/** * Function to send getUserInfo request to PM web service * /*from w w w . java 2s .c o m*/ * @param userid * @param password * @param projectID * @param project * @param demo Flag to indicate if we are in demo mode * @return A String containing the PM web service response */ @SuppressWarnings("rawtypes") public String setUserPassword(String userid, PasswordType password, String projectURL, String domain, String newPassword, String username) throws Exception { String response = null; try { ////////////// GetUserRequestMessage reqMsg1 = new GetUserRequestMessage(userid, password, domain); //RoleType userConfig = new RoleType(); //userConfig.getProject().add(project); //userConfig.setProjectId(pid); String requestString = null; requestString = reqMsg1.doBuildXML(username); //MessageUtil.getInstance().setRequest( //"URL: " + projectURL + "getServices" + "\n" + requestString); //log.info("PM request: /n"+getUserInfoRequestString); if (System.getProperty("webServiceMethod").equals("SOAP")) { response = sendSOAP(new EndpointReference(projectURL), requestString, "http://rpdr.partners.org/GetUserConfiguration", "GetUserConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ } else { response = sendREST(new EndpointReference(projectURL + "getServices"), requestString); //$NON-NLS-1$ } if (response == null) { log.info("no pm response received"); return "error"; } //MessageUtil.getInstance().setResponse( // "URL: " + projectURL + "getServices" + "\n" + response); JAXBUtil jaxbUtil = new JAXBUtil(new String[] { "edu.harvard.i2b2.crcxmljaxb.datavo.pm", "edu.harvard.i2b2.crcxmljaxb.datavo.i2b2message" }); JAXBElement jaxbElement = jaxbUtil.unMashallFromString(response); ResponseMessageType responseMessageType = (ResponseMessageType) jaxbElement.getValue(); String procStatus = responseMessageType.getResponseHeader().getResultStatus().getStatus().getType(); //String procMessage = responseMessageType.getResponseHeader().getResultStatus().getStatus().getValue(); //String serverVersion = responseMessageType.getMessageHeader() //.getSendingApplication().getApplicationVersion(); //System.setProperty("serverVersion", serverVersion); String fullname = null; boolean isadmin = false; if (procStatus.equals("ERROR")) { //setMsg(procMessage); } else if (procStatus.equals("WARNING")) { //setMsg(procMessage); } else { BodyType bodyType = responseMessageType.getMessageBody(); JAXBUnWrapHelper helper = new JAXBUnWrapHelper(); UserType userType = (UserType) helper.getObjectByClass(bodyType.getAny(), UserType.class); fullname = userType.getFullName(); isadmin = userType.isIsAdmin(); } //////////////// SetUserPasswordRequestMessage reqMsg = new SetUserPasswordRequestMessage(userid, password, domain); //RoleType userConfig = new RoleType(); //userConfig.getProject().add(project); //userConfig.setProjectId(pid); requestString = null; UserType user = new UserType(); user.setUserName(username); edu.harvard.i2b2.pm.datavo.pm.PasswordType newPasswordType = new edu.harvard.i2b2.pm.datavo.pm.PasswordType(); newPasswordType.setValue(newPassword); user.setPassword(newPasswordType); user.setDomain(domain); user.setIsAdmin(isadmin); if (fullname != null) { user.setFullName(fullname); } else { user.setFullName("i2b2 User");//UserInfoBean.getInstance().getUserFullName()); } requestString = reqMsg.doBuildXML(user); //MessageUtil.getInstance().setRequest( //"URL: " + projectURL + "getServices" + "\n" + requestString); //log.info("PM request: /n"+getUserInfoRequestString); if (System.getProperty("webServiceMethod").equals("SOAP")) { response = sendSOAP(new EndpointReference(projectURL), requestString, "http://rpdr.partners.org/GetUserConfiguration", "GetUserConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ } else { response = sendREST(new EndpointReference(projectURL + "getServices"), requestString); //$NON-NLS-1$ } if (response == null) { log.info("no pm response received"); return "error"; } //MessageUtil.getInstance().setResponse( //"URL: " + projectURL + "getServices" + "\n" + response); } catch (AxisFault e) { log.error(e.getMessage()); //setMsg(Messages.getString("LoginHelper.PMUnavailable")); } catch (Exception e) { log.error(e.getMessage()); setMsg(e.getMessage()); } return response; }
From source file:com.vmware.identity.sts.ws.SignatureValidator.java
/** * Parses the KeyInfo from the XML signature and extracts the signing * certificate. KeyInfo should have the following format: * * <KeyInfo> <SecurityTokenReference> <Reference URI=""/> OR <KeyIdentifier * /> </SecurityTokenReference> </KeyInfo> * * @param header/* ww w . j a va 2 s . c om*/ * not null * @return the signing certificate */ private Signature extractSignature(SecurityHeaderType header) { assert header != null; Signature result = null; KeyInfoType keyInfo = header.getSignature().getKeyInfo(); if (keyInfo == null) { throwInvalidSecurity("KeyInfo not found"); } logger.debug("Found KeyInfo"); SecurityTokenReferenceType stRef = getTheValue(keyInfo.getContent(), SecurityTokenReferenceType.class, FaultKey.WSSE_INVALID_SECURITY, "SecurityTokenReference not found"); logger.debug("Found SecurityTokenReference"); List<Object> stRefContent = stRef.getAny(); if (stRefContent == null || stRefContent.size() != 1) { throwInvalidSecurity("SecurityTokenReference is empty"); } if (!(stRefContent.get(0) instanceof JAXBElement<?>)) { throwInvalidSecurity("Unknown SecurityTokenReference content type"); } JAXBElement<?> jaxbElement = (JAXBElement<?>) stRefContent.get(0); if (ReferenceType.class.equals(jaxbElement.getDeclaredType())) { ReferenceType reference = (ReferenceType) jaxbElement.getValue(); result = parseReferenceType(header, reference); } else if (KeyIdentifierType.class.equals(jaxbElement.getDeclaredType())) { KeyIdentifierType keyIdentifier = (KeyIdentifierType) jaxbElement.getValue(); result = parseKeyIdentifier(header, keyIdentifier); } else { throw new WSFaultException(FaultKey.WSSE_UNSUPPORTED_SECURITY_TOKEN, "Unknown SecurityTokenReference content"); } return result; }
From source file:com.microsoft.exchange.impl.ExchangeResponseUtilsImpl.java
@Override public Set<ItemType> parseFindItemResponse(FindItemResponse response) { confirmSuccess(response);/*from w w w . j ava2s . co m*/ Set<ItemType> calendarItems = new HashSet<ItemType>(); ArrayOfResponseMessagesType findItemResponseMessages = response.getResponseMessages(); List<JAXBElement<? extends ResponseMessageType>> itemResponseMessages = findItemResponseMessages .getCreateItemResponseMessagesAndDeleteItemResponseMessagesAndGetItemResponseMessages(); for (JAXBElement<? extends ResponseMessageType> element : itemResponseMessages) { FindItemResponseMessageType itemType = (FindItemResponseMessageType) element.getValue(); FindItemParentType rootFolder = itemType.getRootFolder(); ArrayOfRealItemsType items = rootFolder.getItems(); calendarItems.addAll(items.getItemsAndMessagesAndCalendarItems()); } return calendarItems; }
From source file:gov.va.ds4p.ds4pmobileportal.pep.XACMLPolicyEnforcement.java
private PolicySetType getXACMLPolicySetFromString() { PolicySetType res = null;/*from w w w.ja va2 s . c om*/ try { //this is a base65 value so decode //String policyString = new String(com.sun.org.apache.xml.internal.security.utils.Base64.decode(xacmlPolicyS)); //System.out.println("POLICYSET_STRING: "+policyString); JAXBContext context = JAXBContext.newInstance(PolicySetType.class); Unmarshaller unmarshaller = context.createUnmarshaller(); StringReader sr = new StringReader(xacmlPolicyS); Object o = unmarshaller.unmarshal(sr); JAXBElement element = (JAXBElement) o; res = (PolicySetType) element.getValue(); } catch (Exception ex) { ex.printStackTrace(); } return res; }
From source file:org.wallerlab.yoink.service.PropertyWrapper.java
private void putSmoothingResultInProperty(Job<JAXBElement> job, JAXBElement<Cml> cmlElement, Map<JobParameter, Object> parameters, Map<String, Object> properties) { ObjectFactory objectFactory = new ObjectFactory(); PropertyList propertyList = objectFactory.createPropertyList(); propertyList.setTitle("Smoothing result :"); Property property = wrapSmoothResult(job, properties, objectFactory, propertyList); wrapForceAndEnergy(properties, objectFactory, propertyList, property); JAXBElement propertyListJAXB = objectFactory.createPropertyList(propertyList); cmlElement.getValue().getAnyCmlOrAnyOrAny().add(propertyListJAXB); }
From source file:com.microsoft.exchange.integration.AbstractIntegrationTest.java
/** * Create 3 {@link CalendarItemType}s and submit with 1 {@link ExchangeWebServicesClient#createItem(CreateItem)} invocation. *///from w ww .j a va2 s.c o m @Test public void testCreate3CalendarItems() { NonEmptyArrayOfBaseItemIdsType createdIds = new NonEmptyArrayOfBaseItemIdsType(); try { initializeCredentials(); CalendarItemType item1 = constructCalendarItem(DateHelp.parseDateTimePhrase("20121109-1300"), DateHelp.parseDateTimePhrase("20121109-1400"), "integration test: testCreate3CalendarItems, item1", "test location", "test ran at " + new Date()); CalendarItemType item2 = constructCalendarItem(DateHelp.parseDateTimePhrase("20121109-1400"), DateHelp.parseDateTimePhrase("20121109-1500"), "integration test: testCreate3CalendarItems, item2", "test location", "test ran at " + new Date()); CalendarItemType item3 = constructCalendarItem(DateHelp.parseDateTimePhrase("20121109-1500"), DateHelp.parseDateTimePhrase("20121109-1600"), "integration test: testCreate3CalendarItems, item3", "test location", "test ran at " + new Date()); CreateItem request = new CreateItem(); request.setSendMeetingInvitations(CalendarItemCreateOrDeleteOperationType.SEND_TO_ALL_AND_SAVE_COPY); NonEmptyArrayOfAllItemsType arrayOfItems = new NonEmptyArrayOfAllItemsType(); arrayOfItems.getItemsAndMessagesAndCalendarItems().add(item1); arrayOfItems.getItemsAndMessagesAndCalendarItems().add(item2); arrayOfItems.getItemsAndMessagesAndCalendarItems().add(item3); request.setItems(arrayOfItems); DistinguishedFolderIdType folder = new DistinguishedFolderIdType(); folder.setId(DistinguishedFolderIdNameType.CALENDAR); TargetFolderIdType target = new TargetFolderIdType(); target.setDistinguishedFolderId(folder); request.setSavedItemFolderId(target); StopWatch stopWatch = new StopWatch(); stopWatch.start(); CreateItemResponse response = ewsClient.createItem(request); stopWatch.stop(); log.debug("CreateItem request (3 CalendarItems) completed in " + stopWatch); Assert.assertNotNull(response); ArrayOfResponseMessagesType responseMessages = response.getResponseMessages(); Assert.assertNotNull(responseMessages); Assert.assertEquals(3, responseMessages .getCreateItemResponseMessagesAndDeleteItemResponseMessagesAndGetItemResponseMessages().size()); for (JAXBElement<? extends ResponseMessageType> m : responseMessages .getCreateItemResponseMessagesAndDeleteItemResponseMessagesAndGetItemResponseMessages()) { Assert.assertEquals(ResponseCodeType.NO_ERROR, m.getValue().getResponseCode()); ItemInfoResponseMessageType itemType = (ItemInfoResponseMessageType) m.getValue(); ArrayOfRealItemsType itemArray = itemType.getItems(); ItemType item = itemArray.getItemsAndMessagesAndCalendarItems().get(0); createdIds.getItemIdsAndOccurrenceItemIdsAndRecurringMasterItemIds().add(item.getItemId()); } } finally { deleteItems(createdIds); } }
From source file:com.microsoft.exchange.integration.AbstractIntegrationTest.java
/** * Create a single {@link CalendarItemType} and submit with {@link ExchangeWebServicesClient#createItem(CreateItem)}. * @throws JAXBException /*w ww . j a v a 2 s .c om*/ */ @Test public void testCreateCalendarItem() throws JAXBException { NonEmptyArrayOfBaseItemIdsType createdIds = new NonEmptyArrayOfBaseItemIdsType(); try { initializeCredentials(); CalendarItemType calendarItem = new CalendarItemType(); final Date start = DateHelp.parseDateTimePhrase("20121109-1200"); final Date end = DateHelp.parseDateTimePhrase("20121109-1300"); calendarItem.setStart(DateHelp.convertDateToXMLGregorianCalendar(start)); calendarItem.setEnd(DateHelp.convertDateToXMLGregorianCalendar(end)); calendarItem.setSubject("integration test: testCreateCalendarItem"); calendarItem.setLocation("test location"); BodyType body = new BodyType(); body.setBodyType(BodyTypeType.TEXT); body.setValue("test ran at " + new Date()); calendarItem.setBody(body); CreateItem request = new CreateItem(); request.setSendMeetingInvitations(CalendarItemCreateOrDeleteOperationType.SEND_TO_ALL_AND_SAVE_COPY); NonEmptyArrayOfAllItemsType arrayOfItems = new NonEmptyArrayOfAllItemsType(); arrayOfItems.getItemsAndMessagesAndCalendarItems().add(calendarItem); request.setItems(arrayOfItems); DistinguishedFolderIdType folder = new DistinguishedFolderIdType(); folder.setId(DistinguishedFolderIdNameType.CALENDAR); TargetFolderIdType target = new TargetFolderIdType(); target.setDistinguishedFolderId(folder); request.setSavedItemFolderId(target); StopWatch stopWatch = new StopWatch(); stopWatch.start(); CreateItemResponse response = ewsClient.createItem(request); stopWatch.stop(); Assert.assertNotNull(response); String captured = capture(response); log.debug("CreateItem request (1 CalendarItem) completed in " + stopWatch + ", response: " + captured); ArrayOfResponseMessagesType responseMessages = response.getResponseMessages(); Assert.assertNotNull(responseMessages); Assert.assertEquals(1, responseMessages .getCreateItemResponseMessagesAndDeleteItemResponseMessagesAndGetItemResponseMessages().size()); JAXBElement<? extends ResponseMessageType> m = responseMessages .getCreateItemResponseMessagesAndDeleteItemResponseMessagesAndGetItemResponseMessages().get(0); Assert.assertEquals(ResponseCodeType.NO_ERROR, m.getValue().getResponseCode()); ItemInfoResponseMessageType itemType = (ItemInfoResponseMessageType) m.getValue(); ArrayOfRealItemsType itemArray = itemType.getItems(); ItemType item = itemArray.getItemsAndMessagesAndCalendarItems().get(0); createdIds.getItemIdsAndOccurrenceItemIdsAndRecurringMasterItemIds().add(item.getItemId()); } finally { deleteItems(createdIds); } }
From source file:com.microsoft.exchange.impl.ExchangeResponseUtilsImpl.java
@Override public List<ItemIdType> parseCreateItemResponse(CreateItemResponse response) { confirmSuccess(response);//from www . j a va 2s .co m List<ItemIdType> itemIds = new ArrayList<ItemIdType>(); ArrayOfResponseMessagesType responseMessages = response.getResponseMessages(); List<JAXBElement<? extends ResponseMessageType>> createItemResponseMessages = responseMessages .getCreateItemResponseMessagesAndDeleteItemResponseMessagesAndGetItemResponseMessages(); for (JAXBElement<? extends ResponseMessageType> responeElement : createItemResponseMessages) { ItemInfoResponseMessageType itemInfo = (ItemInfoResponseMessageType) responeElement.getValue(); ArrayOfRealItemsType items = itemInfo.getItems(); List<ItemType> calendarItems = items.getItemsAndMessagesAndCalendarItems(); for (ItemType itemType : calendarItems) { itemIds.add(itemType.getItemId()); } } return itemIds; }
From source file:com.microsoft.exchange.impl.ExchangeResponseUtilsImpl.java
@Override public Set<ItemType> parseGetItemResponse(GetItemResponse response) { Set<ItemType> items = new HashSet<ItemType>(); confirmSuccess(response);/*from w w w . ja va 2s . c o m*/ ArrayOfResponseMessagesType responseMessages = response.getResponseMessages(); List<JAXBElement<? extends ResponseMessageType>> getItemResponseMessages = responseMessages .getCreateItemResponseMessagesAndDeleteItemResponseMessagesAndGetItemResponseMessages(); for (JAXBElement<? extends ResponseMessageType> responseMessageElement : getItemResponseMessages) { ItemInfoResponseMessageType itemType = (ItemInfoResponseMessageType) responseMessageElement.getValue(); ArrayOfRealItemsType itemsArray = itemType.getItems(); items.addAll(itemsArray.getItemsAndMessagesAndCalendarItems()); } return items; }