Package org.apache.lenya.cms.publication

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


        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


            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

        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++) {

                    documentId =
                        fileMapper.getDocumentId(
                            publication,
                            area,
                            inconsistentFiles[i]);
                    language = fileMapper.getLanguage(inconsistentFiles[i]);
                    String url = null;
                    if (language != null) {
                        url =
                            builder.buildCanonicalUrl(
                                publication,
                                area,
                                documentId,
                                language);
                    } else {
                        url =
                            builder.buildCanonicalUrl(
                                publication,
                                area,
                                documentId);
                    }
                    documents.add(builder.buildDocument(publication, url));
                }
            } catch (IOException e) {
                throw new ProcessingException(e);
            } catch (DocumentDoesNotExistException e) {
                throw new ProcessingException(e);
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

        Publication _publication = this.getPublication();

        ServiceSelector selector = null;
        SiteManager siteManager = null;
        DocumentBuilder docBuilder = null;
        Vector docs = new Vector();
        Vector checkedOut = new Vector();
        
        String request = getSourceURL();
        if(request.endsWith(".html"))
          request = request.substring(0,request.indexOf(".html"));
        if(!request.endsWith("/"))
          request = request+"/";
        try {
            //get Parameters for RC
            String publicationPath = _publication.getDirectory().getCanonicalPath();
            RCEnvironment rcEnvironment = RCEnvironment.getInstance(_publication.getServletContext()
                    .getCanonicalPath());
            String rcmlDirectory = rcEnvironment.getRCMLDirectory();
            rcmlDirectory = publicationPath + File.separator + rcmlDirectory;
            String backupDirectory = rcEnvironment.getBackupDirectory();
            backupDirectory = publicationPath + File.separator + backupDirectory;

            // Initialize Revision Controller
            RevisionController rc = new RevisionController(rcmlDirectory, backupDirectory, publicationPath);         
         
          selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
            siteManager = (SiteManager) selector.select(_publication.getSiteManagerHint());
            Document[] documents = siteManager.getDocuments(getDocumentIdentityMap(),_publication,this.getArea());

            selector = (ServiceSelector) this.manager.lookup(DocumentBuilder.ROLE + "Selector");
            docBuilder = (DocumentBuilder) selector.select(_publication.getDocumentBuilderHint());
           
            for(int i=0; i< documents.length; i++) {
              String test = documents[i].getCanonicalWebappURL().replaceFirst("/[^/]*.html","");
                if(!test.endsWith("/"))
                  test = test+"/";
              if(test.equals(request)){
                    docs.add(documents[i]);

                String filename = documents[i].getFile().getCanonicalPath();
                filename = filename.substring(publicationPath.length());
                    RCMLEntry entry = rc.getRCML(filename).getLatestEntry();                   
                    if ((entry != null) && (entry.getType() == RCML.co) )
                      checkedOut.add(entry);
                    else
                      checkedOut.add(null);
                    //get additional language documents
                    String[] langs = documents[i].getLanguages();
                    for(int j=0; j< langs.length; j++) {
                      if(!(langs[j].equals(documents[i].getLanguage()))) {
                        String url = documents[i].getCanonicalWebappURL().replaceFirst(".html$","_"+langs[j]+".html");
                        Document langDoc = docBuilder.buildDocument(documents[i].getIdentityMap(),_publication,url);
                        docs.add(langDoc);

                        filename = langDoc.getFile().getCanonicalPath();
                        filename = filename.substring(publicationPath.length());
                            entry = rc.getRCML(filename).getLatestEntry();                   
View Full Code Here

        Publication _publication = this.getPublication();

        ServiceSelector selector = null;
        SiteManager siteManager = null;
        DocumentBuilder docBuilder = null;
        Vector docs = new Vector();
        Vector checkedOut = new Vector();
        
        String request = getSourceURL();
View Full Code Here

            PublicationFactory factory = PublicationFactory.getInstance(getLogger());
            Publication publication = factory.getPublication(this.manager, webappUrl);
            if (publication.exists()) {

                ServiceSelector selector = null;
                DocumentBuilder builder = null;
                try {
                    selector = (ServiceSelector) this.manager.lookup(DocumentBuilder.ROLE
                            + "Selector");
                    builder = (DocumentBuilder) selector.select(publication
                            .getDocumentBuilderHint());
                    return builder.isDocument(publication, webappUrl);
                } finally {
                    if (selector != null) {
                        if (builder != null) {
                            selector.release(builder);
                        }
View Full Code Here

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

        ServiceSelector selector = null;
        DocumentBuilder builder = null;
        try {
            selector = (ServiceSelector) this.manager.lookup(DocumentBuilder.ROLE + "Selector");
            builder = (DocumentBuilder) selector.select(originalTargetDocument.getPublication()
                    .getDocumentBuilderHint());

            String newTargetUrl = builder.buildCanonicalUrl(newTargetDocument.getPublication(),
                    newTargetDocument.getArea(),
                    newTargetDocument.getId() + childString,
                    targetDocument.getLanguage());
            return newTargetUrl;
        } catch (ServiceException e) {
View Full Code Here

        else if (path.length() <= 2 || !path.startsWith("/") || path.endsWith("/")) {
            addErrorMessage("invalid-path");
        }
        else {
            String[] steps = path.substring(1).split("/");
            DocumentBuilder builder = pub.getDocumentBuilder();
            for (int i = 0; i < steps.length; i++) {
                if (!builder.isValidDocumentName(steps[i])) {
                    addErrorMessage("node-name-special-characters");
                }
            }
            if (steps.length > 1) {
                String parentPath = path.substring(0, path.lastIndexOf("/"));
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.