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:com.twinsoft.convertigo.engine.util.RemoteAdmin.java

private void decodeResponseError(String httpResponse) throws RemoteAdminException {
    Document domResponse;//from  w ww .j a  v a  2  s .  co  m
    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);

            throw new RemoteAdminException(errorMessage.getTextContent(),
                    exceptionName == null ? "" : exceptionName.getTextContent(),
                    stackTrace == null ? "" : stackTrace.getTextContent());
        }
    } 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);
    }
}

From source file:com.concursive.connect.web.modules.wiki.utils.HTMLToWikiUtils.java

public static void processChildNodes(ArrayList<Node> nodeList, StringBuffer sb, int indentLevel, boolean doText,
        boolean withFormatting, boolean trim, String appendToCRLF, String contextPath, int projectId) {
    Iterator nodeI = nodeList.iterator();
    while (nodeI.hasNext()) {
        Node n = (Node) nodeI.next();
        if (n != null) {
            if (n.getNodeType() == Node.TEXT_NODE || n.getNodeType() == Node.CDATA_SECTION_NODE) {
                if (doText) {
                    String value = n.getNodeValue();
                    // Escaped characters
                    value = StringUtils.replace(value, "*", "\\*");
                    value = StringUtils.replace(value, "#", "\\#");
                    value = StringUtils.replace(value, "=", "\\=");
                    value = StringUtils.replace(value, "|", "\\|");
                    value = StringUtils.replace(value, "[", "\\{");
                    value = StringUtils.replace(value, "]", "\\}");
                    if (trim && !nodeI.hasNext()) {
                        // If within a cell, make sure returns include the cell value
                        //              String value = (appendToCRLF.length() > 0 ? StringUtils.replace(n.getNodeValue(), CRLF, CRLF + appendToCRLF) : n.getNodeValue());
                        LOG.trace(" <text:trim>");
                        // Output the value, trim is required
                        sb.append(StringUtils.fromHtmlValue(value.trim()));
                    } else {
                        // If within a cell, make sure returns include the cell value
                        if (appendToCRLF.length() > 0
                                && (hasParentNodeType(n, "th") || hasParentNodeType(n, "td"))
                                && value.trim().length() == 0) {
                            // This is an empty value... check to see if the previous line has content or not before appending a new line
                        } else {
                            LOG.trace(" <text>");
                            sb.append(StringUtils.fromHtmlValue((appendToCRLF.length() > 0
                                    ? StringUtils.replace(value, CRLF, CRLF + appendToCRLF)
                                    : value)));
                        }//from  w  w w. j a  v a 2 s . c om
                    }
                }
            } else if (n.getNodeType() == Node.ELEMENT_NODE) {
                Element element = ((Element) n);
                String tag = element.getTagName();
                LOG.trace(tag);
                if ("h1".equals(tag)) {
                    startOnNewLine(sb, appendToCRLF);
                    sb.append("= ").append(StringUtils.fromHtmlValue(element.getTextContent().trim()))
                            .append(" =").append(CRLF + appendToCRLF);
                } else if ("h2".equals(tag)) {
                    startOnNewLine(sb, appendToCRLF);
                    sb.append("== ").append(StringUtils.fromHtmlValue(element.getTextContent().trim()))
                            .append(" ==").append(CRLF + appendToCRLF);
                } else if ("h3".equals(tag)) {
                    startOnNewLine(sb, appendToCRLF);
                    sb.append("=== ").append(StringUtils.fromHtmlValue(element.getTextContent().trim()))
                            .append(" ===").append(CRLF + appendToCRLF);
                } else if ("h4".equals(tag)) {
                    startOnNewLine(sb, appendToCRLF);
                    sb.append("==== ").append(StringUtils.fromHtmlValue(element.getTextContent().trim()))
                            .append(" ====").append(CRLF + appendToCRLF);
                } else if ("h5".equals(tag)) {
                    startOnNewLine(sb, appendToCRLF);
                    sb.append("===== ").append(StringUtils.fromHtmlValue(element.getTextContent().trim()))
                            .append(" =====").append(CRLF + appendToCRLF);
                } else if ("h6".equals(tag)) {
                    startOnNewLine(sb, appendToCRLF);
                    sb.append("====== ").append(StringUtils.fromHtmlValue(element.getTextContent().trim()))
                            .append(" ======").append(CRLF + appendToCRLF);
                } else if ("p".equals(tag) || "div".equals(tag)) {
                    if (n.getChildNodes().getLength() > 0
                            && (hasTextContent(n) || hasImageNodes(n.getChildNodes()))) {
                        // If this contains a Table, UL, OL, or object skip everything else to get there
                        ArrayList<Node> subNodes = new ArrayList<Node>();
                        getNodes(n.getChildNodes(), subNodes, new String[] { "table", "ul", "ol", "object" },
                                false);
                        if (subNodes.size() > 0) {
                            LOG.trace("  nonTextNodes - yes");
                            processChildNodes(subNodes, sb, indentLevel, true, true, false, appendToCRLF,
                                    contextPath, projectId);
                        } else {
                            LOG.trace("  nonTextNodes - no");
                            startOnNewLine(sb, appendToCRLF);
                            processChildNodes(getNodeList(n), sb, indentLevel, true, true, false, appendToCRLF,
                                    contextPath, projectId);
                        }
                    }
                } else if ("strong".equals(tag) || "b".equals(tag)) {
                    if (n.getChildNodes().getLength() > 0) {
                        if ("".equals(StringUtils.fromHtmlValue(n.getTextContent()).trim())) {
                            processChildNodes(getNodeList(n), sb, indentLevel, true, false, false, appendToCRLF,
                                    contextPath, projectId);
                        } else {
                            if (hasNonTextNodes(n.getChildNodes())) {
                                processChildNodes(getNodeList(n), sb, indentLevel, true, withFormatting, false,
                                        appendToCRLF, contextPath, projectId);
                            } else {
                                if (withFormatting) {
                                    sb.append("'''");
                                }
                                processChildNodes(getNodeList(n), sb, indentLevel, true, withFormatting, false,
                                        appendToCRLF, contextPath, projectId);
                                if (withFormatting) {
                                    sb.append("'''");
                                }
                            }
                        }
                    }
                } else if ("em".equals(tag) || "i".equals(tag)) {
                    if (n.getChildNodes().getLength() > 0) {
                        if ("".equals(StringUtils.fromHtmlValue(n.getTextContent()).trim())) {
                            processChildNodes(getNodeList(n), sb, indentLevel, true, false, trim, appendToCRLF,
                                    contextPath, projectId);
                        } else {
                            if (hasNonTextNodes(n.getChildNodes())) {
                                processChildNodes(getNodeList(n), sb, indentLevel, true, withFormatting, trim,
                                        appendToCRLF, contextPath, projectId);
                            } else {
                                if (withFormatting) {
                                    sb.append("''");
                                }
                                processChildNodes(getNodeList(n), sb, indentLevel, true, withFormatting, trim,
                                        appendToCRLF, contextPath, projectId);
                                if (withFormatting) {
                                    sb.append("''");
                                }
                            }
                        }
                    }
                } else if ("span".equals(tag)) {
                    if (n.getChildNodes().getLength() > 0
                            && !"".equals(StringUtils.fromHtmlValue(n.getTextContent()).trim())) {
                        if (element.hasAttribute("style")) {
                            String value = element.getAttribute("style");
                            if (withFormatting) {
                                if (value.contains("underline")) {
                                    sb.append("__");
                                }
                                if (value.contains("line-through")) {
                                    sb.append("<s>");
                                }
                                if (value.contains("bold")) {
                                    sb.append("'''");
                                }
                                if (value.contains("italic")) {
                                    sb.append("''");
                                }
                            }
                            processChildNodes(getNodeList(n), sb, indentLevel, true, withFormatting, trim,
                                    appendToCRLF, contextPath, projectId);
                            if (withFormatting) {
                                if (value.contains("italic")) {
                                    sb.append("''");
                                }
                                if (value.contains("bold")) {
                                    sb.append("'''");
                                }
                                if (value.contains("line-through")) {
                                    sb.append("</s>");
                                }
                                if (value.contains("underline")) {
                                    sb.append("__");
                                }
                            }
                        } else {
                            processChildNodes(getNodeList(n), sb, indentLevel, true, withFormatting, trim,
                                    appendToCRLF, contextPath, projectId);
                        }
                    }
                } else if ("ul".equals(tag) || "ol".equals(tag) || "dl".equals(tag)) {
                    ++indentLevel;
                    if (indentLevel == 1) {
                        if (appendToCRLF.length() == 0) {
                            startOnNewLine(sb, appendToCRLF);
                        } else {
                            // Something\n
                            // !
                            // !* Item 1
                            // !* Item 2
                            if (!sb.toString().endsWith("|") && !sb.toString().endsWith(CRLF + appendToCRLF)) {
                                LOG.trace("ul newline CRLF");
                                sb.append(CRLF + appendToCRLF);
                            }
                        }
                    }
                    if (indentLevel > 1 && !sb.toString().endsWith(CRLF + appendToCRLF)) {
                        LOG.trace("ul indent CRLF");
                        sb.append(CRLF + appendToCRLF);
                    }
                    processChildNodes(getNodeList(n), sb, indentLevel, false, false, trim, appendToCRLF,
                            contextPath, projectId);
                    --indentLevel;
                } else if ("li".equals(tag)) {
                    String parentTag = ((Element) element.getParentNode()).getTagName();
                    for (int counter = 0; counter < indentLevel; counter++) {
                        if ("ul".equals(parentTag)) {
                            sb.append("*");
                        } else if ("ol".equals(parentTag)) {
                            sb.append("#");
                        }
                    }
                    sb.append(" ");
                    processChildNodes(getNodeList(n), sb, indentLevel, true, false, true, appendToCRLF,
                            contextPath, projectId);
                    if (!sb.toString().endsWith(CRLF + appendToCRLF)) {
                        LOG.trace("li CRLF");
                        sb.append(CRLF + appendToCRLF);
                    }
                } else if ("dt".equals(tag) || "dd".equals(tag)) {
                    processChildNodes(getNodeList(n), sb, indentLevel, true, false, trim, appendToCRLF,
                            contextPath, projectId);
                    if (!sb.toString().endsWith(CRLF + appendToCRLF)) {
                        LOG.trace("dt CRLF");
                        sb.append(CRLF + appendToCRLF);
                    }
                } else if ("pre".equals(tag)) {
                    startOnNewLine(sb, appendToCRLF);
                    sb.append("<pre>");
                    processChildNodes(getNodeList(n), sb, indentLevel, true, true, trim, appendToCRLF,
                            contextPath, projectId);
                    sb.append("</pre>");
                    if (nodeI.hasNext()) {
                        sb.append(CRLF + appendToCRLF);
                        sb.append(CRLF + appendToCRLF);
                    }
                } else if ("code".equals(tag)) {
                    startOnNewLine(sb, appendToCRLF);
                    sb.append("<code>");
                    processChildNodes(getNodeList(n), sb, indentLevel, true, true, trim, appendToCRLF,
                            contextPath, projectId);
                    sb.append("</code>");
                    if (nodeI.hasNext()) {
                        sb.append(CRLF + appendToCRLF);
                        sb.append(CRLF + appendToCRLF);
                    }
                } else if ("br".equals(tag)) {
                    LOG.trace("br CRLF");
                    sb.append(CRLF + appendToCRLF);
                } else if ("table".equals(tag)) {
                    // Always start a table on a new line
                    startOnNewLine(sb, appendToCRLF);
                    processTable(n.getChildNodes(), sb, 0, false, false, contextPath, projectId, 0);
                    //if (nodeI.hasNext()) {
                    //  sb.append(CRLF);
                    //}
                } else if ("form".equals(tag)) {
                    // Always start a form on a new line
                    startOnNewLine(sb, appendToCRLF);
                    CustomForm form = processForm(n);
                    convertFormToWiki(form, sb);
                } else if ("a".equals(tag)) {
                    // Determine if the link is around text or around an image
                    if (n.getChildNodes().getLength() > 0 && hasImageNodes(n.getChildNodes())) {
                        // The link is around an image
                        LOG.debug("Processing link as an image");
                        // Get the img tag and pass to processImage...
                        ArrayList<Node> subNodes = new ArrayList<Node>();
                        getNodes(n.getChildNodes(), subNodes, new String[] { "img" }, false);
                        processImage(sb, subNodes.get(0), (Element) subNodes.get(0), appendToCRLF, contextPath,
                                projectId);
                    } else {
                        // The link is around text
                        processLink(sb, element, appendToCRLF, contextPath, projectId);
                    }
                } else if ("img".equals(tag)) {
                    processImage(sb, n, element, appendToCRLF, contextPath, projectId);
                } else if ("object".equals(tag)) {
                    startOnNewLine(sb, appendToCRLF);
                    processVideo(sb, n, element, appendToCRLF, contextPath);
                } else {
                    processChildNodes(getNodeList(n), sb, indentLevel, false, true, trim, appendToCRLF,
                            contextPath, projectId);
                }
            }
        }
    }
}

From source file:eu.esdihumboldt.hale.io.appschema.writer.AppSchemaFileWriterTest.java

private void checkWorkspaceDocument(Document doc, final String id, final String name) {
    assertNotNull(doc);//from   w w  w . jav  a2  s .c  om
    assertEquals("workspace", doc.getDocumentElement().getNodeName());
    Element idEl = getFirstElementByTagName(doc.getDocumentElement(), "id");
    assertNotNull(idEl);
    assertEquals(id, idEl.getTextContent());
    Element nameEl = getFirstElementByTagName(doc.getDocumentElement(), "name");
    assertNotNull(nameEl);
    assertEquals(name, nameEl.getTextContent());
}

From source file:eu.esdihumboldt.hale.io.appschema.writer.AppSchemaFileWriterTest.java

private void checkNamespaceDocument(Document doc, final String id, final String prefix, final String uri) {
    assertNotNull(doc);//from w ww. j  a v  a2 s. c  om
    assertEquals("namespace", doc.getDocumentElement().getNodeName());
    Element idEl = getFirstElementByTagName(doc.getDocumentElement(), "id");
    assertNotNull(idEl);
    assertEquals(id, idEl.getTextContent());
    Element prefixEl = getFirstElementByTagName(doc.getDocumentElement(), "prefix");
    assertNotNull(prefixEl);
    assertEquals(prefix, prefixEl.getTextContent());
    Element uriEl = getFirstElementByTagName(doc.getDocumentElement(), "uri");
    assertNotNull(uriEl);
    assertEquals(uri, uriEl.getTextContent());
}

From source file:com.clican.pluto.dataprocess.spring.parser.JdbcExecProcessorParser.java

@SuppressWarnings("unchecked")

public void customiseBeanDefinition(BeanDefinition beanDef, Element element, ParserContext parserContext) {
    String jdbcTemplate = element.getAttribute("jdbcTemplate");
    beanDef.getPropertyValues().addPropertyValue("jdbcTemplate", new RuntimeBeanReference(jdbcTemplate));
    List jdbcExecBeanList = new ManagedList();
    NodeList nodeList = element.getChildNodes();
    for (int i = 0; i < nodeList.getLength(); i++) {
        Node node = nodeList.item(i);
        if (node.getNodeType() == Node.ELEMENT_NODE) {
            String localName = node.getLocalName();
            if ("exec".equals(localName)) {
                RootBeanDefinition bean = new RootBeanDefinition();
                bean.setAbstract(false);
                bean.setBeanClass(JdbcExecBean.class);
                bean.setLazyInit(false);
                bean.setAutowireMode(Autowire.BY_NAME.value());

                Element jdbcExecElement = (Element) node;
                String batch = jdbcExecElement.getAttribute("batch");
                String paramName = jdbcExecElement.getAttribute("paramName");
                String resultName = jdbcExecElement.getAttribute("resultName");
                String paramNameMap = jdbcExecElement.getAttribute("paramNameMap");
                String singleRow = jdbcExecElement.getAttribute("singleRow");
                String clazz = jdbcExecElement.getAttribute("clazz");
                String sql = jdbcExecElement.getTextContent();
                if (StringUtils.isNotEmpty(paramNameMap)) {
                    Map<String, String> map = new HashMap<String, String>();
                    for (String pnm : paramNameMap.split(";")) {
                        String contextName = pnm.split("=>")[0].trim();
                        String ibatisName = pnm.split("=>")[1].trim();
                        map.put(contextName, ibatisName);
                    }/* ww  w  .  j  ava2  s.  c o  m*/
                    bean.getPropertyValues().addPropertyValue("paramNameMap", map);
                }
                if (StringUtils.isNotEmpty(batch)) {
                    bean.getPropertyValues().addPropertyValue("batch", Boolean.parseBoolean(batch));
                }
                if (StringUtils.isNotEmpty(singleRow)) {
                    bean.getPropertyValues().addPropertyValue("singleRow", Boolean.parseBoolean(singleRow));
                }
                if (StringUtils.isNotEmpty(clazz)) {
                    try {
                        bean.getPropertyValues().addPropertyValue("clazz", Class.forName(clazz));
                    } catch (Exception e) {
                        throw new RuntimeException(e);
                    }
                }
                bean.getPropertyValues().addPropertyValue("paramName", paramName);
                bean.getPropertyValues().addPropertyValue("resultName", resultName);
                bean.getPropertyValues().addPropertyValue("sql", sql);
                jdbcExecBeanList.add(bean);
            }
        }
    }
    beanDef.getPropertyValues().addPropertyValue("jdbcExecBeanList", jdbcExecBeanList);
}

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

/**
 * Fill alfresco class./*  w ww  .  j  a v a 2  s.co m*/
 * 
 * @param login
 *            the login
 * @param alfrescoClass
 *            the alfresco class
 * @param xformsNode
 *            the xforms node
 * @param isServletRequest
 */
private void fillAlfrescoClass(GenericClass alfrescoClass, Node xformsNode, boolean isServletRequest,
        Map<String, String> initParams) {
    Element element = null;
    if (xformsNode instanceof Document) {
        element = ((Document) xformsNode).getDocumentElement();
    } else {
        element = (Element) xformsNode;
    }
    List<Element> children = DOMUtil.getAllChildren(element);

    ClassType classType = null;
    Element sideDataType = DOMUtil.getOneElementByTagName(children, MsgId.INT_INSTANCE_SIDE_DATATYPE.getText());
    if (sideDataType != null) {
        classType = getClassType(sideDataType.getTextContent());
    } else {
        classType = getClassType(element.getTagName());
    }

    alfrescoClass.setQualifiedName(classType.getAlfrescoName());
    List<ClassType> classTypes = getParentClassTypes(classType);

    GenericAttributes attributes = alfrescoObjectFactory.createGenericAttributes();
    GenericAssociations associations = alfrescoObjectFactory.createGenericAssociations();
    associations.setAction("replace");
    for (ClassType subClassType : classTypes) {
        xformsAttributesToAlfresco(attributes, children, subClassType, isServletRequest, initParams);
        xformsAssociationsToAlfresco(associations, children, subClassType);
    }
    alfrescoClass.setAttributes(attributes);
    alfrescoClass.setAssociations(associations);

    String elementId = xformsIdToAlfresco(children);
    if (elementId != null) {
        alfrescoClass.setId(elementId);
    }
}

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

/**
 * Removes the reference.//  ww w.j  a v  a2  s .com
 * 
 * @param node
 *            the node
 * @param elementId
 *            the element id
 */
public void removeReference(Node node, String elementId) {
    String relementId = controller.patchDataId(elementId);

    Element element = null;
    if (node instanceof Document) {
        element = ((Document) node).getDocumentElement();
    } else {
        if (node instanceof Element) {
            element = (Element) node;
        } else {
            throw new RuntimeException("Unknow type of DOM node element");
        }

    }

    List<Element> children = DOMUtil.getAllChildren(element);
    ClassType classType = null;
    Element dataType = DOMUtil.getOneElementByTagName(children, MsgId.INT_INSTANCE_SIDE_DATATYPE.getText());
    if (dataType != null) {
        classType = getClassType(dataType.getTextContent());
    } else {
        classType = getClassType(element.getTagName());
    }
    List<ClassType> classTypes = getParentClassTypes(classType);

    List<Element> elementsToRemove = new ArrayList<Element>();

    for (ClassType subClassType : classTypes) {
        List<AssociationType> xformsAssociations = subClassType.getAssociation();
        for (AssociationType associationType : xformsAssociations) {
            Element associationElement = DOMUtil.getOneElementByTagName(children, associationType.getName());
            if (associationElement != null) {
                List<Element> associationElements = DOMUtil.getAllChildren(associationElement);
                for (Element association : associationElements) {
                    processRemoveReference(relementId, elementsToRemove, associationType, association,
                            isMultiple(associationType));
                }
            }
        }
    }
    for (Element elementToRemove : elementsToRemove) {
        element.removeChild(elementToRemove);
    }
}

From source file:org.gvnix.addon.jpa.addon.audit.providers.envers.EnversRevisionLogProvider.java

/**
 * Check persistence.xml registered provider to assure it's hibernate
 * //from   w  w w.j  a  v  a  2s.c  om
 * @param persistencePath
 * @param persistenceXml
 */
private void checkPersistenceProvider(String persistencePath, Document persistenceXml) {
    Element providerElement = XmlUtils.findFirstElement("/persistence/persistence-unit/provider",
            persistenceXml);
    if (providerElement == null) {
        throw new IllegalStateException("Error loading file '".concat(persistencePath)
                .concat("': /persistence/persistence-unit/provider tag not found"));
    }
    String provider = providerElement.getTextContent();
    if (StringUtils.isBlank(provider)) {
        throw new IllegalStateException("Error loading file '".concat(persistencePath)
                .concat("': /persistence/persistence-unit/provider tag is empty"));
    }
    provider = provider.trim();
    if (!HBER_PERS_PROV_CLS.equals(provider)) {
        throw new IllegalStateException(String.format(
                "Error loading file '%s': unexpected /persistence/persistence-unit/provider (expected: '%s' found: '%s')",
                persistencePath, HBER_PERS_PROV_CLS, provider));
    }
}

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

/**
 * {@inheritDoc}/*w  w w.  ja va2  s . com*/
 */
@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 = this.parseSsl(element);
    if (ssl != null) {
        factoryBuilder.addPropertyValue("sslConfiguration", ssl);
    }

    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, SmscServerNamespaceHandler.SMSCSERVER_NS,
            "blacklist");
    if (blacklistElm != null) {
        this.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,
            SmscServerNamespaceHandler.SMSCSERVER_NS, "remote-ip-filter");
    if (remoteIpFilterElement != null) {
        if (blacklistElm != null) {
            throw new SmscServerConfigurationException(
                    "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);
    this.registerBeanDefinition(factoryHolder, parserContext.getRegistry());

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

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

/**
 * Process association./*from w  ww  .j av a 2s  . c  o m*/
 * 
 * @param login
 *            the login
 * @param associations
 *            the associations
 * @param associationType
 *            the association type
 * @param associationElement
 *            the association element
 * @deprecated
 */
@Deprecated
@SuppressWarnings("unused")
private void processAssociation(AlfrescoTransaction transaction, GenericAssociations associations,
        AssociationType associationType, Element associationElement, Map<String, String> initParams) {
    String targetId = null;

    Element targetNode = null;
    targetNode = associationElement;

    if (targetNode != null) {
        if (isInline(associationType)) {
            targetId = processSave(transaction, targetNode, initParams);
        } else {
            Element specificElement = DOMUtil.getChild(targetNode, MsgId.INT_INSTANCE_SIDEID.getText());
            if (specificElement != null) {
                targetId = StringUtils.trimToNull(specificElement.getTextContent());
                targetId = controller.patchDataId(targetId);
            }
        }
    }

    if (targetId != null) {
        GenericAssociation association = alfrescoObjectFactory.createGenericAssociation();
        association.setQualifiedName(associationType.getAlfrescoName());
        association.setAction(AssociationActions.ADD);

        GenericClassReference target = alfrescoObjectFactory.createGenericClassReference();
        target.setQualifiedName(associationType.getType().getAlfrescoName());
        target.setValue(targetId);
        association.setTarget(target);

        associations.getAssociation().add(association);
    }

}