uPortal 2.4.1
API Documentation

org.jasig.portal
Class MediaManager

java.lang.Object
  extended byorg.jasig.portal.MediaManager

public class MediaManager
extends java.lang.Object

A tool for managing various media properties. Given a request object, MediaManager determines a client browser type (media). MediaManager also provides information on the mime type that generated response should carry.

Version:
$Revision: 1.33 $
Author:
Peter Kharchenko

Field Summary
static java.lang.String NULL_USER_AGENT
          A user agent string to use when the user-agent header value itself is null.
static java.lang.String UNKNOWN
           
 
Constructor Summary
MediaManager()
          Constructs a MediaManager
MediaManager(java.lang.String mediaPropsFile, java.lang.String mimePropsFile, java.lang.String serializerPropsFile)
          Constructor that initializes all of the property tables.
 
Method Summary
 java.lang.String getDefaultMedia()
          Return a default media type.
 java.lang.String getMedia(BrowserInfo bi)
          Determines a media name from the browser info object.
 java.lang.String getMedia(javax.servlet.http.HttpServletRequest req)
          Determines a media name from the request object.
 java.lang.String getReturnMimeType(javax.servlet.http.HttpServletRequest req)
          Determines a mime name from the request object.
 java.lang.String getReturnMimeType(java.lang.String mediaType)
          Determines a mime name from a media type name.
 BaseMarkupSerializer getSerializer(javax.servlet.http.HttpServletRequest req, java.io.OutputStream out)
          Automatically determines the media type from the request object,
 BaseMarkupSerializer getSerializer(javax.servlet.http.HttpServletRequest req, java.io.Writer out)
          Automatically determines the media type from the request object,
 BaseMarkupSerializer getSerializer(java.lang.String mediaType, java.io.OutputStream out)
          Another version of getSerializer() with OutputStream as one of the parameters.
 BaseMarkupSerializer getSerializer(java.lang.String mediaType, java.io.Writer out)
          Determines and configures a serialzier that is proper for the specified media type.
 BaseMarkupSerializer getSerializerByName(java.lang.String serializerName, java.io.OutputStream out)
          Gets a serializer by name which writes to the provided OutputStream
 BaseMarkupSerializer getSerializerByName(java.lang.String serializerName, java.io.Writer out)
          Gets a serializer by name which writes to the provided Writer
 void setMediaProps(java.lang.String uri)
          Initializes media properties table.
 void setMimeProps(java.lang.String uri)
          Initializes mime properties table.
 void setSerializerProps(java.lang.String uri)
          Initializes serializer properties table.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL_USER_AGENT

public static final java.lang.String NULL_USER_AGENT
A user agent string to use when the user-agent header value itself is null.

See Also:
Constant Field Values

UNKNOWN

public static final java.lang.String UNKNOWN
See Also:
Constant Field Values
Constructor Detail

MediaManager

public MediaManager()
Constructs a MediaManager


MediaManager

public MediaManager(java.lang.String mediaPropsFile,
                    java.lang.String mimePropsFile,
                    java.lang.String serializerPropsFile)
Constructor that initializes all of the property tables. This is equivalent to running a base constructor and setMediaProps(), setMimeProps() and setSerializerProps() afterwards.

Parameters:
mediaPropsFile - location of the media properties file
mimePropsFile - location of the mime properties file
serializerPropsFile - location of the serializer properties file
Method Detail

setMediaProps

public void setMediaProps(java.lang.String uri)
Initializes media properties table.

Parameters:
uri - location of the media properties file, complete with the filename

setMimeProps

public void setMimeProps(java.lang.String uri)
Initializes mime properties table.

Parameters:
uri - location of the mime properties file, complete with the filename

setSerializerProps

public void setSerializerProps(java.lang.String uri)
Initializes serializer properties table.

Parameters:
uri - location of the serializer properties file, complete with the filename

getMedia

public java.lang.String getMedia(javax.servlet.http.HttpServletRequest req)
Determines a media name from the request object.

Parameters:
req - the request object
Returns:
media name

getMedia

public java.lang.String getMedia(BrowserInfo bi)
Determines a media name from the browser info object.

Parameters:
bi - the browser info
Returns:
media name

getDefaultMedia

public java.lang.String getDefaultMedia()
Return a default media type. The default media type is the first media listed in the media.properties file

Returns:
default media name

getReturnMimeType

public java.lang.String getReturnMimeType(javax.servlet.http.HttpServletRequest req)
Determines a mime name from the request object.

Parameters:
req - the request object
Returns:
mime type string

getReturnMimeType

public java.lang.String getReturnMimeType(java.lang.String mediaType)
Determines a mime name from a media type name.

Parameters:
mediaType - the media type name
Returns:
mime type string

getSerializer

public BaseMarkupSerializer getSerializer(java.lang.String mediaType,
                                          java.io.Writer out)
Determines and configures a serialzier that is proper for the specified media type. "serializer.properties" file contains mapping of media names to serializer names. Prior to using a serializer returned by this function, make sure to set it up by calling asContentHandler(), asDocumentHandler() or asDOMSerializer().

Parameters:
mediaType - media name
out - output writer
Returns:
the serializer

getSerializerByName

public BaseMarkupSerializer getSerializerByName(java.lang.String serializerName,
                                                java.io.OutputStream out)
                                         throws java.io.UnsupportedEncodingException
Gets a serializer by name which writes to the provided OutputStream

Parameters:
serializerName -
out -
Returns:
the serializer
Throws:
java.io.UnsupportedEncodingException

getSerializerByName

public BaseMarkupSerializer getSerializerByName(java.lang.String serializerName,
                                                java.io.Writer out)
Gets a serializer by name which writes to the provided Writer

Parameters:
serializerName -
out -
Returns:
the serializer

getSerializer

public BaseMarkupSerializer getSerializer(java.lang.String mediaType,
                                          java.io.OutputStream out)
                                   throws java.io.UnsupportedEncodingException
Another version of getSerializer() with OutputStream as one of the parameters.

Parameters:
mediaType - media type string
out - output stream
Returns:
the markup serializer
Throws:
java.io.UnsupportedEncodingException

getSerializer

public BaseMarkupSerializer getSerializer(javax.servlet.http.HttpServletRequest req,
                                          java.io.Writer out)
Automatically determines the media type from the request object,

Parameters:
req - the request object
out - the output writer object
Returns:
the markup serializer

getSerializer

public BaseMarkupSerializer getSerializer(javax.servlet.http.HttpServletRequest req,
                                          java.io.OutputStream out)
                                   throws java.io.UnsupportedEncodingException
Automatically determines the media type from the request object,

Parameters:
req - the request object
out - the output stream object
Returns:
the markup serializer
Throws:
java.io.UnsupportedEncodingException

uPortal 2.4.1
API Documentation