org.openi.project
Class ProjectContext

java.lang.Object
  extended by org.openi.project.ProjectContext

public class ProjectContext
extends java.lang.Object

Author:
plucas TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates

Field Summary
static java.lang.String ALL_USERS
           
 
Constructor Summary
ProjectContext(Project project, java.lang.String baseDirectory, ProjectUser user)
           
 
Method Summary
 boolean addSubFolder(java.lang.String base, java.lang.String folderName)
          creates specified folder to the base path .
 void autogenerate(java.lang.String datasourceName, java.lang.String cube, java.lang.String relativeDir, java.util.List measures)
           
 Menu buildMenu()
          Deprecated.  
 Menu buildMenu(boolean applyFilterPattern)
          Determines appropriate base project directory, and which directories to include in menu delegates all menu building to the MenuBuilder
 boolean checkPermission(java.lang.String resource)
          Checks whether the the resource is allowed for current user or not
 boolean checkPermission(java.lang.String resource, java.util.Map params)
          Checks whether the the resource is allowed for current user or not
 void createDirectory(java.lang.String relativeDirectoryName)
          Creates a directory below this project context's projectDirectory.
 void deleteAnalysis(java.lang.String relativeUrl)
           
 void deleteDatasource(java.lang.String datasourceName)
          To remove datasource from project
 java.lang.String extractModulePath(java.lang.String path)
          extracts path from base directory
 java.util.List getAutoGeneratedMenuNames()
           
 java.lang.String getBaseDirectory()
           
 ChangeLog getChangeLog()
          for getChangeLog - need to trap IOException, this is non critical
 java.lang.String getCustomResourceString(java.lang.String resourceId)
          returns resource string if id for currect user locale from the customizable resource bundle
 Datasource getDatasource(java.lang.String datasourceName)
          returns datasource object from datasource name
 java.lang.Object getDatasourceObject(java.lang.String datasourceName)
          returns datasource object from datasource name
 FeedsDatasource getFeedsDatasource(java.lang.String datasourceName)
          returns FeedsDatasource object
 java.util.Map getFeedsDatasourceMap()
          returns FeedsDatasource map
 java.util.List getFilesByExtension(java.lang.String extension)
          returns all files available under project dir filtered with extension
 JdbcDatasource getJasperDatasource(java.lang.String template)
          return JdbcDatasource object of specified template-i.e .jrxml file
 JdbcDatasource getJdbcDatasource(java.lang.String dataSourceName)
          returns jdbc datasource.
 java.util.Map getJdbcDatasourceMap()
          returns all available JdbcDatasource
 java.util.Properties getJdbcDataSourceProperties(Analysis analysis)
          returns jdbc connection properties of specified analysis.
 java.util.Properties getJdbcDataSourceProperties(java.lang.String dataSourceName)
          returns jdbc connection properties.
 Project getProject()
           
 java.lang.String getProjectDirectory()
           
 java.util.List getProjectModules(boolean includePrivate, boolean includePublic)
          return list of accessible modules(folders) for the project user
 java.util.List getProjectSubDirs()
           
 java.lang.String getResourceString(java.lang.String resourceId)
          returns resource string if id for currect user locale from the standard resource bundle
 RFunctionList getRFunctionList()
          returns RFunctionList bean restored from rfunction.xml.
 java.util.List getSecurityDefinitionList()
          returns SecurityDefinition entries defined in Application.
 java.util.Map getSecurityDefinitionSelectionMap()
          returns map of security definition with value as a map of role selection
 ProjectUser getUser()
           
 java.util.List getUserRoles()
          returns current user roles
 java.util.Map getXmlaDatasourceMap()
          returns all available xmla datasource
 boolean hasPermission(Permission permission)
          Deprecated. use checkPermission(String)
 boolean isAppAdminUser()
          returns true if user is member of APP_ADMINISTRATOR
 boolean isPathAllowed(java.lang.String path)
          test whether path is allowed or not based on folder security
 boolean isPathAllowed(java.lang.String path, Permission permission)
          Deprecated. no longer used
 boolean isPathBeneathProjectDir(java.lang.String path)
          tests whether the path starts with project dir or not
 boolean isPathBeneathPublicDir(java.lang.String path)
          checks whether specified path belongs to project modules
 boolean isPathBeneathUserDir(java.lang.String path)
          checks whether the specified path belongs for private contents or not
 boolean isProjectAdminUser()
          returns true if user is member of PROJ_ADMINISTRATOR
 boolean removeFileFolder(java.lang.String pathname)
           
 boolean renameFileFolder(java.lang.String existing, java.lang.String newname)
          renames existing file or dir.
 java.lang.String resolvePathWithProjectDir(java.lang.String path)
          construct absoulute path with project dir
 Analysis restoreAnalysis(java.lang.String analysisConfigName)
           
 void save(java.lang.String relativeFilename, Analysis analysis, java.lang.String comment)
           
 void savePersonal(java.lang.String relativeUrl, Analysis analysis, java.lang.String comment)
           
 void saveProject()
          Save project
 void savePublic(java.lang.String relativeUrl, Analysis analysis, java.lang.String comment)
           
 void saveRFunctionListBean(RFunctionList object)
          serialize RFunctionList object into rfunction.xml file
 void saveTextFileContent(java.lang.String file, java.lang.String content)
          save text content to the specified file
 void setBaseDirectory(java.lang.String baseDirectory)
           
 void setDatasource(java.lang.String datasourceKey, java.lang.Object dataSource)
           
 void setProject(Project project)
           
 void setUser(ProjectUser user)
           
 java.lang.String toPrivateMenuUri(java.lang.String publicMenu)
          coverts menu to their private menu.
 void zipProjectContents(java.util.zip.ZipOutputStream zos)
          Zips the contents of project directory, for this project context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL_USERS

public static final java.lang.String ALL_USERS
See Also:
Constant Field Values
Constructor Detail

ProjectContext

public ProjectContext(Project project,
                      java.lang.String baseDirectory,
                      ProjectUser user)
Parameters:
project -
baseDirectory -
username -
Method Detail

getBaseDirectory

public java.lang.String getBaseDirectory()
Returns:
Returns the baseDirectory.

setBaseDirectory

public void setBaseDirectory(java.lang.String baseDirectory)
Parameters:
baseDirectory - The baseDirectory to set.

getProjectDirectory

public java.lang.String getProjectDirectory()

getProject

public Project getProject()
Returns:
Returns the project.

setProject

public void setProject(Project project)
Parameters:
project - The project to set.

getUser

public ProjectUser getUser()
Returns:
Returns the ProjectUser.

setUser

public void setUser(ProjectUser user)
Parameters:
user - The ProjectUser to set.

getUserRoles

public java.util.List getUserRoles()
returns current user roles

Returns:

isAppAdminUser

public boolean isAppAdminUser()
returns true if user is member of APP_ADMINISTRATOR

Returns:

isProjectAdminUser

public boolean isProjectAdminUser()
returns true if user is member of PROJ_ADMINISTRATOR

Returns:

getDatasourceObject

public java.lang.Object getDatasourceObject(java.lang.String datasourceName)
returns datasource object from datasource name

Parameters:
datasourceName - String
Returns:
Datasource

getDatasource

public Datasource getDatasource(java.lang.String datasourceName)
returns datasource object from datasource name

Parameters:
datasourceName - String
Returns:
Datasource

setDatasource

public void setDatasource(java.lang.String datasourceKey,
                          java.lang.Object dataSource)
Parameters:
datasourceKey - String
dataSource - Datasource

getJdbcDatasourceMap

public java.util.Map getJdbcDatasourceMap()
returns all available JdbcDatasource

Returns:
Map

getXmlaDatasourceMap

public java.util.Map getXmlaDatasourceMap()
returns all available xmla datasource

Returns:
Map

getJdbcDataSourceProperties

public java.util.Properties getJdbcDataSourceProperties(Analysis analysis)
returns jdbc connection properties of specified analysis. returns default one if datasource is not specified for analysis

Returns:
Properties

getJdbcDataSourceProperties

public java.util.Properties getJdbcDataSourceProperties(java.lang.String dataSourceName)
returns jdbc connection properties. returns default one if datasourcename is not specified explicity

Returns:
Properties

getJdbcDatasource

public JdbcDatasource getJdbcDatasource(java.lang.String dataSourceName)
returns jdbc datasource. Returns default one, if dataSourceName is not specified

Parameters:
analysis - Analysis
Returns:
JdbcDatasource

getFeedsDatasource

public FeedsDatasource getFeedsDatasource(java.lang.String datasourceName)
returns FeedsDatasource object

Parameters:
datasourceName -
Returns:

getFeedsDatasourceMap

public java.util.Map getFeedsDatasourceMap()
returns FeedsDatasource map

Parameters:
datasourceName -
Returns:

deleteDatasource

public void deleteDatasource(java.lang.String datasourceName)
To remove datasource from project

Parameters:
datasourceName - String

getJasperDatasource

public JdbcDatasource getJasperDatasource(java.lang.String template)
return JdbcDatasource object of specified template-i.e .jrxml file

Parameters:
template - String
Returns:
JdbcDatasource

buildMenu

public Menu buildMenu(boolean applyFilterPattern)
               throws java.io.IOException
Determines appropriate base project directory, and which directories to include in menu delegates all menu building to the MenuBuilder

Parameters:
applyFilterPattern - filter is applied if true
Returns:
menu appropriate for the given project context (project context implies user context)
Throws:
java.io.IOException - for a bad project directory

toPrivateMenuUri

public java.lang.String toPrivateMenuUri(java.lang.String publicMenu)
coverts menu to their private menu. Returns null if private is not available

Parameters:
publicMenu -
Returns:

buildMenu

public Menu buildMenu()
               throws java.io.IOException
Deprecated. 

Determines appropriate base project directory, and which directories to include in menu delegates all menu building to the MenuBuilder

Returns:
menu appropriate for the given project context (project context implies user context)
Throws:
java.io.IOException - for a bad project directory

savePublic

public void savePublic(java.lang.String relativeUrl,
                       Analysis analysis,
                       java.lang.String comment)
                throws java.io.IOException
Throws:
java.io.IOException

savePersonal

public void savePersonal(java.lang.String relativeUrl,
                         Analysis analysis,
                         java.lang.String comment)
                  throws java.io.IOException
Throws:
java.io.IOException

save

public void save(java.lang.String relativeFilename,
                 Analysis analysis,
                 java.lang.String comment)
          throws java.io.IOException
Throws:
java.io.IOException

deleteAnalysis

public void deleteAnalysis(java.lang.String relativeUrl)
Parameters:
relativeUrl -

restoreAnalysis

public Analysis restoreAnalysis(java.lang.String analysisConfigName)
                         throws java.io.IOException
Throws:
java.io.IOException

saveProject

public void saveProject()
Save project

Throws:
java.io.IOException

getChangeLog

public ChangeLog getChangeLog()
for getChangeLog - need to trap IOException, this is non critical

Returns:

hasPermission

public boolean hasPermission(Permission permission)
Deprecated. use checkPermission(String)

Method to check user's permission

Parameters:
permission - Permission
Returns:
boolean

createDirectory

public void createDirectory(java.lang.String relativeDirectoryName)
Creates a directory below this project context's projectDirectory. Will not attempt to create a directory that already exists.

Parameters:
relativeDirectoryName -

getProjectModules

public java.util.List getProjectModules(boolean includePrivate,
                                        boolean includePublic)
                                 throws java.io.IOException
return list of accessible modules(folders) for the project user

Returns:
List module list
Throws:
java.io.IOException

isPathAllowed

public boolean isPathAllowed(java.lang.String path)
test whether path is allowed or not based on folder security

Parameters:
path - String
Returns:
boolean

isPathAllowed

public boolean isPathAllowed(java.lang.String path,
                             Permission permission)
Deprecated. no longer used

test whether path is allowed or not based on folder security and user's permission. returns true if it is allowed

Parameters:
path - String
permission - Permission
Returns:
boolean

extractModulePath

public java.lang.String extractModulePath(java.lang.String path)
extracts path from base directory

Parameters:
path - String
Returns:
String

addSubFolder

public boolean addSubFolder(java.lang.String base,
                            java.lang.String folderName)
                     throws java.lang.Exception
creates specified folder to the base path . base should be either absolute or relative to the project dir

Parameters:
base - String
folderName - String
Returns:
boolean
Throws:
java.lang.Exception

isPathBeneathProjectDir

public boolean isPathBeneathProjectDir(java.lang.String path)
                                throws java.lang.Exception
tests whether the path starts with project dir or not

Parameters:
path - String
Returns:
boolean
Throws:
java.lang.Exception

renameFileFolder

public boolean renameFileFolder(java.lang.String existing,
                                java.lang.String newname)
                         throws java.lang.Exception
renames existing file or dir. path should either be absolute or relative to the project dir

Parameters:
existing - String
newname - String
Returns:
boolean
Throws:
java.lang.Exception

removeFileFolder

public boolean removeFileFolder(java.lang.String pathname)
                         throws java.lang.Exception
Parameters:
path - String
Returns:
boolean
Throws:
java.lang.Exception

resolvePathWithProjectDir

public java.lang.String resolvePathWithProjectDir(java.lang.String path)
construct absoulute path with project dir

Parameters:
path - String
Returns:
String

getProjectSubDirs

public java.util.List getProjectSubDirs()
Returns:
List

getFilesByExtension

public java.util.List getFilesByExtension(java.lang.String extension)
                                   throws java.io.IOException
returns all files available under project dir filtered with extension

Parameters:
extension - String
Returns:
List
Throws:
java.io.IOException

zipProjectContents

public void zipProjectContents(java.util.zip.ZipOutputStream zos)
                        throws java.io.IOException
Zips the contents of project directory, for this project context.

Parameters:
zos - zos zip output stream, caller permitted to wrap various stream in the zip os (file, servlet, etc)
Throws:
java.io.IOException

saveTextFileContent

public void saveTextFileContent(java.lang.String file,
                                java.lang.String content)
                         throws java.lang.Exception
save text content to the specified file

Parameters:
file - String relative path of the file
content - String text content
Throws:
java.lang.Exception

getRFunctionList

public RFunctionList getRFunctionList()
                               throws java.lang.Exception
returns RFunctionList bean restored from rfunction.xml. returns new instance of RFunctionList if rfunction.xml file not found

Returns:
RFunctionList
Throws:
java.lang.Exception

saveRFunctionListBean

public void saveRFunctionListBean(RFunctionList object)
                           throws java.lang.Exception
serialize RFunctionList object into rfunction.xml file

Parameters:
object - RFunctionList
Throws:
java.lang.Exception

autogenerate

public void autogenerate(java.lang.String datasourceName,
                         java.lang.String cube,
                         java.lang.String relativeDir,
                         java.util.List measures)
                  throws com.tonbeller.jpivot.olap.model.OlapException,
                         java.io.IOException
Parameters:
uri -
catalog -
cube -
relativeDir -
Throws:
com.tonbeller.jpivot.olap.model.OlapException
java.io.IOException

getAutoGeneratedMenuNames

public java.util.List getAutoGeneratedMenuNames()
Returns:
a non-null list of menu names, under "Auto Generated"

getResourceString

public java.lang.String getResourceString(java.lang.String resourceId)
returns resource string if id for currect user locale from the standard resource bundle

Parameters:
resourceId -
Returns:

getCustomResourceString

public java.lang.String getCustomResourceString(java.lang.String resourceId)
returns resource string if id for currect user locale from the customizable resource bundle

Parameters:
resourceId -
Returns:

checkPermission

public boolean checkPermission(java.lang.String resource)
Checks whether the the resource is allowed for current user or not

Parameters:
resource - resource path. e.g 'deleteanalysis.htm'
Returns:
true if allowed

checkPermission

public boolean checkPermission(java.lang.String resource,
                               java.util.Map params)
Checks whether the the resource is allowed for current user or not

Parameters:
resource - resource path. e.g 'deleteanalysis.htm'
params - Request Parameter
Returns:
true if allowed

getSecurityDefinitionList

public java.util.List getSecurityDefinitionList()
returns SecurityDefinition entries defined in Application. For backward compatibility, it returns SecurityDefinition, created from old permission list

Returns:

isPathBeneathUserDir

public boolean isPathBeneathUserDir(java.lang.String path)
                             throws java.io.IOException
checks whether the specified path belongs for private contents or not

Parameters:
path -
Returns:
Throws:
java.lang.Exception
java.io.IOException

getSecurityDefinitionSelectionMap

public java.util.Map getSecurityDefinitionSelectionMap()
returns map of security definition with value as a map of role selection

Returns:
Map of SecurirityDefinition

isPathBeneathPublicDir

public boolean isPathBeneathPublicDir(java.lang.String path)
                               throws java.lang.Exception
checks whether specified path belongs to project modules

Parameters:
path -
Returns:
true if yes, otherwise false
Throws:
java.lang.Exception