Package com.volantis.mcs.utilities

Examples of com.volantis.mcs.utilities.MarinerURL


     * not absolute.
     */
    public void testMakeProjectRelativeGlobalFails() {
        RuntimeProject project = createGlobalProject();
        try {
            project.makeProjectRelativePath(new MarinerURL("file:/b/c/d.mimg"), true);
            fail("Should fail to create project relative path");
        } catch (UnsupportedOperationException expected) {
        }
    }
View Full Code Here


                               MarinerURL documentURL,
                               String fragmentationSpecifier)
        throws DissectionException {

        if (documentURL.isReadOnly()) {
            documentURL = new MarinerURL(documentURL);
        }

        // Set the request parameter.
        documentURL.setParameterValue(URLConstants.FRAGMENTATION_PARAMETER,
                                      fragmentationSpecifier);

        // Get the URLRewriter to use to encode session information in the
        // URL and use it, do this before stripping the URL as otherwise it is
        // not done properly.
        MarinerRequestContext requestContext = context.getRequestContext();
        URLRewriter sessionURLRewriter = context.getSessionURLRewriter();
        MarinerURL sessionURL
            = sessionURLRewriter.mapToExternalURL(requestContext,
                                                  documentURL);

        if (logger.isDebugEnabled()) {
            logger.debug("Encoded url is "
                         + sessionURL.getExternalForm());
        }

        // As the link we generate is always back to this page we can reduce the
        // overhead by removing the protocol, authority and all but the last part
        // of the path. We do this before URL rewriting as we have no idea what
        // the URL will look like afterwards.
        sessionURL.setProtocol(null);
        sessionURL.setAuthority(null);
        String path = sessionURL.getPath();
        int index = path.lastIndexOf('/');
        if (index != -1) {
            path = path.substring(index + 1);
            sessionURL.setPath(path);
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Relative url is "
                         + sessionURL.getExternalForm());
        }

        // perform any URL rewriting that might be needed
        PageURLRewriter urlRewriter = context.getVolantisBean().
                getLayoutURLRewriter();
        MarinerURL externalURL =
                urlRewriter.rewriteURL(context.getRequestContext(),
                sessionURL,
                PageURLDetailsFactory.createPageURLDetails(PageURLType.FRAGMENT));

        return externalURL;
View Full Code Here

        // Get the URLRewriter to use to encode session information in the
        // URL and use it, do this before stripping the URL as otherwise it is
        // not done properly.
        MarinerRequestContext requestContext = pageContext.getRequestContext();
        URLRewriter sessionURLRewriter = pageContext.getSessionURLRewriter();
        MarinerURL sessionURL
            = sessionURLRewriter.mapToExternalURL(requestContext,
                           pageContext.getRequestURL(true));

        if (logger.isDebugEnabled()) {
            logger.debug("Encoded url is "
                         + sessionURL.getExternalForm());
        }

        // As the link we generate is always back to this page we can reduce the
        // overhead by removing the protocol, authority and all but the last part
        // of the path. We do this before URL rewriting as we have no idea what
        // the URL will look like afterwards.
        sessionURL.setProtocol(null);
        sessionURL.setAuthority(null);
        String path = sessionURL.getPath();
        int index = path.lastIndexOf('/');
        if (index != -1) {
            path = path.substring(index + 1);
            sessionURL.setPath(path);
        }

        if (logger.isDebugEnabled()) {
            logger.debug("Relative url is "
                         + sessionURL.getExternalForm());
        }

        // perform any URL rewriting that might be needed
        URLRewriter urlRewriter
            = pageContext.getVolantisBean().getURLRewriter();
        MarinerURL externalURL =
            urlRewriter.mapToExternalURL(requestContext, sessionURL);
           
        // Split the URL up
        SessionIdentifierSearcher searcher
             = SessionIdentifierSearcherFactory.create();           
        SessionIdentifierURL splitURL
             = searcher.getJSessionId(externalURL.getExternalForm());
           
        // If present, add jsessionid to the string table  
        if (splitURL.hasJsessionid()) {
            references.createReference(splitURL.getJsessionid());
            if (logger.isDebugEnabled()) {
View Full Code Here

        // TODO: avoid rendundant validation and consequent...
        // TODO: avoid redundant logging of warnings
        InternalVariablePolicyBuilder internalVariablePolicyBuilder =
                (InternalVariablePolicyBuilder) variablePolicyBuilder;
        internalVariablePolicyBuilder.validateAndPrune();
        MarinerURL baseURL = getBaseURL(actualProject, policyBuilder,
                logicalProject);

        activateAlternateReferences(logicalProject, variablePolicyBuilder,
                baseURL);
View Full Code Here

    public MarinerURL rewriteAssetURL(MarinerRequestContext requestContext,
                                      Asset asset,
                                      AssetGroup assetGroup,
                                      MarinerURL marinerURL)
        throws RepositoryException {
        MarinerURL rewritten = marinerURL;

        if (preRewriter != null) {
            rewritten = preRewriter.rewriteAssetURL(requestContext,
                                                    asset,
                                                    assetGroup,
                                                    marinerURL);
        }

        if (!(asset instanceof LinkAsset)) {
            String plain = rewritten.getExternalForm();
            String encoded = getEncodedURI(plain);
            ApplicationContext ac =
                ContextInternals.getApplicationContext(requestContext);
            PackageResources pr = ac.getPackageResources();

            if (pr != null) {
                boolean onClientSide = false;
                if (assetGroup != null) {
                    onClientSide = (assetGroup.getLocationType() ==
                            AssetGroup.ON_DEVICE);
                }
                if (!onClientSide && asset instanceof ImageAsset) {
                    onClientSide = ((ImageAsset) asset).isLocalSrc();
                }
               
                PackageResources.Asset prAsset =
                    new PackageResources.Asset(plain, onClientSide);

                pr.addAssetURLMapping(encoded, prAsset);

                rewritten = new MarinerURL(encoded);
            } else {
                throw new NullPointerException(
                    "PackageResources must be set in the application " +
                    "context when using " + getClass().getName());
            }
View Full Code Here

                            URL url = null;
                            URLConnection connection;

                            try {
                                url = context.
                                    getAbsoluteURL(new MarinerURL(assetURL));

                                // Test to ensure that this asset exists
                                // before adding it to the package
                                connection = url.openConnection();
View Full Code Here

     *
     * @param url the URL to be checked
     * @return true if the url is fully qualified
     */
    protected boolean isFullyQualifiedURL(String url) {
        MarinerURL theURL = new MarinerURL(url);

        return (theURL.getProtocol() != null);
    }
View Full Code Here

        }
    }

    public boolean startElement(String systemId) {
        boolean changed;
        MarinerURL enclosingBaseURL = getBaseURL();
        if (enclosingBaseURL == null ||
                !enclosingBaseURL.getExternalForm().equals(systemId)) {
            MarinerURL baseURL = new MarinerURL(systemId);
            stack.push(baseURL);
            changed = true;
        } else {
            stack.push(enclosingBaseURL);
            changed = false;
View Full Code Here

        return changed;
    }

    public void endElement(String systemId) {
        MarinerURL url = (MarinerURL) stack.pop();
        String popped = url.getExternalForm();

        MarinerURL urlToCompare = new MarinerURL(systemId);
        if (!urlToCompare.getExternalForm().equals(popped)) {
            throw new IllegalStateException("Expected to pop '" + systemId +
                    "' but found '" + popped + "'");
        }
    }
View Full Code Here

                    "' but found '" + popped + "'");
        }
    }

    public MarinerURL getBaseURL() {
        MarinerURL result;
        if (stack.isEmpty()) {
            result = null;
        } else {
            result = (MarinerURL) stack.peek();
        }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.utilities.MarinerURL

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.