com.sas.drugdev.remote.repository
Class FileBean

java.lang.Object
  extended bycom.sas.drugdev.remote.repository.NodeBean
      extended bycom.sas.drugdev.remote.repository.FileBean
All Implemented Interfaces:
File, Node

public class FileBean
extends NodeBean
implements File

Simple bean to represent a file. This can be constructed various ways. This class allows the user to construct a File object without requiring a server call.

It is the only way to create a File on the server. Construct a FileBean, then pass it into RepositoryService.createFile(FileBean).

It is also the only means for performing write operations on the File, such as updating content and metadata. Construct a FileBean object then call NodeBean.setProperties(java.util.Map) NodeBean.setProperty(String, String) or setContents(InputStream) method. Then pass that bean into RepositoryService.updateNode(NodeBean) to perform those operations on the server side.


Field Summary
 
Fields inherited from class com.sas.drugdev.remote.repository.NodeBean
PROPERTY_COPIEDFROM, PROPERTY_CREATED_BY, PROPERTY_CREATIONDATE, PROPERTY_DISPLAYNAME, PROPERTY_GETCONTENTLENGTH, PROPERTY_GETLASTMODIFIED, PROPERTY_HAVE_SIGNED, PROPERTY_HREF, PROPERTY_ID, PROPERTY_IS_SIGNED, PROPERTY_LAST_UPLOAD_DATE, PROPERTY_LAST_UPLOAD_HOST, PROPERTY_LAST_UPLOAD_PATH, PROPERTY_LAST_UPLOADED_BY, PROPERTY_LOCKED, PROPERTY_LOCKED_BY, PROPERTY_MODIFIED_BY, PROPERTY_MUST_SIGN, PROPERTY_OWNER, PROPERTY_PATH, PROPERTY_REMOTE_REFRESHABLE, PROPERTY_SIGNING_STATUS, PROPERTY_TYPEDEF_ID, PROPERTY_TYPEDEF_NAME, SYSTEM_PROPERTIES
 
Constructor Summary
FileBean(NodeId id)
          Constructor that takes only an NodeId.
FileBean(NodeId id, FileVersion version)
          Construct a FileBean that points to a particular version of the file with the given id.
FileBean(RemoteFile remoteFile)
          Constructor that takes a RemoteFile.
FileBean(java.lang.String path)
          Construct a FileBean with just the path.
FileBean(java.lang.String path, FileVersion version)
          Construct a FileBean that points to a particular version of the file at the given path.
FileBean(java.lang.String path, Type type)
          Construct the FileBean with a type and a path.
 
Method Summary
 java.io.InputStream getContents()
          Gets the contents of the file as an InputStream.
 java.io.File getFileContents()
          Gets the contents of the file as a File.
 FileVersion getVersion()
          Get the version of this file
 void setContents(java.io.File localFile)
          Sets the contents of a file with the contents of the local file passed in.
 void setContents(java.io.InputStream contents)
          Set the contents of the file.
 
Methods inherited from class com.sas.drugdev.remote.repository.NodeBean
getId, getPath, getProperties, getType, setProperties, setProperty
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sas.drugdev.remote.repository.Node
getId, getPath, getProperties, getType
 

Constructor Detail

FileBean

public FileBean(NodeId id)
Constructor that takes only an NodeId.

Parameters:
id - id with which to populate the FileBean

FileBean

public FileBean(RemoteFile remoteFile)
Constructor that takes a RemoteFile. This is useful for updating entities. If a ContainerBean is constructed using a remote node, then checking is done on the server when an node is moved or updated to ensure that it hasn't been modified since it was retrieved. All the properties from the remote file are copied into the properties of this bean.

Parameters:
remoteFile - remoteFile with which to populate the FileBean

FileBean

public FileBean(java.lang.String path)
Construct a FileBean with just the path.

Parameters:
path - path with which to populate the FileBean

FileBean

public FileBean(java.lang.String path,
                FileVersion version)
Construct a FileBean that points to a particular version of the file at the given path. Using this constructor you can get the contents of a version of a file.

Parameters:
path - path of the file
version - version of the file

FileBean

public FileBean(NodeId id,
                FileVersion version)
Construct a FileBean that points to a particular version of the file with the given id. Using this constructor you can get the contents of a version of a file.

Parameters:
id - id of the file
version - version of the file

FileBean

public FileBean(java.lang.String path,
                Type type)
Construct the FileBean with a type and a path. This is the constructor that must be used for creating files.

Parameters:
path - path of the file you are creating
type - type of the file you are creating
Method Detail

setContents

public void setContents(java.io.InputStream contents)
Set the contents of the file. The contents are not saved and the InputStream is not read until you call RepositoryService.updateNode(NodeBean) or RepositoryService.createFile(FileBean).

Parameters:
contents - InputStream to use as the contents of this file.

setContents

public void setContents(java.io.File localFile)
Sets the contents of a file with the contents of the local file passed in. The contents are not saved and the local file is not read until you call RepositoryService.updateNode(NodeBean) or RepositoryService.createFile(FileBean).

Parameters:
localFile - File object pointing to a local file.

getVersion

public FileVersion getVersion()
Description copied from interface: File
Get the version of this file

Specified by:
getVersion in interface File
Returns:
Version of the file

getContents

public java.io.InputStream getContents()
Gets the contents of the file as an InputStream.

Returns:
InputStream containing the contents of the file

getFileContents

public java.io.File getFileContents()
Gets the contents of the file as a File.

Returns:
File containing the contents of the file