Package org.apache.lenya.cms.publication

Examples of org.apache.lenya.cms.publication.DocumentBuilder


  
   * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
   */
  public void visitSiteTreeNode(SiteTreeNode node) {
    Publication publication = getPublication();
    DocumentBuilder builder = publication.getDocumentBuilder();

    String srcDocumentid = node.getAbsoluteId();
    String destDocumentid =
      srcDocumentid.replaceFirst(
        getFirstdocumentid(),
        getSecdocumentid());

    Label[] labels = node.getLabels();

    // FIXME: if the resources differ for different languages, so iterate
    // on all languages

    String language = labels[0].getLanguage();
    String srcUrl =
      builder.buildCanonicalUrl(
        publication,
        getFirstarea(),
        srcDocumentid,
        language);
    Document srcDoc;
    try {
      srcDoc = builder.buildDocument(publication, srcUrl);
    } catch (DocumentBuildException e) {
      throw new BuildException(e);
    }
    ResourcesManager resourcesMgr = new ResourcesManager(srcDoc);
    List resources = new ArrayList(Arrays.asList(resourcesMgr.getResources()));
    resources.addAll(Arrays.asList(resourcesMgr.getMetaFiles()));
    File[] srcFiles =
      (File[]) resources.toArray(new File[resources.size()]);

    if (srcFiles == null) {
      log(
        "There are no resources for the document "
          + getFirstdocumentid());
      return;
    }

    String destUrl =
      builder.buildCanonicalUrl(
        publication,
        getSecarea(),
        destDocumentid,
        language);
    Document destDoc;
    try {
      destDoc = builder.buildDocument(publication, destUrl);
    } catch (DocumentBuildException e) {
      throw new BuildException(e);
    }
    resourcesMgr = new ResourcesManager(destDoc);

View Full Code Here


  /** (non-Javadoc)
   * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
   */
  public void visitSiteTreeNode(SiteTreeNode node) {
    Publication publication = getPublication();
    DocumentBuilder builder = publication.getDocumentBuilder();

    String destDocumentid = node.getAbsoluteId();
    String srcDocumentid =
      destDocumentid.replaceFirst(
        getSecdocumentid(),
        getFirstdocumentid());

    Label[] labels = node.getLabels();
    for (int i = 0; i < labels.length; i++) {
      String language = labels[i].getLanguage();
      String url =
        builder.buildCanonicalUrl(
          publication,
          getFirstarea(),
          srcDocumentid,
          language);
      Document doc;
      try {
        doc = builder.buildDocument(publication, url);
      } catch (DocumentBuildException e) {
        throw new BuildException(e);
      }
      File srcFile = doc.getFile();
      if (!srcFile.exists()) {
View Full Code Here

        String subject,
        String publisher,
        String rights)
        throws BuildException, DocumentBuildException, DocumentException {

        DocumentBuilder builder = getPublication().getDocumentBuilder();
        String url = builder.buildCanonicalUrl(getPublication(), area, documentId, lang);
        Document doc = builder.buildDocument(getPublication(), url);
        DublinCore dc = doc.getDublinCore();
        dc.setValue(DublinCore.ELEMENT_CREATOR, creator);
        dc.setValue(DublinCore.ELEMENT_TITLE, title);
        dc.setValue(DublinCore.ELEMENT_DESCRIPTION, description);
        dc.setValue(DublinCore.ELEMENT_SUBJECT, subject);
View Full Code Here

        Publication publication = originalTargetDocument.getPublication();
        String area = originalTargetDocument.getArea();
        File[] files = getDocumentFiles(publication, area);

        DocumentBuilder builder = publication.getDocumentBuilder();

        try {
            for (int fileIndex = 0; fileIndex < files.length; fileIndex++) {
                org.w3c.dom.Document xmlDocument = DocumentHelper.readDocument(files[fileIndex]);
                boolean linksRewritten = false;

                String[] xPaths = publication.getRewriteAttributeXPaths();
                for (int xPathIndex = 0; xPathIndex < xPaths.length; xPathIndex++) {
                    NodeList nodes = XPathAPI.selectNodeList(xmlDocument, xPaths[xPathIndex]);
                    for (int nodeIndex = 0; nodeIndex < nodes.getLength(); nodeIndex++) {
                        Node node = nodes.item(nodeIndex);
                        if (node.getNodeType() != Node.ATTRIBUTE_NODE) {
                            throw new RuntimeException("The XPath [" + xPaths[xPathIndex]
                                    + "] may only match attribute nodes!");
                        }
                        Attr attribute = (Attr) node;
                        final String url = attribute.getValue();

                        if (url.startsWith(contextPath + "/" + publication.getId())) {
                            final String webappUrl = url.substring(contextPath.length());
                           
                            if (builder.isDocument(publication, webappUrl)) {
                                Document targetDocument = builder.buildDocument(publication, webappUrl);

                                if (matches(targetDocument, originalTargetDocument)) {
                                    String newTargetUrl = getNewTargetURL(targetDocument,
                                            originalTargetDocument,
                                            newTargetDocument);
View Full Code Here

            Document newTargetDocument) {
        String originalId = originalTargetDocument.getId();
        String targetId = targetDocument.getId();
        String childString = targetId.substring(originalId.length());

        DocumentBuilder builder = targetDocument.getPublication().getDocumentBuilder();
        String newTargetUrl = builder.buildCanonicalUrl(newTargetDocument.getPublication(),
                newTargetDocument.getArea(),
                newTargetDocument.getId() + childString,
                targetDocument.getLanguage());

        return newTargetUrl;
View Full Code Here

  /** (non-Javadoc)
   * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
   */
  public void visitSiteTreeNode(SiteTreeNode node) {
    Publication publication = getPublication();
    DocumentBuilder builder = publication.getDocumentBuilder();

    Label[] labels = node.getLabels();
    for (int i = 0 ; i < labels.length; i++){
      String language = labels[i].getLanguage();

      String srcDocumentid = node.getAbsoluteId();
      String destDocumentid = srcDocumentid.replaceFirst(this.getFirstdocumentid(),this.getSecdocumentid());

      String srcUrl = builder.buildCanonicalUrl(publication, getFirstarea(), srcDocumentid, language);
      String destUrl = builder.buildCanonicalUrl(publication, getSecarea(), destDocumentid, language);


      Document document;
      Document newdocument;
      WorkflowFactory factory = WorkflowFactory.newInstance();
     
      log("init workflow history");
      try {
        document = builder.buildDocument(publication, srcUrl);
        newdocument = builder.buildDocument(publication, destUrl);
      } catch (DocumentBuildException e) {
        throw new BuildException(e);
      }
      try {
        if (factory.hasWorkflow(document)) {
View Full Code Here

     * @throws ExecutionException when something went wrong.
     */
    protected Document getDocument(String documentId, String area, String language)
        throws ExecutionException {
        Publication publication = getPublication();
        DocumentBuilder builder = publication.getDocumentBuilder();
        String url = builder.buildCanonicalUrl(publication, area, documentId, language);
        Document document;
        try {
            document = builder.buildDocument(publication, url);
        } catch (Exception e) {
            throw new ExecutionException(e);
        }
        return document;
    }
View Full Code Here

        String language = getLanguage();

        if (language == null) {
            language = getPublication().getDefaultLanguage();
        }
        DocumentBuilder builder = getPublication().getDocumentBuilder();
        String url = builder.buildCanonicalUrl(getPublication(), Publication.AUTHORING_AREA, getDocumentId(), language);
        Document document;
        try {
            document = builder.buildDocument(getPublication(), url);
            log(".execute(): " + document.getLanguage());
        } catch (DocumentBuildException e) {
            throw new BuildException(e);
        }
View Full Code Here

      throw new BuildException(e);
    }
    SiteTreeNode node = tree.getNode(documentid);
    Label[] labels = node.getLabels();

    DocumentBuilder builder = publication.getDocumentBuilder();

    try {
      if (labels.length < 1) {
        log("no languages found for the node with id : " + node.getId());
        url = builder.buildCanonicalUrl(publication, area, documentid);
        writeDCIdentifier(publication, url);
      } else {
        for (int i = 0; i < labels.length; i++) {
          language = labels[i].getLanguage();
          url = builder.buildCanonicalUrl(publication, area, documentid, language);
          writeDCIdentifier(publication, url);
        }
      }
    } catch (DocumentException e1) {
      throw new BuildException(e1);
View Full Code Here

  
   * @see org.apache.lenya.cms.publication.SiteTreeNodeVisitor#visitSiteTreeNode(org.apache.lenya.cms.publication.SiteTreeNode)
   */
  public void visitSiteTreeNode(SiteTreeNode node) {
    Publication publication = getPublication();
    DocumentBuilder builder = publication.getDocumentBuilder();

    String destDocumentid = node.getAbsoluteId();
    String srcDocumentid =
      destDocumentid.replaceFirst(
        getSecdocumentid(),
        getFirstdocumentid());

    Label[] labels = node.getLabels();
    for (int i = 0; i < labels.length; i++) {
      String language = labels[i].getLanguage();
      String url =
        builder.buildCanonicalUrl(
          publication,
          getFirstarea(),
          srcDocumentid,
          language);
      Document srcDoc;
      try {
        srcDoc = builder.buildDocument(publication, url);
      } catch (DocumentBuildException e) {
        throw new BuildException(e);
      }

      ResourcesManager resourcesMgr = new ResourcesManager(srcDoc);
View Full Code Here

TOP

Related Classes of org.apache.lenya.cms.publication.DocumentBuilder

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.