Package org.apache.lenya.cms.publication

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


            SiteTree sitetree = publication.getTree(Publication.LIVE_AREA);
            String[] links = getInternalLinks(this.document.getFile());
           
            for (int linkIndex = 0; linkIndex < links.length; linkIndex++) {
                if (builder.isDocument(publication, links[linkIndex])) {
                    Document targetDocument = builder.buildDocument(publication, links[linkIndex]);

                    SiteTreeNode documentNode = sitetree.getNode(targetDocument.getId());

                    if (documentNode == null || documentNode.getLabel(targetDocument.getLanguage()) == null) {
                        // the document has not been published for the given language
                        if (log.isDebugEnabled()) {
                            log.debug("found reference to unpublished document: " + targetDocument);
                        }
                        unpublishedReferences.add(targetDocument);
View Full Code Here


      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);
View Full Code Here

        throws PageEnvelopeException, DocumentDoesNotExistException, DocumentException {

        PageEnvelope pageEnvelope =
            PageEnvelopeFactory.getInstance().getPageEnvelope(objectModel);

        Document doc = pageEnvelope.getDocument();
        String language = doc.getLanguage();

        if (!doc.existsInAnyLanguage()) {
            throw new DocumentDoesNotExistException("Document " + doc.getId() + " does not exist. Check sitetree, it might need to be reloaded.");
        }
        List availableLanguages = Arrays.asList(doc.getLanguages());

        if (availableLanguages.contains(language)) {
            return Collections.unmodifiableMap(Collections.EMPTY_MAP);
        }
        return null;
View Full Code Here

      }
      if (node == null || (labels != null && labels.length < 1)) {

        DocumentBuilder builder = publication.getDocumentBuilder();
        String url = builder.buildCanonicalUrl(publication, area, documentid, language);
        Document doc;
        try {
          doc = builder.buildDocument(publication, url);
        } catch (DocumentBuildException e) {
          throw new BuildException(e);
        }
View Full Code Here

        try {
            DocumentBuilder builder = getPublication().getDocumentBuilder();

            String authoringUrl =
                builder.buildCanonicalUrl(getPublication(), Publication.AUTHORING_AREA, documentId);
            Document authoringDocument = builder.buildDocument(getPublication(), authoringUrl);
            ResourcesManager authoringManager = new ResourcesManager(authoringDocument);

            String liveUrl =
                builder.buildCanonicalUrl(getPublication(), Publication.LIVE_AREA, documentId);
            Document liveDocument = builder.buildDocument(getPublication(), liveUrl);
            ResourcesManager liveManager = new ResourcesManager(liveDocument);
           
            // find all resource files and their associated meta files
            List resourcesList =
                new ArrayList(Arrays.asList(authoringManager.getResources()));
View Full Code Here

          builder.buildCanonicalUrl(
            publication,
            getSecarea(),
            destDocumentid,
            language);
        Document destDoc;
        destDoc = builder.buildDocument(publication, destUrl);
                String filename = destDoc.getFile().getCanonicalPath();
        filename = filename.substring(publicationPath.length());
                rc.reservedCheckIn(filename, getUserId(), true);
      }
    } catch (Exception e) {
      throw new BuildException(e);
View Full Code Here

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

      log("url for the source : "+srcUrl);
      log("url for the destination : "+destUrl);

      Document srcDoc;
      Document destDoc;
      WorkflowFactory factory = WorkflowFactory.newInstance();
     
      log("init workflow history");
      try {
        srcDoc = builder.buildDocument(publication, srcUrl);
        destDoc = builder.buildDocument(publication, destUrl);
      } catch (DocumentBuildException e) {
        throw new BuildException(e);
      }

      log("move workflow history of "+srcDoc.getFile().getAbsolutePath()+" to " + destDoc.getFile().getAbsolutePath());
      try {
        if (factory.hasWorkflow(srcDoc)) {
          log("has workflow");
          WorkflowFactory.moveHistory(srcDoc, destDoc);
          log("workflow moved");
View Full Code Here

           
            Publication pub = getPublication();
            DocumentBuilder builder = pub.getDocumentBuilder();
           
            String oldTargetUrl = builder.buildCanonicalUrl(pub, getArea(), getOldDocumentId());
            Document oldTargetDocument = builder.buildDocument(pub, oldTargetUrl);
           
            String newTargetUrl = builder.buildCanonicalUrl(pub, getArea(), getNewDocumentId());
            Document newTargetDocument = builder.buildDocument(pub, newTargetUrl);
           
            LinkRewriter rewriter = new LinkRewriter();
            rewriter.rewriteLinks(oldTargetDocument, newTargetDocument, getContextPrefix());
           
        } catch (Exception e) {
View Full Code Here

        Publication publication = PublicationHelper.getPublication();
        DocumentBuilder builder = publication.getDocumentBuilder();
       
        String sourceUrl =
            builder.buildCanonicalUrl(publication, sourceArea, sourceDocumentId, sourceLanguage);
        Document sourceDocument = builder.buildDocument(publication, sourceUrl);
        String destinationUrl =
            builder.buildCanonicalUrl(
                publication,
                destinationArea,
                destinationDocumentId,
                destinationLanguage);
        Document destinationDocument = builder.buildDocument(publication, destinationUrl);
       
        publication.copyDocument(sourceDocument, destinationDocument);
       
        assertTrue(destinationDocument.exists());
       
        SiteTree destinationTree = publication.getTree(destinationArea);
        SiteTreeNode destinationNode = destinationTree.getNode(destinationDocumentId);
        assertNotNull(destinationNode);
        Label destinationLabel = destinationNode.getLabel(destinationLanguage);
View Full Code Here

            for (int i = 0; i < children.length; i++) {
                String childId = documentId + "/" + children[i].getId();

                //get child document with the same language than the parent document
                String url = builder.buildCanonicalUrl(publication, area, childId, language);
                Document doc;
                try {
                    doc = builder.buildDocument(publication, url);
                } catch (DocumentBuildException e) {
                    throw new SAXException(e);
                }
                File file = doc.getFile();

                if (!file.exists()) {
                    //get first the child document in the default language and then in any other existent language
                    getLogger().debug(
                        "There is no child file "
                            + file.getAbsolutePath()
                            + " in the same language as the parent document ["
                            + language
                            + "]");

                    //available language   
                    String[] availableLanguages = null;
                    try {
                        availableLanguages = doc.getLanguages();
                    } catch (DocumentException e) {
                        throw new SAXException(e);
                    }

                    List languages = new ArrayList();
                    for (int l = 0; l < availableLanguages.length; l++) {
                        if (availableLanguages[l].equals(language)) {
                            getLogger().debug(
                                "Do nothing because language was already tested: ["
                                    + availableLanguages[l]
                                    + "]");
                        } else if (availableLanguages[l].equals(defaultLanguage)) {
                            languages.add(0, availableLanguages[l]);
                        } else {
                            languages.add(availableLanguages[l]);
                        }
                    }

                    int j = 0;
                    while (!file.exists() && j < languages.size()) {
                        String newlanguage = (String) languages.get(j);
                        url = builder.buildCanonicalUrl(publication, area, childId, newlanguage);
                        try {
                            doc = builder.buildDocument(publication, url);
                        } catch (DocumentBuildException e) {
                            throw new SAXException(e);
                        }
                        file = doc.getFile();

                        j++;
                    }
                }
View Full Code Here

TOP

Related Classes of org.apache.lenya.cms.publication.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.