Example usage for org.w3c.dom Element getTextContent

List of usage examples for org.w3c.dom Element getTextContent

Introduction

In this page you can find the example usage for org.w3c.dom Element getTextContent.

Prototype

public String getTextContent() throws DOMException;

Source Link

Document

This attribute returns the text content of this node and its descendants.

Usage

From source file:org.apache.ftpserver.config.spring.ListenerBeanDefinitionParser.java

/**
 * {@inheritDoc}//  ww  w  .  j  a  v a 2  s . c om
 */
@Override
protected void doParse(final Element element, final ParserContext parserContext,
        final BeanDefinitionBuilder builder) {

    BeanDefinitionBuilder factoryBuilder = BeanDefinitionBuilder.genericBeanDefinition(ListenerFactory.class);

    if (StringUtils.hasText(element.getAttribute("port"))) {
        factoryBuilder.addPropertyValue("port", Integer.valueOf(element.getAttribute("port")));
    }

    SslConfiguration ssl = parseSsl(element);
    if (ssl != null) {
        factoryBuilder.addPropertyValue("sslConfiguration", ssl);
    }

    Element dataConElm = SpringUtil.getChildElement(element, FtpServerNamespaceHandler.FTPSERVER_NS,
            "data-connection");
    DataConnectionConfiguration dc = parseDataConnection(dataConElm, ssl);
    factoryBuilder.addPropertyValue("dataConnectionConfiguration", dc);

    if (StringUtils.hasText(element.getAttribute("idle-timeout"))) {
        factoryBuilder.addPropertyValue("idleTimeout", SpringUtil.parseInt(element, "idle-timeout", 300));
    }

    String localAddress = SpringUtil.parseStringFromInetAddress(element, "local-address");
    if (localAddress != null) {
        factoryBuilder.addPropertyValue("serverAddress", localAddress);
    }
    factoryBuilder.addPropertyValue("implicitSsl", SpringUtil.parseBoolean(element, "implicit-ssl", false));

    Element blacklistElm = SpringUtil.getChildElement(element, FtpServerNamespaceHandler.FTPSERVER_NS,
            "blacklist");
    if (blacklistElm != null) {
        LOG.warn(
                "Element 'blacklist' is deprecated, and may be removed in a future release. Please use 'remote-ip-filter' instead. ");
        try {
            RemoteIpFilter remoteIpFilter = new RemoteIpFilter(IpFilterType.DENY,
                    blacklistElm.getTextContent());
            factoryBuilder.addPropertyValue("sessionFilter", remoteIpFilter);
        } catch (UnknownHostException e) {
            throw new IllegalArgumentException("Invalid IP address or subnet in the 'blacklist' element", e);
        }
    }

    Element remoteIpFilterElement = SpringUtil.getChildElement(element, FtpServerNamespaceHandler.FTPSERVER_NS,
            "remote-ip-filter");
    if (remoteIpFilterElement != null) {
        if (blacklistElm != null) {
            throw new FtpServerConfigurationException(
                    "Element 'remote-ip-filter' may not be used when 'blacklist' element is specified. ");
        }
        String filterType = remoteIpFilterElement.getAttribute("type");
        try {
            RemoteIpFilter remoteIpFilter = new RemoteIpFilter(IpFilterType.parse(filterType),
                    remoteIpFilterElement.getTextContent());
            factoryBuilder.addPropertyValue("sessionFilter", remoteIpFilter);
        } catch (UnknownHostException e) {
            throw new IllegalArgumentException(
                    "Invalid IP address or subnet in the 'remote-ip-filter' element");
        }
    }

    BeanDefinition factoryDefinition = factoryBuilder.getBeanDefinition();

    String listenerFactoryName = parserContext.getReaderContext().generateBeanName(factoryDefinition);

    BeanDefinitionHolder factoryHolder = new BeanDefinitionHolder(factoryDefinition, listenerFactoryName);
    registerBeanDefinition(factoryHolder, parserContext.getRegistry());

    // set the factory on the listener bean
    builder.getRawBeanDefinition().setFactoryBeanName(listenerFactoryName);
    builder.getRawBeanDefinition().setFactoryMethodName("createListener");
}

From source file:com.andyasprou.webcrawler.Utilities.GenericSiteMapParser.java

/**
 * Get the element's textual content./*ww  w . ja v a  2  s  .c  om*/
 *
 * @param elem
 * @param elementName
 * @return The element value
 */
protected String getElementValue(Element elem, String elementName) {

    NodeList list = elem.getElementsByTagName(elementName);
    if (list == null)
        return null;
    Element e = (Element) list.item(0);
    if (e != null) {
        return e.getTextContent();
    }
    return null;
}

From source file:com.microsoft.windowsazure.management.network.StaticIPOperationsImpl.java

/**
* The Check Static IP operation retrieves the details for the availability
* of static IP addresses for the given virtual network.
*
* @param networkName Required. The name of the virtual network.
* @param ipAddress Required. The address of the static IP.
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations./*from  www.  j a v  a2s.co m*/
* @throws ServiceException Thrown if an unexpected response is found.
* @throws ParserConfigurationException Thrown if there was a serious
* configuration error with the document parser.
* @throws SAXException Thrown if there was an error parsing the XML
* response.
* @return A response that indicates the availability of a static IP
* address, and if not, provides a list of suggestions.
*/
@Override
public NetworkStaticIPAvailabilityResponse check(String networkName, InetAddress ipAddress)
        throws IOException, ServiceException, ParserConfigurationException, SAXException {
    // Validate
    if (networkName == null) {
        throw new NullPointerException("networkName");
    }
    if (ipAddress == null) {
        throw new NullPointerException("ipAddress");
    }

    // Tracing
    boolean shouldTrace = CloudTracing.getIsEnabled();
    String invocationId = null;
    if (shouldTrace) {
        invocationId = Long.toString(CloudTracing.getNextInvocationId());
        HashMap<String, Object> tracingParameters = new HashMap<String, Object>();
        tracingParameters.put("networkName", networkName);
        tracingParameters.put("ipAddress", ipAddress);
        CloudTracing.enter(invocationId, this, "checkAsync", tracingParameters);
    }

    // Construct URL
    String url = "";
    url = url + "/";
    if (this.getClient().getCredentials().getSubscriptionId() != null) {
        url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8");
    }
    url = url + "/services/networking/";
    url = url + URLEncoder.encode(networkName, "UTF-8");
    ArrayList<String> queryParameters = new ArrayList<String>();
    queryParameters.add("op=checkavailability");
    queryParameters.add("address=" + URLEncoder.encode(ipAddress.getHostAddress(), "UTF-8"));
    if (queryParameters.size() > 0) {
        url = url + "?" + CollectionStringBuilder.join(queryParameters, "&");
    }
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

    // Create HTTP transport objects
    HttpGet httpRequest = new HttpGet(url);

    // Set Headers
    httpRequest.setHeader("x-ms-version", "2015-04-01");

    // Send Request
    HttpResponse httpResponse = null;
    try {
        if (shouldTrace) {
            CloudTracing.sendRequest(invocationId, httpRequest);
        }
        httpResponse = this.getClient().getHttpClient().execute(httpRequest);
        if (shouldTrace) {
            CloudTracing.receiveResponse(invocationId, httpResponse);
        }
        int statusCode = httpResponse.getStatusLine().getStatusCode();
        if (statusCode != HttpStatus.SC_OK) {
            ServiceException ex = ServiceException.createFromXml(httpRequest, null, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        NetworkStaticIPAvailabilityResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new NetworkStaticIPAvailabilityResponse();
            DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
            documentBuilderFactory.setNamespaceAware(true);
            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
            Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent));

            Element addressAvailabilityResponseElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "AddressAvailabilityResponse");
            if (addressAvailabilityResponseElement != null) {
                Element isAvailableElement = XmlUtility.getElementByTagNameNS(
                        addressAvailabilityResponseElement, "http://schemas.microsoft.com/windowsazure",
                        "IsAvailable");
                if (isAvailableElement != null) {
                    boolean isAvailableInstance;
                    isAvailableInstance = DatatypeConverter
                            .parseBoolean(isAvailableElement.getTextContent().toLowerCase());
                    result.setIsAvailable(isAvailableInstance);
                }

                Element availableAddressesSequenceElement = XmlUtility.getElementByTagNameNS(
                        addressAvailabilityResponseElement, "http://schemas.microsoft.com/windowsazure",
                        "AvailableAddresses");
                if (availableAddressesSequenceElement != null) {
                    for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility
                            .getElementsByTagNameNS(availableAddressesSequenceElement,
                                    "http://schemas.microsoft.com/windowsazure", "AvailableAddress")
                            .size(); i1 = i1 + 1) {
                        org.w3c.dom.Element availableAddressesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(availableAddressesSequenceElement,
                                        "http://schemas.microsoft.com/windowsazure", "AvailableAddress")
                                .get(i1));
                        result.getAvailableAddresses()
                                .add(InetAddress.getByName(availableAddressesElement.getTextContent()));
                    }
                }
            }

        }
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
            result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
        }

        if (shouldTrace) {
            CloudTracing.exit(invocationId, result);
        }
        return result;
    } finally {
        if (httpResponse != null && httpResponse.getEntity() != null) {
            httpResponse.getEntity().getContent().close();
        }
    }
}

From source file:com.microsoft.windowsazure.management.LocationOperationsImpl.java

/**
* The List Locations operation lists all of the data center locations that
* are valid for your subscription.  (see
* http://msdn.microsoft.com/en-us/library/windowsazure/gg441293.aspx for
* more information)/*from   w  w  w.  j  a  v a2s  .  co  m*/
*
* @throws IOException Signals that an I/O exception of some sort has
* occurred. This class is the general class of exceptions produced by
* failed or interrupted I/O operations.
* @throws ServiceException Thrown if an unexpected response is found.
* @throws ParserConfigurationException Thrown if there was a serious
* configuration error with the document parser.
* @throws SAXException Thrown if there was an error parsing the XML
* response.
* @return The List Locations operation response.
*/
@Override
public LocationsListResponse list()
        throws IOException, ServiceException, ParserConfigurationException, SAXException {
    // Validate

    // Tracing
    boolean shouldTrace = CloudTracing.getIsEnabled();
    String invocationId = null;
    if (shouldTrace) {
        invocationId = Long.toString(CloudTracing.getNextInvocationId());
        HashMap<String, Object> tracingParameters = new HashMap<String, Object>();
        CloudTracing.enter(invocationId, this, "listAsync", tracingParameters);
    }

    // Construct URL
    String url = "";
    url = url + "/";
    if (this.getClient().getCredentials().getSubscriptionId() != null) {
        url = url + URLEncoder.encode(this.getClient().getCredentials().getSubscriptionId(), "UTF-8");
    }
    url = url + "/locations";
    String baseUrl = this.getClient().getBaseUri().toString();
    // Trim '/' character from the end of baseUrl and beginning of url.
    if (baseUrl.charAt(baseUrl.length() - 1) == '/') {
        baseUrl = baseUrl.substring(0, (baseUrl.length() - 1) + 0);
    }
    if (url.charAt(0) == '/') {
        url = url.substring(1);
    }
    url = baseUrl + "/" + url;
    url = url.replace(" ", "%20");

    // Create HTTP transport objects
    HttpGet httpRequest = new HttpGet(url);

    // Set Headers
    httpRequest.setHeader("x-ms-version", "2014-10-01");

    // Send Request
    HttpResponse httpResponse = null;
    try {
        if (shouldTrace) {
            CloudTracing.sendRequest(invocationId, httpRequest);
        }
        httpResponse = this.getClient().getHttpClient().execute(httpRequest);
        if (shouldTrace) {
            CloudTracing.receiveResponse(invocationId, httpResponse);
        }
        int statusCode = httpResponse.getStatusLine().getStatusCode();
        if (statusCode != HttpStatus.SC_OK) {
            ServiceException ex = ServiceException.createFromXml(httpRequest, null, httpResponse,
                    httpResponse.getEntity());
            if (shouldTrace) {
                CloudTracing.error(invocationId, ex);
            }
            throw ex;
        }

        // Create Result
        LocationsListResponse result = null;
        // Deserialize Response
        if (statusCode == HttpStatus.SC_OK) {
            InputStream responseContent = httpResponse.getEntity().getContent();
            result = new LocationsListResponse();
            DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
            documentBuilderFactory.setNamespaceAware(true);
            DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
            Document responseDoc = documentBuilder.parse(new BOMInputStream(responseContent));

            Element locationsSequenceElement = XmlUtility.getElementByTagNameNS(responseDoc,
                    "http://schemas.microsoft.com/windowsazure", "Locations");
            if (locationsSequenceElement != null) {
                for (int i1 = 0; i1 < com.microsoft.windowsazure.core.utils.XmlUtility
                        .getElementsByTagNameNS(locationsSequenceElement,
                                "http://schemas.microsoft.com/windowsazure", "Location")
                        .size(); i1 = i1 + 1) {
                    org.w3c.dom.Element locationsElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                            .getElementsByTagNameNS(locationsSequenceElement,
                                    "http://schemas.microsoft.com/windowsazure", "Location")
                            .get(i1));
                    LocationsListResponse.Location locationInstance = new LocationsListResponse.Location();
                    result.getLocations().add(locationInstance);

                    Element nameElement = XmlUtility.getElementByTagNameNS(locationsElement,
                            "http://schemas.microsoft.com/windowsazure", "Name");
                    if (nameElement != null) {
                        String nameInstance;
                        nameInstance = nameElement.getTextContent();
                        locationInstance.setName(nameInstance);
                    }

                    Element displayNameElement = XmlUtility.getElementByTagNameNS(locationsElement,
                            "http://schemas.microsoft.com/windowsazure", "DisplayName");
                    if (displayNameElement != null) {
                        String displayNameInstance;
                        displayNameInstance = displayNameElement.getTextContent();
                        locationInstance.setDisplayName(displayNameInstance);
                    }

                    Element availableServicesSequenceElement = XmlUtility.getElementByTagNameNS(
                            locationsElement, "http://schemas.microsoft.com/windowsazure", "AvailableServices");
                    if (availableServicesSequenceElement != null) {
                        for (int i2 = 0; i2 < com.microsoft.windowsazure.core.utils.XmlUtility
                                .getElementsByTagNameNS(availableServicesSequenceElement,
                                        "http://schemas.microsoft.com/windowsazure", "AvailableService")
                                .size(); i2 = i2 + 1) {
                            org.w3c.dom.Element availableServicesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(availableServicesSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "AvailableService")
                                    .get(i2));
                            locationInstance.getAvailableServices()
                                    .add(availableServicesElement.getTextContent());
                        }
                    }

                    Element storageCapabilitiesElement = XmlUtility.getElementByTagNameNS(locationsElement,
                            "http://schemas.microsoft.com/windowsazure", "StorageCapabilities");
                    if (storageCapabilitiesElement != null) {
                        StorageCapabilities storageCapabilitiesInstance = new StorageCapabilities();
                        locationInstance.setStorageCapabilities(storageCapabilitiesInstance);

                        Element storageAccountTypesSequenceElement = XmlUtility.getElementByTagNameNS(
                                storageCapabilitiesElement, "http://schemas.microsoft.com/windowsazure",
                                "StorageAccountTypes");
                        if (storageAccountTypesSequenceElement != null) {
                            storageCapabilitiesInstance.setStorageAccountTypes(new ArrayList<String>());
                            for (int i3 = 0; i3 < com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(storageAccountTypesSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "StorageAccountType")
                                    .size(); i3 = i3 + 1) {
                                org.w3c.dom.Element storageAccountTypesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                        .getElementsByTagNameNS(storageAccountTypesSequenceElement,
                                                "http://schemas.microsoft.com/windowsazure",
                                                "StorageAccountType")
                                        .get(i3));
                                storageCapabilitiesInstance.getStorageAccountTypes()
                                        .add(storageAccountTypesElement.getTextContent());
                            }
                        }
                    }

                    Element computeCapabilitiesElement = XmlUtility.getElementByTagNameNS(locationsElement,
                            "http://schemas.microsoft.com/windowsazure", "ComputeCapabilities");
                    if (computeCapabilitiesElement != null) {
                        ComputeCapabilities computeCapabilitiesInstance = new ComputeCapabilities();
                        locationInstance.setComputeCapabilities(computeCapabilitiesInstance);

                        Element virtualMachinesRoleSizesSequenceElement = XmlUtility.getElementByTagNameNS(
                                computeCapabilitiesElement, "http://schemas.microsoft.com/windowsazure",
                                "VirtualMachinesRoleSizes");
                        if (virtualMachinesRoleSizesSequenceElement != null) {
                            for (int i4 = 0; i4 < com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(virtualMachinesRoleSizesSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "RoleSize")
                                    .size(); i4 = i4 + 1) {
                                org.w3c.dom.Element virtualMachinesRoleSizesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                        .getElementsByTagNameNS(virtualMachinesRoleSizesSequenceElement,
                                                "http://schemas.microsoft.com/windowsazure", "RoleSize")
                                        .get(i4));
                                computeCapabilitiesInstance.getVirtualMachinesRoleSizes()
                                        .add(virtualMachinesRoleSizesElement.getTextContent());
                            }
                        }

                        Element webWorkerRoleSizesSequenceElement = XmlUtility.getElementByTagNameNS(
                                computeCapabilitiesElement, "http://schemas.microsoft.com/windowsazure",
                                "WebWorkerRoleSizes");
                        if (webWorkerRoleSizesSequenceElement != null) {
                            for (int i5 = 0; i5 < com.microsoft.windowsazure.core.utils.XmlUtility
                                    .getElementsByTagNameNS(webWorkerRoleSizesSequenceElement,
                                            "http://schemas.microsoft.com/windowsazure", "RoleSize")
                                    .size(); i5 = i5 + 1) {
                                org.w3c.dom.Element webWorkerRoleSizesElement = ((org.w3c.dom.Element) com.microsoft.windowsazure.core.utils.XmlUtility
                                        .getElementsByTagNameNS(webWorkerRoleSizesSequenceElement,
                                                "http://schemas.microsoft.com/windowsazure", "RoleSize")
                                        .get(i5));
                                computeCapabilitiesInstance.getWebWorkerRoleSizes()
                                        .add(webWorkerRoleSizesElement.getTextContent());
                            }
                        }
                    }
                }
            }

        }
        result.setStatusCode(statusCode);
        if (httpResponse.getHeaders("x-ms-request-id").length > 0) {
            result.setRequestId(httpResponse.getFirstHeader("x-ms-request-id").getValue());
        }

        if (shouldTrace) {
            CloudTracing.exit(invocationId, result);
        }
        return result;
    } finally {
        if (httpResponse != null && httpResponse.getEntity() != null) {
            httpResponse.getEntity().getContent().close();
        }
    }
}

From source file:com.evolveum.midpoint.prism.marshaller.XPathHolder.java

public XPathHolder(Element domElement) {

    String xpath = ".";
    if (null != domElement) {
        xpath = domElement.getTextContent();
    }/*  w w w .  j av  a  2  s .  c  om*/

    parse(xpath, domElement, null);
}

From source file:edu.clemson.lph.civet.xml.StdeCviXmlBuilder.java

private Element getAddress(Element e, String sStreetIn, String sCityIn, String sStateIn, String sZipIn) {
    if (e == null)
        return null;
    ArrayList<Element> eAddresses = XMLUtility.listChildElementsByName(e, "Address");
    for (Element eAddress : eAddresses) {
        String sStreet = null;/* www .  j  av  a2s .c  o  m*/
        String sCity = null;
        String sState = null;
        String sZip = null;
        Element eStreet = childElementByName(eAddress, "Line1");
        if (eStreet != null)
            sStreet = eStreet.getTextContent();
        Element eCity = childElementByName(eAddress, "Town");
        if (eCity != null)
            sCity = eCity.getTextContent();
        Element eState = childElementByName(eAddress, "State");
        if (eState != null)
            sState = eState.getTextContent();
        Element eZip = childElementByName(eAddress, "Zip");
        if (eZip != null)
            sZip = eZip.getTextContent();
        if (((sStreetIn == null && sStreet == null) || (sStreetIn != null && sStreetIn.equals(sStreet)))
                || ((sCityIn == null && sCity == null) || (sCityIn != null && sCityIn.equals(sCity)))
                || ((sStateIn == null && sState == null) || (sStateIn != null && sStateIn.equals(sState)))
                || ((sZipIn == null && sZip == null) || (sZipIn != null && sZipIn.equals(sZip)))) {

            return eAddress;
        }
    }
    return null;
}

From source file:com.twinsoft.convertigo.engine.util.RemoteAdmin.java

public void deployArchive(File archiveFile, boolean bAssembleXsl) throws RemoteAdminException {

    String deployServiceURL = (bHttps ? "https" : "http") + "://" + serverBaseUrl
            + "/admin/services/projects.Deploy?bAssembleXsl=" + bAssembleXsl;

    PostMethod deployMethod = null;/*from www.  j a v  a2s  . co  m*/
    Protocol myhttps = null;

    try {
        if (bHttps && bTrustAllCertificates) {
            ProtocolSocketFactory socketFactory = MySSLSocketFactory.getSSLSocketFactory(null, null, null, null,
                    true);
            myhttps = new Protocol("https", socketFactory, serverPort);
            Protocol.registerProtocol("https", myhttps);

            hostConfiguration = httpClient.getHostConfiguration();
            hostConfiguration.setHost(host, serverPort, myhttps);
            httpClient.setHostConfiguration(hostConfiguration);
        }

        deployMethod = new PostMethod(deployServiceURL);

        Part[] parts = { new FilePart(archiveFile.getName(), archiveFile) };
        deployMethod.setRequestEntity(new MultipartRequestEntity(parts, deployMethod.getParams()));

        int returnCode = httpClient.executeMethod(deployMethod);
        String httpResponse = deployMethod.getResponseBodyAsString();

        if (returnCode == HttpStatus.SC_OK) {
            Document domResponse;
            try {
                DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                domResponse = parser.parse(new InputSource(new StringReader(httpResponse)));
                domResponse.normalize();

                NodeList nodeList = domResponse.getElementsByTagName("error");

                if (nodeList.getLength() != 0) {
                    Element errorNode = (Element) nodeList.item(0);

                    Element errorMessage = (Element) errorNode.getElementsByTagName("message").item(0);

                    Element exceptionName = (Element) errorNode.getElementsByTagName("exception").item(0);

                    Element stackTrace = (Element) errorNode.getElementsByTagName("stacktrace").item(0);

                    if (errorMessage != null) {
                        throw new RemoteAdminException(errorMessage.getTextContent(),
                                exceptionName.getTextContent(), stackTrace.getTextContent());
                    } else {
                        throw new RemoteAdminException(
                                "An unexpected error has occured during the Convertigo project deployment: \n"
                                        + "Body content: \n\n"
                                        + XMLUtils.prettyPrintDOMWithEncoding(domResponse, "UTF-8"));
                    }
                }
            } catch (ParserConfigurationException e) {
                throw new RemoteAdminException("Unable to parse the Convertigo server response: \n"
                        + e.getMessage() + ".\n" + "Received response: " + httpResponse);
            } catch (IOException e) {
                throw new RemoteAdminException(
                        "An unexpected error has occured during the Convertigo project deployment.\n"
                                + "(IOException) " + e.getMessage() + "\n" + "Received response: "
                                + httpResponse,
                        e);
            } catch (SAXException e) {
                throw new RemoteAdminException("Unable to parse the Convertigo server response: "
                        + e.getMessage() + ".\n" + "Received response: " + httpResponse);
            }
        } else {
            decodeResponseError(httpResponse);
        }
    } catch (HttpException e) {
        throw new RemoteAdminException(
                "An unexpected error has occured during the Convertigo project deployment.\n" + "Cause: "
                        + e.getMessage(),
                e);
    } catch (IOException e) {
        throw new RemoteAdminException(
                "Unable to reach the Convertigo server: \n" + "(IOException) " + e.getMessage(), e);
    } catch (Exception e) {
        throw new RemoteAdminException(
                "Unable to reach the Convertigo server: \n" + "(Exception) " + e.getMessage(), e);
    } finally {
        Protocol.unregisterProtocol("https");
        if (deployMethod != null)
            deployMethod.releaseConnection();
    }
}

From source file:org.gvnix.dynamic.configuration.roo.addon.ConfigurationsImpl.java

/**
 * Check if a configuration is the active.
 * /* w  w w.j  av a 2 s. com*/
 * @param conf Configuration element
 * @return Active element or null if is not the active
 */
private Element isActiveConfiguration(Element conf) {

    // Get active configuration element
    Element activeConf = XmlUtils.findFirstElement(ACTIVE_CONFIGURATION_XPATH,
            conf.getOwnerDocument().getDocumentElement());

    // Mark the configuration as active if same than this
    String name = conf.getAttribute(NAME_ATTRIBUTE_NAME);

    if (activeConf != null && activeConf.getTextContent().equals(name)) {

        return activeConf;
    }

    return null;
}

From source file:com.bluexml.xforms.controller.mapping.MappingToolFormsToAlfresco.java

/**
 * Analyzes the value when the association widget is a select in order to add the relevant
 * associations in the GenericClass object.
 * //from www .  j av  a2 s.co m
 * @param modelChoiceType
 *            the mapping entry for the association field
 * @param rootElt
 *            the node for the association field in the form instance
 * @param alfClass
 *            the object to be sent to the webscript
 */
private void collectModelChoiceSelectWidget(ModelChoiceType modelChoiceType, Element rootElt,
        GenericClass alfClass) {
    Element item = DOMUtil.getChild(rootElt, MsgId.INT_INSTANCE_ASSOCIATION_ITEM.getText());
    String textContent = item.getTextContent();
    String[] ids = StringUtils.split(textContent, " ");
    for (String id : ids) {
        collectAddAssociation(alfClass, id, modelChoiceType);
    }
}

From source file:de.bund.bfr.pmfml.numl.ResultComponent.java

public ResultComponent(final Element node) {

    strProps = new HashMap<>(8);
    strProps.put(ID, node.getAttribute(ID));

    final NodeList annotationNodes = node.getElementsByTagName(ANNOTATION);
    final Element annotationNode = (Element) annotationNodes.item(0);

    final NodeList metadataNodes = annotationNode.getElementsByTagName(METADATA);
    final Element metadataNode = (Element) metadataNodes.item(0);

    final NodeList condIdNodes = metadataNode.getElementsByTagName(CONDID);
    if (condIdNodes.getLength() == 1) {
        final Element condIdElement = (Element) condIdNodes.item(0);
        condID = Integer.valueOf(condIdElement.getTextContent());
    } else {//from w w w.ja v a2  s.  c  o  m
        condID = null;
    }

    final NodeList combaseIdNodes = metadataNode.getElementsByTagName(COMBASEID);
    if (combaseIdNodes.getLength() == 1) {
        strProps.put(COMBASEID, combaseIdNodes.item(0).getTextContent());
    }

    final NodeList creatorGivenNameNodes = metadataNode.getElementsByTagName(CREATOR_GIVEN_NAME);
    if (creatorGivenNameNodes.getLength() == 1) {
        strProps.put(CREATOR_GIVEN_NAME, creatorGivenNameNodes.item(0).getTextContent());
    }

    final NodeList creatorFamilyNameNodes = metadataNode.getElementsByTagName(CREATOR_FAMILY_NAME);
    if (creatorFamilyNameNodes.getLength() == 1) {
        strProps.put(CREATOR_FAMILY_NAME, creatorFamilyNameNodes.item(0).getTextContent());
    }

    final NodeList creatorContactNodes = metadataNode.getElementsByTagName(CREATOR_CONTACT);
    if (creatorContactNodes.getLength() == 1) {
        strProps.put(CREATOR_CONTACT, creatorContactNodes.item(0).getTextContent());
    }

    final NodeList createdDateNodes = metadataNode.getElementsByTagName(CREATED_DATE);
    if (createdDateNodes.getLength() == 1) {
        strProps.put(CREATED_DATE, createdDateNodes.item(0).getTextContent());
    }

    final NodeList modifiedDateNodes = metadataNode.getElementsByTagName(MODIFIED_DATE);
    if (modifiedDateNodes.getLength() == 1) {
        strProps.put(MODIFIED_DATE, modifiedDateNodes.item(0).getTextContent());
    }

    final NodeList modelTypeNodes = metadataNode.getElementsByTagName(MODEL_TYPE);
    if (modelTypeNodes.getLength() == 1) {
        final Element modelTypeElement = (Element) modelTypeNodes.item(0);
        modelType = ModelType.valueOf(modelTypeElement.getTextContent());
    } else {
        modelType = null;
    }

    final NodeList rightsNodes = metadataNode.getElementsByTagName(RIGHTS);
    if (rightsNodes.getLength() == 1) {
        strProps.put(RIGHTS, rightsNodes.item(0).getTextContent());
    }

    final NodeList refNodes = metadataNode.getElementsByTagName(ReferenceNuMLNode.TAG);
    references = new ReferenceImpl[refNodes.getLength()];
    for (int i = 0; i < refNodes.getLength(); i++) {
        final Element refElement = (Element) refNodes.item(i);
        references[i] = new ReferenceNuMLNode(refElement).toReference();
    }

    final NodeList dimensionDescriptionNodes = node.getElementsByTagName(DIMENSION_DESCRIPTION);
    final Element dimensionDescriptionNode = (Element) dimensionDescriptionNodes.item(0);

    final NodeList tupleDescriptionNodes = dimensionDescriptionNode
            .getElementsByTagName(TupleDescription.ELEMENT_NAME);
    dimensionDescription = new TupleDescription((Element) tupleDescriptionNodes.item(0));

    final NodeList dimensionNodes = node.getElementsByTagName(DIMENSION);
    final Element dimensionNode = (Element) dimensionNodes.item(0);

    final NodeList tupleNodes = dimensionNode.getElementsByTagName(Tuple.ELEMENT_NAME);
    dimensions = new Tuple[tupleNodes.getLength()];
    for (int i = 0; i < tupleNodes.getLength(); i++) {
        dimensions[i] = new Tuple((Element) tupleNodes.item(i));
    }
}