org.pentaho.platform.repository.solution.filebased
Class FileBasedSolutionRepository

java.lang.Object
  extended by org.pentaho.platform.engine.core.system.PentahoBase
      extended by org.pentaho.platform.engine.services.PentahoMessenger
          extended by org.pentaho.platform.repository.solution.SolutionRepositoryBase
              extended by org.pentaho.platform.repository.solution.filebased.FileBasedSolutionRepository
All Implemented Interfaces:
Serializable, ILogger, IPentahoInitializer, ISessionContainer, ISolutionRepository
Direct Known Subclasses:
ExtensionFileBasedSolutionRepository

public class FileBasedSolutionRepository
extends SolutionRepositoryBase

Author:
James Dixon TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.pentaho.platform.engine.core.system.PentahoBase
EMPTYLOGID, LOGID_MASK1, LOGID_MASK2, LOGID_SEPARATOR
 
Fields inherited from interface org.pentaho.platform.api.repository.ISolutionRepository
ACTION_ADMIN, ACTION_CREATE, ACTION_DELETE, ACTION_EXECUTE, ACTION_SHARE, ACTION_SUBSCRIBE, ACTION_UPDATE, FILE_ADD_FAILED, FILE_ADD_INVALID_PUBLISH_PASSWORD, FILE_ADD_INVALID_USER_CREDENTIALS, FILE_ADD_SUCCESSFUL, FILE_EXISTS, INDEX_FILENAME, REPOSITORY_SERVICE_CACHE_REGION, SEPARATOR
 
Fields inherited from interface org.pentaho.platform.api.engine.ILogger
ACTIVITY_LOG, DEBUG, ERROR, FATAL, INFO, INSTANCE_LOG, SESSION_LOG, SOLUTION_LOG, TRACE, UNKNOWN, WARN
 
Constructor Summary
FileBasedSolutionRepository()
           
 
Method Summary
 void addPermission(ISolutionFile file, IPermissionRecipient recipient, IPermissionMask permission)
          Adds to the ACL associated with aFile.
 IActionSequence getActionSequence(String solutionName, String actionPath, String sequenceName, int localLoggingLevel, int actionOperation)
          Retrieves the action sequence from the repository.
 String[] getAllActionSequences(int actionOperation)
          An array of Strings where each string is the fully qualified path of every *.xaction contained in the repository.
 ClassLoader getClassLoader(String path)
          Returns an appropriate class loader for a specific path
 Map<IPermissionRecipient,IPermissionMask> getEffectivePermissions(ISolutionFile file)
          Returns the ACL for the given file.
 org.dom4j.Document getNavigationUIDocument(String solution, String path, int actionOperation)
          Get an XML document that describes the structure of the solution repository.
 Map<IPermissionRecipient,IPermissionMask> getPermissions(ISolutionFile file)
          Returns the ACL for the given file.
 String getRepositoryName()
           
 org.dom4j.Document getSolutionDocument(String documentPath, int actionOperation)
           
 org.dom4j.Document getSolutionDocument(String solutionName, String actionPath, String actionName, int actionOperation)
           
 long getSolutionFileLastModified(String path, int actionOperation)
          Returns a long that represents the last time this file was modified
 org.dom4j.Document getSolutions(int actionOperation)
          Gets an XML Document representing all the solutions and all the files within all the solutions
 org.dom4j.Document getSolutions(String solutionName, String pathName, int actionOperation, boolean visibleOnly)
          Gets an XML Document representing all the files within a certain path within a solution
 org.dom4j.Document getSolutionStructure(int actionOperation)
          Returns an XML document that represents the parent/child relationship of the current solution repository
 org.dom4j.Document getSolutionTree(int actionOperation)
          Returns an XML document that defines the entire solution tree.
 org.dom4j.Document getSolutionTree(int actionOperation, ISolutionFilter filter)
           
 boolean hasAccess(ISolutionFile file, int actionOperation)
          No access control is enforced in this implementation.
 void init()
           
 int publish(String baseUrl, String path, String fileName, byte[] data, boolean overwrite)
          Put a file into the solution repo.
 int publish(String baseUrl, String path, String fileName, File f, boolean overwrite)
          Put a file into the solution repo.
 void reloadSolutionRepository(IPentahoSession localSession, int localLoggingLevel)
          Loads or reloads a solution repository after a structure change.
 boolean resourceExists(String solutionPath, int actionOperation)
          Returns a true if the specified resource exists.
 long resourceSize(String solutionPath, int actionOperation)
          Returns the size of the specfied resource.
 void setPermissions(ISolutionFile file, Map<IPermissionRecipient,IPermissionMask> acl)
          Replaces the ACL on aFile.
 void share(ISolutionFile file, List<IPermissionRecipient> shareRecipient)
          Share file with recipient.
 boolean solutionSynchronizationSupported()
           
 boolean supportsAccessControls()
           
 boolean synchronizeSolutionWithSolutionSource(IPentahoSession pSession)
          For ISolutionRepository implementations that have a source and a destination (for example, DBBasedSolutionRepository which has a file-system source and a DB destination) this is the entry point that allows synchronization.
 
Methods inherited from class org.pentaho.platform.repository.solution.SolutionRepositoryBase
addSolutionFile, addSolutionFile, createFolder, getAllActionSequences, getFileByPath, getFullSolutionTree, getFullSolutionTree, getLocalizedFileProperty, getLocalizedFileProperty, getLogger, getResourceAsBytes, getResourceAsBytes, getResourceAsBytes, getResourceAsBytes, getResourceAsDocument, getResourceAsDocument, getResourceAsDocument, getResourceAsDocument, getResourceAsString, getResourceAsString, getResourceAsString, getResourceAsString, getResourceDataSource, getResourceDataSource, getResourceDataSource, getResourceDataSource, getResourceInputStream, getResourceInputStream, getResourceInputStream, getResourceInputStream, getResourceReader, getResourceReader, getResourceReader, getResourceReader, getRootFolder, getSolutionFile, getSolutionFile, getSolutionFile, getSolutionFile, getSolutionFileLastModified, getXSLName, init, localizeDoc, removeSolutionFile, removeSolutionFile, resetRepository, resourceExists, resourceSize, setSession
 
Methods inherited from class org.pentaho.platform.engine.services.PentahoMessenger
debug, debug, error, error, error, fatal, fatal, getMessages, getUserString, info, info, setMessages, trace, trace, warn, warn
 
Methods inherited from class org.pentaho.platform.engine.core.system.PentahoBase
genLogIdFromInfo, genLogIdFromInfo, genLogIdFromSession, getLoggingLevel, getLogId, getObjectName, setLoggingLevel, setLogId
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.pentaho.platform.api.repository.ISolutionRepository
getMessages, setMessages
 
Methods inherited from interface org.pentaho.platform.api.engine.ILogger
debug, debug, error, error, fatal, fatal, getLoggingLevel, info, info, setLoggingLevel, trace, trace, warn, warn
 

Constructor Detail

FileBasedSolutionRepository

public FileBasedSolutionRepository()
Method Detail

init

public void init()

getClassLoader

public ClassLoader getClassLoader(String path)
Description copied from interface: ISolutionRepository
Returns an appropriate class loader for a specific path

Returns:
- A ClassLoader

getActionSequence

public IActionSequence getActionSequence(String solutionName,
                                         String actionPath,
                                         String sequenceName,
                                         int localLoggingLevel,
                                         int actionOperation)
Description copied from interface: ISolutionRepository
Retrieves the action sequence from the repository. Should return null if the requested action seqeuence is not found.

Parameters:
solutionName - The name of the solution - like the root folder
actionPath - The relative path (from the solution) of where the file is stored
sequenceName - The name of the action sequence
localLoggingLevel - The level at which to log messages
actionOperation - Whether the action sequence is being retrieved for administration or execution
Returns:

getSolutionDocument

public org.dom4j.Document getSolutionDocument(String solutionName,
                                              String actionPath,
                                              String actionName,
                                              int actionOperation)

getSolutionDocument

public org.dom4j.Document getSolutionDocument(String documentPath,
                                              int actionOperation)

reloadSolutionRepository

public void reloadSolutionRepository(IPentahoSession localSession,
                                     int localLoggingLevel)
Description copied from interface: ISolutionRepository
Loads or reloads a solution repository after a structure change.

Parameters:
localSession - - The session associated with this solution repository
localLoggingLevel - - The requested level of logging

getSolutions

public org.dom4j.Document getSolutions(String solutionName,
                                       String pathName,
                                       int actionOperation,
                                       boolean visibleOnly)
Description copied from interface: ISolutionRepository
Gets an XML Document representing all the files within a certain path within a solution

Parameters:
solutionName - The name of the solution to get
pathName - The path from which to retrieve
actionOperation - Indicates what the list will be used for - execution or administration
Returns:
Document

getSolutions

public org.dom4j.Document getSolutions(int actionOperation)
Description copied from interface: ISolutionRepository
Gets an XML Document representing all the solutions and all the files within all the solutions

Specified by:
getSolutions in interface ISolutionRepository
Overrides:
getSolutions in class SolutionRepositoryBase
Parameters:
actionOperation - Indicates what the list will be used for - execution or administration
Returns:
Document

getSolutionStructure

public org.dom4j.Document getSolutionStructure(int actionOperation)
Description copied from interface: ISolutionRepository
Returns an XML document that represents the parent/child relationship of the current solution repository

Returns:
an XML document

getSolutionTree

public org.dom4j.Document getSolutionTree(int actionOperation,
                                          ISolutionFilter filter)
filter - an implementation of a ISolutionFilter that determines which files will be returned
Returns:
Document representing the solution tree

getSolutionTree

public org.dom4j.Document getSolutionTree(int actionOperation)
Description copied from interface: ISolutionRepository
Returns an XML document that defines the entire solution tree. This general purpose method return all files/folders in the solution in an easily understood XML document.

Returns:

resourceExists

public boolean resourceExists(String solutionPath,
                              int actionOperation)
Description copied from interface: ISolutionRepository
Returns a true if the specified resource exists.

Parameters:
solutionPath - - path to the resource
actionOperation - - Type of action operation to be performed
Returns:
- boolean true if resource exists

resourceSize

public long resourceSize(String solutionPath,
                         int actionOperation)
Description copied from interface: ISolutionRepository
Returns the size of the specfied resource. If resource doesn't exit a -1 is returned

Parameters:
solutionPath - - path to the resource
actionOperation - - Type of action operation to be performed
Returns:
- long value of the size

getAllActionSequences

public String[] getAllActionSequences(int actionOperation)
Description copied from interface: ISolutionRepository
An array of Strings where each string is the fully qualified path of every *.xaction contained in the repository.

Parameters:
actionOperation - - Type of action operation to be performed
Returns:

getSolutionFileLastModified

public long getSolutionFileLastModified(String path,
                                        int actionOperation)
Description copied from interface: ISolutionRepository
Returns a long that represents the last time this file was modified

actionOperation - - Type of action operation to be performed

getNavigationUIDocument

public org.dom4j.Document getNavigationUIDocument(String solution,
                                                  String path,
                                                  int actionOperation)
Description copied from interface: ISolutionRepository
Get an XML document that describes the structure of the solution repository. Returns the document used to construct the navigation UI. Also used by WAQR and jpivot to construct the repository browswer

Specified by:
getNavigationUIDocument in interface ISolutionRepository
Overrides:
getNavigationUIDocument in class SolutionRepositoryBase
Parameters:
solution - String The name of the solution. If this is empty (null or ""), and path is empty, return the root of the document. Otherwise return a document that starts at the node specified by the solution and path in the solution
path - String The path of the interested folder. See notes for parameter solution.
actionOperation - - Type of action operation to be performed
Returns:
Document XML document that describes the structure of the solution repository.

getRepositoryName

public String getRepositoryName()

supportsAccessControls

public boolean supportsAccessControls()
Returns:
whether or not the concrete versions of this interface support access controls

hasAccess

public boolean hasAccess(ISolutionFile file,
                         int actionOperation)
No access control is enforced in this implementation.

Parameters:
file - domain instance to check
actionOperation - permission requested (A constant from ISolutionRepository.)
Returns:
true if actionOperation is allowed for this aFile
See Also:
supportsAccessControls

publish

public int publish(String baseUrl,
                   String path,
                   String fileName,
                   byte[] data,
                   boolean overwrite)
            throws PentahoAccessControlException
Description copied from interface: ISolutionRepository
Put a file into the solution repo. This method differs from addSolutionFile. Only Pentaho administrators can successfully execute addSolutionFile. addSolutionFile is a low-level operation. There is potentially more logic in the implementation of this method than in the implementation of addSolutionFile.

Returns:
Throws:
PentahoAccessControlException

publish

public int publish(String baseUrl,
                   String path,
                   String fileName,
                   File f,
                   boolean overwrite)
            throws PentahoAccessControlException
Description copied from interface: ISolutionRepository
Put a file into the solution repo. This method differs from addSolutionFile. Only Pentaho administrators can successfully execute addSolutionFile. addSolutionFile is a low-level operation. There is potentially more logic in the implementation of this method than in the implementation of addSolutionFile.

Returns:
constant from ISolutionRepository
Throws:
PentahoAccessControlException

share

public void share(ISolutionFile file,
                  List<IPermissionRecipient> shareRecipient)
Description copied from interface: ISolutionRepository
Share file with recipient. This version is appropriate for sharing with a particular role. The semantics of share are encapsulated in the implementation. (The sharer comes from the IPentahoSession.)

Parameters:
file - file to share
shareRecipient - the users or roles with which to share (aka share-ees)

addPermission

public void addPermission(ISolutionFile file,
                          IPermissionRecipient recipient,
                          IPermissionMask permission)
Description copied from interface: ISolutionRepository
Adds to the ACL associated with aFile.

Parameters:
file - file whose ACL is to be modified
recipient - recipient of the permission
permission - right to an action on this file by this user

setPermissions

public void setPermissions(ISolutionFile file,
                           Map<IPermissionRecipient,IPermissionMask> acl)
                    throws PentahoAccessControlException
Description copied from interface: ISolutionRepository
Replaces the ACL on aFile.

Parameters:
file - file whose ACL is to be modified
acl - new ACL
Throws:
PentahoAccessControlException

getPermissions

public Map<IPermissionRecipient,IPermissionMask> getPermissions(ISolutionFile file)
Description copied from interface: ISolutionRepository
Returns the ACL for the given file.

Parameters:
file - file whose ACL is to be returned
Returns:
ACL

getEffectivePermissions

public Map<IPermissionRecipient,IPermissionMask> getEffectivePermissions(ISolutionFile file)
Description copied from interface: ISolutionRepository
Returns the ACL for the given file. If there are no access control entries for the given file, return the access control entries of an ancestor file.

Parameters:
file - file whose ACL is to be returned
Returns:
ACL

synchronizeSolutionWithSolutionSource

public boolean synchronizeSolutionWithSolutionSource(IPentahoSession pSession)
Description copied from interface: ISolutionRepository
For ISolutionRepository implementations that have a source and a destination (for example, DBBasedSolutionRepository which has a file-system source and a DB destination) this is the entry point that allows synchronization. Implementors should throw an UnsupportedOperationException if there is no synchronization necessary (for example, the FileBasedSolutionRepository).

Returns:
boolean true if the synchronization succeeded

solutionSynchronizationSupported

public boolean solutionSynchronizationSupported()
Returns:
True if solution synchronization is supported by this implementor