Package com.volantis.mcs.runtime.policies

Examples of com.volantis.mcs.runtime.policies.SelectedVariant


    public String retrieveVariantURLAsString(
            RuntimePolicyReference reference,
            EncodingCollection requiredEncodings) {

        SelectedVariant selectedVariant = selectBestVariant(reference,
                requiredEncodings);
        return computeURLAsString(selectedVariant);
    }
View Full Code Here


        RuntimePolicyReference runtimePolicyReference =
                createPolicyReference(reference);

        final AssetResolver resolver = pageContext.getAssetResolver();
        SelectedVariant selected = resolver.selectBestVariant(
                runtimePolicyReference, getEncodingCollection(encoding));

        BestVariant best;
        if (selected == null) {
            best = null;
        } else {
            best = new BestVariantImpl(selected.getPolicy(),
                    selected.getVariant());
        }
        return best;
    }
View Full Code Here

        return selected == null ? null : (Asset) selected.getOldObject();
    }

    private Asset getAsset(RuntimePolicyReference reference,
                           EncodingCollection requiredEncodings) {
        SelectedVariant selected = pageContext.getAssetResolver().
                selectBestVariant(reference, requiredEncodings);
        return getAsset(selected);
    }
View Full Code Here

        super(assetResolver);
    }

    protected ActivatedVariablePolicy getPolicy() {

        SelectedVariant selectedVariant = getSelectedVariant();
        if (selectedVariant != null) {
            return selectedVariant.getPolicy();
        }

        return null;
    }
View Full Code Here

        this.assetResolver = assetResolver;
    }

    // JavaDoc inherited
    protected Asset getAsset() {
        SelectedVariant selectedVariant = getSelectedVariant();
        if (selectedVariant != null) {
            return (Asset) selectedVariant.getOldObject();
        }
        return null;
    }
View Full Code Here

    protected abstract RuntimePolicyReference getPolicyReference();

    protected String getTextFromSelectedVariant(TextEncoding encoding) {
        String text = null;

        SelectedVariant selectedVariant = getSelectedVariant();
        if (selectedVariant != null) {
            Variant variant = selectedVariant.getVariant();
            if (variant != null) {
                TextMetaData metaData = (TextMetaData) variant.getMetaData();
                if (metaData.getTextEncoding() == encoding) {
                    text = assetResolver.getContentsFromVariant(selectedVariant);
                } else {
View Full Code Here

        pageContext = ContextInternals.getMarinerPageContext(context
                .getInitialRequestContext());

        // select the best variant for given policy in src
        SelectedVariant selectedVariant = selectVariant(src);
        if(selectedVariant == null) {
          throw new XDIMEException("best selected variant not accessible");
        }

        AssetResolver assetResolver = pageContext.getAssetResolver();
               
        // The external link rendered for device independent resource will have
        // correct URL if used device support encoding from selected variant
        // otherwise returned variant will be null because selected variant is
        // filtered by PolicyVariantSelector#filter method       
        Variant variant = selectedVariant.getVariant();
        VariantType variantType = null;

        if(variant != null) {
            variantType = variant.getVariantType();
        }

        // for MTXT resource
        if (variantType == VariantType.TEXT) {
            PolicyReferenceResolver resolver = pageContext
                    .getPolicyReferenceResolver();
            TextAssetReference textReference = resolver
                    .resolveUnquotedTextExpression(src);

            final String text = textReference.getText(TextEncoding.PLAIN);
            if (text != null) {
                // We have found the text, so let's try and write it out to
                // attributes
                attributes.setTextContainer(text);
            } else {
                if (logger.isDebugEnabled()) {
                    logger.debug("No text exists for text asset  " + src);
                }
            }
            // remove src pointed at text component
            attributes.setSrc(null);

            // remove srcType which contains list of device independent mime
            // types
            attributes.setSrcType(null);
        }

        // retrieve url only for IMAGE, AUDIO and VIDEO resource so far
        String url = assetResolver.retrieveVariantURLAsString(selectedVariant);

        // get dimensions for image and video and save it to params into
        // attributes
        if (variantType == VariantType.IMAGE
                || variantType == VariantType.VIDEO) {

            PixelDimensionsMetaData dimMetaData =
                (PixelDimensionsMetaData) selectedVariant
                    .getVariant().getMetaData();
            // get the Map of parameters
            Map params = attributes.getParamMap();

            // save height and width in pixels unit to object's parameter map
            if (dimMetaData.getHeight() != 0) {
                params.put("height", StringConvertor.valueOf(dimMetaData
                        .getHeight()));
            }
            if (dimMetaData.getWidth() != 0) {
                params.put("width", StringConvertor.valueOf(dimMetaData
                        .getWidth()));
            }
        }

        // convert image if needed
        if (variantType == VariantType.IMAGE) {
            ImageMetaData imageMetaData = (ImageMetaData) selectedVariant
                    .getVariant().getMetaData();

            // image must be convert
            if (url != null
                    && imageMetaData.getConversionMode() ==
View Full Code Here

        }
    }

    // javadoc inherited
    public String resolveVideo(PolicyReference reference) {
        SelectedVariant selected = retrieveBestDynamicVisualAsset(
                (RuntimePolicyReference) reference);
        return assetResolver.computeURLAsString(selected);
    }
View Full Code Here

    }

    // Javadoc inherited.
    public String resolveText(
            PolicyReference reference, EncodingCollection requiredEncodings) {
        SelectedVariant variant = assetResolver.selectBestVariant(
                (RuntimePolicyReference) reference,
                requiredEncodings);
        return assetResolver.getContentsFromVariant(variant);
    }
View Full Code Here

    }

    private SelectedVariant retrieveBestDynamicVisualAsset(
            final RuntimePolicyReference reference) {

        SelectedVariant selected = assetResolver.selectBestVariant(reference, null);
        if (selected == null) {
            return null;
        } else if (selected.getVariant() != null) {
            return selected;
        }

        ActivatedVariablePolicy policy = selected.getPolicy();
        RuntimePolicyReference fallback = (RuntimePolicyReference)
                policy.getAlternatePolicy(PolicyType.IMAGE);
        if (fallback != null) {
            selected = assetResolver.selectBestVariant(fallback, null);
            if (selected == null) {
                return null;
            } else if (selected.getVariant() != null) {
                return selected;
            }
        }

        // No suitable asset could be found for the background dynamic visual.
View Full Code Here

TOP

Related Classes of com.volantis.mcs.runtime.policies.SelectedVariant

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.