com.sap.netweaver.bc.uwl

Class Attachment

java.lang.Object
  extended by com.sap.netweaver.bc.uwl.Attachment
All Implemented Interfaces:
Serializable

public class Attachment
extends Object
implements Serializable

The Attachment class represents two basic types: URL and file document data. URL includes any internet url or any link such as object link. For file document data display, there are mainly 3 scenarios:

See Also:
Serialized Form

Field Summary
static int TYPE_ACTION
          Attachment can also be of type activity, in which case content given from the connector is an Action object.
static int TYPE_ERROR
          Denotes an internal error resulted while getting attachment, no information at all except for the attachment title.
static int TYPE_MEMO
          Special attachment to indicate memo attached to the item.
static int TYPE_MIME_DATA
          Stands for a classic file document attachment with mime type.
static int TYPE_OBJLINK
          This one is similar to TYPE_URL, a link reference to be calculated by server.
static int TYPE_OBJNAVIG
          Represents object based navigation and client script navigation.
static int TYPE_RAW_DATA
          Indicates raw file data without specific mime type.
static int TYPE_TEXT
          Content is string, used for notes.
static int TYPE_UNKNOWN_DATA
          File data is available but data type is unknown.
static int TYPE_UNSUPPORTED
          The type is not supported at all and consequently, file data cannot be retrieved.
static int TYPE_UNSUPPORTED_OLDSYS
          Indicates that retrieving document data is not supported in the system at all.
static int TYPE_URL
          Represents a simple link, no stream data.
 
Constructor Summary
Attachment(String attachmentConnectorID, int type, String title, String description, String internalID)
          This constructor is similar to Attachment(java.lang.String, java.lang.String, int, java.lang.String).
Attachment(String attachmentConnectorID, int type, String title, String description, String internalID, String author, Date timeCreated, PriorityEnum priority)
          This constructor is similar to Attachment(java.lang.String, int, java.lang.String, java.lang.String, java.lang.String), with optional additional data: priority, time created and author.
Attachment(String attachmentConnectorID, int type, String title, String description, String internalID, String author, Date timeCreated, PriorityEnum priority, String fileName, String extension, String mimeType, int fileSize)
          This constructor is chiefly intended for attachment of document type.
Attachment(String attachmentConnectorID, String internalID, int type, String title)
          This constructor takes minimal administrative data to create an attachment.
 
Method Summary
static Attachment createForUpload(String title, String filename, String fileExtension, Object content, int type)
          Creates an attachment instance for file uploading scenario.
 String getAuthor()
           
 String getConnectorId()
          Returns the ID of the attachment connector.
 Object getContent()
           
 Date getCreatedTime()
           
 String getDescription()
           
 String getFileExtension()
           
 String getFileName()
           
 int getFileSize()
           
 String getInternalId()
           
 String getMimeType()
           
 String getName()
           
 PriorityEnum getPriority()
           
 String getTitle()
          Returns the title of the attachment.
 int getType()
          Returns the type of the attachment.
 String getTypeDesc()
          Returns the short text of the attachment type.
 boolean isMemo()
          An Attachment is of memo type if its type is Attachment.TYPE_MEMO or Attachment.TYPE_RAW_DATA or Attachment.TYPE_TEXT
 boolean isRequiredReading()
          This is used to determine if the attachment should be indicated to the user as required reading.
 void setContent(Object content)
          The content of attachment is set through this method.
 void setFileName(String fileName)
          If a physical file exists for an attachment, the file name can be saved.
 void setName(String name)
           
 void setRequiredReading(boolean b)
          Indicate to the user if this attachment is required reading.
 void setType(int attachmentType)
          Sets the attachment type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TYPE_URL

public static final int TYPE_URL
Represents a simple link, no stream data.

See Also:
Constant Field Values

TYPE_TEXT

public static final int TYPE_TEXT
Content is string, used for notes.

See Also:
Constant Field Values

TYPE_MIME_DATA

public static final int TYPE_MIME_DATA
Stands for a classic file document attachment with mime type.

See Also:
Constant Field Values

TYPE_RAW_DATA

public static final int TYPE_RAW_DATA
Indicates raw file data without specific mime type.

See Also:
Constant Field Values

TYPE_UNKNOWN_DATA

public static final int TYPE_UNKNOWN_DATA
File data is available but data type is unknown.

See Also:
Constant Field Values

TYPE_ERROR

public static final int TYPE_ERROR
Denotes an internal error resulted while getting attachment, no information at all except for the attachment title.

See Also:
Constant Field Values

TYPE_OBJLINK

public static final int TYPE_OBJLINK
This one is similar to TYPE_URL, a link reference to be calculated by server. This is a special type for object link display.

See Also:
Constant Field Values

TYPE_OBJNAVIG

public static final int TYPE_OBJNAVIG
Represents object based navigation and client script navigation.

See Also:
Constant Field Values

TYPE_UNSUPPORTED

public static final int TYPE_UNSUPPORTED
The type is not supported at all and consequently, file data cannot be retrieved.

See Also:
Constant Field Values

TYPE_UNSUPPORTED_OLDSYS

public static final int TYPE_UNSUPPORTED_OLDSYS
Indicates that retrieving document data is not supported in the system at all.

See Also:
Constant Field Values

TYPE_MEMO

public static final int TYPE_MEMO
Special attachment to indicate memo attached to the item. Will be treated as a Text type, but will not be displayed on the Attachment page. Will be displayed in UWL detail page only.

See Also:
Constant Field Values

TYPE_ACTION

public static final int TYPE_ACTION
Attachment can also be of type activity, in which case content given from the connector is an Action object. Typically, Url or Launch Actions can be attached to an item. These actions are rendered as links attached to the item. When attachment of type action are populated through UWL Service, content will be the fully constructed URL.

See Also:
Constant Field Values
Constructor Detail

Attachment

public Attachment(String attachmentConnectorID,
                  String internalID,
                  int type,
                  String title)
This constructor takes minimal administrative data to create an attachment.

Parameters:
attachmentConnectorID - Attachment Connector ID
internalID - Unique internal ID of attachment per item (in any format but without the '-' character)
type - Attachment type
title - Title of attachment
See Also:
Attachment(java.lang.String, int, java.lang.String, java.lang.String, java.lang.String)

Attachment

public Attachment(String attachmentConnectorID,
                  int type,
                  String title,
                  String description,
                  String internalID)
This constructor is similar to Attachment(java.lang.String, java.lang.String, int, java.lang.String). It takes additional optional attribute 'description' for the attachment.

Parameters:
attachmentConnectorID - Attachment Connector ID
type - Attachment type
title - Title of attachment
description - Description of an attachment
internalID - Unique internal ID of attachment per item (in any format but without the '-' character)
See Also:
Attachment(java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.Date, com.sap.netweaver.bc.uwl.PriorityEnum)

Attachment

public Attachment(String attachmentConnectorID,
                  int type,
                  String title,
                  String description,
                  String internalID,
                  String author,
                  Date timeCreated,
                  PriorityEnum priority)
This constructor is similar to Attachment(java.lang.String, int, java.lang.String, java.lang.String, java.lang.String), with optional additional data: priority, time created and author.

Parameters:
attachmentConnectorID - Attachment Connector ID
type - Attachment type
title - Title of attachment
description - Description of an attachment
internalID - Unique internal ID of attachment per item (in any format but without the '-' character)
author - Creator of the attachment
timeCreated - Creation time of the attachment
priority - Priority of the attachment
See Also:
Attachment(java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.Date, com.sap.netweaver.bc.uwl.PriorityEnum, java.lang.String, java.lang.String, java.lang.String, int)

Attachment

public Attachment(String attachmentConnectorID,
                  int type,
                  String title,
                  String description,
                  String internalID,
                  String author,
                  Date timeCreated,
                  PriorityEnum priority,
                  String fileName,
                  String extension,
                  String mimeType,
                  int fileSize)
This constructor is chiefly intended for attachment of document type. Other basic administrative data are the same. Similar to #Attachment(java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.Date, java.lang.String, java.util.Date, com.sap.netweaver.bc.uwl.PriorityEnum), with optional additional data about a file document.

Parameters:
attachmentConnectorID - Attachment Connector ID
type - Attachment type
title - Title of attachment
description - Description of an attachment
internalID - Unique internal ID of attachment per item (in any format but without the '-' character)
author - Creator of the attachment
timeCreated - Creation time of the attachment
priority - Priority of the attachment
fileName - File name of the attachment
extension - Extension of the file document
mimeType - Mime type of the file document
fileSize - File size in bytes
Method Detail

getConnectorId

public String getConnectorId()
Returns the ID of the attachment connector.

Returns:
String containing the attachment connector ID.

getType

public int getType()
Returns the type of the attachment.

Returns:
int indicating one of the several types like TYPE_URL or TYPE_TEXT.

setType

public void setType(int attachmentType)
Sets the attachment type.

Parameters:
attachmentType - the type of the attachment like TYPE_URL or TYPE_TEXT.

getTypeDesc

public String getTypeDesc()
Returns the short text of the attachment type. This description is in English language.

Returns:
String containing brief text that describes the attachment type.

getTitle

public String getTitle()
Returns the title of the attachment.

Returns:
String containing the title of the attachment.

getAuthor

public String getAuthor()
Returns:
String the creator of the attachment. Null if no info is available, eg. for CRM object

getDescription

public String getDescription()
Returns:
String the description of the attachment. Null if not available.

getCreatedTime

public Date getCreatedTime()
Returns:
Date the created time of the attachment. Null if no info is available, eg. for CRM object.

getPriority

public PriorityEnum getPriority()
Returns:
PriorityEnum the priority of the attachment. Null if no info is available, eg. for CRM object.
See Also:
com.sap.netweaver.bc.uwl.PriorityEnum.

getInternalId

public String getInternalId()
Returns:
String the internal ID of the attachment (if any).

getFileSize

public int getFileSize()
Returns:
int the file size (in byte) of the file.

getFileName

public String getFileName()
Returns:
String the filename(if any) of the file. Null if attachment is not of document file type, or return empty string if the filename is not available....

getName

public String getName()
Returns:
String the name(if any) of the attachment.

getFileExtension

public String getFileExtension()
Returns:
String the file extension in literal string. Return empty string if attachment does not has a file extension or file extension cannot be resolved.

getMimeType

public String getMimeType()
Returns:
String the mime type for the attachment. if any. Null if not supported.

setFileName

public final void setFileName(String fileName)
If a physical file exists for an attachment, the file name can be saved.

Parameters:
fileName - File name of an attachment

setName

public final void setName(String name)
Parameters:
name - name of an attachment

setContent

public void setContent(Object content)
                throws UWLException
The content of attachment is set through this method. Valid content types are String and byte array,Actions for type TYPE_ACTION. Can also set content to null. Otherwise, UWLException is thrown.

Parameters:
content -
Throws:
UWLException

getContent

public Object getContent()
Returns:
Object the content of the attachment, either a string for a URL attachment type, or a byte array for a document type. Return null if no content available.

isMemo

public boolean isMemo()
An Attachment is of memo type if its type is Attachment.TYPE_MEMO or Attachment.TYPE_RAW_DATA or Attachment.TYPE_TEXT

Returns:
true if it is memo

createForUpload

public static Attachment createForUpload(String title,
                                         String filename,
                                         String fileExtension,
                                         Object content,
                                         int type)
                                  throws UWLException
Creates an attachment instance for file uploading scenario.

Parameters:
title - Can be null. Filename will be used as title display
filename - Filename
fileExtension - File extension, if any.
content - in ByteArrayStream for file upload
type - Attachment.TYPE_TEXT or Attachment.TYPE_MIME_DATA or Attachment.TYPE_UNKNOWN_DATA
Returns:
the created attachment with basic data of the file to be uploaded
Throws:
UWLException

isRequiredReading

public boolean isRequiredReading()
This is used to determine if the attachment should be indicated to the user as required reading. In the UI this atachment will be displayed to indicate it should be read before processing the Task.

Returns:
boolean - True if it should be read else false is returned.

setRequiredReading

public void setRequiredReading(boolean b)
Indicate to the user if this attachment is required reading.

Parameters:
b - - True if it should be read else set to false.


Copyright 2009 SAP AG Complete Copyright Notice