Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.ibm.workplace.wcm.api
Interface Resource

All Known Subinterfaces:
  FileComponent, ImageComponent, LibraryFileComponent, LibraryImageComponent

    public interface Resource

Interface representing a binary resource, like an image or a file.

Since:
  8.5.cf3

Method Summary
`byte[]` | `getBytes()` Returns the contents of the resource contained within this component as a byte array.
`java.io.InputStream` | `getInputStream()` Returns the contents of the resource contained within this component as a input stream.
`java.lang.String` | `getMimeType()` Returns the mime-type of the resource file.
`java.lang.String` | `getResourceName()` Returns the name of the resource contained within this component.
`java.lang.String` | `getResourceURL()` Returns the server relative URL or Piece of Content (PoC) URI to the resource.
`long` | `getSize()` Returns the size in bytes of the file contained within this component.
`void` | `removeResource()` Removes the resource file contained within this component.
`void` | `setDeliverableOverCachingNetworkSupport(boolean deliveryOverCachingNetwork)` Sets a flag indicating the asset should be delivery over a caching network if available.
`void` | `setResource(java.lang.String resourceName, byte[] resourceBytes)` Sets the resource file contained within this component.
`void` | `setResource(java.lang.String resourceName, java.io.File resourceFile)` Sets the resource file contained within this component.
`boolean` | `supportsDeliveryOverCachingNetwork()` Returns true if the asset can be delivery over a caching network if available.

Method Detail

### getResourceName

    java.lang.String getResourceName()
                                     throws AuthorizationException,
                                            PropertyRetrievalException

  Returns the name of the resource contained within this component.

  Returns `null` if a resource name has not been specified.

  Returns:
    the resource name
  Throws:
    `AuthorizationException` - if the user does not have access to the resource
    `PropertyRetrievalException` - if the resource name cannot be retrieved

### getBytes

    byte[] getBytes()
                    throws AuthorizationException,
                           PropertyRetrievalException

  Returns the contents of the resource contained within this component as a byte array.

  May return an empty byte array if the byte content could not be retrieved.

  Returns:
    the file content as a byte array
  Throws:
    `AuthorizationException` - if the user does not have access to the file
    `PropertyRetrievalException` - if the file cannot be retrieved or is externally managed

### getInputStream

    java.io.InputStream getInputStream()
                                       throws AuthorizationException,
                                              PropertyRetrievalException

  Returns the contents of the resource contained within this component as a input stream.

  Returns an empty byte array if no file has been set or the byte content could not be retrieved.

  Returns:
    the file content as a input stream
  Throws:
    `AuthorizationException` - if the user does not have access to the file
    `PropertyRetrievalException` - if the file cannot be retrieved or is externally managed

### setResource

    void setResource(java.lang.String resourceName,
                     byte[] resourceBytes)
                     throws OperationFailedException

  Sets the resource file contained within this component.

  This method does not accept `null` arguments. Passing a `null` argument into this method will result in a `NullPointerException`.

  Parameters:
    `resourceName` - the filename of the resource file
    `resourceBytes` - the content of the resource file as a byte array
  Throws:
    `java.lang.NullPointerException` - if either of the arguments resourceName or resource are null
    `OperationFailedException` - if the resource file could not be set

### setResource

    void setResource(java.lang.String resourceName,
                     java.io.File resourceFile)
                     throws OperationFailedException

  Sets the resource file contained within this component. This method consumes less memory then setting the entire byte array of the resource

  This method does not accept `null` arguments. Passing a `null` argument into this method will result in a `NullPointerException`.

  Parameters:
    `resourceName` - the filename of the resource file
    `resourceFile` - the contents of the resource as a file on the file system
  Throws:
    `java.lang.NullPointerException` - if either of the arguments resourceName or resource are null
    `OperationFailedException` - if the resource file could not be set

### removeResource

    void removeResource()
                        throws OperationFailedException

  Removes the resource file contained within this component.

  Throws:
    `OperationFailedException` - if an error occurred removing the resource file.

### getMimeType

    java.lang.String getMimeType()

  Returns the mime-type of the resource file.

  Returns `null` if no resource file has been set.

  Returns:
    the mime-type
  Since:
    8.0.0.1 CF6

### getSize

    long getSize()
                 throws AuthorizationException,
                        PropertyRetrievalException

  Returns the size in bytes of the file contained within this component.

  Returns `-1` if a file has not been specified.

  Returns:
    the file size in bytes
  Throws:
    `AuthorizationException` - if the user does not have access to the file
    `PropertyRetrievalException` - if the file cannot be retrieved

### getResourceURL

    java.lang.String getResourceURL()

  Returns the server relative URL or Piece of Content (PoC) URI to the resource. A secure context URL will be returned if the current user is authenticated.

  Returns `null` if no resource has been set.

  Returns:
    the server relative URL or PoC URI to the resource.
  Since:
    8.0

### supportsDeliveryOverCachingNetwork

    boolean supportsDeliveryOverCachingNetwork()

  Returns true if the asset can be delivery over a caching network if available.

  Returns:
    true, if asset can be delivered via caching network

### setDeliverableOverCachingNetworkSupport

    void setDeliverableOverCachingNetworkSupport(boolean deliveryOverCachingNetwork)

  Sets a flag indicating the asset should be delivery over a caching network if available. In order to have the resource delivered via a caching network there needs to be some additional logic, e.g. a plugin on the subscriber side, that pushes the resource to the caching network. This setting merely indicates that it makes sense for this resource to be not served out of WCM, but via a caching network.

  Parameters:
    `deliveryOverCachingNetwork` - should asset be delivered via caching network?

Overview | Package | Class | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD