Package org.apache.lenya.cms.publication

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


  public void visitSiteTreeNode(SiteTreeNode node) {
    try {
      Publication publication = getPublication();
      String publicationPath =
        this.getPublicationDirectory().getCanonicalPath();
      DocumentBuilder builder = publication.getDocumentBuilder();

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

      Label[] labels = node.getLabels();
      for (int i = 0; i < labels.length; i++) {
        String language = labels[i].getLanguage();
        String destUrl =
          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) {
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);

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

     */
    public void execute() throws BuildException {
        try {
           
            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

        System.out.println("    Destination area:        [" + destinationArea + "]");
        System.out.println("    Destination document ID: [" + destinationDocumentId + "]");
        System.out.println("    Destination language:    [" + destinationLanguage + "]");
           
        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());
       
View Full Code Here

     * @return true if the specified document id is live
     */
    private boolean documentIsLive(String documentId, String languageExtension)
        throws SAXException {
        boolean result = false;
        DocumentBuilder builder =
            envelope.getPublication().getDocumentBuilder();

        // trim the '_'
        String language =
            (languageExtension.length() == 0) ? null : languageExtension.substring(1);
        String url =
            (language == null)
                ? builder.buildCanonicalUrl(
                    envelope.getPublication(),
                    Publication.LIVE_AREA,
                    documentId)
                : builder.buildCanonicalUrl(
                    envelope.getPublication(),
                    Publication.LIVE_AREA,
                    documentId,
                    language);
        try {
            result =
                builder.buildDocument(envelope.getPublication(), url).exists();
        } catch (PublicationException e) {
            throw new SAXException(e);
        }
        return result;
    }
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.getAbsolutePath();

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

      try {
        resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
        Publication publication = PublicationFactory.getPublication(resolver, request);

        DocumentBuilder builder = publication.getDocumentBuilder();
        if (builder.isDocument(publication, url)) {

          Document document = builder.buildDocument(publication, url);
          WorkflowFactory factory = WorkflowFactory.newInstance();

          if (factory.hasWorkflow(document)) {
            SynchronizedWorkflowInstances instance =
              factory.buildSynchronizedInstance(document);
View Full Code Here

            String href = attrs.getValue(ATTRIBUTE_HREF);
            if (href != null) {

                Publication publication = getCurrentDocument().getPublication();
                DocumentBuilder builder = publication.getDocumentBuilder();

                try {

                    newAttrs = new AttributesImpl(attrs);

                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug(this.indent + "href URL: [" + href + "]");
                    }

                    String context = this.request.getContextPath();

                    if (href.startsWith(context + "/" + publication.getId())) {

                        final String webappUrlWithQueryString = href.substring(context.length());
                        String webappUrlWithAnchor;
                       
                        String queryString = null;
                        int queryStringIndex = webappUrlWithQueryString.indexOf("?");
                        if (queryStringIndex > -1) {
                            webappUrlWithAnchor = webappUrlWithQueryString.substring(0, queryStringIndex);
                            queryString = webappUrlWithQueryString.substring(queryStringIndex + 1);
                        }
                        else {
                            webappUrlWithAnchor = webappUrlWithQueryString;
                        }
                       
                        String anchor = null;
                        String webappUrl = null;
                       
                        int anchorIndex = webappUrlWithAnchor.indexOf("#");
                        if (anchorIndex > -1) {
                            webappUrl = webappUrlWithAnchor.substring(0, anchorIndex);
                            anchor = webappUrlWithAnchor.substring(anchorIndex + 1);
                        }
                        else {
                            webappUrl = webappUrlWithAnchor;
                        }
                       
                        if (getLogger().isDebugEnabled()) {
                            getLogger().debug(this.indent + "webapp URL: [" + webappUrl + "]");
                            getLogger().debug(this.indent + "anchor:     [" + anchor + "]");
                        }
                        if (builder.isDocument(publication, webappUrl)) {

                            Document targetDocument = builder.buildDocument(publication, webappUrl);

                            if (getLogger().isDebugEnabled()) {
                                getLogger().debug(this.indent + "Resolved target document: ["
                                        + targetDocument + "]");
                            }

                            String currentAreaUrl = builder.buildCanonicalUrl(publication,
                                    getCurrentDocument().getArea(),
                                    targetDocument.getId(),
                                    targetDocument.getLanguage());
                            targetDocument = builder.buildDocument(publication, currentAreaUrl);

                            if (targetDocument.exists()) {
                                rewriteLink(newAttrs, targetDocument, anchor, queryString);
                            } else {
                                setIgnoreAElement(true);
View Full Code Here

        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Resolving policy for webapp URL [" + webappUrl + "]");
        }

        Publication publication = getPublication(webappUrl);
        DocumentBuilder builder = publication.getDocumentBuilder();
        String url = null;
        try {
            if (builder.isDocument(publication, webappUrl)) {
                Document document = builder.buildDocument(publication, webappUrl);
                if (document.existsInAnyLanguage()) {
                    url = "/" + document.getArea() + document.getId();
                    if (getLogger().isDebugEnabled()) {
                        getLogger().debug("    Document exists");
                        getLogger().debug("    Document ID: [" + document.getId() + "]");
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.