Package com.volantis.mcs.policies

Examples of com.volantis.mcs.policies.VariablePolicyBuilder


        return getVariantTypeName();
    }

    // Javadoc inherited
    protected PolicyBuilder getPolicy() {
        VariablePolicyBuilder policy = (VariablePolicyBuilder) super.getPolicy();
        boolean variantReady = true;
        for (int i = 0; variantReady && i < variantPages.length; i++) {
            variantReady = variantPages[i].isPageComplete();
        }

        if (variantReady) {
            List variants = new ArrayList();
            for (int i = 0; i < variantPages.length; i++) {
                variantPages[i].performFinish(variants);
            }
            Iterator it = variants.iterator();
            while (it.hasNext()) {
                policy.addVariantBuilder((VariantBuilder) it.next());
            }
        }

        return policy;
    }
View Full Code Here


                    if (componentNamePrefix != null) {
                        policyName = componentNamePrefix + policyName;
                    }

                    // Create the component, if any.
                    VariablePolicyBuilder policyBuilder = (VariablePolicyBuilder)
                            manager.getPolicyBuilder(policyName);

                    // Check to see whether the existing container should
                    // be updated, or a new one created.
                    boolean update = (policyBuilder != null && replace);
                    if (policyBuilder != null) {
                        if (replace) {

                            // ... then remove it
                            logger.info("removing-existing", policyName);

                            manager.removePolicyBuilder(policyName);
                        } else {
                            // ... else all we can do is log a warning.
                            logger.info("found-existing-ignoring-new",
                                        new Object[] {policyName});
                        }
                    }

                    if (policyBuilder == null) {
                        policyBuilder = factory.createVariablePolicyBuilder(
                                PolicyType.IMAGE);
                        policyBuilder.setName(policyName);
                        update = false;
                    } else {
                        update = true;
                    }
View Full Code Here

    protected ActivatedPolicy activateImpl(
            RuntimeProject actualProject, PolicyBuilder policyBuilder,
            RuntimeProject logicalProject) {

        VariablePolicyBuilder variablePolicyBuilder =
                (VariablePolicyBuilder) policyBuilder;

        // Ensure we prune any invalid variants before we start activating.
        // We must do it now as the activation process will trigger lots
        // of redundant(!) validation which will fail otherwise.
        // 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);

        // Iterate over all the variantBuilders to activate any policy
        // references.
        List variantBuilders = variablePolicyBuilder.getVariantBuilders();
        for (Iterator i = variantBuilders.iterator(); i.hasNext();) {
            VariantBuilder builder = (VariantBuilder) i.next();
            ContentBuilder contentBuilder = builder.getContentBuilder();

            if (contentBuilder instanceof URLContentBuilder) {
                URLContentBuilder urlContentBuilder =
                        (URLContentBuilder) contentBuilder;
                PolicyReference reference =
                        urlContentBuilder.getBaseURLPolicyReference();
                if (reference != null) {
                    reference = activateReference(logicalProject, baseURL,
                            reference);
                    urlContentBuilder.setBaseURLPolicyReference(reference);
                }
            }
        }

        // Convert the builder back into a policy. This will trigger another
        // full validation of the policy with consequent redundant logging.
        ActivatedVariablePolicy activatedVariablePolicy =
                new ActivatedVariablePolicyImpl(
                        variablePolicyBuilder.getVariablePolicy(),
                        actualProject, logicalProject);

        return activatedVariablePolicy;
    }
View Full Code Here

                localExpectations);

        projectMock.expects.getCacheControlConstraintsMap()
                .returns(constraintsMap);

        VariablePolicyBuilder policyBuilder =
                policyFactory.createVariablePolicyBuilder(policyType);

        policyBuilder.setName(name);

        VariantBuilder variantBuilder =
                policyFactory.createVariantBuilder(variantType);

        variantBuilder.setSelectionBuilder(
                policyFactory.createDefaultSelectionBuilder());

        variantBuilder.setContentBuilder(contentBuilder);

        policyBuilder.addVariantBuilder(variantBuilder);

        // Activate the policyBuilder.
        VariablePolicy policy = (VariablePolicy) activator.activate(
                projectMock, policyBuilder, projectMock);
View Full Code Here

    // Javadoc inherited.
    protected ActivatedPolicy activateImpl(
            RuntimeProject actualProject, PolicyBuilder policyBuilder,
            RuntimeProject logicalProject) {

        VariablePolicyBuilder variablePolicyBuilder =
                (VariablePolicyBuilder) policyBuilder;

        // Ensure we prune any invalid variants before we start activating.
        // We must do it now as the activation process will trigger lots
        // of redundant(!) validation which will fail otherwise.
        // 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);

        StyleSheetActivator styleSheetActivator =
                new StyleSheetActivatorImpl(logicalProject, baseURL);

        List variantBuilders = variablePolicyBuilder.getVariantBuilders();
        for (int i = 0; i < variantBuilders.size(); i++) {
            VariantBuilder variantBuilder = (VariantBuilder)
                    variantBuilders.get(i);

            InternalLayoutContentBuilder layoutContentBuilder =
                    (InternalLayoutContentBuilder)
                    variantBuilder.getContentBuilder();
            // Convert the content builder back into a content. This will
            // trigger a partial validation of the policy with consequent
            // redundant logging.
            InternalLayoutContent layout = layoutContentBuilder
                    .getInternalLayoutContent();

            final ActivatedLayoutContent activated =
                    contentActivator.activateLayoutContent(
                            styleSheetActivator, layout);
            variantBuilder.setContentBuilder(new FixedContentBuilder(
                    activated));
        }

        // Convert the builder back into a policy. This will trigger another
        // full validation with consequent redundant logging.
        ActivatedVariablePolicy activatedVariablePolicy =
                new ActivatedVariablePolicyImpl(
                        variablePolicyBuilder.getVariablePolicy(),
                        actualProject, logicalProject);

        return activatedVariablePolicy;
    }
View Full Code Here

    // Javadoc inherited.
    protected ActivatedPolicy activateImpl(
            RuntimeProject actualProject, PolicyBuilder policyBuilder,
            RuntimeProject logicalProject) {

        VariablePolicyBuilder variablePolicyBuilder =
                (VariablePolicyBuilder) policyBuilder;

        // Ensure we prune any invalid variants before we start activating.
        // We must do it now as the activation process will trigger lots
        // of redundant(!) validation which will fail otherwise.
        // 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);

        StyleSheetActivator styleSheetActivator =
                new StyleSheetActivatorImpl(logicalProject, baseURL);

        List variantBuilders = variablePolicyBuilder.getVariantBuilders();
        for (int i = 0; i < variantBuilders.size(); i++) {
            VariantBuilder variantBuilder = (VariantBuilder)
                    variantBuilders.get(i);

            InternalThemeContentBuilder themeContentBuilder =
                    (InternalThemeContentBuilder)
                    variantBuilder.getContentBuilder();
            InternalThemeContent theme =
                    themeContentBuilder.getInternalThemeContent();

            ActivatedThemeContent activated = activateThemeContent(
                    styleSheetActivator, theme);
            variantBuilder.setContentBuilder(
                    new FixedContentBuilder(activated));
        }

        // Convert the builder back into a policy. This will trigger another
        // full validation of the policy with consequent redundant logging.
        ActivatedVariablePolicy activatedVariablePolicy =
                new ActivatedVariablePolicyImpl(
                        variablePolicyBuilder.getVariablePolicy(),
                        actualProject, logicalProject);

        return activatedVariablePolicy;
    }
View Full Code Here

    /**
     * Ensure that after retrieving a local policy it is cached.
     */
    public void testRetrieve() throws Exception {

        VariablePolicyBuilder builder = createOriginalPolicyBuilder(projectRelativeName);

        ActivatedPolicy policy = new TestActivatedPolicy(builder.getPolicy(), projectMock);

        // =====================================================================
        //   Set Expectations
        // =====================================================================

View Full Code Here

    /**
     * Ensure that after retrieving a remote policy it is cached.
     */
    public void testRetrieveRemote() throws Exception {

        VariablePolicyBuilder builder = createOriginalPolicyBuilder(remoteName);

        ActivatedPolicy policy = new TestActivatedPolicy(builder.getPolicy(),
                projectMock);

        // =====================================================================
        //   Set Expectations
        // =====================================================================
View Full Code Here

        // =====================================================================
        //   Create Mocks
        // =====================================================================

        VariablePolicyBuilder builder = createOriginalPolicyBuilder(remoteName);

        ActivatedPolicy originalPolicy =
                new TestActivatedPolicy(builder.getPolicy(), projectMock);

        CacheControlBuilder cacheControlBuilder =
                builder.getCacheControlBuilder();
        cacheControlBuilder.setTimeToLive(2);
        cacheControlBuilder.setRetryMaxCount(1);

        ActivatedPolicy refreshedPolicy =
                new TestActivatedPolicy(builder.getPolicy(), projectMock);;
        assertNotEquals(originalPolicy, refreshedPolicy);

        // =====================================================================
        //   Set Expectations
        // =====================================================================
View Full Code Here

        assertSame(originalPolicy, actualPolicy);
    }

    private VariablePolicyBuilder createOriginalPolicyBuilder(
            String policyName) {
        VariablePolicyBuilder builder =
                policyFactory.createVariablePolicyBuilder(PolicyType.AUDIO);
        builder.setName(policyName);

        CacheControlBuilder cacheControlBuilder =
                policyFactory.createCacheControlBuilder();
        cacheControlBuilder.setCacheThisPolicy(true);
        cacheControlBuilder.setTimeToLive(1);
        cacheControlBuilder.setRetryFailedRetrieval(true);
        cacheControlBuilder.setRetryInterval(1);
        cacheControlBuilder.setRetryMaxCount(2);
        builder.setCacheControlBuilder(cacheControlBuilder);
        constraints.applyConstraints(cacheControlBuilder);
        return builder;
    }
View Full Code Here

TOP

Related Classes of com.volantis.mcs.policies.VariablePolicyBuilder

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.