Package com.volantis.mcs.integration

Examples of com.volantis.mcs.integration.PluggableAssetTranscoder


            }
        }
    }

    private void checkOtherPlugins() throws Exception {
        PluggableAssetTranscoder transcoder = volantis.getAssetTranscoder();

        if (transcoder instanceof PluggableAssetTranscoderManager) {
            transcoder = (PluggableAssetTranscoder)
                PrivateAccessor.getField(transcoder,
                                         "transcoder");
        }

        if (config.assetTranscoderPluginClass != null) {
            try {
                Assert.assertSame(
                    "Configured asset transcoder class not as expected",
                    transcoder.getClass(),
                    Class.forName(config.assetTranscoderPluginClass));
            } catch (ClassNotFoundException e) {
                Assert.fail("Configured asset transcoder class is not " +
                            "valid (" + config.assetTranscoderPluginClass +
                            ")");
            }
        } else {
            Assert.assertSame("Default asset transcoder class not as expected",
                              transcoder.getClass(),
                              com.volantis.mcs.integration.transcoder.ICSWithGIF.class);
        }
    }
View Full Code Here


     * Tests that when there is an aspect ratio parameter, it is removed from
     * the urlc.
     */
    public void testAspectRatioRemoval() throws Exception {
        final String rule = "cj24";
        final PluggableAssetTranscoder transcoder = new ICSWithoutGIF();
        final int width = 369;
        final String urlc = "http://www.volantis.com/myImage.jpg?mcs.ar=5:4";
        TestMarinerRequestContext requestContext =
                createRequestContext(transcoder, rule, width);

        // Create the urlc attribute for the image element implementation.
        ImageAttributes papiImageAttributes = new ImageAttributes();
        papiImageAttributes.setUrlc(urlc);

        // Create the image element implementation.
        ImageElementImpl element = new ImageElementImpl();

        // Generate the pane output for this image element.
        element.elementStartImpl(requestContext, papiImageAttributes);

        // Retrieve the image attributes so that the src can be checked for the
        // removal of the aspect ratio parameter.
        com.volantis.mcs.protocols.ImageAttributes protocolImageAttributes =
                (com.volantis.mcs.protocols.ImageAttributes)
                PrivateAccessor.getField(element, "pattributes");

        final String urlcNoAspectRatio = protocolImageAttributes.getSrc();
        assertEquals("There should be no ratio parameter",
                "http://www.volantis.com/" + rule + "/myImage.jpg?" +
                transcoder.getWidthParameter() + "=" + width,
                urlcNoAspectRatio);
    }
View Full Code Here

     * @throws RepositoryException if a problem occurs building the URL
     */
    protected String constructImageURL(final String srcUrl,
                                       PreservedArea preservedArea)
            throws RepositoryException {
        PluggableAssetTranscoder transcoder =
                getVolantisBean().getAssetTranscoder();
        String newURL = srcUrl;

        InternalDevice device = getDevice();

        TranscodingRule transcodingRule = getTranscodingRule(device);

        if (transcodingRule != null) {

            String ruleName = transcodingRule.getName();

            // We got a rule so let's generate the requirNameed URL
            String ruleValue = device.getPolicyValue(ruleName);
            StringBuffer value;
            int width;
            int maxSize;

            // Determine the width to be requested
            if (getCurrentPane() == null) {
                // If we are not in a pane, use the device width
                width = device.getPixelsX();
            } else {
                width = getProtocol().calculatePaneWidth(getCurrentPane());
            }

            // Determine the maxSize to be requested
            try {
                maxSize = device.getIntegerPolicyValue("maximagesize", -1);
                // parse out the values of image maxsize that have been entered
                // by the user
                MarinerURL murl = new MarinerURL(srcUrl);
                String[] paramValues =
                    murl.getParameterValues(transcoder.getMaxImageSizeParameter());

                int min = Integer.MAX_VALUE;
                if (null != paramValues) {
                    // always iterate over the parameter values even if there
                    // is only one as we need to set up "min"
                    if (paramValues.length > 0) {
                        // remove the parameters as they will be added back later
                        murl.removeParameter(
                            transcoder.getMaxImageSizeParameter());
                        // reassign the newURL variable with the removed
                        newURL = murl.getExternalForm();
                        for (int i=0; i< paramValues.length; i++) {
                            int val = Integer.parseInt(paramValues[i]);
                            if (val < min) {
                                min = val;
                            }
                        }
                    }
                    // if min is valid (>-1) and is less then a valid maxSize
                    // then use its value otherwise use the value in the
                    // device repository
                    if (min >= 0 && min < Integer.MAX_VALUE &&
                        maxSize >=0 && min < maxSize) {
                        maxSize = min;
                    }
                }
            } catch (NumberFormatException e) {
                logger.warn("maximagesize-not-valid",
                            new Object[]{
                                device.getPolicyValue("maximagesize")}, e);
                maxSize = -1;
            }

            try {
                AssetTranscoderContext ctx = new AssetTranscoderContext(
                        newURL,
                        ruleValue,
                        width,
                        maxSize,
                        getRequestContext(),
                        preservedArea);

                value = new StringBuffer(
                        transcoder.constructImageURL(ctx));
            } catch (TranscodingException e) {
                throw new RepositoryException(e);
            }

            // Allow the ImageURLModifier (if there is one) in the
View Full Code Here

TOP

Related Classes of com.volantis.mcs.integration.PluggableAssetTranscoder

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.