Skip navigation links

Oracle® Information Rights Management Server Java API Reference
11g Release 1 (11.1.1)

E12907-03


oracle.irm.engine.content.type
Interface ContentTypeOperations


public interface ContentTypeOperations

Content format related operations, such as file extension look-up. This interface provides utility methods for getting ContentType information from file extensions and MIME types. These methods are useful when sealing and unsealing content and MIME type or file extension information is required.

Instance

The methods on ContentTypeOperations can be invoked using ContentTypeOperationsInstance.


Method Summary
 ContentType getContentTypeFromExtension(String extension)
          Get the content type from a sealed or unsealed file extension.
 ContentType getContentTypeFromMimeType(String mimeType)
          Get the content type from a MIME type.
 ContentType getContentTypeFromPath(String path)
          Get the content type from a file path.
 String getSealedFileName(String name)
          Convert a file name into the corresponding sealed file name.
 boolean isSealableFile(String path)
          Determines if a file can be sealed, given a path to the file.
 boolean isSealableMimeType(String mimeType)
          Determine if content for a specified MIME type can be sealed.
 boolean isSealedFile(String path)
          Determines if a file is sealed, given a path to the file.
 boolean isSealedMimeType(String mimeType)
          Determine if a specified MIME type describes sealed content.
 Collection<ContentType> listContentTypes()
          Returns a collection of all content type mappings known to the system.
 Collection<ContentType> listContentTypesFromMimeType(String mimeType)
          List all the content type mappings corresponding to a given MIME type.
 String[] listExtensions(boolean sealed, boolean unsealed)
          Returns a collection of recognized file extensions.
 String[] listMimeTypes(boolean sealed, boolean unsealed)
          Returns a collection of recognized MIME types.

 

Method Detail

getContentTypeFromMimeType

ContentType getContentTypeFromMimeType(String mimeType)
                                       throws UnsupportedContentTypeException,
                                              IllegalMimeTypeException
Get the content type from a MIME type. If a non sealed MIME type is specified and there are multiple sealed content types the first content type is returned. e.g. the {text/plain} content type can be sealed as sealed text or sealed email. In this case the sealed text content type will be returned.
Parameters:
mimeType - file MIME type. e.g. text/html.
Returns:
the content type. This method will never return null.
Throws:
UnsupportedContentTypeException - the MIME type does not correspond to a recognized sealed or sealable document.
IllegalMimeTypeException - the MIME type is syntactically invalid.

listContentTypesFromMimeType

Collection<ContentType> listContentTypesFromMimeType(String mimeType)
                                                     throws UnsupportedContentTypeException,
                                                            IllegalMimeTypeException
List all the content type mappings corresponding to a given MIME type. A MIME type may correspond to more than one mapping. This generally happens with sealed MIME types, which can match multiple unsealed MIME types or extensions. For instance, application/vnd.sealedmedia.softseal.html can match both htm and html file extensions.
Parameters:
mimeType - file MIME type. e.g. text/html.
Returns:
the list of content types. If applicable, this method will return an empty collection rather than null to indicate no results.
Throws:
UnsupportedContentTypeException - the MIME type does not correspond to a recognized sealed or sealable document.
IllegalMimeTypeException - the MIME type is syntactically invalid.

getContentTypeFromExtension

ContentType getContentTypeFromExtension(String extension)
                                        throws UnsupportedContentTypeException
Get the content type from a sealed or unsealed file extension. For an unsealed file extensions there is usually only one target sealed content type. e.g. pass html and get the sealed HTML content type information. For content types that share the same unsealed file extension (e.g. sealed text and sealed email both have an unsealed file extension of txt) the most commonly used sealed type is returned. In the example this would be sealed text. As using the unsealed file extension can cause ambiguity it is advisable to use the sealed file extension with this method.
Parameters:
extension - file extension, without leading period.
Returns:
the content type. This method will never return null.
Throws:
UnsupportedContentTypeException - the extension does not correspond to a recognized sealed or sealable document.

getContentTypeFromPath

ContentType getContentTypeFromPath(String path)
                                   throws UnsupportedContentTypeException
Get the content type from a file path. This function merely extracts the file extension and calls getContentTypeFromExtension.
Parameters:
path - file path. Only the extension is significant.
Returns:
the content type. This method will never return null.
Throws:
UnsupportedContentTypeException - the file does not correspond to a recognized sealed or sealable document.

listMimeTypes

String[] listMimeTypes(boolean sealed,
                       boolean unsealed)
Returns a collection of recognized MIME types.
Parameters:
sealed - if true, sealed MIME types are returned.
unsealed - if true, unsealed MIME types are returned.
Returns:
the list of MIME types. This method will never return null.

listExtensions

String[] listExtensions(boolean sealed,
                        boolean unsealed)
Returns a collection of recognized file extensions.
Parameters:
sealed - if true, sealed file extensions are returned.
unsealed - if true, unsealed file extensions are returned.
Returns:
the list of file extensions. This method will never return null.

listContentTypes

Collection<ContentType> listContentTypes()
Returns a collection of all content type mappings known to the system.

Listing supported sealed file formats

The following code demonstrates how to list file extension and sealed content MIME type information. The code uses a utility method to show the object properties together with captions in the default locale.
 import static oracle.irm.engine.content.type.ContentTypeOperationsInstance.listContentTypes;
 import static oracle.irm.engine.system.i18n.VisualizationInstance.displaySummary;
 
 import java.util.Collection;
 import java.util.Locale;
 
 import oracle.irm.engine.content.type.ContentType;
 
 public class ListContentTypes {
 
        public static void main(String[] args) {
 
         Locale locale = Locale.getDefault();
 
         Collection<ContentType> types = listContentTypes();
 
         for (ContentType type : types) {
 
             String summary = displaySummary(type, locale);
 
             System.out.println(summary);
             System.out.println("");
         }
        }
 }
Returns:
the supported content types. If applicable, this method will return an empty collection rather than null to indicate no results.

isSealableFile

boolean isSealableFile(String path)
Determines if a file can be sealed, given a path to the file. The file is not inspected - the decision is made on the basis of the file extension alone.
Parameters:
path - file path.
Returns:
true if the file can be sealed.

isSealedFile

boolean isSealedFile(String path)
Determines if a file is sealed, given a path to the file. The file is not inspected - the decision is made on the basis of the file extension alone.
Parameters:
path - file path.
Returns:
true if the file is sealed.

isSealableMimeType

boolean isSealableMimeType(String mimeType)
                           throws IllegalMimeTypeException
Determine if content for a specified MIME type can be sealed.
Parameters:
mimeType - a MIME type.
Returns:
true if the MIME type describes a file that can be sealed.
Throws:
IllegalMimeTypeException - the MIME type is syntactically invalid.

isSealedMimeType

boolean isSealedMimeType(String mimeType)
                         throws IllegalMimeTypeException
Determine if a specified MIME type describes sealed content.
Parameters:
mimeType - a MIME type.
Returns:
true if the MIME type describes a sealed file.
Throws:
IllegalMimeTypeException - the MIME type is syntactically invalid.

getSealedFileName

String getSealedFileName(String name)
                         throws UnsupportedContentTypeException
Convert a file name into the corresponding sealed file name. When content is sealed, the file extension is typically altered. e.g. .doc becomes .sdoc. This method converts the provided file name (or file and path) into the equivalent sealed file name. If the file is already sealed no change is made to the file name.
Parameters:
name - the file name.
Returns:
the sealed file name. This method will never return null.
Throws:
UnsupportedContentTypeException - the file name does not correspond to a recognized sealed or sealable document.

Skip navigation links

Oracle® Information Rights Management Server Java API Reference
11g Release 1 (11.1.1)

E12907-03


Copyright © 2011, Oracle. All rights reserved.