Examples of XDIMEException


Examples of com.volantis.mcs.xdime.XDIMEException

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

                attributes.setConvertibleImageAsset(true);               
            }
        }

        if (url != null) {
            // new mime types for device dependent resources
            String mimeTypes = "";
            Iterator encodingIterator = null;
            // for each variant type get encoding and save its all mime types
            // into attributes' srcType
            if (variantType == VariantType.VIDEO) {
                VideoMetaData metaData = (VideoMetaData) variant.getMetaData();
                encodingIterator = metaData.getVideoEncoding().mimeTypes();
            } else if (variantType == VariantType.AUDIO) {
                AudioMetaData metaData = (AudioMetaData) variant.getMetaData();
                encodingIterator = metaData.getAudioEncoding().mimeTypes();
            } else if (variantType == VariantType.IMAGE) {
                // This is incorrect if the asset is marked as
                // <conversion-mode>always</conversion-mode>
                // as we do not know what MAP will convert it to.
                ImageMetaData metaData = (ImageMetaData) variant.getMetaData();
                encodingIterator = metaData.getImageEncoding().mimeTypes();
            }

            int counter = 0;
            while (encodingIterator != null && encodingIterator.hasNext()) {
                if (counter > 0) {
                    mimeTypes += ",";
                }
                mimeTypes += (String) encodingIterator.next();
                counter++;
            }

            attributes.setSrc(url);
            attributes.setSrcType(mimeTypes);
            // This method will reset the src and possibly the type if
            // necessary. Otherwise it leaves them unchanged.
            resetAsMapURL(context, variant, attributes);

        } else {
            // if url cannot be processed remove values src and srcType
            // attribute
            attributes.setSrc(null);
            // remove srcType which contains list of device independent mime
            // types
            attributes.setSrcType(null);
        }

        VolantisProtocol protocol = ContextInternals.getMarinerPageContext(
                context.getInitialRequestContext()).getProtocol();

        try {
      protocol.writeOpenObject(attributes);
          // copy containedContent to current buffer
          pageContext.getCurrentOutputBuffer().transferContentsFrom(bodyBuffer);
          protocol.writeCloseObject(attributes);
    } catch (ProtocolException e) {
      throw new XDIMEException(e);
    }
    }
View Full Code Here

Examples of com.volantis.mcs.xdime.XDIMEException

                URI uri = null;
                try {
                    uri = new URI(objectAttribute.getSrc());
                }catch(URISyntaxException e){
                    throw new XDIMEException(e);
                }

                // Create MediaAgent request based on old-style transcoder URI.
                Request request = pageContext.getMediaAgentRequestFactory()
                    .createRequestFromICSURI(uri);
View Full Code Here

Examples of com.volantis.mcs.xdime.XDIMEException

                String protocol = fakeUrl.getProtocol();
                if (protocol != null && !"".equals(protocol)) {
                    params.setParameterValue(ParameterNames.SOURCE_PROTOCOL, protocol);
                }
            } catch (MalformedURLException e) {
                throw new XDIMEException(e);
            }
        }
    }
View Full Code Here

Examples of com.volantis.mcs.xdime.XDIMEException

                return XDIMEResult.SKIP_ELEMENT_BODY;
            }
        } catch (ProtocolException e) {
            logger.error("rendering-error", getTagName(), e);

            throw new XDIMEException(exceptionLocalizer.format(
                "rendering-error", getTagName()), e);
        }   
        return XDIMEResult.PROCESS_ELEMENT_BODY;      
     }
View Full Code Here

Examples of com.volantis.mcs.xdime.XDIMEException

             }
             widgetRenderer.renderClose(getProtocol(context), (WidgetAttributes)protocolAttributes);
         } catch (ProtocolException e) {
             logger.error("rendering-error", getTagName(), e);

             throw new XDIMEException(exceptionLocalizer.format(
                 "rendering-error", getTagName()), e);
         }            // TODO: do we need to do anything here?
      }
View Full Code Here

Examples of com.volantis.mcs.xdime.XDIMEException

        
             return anonymousRegionInstance;
            
         } catch (RepositoryException e) {
             logger.error("repository-exception", e);
             throw new XDIMEException(e);
         }
     }
View Full Code Here

Examples of com.volantis.mcs.xdime.XDIMEException

        try {
            protocol.writeOpenHeading6((HeadingAttributes)protocolAttributes);
        } catch (ProtocolException e) {
            logger.error("rendering-error", getTagName(), e);

            throw new XDIMEException(exceptionLocalizer.format(
                "rendering-error", getTagName()), e);
        }
        return XDIMEResult.PROCESS_ELEMENT_BODY;
    }
View Full Code Here

Examples of com.volantis.mcs.xdime.XDIMEException

            int cachedPagesCount;
       
            try {
                cachedPagesCount = Integer.parseInt(cachedPagesCountAttribute);
            } catch (NumberFormatException e) {
                throw new XDIMEException("Invalid value for cached-pages-count attribute.");
            }
       
            tableBodyAttributes.setCachedPagesCount(cachedPagesCount);
        }
    }
View Full Code Here

Examples of com.volantis.mcs.xdime.XDIMEException

        try {
            protocol.writeCloseAnchor((AnchorAttributes)protocolAttributes);
        } catch (ProtocolException e) {
            logger.error("rendering-error", getTagName(), e);

            throw new XDIMEException(exceptionLocalizer.format(
                "rendering-error", getTagName()), e);
        }
    }
View Full Code Here

Examples of com.volantis.mcs.xdime.XDIMEException

        try {
            protocol.writeOpenStrong((StrongAttributes)protocolAttributes);
        } catch (ProtocolException e) {
            logger.error("rendering-error", getTagName(), e);

            throw new XDIMEException(exceptionLocalizer.format(
                "rendering-error", getTagName()), e);
        }
        return XDIMEResult.PROCESS_ELEMENT_BODY;
    }
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.