Package org.apache.lenya.cms.publication

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


     * Link test.
     * @throws Exception
     */
    public void testLinks() throws Exception {

        Publication pub = getPublication("test");
        Area area = pub.getArea("authoring");
        SiteStructure site = area.getSite();

        Document source = site.getNode("/index").getLink("en").getDocument();
        Document target = site.getNode("/tutorial").getLink("en").getDocument();

View Full Code Here


     * Test links across publications.
     * @throws Exception
     */
    public void testInterPublicationLinks() throws Exception {

        final Publication defaultPub = getPublication("default");
        final Document[] docs = defaultPub.getArea(Publication.AUTHORING_AREA).getDocuments();
        if (docs.length == 0) {
            getLogger().warn("To run this test, the default publication has to contain documents.");
            return;
        }

        final Document source = docs[0];

        final Publication pub = getPublication("test");
        final Area area = pub.getArea("authoring");
        final SiteStructure site = area.getSite();

        final Document target = site.getNode("/index").getLink("en").getDocument();
        final String queryString = "?format=xhtml";
        final String baseLink = "lenya-document:" + target.getUUID() + ",lang="
View Full Code Here

     * @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
     */
    protected void initParameters() {
        super.initParameters();

        Publication _publication = this.getPublication();

        ServiceSelector siteManagerSelector = null;
        SiteManager siteManager = 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 + "/";
        if (request.indexOf("webdav") > -1) {
            request = request.replaceFirst("webdav", "authoring");
        }
        try {

            siteManagerSelector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE
                    + "Selector");
            siteManager = (SiteManager) siteManagerSelector.select(_publication.getSiteManagerHint());
            Document[] documents = siteManager.getDocuments(getDocumentFactory(),
                    _publication,
                    Publication.AUTHORING_AREA);

            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]);

                    Node node = documents[i].getRepositoryNode();
                    if (node.isCheckedOut()) {
                        checkedOut.add(node.getCheckoutUserId());
                    }
                    else {
                        checkedOut.add(null);
                    }
                }
            }

      //FIXME: This is a workaround for the error
      //  "This usecase can only be invoked on documents!"
      // triggered in (superclass) DocumentUsecase.doCheckPreconditions()
      // when the usecase parameter "document" is not set properly.
      if (docs.size() > 0) {
    setParameter(DOCUMENT, docs.get(0));
      }
            setParameter(DOCUMENTS, docs);
            setParameter(RC, checkedOut);
            setParameter(SOURCEURL, request);
            SimpleDateFormat format = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss zzz");
            setParameter(DATEFORMAT, format);
            Date rootModDate = new Date();
            setParameter("rootModDate", rootModDate);
            String defaultLang = _publication.getDefaultLanguage();
            setParameter("defaultLang", defaultLang);

        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
View Full Code Here

            assertNotNull(this.accessControllerResolver);
            getLogger().info(
                    "Using access controller resolver: ["
                            + this.accessControllerResolver.getClass() + "]");

            Publication pub = getPublication(session, pubId);
            getLogger().info("Resolve access controller");
            getLogger().info(
                    "Publication directory: [" + pub.getDirectory().getAbsolutePath() + "]");

            String url = "/" + pubId + "/authoring/index.html";
            controller = (DefaultAccessController) ((PublicationAccessControllerResolver) this.accessControllerResolver)
                    .resolveAccessController(url);
View Full Code Here

            throws ExecutionException {
        super(manager);

        log.debug("Creating CocoonTaskWrapper");

        Publication publication;
        try {
            publication = PublicationUtil.getPublication(manager, objectModel);
        } catch (Exception e) {
            throw new ExecutionException(e);
        }
View Full Code Here

     * Returns the publication.
     * @return A publication.
     * @throws ExecutionException when something went wrong.
     */
    public Publication getPublication() throws ExecutionException {
        Publication publication;
        try {
            publication = PublicationUtil.getPublication(this.manager,
                    get(Task.PARAMETER_PUBLICATION_ID));
        } catch (PublicationException e) {
            throw new ExecutionException(e);
View Full Code Here

            if (!document.getArea().equals(Publication.AUTHORING_AREA)) {
                addErrorMessage("This usecase can only be invoked from the authoring area.");
                return;
            }

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

            List missingDocuments = new ArrayList();

            ServiceSelector selector = null;
            SiteManager siteManager = null;
            try {
                selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
                siteManager = (SiteManager) selector.select(publication.getSiteManagerHint());

                if (!liveSite.contains(document.getPath())) {
                    DocumentLocator liveLoc = document.getLocator().getAreaVersion(
                            Publication.LIVE_AREA);
                    DocumentLocator[] requiredNodes = siteManager
View Full Code Here

     * @return The documents in the authoring area.
     * @throws PublicationException if an error occurs.
     * @throws SiteException if an error occurs.
     */
    protected Document[] getDocuments() throws PublicationException, SiteException {
        Publication publication = getPublication();
        DocumentFactory identityMap = getDocumentFactory();
        Document[] documents;

        ServiceSelector selector = null;
        SiteManager siteManager = null;
        try {
            selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
            siteManager = (SiteManager) selector.select(publication.getSiteManagerHint());
            documents = siteManager.getDocuments(identityMap, publication,
                    Publication.AUTHORING_AREA);
        } catch (ServiceException e) {
            throw new RuntimeException(e);
        } finally {
View Full Code Here

                if (getLogger().isDebugEnabled()) {
                    getLogger().debug(
                            "Convert links: No XPaths for resource type [" + type.getName() + "]");
                }
            } else {
                Publication pub = examinedDocument.getPublication();
                LinkRewriter incomingRewriter = new IncomingLinkRewriter(pub);
                LinkRewriter urlToUuidRewriter = new UrlToUuidRewriter(examinedDocument.getFactory());

                org.w3c.dom.Document xml = DocumentHelper.readDocument(examinedDocument
                        .getInputStream());

                for (int xPathIndex = 0; xPathIndex < xPaths.length; xPathIndex++) {
                    if (getLogger().isDebugEnabled()) {
                        getLogger()
                                .debug("Convert links: Check XPath [" + xPaths[xPathIndex] + "]");
                    }
                    NodeList nodes = XPathAPI.selectNodeList(xml, xPaths[xPathIndex]);
                    for (int nodeIndex = 0; nodeIndex < nodes.getLength(); nodeIndex++) {
                        Node node = nodes.item(nodeIndex);
                        if (node.getNodeType() != Node.ATTRIBUTE_NODE) {
                            throw new RuntimeException("The XPath [" + xPaths[xPathIndex]
                                    + "] may only match attribute nodes!");
                        }
                        Attr attribute = (Attr) node;
                        final String url = attribute.getValue();
                        if (getLogger().isDebugEnabled()) {
                            getLogger().debug("Convert links: Check URL [" + url + "]");
                        }
                        final String originalUrl = url.startsWith(prefix) ? url.substring(prefix.length()) : url;
                        final String srcPubUrl;
                        if (incomingRewriter.matches(originalUrl)) {
                            srcPubUrl = incomingRewriter.rewrite(originalUrl);
                        } else {
                            srcPubUrl = originalUrl;
                        }
                        final String srcPubPrefix = "/" + srcPub.getId() + "/";
                        if (srcPubUrl.startsWith(srcPubPrefix)) {
                            final String destPubUrl = "/" + pub.getId() + "/" + srcPubUrl.substring(srcPubPrefix.length());
                            if (urlToUuidRewriter.matches(destPubUrl)) {
                                String rewrittenUrl = urlToUuidRewriter.rewrite(destPubUrl);
                                attribute.setValue(rewrittenUrl);
                                linksRewritten = true;
                            }
View Full Code Here

    public AccessController doResolveAccessController(String webappUrl)
            throws AccessControlException {
        getLogger().debug("Resolving controller for URL [" + webappUrl + "]");

        AccessController controller = null;
        Publication publication = getPublication(webappUrl);

        if (publication != null) {
            String publicationUrl = webappUrl.substring(("/" + publication.getId()).length());
            controller = resolveAccessController(publication, publicationUrl);
        }
        return controller;
    }
View Full Code Here

TOP

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

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.