Package org.apache.lenya.cms.publication

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


                    Policy policy = this.policyManager.getPolicy(this.accreditableManager,
                            normalizedUrl);
                    useSsl = policy.isSSLProtected();
                }

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

                Publication pub = null;
                if (pubId != null) {
                    pub = getPublication(pubId);
                }
View Full Code Here


     * @param pub The publication to use for proxy resolving.
     * @param ssl If the URL uses SSL.
     * @return A link URL.
     */
    protected String rewriteLink(String linkUrl, Publication pub, boolean ssl) {
        URLInformation info = new URLInformation(linkUrl);
        String rewrittenUrl;
        String areaName = info.getArea();

        // valid area
        if (areaName != null && hasArea(pub, areaName)) {
            Proxy proxy = pub.getProxy(areaName, ssl);
            rewrittenUrl = proxy.getUrl() + info.getDocumentUrl();
        }

        // invalid area
        else {
            Proxy proxy = getGlobalProxies().getProxy(ssl);
View Full Code Here

        this.factory = factory;
    }

    public boolean matches(String url) {
        if (url.startsWith("/")) {
            URLInformation info = new URLInformation(url);
            String pubId = info.getPublicationId();
            String area = info.getArea();
            if (pubId != null && area != null) {
                if (this.factory.existsPublication(pubId)) {
                    try {
                        Publication pub = this.factory.getPublication(pubId);
                        if (Arrays.asList(pub.getAreaNames()).contains(area)) {
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);

        String webappUrl = getWebappUrl(params, objectModel);
        URLInformation url = new URLInformation(webappUrl);
        this.area = url.getArea();
    }
View Full Code Here

        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

    public String rewrite(String linkUrl) {

        String rewrittenUrl = null;

        URLInformation info = new URLInformation(this.currentUrl);
        if (linkUrl.startsWith(SCHEME)) {

            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;
            try {
                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);
                    rewrittenUrl = getWebappUrl(targetDocument, anchor, queryString, extension);
                } else {
                    rewrittenUrl = null;
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        } 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

     * 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

     *      org.apache.excalibur.source.SourceResolver)
     */
    protected Object generateCacheKey(String webappUrl, SourceResolver resolver)
            throws AccessControlException {

        URLInformation info = new URLInformation(webappUrl);

        String publicationId = info.getPublicationId();
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Using first URL step (might be publication ID) as cache key: ["
                    + publicationId + "]");
        }

View Full Code Here

        // remove leading slash
        String url = webappUrl.substring(1);

        if (url.length() > 0) {

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

            File contextDir = getContext();
            PublicationFactory factory = PublicationFactory.getInstance(getLogger());
            try {
                publication = factory.getPublication(webappUrl, contextDir);
View Full Code Here

     */
    protected void initParameters() {
        super.initParameters();

        try {
            URLInformation info = new URLInformation(getSourceURL());
            setParameter(COMPLETE_AREA, info.getCompleteArea());

            DocumentIdentityMap map = (DocumentIdentityMap) getUnitOfWork().getIdentityMap();
            Document sourceDocument = map.getFromURL(getSourceURL());
            setParameter(DOCUMENT, sourceDocument);

View Full Code Here

TOP

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

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.