Package com.liferay.portal.kernel.xml

Examples of com.liferay.portal.kernel.xml.Document


            if (_log.isDebugEnabled()) {
                _log.debug("Loading " + source);
            }
        }

        Document doc = _saxReader.read(is);

        Element root = doc.getRootElement();

        Iterator<Element> itr1 = root.elements("hint-collection").iterator();

        while (itr1.hasNext()) {
            Element hintCollection = itr1.next();
View Full Code Here


public class ServiceBuilder {

    public static final String AUTHOR = "Brian Wing Shun Chan";

    public static String getContent(String fileName) throws Exception {
        Document document = _getContentDocument(fileName);

        Element rootElement = document.getRootElement();

        Element authorElement = null;
        Element namespaceElement = null;
        Map<String, Element> entityElements = new TreeMap<String, Element>();
        Map<String, Element> exceptionElements = new TreeMap<String, Element>();

        for (Element element : rootElement.elements()) {
            String elementName = element.getName();

            if (elementName.equals("author")) {
                element.detach();

                if (authorElement != null) {
                    throw new IllegalArgumentException(
                            "There can only be one author element");
                }

                authorElement = element;
            }
            else if (elementName.equals("namespace")) {
                element.detach();

                if (namespaceElement != null) {
                    throw new IllegalArgumentException(
                            "There can only be one namespace element");
                }

                namespaceElement = element;
            }
            else if (elementName.equals("entity")) {
                element.detach();

                String name = element.attributeValue("name");

                entityElements.put(StringUtil.toLowerCase(name), element);
            }
            else if (elementName.equals("exceptions")) {
                element.detach();

                for (Element exceptionElement : element.elements("exception")) {
                    exceptionElement.detach();

                    exceptionElements.put(
                            exceptionElement.getText(), exceptionElement);
                }
            }
        }

        if (authorElement != null) {
            rootElement.add(authorElement);
        }

        if (namespaceElement == null) {
            throw new IllegalArgumentException(
                    "The namespace element is required");
        }
        else {
            rootElement.add(namespaceElement);
        }

        _addElements(rootElement, entityElements);

        if (!exceptionElements.isEmpty()) {
            Element exceptionsElement = rootElement.addElement("exceptions");

            _addElements(exceptionsElement, exceptionElements);
        }

        return document.asXML();
    }
View Full Code Here

            _buildNumberIncrement = buildNumberIncrement;
            _modelHints = new ModelHintsLoader(_modelHintsFileName);

            String content = getContent(fileName);

            Document document = SAXReaderUtil.read(content, true);

            Element rootElement = document.getRootElement();

            String packagePath = rootElement.attributeValue("package-path");

            if (Validator.isNull(packagePath)) {
                throw new IllegalArgumentException(
View Full Code Here

    private static Document _getContentDocument(String fileName)
            throws Exception {

        String content = FileUtil.read(new File(fileName));

        Document document = SAXReaderUtil.read(content);

        Element rootElement = document.getRootElement();

        for (Element element : rootElement.elements()) {
            String elementName = element.getName();

            if (!elementName.equals("service-builder-import")) {
                continue;
            }

            element.detach();

            String dirName = fileName.substring(
                    0, fileName.lastIndexOf(StringPool.SLASH) + 1);
            String serviceBuilderImportFileName = element.attributeValue(
                    "file");

            Document serviceBuilderImportDocument = _getContentDocument(
                    dirName + serviceBuilderImportFileName);

            Element serviceBuilderImportRootElement =
                    serviceBuilderImportDocument.getRootElement();

            for (Element serviceBuilderImportElement :
                    serviceBuilderImportRootElement.elements()) {

                serviceBuilderImportElement.detach();
View Full Code Here

    }

    private void _createRemotingXml() throws Exception {
        StringBundler sb = new StringBundler();

        Document document = SAXReaderUtil.read(new File(_springFileName));

        Element rootElement = document.getRootElement();

        List<Element> beanElements = rootElement.elements("bean");

        for (Element beanElement : beanElements) {
            String beanId = beanElement.attributeValue("id");
View Full Code Here

  protected Map<Locale, String> getMap(String value) {
    return getMap(LocaleUtil.getDefault(), value);
  }

  protected boolean isJournalStructureXSD(String xsd) throws Exception {
    Document document = SAXReaderUtil.read(xsd);

    Element rootElement = document.getRootElement();

    Attribute availableLocalesAttribute = rootElement.attribute(
      "available-locales");

    if (availableLocalesAttribute == null) {
View Full Code Here

public class WebXMLDefinitionLoader {

  public WebXMLDefinitionLoader() throws DocumentException {
    Class<?> clazz = getClass();

    Document document = SAXReaderUtil.read(
      clazz.getResource(
        "/com/liferay/httpservice/internal/servlet/dependencies/" +
          "default-web.xml"));

    _defaultWebXmlRootElement = document.getRootElement();
  }
View Full Code Here

    readServlets(bundle, _defaultWebXmlRootElement, webXML);

    URL url = bundle.getEntry("WEB-INF/web.xml");

    if (url != null) {
      Document document = SAXReaderUtil.read(url);

      Element rootElement = document.getRootElement();

      readContextParameters(bundle, rootElement, webXML);
      readFilters(bundle, rootElement, webXML);
      readListeners(bundle, rootElement, webXML);
      readServlets(bundle, rootElement, webXML);
View Full Code Here

    try {
      String pluginPackageXml = HttpUtil.URLtoString(
        bundle.getResource("/WEB-INF/liferay-plugin-package.xml"));

      if (pluginPackageXml != null) {
        Document document = SAXReaderUtil.read(pluginPackageXml);

        Element rootElement = document.getRootElement();

        deploymentContext = GetterUtil.getString(
          rootElement.elementText("recommended-deployment-context"));
      }
      else {
View Full Code Here

    InputStream inputStream = classLoader.getResourceAsStream(
      "/resources/data/sql.xml");

    String xml = new String(FileUtil.getBytes(inputStream));

    Document document = SAXReaderUtil.read(xml);

    Element rootElement = document.getRootElement();

    List<Element> batchElements = rootElement.elements("batch");

    for (Element batchElement : batchElements) {
      String testSQL = batchElement.elementText("test-sql");
View Full Code Here

TOP

Related Classes of com.liferay.portal.kernel.xml.Document

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.