Package com.volantis.mcs.utilities

Examples of com.volantis.mcs.utilities.MarinerURL


            brandable = false;
        } else {
            unprefixedName = name;
        }

        MarinerURL url = new MarinerURL(unprefixedName);

        RuntimeProject normalizedProject;
        String normalizedName = null;
        if (url.isAbsolute()) {
            // An absolute URL so try and find the project, look in the
            // containing project first and then in the others. If the project
            // was not already known then defer loading it until the policy
            // has been retrieved as that will reduce the number of times that
            // the remote server gets hit.
            RuntimeProject project = projectManager.queryProject(unprefixedName,
                    containingProject);

            if (project == null) {
                // Assume that it is in the global project for now.
                project = projectManager.getGlobalProject();
            }

            normalizedProject = project;

            normalizedName = normalizeURLToName(normalizedProject, url);

            // Specifying an absolute URL in the input means that it is not
            // brandable.
            brandable = false;
        } else {
            if (url.getPathType() == MarinerURL.HOST_RELATIVE_PATH) {

                // A host relative path, i.e. a project relative reference.
                normalizedProject = containingProject;
                normalizedName = unprefixedName;

            } else {
                // Resolve against the base URL, the result must be either
                // absolute, or host relative.
                url = new MarinerURL(baseURL, url);
                if (url.isAbsolute()) {

                    // Get the project for the url.
                    String urlAsString = url.getExternalForm();
                    RuntimeProject project =
                            projectManager.getProject(urlAsString, null);

                    // Now check to make sure that the resulting URL is still
                    // within the same project as it started from as document
                    // relative paths cannot move outside the project.
                    if (containingProject.getContainsOrphans()) {
                        // The project is either local default or global
                        // project so the policies they contain are defined by
                        // exclusion so in order to determine whether a policy
                        // is in one of these it is necessary to check to see
                        // if it is in another project.
                        if (project == null) {
                            // The referenced policy is still in the global
                            // project so use the abolute URL as the normalized
                            // name.
                            normalizedName = urlAsString;
                        } else {
                            // The referenced policy is in another project which
                            // is invalid, so set the name to null so an
                            // appropriate exception will be thrown below.
                            normalizedName = null;
                        }
                    } else {

                        if (project == containingProject ||
                                containingProject.extendsProject(project)) {

                            // Ask the project that contains it to make the
                            // URL project relative.
                            normalizedName = project.makeProjectRelativePath(
                                    url, true);

                        } else {
                            // The project is not the same as the containing
                            // one and does is not extended by the containing
                            // one so set the name to null so that it fails
                            // further on.
                            normalizedName = null;
                        }
                    }
                } else if (url.containsHostRelativePath()) {
                    // The base URL must have been host relative so the
                    // resolved URL is also host relative and so it must
                    // belong in the current project.
                    //
                    // Note: This relies on the MarinerURL detecting when a
                    // relative path is invalid, i.e. contains .. that attempt
                    // to take it above the root URL. Apparently there is a
                    // problem with that.
                    normalizedName = url.getExternalForm();

                } else {
                    throw new IllegalStateException("Resolving " +
                            unprefixedName +
                            " against " + baseURL + " resulted in " +
                            url.getExternalForm() + " which is not absolute");
                }

                // If the resulting URL could not be mapped to a project
                // relative URL, because it moved to another project, then
                // fail.
                if (normalizedName == null) {
                    throw new IllegalStateException(
                            "Document relative path " +
                            "cannot move outside project, when '" +
                            unprefixedName + "' is resolved relative to '" +
                            baseURL.getExternalForm() + "' the result '" +
                            url.getExternalForm() +
                            "' is not within project '" + containingProject +
                            "'");
                }

                // The normalized project is the same as the containing
View Full Code Here


            RuntimeProject logicalProject) {

        ButtonImagePolicyBuilder buttonBuilder =
                (ButtonImagePolicyBuilder) policyBuilder;

        MarinerURL baseURL = getBaseURL(actualProject, policyBuilder,
                logicalProject);

        PolicyReference reference;

        reference = buttonBuilder.getUpPolicy();
View Full Code Here

            RuntimeProject logicalProject) {

        RolloverImagePolicyBuilder rolloverBuilder =
                (RolloverImagePolicyBuilder) policyBuilder;

        MarinerURL baseURL = getBaseURL(actualProject, policyBuilder,
                logicalProject);

        PolicyReference reference;

        reference = rolloverBuilder.getNormalPolicy();
View Full Code Here

    public MarinerURL rewriteAssetURL(MarinerRequestContext requestContext,
                                      Asset asset,
                                      AssetGroup assetGroup,
                                      MarinerURL marinerURL)
        throws RepositoryException {
        MarinerURL url = marinerURL;
        int i;
        int size = rewriters.size();
        AssetURLRewriter rewriter;

        // Execute the chain of rewriters to generate the final asset URL
View Full Code Here

                expectations);

        locatedProjectMock = new RuntimeProjectMock("locatedProjectMock",
                expectations);

        absoluteBaseURL = new MarinerURL("file:/a/b/");

        globalProjectMock = new RuntimeProjectMock("globalProjectMock",
                expectations);

        // =====================================================================
View Full Code Here

        locatedProjectMock.expects.getContainsOrphans().returns(false).any();

        // The located project expects to be asked to convert an absolute URL
        // into a project relative one.
        locatedProjectMock.expects
                .makeProjectRelativePath(new MarinerURL("file:/fred.mimg"), true)
                .returns("/fred.mimg").any();

        // =====================================================================
        //   Test Expectations
        // =====================================================================
View Full Code Here

                .returns(projectMock);

        // The project expects to be asked to convert an absolute path into
        // a project relative one.
        projectMock.expects.makeProjectRelativePath(
                new MarinerURL("file:/a/b/fred.mimg"), true)
                .returns("/b/fred.mimg").atLeast(1);

        // =====================================================================
        //   Test Expectations
        // =====================================================================
View Full Code Here

                .returns(projectMock);

        // The project expects to be asked to convert an absolute path into
        // a project relative one.
        projectMock.expects.makeProjectRelativePath(
                new MarinerURL("file:/a/b/fred.mimg"), true)
                .returns("/b/fred.mimg").atLeast(1);

        // =====================================================================
        //   Test Expectations
        // =====================================================================
View Full Code Here

                .returns(true).any();

        // The project expects to be asked to convert an absolute path into
        // a project relative one.
        locatedProjectMock.expects.makeProjectRelativePath(
                new MarinerURL("file:/a/b/fred.mimg"), true)
                .returns("/b/fred.mimg").atLeast(1);

        // =====================================================================
        //   Test Expectations
        // =====================================================================
View Full Code Here

                .returns(projectMock);

        // The project expects to be asked to convert an absolute path into
        // a project relative one.
        projectMock.expects.makeProjectRelativePath(
                new MarinerURL("file:/a/b/fred.mimg"), true)
                .returns("/b/fred.mimg").atLeast(1);

        // =====================================================================
        //   Test Expectations
        // =====================================================================
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.