org.dspace.authorize
Class ResourcePolicy

java.lang.Object
  extended by org.dspace.authorize.ResourcePolicy

public class ResourcePolicy
extends Object

Class representing a ResourcePolicy

Version:
$Revision: 3735 $
Author:
David Stuve

Method Summary
static ResourcePolicy create(Context context)
          Create a new ResourcePolicy
 void delete()
          Delete an ResourcePolicy
static ResourcePolicy find(Context context, int id)
          Get an ResourcePolicy from the database.
 int getAction()
           
 String getActionText()
           
 Date getEndDate()
          Get end date for the policy
 EPerson getEPerson()
          get EPerson this policy relates to
 int getEPersonID()
           
 Group getGroup()
          gets Group for this policy
 int getGroupID()
          gets ID for Group referred to by this policy
 int getID()
          Get the e-person's internal identifier
 int getResourceID()
          Get the ID of a resource pointed to by the policy (is null if policy doesn't apply to a single resource.)
 int getResourceType()
          Get the type of the objects referred to by policy
 Date getStartDate()
          Get the start date of the policy
 boolean isDateValid()
          figures out if the date is valid for the policy
 void setAction(int myid)
          set the action this policy authorizes
 void setEndDate(Date d)
          Set end date for the policy
 void setEPerson(EPerson e)
          assign an EPerson to this policy
 void setGroup(Group g)
          set Group for this policy
 void setResource(DSpaceObject o)
          set both type and id of resource referred to by policy
 void setResourceID(int myid)
          If the policy refers to a single resource, this is the ID of that resource.
 void setResourceType(int mytype)
          Set the type of the resource referred to by the policy
 void setStartDate(Date d)
          Set the start date for the policy
 void update()
          Update the ResourcePolicy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

find

public static ResourcePolicy find(Context context,
                                  int id)
                           throws SQLException
Get an ResourcePolicy from the database.

Parameters:
context - DSpace context object
id - ID of the ResourcePolicy
Returns:
the ResourcePolicy format, or null if the ID is invalid.
Throws:
SQLException

create

public static ResourcePolicy create(Context context)
                             throws SQLException,
                                    AuthorizeException
Create a new ResourcePolicy

Parameters:
context - DSpace context object
Throws:
SQLException
AuthorizeException

delete

public void delete()
            throws SQLException
Delete an ResourcePolicy

Throws:
SQLException

getID

public int getID()
Get the e-person's internal identifier

Returns:
the internal identifier

getResourceType

public int getResourceType()
Get the type of the objects referred to by policy

Returns:
type of object/resource

setResource

public void setResource(DSpaceObject o)
set both type and id of resource referred to by policy


setResourceType

public void setResourceType(int mytype)
Set the type of the resource referred to by the policy

Parameters:
mytype - type of the resource

getResourceID

public int getResourceID()
Get the ID of a resource pointed to by the policy (is null if policy doesn't apply to a single resource.)

Returns:
resource_id

setResourceID

public void setResourceID(int myid)
If the policy refers to a single resource, this is the ID of that resource.

Parameters:
myid - id of resource (database primary key)

getAction

public int getAction()
Returns:
get the action this policy authorizes

getActionText

public String getActionText()
Returns:
action text or 'null' if action row empty

setAction

public void setAction(int myid)
set the action this policy authorizes

Parameters:
myid - action ID from org.dspace.core.Constants

getEPersonID

public int getEPersonID()
Returns:
eperson ID, or -1 if EPerson not set

getEPerson

public EPerson getEPerson()
                   throws SQLException
get EPerson this policy relates to

Returns:
EPerson, or null
Throws:
SQLException

setEPerson

public void setEPerson(EPerson e)
assign an EPerson to this policy

Parameters:
e - EPerson

getGroupID

public int getGroupID()
gets ID for Group referred to by this policy

Returns:
groupID, or -1 if no group set

getGroup

public Group getGroup()
               throws SQLException
gets Group for this policy

Returns:
Group, or -1 if no group set
Throws:
SQLException

setGroup

public void setGroup(Group g)
set Group for this policy

Parameters:
g - group

isDateValid

public boolean isDateValid()
figures out if the date is valid for the policy

Returns:
true if policy has begun and hasn't expired yet (or no dates are set)

getStartDate

public Date getStartDate()
Get the start date of the policy

Returns:
start date, or null if there is no start date set (probably most common case)

setStartDate

public void setStartDate(Date d)
Set the start date for the policy

Parameters:
d - date, or null for no start date

getEndDate

public Date getEndDate()
Get end date for the policy

Returns:
end date or null for no end date

setEndDate

public void setEndDate(Date d)
Set end date for the policy

Parameters:
d - end date, or null

update

public void update()
            throws SQLException
Update the ResourcePolicy

Throws:
SQLException


Copyright © 2010 DuraSpace. All Rights Reserved.