org.dspace.sword
Class SWORDContext

java.lang.Object
  extended by org.dspace.sword.SWORDContext

public class SWORDContext
extends Object

This class holds information about authenticated users (both the depositing user and the on-behalf-of user), and their associated DSpace Context objects. Since this class will be used to make authentication requests on both user types, it may hold up to 2 active DSpace Context objects at any one time WARNING: failure to use the contexts used in this class in the appropriate way may result in exceptions or data loss. Unless you are performing authentication processes, you should always access the context under which to deposit content into the archive from: getContext() and not from any of the other context retrieval methods in this class

Author:
Richard Jones

Constructor Summary
SWORDContext()
           
 
Method Summary
 void abort()
          Abort all of the contexts held by this class.
 void commit()
          Commit the primary context held by this class, and abort the authenticated user's context if it is different.
 EPerson getAuthenticated()
           
 Context getAuthenticatorContext()
          Get the context of the user who authenticated.
 Context getContext()
          Returns the most appropriate context for operations on the database.
 EPerson getOnBehalfOf()
           
 Context getOnBehalfOfContext()
          Get the context of the on-behalf-of user.
 void setAuthenticated(EPerson authenticated)
           
 void setAuthenticatorContext(Context authenticatorContext)
           
 void setContext(Context context)
           
 void setOnBehalfOf(EPerson onBehalfOf)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SWORDContext

public SWORDContext()
Method Detail

getAuthenticated

public EPerson getAuthenticated()
Returns:
the authenticated user

setAuthenticated

public void setAuthenticated(EPerson authenticated)
Parameters:
authenticated - the eperson to set

getOnBehalfOf

public EPerson getOnBehalfOf()
Returns:
the onBehalfOf user

setOnBehalfOf

public void setOnBehalfOf(EPerson onBehalfOf)
Parameters:
onBehalfOf - the eperson to set

getContext

public Context getContext()
Returns the most appropriate context for operations on the database. This is the on-behalf-of user's context if the user exists, or the authenticated user's context otherwise

Returns:

setContext

public void setContext(Context context)

getAuthenticatorContext

public Context getAuthenticatorContext()
Get the context of the user who authenticated. This should only be used for authentication purposes. If there is an on-behalf-of user, that context should be used to write database changes. Use: getContext() on this class instead.

Returns:

setAuthenticatorContext

public void setAuthenticatorContext(Context authenticatorContext)

getOnBehalfOfContext

public Context getOnBehalfOfContext()
Get the context of the on-behalf-of user. This method should only be used for authentication purposes. In all other cases, use: getContext() on this class instead. If there is no on-behalf-of user, this method will return null.

Returns:

abort

public void abort()
Abort all of the contexts held by this class. No changes will be written to the database


commit

public void commit()
            throws DSpaceSWORDException
Commit the primary context held by this class, and abort the authenticated user's context if it is different. This ensures that only changes written through the appropriate user's context is persisted, and all other operations are flushed. You should, in general, not try to commit the contexts directly when using the sword api.

Throws:
DSpaceSWORDException


Copyright © 2011 DuraSpace. All Rights Reserved.