ALBPM Process API (PAPI)

fuego.papi
Interface Attachment

All Superinterfaces:
AttachmentInterface

public interface Attachment
extends AttachmentInterface

Represents an Attachment associated with an instance.

This class contains information about attachment properties: content type, creator name, created time, description, edition time (version) filename, name, remarks size and other properties. It also contains methods to determine if the file exists and to save the file as another file.

To add an attachment to an instance, use ProcessServiceSession.instanceAttach(InstanceInfo, String, String, String, java.io.File, String).
To get the list of attachments associated with an instance, use ProcessServiceNESession.getAttachmentsByInstance(String).
To check out an attachment and write it to a directory, use ProcessServiceSession.obtainEditionLock(Attachment) then ProcessServiceSession.checkOutAttachment(Attachment, String).
To check in an attachment and create a new version, use ProcessServiceSession.checkInAttachment(Attachment, String, java.io.File).


Field Summary
static int DESCRIPT_LENGTH
          Constant for the maximum length of description.
static int FILENAME_LENGTH
          Constant for the maximum length of a filename.
static int REMARK_LENGTH
          Constant for maximum length of remarks.
 
Method Summary
 boolean existsFile(String directory)
          Returns true if the attachment has already been checked out in the specified directory.
 long getContentSize()
          Gets the content size in bytes.
 String getContentType()
          Gets the file content type.
 Time getCreationTime()
          Gets the attachment creation time.
 String getCreatorName()
          Gets the Id of the participant who created this attachment.
 String getDescription()
          Gets the attachment description.
 Time getEditionTime()
          Gets the edition time, which is the version creation time.
 String getFileExtension()
          Gets the file extension, for example txt, doc.
 String getFileName()
          Gets the filename used to save the attachment to disk.
 String getId()
          Gets the attachment Id.
 int getIn()
          Gets the attachment identification number.
 String getInstanceId()
          Gets the instance Id of the instance where this attachment was attached.
 int getInstanceIn()
          Gets the instance identification number of the instance where this attachment was attached.
 String getLocaleSize(Locale locale)
          Gets the size of this attachment, formatted using the specified locale.
 String getLockerName()
          Gets the uid of the participant who has locked this attachment, or the empty string is this attachment is not locked.
 String getName()
          Gets the name of this attachment.
 String getOsInfo()
          Deprecated. Method getOsInfo is deprecated.
 int getProcessIn()
          Gets the process identification number associated with this attachment.
 String getRemarks()
          Gets the remarks for this version of the attachment.
 Object getVar(String variableId)
          Returns Object value of the VarDefinition specified by variableId.
 int getVersion()
          Gets the version number of this attachment.
 boolean isFileModified(String directory)
          Returns true if the attachment has already been checked out in the specified directory, and the file has been modified.
 boolean isLocked()
          Returns true if this attachment has been locked.
 boolean isLockedByParticipant(String participantId)
          Returns true if this attachment has been locked by the specified participant.
 void saveAs(String attachmentsDirectory, File file)
          Saves the file in the specified directory.
 

Field Detail

DESCRIPT_LENGTH

public static final int DESCRIPT_LENGTH
Constant for the maximum length of description.

See Also:
Constant Field Values

FILENAME_LENGTH

public static final int FILENAME_LENGTH
Constant for the maximum length of a filename.

See Also:
Constant Field Values

REMARK_LENGTH

public static final int REMARK_LENGTH
Constant for maximum length of remarks.

See Also:
Constant Field Values
Method Detail

getContentSize

public long getContentSize()
Gets the content size in bytes.

Specified by:
getContentSize in interface AttachmentInterface
Returns:
the content size in bytes.

getContentType

public String getContentType()
Gets the file content type. For example, "text/plain" or "application/ms-word".

Specified by:
getContentType in interface AttachmentInterface
Returns:
Content type

getCreationTime

public Time getCreationTime()
Gets the attachment creation time.

Specified by:
getCreationTime in interface AttachmentInterface
Returns:
Attachment creation time.

getCreatorName

public String getCreatorName()
Gets the Id of the participant who created this attachment.

Specified by:
getCreatorName in interface AttachmentInterface
Returns:
Id of the participant who created this attachment

getDescription

public String getDescription()
Gets the attachment description.

The description is only set when the attachment is created; remarks are set for each version.

Specified by:
getDescription in interface AttachmentInterface
Returns:
Attachment description.

getEditionTime

public Time getEditionTime()
Gets the edition time, which is the version creation time. If there is only one version, this will be the same as getCreationTime.

Specified by:
getEditionTime in interface AttachmentInterface
Returns:
edition time or null if it is not locked

getFileExtension

public String getFileExtension()
Gets the file extension, for example txt, doc. Does not include the period.

Returns:
file extension

isFileModified

public boolean isFileModified(String directory)
Returns true if the attachment has already been checked out in the specified directory, and the file has been modified.

Parameters:
directory - directory to check for the file. Cannot be null.
Returns:
true if the attachment has already been checked out in the specified directory, and the file has been modified.

getFileName

public String getFileName()
Gets the filename used to save the attachment to disk.

Returns:
filename used to save the attachment to disk.

getId

public String getId()
Gets the attachment Id.

The format of the attachment id is "InstanceId/AttachmentIn/Version"

Specified by:
getId in interface AttachmentInterface
Returns:
attachment Id

getIn

public int getIn()
Gets the attachment identification number.

Returns:
Attachment identification number.

getInstanceId

public String getInstanceId()
Gets the instance Id of the instance where this attachment was attached.

Returns:
instance Id of the instance where this attachment was attached.

getInstanceIn

public int getInstanceIn()
Gets the instance identification number of the instance where this attachment was attached.

Returns:
instance identification number of the instance where this attachment was attached.

getLocaleSize

public String getLocaleSize(Locale locale)
Gets the size of this attachment, formatted using the specified locale.

Parameters:
locale - locale to use for formatting. Cannot be null.
Returns:
Size of this attachment, formatted using the specified locale.

isLocked

public boolean isLocked()
Returns true if this attachment has been locked.

Returns:
true if this attachment has been locked.

isLockedByParticipant

public boolean isLockedByParticipant(String participantId)
Returns true if this attachment has been locked by the specified participant.

Parameters:
participantId - uid of participant to check. Cannot be null.
Returns:
true if this attachment has been locked by the specified participant.

getLockerName

public String getLockerName()
Gets the uid of the participant who has locked this attachment, or the empty string is this attachment is not locked.

Specified by:
getLockerName in interface AttachmentInterface
Returns:
Uid of the participant who has locked this attachment, or the empty string is this attachment is not locked.

getName

public String getName()
Gets the name of this attachment.

While this is usually the filename, it can be set programmatically using ProcessServiceSession.instanceAttach(InstanceInfo, String, String, String, java.io.File), so there is no guarantee that it is the filename.

Specified by:
getName in interface AttachmentInterface
Returns:
Attachment name.

getOsInfo

public String getOsInfo()
Deprecated. Method getOsInfo is deprecated.

Gets information about the operating system.

Returns:
information about the operating system.

getProcessIn

public int getProcessIn()
Gets the process identification number associated with this attachment.

Returns:
Process identification number associated with this attachment.

getRemarks

public String getRemarks()
Gets the remarks for this version of the attachment.

Specified by:
getRemarks in interface AttachmentInterface
Returns:
Remarks for this version of the attachment.

getVar

public Object getVar(String variableId)
              throws InvalidVariableIdException
Returns Object value of the VarDefinition specified by variableId. The following VarDefinitions are associated with instances:

Parameters:
variableId - VarDefinition Id. Cannot be null.
Returns:
Object value of VarDefinition specified by variableId.
Throws:
InvalidVariableIdException - if there is no matching VarDefinition.

getVersion

public int getVersion()
Gets the version number of this attachment.

Specified by:
getVersion in interface AttachmentInterface
Returns:
Version number of this attachment.

existsFile

public boolean existsFile(String directory)
                   throws IOException
Returns true if the attachment has already been checked out in the specified directory.

Parameters:
directory - directory to check. Cannot be null.
Returns:
true if the attachment has already been checked out in the specified directory.
Throws:
IOException - if an IO error occured searching the file.

saveAs

public void saveAs(String attachmentsDirectory,
                   File file)
            throws FileNotFoundException,
                   SecurityException,
                   IOException
Saves the file in the specified directory.

Parameters:
attachmentsDirectory - where to save the file. Cannot be null.
file - file to save. Cannot be null.
Throws:
FileNotFoundException - if unable to find the file.
SecurityException - if unable to write the file to the specified directory
IOException - if an IO error occured reading or writing the file.

ALBPM Process API (PAPI)

© Copyright 1996/2005 Fuego Inc. All Rights Reserved