org.pentaho.platform.api.repository
Interface ISolutionRepository

All Superinterfaces:
ILogger
All Known Implementing Classes:
DbBasedSolutionRepository, ExtensionDbBasedSolutionRepository, ExtensionFileBasedSolutionRepository, FileBasedSolutionRepository, SolutionRepositoryBase

public interface ISolutionRepository
extends ILogger

Defines methods for getting information out of a location holding the Pentaho solutions.

Author:
jdixon

Field Summary
static int ACTION_ADMIN
           
static int ACTION_CREATE
           
static int ACTION_DELETE
           
static int ACTION_EXECUTE
           
static int ACTION_SHARE
           
static int ACTION_SUBSCRIBE
           
static int ACTION_UPDATE
           
static int FILE_ADD_FAILED
           
static int FILE_ADD_INVALID_PUBLISH_PASSWORD
           
static int FILE_ADD_INVALID_USER_CREDENTIALS
           
static int FILE_ADD_SUCCESSFUL
           
static int FILE_EXISTS
           
static String INDEX_FILENAME
           
static char 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
 
Method Summary
 void addPermission(ISolutionFile aFile, IPermissionRecipient recipient, IPermissionMask permission)
          Adds to the ACL associated with aFile.
 int addSolutionFile(String baseUrl, String path, String fileName, byte[] data, boolean overwrite)
          Adds a solution to the solution repository defined by the url that is built by concatenating baseUrl, path, and fileName.
 int addSolutionFile(String baseUrl, String path, String fileName, File f, boolean overwrite)
          Adds a solution to the solution repository defined by the url that is built by concatenating baseUrl, path, and fileName.
 ISolutionFile createFolder(File newFolder)
          This method creates a new folder in the Repository
 IActionSequence getActionSequence(String solutionName, String actionPath, String actionName, int loggingLevel, int actionOperation)
          Retrieves the action sequence from the repository.
 String[] getAllActionSequences()
           
 ClassLoader getClassLoader(String path)
          Returns an appropriate class loader for a specific path
 Map<IPermissionRecipient,IPermissionMask> getEffectivePermissions(ISolutionFile aFile)
          Returns the ACL for the given file.
 ISolutionFile getFileByPath(String path)
           
 Document getFullSolutionTree(int actionOperation, ISolutionFilter filter)
           
 String getLocalizedFileProperty(ISolutionFile resourceFile, String key)
          This method retrieves a locale aware value given a key and a file.
 List getMessages()
          Return the message list, if any, that all log messages generated by this Solution Repository are being appended to
 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 aFile)
          Returns the ACL for the given file.
 String getRepositoryName()
           
 byte[] getResourceAsBytes(IActionSequenceResource actionResource, boolean getLocalizedResource)
          See getResourceInputBytes(String solutionPath).
 byte[] getResourceAsBytes(String solutionPath, boolean getLocalizedResource)
          See getResourceInputBytes(String solutionPath).
 Document getResourceAsDocument(IActionSequenceResource actionResource)
          See getResourceInputStream(IActionResource actionResource).
 Document getResourceAsDocument(String solutionPath)
          See getResourceInputStream(String solutionPath).
 String getResourceAsString(IActionSequenceResource actionResource)
          See getResourceInputStream(IActionResource actionResource).
 String getResourceAsString(String solutionPath)
          See getResourceInputStream(String solutionPath).
 IPentahoStreamSource getResourceDataSource(IActionSequenceResource actionResource)
          See getResourceInputStream(IActionResource actionResource).
 IPentahoStreamSource getResourceDataSource(String solutionPath)
          See getResourceInputStream(String solutionPath).
 InputStream getResourceInputStream(IActionSequenceResource actionResource, boolean getLocalizedResource)
          Given a IActionResource this method returns a InputStream that references the content of the actionResource.
 InputStream getResourceInputStream(String solutionPath, boolean getLocalizedResource)
          Returns an InputStream that contains the data of the resource defined by the solutionPath.
 Reader getResourceReader(IActionSequenceResource actionResource)
          See getResourceInputStream(IActionResource actionResource).
 Reader getResourceReader(String solutionPath)
          See getResourceInputStream(String solutionPath).
 ISolutionFile getRootFolder()
           
 ISolutionFile getSolutionFile(IActionSequenceResource actionResource)
           
 long getSolutionFileLastModified(String path)
          Returns a long that represents the last time this file was modified
 Document getSolutions(int actionOperation)
          Gets an XML Document representing all the solutions and all the files within all the solutions
 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
 Document getSolutionStructure(int actionOperation)
          Returns an XML document that represents the parent/child relationship of the current solution repository
 Document getSolutionTree(int actionOperation)
          Returns an XML document that defines the entire solution tree.
 Document getSolutionTree(int actionOperation, ISolutionFilter filter)
           
 String getXSLName(Document doc, String solution, String inputXSLName)
          Interprets the XSL name coming in against the document to see if there are any repository-specific changes based on display type associated with the XSL name
 boolean hasAccess(IPermissionRecipient permRecipient, ISolutionFile aFile, int actionOperation)
          Checks permission.
 boolean hasAccess(ISolutionFile aFile, int actionOperation)
          Checks permission.
 void init(IPentahoSession session)
          Initializes the solution repository with the user session
 void localizeDoc(Node document, ISolutionFile file)
           
 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 session, int loggingLevel)
          Loads or reloads a solution repository after a structure change.
 boolean removeSolutionFile(String solutionPath)
           
 boolean removeSolutionFile(String solution, String path, String fileName)
          Removes the file (fileName) from the path defined by the solution and path.
 void resetRepository()
          This method resets the caches used by the solution repository.
 boolean resourceExists(String solutionPath)
          Returns a true if the specified resource exists.
 long resourceSize(String solutionPath)
          Returns the size of the specfied resource.
 void setMessages(List messages)
          Allows the caller to provide a List that will contain all log messages generated by the Solution Repository represented by this interface
 void setPermissions(ISolutionFile aFile, Map<IPermissionRecipient,IPermissionMask> acl)
          Replaces the ACL on aFile.
 void share(ISolutionFile aFile, List<IPermissionRecipient> shareRecipients)
          Share file with recipient.
 boolean solutionSynchronizationSupported()
           
 boolean supportsAccessControls()
           
 boolean synchronizeSolutionWithSolutionSource(IPentahoSession session)
          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.
 void unshare(ISolutionFile aFile, List<IPermissionRecipient> shareRecipients)
          Undoes the share operation.
 
Methods inherited from interface org.pentaho.platform.api.engine.ILogger
debug, debug, error, error, fatal, fatal, getLoggingLevel, info, info, setLoggingLevel, trace, trace, warn, warn
 

Field Detail

ACTION_EXECUTE

static final int ACTION_EXECUTE
See Also:
Constant Field Values

ACTION_ADMIN

static final int ACTION_ADMIN
See Also:
Constant Field Values

ACTION_SUBSCRIBE

static final int ACTION_SUBSCRIBE
See Also:
Constant Field Values

ACTION_CREATE

static final int ACTION_CREATE
See Also:
Constant Field Values

ACTION_UPDATE

static final int ACTION_UPDATE
See Also:
Constant Field Values

ACTION_DELETE

static final int ACTION_DELETE
See Also:
Constant Field Values

ACTION_SHARE

static final int ACTION_SHARE
See Also:
Constant Field Values

FILE_EXISTS

static final int FILE_EXISTS
See Also:
Constant Field Values

FILE_ADD_FAILED

static final int FILE_ADD_FAILED
See Also:
Constant Field Values

FILE_ADD_SUCCESSFUL

static final int FILE_ADD_SUCCESSFUL
See Also:
Constant Field Values

FILE_ADD_INVALID_PUBLISH_PASSWORD

static final int FILE_ADD_INVALID_PUBLISH_PASSWORD
See Also:
Constant Field Values

FILE_ADD_INVALID_USER_CREDENTIALS

static final int FILE_ADD_INVALID_USER_CREDENTIALS
See Also:
Constant Field Values

INDEX_FILENAME

static final String INDEX_FILENAME
See Also:
Constant Field Values

SEPARATOR

static final char SEPARATOR
See Also:
Constant Field Values
Method Detail

getActionSequence

IActionSequence getActionSequence(String solutionName,
                                  String actionPath,
                                  String actionName,
                                  int loggingLevel,
                                  int actionOperation)
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
actionName - The name of the action sequence
loggingLevel - The level at which to log messages
actionOperation - Whether the action sequence is being retrieved for administration or execution
Returns:

init

void init(IPentahoSession session)
Initializes the solution repository with the user session

Parameters:
session - The current user session

getSolutions

Document getSolutions(int actionOperation)
Gets an XML Document representing all the solutions and all the files within all the solutions

Parameters:
actionOperation - Indicates what the list will be used for - execution or administration
Returns:
Document

getSolutions

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

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

getSolutionStructure

Document getSolutionStructure(int actionOperation)
Returns an XML document that represents the parent/child relationship of the current solution repository

Parameters:
actionOperation -
Returns:
an XML document

reloadSolutionRepository

void reloadSolutionRepository(IPentahoSession session,
                              int loggingLevel)
Loads or reloads a solution repository after a structure change.

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

getRepositoryName

String getRepositoryName()

removeSolutionFile

boolean removeSolutionFile(String solution,
                           String path,
                           String fileName)
Removes the file (fileName) from the path defined by the solution and path.

Parameters:
solution -
path -
fileName -
Returns:
- boolean indicating success

removeSolutionFile

boolean removeSolutionFile(String solutionPath)

addSolutionFile

int addSolutionFile(String baseUrl,
                    String path,
                    String fileName,
                    File f,
                    boolean overwrite)
Adds a solution to the solution repository defined by the url that is built by concatenating baseUrl, path, and fileName. The fileName that is added has its data populated by the data from File (on disk).

Parameters:
baseUrl -
path -
fileName -
fi -
overwrite -
Returns:
- int indicating status of return

addSolutionFile

int addSolutionFile(String baseUrl,
                    String path,
                    String fileName,
                    byte[] data,
                    boolean overwrite)
Adds a solution to the solution repository defined by the url that is built by concatenating baseUrl, path, and fileName. The fileName that is added has its data populated by the data.

Parameters:
baseUrl -
path -
fileName -
data -
overwrite -
Returns:
- int indicating status of return

getSolutionFileLastModified

long getSolutionFileLastModified(String path)
Returns a long that represents the last time this file was modified

Parameters:
path -

getClassLoader

ClassLoader getClassLoader(String path)
Returns an appropriate class loader for a specific path

Parameters:
path -
Returns:
- A ClassLoader

getFullSolutionTree

Document getFullSolutionTree(int actionOperation,
                             ISolutionFilter filter)

getSolutionTree

Document getSolutionTree(int actionOperation)
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.

Parameters:
actionOperation -
Returns:

getSolutionTree

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

resourceExists

boolean resourceExists(String solutionPath)
Returns a true if the specified resource exists.

Parameters:
solutionPath - - path to the resource
Returns:
- boolean true if resource exists

resourceSize

long resourceSize(String solutionPath)
Returns the size of the specfied resource. If resource doesn't exit a -1 is returned

Parameters:
solutionPath - - path to the resource
Returns:
- long value of the size

getResourceInputStream

InputStream getResourceInputStream(IActionSequenceResource actionResource,
                                   boolean getLocalizedResource)
                                   throws FileNotFoundException
Given a IActionResource this method returns a InputStream that references the content of the actionResource.

Parameters:
actionResource - - resource to create a stream for.
getLocalizedResource - - flag to use to check if we should attempt to get a localized version of the resource
Returns:
- InputStream that contains the data of the actionResource
Throws:
FileNotFoundException

getResourceInputStream

InputStream getResourceInputStream(String solutionPath,
                                   boolean getLocalizedResource)
                                   throws FileNotFoundException
Returns an InputStream that contains the data of the resource defined by the solutionPath.

Parameters:
solutionPath - - location of a resource.
Returns:
- InputStream that represents the data of the resource.
Throws:
FileNotFoundException

getResourceReader

Reader getResourceReader(IActionSequenceResource actionResource)
                         throws FileNotFoundException,
                                IOException
See getResourceInputStream(IActionResource actionResource). Identical method except returns results as a Reader. Exceptions are thrown if io error or file is not found.

Parameters:
actionResource -
Returns:
Throws:
FileNotFoundException
IOException

getResourceReader

Reader getResourceReader(String solutionPath)
                         throws FileNotFoundException,
                                IOException
See getResourceInputStream(String solutionPath). Identical method except returns results as a Reader. Exceptions are thrown if io error or file is not found.

Parameters:
solutionPath -
Returns:
Throws:
FileNotFoundException
IOException

getResourceAsString

String getResourceAsString(IActionSequenceResource actionResource)
                           throws IOException
See getResourceInputStream(IActionResource actionResource). Identical method except returns results as a String. Exception is thrown if io error.

Parameters:
actionResource -
Returns:
Throws:
IOException

getResourceAsString

String getResourceAsString(String solutionPath)
                           throws IOException
See getResourceInputStream(String solutionPath). Identical method except returns results as a String. Exception is thrown if io error.

Parameters:
solutionPath -
Returns:
Throws:
IOException

getResourceAsBytes

byte[] getResourceAsBytes(String solutionPath,
                          boolean getLocalizedResource)
                          throws IOException
See getResourceInputBytes(String solutionPath). Identical method except returns results as a byte array. Exception is thrown if io error.

Parameters:
solutionPath -
Returns:
Throws:
IOException

getResourceAsBytes

byte[] getResourceAsBytes(IActionSequenceResource actionResource,
                          boolean getLocalizedResource)
                          throws IOException
See getResourceInputBytes(String solutionPath). Identical method except returns results as a byte array. Exception is thrown if io error.

Parameters:
solutionPath -
Returns:
Throws:
IOException

getResourceDataSource

IPentahoStreamSource getResourceDataSource(String solutionPath)
                                           throws FileNotFoundException
See getResourceInputStream(String solutionPath). Identical method except returns results as a DataSource.

Parameters:
solutionPath -
Returns:
Throws:
FileNotFoundException

getResourceDataSource

IPentahoStreamSource getResourceDataSource(IActionSequenceResource actionResource)
                                           throws FileNotFoundException
See getResourceInputStream(IActionResource actionResource). Identical method except returns results as a DataSource.

Parameters:
solutionPath -
Returns:
Throws:
FileNotFoundException

getResourceAsDocument

Document getResourceAsDocument(String solutionPath)
                               throws IOException
See getResourceInputStream(String solutionPath). Identical method except returns results as a Document.

Parameters:
solutionPath -
Returns:
Throws:
IOException

getResourceAsDocument

Document getResourceAsDocument(IActionSequenceResource actionResource)
                               throws IOException
See getResourceInputStream(IActionResource actionResource). Identical method except returns results as a Document.

Parameters:
solutionPath -
Returns:
Throws:
IOException

getAllActionSequences

String[] getAllActionSequences()
Returns:
An array of Strings where each string is the fully qualified path of every *.xaction contained in the repository.

setMessages

void setMessages(List messages)
Allows the caller to provide a List that will contain all log messages generated by the Solution Repository represented by this interface

Parameters:
messages - a List that String messages will be appended to

getMessages

List getMessages()
Return the message list, if any, that all log messages generated by this Solution Repository are being appended to

Returns:
List of String messages

getNavigationUIDocument

Document getNavigationUIDocument(String solution,
                                 String path,
                                 int actionOperation)
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

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 - String
Returns:
Document XML document that describes the structure of the solution repository.

getXSLName

String getXSLName(Document doc,
                  String solution,
                  String inputXSLName)
Interprets the XSL name coming in against the document to see if there are any repository-specific changes based on display type associated with the XSL name

Parameters:
doc -
inputXSLName -
Returns:
Actual XSL name to use

resetRepository

void resetRepository()
This method resets the caches used by the solution repository.


getFileByPath

ISolutionFile getFileByPath(String path)
Parameters:
path - the solution path to the desired resource
Returns:
the ISolutionFile for the given path

getRootFolder

ISolutionFile getRootFolder()
Returns:
the ISolutionFile for the root of the repository

localizeDoc

void localizeDoc(Node document,
                 ISolutionFile file)

supportsAccessControls

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

getSolutionFile

ISolutionFile getSolutionFile(IActionSequenceResource actionResource)

createFolder

ISolutionFile createFolder(File newFolder)
                           throws IOException
This method creates a new folder in the Repository

Parameters:
newFolder - The File that points to the new folder to create
Returns:
The RepositoryFile object created
Throws:
IOException

hasAccess

boolean hasAccess(IPermissionRecipient permRecipient,
                  ISolutionFile aFile,
                  int actionOperation)
Checks permission. Although implementations should enforce permissions, some clients may want to see beforehand whether or not an operation will succeed. An example is enabling/disable UI controls based on access.

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

hasAccess

boolean hasAccess(ISolutionFile aFile,
                  int actionOperation)
Checks permission. Although implementations should enforce permissions, some clients may want to see beforehand whether or not an operation will succeed. An example is enabling/disable UI controls based on access.

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

share

void share(ISolutionFile aFile,
           List<IPermissionRecipient> shareRecipients)
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:
aFile - file to share
shareRecipients - the users or roles with which to share (aka share-ees)

unshare

void unshare(ISolutionFile aFile,
             List<IPermissionRecipient> shareRecipients)
Undoes the share operation.

Parameters:
aFile - file to stop sharing
shareRecipients - the users or roles with which to stop sharing

publish

int publish(String baseUrl,
            String path,
            String fileName,
            byte[] data,
            boolean overwrite)
            throws PentahoAccessControlException
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.

Parameters:
baseUrl -
path -
fileName -
data -
overwrite -
Returns:
Throws:
PentahoAccessControlException

publish

int publish(String baseUrl,
            String path,
            String fileName,
            File f,
            boolean overwrite)
            throws PentahoAccessControlException
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.

Parameters:
baseUrl -
path -
fileName -
f -
overwrite -
Returns:
constant from ISolutionRepository
Throws:
PentahoAccessControlException

addPermission

void addPermission(ISolutionFile aFile,
                   IPermissionRecipient recipient,
                   IPermissionMask permission)
Adds to the ACL associated with aFile.

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

setPermissions

void setPermissions(ISolutionFile aFile,
                    Map<IPermissionRecipient,IPermissionMask> acl)
                    throws PentahoAccessControlException
Replaces the ACL on aFile.

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

getPermissions

Map<IPermissionRecipient,IPermissionMask> getPermissions(ISolutionFile aFile)
Returns the ACL for the given file.

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

getEffectivePermissions

Map<IPermissionRecipient,IPermissionMask> getEffectivePermissions(ISolutionFile aFile)
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:
aFile - file whose ACL is to be returned
Returns:
ACL

synchronizeSolutionWithSolutionSource

boolean synchronizeSolutionWithSolutionSource(IPentahoSession session)
                                              throws UnsupportedOperationException
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).

Parameters:
session -
Returns:
boolean true if the synchronization succeeded
Throws:
UnsupportedOperationException

solutionSynchronizationSupported

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

getLocalizedFileProperty

String getLocalizedFileProperty(ISolutionFile resourceFile,
                                String key)
This method retrieves a locale aware value given a key and a file. The intention is to allow the repository to be used as an API, so we can ask it for the "title" or "description" or "author" of a given file with localization in effect.

Parameters:
path - the solution path to the desired resource
Returns:
the String value found for the given key