Examples of URLInformation


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

     * If the link doesn't contain context information (publication ID, area), provide it.
     * @param link The link.
     * @param webappUrl The web application URL to extract the context information from..
     */
    protected void contextualize(Link link, String webappUrl) {
        URLInformation url = new URLInformation(webappUrl);
        if (link.getPubId() == null) {
            link.setPubId(url.getPublicationId());
        }
        if (link.getArea() == null) {
            link.setArea(url.getArea());
        }
    }
View Full Code Here

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

        if (getDocumentFactory().isDocument(sourceUrl)) {
            Document doc = factory.getFromURL(sourceUrl);
            preOrder = getPreOrder(doc.getLink().getNode());
        } else {
            preOrder = new ArrayList();
            URLInformation info = new URLInformation(getSourceURL());
            Publication pub = factory.getPublication(info.getPublicationId());
            Area area = pub.getArea(info.getArea());
            SiteStructure site = area.getSite();
            SiteNode[] topLevelNodes = site.getTopLevelNodes();
            for (int i = 0; i < topLevelNodes.length; i++) {
                preOrder.addAll(getPreOrder(topLevelNodes[i]));
            }
View Full Code Here

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

    }

    protected void handleLink(String linkUrl, AttributeConfiguration config, AttributesImpl newAttrs)
            throws Exception {

        URLInformation info = new URLInformation(this.currentUrl);
        if (linkUrl.startsWith("lenya-document:")) {

            String anchor = null;
            String url = null;

            int anchorIndex = linkUrl.indexOf("#");
            if (anchorIndex > -1) {
                url = linkUrl.substring(0, anchorIndex);
                anchor = linkUrl.substring(anchorIndex + 1);
            } else {
                url = linkUrl;
            }

            StringTokenizer tokenizer = new StringTokenizer(url, "?");
            String linkUri = tokenizer.nextToken();
            String queryString = null;
            String requiredExtension = null;
            if (tokenizer.hasMoreTokens()) {
                queryString = tokenizer.nextToken();
                Query query = new Query(queryString);
                requiredExtension = query.getValue(EXTENSION_PARAM);
                query.removeValue(EXTENSION_PARAM);
                queryString = query.toString();
            }

            LinkTarget target;
            if (this.currentDoc != null) {
                target = this.linkResolver.resolve(this.currentDoc, linkUri);
            } else {
                Link link = getAbsoluteLink(info, linkUri);
                target = this.linkResolver.resolve(this.factory, link.getUri());
            }

            if (target.exists() && target.getDocument().hasLink()) {
                Document targetDocument = target.getDocument();
                String extension = getExtension(targetDocument, requiredExtension);
                rewriteLink(newAttrs, config.attribute, targetDocument, anchor, queryString,
                        extension);
            } else if (info.getArea().equals(Publication.AUTHORING_AREA)) {
                markBrokenLink(newAttrs, config.attribute, linkUrl);
            } else {
                this.ignoreLinkElement = true;
            }
        } else {
            /*
             * This is legacy code. It rewrites links to non-document images (in resources/shared).
             * These images shouldn't be referenced in documents since this violates the separation
             * between content and layout.
             */
            String prefix = "/" + info.getPublicationId() + "/";
            if (linkUrl.startsWith(prefix)) {
                String pubUrl = linkUrl.substring(prefix.length());
                StringTokenizer tokenizer = new StringTokenizer(pubUrl, "/");
                String area = tokenizer.nextToken();

View Full Code Here

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

        Request _request = ObjectModelHelper.getRequest(_objectModel);
        try {
            Session session = RepositoryUtil.getSession(this.manager, _request);
            DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
            String url = ServletHelper.getWebappURI(_request);
            URLInformation info = new URLInformation(url);
            Publication pub = factory.getPublication(info.getPublicationId());
            Area area = pub.getArea(info.getArea());
            this.rewriter = new UrlToUuidRewriter(area);
        } catch (final Exception e1) {
            throw new ProcessingException(e1);
        }
    }
View Full Code Here

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

        Request request = ObjectModelHelper.getRequest(_objectModel);

        try {
            Session session = RepositoryUtil.getSession(this.manager, request);
            DocumentFactory factory = DocumentUtil.createDocumentFactory(this.manager, session);
            URLInformation info = new URLInformation(ServletHelper.getWebappURI(request));
            String pubId = info.getPublicationId();
            this.rewriter = new IncomingLinkRewriter(factory.getPublication(pubId));
        } catch (final Exception e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

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

            throws ProcessingException, SAXException, IOException {
        super.setup(resolver, objectModel, src, params);

        Request request = ObjectModelHelper.getRequest(objectModel);
        String url = ServletHelper.getWebappURI(request);
        URLInformation info = new URLInformation(url);

        String pubId = params.getParameter("pubId", info.getPublicationId());
        String areaId = params.getParameter("area", info.getArea());

        DocumentFactory factory = DocumentUtil.getDocumentFactory(this.manager, request);
        try {
            Publication pub = factory.getPublication(pubId);
            Area area = pub.getArea(areaId);
View Full Code Here

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

        }

    }

    protected Publication getPublication() throws PublicationException {
        String pubId = new URLInformation(getSourceURL()).getPublicationId();
        Publication pub = getDocumentFactory().getPublication(pubId);
        return pub;
    }
View Full Code Here

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

    /**
     * @return The publicationID from an URL.
     */
    private String getPublicationIDfromURL() {
        URLInformation info = new URLInformation(getSourceURL());
        return info.getPublicationId();
    }
View Full Code Here

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

                areaName = steps.nextToken();
                String prefix = pubId + "/" + areaName;
                relativePath = fullPath.substring(prefix.length());
            } else if (absolutePath.startsWith("/")) {
                String webappUrl = ServletHelper.getWebappURI(request);
                URLInformation info = new URLInformation(webappUrl);
                pubId = info.getPublicationId();
                areaName = info.getArea();
                relativePath = absolutePath;
            } else {
                throw new MalformedURLException("The path [" + absolutePath
                        + "] must start with at least one slash.");
            }
View Full Code Here

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

                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 {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.