Package com.volantis.mcs.runtime

Examples of com.volantis.mcs.runtime.RuntimeProject


            expression = parser.parse(unquotedExpression);
        } catch (ExpressionException e) {
            throw new ExtendedRuntimeException(e);
        }

        RuntimeProject project = projectProvider.getCurrentProject();
        String brandName = getCurrentBrandName();
        return new RuntimePolicyReferenceExpression(project,
                baseURLProvider.getBaseURL(), brandName, expression,
                unquotedExpression);
    }
View Full Code Here


                }

                // Iterate over the projects trying to find the project that
                // contains the policy. If one could be found then it is
                // returned immediately.
                RuntimeProject project;
                for (int i = 0; i < projects.size(); i++) {
                    project = (RuntimeProject) projects.get(i);
                    if (project != bestGuess &&
                            project.containsPolicy(policyURLAsString)) {
                        return project;
                    }
                }

                // The project could not be found so try and load it if
                // requested.
                if (loadProject) {
                    RuntimeProjectConfiguration configuration = null;
                    try {
                        configuration = projectLoader.loadProjectConfiguration(
                                policyURLAsString, optimizer);
                    } catch (IOException e) {
                        // load failed, keep configuration null.
                        LOGGER.warn(
                            "failed-to-load-project", policyURLAsString, e);
                    } catch (JiBXException e) {
                        // load failed, keep configuration null.
                        LOGGER.warn(
                            "failed-to-load-project", policyURLAsString, e);
                    }
                    if (configuration == null) {
                        project = null;
                    } else {
                        project = buildProject(configuration);
                        final RuntimeProject existingProject =
                            getProjectWithSameAlias(project, projects);
                        if (existingProject != null) {
                            // we have an existing project that shares an alias
                            // with the new one, so lets us the existing project
                            // and add an alias to it so next time we'll find
                            // it easier
                            project = existingProject;
                            final String alias =
                                createAlias(policyURLAsString, existingProject);
                            existingProject.addPolicyRootAlias(alias);
                        } else {
                            // Need to add the project to the list of existing
                            // projects.
                            synchronized (this) {
                                // Check to make sure that the projects do not
View Full Code Here

     * @return the first project that has a matching alias or null if no such
     * project exist.
     */
    private RuntimeProject getProjectWithSameAlias(final RuntimeProject project,
                                                   final List projects) {
        RuntimeProject result = null;
        final Set aliases = project.getPolicyRootAliases();
        for (Iterator projectsIter = projects.iterator();
                projectsIter.hasNext() && result == null; ) {
            final RuntimeProject other = (RuntimeProject) projectsIter.next();
            final Set otherAliases = new HashSet(other.getPolicyRootAliases());
            for (Iterator aliasesIter = aliases.iterator();
                    aliasesIter.hasNext() && result == null;){
                if (otherAliases.contains(aliasesIter.next())) {
                    result = other;
                }
View Full Code Here

     */
    private void ensureNoOverlaps(RuntimeProject project, List projects) {
        final Set aliases = project.getPolicyRootAliases();
        for (Iterator projectsIter = projects.iterator();
                projectsIter.hasNext(); ) {
            final RuntimeProject other = (RuntimeProject) projectsIter.next();
            final Set otherAliases = other.getPolicyRootAliases();
            for (Iterator aliasesIter = aliases.iterator();
                    aliasesIter.hasNext();){
                final String alias = (String) aliasesIter.next();
                for (Iterator otherAliasesIter = otherAliases.iterator();
                        otherAliasesIter.hasNext();) {
View Full Code Here

            RuntimeProjectConfiguration configuration) {

        // todo detect cycles.
        // Resolve base project.
        String baseProjectName = configuration.getFallbackProjectName();
        RuntimeProject baseProject;
        if (baseProjectName != null) {
            String location = configuration.getLocation();
            String baseProjectURL;
            try {
                URL base = new URL(location);
View Full Code Here

            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
View Full Code Here

            // themes and layouts. These need to be set up before we get any
            // per-page versions.

            // Get the current project.
            MarinerPageContext pageContext = getPageContext(context);
            final RuntimeProject runtimeProject = (RuntimeProject)
                    pageContext.getCurrentProject();

            if (runtimeProject != null) {
                // Add any project specified style sheets into the list of
                // theme style sheets. These must be added before any style
                // sheets that are specified in the head.
                addProjectStyleSheets(context, runtimeProject);

                // Extract any default layout from the project.
                // This will be overridden with an any explicit layout
                // provided in the head.
                layoutName = runtimeProject.getDefaultProjectLayoutLocation();
                if (logger.isDebugEnabled()) {
                    logger.debug("Project layout: " + layoutName);
                }
            }
            // else, presumably this is only for test...?
View Full Code Here

        // Create the branded name by prepending it to the project relative
        // name minus the leading /.
        String brandedName = brandName + projectRelativeName.substring(1);

        RuntimeProject project = (RuntimeProject) reference.getProject();
        PolicyType expectedPolicyType = reference.getExpectedPolicyType();
        if (remoteBrandName) {
            // The brand name is remote so we need to renormalize the
            // branded reference, as it could refer to another policy.
            reference = referenceFactory.createLazyNormalizedReference(
View Full Code Here

        Group baseGroup = null;

        // If a policy was found then check it's project to see whether it
        // already has a cache group selected.
        if (policy != null) {
            RuntimeProject project = policy.getLogicalProject();
            baseGroup = project.getCacheGroup();
        }

        // If a group could not be found from the project then try it based on
        // the key.
        if (key instanceof ProjectSpecificKey) {
View Full Code Here

                        .createPrefixTracker());

        expressionContext.setProperty(MarinerRequestContext.class,
                                      requestContext, false);

        RuntimeProject project = new RuntimeProjectMock("runtimeProjectMock",
                expectations);
        volantisBean.setDefaultProject(project);

        final CurrentProjectProviderMock projectProviderMock =
                new CurrentProjectProviderMock("projectProviderMock",
View Full Code Here

TOP

Related Classes of com.volantis.mcs.runtime.RuntimeProject

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.