Package com.volantis.mcs.protocols.assets.implementation

Examples of com.volantis.mcs.protocols.assets.implementation.AssetResolver


        OutputBufferFactory outputBufferFactory
                = new TestDOMOutputBufferFactory();
        MenuItemRendererFactory itemRendererFactory
                = new TestMenuItemRendererFactory(outputBufferFactory);
        AssetResolver assetResolver = new AssetResolverMock("assetResolverMock",
                expectations);
        MenuSeparatorRendererFactory separatorRendererFactory
                = new TestMenuSeparatorRendererFactory();

        separatorRendererSelector
View Full Code Here


                                           Encoding encoding) {

        RuntimePolicyReference runtimePolicyReference =
                createPolicyReference(reference);

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

        BestVariant best;
        if (selected == null) {
            best = null;
View Full Code Here

    public String retrieveAudioAssetURLAsString(String name, int encoding)
            throws RepositoryException {

        RuntimePolicyReference reference = createPolicyReference(name,
                PolicyType.AUDIO);
        final AssetResolver resolver = pageContext.getAssetResolver();
        return resolver.retrieveVariantURLAsString(reference,
                getEncodingCollection(EnumerationConverter.AUDIO_ENCODING,
                        encoding));
    }
View Full Code Here

        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() ==
                        ImageConversionMode.ALWAYS_CONVERT) {
                url = assetResolver.rewriteURLWithPageURLRewriter(url,
                        PageURLType.IMAGE);

                attributes.setConvertibleImageAsset(true);               
            }
        }
View Full Code Here

                }
            } else if (labelContent instanceof StyleComponentURI) {

                // Get asset and policy resolvers, resolve component policy
                PolicyReferenceResolver referenceResolver = protocol.getMarinerPageContext().getPolicyReferenceResolver();
                AssetResolver assetResolver = protocol.getMarinerPageContext()
                        .getAssetResolver();
                RuntimePolicyReference policyReference = referenceResolver
                        .resolvePolicyExpression(((StyleComponentURI)labelContent).getExpression());

                // Create image asset from the policy and get fallback
View Full Code Here

        }

        // TODO: factor together with AbstractImageElement
        MarinerPageContext pageContext = protocol.getMarinerPageContext();

        AssetResolver resolver = pageContext.getAssetResolver();

        SelectedVariant selectedVariant =
                resolver.selectBestVariant(reference, null);

        String url = resolver.retrieveVariantURLAsString(selectedVariant);
        if (url == null) {
            return;
        }

        url = resolver.rewriteURLWithPageURLRewriter(url, PageURLType.IMAGE);

        ImageAttributes imageAttributes = new ImageAttributes();

        BaseLocation location = resolver.getBaseLocation(selectedVariant);
        imageAttributes.setLocalSrc(location == BaseLocation.DEVICE);

        Variant variant = selectedVariant.getVariant();
        ImageMetaData image = (ImageMetaData) variant.getMetaData();
        // Make a note of whether this image is a convertible
View Full Code Here

                    policy.getName()
                    + " on device " + pageContext.getDeviceName());
        }

        String imageURL = null;
        AssetResolver resolver = pageContext.getAssetResolver();
        RuntimePolicyReference fallback = (RuntimePolicyReference)
                policy.getAlternatePolicy(PolicyType.IMAGE);
        if (fallback != null) {
            imageURL = resolver.retrieveVariantURLAsString(fallback, null);
        }

        if (imageURL == null) {
            if (logger.isDebugEnabled()) {
                logger.debug("No altImage for component \"" + policy.getName());
View Full Code Here

            logger.debug("Trying altText for dynvis asset named \"" +
                    policy.getName() + " on device " +
                    pageContext.getDeviceName());
        }

        AssetResolver resolver = pageContext.getAssetResolver();

        TextAssetReference altText = new LiteralTextAssetReference(altAttr);
        altText = new FallbackComponentTextAssetReference(resolver, policy,
                altText);
View Full Code Here

                // Resolve the expression to a reference.
                RuntimePolicyReference reference =
                        resolver.resolveUnquotedPolicyExpression(
                                imageComponentName, PolicyType.IMAGE);

                AssetResolver assetResolver = pageContext.getAssetResolver();

                SelectedVariant selected =
                        assetResolver.selectBestVariant(reference, null);

                // Try and find the best image asset with the specified name.
                if (selected != null) {
                    ImageAsset imageAsset =
                            (ImageAsset) selected.getOldObject();
                    if (imageAsset == null) {
                        // No image asset which matches could be found so use the
                        // alt text, if any.

                        // And then try and write out the alt or fallback text,
                        // if we can
                        AltTextAttributes altTextAttrs =
                                new AltTextAttributes(attributes);
                        altTextAttrs.setStyles(pattributes.getStyles());
                        altText = new FallbackComponentTextAssetReference(
                                assetResolver, selected.getPolicy(), altText);
                        altTextAttrs.setAltText(altText);

                        if (protocol.writeAltText(altTextAttrs)) {
                            return SKIP_ELEMENT_BODY;
                        }

                    } else {
                        String[] srcArray = pageContext.
                                retrieveImageAssetURLAsString(imageAsset);
                        url = srcArray[0];

                        AssetGroup assetGroup =
                                assetResolver.getAssetGroup(imageAsset);
                        if (assetGroup != null) {
                            pattributes.setLocalSrc(AssetGroup.ON_DEVICE ==
                                    assetGroup.getLocationType());
                        } else {
                            pattributes.setLocalSrc(false);
View Full Code Here

        String url = getAttribute(XDIMEAttribute.HREF, attributes);

        // Do the actual processing, if the 'href' attribute is specified.
        if (url != null) {
            // Prepare the asset resolver and page URI rewriter for later use.
            AssetResolver assetResolver = getProtocol(context).getMarinerPageContext()
                    .getAssetResolver();
            PageURIRewriter uriRewriter = getProtocol(context).getMarinerPageContext()
                    .getPageURIRewriter();

            if (!uriRewriter.willPossiblyRewrite(PageURLType.ANCHOR)) {
                // If the URL is not to be rewritten using page URI rewriter
                // for which the current state of the page context is important,
                // simply create a LinkAssetReference in standard way.
                // The URL will be rewritten by PageURLRewriter when the
                // getUrl() method gets called.
                linkAssetReference = new LiteralLinkAssetReference(url, assetResolver,
                        PageURLType.ANCHOR);

            } else {
                // If the URL possibly is to be rewritten using page URI
                // rewriter, rewrite the URL in-place, since at the moment the
                // getUrl() method would be invoked, the page context would
                // change and the page URI rewriter would return different
                // result than expected.
                url = assetResolver.rewriteURLWithPageURLRewriter(url, PageURLType.ANCHOR);

                try {
                    url = uriRewriter.rewrite(new URI(url), PageURLType.ANCHOR).toString();
                } catch (URISyntaxException e) {
                    throw new XDIMEException("Invalid URI: " + url, e);
View Full Code Here

TOP

Related Classes of com.volantis.mcs.protocols.assets.implementation.AssetResolver

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.