org.alfresco.filesys.state
Class FileState

java.lang.Object
  extended by org.alfresco.filesys.state.FileState

public class FileState
extends java.lang.Object

File State Class

Keeps track of file state across all sessions on the server, to keep track of file sharing modes, file locks and also for synchronizing access to files/folders.


Nested Class Summary
static class FileState.FileStateStatus
           
 
Field Summary
static long DefTimeout
           
static long NoTimeout
           
static long RenameTimeout
           
 
Constructor Summary
FileState(java.lang.String fname, boolean isdir)
          Class constructor
 
Method Summary
 void addLock(org.alfresco.jlan.locking.FileLock lock)
          Add a lock to this file
 void addPseudoFile(org.alfresco.jlan.server.filesys.pseudo.PseudoFile pfile)
          Add a pseudo file to this folder
 boolean allowsOpen(org.alfresco.jlan.server.filesys.FileOpenParams params)
          Check if the file can be opened depending on any current file opens and the sharing mode of the first file open
 boolean canReadFile(long offset, long len, int pid)
          Check if the file is readable for the specified section of the file and process id
 boolean canWriteFile(long offset, long len, int pid)
          Check if the file is writeable for the specified section of the file and process id
 int decrementOpenCount()
          Decrement the file open count
 boolean exists()
          Determine if the file/folder exists
 long getAccessDateTime()
          Return the access date/time
 long getChangeDateTime()
          Return the change date/time
 FileState.FileStateStatus getFileStatus()
          Return the file status
 long getModifyDateTime()
          Return the modify date/time
 NodeRef getNodeRef()
          Return the associated node
 int getOpenCount()
          Return the file open count
 java.lang.String getPath()
          Return the file name/path
 org.alfresco.jlan.server.filesys.pseudo.PseudoFileList getPseudoFileList()
          Return the pseudo file list
 FileState getRenameState()
          Return the associated rename state
 long getSecondsToExpire(long curTime)
          Return the number of seconds left before the file state expires
 int getSharedAccess()
          Return the shared access mode
 boolean hasAccessDateTime()
          Check if the access date/time has been set
 boolean hasActiveLocks()
          Check if there are active locks on this file
 boolean hasChangeDateTime()
          Check if the change date/time has been set
 boolean hasExpired(long curTime)
          Check if the file state has expired
 boolean hasModifyDateTime()
          Check if the modification date/time has been set
 boolean hasNodeRef()
          Determine if the associated node has been set
 boolean hasNoTimeout()
          Check if this file state does not expire
 boolean hasPseudoFiles()
          Determine if a folder has pseudo files associated with it
 boolean hasRenameState()
          Determine if the file state has an associated rename state
 int incrementOpenCount()
          Increment the file open count
 boolean isDirectory()
          Return the directory state
static java.lang.String normalizePath(java.lang.String path)
          Normalize the path to uppercase the directory names and keep the case of the file name.
 int numberOfLocks()
          Return the count of active locks on this file
 void removeLock(org.alfresco.jlan.locking.FileLock lock)
          Remove a lock on this file
 void setExpiryTime(long expire)
          Set the file state expiry time
 void setFileStatus(FileState.FileStateStatus status)
          Set the file status
 void setFileStatus(int fsts)
          Set the file status
 void setNodeRef(NodeRef nodeRef)
          Set the node ref for the file/folder
 void setPath(java.lang.String path)
          Set the file path
 void setRenameState(FileState fstate)
          Set the associated file state when a file is renamed, this is the link to the new file state
 void setSharedAccess(int mode)
          Set the shared access mode, from the first file open
 java.lang.String toString()
          Return the file state as a string
 void updateAccessDateTime()
          Update the access date/time
 void updateChangeDateTime()
          Update the change date/time
 void updateModifyDateTime()
          Update the modify date/time
 void updateModifyDateTime(long modTime)
          Update the modify date/time
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NoTimeout

public static final long NoTimeout
See Also:
Constant Field Values

DefTimeout

public static final long DefTimeout
See Also:
Constant Field Values

RenameTimeout

public static final long RenameTimeout
See Also:
Constant Field Values
Constructor Detail

FileState

public FileState(java.lang.String fname,
                 boolean isdir)
Class constructor

Parameters:
fname - String
isdir - boolean
Method Detail

getPath

public final java.lang.String getPath()
Return the file name/path

Returns:
String

getFileStatus

public final FileState.FileStateStatus getFileStatus()
Return the file status

Returns:
FileStateStatus

exists

public final boolean exists()
Determine if the file/folder exists

Returns:
boolen

isDirectory

public final boolean isDirectory()
Return the directory state

Returns:
boolean

hasNodeRef

public final boolean hasNodeRef()
Determine if the associated node has been set

Returns:
boolean

getNodeRef

public final NodeRef getNodeRef()
Return the associated node

Returns:
NodeRef

getOpenCount

public final int getOpenCount()
Return the file open count

Returns:
int

getSharedAccess

public final int getSharedAccess()
Return the shared access mode

Returns:
int

hasActiveLocks

public final boolean hasActiveLocks()
Check if there are active locks on this file

Returns:
boolean

hasNoTimeout

public final boolean hasNoTimeout()
Check if this file state does not expire

Returns:
boolean

allowsOpen

public final boolean allowsOpen(org.alfresco.jlan.server.filesys.FileOpenParams params)
Check if the file can be opened depending on any current file opens and the sharing mode of the first file open

Parameters:
params - FileOpenParams
Returns:
boolean

incrementOpenCount

public final int incrementOpenCount()
Increment the file open count

Returns:
int

decrementOpenCount

public final int decrementOpenCount()
Decrement the file open count

Returns:
int

hasExpired

public final boolean hasExpired(long curTime)
Check if the file state has expired

Parameters:
curTime - long
Returns:
boolean

getSecondsToExpire

public final long getSecondsToExpire(long curTime)
Return the number of seconds left before the file state expires

Parameters:
curTime - long
Returns:
long

hasRenameState

public final boolean hasRenameState()
Determine if the file state has an associated rename state

Returns:
boolean

getRenameState

public final FileState getRenameState()
Return the associated rename state

Returns:
FileState

hasPseudoFiles

public final boolean hasPseudoFiles()
Determine if a folder has pseudo files associated with it

Returns:
boolean

getPseudoFileList

public final org.alfresco.jlan.server.filesys.pseudo.PseudoFileList getPseudoFileList()
Return the pseudo file list

Returns:
PseudoFileList

addPseudoFile

public final void addPseudoFile(org.alfresco.jlan.server.filesys.pseudo.PseudoFile pfile)
Add a pseudo file to this folder

Parameters:
pfile - PseudoFile

setFileStatus

public final void setFileStatus(FileState.FileStateStatus status)
Set the file status

Parameters:
status - FileStateStatus

setFileStatus

public final void setFileStatus(int fsts)
Set the file status

Parameters:
fsts - int

setExpiryTime

public final void setExpiryTime(long expire)
Set the file state expiry time

Parameters:
expire - long

setNodeRef

public final void setNodeRef(NodeRef nodeRef)
Set the node ref for the file/folder

Parameters:
nodeRef - NodeRef

setRenameState

public final void setRenameState(FileState fstate)
Set the associated file state when a file is renamed, this is the link to the new file state

Parameters:
fstate - FileState

setSharedAccess

public final void setSharedAccess(int mode)
Set the shared access mode, from the first file open

Parameters:
mode - int

setPath

public final void setPath(java.lang.String path)
Set the file path

Parameters:
path - String

numberOfLocks

public final int numberOfLocks()
Return the count of active locks on this file

Returns:
int

addLock

public final void addLock(org.alfresco.jlan.locking.FileLock lock)
                   throws org.alfresco.jlan.locking.LockConflictException
Add a lock to this file

Parameters:
lock - FileLock
Throws:
org.alfresco.jlan.locking.LockConflictException

removeLock

public final void removeLock(org.alfresco.jlan.locking.FileLock lock)
                      throws org.alfresco.jlan.locking.NotLockedException
Remove a lock on this file

Parameters:
lock - FileLock
Throws:
org.alfresco.jlan.locking.NotLockedException

hasAccessDateTime

public final boolean hasAccessDateTime()
Check if the access date/time has been set

Returns:
boolean

getAccessDateTime

public final long getAccessDateTime()
Return the access date/time

Returns:
long

updateAccessDateTime

public final void updateAccessDateTime()
Update the access date/time


hasChangeDateTime

public final boolean hasChangeDateTime()
Check if the change date/time has been set

Returns:
boolean

getChangeDateTime

public final long getChangeDateTime()
Return the change date/time

Returns:
long

updateChangeDateTime

public final void updateChangeDateTime()
Update the change date/time


hasModifyDateTime

public final boolean hasModifyDateTime()
Check if the modification date/time has been set

Returns:
boolean

getModifyDateTime

public final long getModifyDateTime()
Return the modify date/time

Returns:
long

updateModifyDateTime

public final void updateModifyDateTime()
Update the modify date/time


updateModifyDateTime

public final void updateModifyDateTime(long modTime)
Update the modify date/time

Parameters:
modTime - long

canReadFile

public final boolean canReadFile(long offset,
                                 long len,
                                 int pid)
Check if the file is readable for the specified section of the file and process id

Parameters:
offset - long
len - long
pid - int
Returns:
boolean

canWriteFile

public final boolean canWriteFile(long offset,
                                  long len,
                                  int pid)
Check if the file is writeable for the specified section of the file and process id

Parameters:
offset - long
len - long
pid - int
Returns:
boolean

normalizePath

public static final java.lang.String normalizePath(java.lang.String path)
Normalize the path to uppercase the directory names and keep the case of the file name.

Parameters:
path - String
Returns:
String

toString

public java.lang.String toString()
Return the file state as a string

Overrides:
toString in class java.lang.Object
Returns:
String


Copyright © 2005 - 2008 Alfresco Software, Inc. All Rights Reserved.