2.17.2: 2011-06-17

net.sf.basedb.core
Class FileSetMember

java.lang.Object
  extended by net.sf.basedb.core.BasicItem<FileSetMemberData>
      extended by net.sf.basedb.core.FileSetMember
All Implemented Interfaces:
AccessControlled, Identifiable

public class FileSetMember
extends BasicItem<FileSetMemberData>

This class represents a file that is member of a file set.

Version:
2.5
Author:
Nicklas
Last modified
$Date: 2009-02-11 12:59:25 +0100 (Wed, 11 Feb 2009) $

Nested Class Summary
private static class FileSetMember.QueryRuntimeFilterImpl
           
 
Field Summary
private static QueryRuntimeFilter RUNTIME_FILTER
          This filter gives everybody read permission to file set members.
static Item TYPE
          The type of item represented by this class.
 
Constructor Summary
FileSetMember(FileSetMemberData data)
          Creates a new member item from the given data.
 
Method Summary
static FileSetMember getById(DbControl dc, int id)
          Get a FileSetMember object when you know the ID.
 DataFileType getDataFileType()
          Get the type of the file.
 String getErrorMessage()
          Get the error message if the validation failed.
 File getFile()
          Get the file this item is representing in the file set.
 FileSet getFileSet()
          Get the file set the file is a member of.
(package private) static FileSetMember getNew(DbControl dc, FileSet fileSet, File file, DataFileType type)
          Create a new member in a file set.
(package private)  PluginPermission getPluginPermissions()
           
static ItemQuery<FileSetMember> getQuery(FileSet fileSet)
          Get a query configured to retrieve FileSetMember items.
 Item getType()
          Get the type of item represented by the object.
(package private)  void initPermissions(int granted, int denied)
          READ permission is granted to all users.
 boolean isPlatformFile()
          Checks if this file is part of the platform/variant the parent item belongs to.
 Boolean isValid()
          Check if the file has been validated and if it passed or not.
 void setValid(Boolean valid, String errorMessage)
          Set the validation status of this member.
 
Methods inherited from class net.sf.basedb.core.BasicItem
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterCommit, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, toTransferable, validate
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE

public static final Item TYPE
The type of item represented by this class.

See Also:
Item.FILESETMEMBER, getType()

RUNTIME_FILTER

private static final QueryRuntimeFilter RUNTIME_FILTER
This filter gives everybody read permission to file set members.

Constructor Detail

FileSetMember

FileSetMember(FileSetMemberData data)
Creates a new member item from the given data.

Parameters:
data - the data.
Method Detail

getNew

static FileSetMember getNew(DbControl dc,
                            FileSet fileSet,
                            File file,
                            DataFileType type)
Create a new member in a file set.

See Also:
FileSet.setMember(File, DataFileType)

getById

public static FileSetMember getById(DbControl dc,
                                    int id)
                             throws ItemNotFoundException,
                                    PermissionDeniedException,
                                    BaseException
Get a FileSetMember object when you know the ID.

Parameters:
dc - The DbControl which will be used for permission checking and database access.
id - The ID of the item to load
Returns:
The FileSetMember item
Throws:
ItemNotFoundException - If an item with the specified ID is not found
PermissionDeniedException - If the logged in user doesn't have Permission.READ permission to the items
BaseException - If there is another error

getQuery

public static ItemQuery<FileSetMember> getQuery(FileSet fileSet)
                                         throws BaseException
Get a query configured to retrieve FileSetMember items.

Parameters:
fileSet - The file set to get members for, null is not allowed
Returns:
An ItemQuery object
Throws:
InvalidUseOfNullException - If required argument is null.
BaseException - If there is another error.

getType

public Item getType()
Description copied from interface: Identifiable
Get the type of item represented by the object. The returned value is one of the values defined in the Item enumeration.

Returns:
A value indicating the type of item

initPermissions

void initPermissions(int granted,
                     int denied)
               throws BaseException
READ permission is granted to all users. CREATE, WRITE and DELETE permissions are granted if the logged in user has WRITE permission on the associated file set.

Overrides:
initPermissions in class BasicItem<FileSetMemberData>
Parameters:
granted - Permissions that have been granted by the subclass
denied - Permissions that have been denied by the subclass
Throws:
BaseException - If the permissions couldn't be initialised

getPluginPermissions

PluginPermission getPluginPermissions()
Overrides:
getPluginPermissions in class BasicItem<FileSetMemberData>

getFileSet

public FileSet getFileSet()
Get the file set the file is a member of.

Returns:
A file set item

getFile

public File getFile()
Get the file this item is representing in the file set.

Returns:
A file item

getDataFileType

public DataFileType getDataFileType()
Get the type of the file.

Returns:
A file set member type item

isValid

public Boolean isValid()
Check if the file has been validated and if it passed or not.

Returns:
NULL if the file hasn't been validated, TRUE or FALSE to indicate the result of the validation

setValid

public void setValid(Boolean valid,
                     String errorMessage)
Set the validation status of this member.

Parameters:
valid - If the member file is valid or not, use null to indicate that no validation has been performed
errorMessage - The error message if the validation failes

getErrorMessage

public String getErrorMessage()
Get the error message if the validation failed.

Returns:
The error message or null if the file is valid or if it hasn't been validated

isPlatformFile

public boolean isPlatformFile()
Checks if this file is part of the platform/variant the parent item belongs to.

Returns:
TRUE if the file is part of the platform, FALSE otherwise
Since:
2.10

2.17.2: 2011-06-17