org.pentaho.platform.repository.solution
Class SolutionRepositoryBase

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
All Implemented Interfaces:
Serializable, ILogger, IPentahoInitializer, ISolutionRepository
Direct Known Subclasses:
DbBasedSolutionRepository, FileBasedSolutionRepository

public abstract class SolutionRepositoryBase
extends PentahoMessenger
implements ISolutionRepository, IPentahoInitializer

See Also:
Serialized Form

Nested Class Summary
static class SolutionRepositoryBase.ActionSequenceResourceWrapper
           
 
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, 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
SolutionRepositoryBase()
           
 
Method Summary
 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
 ISolutionFile getFileByPath(String path)
           
 Document getFullSolutionTree(int actionOperation, ISolutionFilter filter)
           
 String getLocaleString(String key, String baseName, String baseFilePath)
           
 ISolutionFile getLocalizedFile(ISolutionFile resourceFile)
           
 String getLocalizedFileProperty(ISolutionFile resourceFile, String key)
          This method retrieves a locale aware value given a key and a file.
 Log getLogger()
           
 Document getNavigationUIDocument(String solution, String path, int actionOperation)
          Get an XML document that describes the structure of the solution repository.
 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)
           
 Document getSolutions(int actionOperation)
          Gets an XML Document representing all the solutions and all the files within all the solutions
 String getXSLName(Document document, 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
 void init()
           
 void init(IPentahoSession pentahoSession)
          NOTE regarding old code: the cacheManager cannot be cached, because it is possible that the SolutionRepository implementation has a scope that is longer lived than the cacheManager.
static boolean isSystemPath(String path)
           
static boolean isSystemTmpPath(String path)
          Returns true if the path is the tmp directory in the system solution.
 void localizeDoc(Node document, ISolutionFile file)
           
 boolean removeSolutionFile(String solutionPath)
           
 boolean removeSolutionFile(String solution, String path, String fileName)
          this is the file based removeSolutionFile, used by subclasses
 void resetRepository()
          Clears cached data for ALL users
 
Methods inherited from class org.pentaho.platform.engine.services.PentahoMessenger
debug, debug, 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
addPermission, getActionSequence, getAllActionSequences, getClassLoader, getEffectivePermissions, getMessages, getPermissions, getRepositoryName, getSolutionFileLastModified, getSolutions, getSolutionStructure, getSolutionTree, getSolutionTree, hasAccess, hasAccess, publish, publish, reloadSolutionRepository, resourceExists, resourceSize, setMessages, setPermissions, share, solutionSynchronizationSupported, supportsAccessControls, synchronizeSolutionWithSolutionSource, unshare
 
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

SolutionRepositoryBase

public SolutionRepositoryBase()
Method Detail

getLogger

public Log getLogger()
Specified by:
getLogger in class PentahoBase

init

public void init()

init

public void init(IPentahoSession pentahoSession)
NOTE regarding old code: the cacheManager cannot be cached, because it is possible that the SolutionRepository implementation has a scope that is longer lived than the cacheManager. When the cacheManager goes out of scope, this class would have maintained a stale reference to a now obsolete cacheManager. (sbarkdull)

Specified by:
init in interface IPentahoInitializer
Specified by:
init in interface ISolutionRepository
Parameters:
pentahoSession - The current user session

getLocalizedFile

public ISolutionFile getLocalizedFile(ISolutionFile resourceFile)

getFileByPath

public ISolutionFile getFileByPath(String path)
Specified by:
getFileByPath in interface ISolutionRepository
Parameters:
path - the solution path to the desired resource
Returns:
the ISolutionFile for the given path

isSystemPath

public static boolean isSystemPath(String path)

isSystemTmpPath

public static boolean isSystemTmpPath(String path)
Returns true if the path is the tmp directory in the system solution.


getResourceInputStream

public InputStream getResourceInputStream(IActionSequenceResource actionResource,
                                          boolean getLocalizedResource)
                                   throws FileNotFoundException
Description copied from interface: ISolutionRepository
Given a IActionResource this method returns a InputStream that references the content of the actionResource.

Specified by:
getResourceInputStream in interface ISolutionRepository
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

localizeDoc

public void localizeDoc(Node document,
                        ISolutionFile file)
Specified by:
localizeDoc in interface ISolutionRepository

getLocaleString

public String getLocaleString(String key,
                              String baseName,
                              String baseFilePath)

getResourceInputStream

public InputStream getResourceInputStream(String solutionPath,
                                          boolean getLocalizedResource)
                                   throws FileNotFoundException
Description copied from interface: ISolutionRepository
Returns an InputStream that contains the data of the resource defined by the solutionPath.

Specified by:
getResourceInputStream in interface ISolutionRepository
Parameters:
solutionPath - - location of a resource.
Returns:
- InputStream that represents the data of the resource.
Throws:
FileNotFoundException

getResourceReader

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

Specified by:
getResourceReader in interface ISolutionRepository
Returns:
Throws:
FileNotFoundException
IOException

getResourceReader

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

Specified by:
getResourceReader in interface ISolutionRepository
Returns:
Throws:
FileNotFoundException
IOException

getResourceAsString

public String getResourceAsString(IActionSequenceResource actionResource)
                           throws IOException
Description copied from interface: ISolutionRepository
See getResourceInputStream(IActionResource actionResource). Identical method except returns results as a String. Exception is thrown if io error.

Specified by:
getResourceAsString in interface ISolutionRepository
Returns:
Throws:
IOException

getResourceAsString

public String getResourceAsString(String solutionPath)
                           throws IOException
Description copied from interface: ISolutionRepository
See getResourceInputStream(String solutionPath). Identical method except returns results as a String. Exception is thrown if io error.

Specified by:
getResourceAsString in interface ISolutionRepository
Returns:
Throws:
IOException

getResourceAsBytes

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

Specified by:
getResourceAsBytes in interface ISolutionRepository
Returns:
Throws:
IOException

getResourceAsBytes

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

Specified by:
getResourceAsBytes in interface ISolutionRepository
Returns:
Throws:
IOException

getResourceDataSource

public IPentahoStreamSource getResourceDataSource(IActionSequenceResource actionResource)
                                           throws FileNotFoundException
Description copied from interface: ISolutionRepository
See getResourceInputStream(IActionResource actionResource). Identical method except returns results as a DataSource.

Specified by:
getResourceDataSource in interface ISolutionRepository
Returns:
Throws:
FileNotFoundException

getResourceDataSource

public IPentahoStreamSource getResourceDataSource(String solutionPath)
                                           throws FileNotFoundException
Description copied from interface: ISolutionRepository
See getResourceInputStream(String solutionPath). Identical method except returns results as a DataSource.

Specified by:
getResourceDataSource in interface ISolutionRepository
Returns:
Throws:
FileNotFoundException

getResourceAsDocument

public Document getResourceAsDocument(String solutionPath)
                               throws IOException
Description copied from interface: ISolutionRepository
See getResourceInputStream(String solutionPath). Identical method except returns results as a Document.

Specified by:
getResourceAsDocument in interface ISolutionRepository
Returns:
Throws:
IOException

getResourceAsDocument

public Document getResourceAsDocument(IActionSequenceResource actionResource)
                               throws IOException
Description copied from interface: ISolutionRepository
See getResourceInputStream(IActionResource actionResource). Identical method except returns results as a Document.

Specified by:
getResourceAsDocument in interface ISolutionRepository
Returns:
Throws:
IOException

getSolutions

public 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
Parameters:
actionOperation - Indicates what the list will be used for - execution or administration
Returns:
Document

resetRepository

public void resetRepository()
Clears cached data for ALL users

Specified by:
resetRepository in interface ISolutionRepository

getRootFolder

public ISolutionFile getRootFolder()
Specified by:
getRootFolder in interface ISolutionRepository
Returns:
the ISolutionFile for the root of the repository

getXSLName

public String getXSLName(Document document,
                         String solution,
                         String inputXSLName)
Description copied from interface: ISolutionRepository
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

Specified by:
getXSLName in interface ISolutionRepository
Returns:
Actual XSL name to use

getNavigationUIDocument

public 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
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.

addSolutionFile

public int addSolutionFile(String baseUrl,
                           String path,
                           String fileName,
                           File f,
                           boolean overwrite)
Description copied from interface: ISolutionRepository
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).

Specified by:
addSolutionFile in interface ISolutionRepository
Returns:
int possible values: ISolutionRepository.FILE_ADD_SUCCESSFUL ISolutionRepository.FILE_EXISTS ISolutionRepository.FILE_ADD_FAILED TODO mlowery Why can't this delegate to the other addSolutionFile?

addSolutionFile

public int addSolutionFile(String baseUrl,
                           String path,
                           String fileName,
                           byte[] data,
                           boolean overwrite)
Description copied from interface: ISolutionRepository
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.

Specified by:
addSolutionFile in interface ISolutionRepository
Returns:
- int indicating status of return

removeSolutionFile

public boolean removeSolutionFile(String solutionPath)
Specified by:
removeSolutionFile in interface ISolutionRepository

removeSolutionFile

public boolean removeSolutionFile(String solution,
                                  String path,
                                  String fileName)
this is the file based removeSolutionFile, used by subclasses

Specified by:
removeSolutionFile in interface ISolutionRepository
Returns:
- boolean indicating success

getFullSolutionTree

public Document getFullSolutionTree(int actionOperation,
                                    ISolutionFilter filter)
Specified by:
getFullSolutionTree in interface ISolutionRepository

getSolutionFile

public ISolutionFile getSolutionFile(IActionSequenceResource actionResource)
Specified by:
getSolutionFile in interface ISolutionRepository

createFolder

public ISolutionFile createFolder(File newFolder)
                           throws IOException
Description copied from interface: ISolutionRepository
This method creates a new folder in the Repository

Specified by:
createFolder in interface ISolutionRepository
Parameters:
newFolder - The File that points to the new folder to create
Returns:
The RepositoryFile object created
Throws:
IOException

getLocalizedFileProperty

public String getLocalizedFileProperty(ISolutionFile resourceFile,
                                       String key)
Description copied from interface: ISolutionRepository
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.

Specified by:
getLocalizedFileProperty in interface ISolutionRepository
Returns:
the String value found for the given key