Package org.apache.lenya.cms.publication

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


        return getParameterAsString(NODE_NAME).trim();
    }

    protected boolean isPathValid() {
        String nodeName = getNewDocumentName();
        DocumentBuilder builder = getPublication().getDocumentBuilder();
        return !nodeName.trim().equals("") && builder.isValidDocumentName(nodeName);
    }
View Full Code Here


     */
    protected Document getAuthoringDocument()
        throws ParameterException, DocumentBuildException, ExecutionException {
        String id = getParameters().getParameter(PARAMETER_DOCUMENT_ID);
        String language = getParameters().getParameter(PARAMETER_DOCUMENT_LANGUAGE);
        DocumentBuilder builder = getPublication().getDocumentBuilder();
        String url =
            builder.buildCanonicalUrl(getPublication(), Publication.AUTHORING_AREA, id, language);
        Document document = builder.buildDocument(getPublication(), url);
        return document;
    }
View Full Code Here

     */
    protected Document getLiveDocument()
        throws ParameterException, DocumentBuildException, ExecutionException {
        String id = getParameters().getParameter(PARAMETER_DOCUMENT_ID);
        String language = getParameters().getParameter(PARAMETER_DOCUMENT_LANGUAGE);
        DocumentBuilder builder = getPublication().getDocumentBuilder();
        String url =
            builder.buildCanonicalUrl(getPublication(), Publication.LIVE_AREA, id, language);
        Document document = builder.buildDocument(getPublication(), url);
        return document;
    }
View Full Code Here

      // TODO: resources (fix the build file)
      // TODO: rcml (fix the build file)
      // TODO: rcbak (fix the build file)

      //move workflow
      DocumentBuilder builder = publication.getDocumentBuilder();
      String url = builder.buildCanonicalUrl(publication, firstarea, srcDocumentid, language);
      String newurl =
        builder.buildCanonicalUrl(publication, secarea, destDocumentid, language);

      Document document;
      Document newDocument;
      WorkflowFactory factory = WorkflowFactory.newInstance();

      log("move workflow history");
      try {
        document = builder.buildDocument(publication, url);
        newDocument = builder.buildDocument(publication, newurl);
      } 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

      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

     * @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

   * @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

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.