List of usage examples for javax.xml.namespace QName getLocalPart
public String getLocalPart()
Get the local part of this QName
.
From source file:com.evolveum.midpoint.prism.util.JaxbTestUtil.java
public <T> Element marshalObjectToDom(T jaxbObject, QName elementQName, Document doc) throws JAXBException { if (doc == null) { doc = DOMUtil.getDocument();// www . j a v a2 s . c o m } JAXBElement<T> jaxbElement = new JAXBElement<T>(elementQName, (Class<T>) jaxbObject.getClass(), jaxbObject); Element element = doc.createElementNS(elementQName.getNamespaceURI(), elementQName.getLocalPart()); marshalElementToDom(jaxbElement, element); return (Element) element.getFirstChild(); }
From source file:com.evolveum.midpoint.web.page.admin.configuration.PageDebugList.java
private void deleteAllTypeConfirmed(AjaxRequestTarget target) { DebugSearchDto dto = searchModel.getObject(); LOGGER.debug("Deleting all of type {}", dto.getType()); OperationResult result = new OperationResult(OPERATION_DELETE_OBJECTS); try {/*from www .j a v a2 s . c o m*/ ObjectQuery query = null; if (ObjectTypes.USER.equals(dto.getType())) { query = createDeleteAllUsersQuery(); } QName type = dto.getType().getTypeQName(); deleteObjectsAsync(type, query, true, "Delete all of type " + type.getLocalPart(), result); info(getString("pageDebugList.messsage.deleteAllOfType", dto.getType())); } catch (Exception ex) { result.recomputeStatus(); result.recordFatalError("Couldn't delete objects of type " + dto.getType(), ex); LoggingUtils.logException(LOGGER, "Couldn't delete objects of type " + dto.getType(), ex); } showResult(result); target.add(getFeedbackPanel()); }
From source file:org.apache.servicemix.jbi.cluster.engine.ClusterEngine.java
/** * Process a JMS message//from w ww. ja v a 2 s . co m * * @param requestor the item to use * @throws JMSException if an error occur */ protected void process(JmsRequestor requestor) throws JMSException { javax.jms.Message message = requestor.getMessage(); int type = message.getIntProperty(JBI_MESSAGE); switch (type) { case JBI_MESSAGE_DONE: { String corrId = message.getStringProperty(PROPERTY_CORR_ID); if (corrId == null) { throw new IllegalStateException("Incoming JMS message has no correlationId"); } Exchange exchange = exchanges.remove(corrId); if (exchange == null) { throw new IllegalStateException("Exchange not found for id " + corrId); } done(exchange); break; } case JBI_MESSAGE_ERROR: { String corrId = message.getStringProperty(PROPERTY_CORR_ID); if (corrId == null) { throw new IllegalStateException("Incoming JMS message has no correlationId"); } Exchange exchange = exchanges.remove(corrId); if (exchange == null) { throw new IllegalStateException("Exchange not found for id " + corrId); } fail(exchange, (Exception) ((ObjectMessage) message).getObject()); break; } case JBI_MESSAGE_IN: { String mep = message.getStringProperty(JBI_MEP); if (mep == null) { throw new IllegalStateException( "Exchange MEP not found for JMS message " + message.getJMSMessageID()); } Exchange exchange = getChannel().createExchange(Pattern.fromWsdlUri(mep)); exchange.setProperty(PROPERTY_ROLLBACK_ON_ERRORS + "." + name, message.getBooleanProperty(PROPERTY_ROLLBACK_ON_ERRORS)); if (message.propertyExists(JBI_INTERFACE)) { exchange.setProperty(MessageExchangeImpl.INTERFACE_NAME_PROP, QName.valueOf(message.getStringProperty(JBI_INTERFACE))); } if (message.propertyExists(JBI_OPERATION)) { exchange.setOperation(QName.valueOf(message.getStringProperty(JBI_OPERATION))); } if (message.propertyExists(JBI_SERVICE)) { exchange.setProperty(MessageExchangeImpl.SERVICE_NAME_PROP, QName.valueOf(message.getStringProperty(JBI_SERVICE))); } if (message.propertyExists(JBI_ENDPOINT)) { QName q = QName.valueOf(message.getStringProperty(JBI_ENDPOINT)); String e = q.getLocalPart(); q = QName.valueOf(q.getNamespaceURI()); ServiceEndpoint se = getEndpoint(q, e); // TODO: check that endpoint exists exchange.setProperty(MessageExchangeImpl.SERVICE_ENDPOINT_PROP, se); } // Re-process JBI addressing DeliveryChannelImpl.createTarget(getChannel().getNMR(), exchange); // TODO: read exchange properties Message msg = (Message) ((ObjectMessage) message).getObject(); exchange.setIn(msg); exchanges.put(exchange.getId(), exchange); if (pendingExchanges.incrementAndGet() >= maxPendingExchanges) { if (pauseConsumption.compareAndSet(false, true)) { invalidateSelector(); } } exchange.setProperty(PROPERTY_CORR_ID + "." + name, exchange.getId()); requestor.suspend(exchange.getId()); if (requestor.getTransaction() != null) { exchange.setProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME, requestor.getTransaction()); } send(exchange); break; } case JBI_MESSAGE_OUT: { String corrId = message.getStringProperty(PROPERTY_CORR_ID); if (corrId == null) { throw new IllegalStateException("Incoming JMS message has no correlationId"); } Exchange exchange = exchanges.get(corrId); if (exchange == null) { throw new IllegalStateException("Exchange not found for id " + corrId); } Message msg = (Message) ((ObjectMessage) message).getObject(); exchange.setOut(msg); exchanges.put(exchange.getId(), exchange); exchange.setProperty(PROPERTY_CORR_ID + "." + name, exchange.getId()); requestor.suspend(exchange.getId()); if (requestor.getTransaction() != null) { exchange.setProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME, requestor.getTransaction()); } send(exchange); break; } case JBI_MESSAGE_FAULT: { String corrId = message.getStringProperty(PROPERTY_CORR_ID); if (corrId == null) { throw new IllegalStateException("Incoming JMS message has no correlationId"); } Exchange exchange = exchanges.get(corrId); if (exchange == null) { throw new IllegalStateException("Exchange not found for id " + corrId); } Message msg = (Message) ((ObjectMessage) message).getObject(); exchange.setFault(msg); exchanges.put(exchange.getId(), exchange); exchange.setProperty(PROPERTY_CORR_ID + "." + name, exchange.getId()); requestor.suspend(exchange.getId()); if (requestor.getTransaction() != null) { exchange.setProperty(MessageExchange.JTA_TRANSACTION_PROPERTY_NAME, requestor.getTransaction()); } send(exchange); break; } default: { throw new IllegalStateException("Received unknown message type: " + type); } } }
From source file:org.eclipse.winery.repository.client.WineryRepositoryClient.java
/** * {@inheritDoc}//from w ww.j a v a 2s .c o m * * Does NOT check for global QName uniqueness, only in the scope of all * artifact templates */ @Override public void createArtifactTemplate(QName qname, QName artifactType) throws QNameAlreadyExistsException { WebResource artifactTemplates = this.primaryWebResource.path("artifacttemplates"); MultivaluedMap<String, String> map = new MultivaluedMapImpl(); map.putSingle("namespace", qname.getNamespaceURI()); map.putSingle("name", qname.getLocalPart()); map.putSingle("type", artifactType.toString()); ClientResponse response = artifactTemplates.type(MediaType.APPLICATION_FORM_URLENCODED) .accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, map); if (response.getClientResponseStatus() != ClientResponse.Status.CREATED) { // TODO: pass ClientResponse.Status somehow // TODO: more fine grained checking for error message. Not all // failures are that the QName already exists LOGGER.debug(String.format("Error %d when creating id %s from URI %s", response.getStatus(), qname.toString(), this.primaryWebResource.getURI().toString())); throw new QNameAlreadyExistsException(); } // no further return is made }
From source file:microsoft.exchange.webservices.data.core.EwsXmlReader.java
/** * Determines whether current element is a start element. * * @param namespacePrefix the namespace prefix * @param localName the local name * @return boolean//from ww w .j av a 2s . c o m */ public boolean isStartElement(String namespacePrefix, String localName) { boolean isStart = false; if (this.presentEvent.isStartElement()) { StartElement startElement = this.presentEvent.asStartElement(); QName qName = startElement.getName(); isStart = qName.getLocalPart().equals(localName) && qName.getPrefix().equals(namespacePrefix); } return isStart; }
From source file:microsoft.exchange.webservices.data.core.EwsXmlReader.java
/** * Determines whether current element is a end element. * * @param namespacePrefix the namespace prefix * @param localName the local name * @return boolean//from w ww . jav a 2 s. co m */ public boolean isEndElement(String namespacePrefix, String localName) { boolean isEndElement = false; if (this.presentEvent.isEndElement()) { EndElement endElement = this.presentEvent.asEndElement(); QName qName = endElement.getName(); isEndElement = qName.getLocalPart().equals(localName) && qName.getPrefix().equals(namespacePrefix); } return isEndElement; }
From source file:microsoft.exchange.webservices.data.core.EwsXmlReader.java
/** * Determines whether current element is a end element. * * @param xmlNamespace the xml namespace * @param localName the local name/* w ww. j av a 2s. c om*/ * @return boolean */ public boolean isEndElement(XmlNamespace xmlNamespace, String localName) { boolean isEndElement = false; /* * if(localName.equals("Body")) { return true; } else */ if (this.presentEvent.isEndElement()) { EndElement endElement = this.presentEvent.asEndElement(); QName qName = endElement.getName(); isEndElement = qName.getLocalPart().equals(localName) && (qName.getPrefix().equals(EwsUtilities.getNamespacePrefix(xmlNamespace)) || qName.getNamespaceURI().equals(EwsUtilities.getNamespaceUri(xmlNamespace))); } return isEndElement; }
From source file:microsoft.exchange.webservices.data.core.EwsXmlReader.java
public boolean readToDescendant(String localName, String namespaceURI) throws XMLStreamException { if (!this.isStartElement()) { return false; }// w w w . ja va2 s .c o m XMLEvent startEvent = this.presentEvent; XMLEvent event = this.presentEvent; do { if (event.isStartElement()) { QName qEName = event.asStartElement().getName(); if (qEName.getLocalPart().equals(localName) && qEName.getNamespaceURI().equals(namespaceURI)) { return true; } } event = this.xmlReader.nextEvent(); } while (!checkEndElement(startEvent, event)); return false; }
From source file:com.collabnet.ccf.teamforge.TFTrackerHandler.java
/** * Creates an artifact.//from ww w. ja v a 2 s .c o m * * @throws RemoteException * when an error is encountered in creating the artifact. * @return Newly created artifact * @throws PlanningFolderRuleViolationException */ public ArtifactDO createArtifact(Connection connection, String trackerId, String description, String category, String group, String status, String statusClass, String customer, int priority, int estimatedEfforts, int actualEfforts, Date closeDate, String assignedTo, String reportedReleaseId, String resolvedReleaseId, List<String> flexFieldNames, List<Object> flexFieldValues, List<String> flexFieldTypes, String title, String[] comments, int remainingEfforts, boolean autosumming, String planningFolderId, int points) throws RemoteException, PlanningFolderRuleViolationException { FieldValues flexFields = new FieldValues(); flexFields.setNames(flexFieldNames.toArray(new String[0])); flexFields.setValues(flexFieldValues.toArray()); flexFields.setTypes(flexFieldTypes.toArray(new String[0])); String teamId = null; boolean autosummingPoints = false; ArtifactDO artifactData = connection.getTrackerClient().createArtifact(trackerId, title, description, group, category, // category status, // status customer, // customer priority, // priority autosumming ? 0 : estimatedEfforts, // estimated efforts autosumming ? 0 : remainingEfforts, // remaining efforts autosumming, points, // story points autosummingPoints, assignedTo, // assigned user name teamId, reportedReleaseId, planningFolderId, flexFields, null, null, null); if (!autosumming) { artifactData.setActualEffort(actualEfforts); } artifactData.setStatusClass(statusClass); artifactData.setCloseDate(closeDate); artifactData.setResolvedReleaseId(resolvedReleaseId); FieldValues newFlexFields = new FieldValues(); newFlexFields.setNames(flexFieldNames.toArray(new String[0])); newFlexFields.setValues(flexFieldValues.toArray()); newFlexFields.setTypes(flexFieldTypes.toArray(new String[0])); artifactData.setFlexFields(newFlexFields); boolean initialUpdated = true; while (initialUpdated) { try { initialUpdated = false; connection.getTrackerClient().setArtifactData(artifactData, null, null, null, null); } catch (AxisFault e) { javax.xml.namespace.QName faultCode = e.getFaultCode(); if (!faultCode.getLocalPart().equals("VersionMismatchFault")) { throw e; } logConflictResolutor.warn("Stale initial update, will override in any case ...:", e); artifactData.setVersion(artifactData.getVersion() + 1); initialUpdated = true; } } // we have to increase the version number to add the comments if (comments.length != 0) { artifactData.setVersion(artifactData.getVersion() + 1); } for (String comment : comments) { boolean commentNotUpdated = true; while (commentNotUpdated) { try { commentNotUpdated = false; if (StringUtils.isEmpty(comment)) { continue; } connection.getTrackerClient().setArtifactData(artifactData, comment, null, null, null); // artifactData = mTrackerApp.getArtifactData(sessionId, // artifactData.getId()); artifactData.setVersion(artifactData.getVersion() + 1); } catch (AxisFault e) { javax.xml.namespace.QName faultCode = e.getFaultCode(); if (!faultCode.getLocalPart().equals("VersionMismatchFault")) { throw e; } logConflictResolutor.warn("Stale comment update, trying again ...:", e); artifactData = connection.getTrackerClient().getArtifactData(artifactData.getId()); commentNotUpdated = true; } } } // it looks as if since TF 5.3, not every update call automatically // increases the version number // hence we retrieve the artifact version here again if (comments.length == 0) { // artifactData.setVersion(artifactData.getVersion() + 1); artifactData = connection.getTrackerClient().getArtifactData(artifactData.getId()); } log.info("Artifact created: " + artifactData.getId() + " in " + trackerId); return artifactData; }
From source file:org.eclipse.winery.repository.client.WineryRepositoryClient.java
/** * {@inheritDoc}/* w ww . j a v a 2 s . co m*/ */ @Override public void createComponent(QName qname, Class<? extends TOSCAComponentId> idClass) throws QNameAlreadyExistsException { WebResource resource = this.primaryWebResource.path(Util.getRootPathFragment(idClass)); MultivaluedMap<String, String> map = new MultivaluedMapImpl(); map.putSingle("namespace", qname.getNamespaceURI()); map.putSingle("name", qname.getLocalPart()); ClientResponse response = resource.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.TEXT_PLAIN) .post(ClientResponse.class, map); if (response.getClientResponseStatus() != ClientResponse.Status.CREATED) { // TODO: pass ClientResponse.Status somehow // TODO: more fine grained checking for error message. Not all failures are that the QName already exists LOGGER.debug(String.format("Error %d when creating id %s from URI %s", response.getStatus(), qname.toString(), this.primaryWebResource.getURI().toString())); throw new QNameAlreadyExistsException(); } // no further return is made }