List of usage examples for org.w3c.dom Element setPrefix
public void setPrefix(String prefix) throws DOMException;
null
if it is unspecified. From source file:org.ojbc.bundles.adapters.TestStaticMockAdapter.java
private Document buildFirearmReportQueryRequest() throws Exception { Document ret = createDocument(); Element root = ret.createElementNS(OjbcNamespaceContext.NS_FIREARM_REGISTRATION_QUERY_REQUEST_DOC, "FirearmRegistrationRequest"); ret.appendChild(root);//from ww w .java 2 s. c om root.setPrefix(OjbcNamespaceContext.NS_PREFIX_FIREARM_REGISTRATION_QUERY_REQUEST_DOC); Element id = XmlUtils.appendElement(root, OjbcNamespaceContext.NS_FIREARM_REGISTRATION_QUERY_REQUEST_EXT, "FirearmRegistrationIdentification"); Element e = XmlUtils.appendElement(id, OjbcNamespaceContext.NS_NC, "IdentificationID"); e.setTextContent("sample-980082210822985352.xml:F1"); e = XmlUtils.appendElement(id, OjbcNamespaceContext.NS_NC, "IdentificationSourceText"); e.setTextContent(StaticMockQuery.FIREARM_MOCK_ADAPTER_QUERY_BY_FIREARM_SYSTEM_ID); XmlUtils.OJBC_NAMESPACE_CONTEXT.populateRootNamespaceDeclarations(root); return ret; }
From source file:org.ojbc.intermediaries.sn.dao.rapback.FbiSubModDocBuilder.java
public Document buildFbiSubModDoc(FbiSubscriptionModification fbiSubMod) throws Exception { Document doc = OJBCXMLUtils.createDocument(); Element modifyElement = doc.createElementNS(OjbcNamespaceContext.NS_B2, "Modify"); modifyElement.setPrefix(OjbcNamespaceContext.NS_PREFIX_B2); doc.appendChild(modifyElement);// w w w . j a v a 2s .c o m Element subModMsgElement = XmlUtils.appendElement(modifyElement, OjbcNamespaceContext.NS_SUB_MODIFY_MESSAGE, "SubscriptionModificationMessage"); buildSubjectElement(subModMsgElement, fbiSubMod); buildFBISubscriptionElement(subModMsgElement, fbiSubMod); buildSubModEndDateElement(subModMsgElement, fbiSubMod); CTXT.populateRootNamespaceDeclarations(doc.getDocumentElement()); return doc; }
From source file:org.ojbc.intermediaries.sn.FbiSubscriptionProcessor.java
/** * Anticipated to be received from the portal manual subscriptions (not from intermediary auto subscriptions) *///from ww w . java 2s . c o m public Document appendFbiUcnIdToUnsubscribeDoc(Document unsubscribeDoc, String fbiUcnId) throws Exception { logger.info("\n\n\n appendFbiUcnIdToUnsubscribeDoc... \n\n\n"); Node unsubMsgElement = XmlUtils.xPathNodeSearch(unsubscribeDoc, "/b-2:Unsubscribe/unsubmsg-exch:UnsubscriptionMessage"); Node subjNode = XmlUtils.xPathNodeSearch(unsubMsgElement, "submsg-ext:Subject"); if (subjNode != null) { throw new Exception( "Unexpected existance of Subject node. Appending fbi data would have created duplicate subject node" + "(corrupting doc). Requirements must have changed to arrive here."); } if (StringUtils.isNotEmpty(fbiUcnId)) { Element subjectElement = unsubscribeDoc.createElementNS(OjbcNamespaceContext.NS_SUB_MSG_EXT, "Subject"); subjectElement.setPrefix(OjbcNamespaceContext.NS_PREFIX_SUB_MSG_EXT); unsubMsgElement.appendChild(subjectElement); Element personAugmentElement = XmlUtils.appendElement(subjectElement, OjbcNamespaceContext.NS_JXDM_41, "PersonAugmentation"); Element personFbiIdElement = XmlUtils.appendElement(personAugmentElement, OjbcNamespaceContext.NS_JXDM_41, "PersonFBIIdentification"); Element personFbiIdValElement = XmlUtils.appendElement(personFbiIdElement, OjbcNamespaceContext.NS_NC, "IdentificationID"); personFbiIdValElement.setTextContent(fbiUcnId); } OjbcNamespaceContext ojbNsCtxt = new OjbcNamespaceContext(); ojbNsCtxt.populateRootNamespaceDeclarations(unsubscribeDoc.getDocumentElement()); return unsubscribeDoc; }
From source file:org.ojbc.intermediaries.sn.FbiSubscriptionProcessor.java
public Document appendFbiSubscriptionIdToUnsubscribeDoc(Document unsubscribeDoc, String fbiSubId) throws Exception { logger.info("\n\n\n appendFbiDataToFbiUnSubscribeDoc... \n\n\n"); Element relatedFBISubscriptionElement = unsubscribeDoc.createElementNS(OjbcNamespaceContext.NS_SUB_MSG_EXT, "RelatedFBISubscription"); relatedFBISubscriptionElement.setPrefix(OjbcNamespaceContext.NS_PREFIX_SUB_MSG_EXT); Node unsubMsgNode = XmlUtils.xPathNodeSearch(unsubscribeDoc, "//unsubmsg-exch:UnsubscriptionMessage"); unsubMsgNode.appendChild(relatedFBISubscriptionElement); if (StringUtils.isNotEmpty(fbiSubId)) { Element subFbiIdElement = XmlUtils.appendElement(relatedFBISubscriptionElement, OjbcNamespaceContext.NS_SUB_MSG_EXT, "SubscriptionFBIIdentification"); Element fbiIdValElement = XmlUtils.appendElement(subFbiIdElement, OjbcNamespaceContext.NS_NC, "IdentificationID"); fbiIdValElement.setTextContent(fbiSubId); }//from w w w. j a va2 s . c o m OjbcNamespaceContext ojbNsCtxt = new OjbcNamespaceContext(); ojbNsCtxt.populateRootNamespaceDeclarations(unsubscribeDoc.getDocumentElement()); return unsubscribeDoc; }
From source file:org.ojbc.intermediaries.sn.FbiSubscriptionProcessor.java
public Document appendFbiDataToSubscriptionDoc(Document subscriptionDoc, FbiRapbackSubscription fbiRapbackSubscription) throws Exception { logger.info("appendFbiDataToSubscriptionDoc..."); Element relatedFBISubscriptionElement = subscriptionDoc.createElementNS(OjbcNamespaceContext.NS_SUB_MSG_EXT, "RelatedFBISubscription"); relatedFBISubscriptionElement.setPrefix(OjbcNamespaceContext.NS_PREFIX_SUB_MSG_EXT); Node subMsgNode = XmlUtils.xPathNodeSearch(subscriptionDoc, "//submsg-exch:SubscriptionMessage"); subMsgNode.appendChild(relatedFBISubscriptionElement); Element dateRangeElement = XmlUtils.appendElement(relatedFBISubscriptionElement, OjbcNamespaceContext.NS_NC, "DateRange"); DateTime jtStartDate = fbiRapbackSubscription.getRapbackStartDate(); if (jtStartDate != null) { Element startDateElement = XmlUtils.appendElement(dateRangeElement, OjbcNamespaceContext.NS_NC, "StartDate"); Element startDateValElement = XmlUtils.appendElement(startDateElement, OjbcNamespaceContext.NS_NC, "Date"); String sStartDate = sdf.format(jtStartDate.toDate()); startDateValElement.setTextContent(sStartDate); }//from www. j av a 2 s. c om DateTime jtEndDate = fbiRapbackSubscription.getRapbackExpirationDate(); if (jtEndDate != null) { Element endDateElement = XmlUtils.appendElement(dateRangeElement, OjbcNamespaceContext.NS_NC, "EndDate"); Element endDateValElement = XmlUtils.appendElement(endDateElement, OjbcNamespaceContext.NS_NC, "Date"); String sEndDate = sdf.format(jtEndDate.toDate()); endDateValElement.setTextContent(sEndDate); } String fbiId = fbiRapbackSubscription.getFbiSubscriptionId(); if (StringUtils.isNotEmpty(fbiId)) { Element subFbiIdElement = XmlUtils.appendElement(relatedFBISubscriptionElement, OjbcNamespaceContext.NS_SUB_MSG_EXT, "SubscriptionFBIIdentification"); Element fbiIdValElement = XmlUtils.appendElement(subFbiIdElement, OjbcNamespaceContext.NS_NC, "IdentificationID"); fbiIdValElement.setTextContent(fbiId); } String reasonCode = fbiRapbackSubscription.getRapbackCategory(); if (StringUtils.isNotEmpty(reasonCode)) { Element reasonCodeElement = XmlUtils.appendElement(relatedFBISubscriptionElement, OjbcNamespaceContext.NS_SUB_MSG_EXT, "CriminalSubscriptionReasonCode"); reasonCodeElement.setTextContent(reasonCode); } String subTerm = fbiRapbackSubscription.getSubscriptionTerm(); if (StringUtils.isNotEmpty(subTerm)) { Element subscriptionTermElement = XmlUtils.appendElement(relatedFBISubscriptionElement, OjbcNamespaceContext.NS_SUB_MSG_EXT, "SubscriptionTerm"); Element termDurationElement = XmlUtils.appendElement(subscriptionTermElement, OjbcNamespaceContext.NS_JXDM_41, "TermDuration"); termDurationElement.setTextContent(subTerm); } OjbcNamespaceContext ojbNsCtxt = new OjbcNamespaceContext(); ojbNsCtxt.populateRootNamespaceDeclarations(subscriptionDoc.getDocumentElement()); return subscriptionDoc; }
From source file:org.ojbc.intermediaries.sn.subscription.SubscriptionSearchQueryProcessor.java
/** * Convert the POJO to the equivalent XML document *//*from w w w . j a va2 s . c o m*/ public Document buildSubscriptionQueryResponseDoc(Subscription subscriptionSearchResponse) throws Exception { Document doc = null; DocumentBuilderFactory docBuilderFact = DocumentBuilderFactory.newInstance(); docBuilderFact.setNamespaceAware(true); DocumentBuilder docBuilder = docBuilderFact.newDocumentBuilder(); doc = docBuilder.newDocument(); Element root = doc.createElementNS(OjbcNamespaceContext.NS_SUBSCRIPTION_QUERY_RESULTS, "SubscriptionQueryResults"); doc.appendChild(root); root.setPrefix(OjbcNamespaceContext.NS_PREFIX_SUBSCRIPTION_QUERY_RESULTS); Element subscriptionSearchResultElement = XmlUtils.appendElement(root, OjbcNamespaceContext.NS_SUBSCRIPTION_QUERY_RESULTS_EXT, "SubscriptionQueryResult"); appendSubscriptionParentResponse(subscriptionSearchResponse, doc, subscriptionSearchResultElement, 0, OjbcNamespaceContext.NS_SUBSCRIPTION_QUERY_RESULTS_EXT); List<Subscription> searchResponse = new ArrayList<Subscription>(); searchResponse.add(subscriptionSearchResponse); createSubscriptionSubjects(searchResponse, doc, root, OjbcNamespaceContext.NS_SUBSCRIPTION_QUERY_RESULTS_EXT); createSubscriptionEmails(searchResponse, doc, root, OjbcNamespaceContext.NS_SUBSCRIPTION_QUERY_RESULTS_EXT); OJBC_NAMESPACE_CONTEXT.populateRootNamespaceDeclarations(root); return doc; }
From source file:org.ojbc.intermediaries.sn.subscription.SubscriptionSearchQueryProcessor.java
/** * Convert the list of POJOs to the equivalent XML document *//*from w ww . j av a 2 s.com*/ public Document buildSubscriptionSearchResponseDoc(List<Subscription> subscriptionSearchResponseList) throws Exception { Document doc = null; DocumentBuilderFactory docBuilderFact = DocumentBuilderFactory.newInstance(); docBuilderFact.setNamespaceAware(true); DocumentBuilder docBuilder = docBuilderFact.newDocumentBuilder(); doc = docBuilder.newDocument(); Element root = doc.createElementNS(OjbcNamespaceContext.NS_SUBSCRIPTION_SEARCH_RESULTS, "SubscriptionSearchResults"); doc.appendChild(root); root.setPrefix(OjbcNamespaceContext.NS_PREFIX_SUBSCRIPTION_SEARCH_RESULTS); for (Subscription subscriptionSearchResponse : subscriptionSearchResponseList) { Element subscriptionSearchResultElement = XmlUtils.appendElement(root, OjbcNamespaceContext.NS_SUBSCRIPTION_SEARCH_RESULTS_EXT, "SubscriptionSearchResult"); int index = subscriptionSearchResponseList.indexOf(subscriptionSearchResponse); appendSubscriptionParentResponse(subscriptionSearchResponse, doc, subscriptionSearchResultElement, index, OjbcNamespaceContext.NS_SUBSCRIPTION_SEARCH_RESULTS_EXT); } createSubscriptionSubjects(subscriptionSearchResponseList, doc, root, OjbcNamespaceContext.NS_SUBSCRIPTION_SEARCH_RESULTS_EXT); createSubscriptionEmails(subscriptionSearchResponseList, doc, root, OjbcNamespaceContext.NS_SUBSCRIPTION_SEARCH_RESULTS_EXT); OJBC_NAMESPACE_CONTEXT.populateRootNamespaceDeclarations(root); return doc; }
From source file:org.ojbc.intermediaries.sn.subscription.SubscriptionValidationMessageProcessor.java
/** * This method create the validation response message. It will set the validation indicator appropriately. * /*from w w w . j av a2 s. co m*/ * @param validationIndicator * @return * @throws Exception */ Document createSubscriptionValidationResponseMessage(boolean validationIndicator) throws Exception { Document doc = null; DocumentBuilderFactory docBuilderFact = DocumentBuilderFactory.newInstance(); docBuilderFact.setNamespaceAware(true); DocumentBuilder docBuilder = docBuilderFact.newDocumentBuilder(); doc = docBuilder.newDocument(); Element root = doc.createElementNS(OjbcNamespaceContext.NS_B2, "ValidateResponse"); doc.appendChild(root); root.setPrefix(OjbcNamespaceContext.NS_PREFIX_B2); Element subscriptionValidationResponseMessageElement = XmlUtils.appendElement(root, OjbcNamespaceContext.NS_SUB_VALID_MESSAGE, "SubscriptionValidationResponseMessage"); Element subscriptionValidatedIndicatorElement = XmlUtils.appendElement( subscriptionValidationResponseMessageElement, OjbcNamespaceContext.NS_SUBSCRIPTION_RESPONSE_EXT, "SubscriptionValidatedIndicator"); subscriptionValidatedIndicatorElement.setTextContent(String.valueOf(validationIndicator)); return doc; }
From source file:org.ojbc.intermediaries.sn.util.FaultMessageBuilderUtil.java
public static Document createUnableToValidateSubscriptionFault( @Header(value = "subscriptionID") String subscriptionID) throws Exception { DateTime faultTime = new DateTime(); Document doc = null;/* w w w.j a v a 2 s. c o m*/ DocumentBuilderFactory docBuilderFact = DocumentBuilderFactory.newInstance(); docBuilderFact.setNamespaceAware(true); DocumentBuilder docBuilder = docBuilderFact.newDocumentBuilder(); doc = docBuilder.newDocument(); Element root = doc.createElementNS(OjbcNamespaceContext.NS_B2, "UnableToValidateSubscriptionFault"); doc.appendChild(root); root.setPrefix(OjbcNamespaceContext.NS_PREFIX_B2); Element subscriptionValidationFaultResponseMessageElement = XmlUtils.appendElement(root, OjbcNamespaceContext.NS_SUBSCRIPTION_FAULT_RESPONSE_EXCH, "SubscriptionValidationFaultResponseMessage"); if (StringUtils.isNotBlank(subscriptionID)) { Element subscriptionIdentificationElement = XmlUtils.appendElement( subscriptionValidationFaultResponseMessageElement, OjbcNamespaceContext.NS_SUBSCRIPTION_FAULT_RESPONSE_EXT, "SubscriptionIdentification"); Element identificationIDElement = XmlUtils.appendElement(subscriptionIdentificationElement, OjbcNamespaceContext.NS_NC, "IdentificationID"); identificationIDElement.setTextContent(subscriptionID); Element identificationSourceTextElement = XmlUtils.appendElement(subscriptionIdentificationElement, OjbcNamespaceContext.NS_NC, "IdentificationSourceText"); identificationSourceTextElement.setTextContent("Subscriptions"); } Element invalidSubscriptionIdentifierIndicatorElement = XmlUtils.appendElement( subscriptionValidationFaultResponseMessageElement, OjbcNamespaceContext.NS_SUBSCRIPTION_FAULT_RESPONSE_EXT, "IdentificationSourceText"); invalidSubscriptionIdentifierIndicatorElement.setTextContent("true"); Element timestampElement = XmlUtils.appendElement(root, OjbcNamespaceContext.NS_BF2, "Timestamp"); timestampElement.setTextContent(faultTime.toString("yyyy-MM-dd'T'HH:mm:ss")); return doc; }
From source file:org.ojbc.util.helper.NIEMXMLUtils.java
public static Element createNC20DateOnlyRangeElementWithParent(Document doc, String parentElementName, DateTime dateStart, DateTime dateEnd) { Element parentElement = doc.createElementNS(OjbcNamespaceContext.NS_NC, OjbcNamespaceContext.NS_PREFIX_NC + ":" + parentElementName); if (dateStart != null) { Element startDateElement = createElementDate(doc, "StartDate", dateStart); startDateElement.setPrefix("nc"); parentElement.appendChild(startDateElement); }/*from w w w . ja v a2 s . co m*/ if (dateEnd != null) { Element endDateElement = createElementDate(doc, "EndDate", dateEnd); endDateElement.setPrefix("nc"); parentElement.appendChild(endDateElement); } return parentElement; }