Package com.volantis.mcs.runtime.policies

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


        if (selected == null) {
            return null;
        }

        ActivatedVariablePolicy policy = selected.getPolicy();

        Variant variant = selected.getVariant();
        if (variant == null) {
            return null;
        }

        Content content = variant.getContent();
        if (content instanceof EmbeddedContent) {
            EmbeddedContent embedded = (EmbeddedContent) content;
            return embedded.getData();
        } else {
            MarinerURL marinerURL = computeURL((Asset) selected.getOldObject());

            // Then, convert it to an absolute URL
            URL url;
            try {
                url = context.getAbsoluteURL(marinerURL);
            } catch (MalformedURLException e) {
                logger.warn("asset-mariner-url-retrieval-error",
                        new Object[]{
                            policy.getName(),
                            ((marinerURL == null) ? "" :
                        marinerURL.getExternalForm())},
                        e);
                return null;
            }

            // Finally, attempt to read out the URL's contents.
            String text = null;
            try {
                if (logger.isDebugEnabled()) {
                    logger.debug("Retrieving contents of URL " + url);
                }

                URLConnection connection = url.openConnection();
                int contentLength = connection.getContentLength();
                if (contentLength > 0) {
                    String charset = connection.getContentEncoding();
                    if (charset == null) {
                        charset = "UTF-8";
                    }
                    InputStreamReader is = new InputStreamReader(
                            connection.getInputStream(), charset);
                    BufferedReader br = new BufferedReader(is);
                    char[] buf = new char[contentLength];
                    int length = br.read(buf, 0, buf.length);
                    text = String.copyValueOf(buf, 0, length);
                }
            } catch (IOException e) {
                logger.warn("asset-url-retrieval-error",
                            new Object[]{ policy.getName(), url}, e);
            }

            return text;
        }
    }
View Full Code Here


    public TextAssetReference retrieveTextFallback() {
        // Return a fallback text asset reference which falls back from this
        // link asset.
        FallbackComponentTextAssetReference reference = null;

        ActivatedVariablePolicy policy = getPolicy();
        if (policy != null) {
            reference = new FallbackComponentTextAssetReference(
                assetResolver, policy, null);
        }
        return reference;
View Full Code Here

    public TextAssetReference retrieveTextFallback() {
        // Return a fallback text asset reference which falls back from this
        // image asset.
        FallbackComponentTextAssetReference reference = null;

        ActivatedVariablePolicy policy = getPolicy();
        if (policy != null) {
            reference = new FallbackComponentTextAssetReference(
                assetResolver, policy, null);
        }
        return reference;
View Full Code Here

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

        PolicyFetcher fetcher = context.getPolicyFetcher();

        // Get the policy, if it could not be found then return immediately.
        // There is no need to cache the fact that it could not be found as
        // that will already have been done in a lower level accessor.
        ActivatedVariablePolicy policy = (ActivatedVariablePolicy)
                fetcher.fetchPolicy(reference);
        if (policy == null) {
            return null;
        }

        // Cache selection.
        final InternalDevice device = context.getDevice();
        Object key = new DeviceSpecificKey(device.getName(), requiredEncodings);
        SelectedVariant selected;
        synchronized (policy) {
            selected = policy.getSelected(key);
            if (selected == null) {
                selected = selectBest(context, policy, requiredEncodings);
                policy.putSelected(key, selected);
            }
        }

        // If nothing was found return the policy wrapped in a variant
        if (selected == POLICY_NOT_FOUND || selected == null) {
View Full Code Here

    public TextAssetReference retrieveTextFallback() {
        // Return a fallback text asset reference which falls back from this
        // link asset.
        FallbackComponentTextAssetReference reference = null;

        ActivatedVariablePolicy policy = getPolicy();
        if (policy != null) {
            reference = new FallbackComponentTextAssetReference(
                assetResolver, policy, null);
        }
        return reference;
View Full Code Here

    public TextAssetReference retrieveTextFallback() {
        // Return a fallback text asset reference which falls back from this
        // script asset.
        FallbackComponentTextAssetReference reference = null;

        ActivatedVariablePolicy policy = getPolicy();
        if (policy != null) {
            reference = new FallbackComponentTextAssetReference(
                assetResolver, policy, null);
        }
        return reference;
View Full Code Here

        //
        // Instead we now call the other overload which specifies an
        // explicit encoding as we know we only support AMR at this
        // stage anyway. See VBM:2005040106.

        ActivatedVariablePolicy policy = selected.getPolicy();
        Variant variant = selected.getVariant();
        if (variant == null) {
            MediaUtilities.tryAltText(attributes, pageContext, policy,
                    attributes.getAlt(), aAttributes.getStyles());
        } else {

            AudioMetaData audio = (AudioMetaData) variant.getMetaData();

            // Currently this audio tag is only supported by the MMS_SMIL_2_0
            // protocol.  This only suports AMR so we need only deal with
            // assets that have AMR encoding.
            AudioEncoding encoding = audio.getAudioEncoding();
            if (encoding == AudioEncoding.AMR) {
                doAMR(selected, attributes, protocol, pageContext);
                if (logger.isDebugEnabled()) {
                    logger.debug("Done a Audio tag");
                }
            } else {
                logger.warn("unsupported-asset-encoding", new Object[]{
                    policy.getName(), pageContext.getDeviceName(),
                    encoding});
            }
        }
    }
View Full Code Here

                    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

                    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

TOP

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

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.