Package org.apache.lenya.cms.publication

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


   * @return the document with the given language
   *
   * @throws ProcessingException if the document for the given language could not be created.
   */
    protected Document getDocument(String language) throws ProcessingException {
        DocumentBuilder builder = pageEnvelope.getPublication().getDocumentBuilder();
        Document document = builder.buildLanguageVersion(pageEnvelope.getDocument(), language);
        return document;
    }
View Full Code Here


        DocumentIdToPathMapper mapper = publication.getPathMapper();
        if (mapper instanceof PathToDocumentIdMapper) {
            PathToDocumentIdMapper fileMapper = (PathToDocumentIdMapper)mapper;
            String documentId = null;
            String language = null;
            DocumentBuilder builder = publication.getDocumentBuilder();
            File[] inconsistentFiles;
            try {
                inconsistentFiles =
                    Grep.find(
                        publication.getContentDirectory(area),
                        getReferencesSearchString());
                for (int i = 0; i < inconsistentFiles.length; i++) {
                    // for performance reasons the getReferencesSearchString() is
                    // constructed in a way such that it will catch all files which
                    // have a link to any language version of the current document.
                    // That's why we need to do some additional tests for each hit.
                    String languageOfCurrentDocument =
                        pageEnvelope.getDocument().getLanguage();
                    String defaultLanguage =
                        pageEnvelope.getPublication().getDefaultLanguage();
                    Pattern referencesSearchStringWithLanguage =
                        Pattern.compile(
                            getReferencesSearchString()
                                + "_"
                                + languageOfCurrentDocument);
                    Pattern referencesSearchStringWithOutLanguage =
                        Pattern.compile(
                            getReferencesSearchString() + "\\.html");
                    log.debug(
                        "languageOfCurrentDocument: "
                            + languageOfCurrentDocument);
                    log.debug("defaultLanguage: " + defaultLanguage);
                    log.debug(
                        "referencesSearchStringWithOutLanguage: "
                            + referencesSearchStringWithOutLanguage.pattern());
                    log.debug(
                        "referencesSearchStringWithLanguage: "
                            + referencesSearchStringWithLanguage.pattern());
                    // a link is indeed to the current document if the following conditions
                    // are met:
                    // 1. the link is to foo_xx and the language of the current
                    //    document is xx.
                    // 2. or the link is to foo.html and the language of the current
                    //    document is the default language.
                    // Now negate the expression because we continue if above (1) and (2) are
                    // false, and you'll get the following if statement
                    if (!Grep
                        .containsPattern(
                            inconsistentFiles[i],
                            referencesSearchStringWithLanguage)
                        && !(Grep
                            .containsPattern(
                                inconsistentFiles[i],
                                referencesSearchStringWithOutLanguage)
                            && languageOfCurrentDocument.equals(
                                defaultLanguage))) {
                        // the reference foo_xx is neither to the language of the current
                        // document.
                        // nor is the reference foo.html and the current document is in the
                        // default language.
                        // So the reference is of no importance to us, skip
                        continue;
                    }

                    documentId =
                        fileMapper.getDocumentId(
                            publication,
                            area,
                            inconsistentFiles[i]);
                    log.debug("documentId: " + documentId);
                    language = fileMapper.getLanguage(inconsistentFiles[i]);
                    log.debug("language: " + language);

                    String url = null;
                    if (language != null) {
                        url =
                            builder.buildCanonicalUrl(
                                publication,
                                area,
                                documentId,
                                language);
                        log.debug("url: " + url);
                    } else {
                        url =
                            builder.buildCanonicalUrl(
                                publication,
                                area,
                                documentId);
                        log.debug("url: " + url);
                    }
                    documents.add(builder.buildDocument(publication, url));
                }
            } catch (IOException e) {
                throw new ProcessingException(e);
            } catch (DocumentDoesNotExistException e) {
                throw new ProcessingException(e);
View Full Code Here

    public Document[] getInternalReferences() throws ProcessingException {
        ArrayList unpublishedReferences = new ArrayList();
        SiteTree sitetree;
        Pattern internalLinkPattern = getInternalLinkPattern();
        Publication publication = pageEnvelope.getPublication();
        DocumentBuilder builder = publication.getDocumentBuilder();
        try {
            sitetree = publication.getSiteTree(Publication.LIVE_AREA);
            String[] internalLinks =
                Grep.findPattern(
                    pageEnvelope.getDocument().getFile(),
                    internalLinkPattern,
                    1);
            String[] internalLinksLanguages =
                Grep.findPattern(
                    pageEnvelope.getDocument().getFile(),
                    internalLinkPattern,
                    2);

            for (int i = 0; i < internalLinks.length; i++) {
                String docId = internalLinks[i];
                String language = null;

                log.debug("docId: " + docId);
                if (internalLinksLanguages[i] != null) {
                    // trim the leading '_'
                    language = internalLinksLanguages[i].substring(1);
                }

                log.debug("language: " + language);
                SiteTreeNode documentNode = sitetree.getNode(docId);

                if (language == null) {
                    String url =
                        "/"
                            + publication.getId()
                            + "/"
                            + pageEnvelope.getDocument().getArea()
                            + docId
                            + ".html";
                    language =
                        builder.buildDocument(publication, url).getLanguage();
                }
                log.debug("language: " + language);
                if (documentNode == null
                    || documentNode.getLabel(language) == null) {
                    // the docId has not been published for the given language
                    String url = null;
                    if (language != null) {
                        url =
                            builder.buildCanonicalUrl(
                                publication,
                                Publication.AUTHORING_AREA,
                                docId,
                                language);
                        log.debug("url: " + url);
                    } else {
                        url =
                            builder.buildCanonicalUrl(
                                publication,
                                Publication.AUTHORING_AREA,
                                docId);
                        log.debug("url: " + url);
                    }
                    unpublishedReferences.add(
                        builder.buildDocument(publication, url));
                }
            }
        } catch (SiteTreeException e) {
            throw new ProcessingException(e);
        } catch (IOException e) {
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 parentid = node.getAbsoluteParentId();
      String srcDocumentid = parentid + "/" +node.getId();
      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

        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

                        documentid.substring(0, lang)
                            + documentid.substring(lang + langLength, l - bxLength);
                }
            }

            DocumentBuilder builder = publication.getDocumentBuilder();

            String srcUrl = builder.buildCanonicalUrl(publication, document.getArea(), documentid, language);
            Document srcDoc = builder.buildDocument(publication, srcUrl);
            File newFile = srcDoc.getFile();
            filename = newFile.getCanonicalPath();

        } else {
            filename = document.getFile().getCanonicalPath();
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

            getLogger().debug("    Event:       [" + eventName + "]");
        }

        PageEnvelope envelope = PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);
        Publication publication = envelope.getPublication();
        DocumentBuilder builder = publication.getDocumentBuilder();
        String url = builder.buildCanonicalUrl(publication, area, documentId, language);
        Document document = builder.buildDocument(publication, url);

        WorkflowFactory factory = WorkflowFactory.newInstance();

        if (factory.hasWorkflow(document)) {
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 parentid = node.getAbsoluteParentId();
    String destDocumentid = parentid + "/" + node.getId();
    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

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

            String language = labels[i].getLanguage();
            DocumentBuilder builder = publication.getDocumentBuilder();

            try {
                String url = builder.buildCanonicalUrl(publication, area, documentId, language);
                Document document = builder.buildDocument(publication, url);

                String servletContext = new File(servletContextPath).getCanonicalPath();
                log("Deleting scheduler entry for document [" + document + "]");
                log("Resolving servlet [" + servletContext + "]");
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.