Java Code Examples for org.w3c.dom.Element#getElementsByTagNameNS()
The following examples show how to use
org.w3c.dom.Element#getElementsByTagNameNS() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WebProjectWebServicesSupport.java From netbeans with Apache License 2.0 | 6 votes |
private StubDescriptor getServiceStubDescriptor(org.w3c.dom.Node parentNode) { StubDescriptor result = null; if(parentNode instanceof Element) { Element parentElement = (Element) parentNode; NodeList fromWsdlList = parentElement.getElementsByTagNameNS( WebProjectType.PROJECT_CONFIGURATION_NAMESPACE, WEB_SERVICE_FROM_WSDL); if(fromWsdlList.getLength() == 1) { result = wsdlServiceStub; } else { result = seiServiceStub; } } return result; }
Example 2
Source File: ODataAtomParser.java From odata with Apache License 2.0 | 6 votes |
private void setEntityProperties(Object entity, EntityType entityType, Element entryElement) throws ODataException { LOG.trace("setEntityProperties: entityType={}", entityType); NodeList childNodes = entryElement.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node instanceof Element && node.getNodeName().equals(ODATA_CONTENT)) { Element contentElement = (Element) node; NodeList propertiesElements = contentElement.getElementsByTagNameNS(getODataMetadataNS(), ODATA_PROPERTIES); for (int j = 0; j < propertiesElements.getLength(); j++) { Element propertiesElement = (Element) propertiesElements.item(j); NodeList propertyNodes = propertiesElement.getChildNodes(); for (int k = 0; k < propertyNodes.getLength(); k++) { Node propertyNode = propertyNodes.item(k); if (propertyNode instanceof Element) { setStructProperty(entity, entityType, (Element) propertyNode); } } } } } }
Example 3
Source File: UddiUpdater.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private static String endpoint(Element bindingTemplate) { NodeList accessPoints = bindingTemplate.getElementsByTagNameNS("urn:uddi-org:api_v3", "accessPoint"); for(int j = 0; j < accessPoints.getLength(); ++j) { Element accessPoint = (Element)accessPoints.item(j); if ("endPoint".equals(accessPoint.getAttribute("useType"))) { return accessPoint.getTextContent(); } } return ""; }
Example 4
Source File: STSHelper.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public static String getType(Element element) throws IntegrationModuleException { NodeList attributes = element.getElementsByTagName(SAML_ATTRIBUTE); if (attributes.getLength() == 0) { attributes = element.getElementsByTagNameNS( ASSERTION_URI, SAML_ATTRIBUTE); if (attributes.getLength() == 0) { return null; } } for (int i = 0; i < attributes.getLength(); i++) { Node node = attributes.item(i); String attributeName = node.getAttributes().getNamedItem(SAML_ATTRIBUTE_NAME).getTextContent(); String attributeNamespace = node.getAttributes().getNamedItem(SAML_ATTRIBUTE_NAMESPACE).getTextContent(); // Doctor // if( "urn:be:fgov:person:ssin:ehealth:1.0:doctor:nihii11".equals(attributeName) && // "urn:be:fgov:certified-namespace:ehealth".equals(attributeNamespace)){ // return PharmacyIdType. // // RequestorType.CBE.toString(); // }else // Pharmacist if (PHARMACIST_NIHII_URI.equals(attributeName) && INDENTIFICATION_NAME_SPACE.equals(attributeNamespace)) { return PharmacyIdType.NIHII.toString(); // RequestorType.NIHIIPHARMACY.toString(); } } throw new IntegrationModuleException(I18nHelper.getLabel("error.validation.saml.type.not.found")); }
Example 5
Source File: MetadataFinder.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Identifies WSDL documents from the {@link DOMForest}. Also identifies the root wsdl document. */ private void identifyRootWsdls(){ for(String location: rootDocuments){ Document doc = get(location); if(doc!=null){ Element definition = doc.getDocumentElement(); if(definition == null || definition.getLocalName() == null || definition.getNamespaceURI() == null) continue; if(definition.getNamespaceURI().equals(WSDLConstants.NS_WSDL) && definition.getLocalName().equals("definitions")){ rootWsdls.add(location); //set the root wsdl at this point. Root wsdl is one which has wsdl:service in it NodeList nl = definition.getElementsByTagNameNS(WSDLConstants.NS_WSDL, "service"); //TODO:what if there are more than one wsdl with wsdl:service element. Probably such cases //are rare and we will take any one of them, this logic should still work if(nl.getLength() > 0) rootWSDL = location; } } } //no wsdl with wsdl:service found, throw error if(rootWSDL == null){ StringBuilder strbuf = new StringBuilder(); for(String str : rootWsdls){ strbuf.append(str); strbuf.append('\n'); } errorReceiver.error(null, WsdlMessages.FAILED_NOSERVICE(strbuf.toString())); } }
Example 6
Source File: MetadataFinder.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Identifies WSDL documents from the {@link DOMForest}. Also identifies the root wsdl document. */ private void identifyRootWsdls(){ for(String location: rootDocuments){ Document doc = get(location); if(doc!=null){ Element definition = doc.getDocumentElement(); if(definition == null || definition.getLocalName() == null || definition.getNamespaceURI() == null) continue; if(definition.getNamespaceURI().equals(WSDLConstants.NS_WSDL) && definition.getLocalName().equals("definitions")){ rootWsdls.add(location); //set the root wsdl at this point. Root wsdl is one which has wsdl:service in it NodeList nl = definition.getElementsByTagNameNS(WSDLConstants.NS_WSDL, "service"); //TODO:what if there are more than one wsdl with wsdl:service element. Probably such cases //are rare and we will take any one of them, this logic should still work if(nl.getLength() > 0) rootWSDL = location; } } } //no wsdl with wsdl:service found, throw error if(rootWSDL == null){ StringBuilder strbuf = new StringBuilder(); for(String str : rootWsdls){ strbuf.append(str); strbuf.append('\n'); } errorReceiver.error(null, WsdlMessages.FAILED_NOSERVICE(strbuf.toString())); } }
Example 7
Source File: STSHelper.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public static String getNihii(Element element) throws IntegrationModuleException { NodeList attributes = element.getElementsByTagName("Attribute"); if (attributes.getLength() == 0) { attributes = element.getElementsByTagNameNS("urn:oasis:names:tc:SAML:1.0:assertion", "Attribute"); if (attributes.getLength() == 0) { return null; } } for(int i = 0; i < attributes.getLength(); ++i) { Node node = attributes.item(i); String attributeName = node.getAttributes().getNamedItem("AttributeName").getTextContent(); String attributeNamespace = node.getAttributes().getNamedItem("AttributeNamespace").getTextContent(); if (("urn:be:fgov:person:ssin:ehealth:1.0:doctor:nihii11".equals(attributeName) || "urn:be:fgov:person:ssin:ehealth:1.0:nihii:doctor:nihii11".equals(attributeName)) && verifyNameSpace(attributeNamespace)) { return node.getTextContent().trim(); } if (("urn:be:fgov:person:ssin:ehealth:1.0:nihii:dentist:nihii11".equals(attributeName) || "urn:be:fgov:person:ssin:ehealth:1.0:dentist:nihii11".equals(attributeName)) && verifyNameSpace(attributeNamespace)) { return node.getTextContent().trim(); } if (("urn:be:fgov:person:ssin:ehealth:1.0:nihii:midwife:nihii11".equals(attributeName) || "urn:be:fgov:person:ssin:ehealth:1.0:midwife:nihii11".equals(attributeName)) && verifyNameSpace(attributeNamespace)) { return node.getTextContent().trim(); } if (("urn:be:fgov:person:ssin:ehealth:1.0:nihii:physiotherapist:nihii11".equals(attributeName) || "urn:be:fgov:person:ssin:ehealth:1.0:physiotherapist:nihii11".equals(attributeName)) && verifyNameSpace(attributeNamespace)) { return node.getTextContent().trim(); } if (("urn:be:fgov:person:ssin:ehealth:1.0:nihii:nurse:nihii11".equals(attributeName) || "urn:be:fgov:person:ssin:ehealth:1.0:nurse:nihii11".equals(attributeName)) && verifyNameSpace(attributeNamespace)) { return node.getTextContent().trim(); } if (("urn:be:fgov:ehealth:1.0:pharmacy:nihii-number".equals(attributeName) || "urn:be:fgov:ehealth:1.0:nihii:pharmacy:nihii-number".equals(attributeName)) && verifyNameSpace(attributeNamespace)) { return node.getTextContent().trim(); } } throw new IntegrationModuleException(I18nHelper.getLabel("error.validation.saml.nihii.not.found")); }
Example 8
Source File: LoanApplication.java From learning with Apache License 2.0 | 5 votes |
private static String getElementValue(Element parent, String elementName) { String value = null; NodeList nodes = parent.getElementsByTagNameNS(APP_NS, elementName); if (nodes.getLength() > 0) { value = nodes.item(0).getChildNodes().item(0).getNodeValue(); } return value; }
Example 9
Source File: DOMForest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Parses the given document and add it to the DOM forest. * * @return null if there was a parse error. otherwise non-null. */ private @NotNull Document parse(String systemId, InputSource inputSource, boolean root) throws SAXException, IOException{ Document dom = documentBuilder.newDocument(); systemId = normalizeSystemId(systemId); // put into the map before growing a tree, to // prevent recursive reference from causing infinite loop. core.put(systemId, dom); dom.setDocumentURI(systemId); if (root) rootDocuments.add(systemId); try { XMLReader reader = createReader(dom); InputStream is = null; if(inputSource.getByteStream() == null){ inputSource = entityResolver.resolveEntity(null, systemId); } reader.parse(inputSource); Element doc = dom.getDocumentElement(); if (doc == null) { return null; } NodeList schemas = doc.getElementsByTagNameNS(SchemaConstants.NS_XSD, "schema"); for (int i = 0; i < schemas.getLength(); i++) { inlinedSchemaElements.add((Element) schemas.item(i)); } } catch (ParserConfigurationException e) { errorReceiver.error(e); throw new SAXException(e.getMessage()); } resolvedCache.put(systemId, dom.getDocumentURI()); return dom; }
Example 10
Source File: ODataAtomParser.java From odata with Apache License 2.0 | 5 votes |
private EntityType getEntityType(Element entryElement) throws ODataUnmarshallingException { NodeList elements = entryElement.getElementsByTagNameNS(ATOM_NS, ATOM_CATEGORY); // Note that when a payload has nested inline feed or entries, there are more than one <category> element. In // this case, by iterating in reverse mode, we are sure we pick the right <category> element; this is, the // <category> element that belongs to the main entry and not the ones that belongs to the inline entries. for (int i = elements.getLength() - 1; i >= 0; i--) { Element element = (Element) elements.item(i); String scheme = element.getAttribute(SCHEME); if (scheme != null && scheme.equals(getOdataSchemeNS())) { String entityTypeName = getEntityTerm(element); if (entityTypeName == null) { throw new ODataUnmarshallingException("Found a <category> element, but its term attribute " + "does not correctly specify the entity type: term=\"" + element.getAttribute(TERM) + "\""); } LOG.debug("Found entity type name: {}", entityTypeName); Type type = getEntityDataModel().getType(entityTypeName); if (type == null) { throw new ODataUnmarshallingException("Entity type does not exist in the entity data model: " + entityTypeName); } if (type.getMetaType() != MetaType.ENTITY) { throw new ODataUnmarshallingException("This type exists in the entity data model, but it is " + "not an entity type: " + entityTypeName + "; it is: " + type.getMetaType()); } return (EntityType) type; } else { LOG.debug("Found a <category> element with an unexpected 'scheme' attribute: " + scheme); } } throw new ODataUnmarshallingException("No <category> element found with attribute scheme=\"" + getOdataSchemeNS() + "\" that specifies the entity type."); }
Example 11
Source File: SessionUtil.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
private static NodeList extractAttributes(Element element) { NodeList attributes = element.getElementsByTagName("Attribute"); if (attributes.getLength() == 0) { attributes = element.getElementsByTagNameNS("urn:oasis:names:tc:SAML:1.0:assertion", "Attribute"); if (attributes.getLength() == 0) { return null; } } return attributes; }
Example 12
Source File: AbstractConfigObject.java From thym with Eclipse Public License 1.0 | 5 votes |
/** * Sets the text content for a child of element. If tagName child can not * be found it creates one * * @param element * @param namespace * @param tagName * @param value * @throws IllegalArgumentException if element is null */ protected void setTextContentValueForTag(Element element, String namespace, String tagName, String value) { if ( element == null ) throw new IllegalArgumentException("Element is null"); NodeList nodes = null; if (namespace == null ){ nodes = element.getElementsByTagName(tagName); }else{ nodes = element.getElementsByTagNameNS(namespace, tagName); } Node target = null; if (nodes.getLength() < 1) { target = element.getOwnerDocument().createElementNS(namespace, tagName); element.appendChild(target); } else { target = nodes.item(0); } Node firstChild = target.getFirstChild(); if (firstChild != null) { firstChild.setNodeValue(value); } else { target.appendChild(element.getOwnerDocument().createTextNode(value)); } }
Example 13
Source File: ConnectorXmlUtils.java From freehealth-connector with GNU Affero General Public License v3.0 | 5 votes |
public static Element getFirstElementByTagNameNS(Element node, String namespaceURI, String localName) { NodeList nodeList = node.getElementsByTagNameNS(namespaceURI, localName); if (nodeList.getLength() == 0) { return null; } else { if (nodeList.getLength() > 1) { LOG.debug("{}:{} elements count: ,returning first one", new Object[]{namespaceURI, localName, nodeList.getLength()}); } return (Element)nodeList.item(0); } }
Example 14
Source File: UpdateProjectImpl.java From netbeans with Apache License 2.0 | 4 votes |
public Element getUpdatedSharedConfigurationData() { if (cachedElement == null) { final String ns = EarProjectType.PROJECT_CONFIGURATION_NAMESPACE; //NOI18N Element oldRoot = this.cfg.getConfigurationFragment("data","http://www.netbeans.org/ns/j2ee-earproject/1" ,true); //NOI18N if(oldRoot != null) { Document doc = oldRoot.getOwnerDocument(); Element newRoot = doc.createElementNS(EarProjectType.PROJECT_CONFIGURATION_NAMESPACE,"data"); //NOI18N XMLUtil.copyDocument(oldRoot, newRoot, EarProjectType.PROJECT_CONFIGURATION_NAMESPACE); //update <web-module-/additional/-libraries/> to <j2ee-module-/additional/-libraries/> // NodeList contList = newRoot.getElementsByTagNameNS(ns, "web-module-libraries"); // contList.item(0).setNodeValue(ArchiveProjectProperties.TAG_WEB_MODULE_LIBRARIES); // contList = newRoot.getElementsByTagNameNS(ns, "web-module-additional-libraries"); // contList.item(0).setNodeValue(ArchiveProjectProperties.TAG_WEB_MODULE__ADDITIONAL_LIBRARIES); NodeList libList = newRoot.getElementsByTagNameNS(ns, TAG_LIBRARY); for (int i = 0; i < libList.getLength(); i++) { if (libList.item(i).getNodeType() == Node.ELEMENT_NODE) { Element library = (Element) libList.item(i); Node webFile = library.getElementsByTagNameNS(ns, TAG_FILE).item(0); //remove ${ and } from the beginning and end String webFileText = XMLUtil.findText(webFile); webFileText = webFileText.substring(2, webFileText.length() - 1); if (webFileText.startsWith("libs.")) { String libName = webFileText.substring(5, webFileText.indexOf(".classpath")); //NOI18N @SuppressWarnings("unchecked") List<URL> roots = LibraryManager.getDefault().getLibrary(libName).getContent("classpath"); //NOI18N List<FileObject> files = new ArrayList<FileObject>(); List<FileObject> dirs = new ArrayList<FileObject>(); for (URL rootUrl : roots) { FileObject root = org.openide.filesystems.URLMapper.findFileObject(rootUrl); if ("jar".equals(rootUrl.getProtocol())) { //NOI18N root = FileUtil.getArchiveFile(root); } if (root != null) { if (root.isData()) { files.add(root); } else { dirs.add(root); } } } if (files.size() > 0) { library.setAttribute(ATTR_FILES, "" + files.size()); } if (dirs.size() > 0) { library.setAttribute(ATTR_DIRS, "" + dirs.size()); } } } } cachedElement = newRoot; } } return cachedElement; }
Example 15
Source File: XMLCipher.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * @param element * @return a new EncryptedData * @throws XMLEncryptionException * */ EncryptedData newEncryptedData(Element element) throws XMLEncryptionException { EncryptedData result = null; NodeList dataElements = element.getElementsByTagNameNS( EncryptionConstants.EncryptionSpecNS, EncryptionConstants._TAG_CIPHERDATA); // Need to get the last CipherData found, as earlier ones will // be for elements in the KeyInfo lists Element dataElement = (Element) dataElements.item(dataElements.getLength() - 1); CipherData data = newCipherData(dataElement); result = newEncryptedData(data); result.setId(element.getAttributeNS(null, EncryptionConstants._ATT_ID)); result.setType(element.getAttributeNS(null, EncryptionConstants._ATT_TYPE)); result.setMimeType(element.getAttributeNS(null, EncryptionConstants._ATT_MIMETYPE)); result.setEncoding( element.getAttributeNS(null, Constants._ATT_ENCODING)); Element encryptionMethodElement = (Element) element.getElementsByTagNameNS( EncryptionConstants.EncryptionSpecNS, EncryptionConstants._TAG_ENCRYPTIONMETHOD).item(0); if (null != encryptionMethodElement) { result.setEncryptionMethod(newEncryptionMethod(encryptionMethodElement)); } // BFL 16/7/03 - simple implementation // TODO: Work out how to handle relative URI Element keyInfoElement = (Element) element.getElementsByTagNameNS( Constants.SignatureSpecNS, Constants._TAG_KEYINFO).item(0); if (null != keyInfoElement) { KeyInfo ki = newKeyInfo(keyInfoElement); result.setKeyInfo(ki); } // TODO: Implement Element encryptionPropertiesElement = (Element) element.getElementsByTagNameNS( EncryptionConstants.EncryptionSpecNS, EncryptionConstants._TAG_ENCRYPTIONPROPERTIES).item(0); if (null != encryptionPropertiesElement) { result.setEncryptionProperties( newEncryptionProperties(encryptionPropertiesElement) ); } return result; }
Example 16
Source File: DigSigUtil.java From juddi with Apache License 2.0 | 4 votes |
private boolean verifySignature(Element element, PublicKey validatingKey, AtomicReference<String> OutReadableErrorMessage) { if (OutReadableErrorMessage == null) { OutReadableErrorMessage = new AtomicReference<String>(); } XMLSignatureFactory fac = initXMLSigFactory(); NodeList nl = element.getElementsByTagNameNS(XMLSignature.XMLNS, "Signature"); if (nl.getLength() == 0) { throw new RuntimeException("Cannot find Signature element"); } DOMValidateContext valContext = new DOMValidateContext(validatingKey, nl.item(0)); try { valContext.setProperty("javax.xml.crypto.dsig.cacheReference", Boolean.TRUE); XMLSignature signature = fac.unmarshalXMLSignature(valContext); boolean coreValidity = signature.validate(valContext); // Check core validation status. if (coreValidity == false) { logger.warn("Signature failed core validation"); boolean sv = signature.getSignatureValue().validate(valContext); logger.debug("signature validation status: " + sv); OutReadableErrorMessage.set("signature validation failed: " + sv + "." + OutReadableErrorMessage.get()); // Check the validation status of each Reference. @SuppressWarnings("unchecked") Iterator<Reference> i = signature.getSignedInfo().getReferences().iterator(); //System.out.println("---------------------------------------------"); for (int j = 0; i.hasNext(); j++) { Reference ref = (Reference) i.next(); boolean refValid = ref.validate(valContext); logger.debug(j); logger.debug("ref[" + j + "] validity status: " + refValid); if (!refValid) { OutReadableErrorMessage.set("signature reference " + j + " invalid. " + OutReadableErrorMessage.get()); } logger.debug("Ref type: " + ref.getType() + ", URI: " + ref.getURI()); for (Object xform : ref.getTransforms()) { logger.debug("Transform: " + xform); } String calcDigValStr = digestToString(ref.getCalculatedDigestValue()); String expectedDigValStr = digestToString(ref.getDigestValue()); logger.warn(" Calc Digest: " + calcDigValStr); logger.warn("Expected Digest: " + expectedDigValStr); if (!calcDigValStr.equalsIgnoreCase(expectedDigValStr)) { OutReadableErrorMessage.set("digest mismatch for signature ref " + j + "." + OutReadableErrorMessage.get()); } } } else { logger.info("Signature passed core validation"); } return coreValidity; } catch (Exception e) { OutReadableErrorMessage.set("signature validation failed: " + e.getMessage() + OutReadableErrorMessage.get()); logger.fatal(e); return false; } }
Example 17
Source File: Suite.java From teamengine with Apache License 2.0 | 4 votes |
public Suite(Element suiteElement) { String name = suiteElement.getAttribute("name"); this.version = suiteElement.getAttribute("version"); int colon = name.indexOf(":"); prefix = name.substring(0, colon); localName = name.substring(colon + 1); namespaceUri = suiteElement.lookupNamespaceURI(prefix); NodeList titleElements = suiteElement.getElementsByTagNameNS( Test.CTL_NS, "title"); title = ((Element) titleElements.item(0)).getTextContent(); NodeList descElements = suiteElement.getElementsByTagNameNS( Test.CTL_NS, "description"); if (descElements.getLength() > 0) { description = ((Element) descElements.item(0)).getTextContent(); } else { description = null; } NodeList linkElements = suiteElement.getElementsByTagNameNS( Test.CTL_NS, "link"); for (int i = 0; i < linkElements.getLength(); i++) { Element linkElem = (Element) linkElements.item(i); String linkText = linkElem.getTextContent(); if (linkText.startsWith("data")) { this.dataLink = linkText; } else { this.link = linkText; } } NodeList startingTestElements = suiteElement.getElementsByTagNameNS( Test.CTL_NS, "starting-test"); name = ((Element) startingTestElements.item(0)).getTextContent(); colon = name.indexOf(":"); startingTestPrefix = name.substring(0, colon); startingTestLocalName = name.substring(colon + 1); startingTestNamespaceUri = suiteElement .lookupNamespaceURI(startingTestPrefix); }
Example 18
Source File: AlbumsPluginImpl.java From socialauth with MIT License | 4 votes |
private List<Photo> getAlbumPhotos(final String id) throws Exception { Response response = providerSupport.api(PHOTOS_URL + id, MethodType.GET.toString(), null, null, null); LOG.info("Getting Photos of Album :: " + id); Element root; try { root = XMLParseUtil.loadXmlResource(response.getInputStream()); } catch (Exception e) { throw new ServerDataException( "Failed to parse the photos from response." + PHOTOS_URL + id, e); } List<Photo> photos = new ArrayList<Photo>(); if (root != null) { NodeList photoList = root.getElementsByTagName("entry"); if (photoList != null && photoList.getLength() > 0) { LOG.info("Found photos : " + photoList.getLength()); for (int i = 0; i < photoList.getLength(); i++) { Photo photo = new Photo(); Element pl = (Element) photoList.item(i); NodeList pid = pl.getElementsByTagNameNS(ALBUM_NAMESPACE, "id"); String photoId = XMLParseUtil.getElementData(pid.item(0)); photo.setId(photoId); photo.setTitle(XMLParseUtil.getElementData(pl, "title")); NodeList mediaGroup = pl.getElementsByTagNameNS( MEDIA_NAMESPACE, "group"); String urlLarge = null; String urlMedium = null; String urlSmall = null; String urlThumb = null; int width = 0; if (mediaGroup != null && mediaGroup.getLength() > 0) { Element el = (Element) mediaGroup.item(0); if (el != null) { NodeList content = el.getElementsByTagNameNS( MEDIA_NAMESPACE, "content"); if (content != null) { Element cl = (Element) content.item(0); if (cl != null) { urlLarge = cl.getAttribute("url"); } } NodeList thumbnail = el.getElementsByTagNameNS( MEDIA_NAMESPACE, "thumbnail"); if (thumbnail != null && thumbnail.getLength() > 0) { for (int k = 0; k < thumbnail.getLength(); k++) { Element thumb = (Element) thumbnail.item(k); if (thumb != null) { width = Integer.parseInt(thumb .getAttribute("width")); if (width == 288) { urlMedium = thumb .getAttribute("url"); } else if (width == 144) { urlSmall = thumb .getAttribute("url"); } else if (width == 72) { urlThumb = thumb .getAttribute("url"); } } } } } } photo.setLargeImage(urlLarge); photo.setMediumImage(urlMedium); photo.setSmallImage(urlSmall); photo.setThumbImage(urlThumb); photos.add(photo); } } else { LOG.info("No photos were obtained from : " + PHOTOS_URL); } } return photos; }
Example 19
Source File: Internalizer.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Moves JAXB customizations under their respective target nodes. */ private void move(Element bindings, Map<Element, List<Node>> targetNodes) { List<Node> nodelist = targetNodes.get(bindings); if(nodelist == null) { return; // abort } for (Node target : nodelist) { if (target == null) // this must be the result of an error on the external binding. // recover from the error by ignoring this node { return; } for (Element item : DOMUtils.getChildElements(bindings)) { String localName = item.getLocalName(); if ("bindings".equals(localName)) { // process child <jaxb:bindings> recursively move(item, targetNodes); } else if ("globalBindings".equals(localName)) { // <jaxb:globalBindings> always go to the root of document. Element root = forest.getOneDocument().getDocumentElement(); if (root.getNamespaceURI().equals(WSDL_NS)) { NodeList elements = root.getElementsByTagNameNS(XMLConstants.W3C_XML_SCHEMA_NS_URI, "schema"); if ((elements == null) || (elements.getLength() < 1)) { reportError(item, Messages.format(Messages.ORPHANED_CUSTOMIZATION, item.getNodeName())); return; } else { moveUnder(item, (Element)elements.item(0)); } } else { moveUnder(item, root); } } else { if (!(target instanceof Element)) { reportError(item, Messages.format(Messages.CONTEXT_NODE_IS_NOT_ELEMENT)); return; // abort } if (!forest.logic.checkIfValidTargetNode(forest, item, (Element) target)) { reportError(item, Messages.format(Messages.ORPHANED_CUSTOMIZATION, item.getNodeName())); return; // abort } // move this node under the target moveUnder(item, (Element) target); } } } }
Example 20
Source File: Internalizer.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Moves JAXB customizations under their respective target nodes. */ private void move(Element bindings, Map<Element, List<Node>> targetNodes) { List<Node> nodelist = targetNodes.get(bindings); if(nodelist == null) { return; // abort } for (Node target : nodelist) { if (target == null) // this must be the result of an error on the external binding. // recover from the error by ignoring this node { return; } for (Element item : DOMUtils.getChildElements(bindings)) { String localName = item.getLocalName(); if ("bindings".equals(localName)) { // process child <jaxb:bindings> recursively move(item, targetNodes); } else if ("globalBindings".equals(localName)) { // <jaxb:globalBindings> always go to the root of document. Element root = forest.getOneDocument().getDocumentElement(); if (root.getNamespaceURI().equals(WSDL_NS)) { NodeList elements = root.getElementsByTagNameNS(XMLConstants.W3C_XML_SCHEMA_NS_URI, "schema"); if ((elements == null) || (elements.getLength() < 1)) { reportError(item, Messages.format(Messages.ORPHANED_CUSTOMIZATION, item.getNodeName())); return; } else { moveUnder(item, (Element)elements.item(0)); } } else { moveUnder(item, root); } } else { if (!(target instanceof Element)) { reportError(item, Messages.format(Messages.CONTEXT_NODE_IS_NOT_ELEMENT)); return; // abort } if (!forest.logic.checkIfValidTargetNode(forest, item, (Element) target)) { reportError(item, Messages.format(Messages.ORPHANED_CUSTOMIZATION, item.getNodeName())); return; // abort } // move this node under the target moveUnder(item, (Element) target); } } } }