Package com.volantis.mcs.policies.variants

Examples of com.volantis.mcs.policies.variants.VariantBuilder


                    try {
                        logger.info("generic-asset-file-added-for-component",
                                    new Object[] {assetFile, policyBuilder});

                        VariantBuilder variantBuilder =
                                assetFactory.createGenericImageVariant(
                                        assetFile, assetGroupName, widthHint);
                        addAssetSafely(policyBuilder, variantBuilder);
                    } catch (Exception e) {
                        logger.info("generic-asset-file-error-adding-for-" +
View Full Code Here


        // See if we have an old version of the variantBuilder.
        SelectionBuilder selectionBuilder =
                variantBuilder.getSelectionBuilder();
        List variants = policyBuilder.getVariantBuilders();
        for (int i = 0; i < variants.size(); i++) {
            VariantBuilder existing = (VariantBuilder) variants.get(i);
            if (existing.getSelectionBuilder().equals(selectionBuilder)) {
                // And if we are replacing...
                if (replace) {
                    // ... then remove it
                    logger.info("removing-existing", existing);
                    variants.remove(i);
View Full Code Here

     * @throws IOException if there was a problem reading the image file.
     */
    public VariantBuilder createDeviceImageVariant(File imageFile,
            String assetGroup, String deviceName) throws IOException {

        VariantBuilder variantBuilder =
                factory.createVariantBuilder(VariantType.IMAGE);

        TargetedSelectionBuilder targeted =
                factory.createTargetedSelectionBuilder();
        targeted.addDevice(deviceName);
        variantBuilder.setSelectionBuilder(targeted);

        ImageMetaDataBuilder image = createImageMetaData(imageFile);
        variantBuilder.setMetaDataBuilder(image);

        URLContentBuilder content = createURLContent(assetGroup, imageFile);
        variantBuilder.setContentBuilder(content);

        return variantBuilder;
    }
View Full Code Here

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

    /**
     * Expectations for device independent text processing
     */
    private void addTextExpectations(String imageSrc) {

        VariantBuilder variantBuilder = POLICY_FACTORY
                .createVariantBuilder(VariantType.TEXT);

        variantBuilder.setSelectionBuilder(POLICY_FACTORY
                .createDefaultSelectionBuilder());

        TextMetaDataBuilder builder = POLICY_FACTORY.
                createTextMetaDataBuilder();
        builder.setTextEncoding(TextEncoding.PLAIN);
       

        URLContentBuilder urlContentBuilder = POLICY_FACTORY
                .createURLContentBuilder();
        urlContentBuilder.setURL("/text.txt");
        variantBuilder.setContentBuilder(urlContentBuilder);

        variantBuilder.setMetaDataBuilder(builder);

        Variant variant = variantBuilder.getVariant();

        final RuntimePolicyReferenceMock textReferenceMock = new RuntimePolicyReferenceMock(
                "textReferenceMock", expectations);

        referenceResolverMock.expects.resolveUnquotedPolicyExpression(imageSrc,
View Full Code Here

    /**
     * Expectations for device independent image processing
     */
    private void addImageSrcExpectations(String imageSrc) {

        VariantBuilder variantBuilder = POLICY_FACTORY
                .createVariantBuilder(VariantType.IMAGE);

        variantBuilder.setSelectionBuilder(POLICY_FACTORY
                .createDefaultSelectionBuilder());

        ImageMetaDataBuilder builder = POLICY_FACTORY
                .createImageMetaDataBuilder();
        builder.setWidth(100);
        builder.setHeight(200);
        builder.setImageEncoding(ImageEncoding.JPEG);
        builder.setPixelDepth(24);

        URLContentBuilder urlContentBuilder = POLICY_FACTORY
                .createURLContentBuilder();
        urlContentBuilder.setURL("/foo.jpeg");
        variantBuilder.setContentBuilder(urlContentBuilder);

        variantBuilder.setMetaDataBuilder(builder);

        Variant variant = variantBuilder.getVariant();

        final RuntimePolicyReferenceMock imageReferenceMock = new RuntimePolicyReferenceMock(
                "imageReferenceMock", expectations);

        referenceResolverMock.expects.resolveUnquotedPolicyExpression(imageSrc,
View Full Code Here

    /**
     * Expectations for device independent image processing
     */
    private void addAudioExpectations(String audioSrc,String audioExpected) {

        VariantBuilder variantBuilder = POLICY_FACTORY
                .createVariantBuilder(VariantType.AUDIO);

        variantBuilder.setSelectionBuilder(POLICY_FACTORY
                .createDefaultSelectionBuilder());

        AudioMetaDataBuilder builder = POLICY_FACTORY
                .createAudioMetaDataBuilder();

        builder.setAudioEncoding(AudioEncoding.MP3);

        URLContentBuilder urlContentBuilder = POLICY_FACTORY
                .createURLContentBuilder();
        urlContentBuilder.setURL("/foo.mp3");
        variantBuilder.setContentBuilder(urlContentBuilder);

        variantBuilder.setMetaDataBuilder(builder);

        Variant variant = variantBuilder.getVariant();

        final RuntimePolicyReferenceMock audioReferenceMock = new RuntimePolicyReferenceMock(
                "audioReferenceMock", expectations);

        referenceResolverMock.expects.resolveUnquotedPolicyExpression(audioSrc,
View Full Code Here

    /**
     * Expectations for device independent image processing
     */
    private void addVideoExpectations(String videoSrc,String expectation) {

        VariantBuilder variantBuilder = POLICY_FACTORY
                .createVariantBuilder(VariantType.VIDEO);

        variantBuilder.setSelectionBuilder(POLICY_FACTORY
                .createDefaultSelectionBuilder());

        VideoMetaDataBuilder builder = POLICY_FACTORY
                .createVideoMetaDataBuilder();

        builder.setVideoEncoding(VideoEncoding.MPEG4);
        builder.setHeight(200);
        builder.setWidth(200);

        URLContentBuilder urlContentBuilder = POLICY_FACTORY
                .createURLContentBuilder();
        urlContentBuilder.setURL("/foo.mpeg");
        variantBuilder.setContentBuilder(urlContentBuilder);

        variantBuilder.setMetaDataBuilder(builder);

        Variant variant = variantBuilder.getVariant();

        final RuntimePolicyReferenceMock videoReferenceMock = new RuntimePolicyReferenceMock(
                "videoReferenceMock", expectations);

        referenceResolverMock.expects.resolveUnquotedPolicyExpression(videoSrc,
View Full Code Here

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

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

TOP

Related Classes of com.volantis.mcs.policies.variants.VariantBuilder

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.