Package org.apache.jetspeed.capabilities

Examples of org.apache.jetspeed.capabilities.MimeType


    public MimeType getPreferredType()
    {
        // Return the value that matches the preferredMimeType defined in the Client
        int prefMimeTypeId = this.client.getPreferredMimeTypeId();

        MimeType mt = null;       
        Iterator e = this.mimeTypeMap.values().iterator();
        while (e.hasNext())
        {           
            mt = (MimeType) e.next();
           
            if (mt.getMimetypeId() == prefMimeTypeId)
                return mt;
        }
        log.error("Could not find preferred Mime Type for " + prefMimeTypeId);       

        // Should never reach this point. A preferred value needs to be set
View Full Code Here


        Vector temp = new Vector();
        // Add Mimetypes to map and create query
        while (mimetypes.hasNext())
        {
            MimeType mt = (MimeType) mimetypes.next();

            // Add mimetype to query
            // Note: mimetypes is a member of MediaTypeImpl
            // criteria.addEqualTo("mimetypes.name", mt.getName());
            //stuff.add(new Integer(mt.getMimetypeId()));
            temp.add(mt.getName());
        }
       
        Collection co = null;
        if (temp.size() > 0)
        {
View Full Code Here

        {
           throw new PipelineException("Falied to create capabilitied:  "+e.getMessage(), e);
        }
       
        MediaType mediaType = cm.getPreferredMediaType();
        MimeType mimeType = cm.getPreferredType();

        if (mediaType == null)
        {
            log.error("CapabilityMap returned a null media type");
            throw new PipelineException("CapabilityMap returned a null media type");
        }

        if (mimeType == null)
        {
            log.error("CapabilityMap returned a null mime type");
            throw new PipelineException("CapabilityMap returned a null mime type");
        }

        String encoding = request.getRequest().getCharacterEncoding();

        if (encoding == null)
        {
            if (mediaType != null && mediaType.getCharacterSet() != null)
            {
                encoding = mediaType.getCharacterSet();
            }
        }

        if (log.isDebugEnabled())
        {
            log.debug("MediaType: " + mediaType.getName());
            log.debug("Encoding: " + encoding);
            log.debug("Mimetype: " + mimeType.getName());
        }

        // Put the encoding in the request
        request.setCharacterEncoding(encoding);

        // Put the CapabilityMap into the request
        request.setCapabilityMap(cm);

        // Put the Media Type into the request
        request.setMediaType(mediaType.getName());

        // Put the Mime Type into the request
        request.setMimeType(mimeType.getName());

        // Put the Mime Type and Charset into the response
        StringBuffer contentType = new StringBuffer(mimeType.getName());
        if (encoding != null)
        {
            contentType.append("; charset=" + encoding);
        }
        request.getResponse().setContentType(contentType.toString());
View Full Code Here

        Vector temp = new Vector();
        // Add Mimetypes to map and create query
        while (mimetypes.hasNext())
        {
            MimeType mt = (MimeType) mimetypes.next();

            // Add mimetype to query
            // Note: mimetypes is a member of MediaTypeImpl
            // criteria.addEqualTo("mimetypes.name", mt.getName());
            //stuff.add(new Integer(mt.getMimetypeId()));
            temp.add(mt.getName());
        }
       
        Collection co = null;
        if (temp.size() > 0)
        {
View Full Code Here

        {
           throw new PipelineException("Falied to create capabilitied:  "+e.getMessage(), e);
        }
       
        MediaType mediaType = cm.getPreferredMediaType();
        MimeType mimeType = cm.getPreferredType();

        if (mediaType == null)
        {
            log.error("CapabilityMap returned a null media type");
            throw new PipelineException("CapabilityMap returned a null media type");
        }

        if (mimeType == null)
        {
            log.error("CapabilityMap returned a null mime type");
            throw new PipelineException("CapabilityMap returned a null mime type");
        }

        String encoding = request.getRequest().getCharacterEncoding();
        boolean containerEncoding = encoding!=null;
        if (encoding == null)
        {
            if (mediaType != null && mediaType.getCharacterSet() != null)
            {
                encoding = mediaType.getCharacterSet();
            }
        }

        if (log.isDebugEnabled())
        {
            log.debug("MediaType: " + mediaType.getName());
            log.debug("Encoding: " + encoding);
            log.debug("Mimetype: " + mimeType.getName());
        }

        // Put the encoding in the request
        if(!containerEncoding && encoding!=null)
        request.setCharacterEncoding(encoding);

        // Put the CapabilityMap into the request
        request.setCapabilityMap(cm);

        // Put the Media Type into the request
        request.setMediaType(mediaType.getName());

        // Put the Mime Type into the request
        request.setMimeType(mimeType.getName());

        // Put the Mime Type and Charset into the response
        StringBuffer contentType = new StringBuffer(mimeType.getName());
        if (encoding != null)
        {
            contentType.append("; charset=" + encoding);
        }
        String type =  contentType.toString(); //mapContentType(request, contentType.toString());
View Full Code Here

    public MimeType getPreferredType()
    {
        // Return the value that matches the preferredMimeType defined in the Client
        int prefMimeTypeId = this.client.getPreferredMimeTypeId();

        MimeType mt = null;       
        Iterator e = this.mimeTypeMap.values().iterator();
        while (e.hasNext())
        {           
            mt = (MimeType) e.next();
           
            if (mt.getMimetypeId() == prefMimeTypeId)
                return mt;
        }
        log.error("Could not find preferred Mime Type for " + prefMimeTypeId);       

        // Should never reach this point. A preferred value needs to be set
View Full Code Here

            {
                JSMimeType _c = (JSMimeType) _it.next();
                // create a new Mime Type
                try
                {
                    MimeType mimeType = caps.createMimeType(_c.getName());
                    /**
                     * THE KEY_OVERWRITE_EXISTING test is not required for mime
                     * types, since they carry no other information than the
                     * name Used here for consistency, though
                     */
                    if ((isSettingSet(settings, JetspeedSerializer.KEY_OVERWRITE_EXISTING))
                            || (mimeType.getMimetypeId() == 0))
                    {
                        caps.storeMimeType(mimeType);
                    }

                }
View Full Code Here

                            {
                                Iterator<String> _it1 = list.iterator();
                                int added = 0;
                                while (_it1.hasNext())
                                {
                                    MimeType _mt = caps.createMimeType((String) _it1.next());
                                    if (_mt != null)
                                        mediaType.addMimetype(_mt);
                                    added++;
                                }
                            }
View Full Code Here

                            {
                                Iterator<String> _it1 = list.iterator();
                                int added = 0;
                                while (_it1.hasNext())
                                {
                                    MimeType _mt = caps.createMimeType((String) _it1.next());
                                    if (_mt != null)
                                    {
                                        client.getMimetypes().add(_mt);
                                        if (_mt.getMimetypeId() == 0)
                                        {
                                            caps.storeMimeType(_mt);
                                        }
                                        if (myPrefMimeType.equalsIgnoreCase(_mt.getName()))
                                            client.setPreferredMimeTypeId(_mt.getMimetypeId());

                                    }
                                    added++;
                                }
                            }
View Full Code Here

        while (list.hasNext())
        {
            try
            {
                MimeType _mt = (MimeType) list.next();
                JSMimeType _jsM = new JSMimeType();
                _jsM.setName(_mt.getName());
                refs.mimeMap.put(_jsM.getName(), _jsM);
                refs.mimeMapInt.put(new Integer(_mt.getMimetypeId()), _jsM);

                snapshot.getMimeTypes().add(_jsM);
            } catch (Exception e)
            {
                throw new SerializerException(
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.capabilities.MimeType

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.