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.marshaller.PrismMarshaller.java
private QName createReferenceQName(QName qname, String namespace) { if (namespace != null) { return new QName(namespace, qname.getLocalPart()); } else {/* w ww . j a v a 2s . c om*/ return qname; } }
From source file:com.evolveum.midpoint.util.DOMUtil.java
public static Element getOrCreateAsFirstElement(Element parentElement, QName elementQName) { Element element = getChildElement(parentElement, elementQName); if (element != null) { return element; }/* w w w . ja v a 2 s.c o m*/ Document doc = parentElement.getOwnerDocument(); element = doc.createElementNS(elementQName.getNamespaceURI(), elementQName.getLocalPart()); parentElement.insertBefore(element, getFirstChildElement(parentElement)); return element; }
From source file:com.twinsoft.convertigo.engine.util.WsReference.java
private static HttpConnector importSoapWebService(Project project, WebServiceReference soapServiceReference) throws Exception { List<HttpConnector> connectors = new ArrayList<HttpConnector>(); HttpConnector firstConnector = null; String wsdlUrl = soapServiceReference.getUrlpath(); WsdlProject wsdlProject = new WsdlProject(); WsdlInterface[] wsdls = WsdlImporter.importWsdl(wsdlProject, wsdlUrl); int len = wsdls.length; if (len > 0) { WsdlInterface iface = wsdls[len - 1]; if (iface != null) { // Retrieve definition name or first service name String definitionName = null; try { Definition definition = iface.getWsdlContext().getDefinition(); QName qname = definition.getQName(); qname = (qname == null ? (QName) definition.getAllServices().keySet().iterator().next() : qname);//from w ww . j av a2s. c o m definitionName = qname.getLocalPart(); } catch (Exception e1) { throw new Exception("No service found !"); } // Modify reference's name if (soapServiceReference.bNew) { // Note : new reference may have already been added to the project (new object wizard) // its name must be replaced with a non existing one ! String newDatabaseObjectName = project.getChildBeanName(project.getReferenceList(), StringUtils.normalize("Import_WS_" + definitionName), true); soapServiceReference.setName(newDatabaseObjectName); } // Retrieve directory for WSDLs to download File exportDir = null; /* For further use... if (!webServiceReference.getFilepath().isEmpty()) { // for update case try { exportDir = webServiceReference.getFile().getParentFile(); if (exportDir.exists()) { File destDir = exportDir; for (int index = 0; destDir.exists(); index++) { destDir = new File(exportDir.getPath()+ "/v" + index); } Collection<File> files = GenericUtils.cast(FileUtils.listFiles(exportDir, null, false)); for (File file: files) { FileUtils.copyFileToDirectory(file, destDir); } } } catch (Exception ex) {} }*/ if (soapServiceReference.bNew || exportDir == null) { // for other cases String projectDir = Engine.PROJECTS_PATH + "/" + project.getName(); exportDir = new File(projectDir + "/wsdl/" + definitionName); for (int index = 1; exportDir.exists(); index++) { exportDir = new File(projectDir + "/wsdl/" + definitionName + index); } } // Download all needed WSDLs (main one and imported/included ones) String wsdlPath = iface.getWsdlContext().export(exportDir.getPath()); // Modify reference's filePath : path to local main WSDL String wsdlUriPath = new File(wsdlPath).toURI().getPath(); String wsdlLocalPath = ".//" + wsdlUriPath.substring(wsdlUriPath.indexOf("/wsdl") + 1); soapServiceReference.setFilepath(wsdlLocalPath); soapServiceReference.hasChanged = true; // Add reference to project if (soapServiceReference.getParent() == null) { project.add(soapServiceReference); } // create an HTTP connector for each binding if (soapServiceReference.bNew) { for (int i = 0; i < wsdls.length; i++) { iface = wsdls[i]; if (iface != null) { Definition definition = iface.getWsdlContext().getDefinition(); XmlSchemaCollection xmlSchemaCollection = WSDLUtils.readSchemas(definition); XmlSchema xmlSchema = xmlSchemaCollection .schemaForNamespace(definition.getTargetNamespace()); HttpConnector httpConnector = createSoapConnector(iface); if (httpConnector != null) { String bindingName = iface.getBindingName().getLocalPart(); String newDatabaseObjectName = project.getChildBeanName(project.getConnectorsList(), StringUtils.normalize(bindingName), true); httpConnector.setName(newDatabaseObjectName); boolean hasDefaultTransaction = false; for (int j = 0; j < iface.getOperationCount(); j++) { WsdlOperation wsdlOperation = (WsdlOperation) iface.getOperationAt(j); XmlHttpTransaction xmlHttpTransaction = createSoapTransaction(xmlSchema, iface, wsdlOperation, project, httpConnector); // Adds transaction if (xmlHttpTransaction != null) { httpConnector.add(xmlHttpTransaction); if (!hasDefaultTransaction) { xmlHttpTransaction.setByDefault(); hasDefaultTransaction = true; } } } connectors.add(httpConnector); } } } // add connector(s) to project for (HttpConnector httpConnector : connectors) { project.add(httpConnector); if (firstConnector == null) { firstConnector = httpConnector; } } } } } else { throw new Exception("No interface found !"); } return firstConnector; }
From source file:org.apache.synapse.mediators.transform.PayloadFactoryMediator.java
private boolean checkAndReplaceEnvelope(OMElement resultElement, MessageContext synCtx) { OMElement firstChild = resultElement.getFirstElement(); QName resultQName = firstChild.getQName(); if (resultQName.getLocalPart().equals("Envelope") && (resultQName.getNamespaceURI().equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI) || resultQName.getNamespaceURI().equals(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI))) { SOAPEnvelope soapEnvelope = AXIOMUtils.getSOAPEnvFromOM(resultElement.getFirstElement()); if (soapEnvelope != null) { try { soapEnvelope.buildWithAttachments(); synCtx.setEnvelope(soapEnvelope); } catch (AxisFault axisFault) { handleException("Unable to attach SOAPEnvelope", axisFault, synCtx); }/*from w w w . ja v a2 s . c om*/ } } else { return false; } return true; }
From source file:gov.nih.nci.cacis.common.util.ExtractSchematron.java
private boolean isFlavor(QName typeName) { return typeName.getLocalPart().contains(".") && !typeName.getLocalPart().startsWith("StrucDoc") || SPECIAL_FLAVOR_TYPES.contains(typeName.getLocalPart()); }
From source file:com.evolveum.midpoint.util.DOMUtil.java
public static Element createElement(Document document, QName qname) { Element element;// www . j a v a2 s . c om // String namespaceURI = qname.getNamespaceURI(); // if (StringUtils.isBlank(namespaceURI)) { // element = document.createElement(qname.getLocalPart()); // } else { element = document.createElementNS(qname.getNamespaceURI(), qname.getLocalPart()); // } if (StringUtils.isNotEmpty(qname.getPrefix()) && StringUtils.isNotEmpty(qname.getNamespaceURI())) { // second part of the condition is because of wrong data in tests (undeclared prefixes in XPath expressions) element.setPrefix(qname.getPrefix()); } return element; }
From source file:com.centeractive.ws.builder.soap.XmlUtils.java
public static Document createDocument(QName element) { ensureDocumentBuilder();// w ww .jav a 2 s. c om Document document = documentBuilder.newDocument(); document.appendChild(document.createElementNS(element.getNamespaceURI(), element.getLocalPart())); return document; }
From source file:com.evolveum.midpoint.web.component.assignment.MetadataPanel.java
private void initLayout() { WebMarkupContainer metadataBlock = new WebMarkupContainer(ID_METADATA_BLOCK); metadataBlock.setOutputMarkupId(true); add(metadataBlock);/*from w w w .j a v a 2 s. co m*/ WebMarkupContainer headerContainer = new WebMarkupContainer(ID_HEADER_CONTAINER); headerContainer.setOutputMarkupId(true); headerContainer.add(new AttributeAppender("class", "prism-header " + additionalHeaderStyle)); metadataBlock.add(headerContainer); Label metadataHeader = new Label(ID_METADATA_LABEL, createStringResource("AssignmentEditorPanel.metadataBlock", header != null ? header : "")); metadataHeader.setOutputMarkupId(true); headerContainer.add(metadataHeader); RepeatingView metadataRowRepeater = new RepeatingView(ID_METADATA_ROW); metadataBlock.add(metadataRowRepeater); for (QName qname : metadataFieldsList) { WebMarkupContainer metadataRow = new WebMarkupContainer(metadataRowRepeater.newChildId()); metadataRow.setOutputMarkupId(true); if (metadataFieldsList.indexOf(qname) % 2 != 0) { metadataRow.add(new AttributeAppender("class", "stripe")); } metadataRowRepeater.add(metadataRow); metadataRow.add( new Label(ID_METADATA_PROPERTY_KEY, createStringResource(DOT_CLASS + qname.getLocalPart()))); AbstractReadOnlyModel<String> metadataFieldModel = new AbstractReadOnlyModel<String>() { @Override public String getObject() { PropertyModel<Object> tempModel = new PropertyModel<>(getModel(), qname.getLocalPart()); if (tempModel.getObject() instanceof XMLGregorianCalendar) { return WebComponentUtil.getLocalizedDate((XMLGregorianCalendar) tempModel.getObject(), DateLabelComponent.MEDIUM_MEDIUM_STYLE); } else if (tempModel.getObject() instanceof ObjectReferenceType) { ObjectReferenceType ref = (ObjectReferenceType) tempModel.getObject(); return WebComponentUtil.getName(ref, getPageBase(), OPERATION_LOAD_USER); } else if (tempModel.getObject() instanceof List) { List list = (List) tempModel.getObject(); String result = ""; for (Object o : list) { if (o instanceof ObjectReferenceType) { if (result.length() > 0) { result += ", "; } result += WebComponentUtil.getName((ObjectReferenceType) o, getPageBase(), OPERATION_LOAD_USER); } } return result; } return ""; } }; metadataRow.add(new Label(ID_METADATA_FILED, metadataFieldModel)); metadataRow.add(new VisibleEnableBehaviour() { @Override public boolean isVisible() { return StringUtils.isNotEmpty(metadataFieldModel.getObject()); } }); } }
From source file:edu.jhu.hlt.concrete.ingesters.bolt.BoltForumPostIngester.java
@Override public Communication fromCharacterBasedFile(final Path path) throws IngestException { if (!Files.exists(path)) throw new IngestException("No file at: " + path.toString()); AnalyticUUIDGeneratorFactory f = new AnalyticUUIDGeneratorFactory(); AnalyticUUIDGenerator gen = f.create(); Communication c = new Communication(); c.setUuid(gen.next());/* w w w .j av a 2 s .c o m*/ c.setType(this.getKind()); c.setMetadata(TooledMetadataConverter.convert(this)); try { ExistingNonDirectoryFile ef = new ExistingNonDirectoryFile(path); c.setId(ef.getName().split("\\.")[0]); } catch (NoSuchFileException | NotFileException e) { // might throw if path is a directory. throw new IngestException(path.toString() + " is not a file, or is a directory."); } String content; try (InputStream is = Files.newInputStream(path); BufferedInputStream bin = new BufferedInputStream(is, 1024 * 8 * 8);) { content = IOUtils.toString(bin, StandardCharsets.UTF_8); c.setText(content); } catch (IOException e) { throw new IngestException(e); } try (InputStream is = Files.newInputStream(path); BufferedInputStream bin = new BufferedInputStream(is, 1024 * 8 * 8); BufferedReader reader = new BufferedReader(new InputStreamReader(bin, StandardCharsets.UTF_8));) { XMLEventReader rdr = null; try { rdr = inF.createXMLEventReader(reader); // Below method moves the reader // to the first post element. Section headline = handleHeadline(rdr, content); headline.setUuid(gen.next()); c.addToSectionList(headline); int start = headline.getTextSpan().getStart(); int ending = headline.getTextSpan().getEnding(); if (ending < start) ending = start; // @tongfei: handle empty headlines String htxt = c.getText().substring(start, ending); LOGGER.debug("headline text: {}", htxt); // Section indices. int sectNumber = 1; int subSect = 0; // Move iterator to post start element. this.iterateToPosts(rdr); // Offset pointer. int currOff = -1; SectionFactory sf = new SectionFactory(gen); // First post element. while (rdr.hasNext()) { XMLEvent nextEvent = rdr.nextEvent(); currOff = nextEvent.getLocation().getCharacterOffset(); if (currOff > 0) { int currOffPlus = currOff + 20; int currOffLess = currOff - 20; LOGGER.debug("Offset: {}", currOff); if (currOffPlus < content.length()) LOGGER.debug("Surrounding text: {}", content.substring(currOffLess, currOffPlus)); } // First: see if document is going to end. // If yes: exit. if (nextEvent.isEndDocument()) break; // XMLEvent peeker = rdr.peek(); // Check if start element. if (nextEvent.isStartElement()) { StartElement se = nextEvent.asStartElement(); QName name = se.getName(); final String localName = name.getLocalPart(); LOGGER.debug("Hit start element: {}", localName); //region // Add sections for authors and datetimes for each bolt post // by Tongfei Chen Attribute attrAuthor = se.getAttributeByName(QName.valueOf("author")); Attribute attrDateTime = se.getAttributeByName(QName.valueOf("datetime")); if (attrAuthor != null && attrDateTime != null) { int loc = attrAuthor.getLocation().getCharacterOffset(); int sectAuthorBeginningOffset = loc + "<post author=\"".length(); Section sectAuthor = sf.fromTextSpan(new TextSpan(sectAuthorBeginningOffset, sectAuthorBeginningOffset + attrAuthor.getValue().length()), "author"); c.addToSectionList(sectAuthor); int sectDateTimeBeginningOffset = sectAuthorBeginningOffset + attrAuthor.getValue().length() + " datetime=".length(); Section sectDateTime = sf.fromTextSpan( new TextSpan(sectDateTimeBeginningOffset, sectDateTimeBeginningOffset + attrDateTime.getValue().length()), "datetime"); c.addToSectionList(sectDateTime); } //endregion // Move past quotes, images, and links. if (localName.equals(QUOTE_LOCAL_NAME)) { this.handleQuote(rdr); } else if (localName.equals(IMG_LOCAL_NAME)) { this.handleImg(rdr); } else if (localName.equals(LINK_LOCAL_NAME)) { this.handleLink(rdr); } // not a start element } else if (nextEvent.isCharacters()) { Characters chars = nextEvent.asCharacters(); int coff = chars.getLocation().getCharacterOffset(); if (!chars.isWhiteSpace()) { // content to be captured String fpContent = chars.getData(); LOGGER.debug("Character offset: {}", coff); LOGGER.debug("Character based data: {}", fpContent); // LOGGER.debug("Character data via offset diff: {}", content.substring(coff - fpContent.length(), coff)); SimpleImmutableEntry<Integer, Integer> pads = trimSpacing(fpContent); final int tsb = currOff + pads.getKey(); final int tse = currOff + fpContent.length() - pads.getValue(); final String subs = content.substring(tsb, tse); if (subs.replaceAll("\\p{Zs}", "").replaceAll("\\n", "").isEmpty()) { LOGGER.info("Found empty section: skipping."); continue; } LOGGER.debug("Section text: {}", subs); TextSpan ts = new TextSpan(tsb, tse); Section s = sf.fromTextSpan(ts, "post"); List<Integer> intList = new ArrayList<>(); intList.add(sectNumber); intList.add(subSect); s.setNumberList(intList); c.addToSectionList(s); subSect++; } } else if (nextEvent.isEndElement()) { EndElement ee = nextEvent.asEndElement(); currOff = ee.getLocation().getCharacterOffset(); QName name = ee.getName(); String localName = name.getLocalPart(); LOGGER.debug("Hit end element: {}", localName); if (localName.equalsIgnoreCase(POST_LOCAL_NAME)) { sectNumber++; subSect = 0; } } } return c; } catch (XMLStreamException | ConcreteException | StringIndexOutOfBoundsException x) { throw new IngestException(x); } finally { if (rdr != null) try { rdr.close(); } catch (XMLStreamException e) { // not likely. LOGGER.info("Error closing XMLReader.", e); } } } catch (IOException e) { throw new IngestException(e); } }
From source file:fi.laverca.ws.MSS_SignatureServiceLocator.java
/** * For the given interface, get the stub implementation. * If this service has no port for the given interface, * then ServiceException is thrown./* w ww . j a v a 2 s .c om*/ * @param portName Name of the port * @param serviceEndpointInterface Interface class reference */ @Override public Remote getPort(QName portName, Class serviceEndpointInterface) throws ServiceException { if (portName == null) { return getPort(serviceEndpointInterface); } String inputPortName = portName.getLocalPart(); if ("MSS_SignaturePort".equals(inputPortName)) { return getMSS_SignaturePort(); } else if ("MSS_StatusQueryPort".equals(inputPortName)) { return getMSS_StatusQueryPort(); } else if ("MSS_ReceiptPort".equals(inputPortName)) { return getMSS_ReceiptPort(); } else if ("MSS_NotificationPort".equals(inputPortName)) { return getMSS_NotificationPort(); } else if ("MSS_RegistrationPort".equals(inputPortName)) { return getMSS_RegistrationPort(); } else if ("MSS_ProfileQueryPort".equals(inputPortName)) { return getMSS_ProfileQueryPort(); } else if ("MSS_HandshakePort".equals(inputPortName)) { return getMSS_HandshakePort(); } else { Remote _stub = getPort(serviceEndpointInterface); ((Stub) _stub).setPortName(portName); return _stub; } }