Package org.apache.lenya.cms.publication

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


     */
    public void testResourceLinkRewriting() throws Exception {
        String documentId = "/testResourceLinkRewriting";
       
        Session session = login("lenya");
        DocumentFactory factory = DocumentUtil.createDocumentFactory(getManager(), session);

        Publication pub = getPublication("test");
       
        ResourceWrapperTest.createResource(factory, pub, documentId, getManager(), getLogger());
       
View Full Code Here


    public Object getAttribute(String name, Configuration modeConf, Map objectModel)
            throws ConfigurationException {
        Request request = ObjectModelHelper.getRequest(objectModel);
        try {
            DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
            LinkResolver linkResolver = (LinkResolver) this.manager.lookup(LinkResolver.ROLE);
            String currentUrl = ServletHelper.getWebappURI(request);
           
            UuidToUrlRewriter rewriter = new UuidToUrlRewriter(currentUrl, linkResolver, factory);
            if (factory.isDocument(currentUrl)) {
                rewriter.setCurrentDocument(factory.getFromURL(currentUrl));
            }
           
            return rewriter.rewrite(name);
           
        } catch (final Exception e) {
View Full Code Here

                    selector = (ServiceSelector) this.manager
                            .lookup(ResourceType.ROLE + "Selector");

                    documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);

                    DocumentFactory map = getDocumentFactory();
                    String path = doc.getPath();

                    resourceType = (ResourceType) selector.select(TYPE);
                    ResourceType.Sample sample = resourceType.getSample(resourceType.getSampleNames()[0]);
                    doc = documentManager.add(map, resourceType, sample.getUri(), getPublication(), doc
View Full Code Here

                String webappUrl = ServletHelper.getWebappURI(request);
                URLInformation info = new URLInformation(webappUrl);
                pubId = info.getPublicationId();
            }

            DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);

            String[] uris;

            if (factory.existsPublication(pubId)) {
                Publication pub = factory.getPublication(pubId);
                AllExistingSourceResolver resolver = new AllExistingSourceResolver();
                templateManager.visit(pub, path, resolver);
                uris = resolver.getUris();
            } else {
                uris = new String[0];
View Full Code Here

        getLogger().info("    Destination area:        [" + destinationArea + "]");
        getLogger().info("    Destination document ID: [" + _destinationDocumentId + "]");
        getLogger().info("    Destination language:    [" + _destinationLanguage + "]");

        Publication publication = getPublication("test");
        DocumentFactory map = getFactory();

        Document sourceDocument = map.get(publication,
                sourceArea,
                _sourceDocumentId,
                _sourceLanguage);
        Document destinationDocument = map.get(publication,
                destinationArea,
                _destinationDocumentId,
                _destinationLanguage);
/*
        publication.copyDocument(sourceDocument, destinationDocument);
View Full Code Here

     */
    protected Document getSourceDocument() {
        Document doc = (Document) getParameter(DOCUMENT);
        if (doc == null || doc.getFactory().getSession() != getSession()) {
            try {
                DocumentFactory factory = getDocumentFactory();
                String sourceUrl = getParameterAsString(SOURCE_URL);
                if (factory.isDocument(sourceUrl)) {
                    doc = factory.getFromURL(sourceUrl);
                    setParameter(DOCUMENT, doc);
                }
            } catch (DocumentBuildException e) {
                throw new RuntimeException(e);
            }
View Full Code Here

        Assert.notNull("language", lang);
        Assert.notNull("label", label);
        if (this.language2link.containsKey(lang)) {
            throw new RuntimeException("The language [" + lang + "] is already contained.");
        }
        DocumentFactory factory = getTree().getPublication().getFactory();
        Link link = new SiteTreeLink(factory, this, label, lang);
        this.language2link.put(lang, link);
        getTree().linkAdded(link);
        return link;
    }
View Full Code Here

        Publication publication = null;
        ContextUtility util = null;
        try {
            util = (ContextUtility) this.manager.lookup(ContextUtility.ROLE);
            Request request = util.getRequest();
            DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);

            URLInformation info = new URLInformation(webappUrl);
            String pubId = info.getPublicationId();

            if (pubId != null && factory.existsPublication(pubId)) {
                publication = factory.getPublication(pubId);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            if (util != null) {
View Full Code Here

            String[] steps = uri.split("/");
            String pubId = steps[steps.length - 4];
            String areaName = steps[steps.length - 2];
            try {
                Session session = RepositoryUtil.createSession(this.manager, null, false);
                DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
                Area area = factory.getPublication(pubId).getArea(areaName);
                SiteTreeImpl tree = new SiteTreeImpl(this.manager, area, getLogger());
                int treeRev = tree.getRevision();
                int rcmlRev = tree.getRevision(tree.getRepositoryNode());
                if (treeRev != rcmlRev) {
                    throw new IllegalStateException("Tree revision " + treeRev
View Full Code Here

        String area = tabGroup != null ? tabGroup : url.getArea();

        this.attributeHandlers.add(new AttributeHandler(ATTR_AREAS, area));
       
        try {
            DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
            String resourceType = factory.isDocument(webappUri) ?
                resourceType = factory.getFromURL(webappUri).getResourceType().getName()
                : null;
            this.attributeHandlers.add(new AttributeHandler(ATTR_RESOURCE_TYPES, resourceType));
        } catch (RepositoryException e) {
            throw new ProcessingException(e);
        }
View Full Code Here

TOP

Related Classes of org.apache.lenya.cms.publication.DocumentFactory

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.