Keel 2.1RC2

org.keel.apps.fileservices.model
Class FileManageModel

java.lang.Object
  extended byorg.keel.services.model.StandardModel
      extended byorg.keel.services.model.StandardLogEnabledModel
          extended byorg.keel.services.model.SecurableStandardLogEnabledModel
              extended byorg.keel.apps.fileservices.model.FileManageModel
All Implemented Interfaces:
Configurable, LogEnabled, Model, Securable

public class FileManageModel
extends SecurableStandardLogEnabledModel

This model provides the basic File Management services for Keel. The services provided are;
COPY
MOVE
DELETE
MKDIR
RMDIR
This class is securable, so as to not allow users to be able to randomly access and manipulate files on the system. BEWARE WHAT ACCESS LEVELS YOU GRANT TO WHAT USER!

Author:
Stephen Davidson

Field Summary
static java.lang.String COMMAND
          The Parameter Key for the command to execute.
static java.lang.String COPY
          The command for copy files.
static java.lang.String DELETE
          The command to delete a file.
static java.lang.String DELETE_CONTENTS
          The parameter key for whether the contents should be deleted when deleting the current directory
static java.lang.String DESTINATION_KEY
          The Parameter Key for the Destination file/filename
static java.lang.String MAKE_PARENTS
          The parameter key for whether the parent directories should be made
static java.lang.String MKDIR
          The command to make a directory
static java.lang.String MOVE
          The command to move a file.
static java.lang.String RMDIR
          The command to delete a directory
static java.lang.String SOURCE_KEY
          The Parameter Key for the Source file/filename
 
Fields inherited from class org.keel.services.model.SecurableStandardLogEnabledModel
 
Fields inherited from class org.keel.services.model.StandardLogEnabledModel
log
 
Fields inherited from class org.keel.services.model.StandardModel
configuration
 
Fields inherited from interface org.keel.services.model.Model
ROLE
 
Constructor Summary
FileManageModel()
           
 
Method Summary
protected  ModelResponse copy(ModelRequest req, ModelResponse res)
          Copies a file from source to destination.
protected  ModelResponse delete(ModelRequest req, ModelResponse res)
          Deletes the specified file.
 ModelResponse execute(ModelRequest request)
          Executes the FileManage Request
protected  File getFileFromRequest(ModelRequest req, java.lang.String key, java.lang.String errorKey)
          Gets the File object at the requested key from the request object.
protected  ModelResponse mkdir(ModelRequest req, ModelResponse res)
          Makes a new directory/volume/set, depending on the FileType.
protected  ModelResponse move(ModelRequest req, ModelResponse res)
          Move a file from one location to another
protected  ModelResponse rmdir(ModelRequest req, ModelResponse res)
          Removes the directory specified in the Request's "source" parameter.
 
Methods inherited from class org.keel.services.model.SecurableStandardLogEnabledModel
getAuthorizationManager, setAuthorizationManager
 
Methods inherited from class org.keel.services.model.StandardLogEnabledModel
enableLogging
 
Methods inherited from class org.keel.services.model.StandardModel
configure, getConfiguration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMMAND

public static final java.lang.String COMMAND
The Parameter Key for the command to execute.

See Also:
Constant Field Values

COPY

public static final java.lang.String COPY
The command for copy files.

See Also:
Constant Field Values

MOVE

public static final java.lang.String MOVE
The command to move a file.

See Also:
Constant Field Values

DELETE

public static final java.lang.String DELETE
The command to delete a file.

See Also:
Constant Field Values

MKDIR

public static final java.lang.String MKDIR
The command to make a directory

See Also:
Constant Field Values

RMDIR

public static final java.lang.String RMDIR
The command to delete a directory

See Also:
Constant Field Values

SOURCE_KEY

public static final java.lang.String SOURCE_KEY
The Parameter Key for the Source file/filename

See Also:
Constant Field Values

DESTINATION_KEY

public static final java.lang.String DESTINATION_KEY
The Parameter Key for the Destination file/filename

See Also:
Constant Field Values

MAKE_PARENTS

public static final java.lang.String MAKE_PARENTS
The parameter key for whether the parent directories should be made

See Also:
Constant Field Values

DELETE_CONTENTS

public static final java.lang.String DELETE_CONTENTS
The parameter key for whether the contents should be deleted when deleting the current directory

See Also:
Constant Field Values
Constructor Detail

FileManageModel

public FileManageModel()
Method Detail

execute

public ModelResponse execute(ModelRequest request)
                      throws ModelException
Executes the FileManage Request

Parameters:
request - The command to execute, as well as any needed parameters
Returns:
Empty response if no errors. If any errors occur, appropriate Error objects are embedded
Throws:
ModelException - Thrown if a severe error occurs processing the request. Also thrown if command is not understood/valid.
See Also:
Model.execute(org.keel.services.model.ModelRequest)

copy

protected ModelResponse copy(ModelRequest req,
                             ModelResponse res)
Copies a file from source to destination. The files could be either File objects, or specified as String names for files in the local filesystem (or a combination).

Parameters:
req - The request containing the copy command and needed parameters
res - The response to add any error messages to
Returns:
Empty response if no errors. If any errors occur, appropriate Error objects are embedded
See Also:
File.copyTo(org.keel.apps.fileservices.File)

move

protected ModelResponse move(ModelRequest req,
                             ModelResponse res)
Move a file from one location to another

Parameters:
req - The request containing the move command and needed parameters
res - The response to add any error messages to
Returns:
Any errors, loaded in the response object
See Also:
File.moveTo(org.keel.apps.fileservices.File)

delete

protected ModelResponse delete(ModelRequest req,
                               ModelResponse res)
Deletes the specified file.

Parameters:
req - The request containing the delete command, and the file to delete
res - The response to add any error messages to
Returns:
Any errors, loaded in the response object
See Also:
org.keel.apps.fileservices.File#delete()

mkdir

protected ModelResponse mkdir(ModelRequest req,
                              ModelResponse res)
Makes a new directory/volume/set, depending on the FileType. Directory/Set name is specified by the "source" parameter in the request object. If MAKE_PARENTS is specified, any needed parent directories are made as well.

Parameters:
req - The request containing the delete command, and the file to delete
res - The response to add any error messages to
Returns:
Any errors, loaded in the response object
See Also:
org.keel.apps.fileservices.File#mkdir()

rmdir

protected ModelResponse rmdir(ModelRequest req,
                              ModelResponse res)
Removes the directory specified in the Request's "source" parameter. If the DELETE_CONTENTS parameter is set to true, deletes the contents of the directory as well.

Parameters:
req - The request containing the delete command, and the file to delete
res - The response to add any error messages to
Returns:
Any errors, loaded in the response object

getFileFromRequest

protected File getFileFromRequest(ModelRequest req,
                                  java.lang.String key,
                                  java.lang.String errorKey)
                           throws ModelException
Gets the File object at the requested key from the request object. If the value is a String, attempts to make a DefaultFile object to return, using the value as the file name.

Parameters:
req - The ModelRequest containing the key/value pair as a parameter
key - The Key for the File value
errorKey - The Key for the error message if the parameter is not found.
Returns:
File object, either a wrapper for a java.io.File specified by the string value of the key, or the File object sent by the caller.
Throws:
ModelException - Thrown if no value at specified key.

Keel 2.1RC2

Please see keelframework.org for information about new Keel releases.