Examples of InternalDevice


Examples of com.volantis.mcs.devices.InternalDevice

            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
            // ApplicationContext to modify the image url.
            ImageURLModifier ium = applicationContext.getImageURLModifier();
            if (ium != null) {
                ImageURLModifierDetails details =
                        new ImageURLModifierDetails();
                details.setMaxImageSize(device.getPolicyValue("maxmmsize"));
                details.setEncoding(transcodingRule.getEncoding());

                ium.modifyImageURL(value, details);
            }
View Full Code Here

Examples of com.volantis.mcs.devices.InternalDevice

     * list as string with encoding separated by comma
     * @return
     */
    public String getSupportedImages() {

        InternalDevice device = getDevice();

        int preferredImageType = device.getPreferredImageType();
        StringBuffer supportedImages = new StringBuffer();

        int supportedEncodings[] = device.getSupportedImageEncodingArray();

        int index = 0;
        while (index < supportedEncodings.length) {
            int supportedEncoding = supportedEncodings[index];
            if (supportedEncoding != preferredImageType) {
View Full Code Here

Examples of com.volantis.mcs.devices.InternalDevice

     * @param deviceName The device to check.
     * @return The relationship with the current device.
     */
    public int getAncestorRelationship(String deviceName) {

        InternalDevice device = getDevice();

        if (device.getName().equals(deviceName)) {
            return MarinerRequestContext.IS_DEVICE;
        }

        device = device.getFallbackDevice();

        while (device != null) {
            if (device.getName().equals(deviceName)) {
                return MarinerRequestContext.IS_ANCESTOR;
            }
            device = device.getFallbackDevice();
        }

        return MarinerRequestContext.IS_UNRELATED;
    }
View Full Code Here

Examples of com.volantis.mcs.devices.InternalDevice

            throw new IllegalStateException
                    ("Volantis bean has not been initialised");
        }

        // Resolve the device (once for this session).
        InternalDevice device = resolveDevice(
                volantisBean,
                requestContext);

        // Create the application context
        applicationContext = createApplicationContext(
View Full Code Here

Examples of com.volantis.mcs.devices.InternalDevice

    }

    private void calculateAncestors(final InternalDevice device,
            String styleSheetVersion) {

        InternalDevice ancestor = device.getFallbackDevice();
        while (ancestor != null && ancestor.getStyleSheetVersion() != null &&
                ancestor.getStyleSheetVersion().equals(styleSheetVersion)) {
            cssMatchAncestors.add(ancestor);
            ancestor = ancestor.getFallbackDevice();
        }

        if (logger.isDebugEnabled()) {
            StringBuffer buffer = new StringBuffer();
            for (int i = 0; i < cssMatchAncestors.size(); i++) {
                InternalDevice dev = (InternalDevice)
                        cssMatchAncestors.get(i);
                buffer.append(dev.getName()).append(" ");
            }
            logger.debug("CSS match ancestors: " + buffer);
        }
    }
View Full Code Here

Examples of com.volantis.mcs.devices.InternalDevice

        String value = device.getSpecifiedPolicyValue(policy);
        if (value == null) {
            int depth = cssMatchAncestors.size() - 1;
            while (value == null && depth >= 0) {
                InternalDevice ancestor = (InternalDevice)
                        cssMatchAncestors.get(depth);
                value = ancestor.getSpecifiedPolicyValue(policy);
                depth--;
                if (logger.isDebugEnabled()) {
                    if (value != null) {
                        logger.debug("Using ancestor '" +
                                ancestor.getName() + "' specified: " +
                                policy + "=" + value);
                    }
                }
            }
        } else {
View Full Code Here

Examples of com.volantis.mcs.devices.InternalDevice

     * @return the newly created style visitor.
     */
    protected StyleEmulationVisitor createStyleVisitor() {
        ProtocolConfigurationImpl configuration = getProtocolConfiguration();
        final HashMap policies = new HashMap();
        InternalDevice device = INTERNAL_DEVICE_FACTORY.createInternalDevice(
            new DefaultDevice("testDevice", policies, null));
        DeviceCapabilityManagerBuilder builder =
                new DeviceCapabilityManagerBuilder(device);
        configuration.initialize(device, builder);
        return new StyleEmulationVisitor(domFactory,
View Full Code Here

Examples of com.volantis.mcs.devices.InternalDevice

        ProtocolConfigurationImpl config = new ProtocolConfigurationImpl();

        HashMap policies = new HashMap();
        policies.put(DeviceCapabilityConstants.HR_SUPPORTED, "full");

        InternalDevice device = INTERNAL_DEVICE_FACTORY.createInternalDevice(
            new DefaultDevice("device", policies, null));
        device.setProtocolConfiguration(config);

        DeviceCapabilityManagerBuilder builder =
                new DeviceCapabilityManagerBuilder(device);

        config.setDeviceCapabilityManager(builder.build());
View Full Code Here

Examples of com.volantis.mcs.devices.InternalDevice

        ProtocolConfigurationImpl config = new ProtocolConfigurationImpl();

        HashMap policies = new HashMap();
        policies.put(DeviceCapabilityConstants.HR_SUPPORTED, "partial");

        InternalDevice device = INTERNAL_DEVICE_FACTORY.createInternalDevice(
            new DefaultDevice("device", policies, null));
        device.setProtocolConfiguration(config);

        DeviceCapabilityManagerBuilder builder =
                new DeviceCapabilityManagerBuilder(device);

        config.setDeviceCapabilityManager(builder.build());
View Full Code Here

Examples of com.volantis.mcs.devices.InternalDevice

        policies.put(DeviceCapabilityConstants.HR_BORDER_TOP_COLOR, "none");
        policies.put(DeviceCapabilityConstants.HR_BORDER_TOP_WIDTH, "none");
        policies.put(DeviceCapabilityConstants.HR_BORDER_BOTTOM_COLOR, "full");
        policies.put(DeviceCapabilityConstants.HR_BORDER_BOTTOM_WIDTH, "full");

        InternalDevice device = INTERNAL_DEVICE_FACTORY.createInternalDevice(
            new DefaultDevice("device", policies, null));
        device.setProtocolConfiguration(config);

        DeviceCapabilityManagerBuilder builder =
                new DeviceCapabilityManagerBuilder(device);

        config.setDeviceCapabilityManager(builder.build());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.