org.nuxeo.core.resources.model
Interface ISiteOperation

All Known Implementing Classes:
AbstractSiteOperation, CompositeSiteOperation, CreateOperation, DeleteOperation, EditOperation, GetChildrenOperation, GetContentsOperation, ModifyOperation, SetContentsOperation

public interface ISiteOperation

This object describe an operation on a site that may modify site resources. Operations are executed by the site controller through an operation handler.
This approach allows to redefine the operation handling at the site level. Thus, each type of site may define its own type of operations and its own handlers or may share operation and handlers with other type of sites.
Operation -> handler asociations are registered at the site controller level ISiteController#registerOperationHandler()

Site operations may support:

These features should not be implemented directly in the site controller, instead they should be hooked using the operation notification mechanism (that supports cancelation) provided by ISiteController
ISiteController.addOperationListener(ISiteOperationListener)
ISiteController.addOperationListener(ISiteOperationListener)
Operation objects may support or not some actions like security check, undo, redo, history log etc. This can be checked by getting the supported actions bit mask and checking if a particular action is supported. getFlags()

Operations should be lightweight objects because they may be stored temporarly in an undo/redo queue by an Undo manager.

Author:
Bogdan Stefanescu
See Also:
ISiteController#registerOperationHandler(), ISiteController.addOperationListener(ISiteOperationListener), ISiteController#execute(ISiteResource, String, java.util.List)

Field Summary
static int ANY
           
static int ASYNCHRONOUS
           
static java.lang.String COPY
           
static java.lang.String CREATE
           
static java.lang.String DELETE
           
static java.lang.String EDIT
           
static int HISTORY_ENABLED
           
static java.lang.String MOVE
           
static int NONE
           
static java.lang.String PUBLISH
           
static int RESTRICTED
           
static java.lang.String SUBMIT
           
static int UNDOABLE
           
 
Method Summary
 void clearFlag(int flag)
          Clear the given flag (set the corresponding bit to 0)
 void execute()
          Execute the operation.
 int getFlags()
          Get the supported actions on the operation as a bit mask.
 ISiteOperation getInverseOperation()
          Get the inverse operation.
 org.eclipse.core.runtime.IProgressMonitor getProgressMonitor()
          Get the progress monitor used by this operation or null if none
 ISiteOperationStatus getStatus()
          Get the operation status If the operation was not executed the status is null
 java.lang.String getType()
          Get the operation type
 boolean isAsynchronous()
          Tests whther the operation should be exectued asynchronously
 boolean isFlagSet(int flag)
          Tests if the given flag is set (the corresponding bit is 1)
 boolean isHistoryEnabled()
          Test whether ot nmot the operation should be logged
 boolean isRestricted()
          Test whether security checks should be done before executing the operation
 boolean isUndoable()
          Test whether the operation may be undoed.
 void setAsynchronous(boolean val)
          Set the asynchornous flag.
 void setFlag(int flag)
          Set the given flag (set the corresponding bit to 1)
 void setFlags(int flags)
          Set the supported actioons on the operation
 void setHistoryEnabled(boolean val)
          Set the history enabled flag
 void setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor monitor)
          Set the progress monitor to be used by the operation
 void setRestricted(boolean val)
          Set the security check flag.
 void setStatus(ISiteOperationStatus status)
          Set the operation status
 void setUndoable(boolean val)
          Set the undoable flag.
 

Field Detail

CREATE

static final java.lang.String CREATE
See Also:
Constant Field Values

DELETE

static final java.lang.String DELETE
See Also:
Constant Field Values

EDIT

static final java.lang.String EDIT
See Also:
Constant Field Values

COPY

static final java.lang.String COPY
See Also:
Constant Field Values

MOVE

static final java.lang.String MOVE
See Also:
Constant Field Values

PUBLISH

static final java.lang.String PUBLISH
See Also:
Constant Field Values

SUBMIT

static final java.lang.String SUBMIT
See Also:
Constant Field Values

NONE

static final int NONE
See Also:
Constant Field Values

ASYNCHRONOUS

static final int ASYNCHRONOUS
See Also:
Constant Field Values

UNDOABLE

static final int UNDOABLE
See Also:
Constant Field Values

RESTRICTED

static final int RESTRICTED
See Also:
Constant Field Values

HISTORY_ENABLED

static final int HISTORY_ENABLED
See Also:
Constant Field Values

ANY

static final int ANY
See Also:
Constant Field Values
Method Detail

getType

java.lang.String getType()
Get the operation type

Returns:
the operation type

execute

void execute()
             throws org.eclipse.core.runtime.CoreException
Execute the operation. The operation is determining the target site controller based on the resources it manipulates and the type of operation, then it is delegating the operation execution to the controller

Throws:
org.eclipse.core.runtime.CoreException - if an error occurs

getStatus

ISiteOperationStatus getStatus()
Get the operation status If the operation was not executed the status is null

Returns:
the operation status.

setStatus

void setStatus(ISiteOperationStatus status)
Set the operation status

Parameters:
status - the status to set

getProgressMonitor

org.eclipse.core.runtime.IProgressMonitor getProgressMonitor()
Get the progress monitor used by this operation or null if none

Returns:
the progress monitor used by this operation or null if none

setProgressMonitor

void setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor monitor)
Set the progress monitor to be used by the operation


getInverseOperation

ISiteOperation getInverseOperation()
Get the inverse operation. The inverse operation is used by an undo/redo manager to undo an operation. Note that it is not assumed that an inverse operation can be undoed (i.e. it may not provide an inverse op. of itself) Redoing an operation means undoing the inverse operation. So if the inverse operation is not undoable then the operation is not redoable. So operations supporting undo are not necesarly supporting redo

Returns:
the inverse operation

getFlags

int getFlags()
Get the supported actions on the operation as a bit mask. This is mainly used to specify what additional handling is supported by the operation. The default is NONE this means operation

Returns:
the supported actions on the operation as a bit mask

setFlags

void setFlags(int flags)
Set the supported actioons on the operation

Parameters:
flags - the bit mask of supported actions

isAsynchronous

boolean isAsynchronous()
Tests whther the operation should be exectued asynchronously

Returns:
true if operation should be executed asynchronously, false otherwise

setAsynchronous

void setAsynchronous(boolean val)
Set the asynchornous flag. An asynchronous operation should run async. by the controller

Parameters:
val - true if operation should be executed asynchronously, false otherwise

isRestricted

boolean isRestricted()
Test whether security checks should be done before executing the operation

Returns:
true if the operation is restricted and permissions must be checked

setRestricted

void setRestricted(boolean val)
Set the security check flag.

Parameters:
val - true if the operation should be checked for right permissions before being executed or false otherwise

isUndoable

boolean isUndoable()
Test whether the operation may be undoed. Undoable operations may not be redoable. If the operation needs a large amount of data to be executed it must not keep it in memory instead it should backup this data somehow and restore it when exectued

Returns:
true if the operation may be undoed, false otherwise

setUndoable

void setUndoable(boolean val)
Set the undoable flag. If an operation is undoable it must provide an inverse operation using getInverseOperation()

Parameters:
val - true if operation can be undoed, false otherwise

isHistoryEnabled

boolean isHistoryEnabled()
Test whether ot nmot the operation should be logged

Returns:
true if the operation shpould be logged, false otherwise

setHistoryEnabled

void setHistoryEnabled(boolean val)
Set the history enabled flag

Parameters:
val - true to enable history logs, false otherwise

setFlag

void setFlag(int flag)
Set the given flag (set the corresponding bit to 1)

Parameters:
flag - the flag to set

clearFlag

void clearFlag(int flag)
Clear the given flag (set the corresponding bit to 0)

Parameters:
flag - the flag to clear

isFlagSet

boolean isFlagSet(int flag)
Tests if the given flag is set (the corresponding bit is 1)

Parameters:
flag - the flag to test
Returns:
true if the flag is set, false otherwise