public static boolean hasReferenceParameters(EndpointReference epr){ Map<QName, OMElement> refParams = epr.getAllReferenceParameters(); if(refParams!=null){ if(!refParams.isEmpty()){ return true; } } return false; }
public static String decodeSubscriptionResponse(OMElement subscriptionReference) throws AxisFault { String subscriptionId = null; EndpointReference subscriptionReferenceEPR = EndpointReferenceHelper.fromOM(subscriptionReference); Map<QName, OMElement> referenceParams = subscriptionReferenceEPR.getAllReferenceParameters(); if (referenceParams != null) { QName identifierQName = new QName(NameSpaceConstants.WSNT_NS.getNamespaceURI(), WsmgCommonConstants.SUBSCRIPTION_ID); OMElement identifierEl = referenceParams.get(identifierQName); subscriptionId = (identifierEl != null) ? identifierEl.getText() : null; } return subscriptionId; }
public static String decodeSubscriptionResponse(OMElement subscriptionReference) throws AxisFault { String subscriptionId = null; EndpointReference subscriptionReferenceEPR = EndpointReferenceHelper.fromOM(subscriptionReference); Map<QName, OMElement> referenceParams = subscriptionReferenceEPR.getAllReferenceParameters(); if (referenceParams != null) { QName identifierQName = new QName(NameSpaceConstants.WSNT_NS.getNamespaceURI(), WsmgCommonConstants.SUBSCRIPTION_ID); OMElement identifierEl = referenceParams.get(identifierQName); subscriptionId = (identifierEl != null) ? identifierEl.getText() : null; } return subscriptionId; }
public static String decodeSubscriptionResponse(OMElement subscriptionReference) throws AxisFault { String subscriptionId = null; EndpointReference subscriptionReferenceEPR = EndpointReferenceHelper.fromOM(subscriptionReference); Map<QName, OMElement> referenceParams = subscriptionReferenceEPR.getAllReferenceParameters(); if (referenceParams != null) { QName identifierQName = new QName(NameSpaceConstants.WSNT_NS.getNamespaceURI(), WsmgCommonConstants.SUBSCRIPTION_ID); OMElement identifierEl = referenceParams.get(identifierQName); subscriptionId = (identifierEl != null) ? identifierEl.getText() : null; } return subscriptionId; }
public static String decodeSubscriptionResponse(OMElement subscriptionReference) throws AxisFault { String subscriptionId = null; EndpointReference subscriptionReferenceEPR = EndpointReferenceHelper.fromOM(subscriptionReference); Map<QName, OMElement> referenceParams = subscriptionReferenceEPR.getAllReferenceParameters(); if (referenceParams != null) { QName identifierQName = new QName(NameSpaceConstants.WSNT_NS.getNamespaceURI(), WsmgCommonConstants.SUBSCRIPTION_ID); OMElement identifierEl = referenceParams.get(identifierQName); subscriptionId = (identifierEl != null) ? identifierEl.getText() : null; } return subscriptionId; }
public MessagePuller startPullingFromExistingMsgBox(EndpointReference msgBoxAddr, NotificationHandler handler, long interval, long timeout) throws MsgBrokerClientException { String toAddress = msgBoxAddr.getAddress(); int biginIndex = toAddress.indexOf("clientid"); String clientId = toAddress.substring(biginIndex + "clientid".length() + 1); if ((msgBoxAddr.getAllReferenceParameters() == null || msgBoxAddr.getAllReferenceParameters() .get(MsgBoxQNameConstants.MSG_BOXID_QNAME).getText() == null) && biginIndex == -1) throw new MsgBrokerClientException("Invalid Message Box Address"); this.msgBoxUser = new MsgBoxClient(); MessagePuller messagePuller = new MessagePuller(msgBoxUser, msgBoxAddr, handler, interval, timeout); messagePuller.startPulling(); return messagePuller; }
public MessagePuller startPullingFromExistingMsgBox(EndpointReference msgBoxAddr, NotificationHandler handler, long interval, long timeout) throws MsgBrokerClientException { String toAddress = msgBoxAddr.getAddress(); int biginIndex = toAddress.indexOf("clientid"); String clientId = toAddress.substring(biginIndex + "clientid".length() + 1); if ((msgBoxAddr.getAllReferenceParameters() == null || msgBoxAddr.getAllReferenceParameters() .get(MsgBoxQNameConstants.MSG_BOXID_QNAME).getText() == null) && biginIndex == -1) throw new MsgBrokerClientException("Invalid Message Box Address"); this.msgBoxUser = new MsgBoxClient(); MessagePuller messagePuller = new MessagePuller(msgBoxUser, msgBoxAddr, handler, interval, timeout); messagePuller.startPulling(); return messagePuller; }
public String subscribeMsgBox(EndpointReference msgBoxEpr, String topicExpression, String xpathExpression, long expireTime) throws MsgBrokerClientException { String msgBoxEventSink = msgBoxEpr.getAddress(); String formattedEventSink = null; if (msgBoxEpr.getAddress().contains("clientid")) { formattedEventSink = msgBoxEventSink; } else { if (msgBoxEpr.getAllReferenceParameters() == null) throw new MsgBrokerClientException("Invalid Message Box EPR, no reference parameters found"); String msgBoxId = msgBoxEpr.getAllReferenceParameters().get(MsgBoxQNameConstants.MSG_BOXID_QNAME).getText(); if (msgBoxId == null) throw new MsgBrokerClientException("Invalid Message Box EPR, reference parameter MsgBoxAddr is missing"); String format = msgBoxEventSink.endsWith("/") ? "%sclientid/%s" : "%s/clientid/%s"; formattedEventSink = String.format(format, msgBoxEventSink, msgBoxId); } return subscribe(new EndpointReference(formattedEventSink), topicExpression, xpathExpression, expireTime); }
public String subscribeMsgBox(EndpointReference msgBoxEpr, String topicExpression, String xpathExpression, long expireTime) throws MsgBrokerClientException { String msgBoxEventSink = msgBoxEpr.getAddress(); String formattedEventSink = null; if (msgBoxEpr.getAddress().contains("clientid")) { formattedEventSink = msgBoxEventSink; } else { if (msgBoxEpr.getAllReferenceParameters() == null) throw new MsgBrokerClientException("Invalid Message Box EPR, no reference parameters found"); String msgBoxId = msgBoxEpr.getAllReferenceParameters().get(MsgBoxQNameConstants.MSG_BOXID_QNAME).getText(); if (msgBoxId == null) throw new MsgBrokerClientException("Invalid Message Box EPR, reference parameter MsgBoxAddr is missing"); String format = msgBoxEventSink.endsWith("/") ? "%sclientid/%s" : "%s/clientid/%s"; formattedEventSink = String.format(format, msgBoxEventSink, msgBoxId); } return subscribe(new EndpointReference(formattedEventSink), topicExpression, xpathExpression, expireTime); }
private boolean equalReferenceParameters(SubscriptionState anotherSubscription) { .getAllReferenceParameters(); Map<QName, OMElement> myRefProperties = getConsumerReference().getAllReferenceParameters();
public static EndpointReference cloneEPR (EndpointReference epr) { EndpointReference newEPR = new EndpointReference (epr.getAddress()); Map<QName, OMElement> referenceParams = epr.getAllReferenceParameters(); if (referenceParams != null) { for (Iterator<Entry<QName, OMElement>> entries = referenceParams.entrySet().iterator(); entries .hasNext();) { Entry<QName, OMElement> entry = entries.next(); Object referenceParam = entry.getValue(); if (referenceParam instanceof OMElement) { OMElement clonedElement = ((OMElement) referenceParam) .cloneOMElement(); clonedElement.setText("false"); newEPR.addReferenceParameter(clonedElement); } } } return newEPR; }
/** * * Converts Axis2's EPR type into our general one so that code isn't specific * to the Axis2 platform. Hopefully this becomes irrelevant through the * adoption of something like JSR-261 or some WS-A project in Apache Commons. * */ public EndpointReference convertEPR(org.apache.axis2.addressing.EndpointReference axisEPR) { URI address = URI.create(axisEPR.getAddress()); EndpointReference epr = new EndpointReference(address); Map parameters = axisEPR.getAllReferenceParameters(); Iterator i = parameters.keySet().iterator(); while (i.hasNext()) { QName name = (QName)i.next(); OMElement axiomValue = (OMElement)parameters.get(name); Element domValue = convertToDOM(axiomValue); epr.addParameter(domValue); } return epr; }
public String deleteMsgBox(EndpointReference msgBoxEpr, long timeout) throws MsgBrokerClientException { String msgBoxEventSink = msgBoxEpr.getAddress(); String formattedEventSink = null; if (msgBoxEpr.getAddress().contains("clientid")) { formattedEventSink = msgBoxEventSink; } else { if (msgBoxEpr.getAllReferenceParameters() == null) throw new MsgBrokerClientException("Invalid Message Box EPR, no reference parameters found"); String msgBoxId = msgBoxEpr.getAllReferenceParameters().get(MsgBoxQNameConstants.MSG_BOXID_QNAME).getText(); if (msgBoxId == null) throw new MsgBrokerClientException( "Invalid Message Box EPR, reference parameter MsgBoxAddress is missing"); String format = msgBoxEventSink.endsWith("/") ? "%sclientid/%s" : "%s/clientid/%s"; formattedEventSink = String.format(format, msgBoxEventSink, msgBoxId); } if (this.msgBoxUser == null) { this.msgBoxUser = new MsgBoxClient(); } String resp = null; try { resp = msgBoxUser.deleteMsgBox(msgBoxEpr, timeout); } catch (RemoteException e) { throw new MsgBrokerClientException("unable to delete the msg box", e); } return resp; }
private void processEmbeddedEPR(List extensibilityElements, AxisEndpoint axisEndpoint) { Iterator eelts = extensibilityElements.iterator(); while(eelts.hasNext()){ ExtensibilityElement ee = (ExtensibilityElement)eelts.next(); if(AddressingConstants.Final.WSA_ENDPOINT_REFERENCE.equals(ee.getElementType())){ try { Element elt = ((UnknownExtensibilityElement)ee).getElement(); OMElement eprOMElement = XMLUtils.toOM(elt); EndpointReference epr = EndpointReferenceHelper.fromOM(eprOMElement); Map referenceParameters = epr.getAllReferenceParameters(); if(referenceParameters != null){ axisEndpoint.addParameter(AddressingConstants.REFERENCE_PARAMETER_PARAMETER, new ArrayList(referenceParameters.values())); } for (OMElement extensibleElement : epr.getExtensibleElements()) { if (AddressingConstants.QNAME_IDENTITY.equals(extensibleElement.getQName())) { axisEndpoint.addParameter(AddressingConstants.ADDRESSING_IDENTITY_PARAMETER, extensibleElement.cloneOMElement()); break; } } } catch (Exception e) { if(log.isDebugEnabled()){ log.debug("Exception encountered processing embedded wsa:EndpointReference", e); } } } } }
public String deleteMsgBox(EndpointReference msgBoxEpr, long timeout) throws MsgBrokerClientException { String msgBoxEventSink = msgBoxEpr.getAddress(); String formattedEventSink = null; if (msgBoxEpr.getAddress().contains("clientid")) { formattedEventSink = msgBoxEventSink; } else { if (msgBoxEpr.getAllReferenceParameters() == null) throw new MsgBrokerClientException("Invalid Message Box EPR, no reference parameters found"); String msgBoxId = msgBoxEpr.getAllReferenceParameters().get(MsgBoxQNameConstants.MSG_BOXID_QNAME).getText(); if (msgBoxId == null) throw new MsgBrokerClientException( "Invalid Message Box EPR, reference parameter MsgBoxAddress is missing"); String format = msgBoxEventSink.endsWith("/") ? "%sclientid/%s" : "%s/clientid/%s"; formattedEventSink = String.format(format, msgBoxEventSink, msgBoxId); } if (this.msgBoxUser == null) { this.msgBoxUser = new MsgBoxClient(); } String resp = null; try { resp = msgBoxUser.deleteMsgBox(msgBoxEpr, timeout); } catch (RemoteException e) { throw new MsgBrokerClientException("unable to delete the msg box", e); } return resp; }
private void processEmbeddedEPR(List extensibilityElements, AxisEndpoint axisEndpoint) { Iterator eelts = extensibilityElements.iterator(); while(eelts.hasNext()){ ExtensibilityElement ee = (ExtensibilityElement)eelts.next(); if(AddressingConstants.Final.WSA_ENDPOINT_REFERENCE.equals(ee.getElementType())){ try { Element elt = ((UnknownExtensibilityElement)ee).getElement(); OMElement eprOMElement = XMLUtils.toOM(elt); EndpointReference epr = EndpointReferenceHelper.fromOM(eprOMElement); Map referenceParameters = epr.getAllReferenceParameters(); if(referenceParameters != null){ axisEndpoint.addParameter(AddressingConstants.REFERENCE_PARAMETER_PARAMETER, new ArrayList(referenceParameters.values())); } for (OMElement extensibleElement : epr.getExtensibleElements()) { if (AddressingConstants.QNAME_IDENTITY.equals(extensibleElement.getQName())) { axisEndpoint.addParameter(AddressingConstants.ADDRESSING_IDENTITY_PARAMETER, extensibleElement.cloneOMElement()); break; } } } catch (Exception e) { if(log.isDebugEnabled()){ log.debug("Exception encountered processing embedded wsa:EndpointReference", e); } } } } }
public Subscription startListeningToPreviousMessageBox(EndpointReference msgBoxAddr, String subscriptionId, String topic, String xpath, Callback callback, boolean subscribePermanatly) throws MsgBrokerClientException { this.callback = callback; this.subscriptionId = subscriptionId; this.topic = topic; WseMsgBrokerClient wseClient = new WseMsgBrokerClient(); MsgboxHandler msgboxHandler = new MsgboxHandler(); messagePuller = msgboxHandler.startPullingFromExistingMsgBox(msgBoxAddr, this, 500L, 1000L); if (logger.isDebugEnabled()) logger.debug("\n\nCreate Subscription for topic" + topic + " [Messagebox]\n\n"); String msgBoxEventSink = msgBoxAddr.getAddress(); String formattedEventSink = null; if (msgBoxEventSink.contains("clientid")) { formattedEventSink = msgBoxEventSink; } else { if (msgBoxAddr.getAllReferenceParameters() == null) throw new MsgBrokerClientException("Invalid Message Box EPR, no reference parameters found"); String msgBoxId = msgBoxAddr.getAllReferenceParameters().get(MsgBoxQNameConstants.MSG_BOXID_QNAME) .getText(); if (msgBoxId == null) throw new MsgBrokerClientException("Invalid Message Box EPR, reference parameter MsgBoxAddr is missing"); String format = msgBoxEventSink.endsWith("/") ? "%sclientid/%s" : "%s/clientid/%s"; formattedEventSink = String.format(format, msgBoxEventSink, msgBoxId); } subscriptionId = subscribeToBroker(formattedEventSink, topic, xpath, wseClient, subscribePermanatly); Subscription subscription = new Subscription(this, subscriptionId, topic, callback, this.brokerURL); subscription.setMessageBoxEpr(msgBoxAddr); return subscription; }
protected void addReferenceParameters(MessageContext msgctx) { EndpointReference to = msgctx.getTo(); if (options.isManageSession() || (options.getParent() != null && options.getParent().isManageSession())) { EndpointReference tepr = sc.getTargetEPR(); if (tepr != null) { Map<QName, OMElement> map = tepr.getAllReferenceParameters(); if (map != null) { Iterator<OMElement> valuse = map.values().iterator(); while (valuse.hasNext()) { Object refparaelement = valuse.next(); if (refparaelement instanceof OMElement) { to.addReferenceParameter((OMElement) refparaelement); } } } } } }
protected void addReferenceParameters(MessageContext msgctx) { EndpointReference to = msgctx.getTo(); if (options.isManageSession() || (options.getParent() != null && options.getParent().isManageSession())) { EndpointReference tepr = sc.getTargetEPR(); if (tepr != null) { Map<QName, OMElement> map = tepr.getAllReferenceParameters(); if (map != null) { Iterator<OMElement> valuse = map.values().iterator(); while (valuse.hasNext()) { Object refparaelement = valuse.next(); if (refparaelement instanceof OMElement) { to.addReferenceParameter((OMElement) refparaelement); } } } } } }
private void processToEPR() throws AxisFault { EndpointReference epr = messageContextOptions.getTo(); if (epr != null && !isAddressingHeaderAlreadyAvailable(WSA_TO, false)) { try { processToEPRReferenceInformation(epr.getAllReferenceParameters()); } catch (Exception e) { throw new AxisFault(AddressingMessages.getMessage("referenceParameterError"), e); } String address = epr.getAddress(); if (address != null && address.length()!=0) { if (!includeOptionalHeaders && isFinalAddressingNamespace && epr.isWSAddressingAnonymous()) { return; //Omit the header. } createSOAPHeaderBlock(address, WSA_TO, epr.getAddressAttributes()); } } }