The mediaContent item type has a mediaType
property that indicates the type of binary file that the item’s url
property points to. The mediaType
property is an enumerated property that accepts the following values:
Video
Image
PDF
Audio
Other
The mediaType
property is set automatically by the /atg/content/service/MimeCategoryTyper
component, which is of class atg.servlet.MimeCategoryTyper
. This component uses the /atg/dynamo/servlet/pipeline/MimeTyper
component to examine the filename extension of the mediaContent item’s url
property and determine the corresponding MIME type. For example, if the extension is mpeg
, MimeTyper
returns video/mpeg
as the MIME type.
Important: When a URL is created by uploading content in the Business Control Center, it does not contain the full path, but only the path that works on the server where the content was uploaded. When loading the URL values to a production server, you must modify the URL path so that it contains the full path. For information on creating media content, refer to the Merchandising Guide for Business Users.
MimeCategoryTyper
then examines the MIME type returned by MimeTyper
and returns one of the MIME categories listed above. For example, if the MIME type is image/jpeg
or image/gif
(or any other image type), MimeCategoryTyper
returns Image.
MimeCategoryTyper
has properties for specifying strings that it attempts to match with the MIME type to determine the MIME category:
exactMatchCategories
startsWithCategories
endsWithCategories
Each of these properties is a Map in which the keys are strings used for comparison with MIME types, and the values are MIME categories. To return the appropriate MIME category, MimeCategoryTyper
uses the following logic:
MimeCategoryTyper
compares the MIME type with theexactMatchCategories
keys. If there is an exact match between a key and the MIME type, the Map value for that key is returned as the MIME category.If there is no exact match,
MimeCategoryTyper
compares the MIME type with thestartsWithCategories
keys. If there is a match between a key and the beginning of the MIME type string, the Map value for that key is returned as the MIME category.If there is no match,
MimeCategoryTyper
compares the MIME type with theendsWithCategories
keys. If there is a match between a key and the ending of the MIME type string, the Map value for that key is returned as the MIME category.If there is no match,
MimeCategoryTyper
returns the value of itsdefaultCategory
property as the MIME category.
The MimeCategoryTyper
component’s properties file includes the following:
mimeTyper=/atg/dynamo/servlet/pipeline/MimeTyper
startsWithCategories=\
image=Image, \
video=Video, \
audio=Audio
endsWithCategories=\
pdf=PDF
defaultCategory=Other
So, for example, if the MIME type is video/mpeg
, the MIME category is Video; if the MIME type is application/pdf
, the MIME category is PDF; and if the MIME type is application/rtf
, the MIME category is Other.
Detecting Changes to the url Property
The /atg/content/service/MimeTypeCategoryListener
component is responsible for determining when the url
property of a mediaContent item has been set or changed, and then invoking MimeCategoryTyper
to determine the new value of the item’s mediaType
property. To do this, MimeTypeCategoryListener
registers an atg.repository.PropertiesChangedListener
on the mediaContent item descriptor.
The MimeTypeCategoryListener
component’s properties file specifies the item descriptor to set the listener on, the names of the url
and mediaType
properties, and the MimeCategoryTyper
component responsible for setting the mediaType
value:
mimeCategoryTyper=/atg/content/service/MimeCategoryTyper
itemDescriptorName=mediaContent
repository=/atg/content/ContentManagementRepository
urlPropertyName=url
mimeTypeCategoryPropertyName=mediaType
When MimeTypeCategoryListener
detects that the url
property of a mediaContent item has changed, it invokes MimeCategoryTyper
to determine the new value of the mediaType
property of the item, as described above. The MimeTypeCategoryListener
component is registered in the initialServices
property of the /Initial
component, so that it starts up automatically when the Oracle Commerce Core Platform starts up.