Package org.apache.lenya.cms.publication

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


                    + "]");
        }

        Map objectModel = ContextHelper.getObjectModel(this.context);
        Request request = ObjectModelHelper.getRequest(objectModel);
        DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);

        start = end + 1;
       
        // Absolute vs. relative
        if (location.startsWith("//", start)) {
            // Absolute: get publication id
            start += 2;
            end = location.indexOf('/', start);
            if (end == -1) {
                throw new MalformedURLException("Malformed lenyadoc: URI: publication part not found ["
                        + location + "]");
            }
            String publicationId = location.substring(start, end);
            try {
                pub = factory.getPublication(publicationId);
            } catch (PublicationException e) {
                throw new MalformedURLException("Malformed lenyadoc: Publication [" + publicationId
                        + "] does not exist or could not be initialized");
            }
            if (pub == null || !pub.exists()) {
                throw new SourceException("The publication [" + publicationId + "] does not exist!");
            }

            // Area
            start = end + 1;
            end = location.indexOf('/', start);
            if (end == -1) {
                throw new MalformedURLException("Malformed lenyadoc: URI: cannot find area ["
                        + location + "]");
            }
            area = location.substring(start, end);

        } else if (location.startsWith("/", start)) {
            end += 1;
            // Relative: get publication id and area from page envelope
            try {
                pub = PublicationUtil.getPublication(this.manager, objectModel);
            } catch (PublicationException e) {
                throw new SourceException("Error getting publication id / area from page envelope ["
                        + location + "]");
            }
            if (pub != null && pub.exists()) {
                String url = ServletHelper.getWebappURI(request);
                area = new URLInformation(url).getArea();
            } else {
                throw new SourceException("Error getting publication id / area from page envelope ["
                        + location + "]");
            }
        } else {
            throw new MalformedURLException("Malformed lenyadoc: URI [" + location + "]");
        }

        // Language
        start = end + 1;
        end = location.indexOf('/', start);
        if (end == -1) {
            throw new MalformedURLException("Malformed lenyadoc: URI: cannot find language ["
                    + location + "]");
        }
        language = location.substring(start, end);

        // UUID
        start = end + 1;
        uuid = location.substring(start);

        Session session;
        try {
            session = RepositoryUtil.getSession(this.manager, request);
        } catch (RepositoryException e1) {
            throw new RuntimeException(e1);
        }

        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Creating repository source for URI [" + location + "]");
        }
        Document document;
        try {
            document = factory.get(pub, area, uuid, language);
        } catch (DocumentBuildException e) {
            throw new MalformedURLException("Malformed lenyadoc: Document [" + uuid + ":"
                    + language + "] could not be created.");
        }
View Full Code Here


     * @see org.apache.lenya.cms.site.SiteManager#sortAscending(org.apache.lenya.cms.publication.util.DocumentSet)
     */
    public SiteNode[] sortAscending(SiteNode[] nodes) throws SiteException {
        if (nodes.length > 0) {

            DocumentFactory map = nodes[0].getStructure().getPublication().getFactory();
            if (!check(map, new NodeSet(this.manager, nodes))) {
                throw new SiteException("The dependence relation is not a strict partial order!");
            }

            SiteNode[] sortedNodes = (SiteNode[]) Arrays.asList(nodes).toArray(new SiteNode[nodes.length]);
View Full Code Here

    public Part getPart(String name) {
        return (Part) getParameter(name);
    }

    protected DocumentFactory getDocumentFactory() {
        DocumentFactory factory = (DocumentFactory) getParameter(PARAMETER_FACTORY);
        Session session = getSession();
        if (factory == null || factory.getSession() != session) {
            factory = DocumentUtil.createDocumentFactory(this.manager, session);
            setParameter(PARAMETER_FACTORY, factory);
        }
        return factory;
    }
View Full Code Here

       
        String pubId = "test";
        String area = "authoring";
       
        Session lenyaSession = login("lenya");
        DocumentFactory lenyaFactory = DocumentUtil.createDocumentFactory(getManager(), lenyaSession);
        Publication lenyaPub = lenyaFactory.getPublication(pubId);
       
        SiteStructure lenyaSite = lenyaPub.getArea(area).getSite();
        lenyaSite.getRepositoryNode().lock();
       
        Session aliceSession = login("alice");
        DocumentFactory aliceFactory = DocumentUtil.createDocumentFactory(getManager(), aliceSession);
        Publication alicePub = aliceFactory.getPublication(pubId);
       
        SiteStructure aliceSite = alicePub.getArea(area).getSite();
        aliceSite.getRepositoryNode().lock();
       
        SiteNode lenyaNode = lenyaSite.getNodes()[1];
View Full Code Here

            return;
        }
       
        Document document = getSourceDocument();
        Publication publication = document.getPublication();
        DocumentFactory map = document.getFactory();
        SiteStructure liveSite = publication.getArea(Publication.LIVE_AREA).getSite();

        List missingDocuments = new ArrayList();

        ServiceSelector selector = null;
View Full Code Here

     */
    public void testXLinkCollection() throws PublicationException, AccessControlException,
            TransactionException, ServiceException {

        Session session = login("lenya");
        DocumentFactory map = DocumentUtil.createDocumentFactory(getManager(), session);

        Publication pub = getPublication("test");

        Document collectionDoc = createCollectionDocument(pub);

        CollectionWrapper collection = new CollectionWrapper(collectionDoc, getLogger());

        SiteStructure structure = pub.getArea("authoring").getSite();
        structure.getRepositoryNode().lock();

        SiteManager siteManager = null;
        ServiceSelector selector = null;
        try {
            selector = (ServiceSelector) getManager().lookup(SiteManager.ROLE + "Selector");
            siteManager = (SiteManager) selector.select(pub.getSiteManagerHint());

            siteManager.add("/collection", collection.getDelegate());
        } finally {
            selector.release(siteManager);
            getManager().release(selector);
        }

        Document doc = map.get(pub, Publication.AUTHORING_AREA, "/index", "en");
        collection.add(doc);
        collection.save();

        collection.getDelegate().getRepositoryNode().unlock();
        structure.getRepositoryNode().unlock();
View Full Code Here

    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters params)
            throws ProcessingException, SAXException, IOException {
        super.setup(resolver, objectModel, src, params);

        Request req = ObjectModelHelper.getRequest(objectModel);
        DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
        String webappUrl = ServletHelper.getWebappURI(req);
        URLInformation info = new URLInformation(webappUrl);
        try {
            Publication pub = factory.getPublication(info.getPublicationId());
            this.area = pub.getArea(info.getArea());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

        Request request = ObjectModelHelper.getRequest(objectModel);
        this.useIgnore = true;
        try {
            String currentUrl = getWebappUrl(params, objectModel);
            DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
            this.linkResolver = (LinkResolver) this.manager.lookup(LinkResolver.ROLE);
            this.rewriter = new UuidToUrlRewriter(currentUrl, this.linkResolver, factory);
           
            if (factory.isDocument(currentUrl)) {
                this.rewriter.setCurrentDocument(factory.getFromURL(currentUrl));
            }
           
        } catch (final Exception e) {
            throw new ProcessingException(e);
        }
View Full Code Here

        super.setup(_resolver, _objectModel, _source, _parameters);

        Request request = ObjectModelHelper.getRequest(_objectModel);
        try {
            Session session = RepositoryUtil.getSession(this.manager, request);
            DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
            this.rewriter = new UrlToUuidRewriter(factory);
        } catch (final Exception e1) {
            throw new ProcessingException(e1);
        }
    }
View Full Code Here

        super.setup(_resolver, _objectModel, _source, params);
        Request request = ObjectModelHelper.getRequest(_objectModel);

        try {
            Session session = RepositoryUtil.getSession(this.manager, request);
            DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
            String webappUrl = getWebappUrl(params, objectModel);
            URLInformation info = new URLInformation(webappUrl);
            String pubId = info.getPublicationId();
            this.rewriter = new IncomingLinkRewriter(factory.getPublication(pubId));
        } catch (final Exception e) {
            throw new RuntimeException(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.