Class MondrianCatalogHelper
- java.lang.Object
-
- org.pentaho.platform.plugin.action.mondrian.catalog.MondrianCatalogHelper
-
- All Implemented Interfaces:
IAclAwareMondrianCatalogService
,IMondrianCatalogService
public class MondrianCatalogHelper extends Object implements IAclAwareMondrianCatalogService
Reads in file containing Mondrian data sources and catalogs. (Contains code copied fromXmlaServlet
.)- Author:
- mlowery
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
MondrianCatalogHelper.CatalogPermission
-
Field Summary
Fields Modifier and Type Field Description static String
MONDRIAN_CATALOG_CACHE_REGION
static String
MONDRIAN_DATASOURCE_FOLDER
static String
SOLUTION_PREFIX
-
Constructor Summary
Constructors Constructor Description MondrianCatalogHelper()
MondrianCatalogHelper(boolean useLegacyDbName)
MondrianCatalogHelper(org.pentaho.platform.api.repository2.unified.IAclNodeHelper aclHelper)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addCatalog(InputStream inputStream, MondrianCatalog catalog, boolean overwriteInRepossitory, org.pentaho.platform.api.engine.IPentahoSession session)
pass the input stream directly from data access PUC and schema workbenchvoid
addCatalog(InputStream schemaInputStream, MondrianCatalog catalog, boolean overwrite, org.pentaho.platform.api.repository2.unified.RepositoryFileAcl acl, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
new method to pass the input stream directly from data access put and post schemavoid
addCatalog(MondrianCatalog catalog, boolean overwrite, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
use the in memory session value of input stream (used by test harness)static int
addToCatalog(String baseUrl, boolean enableXmla, String schemaSolutionPath, org.pentaho.platform.api.engine.IPentahoSession session, String jndiName, boolean overwrite)
protected void
appendCatalogsSection(org.pentaho.platform.api.repository2.unified.IUnifiedRepository unifiedRepository, String etcMondrian, org.pentaho.platform.api.repository2.unified.RepositoryFile etcMondrianFolder, StringBuffer datasourcesXML)
protected String
applyDSP(org.pentaho.platform.api.engine.IPentahoSession ps, String catalogDsInfo, String catalogDefinition)
protected boolean
catalogExists(MondrianCatalog catalog, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
Performs a search for an existing catalog based on the datasource info and catalog definition.protected String
cleanseDataSourceInfo(String dataSourceInfo)
protected String
contextPathFromRequestContextHolder()
protected String
docAtUrlToString(String urlStr, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
protected List<MondrianCatalog>
filter(List<MondrianCatalog> origList, org.pentaho.platform.api.engine.IPentahoSession pentahoSession, boolean jndiOnly)
String
generateInMemoryDatasourcesXml(org.pentaho.platform.api.repository2.unified.IUnifiedRepository unifiedRepository)
org.pentaho.platform.api.repository2.unified.RepositoryFileAcl
getAclFor(String catalogName)
protected org.pentaho.platform.api.repository2.unified.IAclNodeHelper
getAclHelper()
MondrianCatalog
getCatalog(String context, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
Returns the catalog with the given context - name or definition allowable.protected String
getCatalogAsString(org.pentaho.platform.api.engine.IPentahoSession ps, mondrian.xmla.DataSourcesConfig.Catalog catalog)
MondrianCatalogComplementInfo
getCatalogComplementInfoMap(String name)
Method to access the MondrianCatalogComplementInfo taken a catalog name.protected MondrianCatalog
getCatalogFromCache(String context, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
protected List<MondrianCatalog>
getCatalogs(org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
String
getDataSourcesConfig()
static MondrianCatalogHelper
getInstance()
Deprecated.Please use PentahoSystem.get to get the Mondrian Catalog Serviceprotected MondrianCatalogRepositoryHelper
getMondrianCatalogRepositoryHelper()
protected org.pentaho.platform.api.repository2.unified.IUnifiedRepository
getRepository()
protected MondrianSchema
getSchema(String catalogName, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
protected String
getSolutionRepositoryRelativePath(String path, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
protected boolean
hasAccess(MondrianCatalog cat, org.pentaho.platform.api.repository2.unified.RepositoryFilePermission permission)
This (hacky) implementation bases its decision on whether or not the user has the permission (indicated byCatalogPermission
) based on whether the user has permission on the file in the solution repository indicated bycatalog.getDefinition()
.void
importSchema(File mondrianFile, String databaseConnection, String parameters)
protected void
init(org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
boolean
isUseSchemaNameAsCatalogName()
List<MondrianCatalog>
listCatalogs(org.pentaho.platform.api.engine.IPentahoSession pentahoSession, boolean jndiOnly)
Lists all catalogs (filtered according to access control rules).protected void
loadCatalogsIntoCache(mondrian.xmla.DataSourcesConfig.DataSources dataSources, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
MondrianSchema
loadMondrianSchema(String solutionLocation, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
this method loads a mondrian schemaprotected Map<String,MondrianCatalogComplementInfo>
makeCatalogComplementInfoMap(org.eigenbase.xom.DOMWrapper doc)
protected Map<String,MondrianCatalog>
makeCatalogMap(List<MondrianCatalog> cats)
protected mondrian.xmla.DataSourcesConfig.DataSources
makeDataSources()
Same as implemented inXmlaServlet
except takes advantage of Spring's Resource framework.protected MondrianSchema
makeSchema(String catalogStr)
protected mondrian.xmla.DataSourcesConfig.DataSources
parseDataSources(String dataSourcesConfigString)
protected mondrian.xmla.DataSourcesConfig.DataSources
parseDataSourcesUrl(URL dataSourcesConfigUrl)
protected String
readDataSourcesContent(URL dataSourcesConfigUrl)
void
reInit(org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
Flushes the catalog cache.void
removeCatalog(String catalogName, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
This method removes a mondrian catalog from the JCR repository.void
setAclFor(String catalogName, org.pentaho.platform.api.repository2.unified.RepositoryFileAcl acl)
void
setAclHelper(org.pentaho.platform.api.repository2.unified.IAclNodeHelper helper)
void
setDataSourcesConfig(String dataSourcesConfig)
void
setUseSchemaNameAsCatalogName(boolean useSchemaNameAsCatalogName)
protected List<MondrianCatalog>
transformIntoCatalogList(mondrian.xmla.DataSourcesConfig.DataSources dataSources, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
Deprecated.protected void
writeDataSources(mondrian.xmla.DataSourcesConfig.DataSources dataSources)
Deprecated.
-
-
-
Field Detail
-
MONDRIAN_DATASOURCE_FOLDER
public static final String MONDRIAN_DATASOURCE_FOLDER
- See Also:
- Constant Field Values
-
SOLUTION_PREFIX
public static final String SOLUTION_PREFIX
- See Also:
- Constant Field Values
-
MONDRIAN_CATALOG_CACHE_REGION
public static String MONDRIAN_CATALOG_CACHE_REGION
-
-
Constructor Detail
-
MondrianCatalogHelper
@Deprecated public MondrianCatalogHelper(org.pentaho.platform.api.repository2.unified.IAclNodeHelper aclHelper)
Deprecated.
-
MondrianCatalogHelper
public MondrianCatalogHelper()
-
MondrianCatalogHelper
public MondrianCatalogHelper(boolean useLegacyDbName)
-
-
Method Detail
-
getCatalogs
protected List<MondrianCatalog> getCatalogs(org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
-
catalogExists
protected boolean catalogExists(MondrianCatalog catalog, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
Performs a search for an existing catalog based on the datasource info and catalog definition.- Parameters:
catalog
- The catalog to compare againstpentahoSession
- The session with which this request is associated (Used to locate the cache)- Returns:
- True if an existing match has been found for the catalog
-
getCatalogFromCache
protected MondrianCatalog getCatalogFromCache(String context, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
-
getInstance
@Deprecated public static MondrianCatalogHelper getInstance()
Deprecated.Please use PentahoSystem.get to get the Mondrian Catalog ServiceTODO Delete this method. Calling this method ties you to this implementation.
-
init
protected void init(org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
-
reInit
public void reInit(org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
Description copied from interface:IMondrianCatalogService
Flushes the catalog cache.- Specified by:
reInit
in interfaceIMondrianCatalogService
-
makeDataSources
protected mondrian.xmla.DataSourcesConfig.DataSources makeDataSources()
Same as implemented inXmlaServlet
except takes advantage of Spring's Resource framework.
-
generateInMemoryDatasourcesXml
public String generateInMemoryDatasourcesXml(org.pentaho.platform.api.repository2.unified.IUnifiedRepository unifiedRepository)
-
contextPathFromRequestContextHolder
protected String contextPathFromRequestContextHolder()
-
appendCatalogsSection
protected void appendCatalogsSection(org.pentaho.platform.api.repository2.unified.IUnifiedRepository unifiedRepository, String etcMondrian, org.pentaho.platform.api.repository2.unified.RepositoryFile etcMondrianFolder, StringBuffer datasourcesXML)
-
parseDataSourcesUrl
protected mondrian.xmla.DataSourcesConfig.DataSources parseDataSourcesUrl(URL dataSourcesConfigUrl)
-
readDataSourcesContent
protected String readDataSourcesContent(URL dataSourcesConfigUrl) throws IOException
- Throws:
IOException
-
parseDataSources
protected mondrian.xmla.DataSourcesConfig.DataSources parseDataSources(String dataSourcesConfigString)
-
makeCatalogComplementInfoMap
protected Map<String,MondrianCatalogComplementInfo> makeCatalogComplementInfoMap(org.eigenbase.xom.DOMWrapper doc)
-
makeCatalogMap
protected Map<String,MondrianCatalog> makeCatalogMap(List<MondrianCatalog> cats)
-
getDataSourcesConfig
public String getDataSourcesConfig()
-
setDataSourcesConfig
public void setDataSourcesConfig(String dataSourcesConfig)
-
listCatalogs
public List<MondrianCatalog> listCatalogs(org.pentaho.platform.api.engine.IPentahoSession pentahoSession, boolean jndiOnly)
Description copied from interface:IMondrianCatalogService
Lists all catalogs (filtered according to access control rules).- Specified by:
listCatalogs
in interfaceIMondrianCatalogService
jndiOnly
- return only JNDI-based catalogs
-
addCatalog
public void addCatalog(MondrianCatalog catalog, boolean overwrite, org.pentaho.platform.api.engine.IPentahoSession pentahoSession) throws MondrianCatalogServiceException
use the in memory session value of input stream (used by test harness)- Specified by:
addCatalog
in interfaceIMondrianCatalogService
overwrite
- true to overwrite existing catalog (based on match with definition and effectiveDataSourceInfo- Throws:
MondrianCatalogServiceException
-
addCatalog
public void addCatalog(InputStream inputStream, MondrianCatalog catalog, boolean overwriteInRepossitory, org.pentaho.platform.api.engine.IPentahoSession session)
pass the input stream directly from data access PUC and schema workbench- Specified by:
addCatalog
in interfaceIMondrianCatalogService
-
addCatalog
public void addCatalog(InputStream schemaInputStream, MondrianCatalog catalog, boolean overwrite, org.pentaho.platform.api.repository2.unified.RepositoryFileAcl acl, org.pentaho.platform.api.engine.IPentahoSession pentahoSession) throws MondrianCatalogServiceException
new method to pass the input stream directly from data access put and post schema- Specified by:
addCatalog
in interfaceIAclAwareMondrianCatalogService
- Parameters:
schemaInputStream
-catalog
-overwrite
-acl
- catalog ACLpentahoSession
-- Throws:
MondrianCatalogServiceException
-
getRepository
protected org.pentaho.platform.api.repository2.unified.IUnifiedRepository getRepository()
-
getMondrianCatalogRepositoryHelper
protected MondrianCatalogRepositoryHelper getMondrianCatalogRepositoryHelper()
-
getAclHelper
protected org.pentaho.platform.api.repository2.unified.IAclNodeHelper getAclHelper()
-
setAclHelper
public void setAclHelper(org.pentaho.platform.api.repository2.unified.IAclNodeHelper helper)
-
setAclFor
public void setAclFor(String catalogName, org.pentaho.platform.api.repository2.unified.RepositoryFileAcl acl)
- Specified by:
setAclFor
in interfaceIAclAwareMondrianCatalogService
-
getAclFor
public org.pentaho.platform.api.repository2.unified.RepositoryFileAcl getAclFor(String catalogName)
- Specified by:
getAclFor
in interfaceIAclAwareMondrianCatalogService
-
importSchema
public void importSchema(File mondrianFile, String databaseConnection, String parameters)
-
writeDataSources
@Deprecated protected void writeDataSources(mondrian.xmla.DataSourcesConfig.DataSources dataSources)
Deprecated.
-
getCatalog
public MondrianCatalog getCatalog(String context, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
Description copied from interface:IMondrianCatalogService
Returns the catalog with the given context - name or definition allowable. Returnsnull
if context not recognized.- Specified by:
getCatalog
in interfaceIMondrianCatalogService
- Parameters:
context
- Either the name of the catalog to fetch, or the catalog's definition string NOTE that the context can be the catalog name or the definition string for the catalog. If you are using the definition string to retrieve the catalog from the cache, you cannot be guaranteed what datasource is in play; so under these circumstances, this catalog's definition is the only part of the catalog that can be trusted. As this feature was added to enable looking up Mondrian roles from the schema, we don't much care which datasource is in play.
-
loadCatalogsIntoCache
protected void loadCatalogsIntoCache(mondrian.xmla.DataSourcesConfig.DataSources dataSources, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
-
applyDSP
protected String applyDSP(org.pentaho.platform.api.engine.IPentahoSession ps, String catalogDsInfo, String catalogDefinition) throws Exception
- Throws:
Exception
-
getCatalogAsString
protected String getCatalogAsString(org.pentaho.platform.api.engine.IPentahoSession ps, mondrian.xmla.DataSourcesConfig.Catalog catalog) throws Exception
- Throws:
Exception
-
transformIntoCatalogList
@Deprecated protected List<MondrianCatalog> transformIntoCatalogList(mondrian.xmla.DataSourcesConfig.DataSources dataSources, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
Deprecated.
-
getCatalogComplementInfoMap
public MondrianCatalogComplementInfo getCatalogComplementInfoMap(String name)
Method to access the MondrianCatalogComplementInfo taken a catalog name.- Parameters:
name
- Catalog schema location- Returns:
- MondrianCatalogComplementInfo object
-
loadMondrianSchema
public MondrianSchema loadMondrianSchema(String solutionLocation, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
this method loads a mondrian schema- Specified by:
loadMondrianSchema
in interfaceIMondrianCatalogService
- Parameters:
solutionLocation
- location of the schemapentahoSession
- current session object- Returns:
- Mondrian Schema object.
-
docAtUrlToString
protected String docAtUrlToString(String urlStr, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
-
getSchema
protected MondrianSchema getSchema(String catalogName, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
-
makeSchema
protected MondrianSchema makeSchema(String catalogStr)
-
filter
protected List<MondrianCatalog> filter(List<MondrianCatalog> origList, org.pentaho.platform.api.engine.IPentahoSession pentahoSession, boolean jndiOnly)
-
hasAccess
protected boolean hasAccess(MondrianCatalog cat, org.pentaho.platform.api.repository2.unified.RepositoryFilePermission permission)
This (hacky) implementation bases its decision on whether or not the user has the permission (indicated byCatalogPermission
) based on whether the user has permission on the file in the solution repository indicated bycatalog.getDefinition()
. Why is this class even enforcing security anyway!?
-
getSolutionRepositoryRelativePath
protected String getSolutionRepositoryRelativePath(String path, org.pentaho.platform.api.engine.IPentahoSession pentahoSession)
-
isUseSchemaNameAsCatalogName
public boolean isUseSchemaNameAsCatalogName()
-
setUseSchemaNameAsCatalogName
public void setUseSchemaNameAsCatalogName(boolean useSchemaNameAsCatalogName)
-
addToCatalog
public static int addToCatalog(String baseUrl, boolean enableXmla, String schemaSolutionPath, org.pentaho.platform.api.engine.IPentahoSession session, String jndiName, boolean overwrite)
-
removeCatalog
public void removeCatalog(String catalogName, org.pentaho.platform.api.engine.IPentahoSession pentahoSession) throws MondrianCatalogServiceException
This method removes a mondrian catalog from the JCR repository.- Specified by:
removeCatalog
in interfaceIMondrianCatalogService
- Parameters:
catalogName
- the name of the catalog to removepentahoSession
- current session object- Throws:
MondrianCatalogServiceException
-
-