private boolean isKioskEnabled() { if (PentahoSystem.getInitializedOK()) { return "true".equals(PentahoSystem.getSystemSetting("kiosk-mode", "false")); } else { return false; } }
public static void mapPlatformRolesToMondrianRolesHelper(Util.PropertyList properties) throws PentahoAccessControlException { if (properties.get(RolapConnectionProperties.Role.name(), null) == null) { // Only if the action sequence/requester hasn't already injected a role in here do this. if (PentahoSystem.getObjectFactory().objectDefined(MDXConnection.MDX_CONNECTION_MAPPER_KEY)) { IConnectionUserRoleMapper mondrianUserRoleMapper = PentahoSystem.get( IConnectionUserRoleMapper.class, MDXConnection.MDX_CONNECTION_MAPPER_KEY, null); if (mondrianUserRoleMapper != null) { // Do role mapping String[] validMondrianRolesForUser = mondrianUserRoleMapper.mapConnectionRoles( PentahoSessionHolder.getSession(), properties.get(RolapConnectionProperties.Catalog.name())); if ((validMondrianRolesForUser != null) && (validMondrianRolesForUser.length > 0)) { StringBuffer buff = new StringBuffer(); String aRole = null; for (int i = 0; i < validMondrianRolesForUser.length; i++) { aRole = validMondrianRolesForUser[i]; // According to http://mondrian.pentaho.org/documentation/configuration.php // double-comma escapes a comma if (i > 0) { buff.append(","); // $NON-NLS-1$ } buff.append(aRole.replaceAll(",", ",,")); // $NON-NLS-1$//$NON-NLS-2$ } properties.put(RolapConnectionProperties.Role.name(), buff.toString()); } } } } }
@Before public void init0() { microPlatform = new MicroPlatform("test-src/solution"); microPlatform.define(ISolutionEngine.class, SolutionEngine.class); microPlatform.define( IUnifiedRepository.class, FileSystemBackedUnifiedRepository.class, Scope.GLOBAL); microPlatform.define(IMondrianCatalogService.class, MondrianCatalogHelper.class, Scope.GLOBAL); microPlatform.define("connection-SQL", SQLConnection.class); microPlatform.define("connection-MDX", MDXConnection.class); microPlatform.define(IDBDatasourceService.class, JndiDatasourceService.class, Scope.GLOBAL); microPlatform.define(IUserRoleListService.class, TestUserRoleListService.class, Scope.GLOBAL); microPlatform.define(UserDetailsService.class, TestUserDetailsService.class, Scope.GLOBAL); FileSystemBackedUnifiedRepository repo = (FileSystemBackedUnifiedRepository) PentahoSystem.get(IUnifiedRepository.class); repo.setRootDir(new File("test-src/solution")); try { microPlatform.start(); } catch (PlatformInitializationException ex) { Assert.fail(); } MondrianCatalogHelper catalogService = (MondrianCatalogHelper) PentahoSystem.get(IMondrianCatalogService.class); catalogService.setDataSourcesConfig( "file:" + PentahoSystem.getApplicationContext() .getSolutionPath("test/analysis/test-datasources.xml")); // JNDI System.setProperty("java.naming.factory.initial", "org.osjava.sj.SimpleContextFactory"); System.setProperty("org.osjava.sj.root", "test-src/solution/system/simple-jndi"); System.setProperty("org.osjava.sj.delimiter", "/"); }
public void showInitializationMessage( final boolean initOk, final String fullyQualifiedServerUrl) { if (PentahoSystem.getObjectFactory().objectDefined(IVersionHelper.class.getSimpleName())) { IVersionHelper helper = PentahoSystem.get(IVersionHelper.class, null); // No session yet if (initOk) { System.out.println( Messages.getInstance() .getString( "SolutionContextListener.INFO_SYSTEM_READY", "(" + helper.getVersionInformation(PentahoSystem.class) + ")", fullyQualifiedServerUrl, SolutionContextListener .solutionPath)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } else { System.err.println( Messages.getInstance() .getString( "SolutionContextListener.INFO_SYSTEM_NOT_READY", "(" + helper.getVersionInformation(PentahoSystem.class) + ")", fullyQualifiedServerUrl, SolutionContextListener .solutionPath)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } } }
public ISolutionEngine getSolutionEngine(String path) { StandaloneApplicationContext applicationContext = new StandaloneApplicationContext(path, ""); // $NON-NLS-1$ if (!PentahoSystem.getInitializedOK()) { PentahoSystem.init(applicationContext); assertTrue( "PentahoSystem did not initialize", PentahoSystem.getInitializedOK()); // $NON-NLS-1$ } IPentahoSession session = new StandaloneSession("system"); // $NON-NLS-1$ ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, session); assertNotNull("SolutionEngine is null", solutionEngine); // $NON-NLS-1$ solutionEngine.setLoggingLevel(ILogger.ERROR); solutionEngine.init(session); try { solutionEngine.setSession(session); return solutionEngine; } catch (Exception e) { // we should not get here e.printStackTrace(); assertTrue(e.getMessage(), false); } return null; }
public static String postExecute( IRuntimeContext runtime, boolean debugMessages, boolean doWrapper, IOutputHandler outputHandler, Map<String, IParameterProvider> parameterProviders, HttpServletRequest request, HttpServletResponse response, List<?> messages, boolean deleteGeneratedFiles) throws Exception { StringBuffer buffer = new StringBuffer(); boolean hasResponse = outputHandler.isResponseExpected(); IContentItem responseContentItem = outputHandler.getOutputContentItem( IOutputHandler.RESPONSE, IOutputHandler.CONTENT, null, null); boolean success = (runtime != null && runtime.getStatus() == IRuntimeContext.RUNTIME_STATUS_SUCCESS); boolean printSuccess = (runtime != null) && success && (!hasResponse || debugMessages); boolean printError = (runtime != null) && !success && !response.isCommitted(); if (printSuccess || printError) { final String htmlMimeType = "text/html"; // $NON-NLS-1$ responseContentItem.setMimeType(htmlMimeType); response.setContentType(htmlMimeType); IMessageFormatter formatter = PentahoSystem.get(IMessageFormatter.class, PentahoSessionHolder.getSession()); if (printSuccess) { formatter.formatSuccessMessage(htmlMimeType, runtime, buffer, debugMessages, doWrapper); } else { response.resetBuffer(); formatter.formatFailureMessage(htmlMimeType, runtime, buffer, messages); } } // clear files which was generated during action execution // http://jira.pentaho.com/browse/BISERVER-12639 IUnifiedRepository unifiedRepository = PentahoSystem.get(IUnifiedRepository.class, null); if (unifiedRepository != null) { for (IContentItem contentItem : runtime.getOutputContentItems()) { if (contentItem != null) { try { contentItem.closeOutputStream(); if (deleteGeneratedFiles) { deleteContentItem(contentItem, unifiedRepository); } } catch (Exception e) { logger.warn( Messages.getInstance() .getString("XactionUtil.CANNOT_REMOVE_OUTPUT_FILE", contentItem.getPath()), e); } } } } return buffer.toString(); }
protected AuthenticationManager getAuthenticationManager() { if (authManager == null && PentahoSystem.getInitializedOK()) { authManager = PentahoSystem.get(AuthenticationManager.class); } if (authManager == null) { return NULL_AUTHENTICATION_MANAGER; } return authManager; }
@Override public void createContent() throws Exception { this.session = PentahoSessionHolder.getSession(); this.repository = PentahoSystem.get(IUnifiedRepository.class, session); final RepositoryFile BIRTfile = (RepositoryFile) parameterProviders.get("path").getParameter("file"); final String ExecBIRTFilePath = "../webapps/birt/" + BIRTfile.getId() + ".rptdocument"; /* * Get BIRT report design from repository */ final File ExecBIRTFile = new File(ExecBIRTFilePath); if (!ExecBIRTFile.exists()) { final FileOutputStream fos = new FileOutputStream(ExecBIRTFilePath); try { final SimpleRepositoryFileData data = repository.getDataForRead(BIRTfile.getId(), SimpleRepositoryFileData.class); final InputStream inputStream = data.getInputStream(); final byte[] buffer = new byte[0x1000]; int bytesRead = inputStream.read(buffer); while (bytesRead >= 0) { fos.write(buffer, 0, bytesRead); bytesRead = inputStream.read(buffer); } } catch (final Exception e) { Logger.error(getClass().getName(), e.getMessage()); } finally { fos.close(); } } /* * Redirect to BIRT Viewer */ try { // Get informations about user context final IUserRoleListService service = PentahoSystem.get(IUserRoleListService.class); String roles = ""; final ListIterator<String> li = service.getRolesForUser(null, session.getName()).listIterator(); while (li.hasNext()) { roles = roles + li.next().toString() + ","; } // Redirect final HttpServletResponse response = (HttpServletResponse) this.parameterProviders.get("path").getParameter("httpresponse"); response.sendRedirect( "/birt/frameset?__document=" + BIRTfile.getId() + ".rptdocument&__showtitle=false&username="******"&userroles=" + roles + "&reportname=" + BIRTfile.getTitle()); } catch (final Exception e) { Logger.error(getClass().getName(), e.getMessage()); } }
public PentahoXmlaServlet() { super(); repo = PentahoSystem.get(IUnifiedRepository.class); mondrianCatalogService = (MondrianCatalogHelper) PentahoSystem.get(IMondrianCatalogService.class); try { DefaultFileSystemManager dfsm = (DefaultFileSystemManager) VFS.getManager(); if (dfsm.hasProvider("mondrian") == false) { dfsm.addProvider("mondrian", new MondrianVfs()); } } catch (FileSystemException e) { logger.error(e.getMessage()); } }
@SuppressWarnings("rawtypes") protected static IRuntimeContext executeInternal( RepositoryFile file, IParameterProvider requestParams, HttpServletRequest httpServletRequest, IOutputHandler outputHandler, Map<String, IParameterProvider> parameterProviders, IPentahoSession userSession, boolean forcePrompt, List messages) throws Exception { String processId = XactionUtil.class.getName(); String instanceId = httpServletRequest.getParameter("instance-id"); // $NON-NLS-1$ SimpleUrlFactory urlFactory = new SimpleUrlFactory(""); // $NON-NLS-1$ ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, userSession); ISystemSettings systemSettings = PentahoSystem.getSystemSettings(); if (solutionEngine == null) { throw new ObjectFactoryException("No Solution Engine"); } boolean instanceEnds = "true" .equalsIgnoreCase( requestParams.getStringParameter( "instanceends", "true")); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ String parameterXsl = systemSettings.getSystemSetting( "default-parameter-xsl", "DefaultParameterForm.xsl"); // $NON-NLS-1$ //$NON-NLS-2$ solutionEngine.setLoggingLevel(2); solutionEngine.init(userSession); solutionEngine.setForcePrompt(forcePrompt); if (parameterXsl != null) { solutionEngine.setParameterXsl(parameterXsl); } return solutionEngine.execute( file.getPath(), processId, false, instanceEnds, instanceId, false, parameterProviders, outputHandler, null, urlFactory, messages); }
protected OutputStream getOutputStream(String testName, String extension) { OutputStream outputStream = null; try { String tmpDir = PentahoSystem.getApplicationContext().getFileOutputPath("test/tmp"); // $NON-NLS-1$ File file = new File(tmpDir); file.mkdirs(); String path = PentahoSystem.getApplicationContext() .getFileOutputPath("test/tmp/" + testName + extension); // $NON-NLS-1$ outputStream = new FileOutputStream(path); } catch (FileNotFoundException e) { } return outputStream; }
@Test public void testDeleteUserSettingsByName() throws Exception { IAuthorizationPolicy policy = mock(IAuthorizationPolicy.class); when(policy.isAllowed(anyString())).thenReturn(true); PentahoSystem.registerObject(policy); final RepositoryFile repositoryFile = mock(RepositoryFile.class); when(repositoryFile.getId()).thenReturn(USER_FOLDER_ID); when(repository.getFile(anyString())).thenReturn(repositoryFile); doAnswer( new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { final Map<String, Serializable> settings = (Map<String, Serializable>) invocation.getArguments()[1]; assertNotNull(settings); assertEquals(2, settings.size()); final Iterator<String> iterator = settings.keySet().iterator(); assertFalse(iterator.next().startsWith(UserSettingService.SETTING_PREFIX)); assertFalse(iterator.next().startsWith(UserSettingService.SETTING_PREFIX)); return null; } }) .when(repository) .setFileMetadata(eq(USER_FOLDER_ID), anyMap()); userSettingService.deleteUserSettings("test"); }
private void setObjectFactory(final ServletContext context) { final String SYSTEM_FOLDER = "/system"; // $NON-NLS-1$ String pentahoObjectFactoryClassName = getServerParameter("pentahoObjectFactory"); // $NON-NLS-1$ String pentahoObjectFactoryConfigFile = getServerParameter("pentahoObjectFactoryCfgFile"); // $NON-NLS-1$ // if web.xml doesnt specify a config file, use the default path. if (StringUtils.isEmpty(pentahoObjectFactoryConfigFile)) { pentahoObjectFactoryConfigFile = solutionPath + SYSTEM_FOLDER + "/" + DEFAULT_SPRING_CONFIG_FILE_NAME; // $NON-NLS-1$ } else if (-1 == pentahoObjectFactoryConfigFile.indexOf("/")) { // $NON-NLS-1$ pentahoObjectFactoryConfigFile = solutionPath + SYSTEM_FOLDER + "/" + pentahoObjectFactoryConfigFile; // $NON-NLS-1$ } // else objectFactoryCreatorCfgFile contains the full path. IPentahoObjectFactory pentahoObjectFactory; try { Class<?> classObject = Class.forName(pentahoObjectFactoryClassName); pentahoObjectFactory = (IPentahoObjectFactory) classObject.newInstance(); } catch (Exception e) { String msg = Messages.getInstance() .getErrorString( "SolutionContextListener.ERROR_0002_BAD_OBJECT_FACTORY", pentahoObjectFactoryClassName); //$NON-NLS-1$ // Cannot proceed without an object factory, so we'll put some context around what // we were trying to do throw a runtime exception throw new RuntimeException(msg, e); } pentahoObjectFactory.init(pentahoObjectFactoryConfigFile, context); PentahoSystem.registerPrimaryObjectFactory(pentahoObjectFactory); }
@Test public void testReadRolesInSchema() throws Exception { final MondrianCatalogHelper helper = (MondrianCatalogHelper) PentahoSystem.get(IMondrianCatalogService.class); Assert.assertNotNull(helper); MondrianCatalog mc = SecurityHelper.getInstance() .runAsUser( "admin", new Callable<MondrianCatalog>() { @Override public MondrianCatalog call() throws Exception { return helper.getCatalog("SteelWheelsRoles", PentahoSessionHolder.getSession()); } }); Assert.assertNotNull(mc); MondrianSchema ms = mc.getSchema(); Assert.assertNotNull(ms); String[] roleNames = ms.getRoleNames(); Assert.assertNotNull(roleNames); Assert.assertEquals(2, roleNames.length); Assert.assertEquals("Role1", roleNames[0]); Assert.assertEquals("Role2", roleNames[1]); }
public List<String> getPermittedRoleList(IPentahoSession session) { List<String> roleList = new ArrayList<String>(); Authentication auth = SecurityHelper.getAuthentication(session, true); IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null); String roles = null; try { roles = resLoader.getPluginSetting(getClass(), "settings/data-access-view-roles"); // $NON-NLS-1$ } catch (Exception e) { e.printStackTrace(); } if (roles != null) { String roleArr[] = roles.split(","); // $NON-NLS-1$ for (String role : roleArr) { for (GrantedAuthority userRole : auth.getAuthorities()) { if (role != null && role.trim().equals(userRole.getAuthority())) { roleList.add(role); } } } } return roleList; }
public void testForcePrompt() { startTest(); SimpleParameterProvider parameterProvider = new SimpleParameterProvider(); OutputStream outputStream = getOutputStream("RuntimeTest.testForcePrompt", ".html"); // $NON-NLS-1$ //$NON-NLS-2$ SimpleOutputHandler outputHandler = new SimpleOutputHandler(outputStream, true); outputHandler.setOutputPreference(IOutputHandler.OUTPUT_TYPE_PARAMETERS); StandaloneSession session = new StandaloneSession(Messages.getString("BaseTest.DEBUG_JUNIT_SESSION")); // $NON-NLS-1$ ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, session); solutionEngine.setLoggingLevel(getLoggingLevel()); solutionEngine.init(session); solutionEngine.setForcePrompt(true); IRuntimeContext context = run( solutionEngine, "test", "reporting", "jfreereport-reports-test-param.xaction", null, false, parameterProvider, outputHandler); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertEquals( Messages.getString("BaseTest.USER_RUNNING_ACTION_SEQUENCE"), IRuntimeContext.RUNTIME_STATUS_SUCCESS, context.getStatus()); // $NON-NLS-1$ finishTest(); }
public static MasterReport createReport(final Serializable fileId) throws ResourceException, IOException { final ResourceManager resourceManager = new ResourceManager(); resourceManager.registerDefaults(); final HashMap helperObjects = new HashMap(); // add the runtime context so that PentahoResourceData class can get access // to the solution repo ResourceKey key = null; IUnifiedRepository unifiedRepository = PentahoSystem.get(IUnifiedRepository.class, PentahoSessionHolder.getSession()); RepositoryFile repositoryFile = unifiedRepository.getFileById(fileId); if (repositoryFile != null) { key = resourceManager.createKey( RepositoryResourceLoader.SOLUTION_SCHEMA_NAME + RepositoryResourceLoader.SCHEMA_SEPARATOR + repositoryFile.getPath(), helperObjects); } else { key = resourceManager.createKey( RepositoryResourceLoader.SOLUTION_SCHEMA_NAME + RepositoryResourceLoader.SCHEMA_SEPARATOR + fileId, helperObjects); } final Resource resource = resourceManager.create(key, null, MasterReport.class); return (MasterReport) resource.getResource(); }
protected void importUserSettings(UserExport user) { IUserSettingService settingService = PentahoSystem.get(IUserSettingService.class); IAnyUserSettingService userSettingService = null; if (settingService != null && settingService instanceof IAnyUserSettingService) { userSettingService = (IAnyUserSettingService) settingService; } if (userSettingService != null) { List<ExportManifestUserSetting> exportedSettings = user.getUserSettings(); try { for (ExportManifestUserSetting exportedSetting : exportedSettings) { if (isOverwriteFile()) { userSettingService.setUserSetting( user.getUsername(), exportedSetting.getName(), exportedSetting.getValue()); } else { // see if it's there first before we set this setting IUserSetting userSetting = userSettingService.getUserSetting( user.getUsername(), exportedSetting.getName(), null); if (userSetting == null) { // only set it if we didn't find that it exists already userSettingService.setUserSetting( user.getUsername(), exportedSetting.getName(), exportedSetting.getValue()); } } } } catch (SecurityException e) { log.error( Messages.getInstance().getString("ERROR.ImportingUserSetting", user.getUsername())); log.debug( Messages.getInstance().getString("ERROR.ImportingUserSetting", user.getUsername()), e); } } }
public static boolean hasAccess( final IAclHolder aHolder, final int actionOperation, final IPentahoSession session) { IAclVoter voter = PentahoSystem.get(IAclVoter.class, session); int aclMask = -1; switch (actionOperation) { case (IAclHolder.ACCESS_TYPE_READ): { aclMask = IPentahoAclEntry.PERM_EXECUTE; break; } case IAclHolder.ACCESS_TYPE_WRITE: case IAclHolder.ACCESS_TYPE_UPDATE: { aclMask = IPentahoAclEntry.PERM_UPDATE; break; } case IAclHolder.ACCESS_TYPE_DELETE: { aclMask = IPentahoAclEntry.PERM_DELETE; break; } case IAclHolder.ACCESS_TYPE_ADMIN: { aclMask = IPentahoAclEntry.PERM_ADMINISTRATION; break; } default: { aclMask = IPentahoAclEntry.PERM_EXECUTE; break; } } return voter.hasAccess(session, aHolder, aclMask); }
protected String assembleRole(String catalog) { try { final IConnectionUserRoleMapper mondrianUserRoleMapper = PentahoSystem.get(IConnectionUserRoleMapper.class, "Mondrian-UserRoleMapper", null); if (mondrianUserRoleMapper != null) {} final String[] validMondrianRolesForUser = mondrianUserRoleMapper.mapConnectionRoles( PentahoSessionHolder.getSession(), "solution:" + catalog.replaceAll("solution/", "")); if ((validMondrianRolesForUser != null) && (validMondrianRolesForUser.length > 0)) { final StringBuffer buff = new StringBuffer(); for (int i = 0; i < validMondrianRolesForUser.length; i++) { final String aRole = validMondrianRolesForUser[i]; // According to http://mondrian.pentaho.org/documentation/configuration.php // double-comma escapes a comma if (i > 0) { buff.append(","); } buff.append(aRole.replaceAll(",", ",,")); } return buff.toString(); } else { return ""; } } catch (Exception e) { return ""; } }
@Test public void testMetadataImportExport() throws PlatformInitializationException, IOException, PlatformImportException { List<MimeType> mimeTypeList = new ArrayList<MimeType>(); mimeTypeList.add(new MimeType("Metadata", ".xmi")); File metadata = new File("test-res/dsw/testData/metadata.xmi"); RepositoryFile repoMetadataFile = new RepositoryFile.Builder(metadata.getName()).folder(false).hidden(false).build(); MetadataImportHandler metadataImportHandler = new MetadataImportHandler( mimeTypeList, (IPentahoMetadataDomainRepositoryImporter) PentahoSystem.get(IMetadataDomainRepository.class)); RepositoryFileImportBundle bundle1 = new RepositoryFileImportBundle.Builder() .file(repoMetadataFile) .charSet("UTF-8") .input(new FileInputStream(metadata)) .mime(".xmi") .withParam("domain-id", "SalesData") .build(); metadataImportHandler.importFile(bundle1); final Response salesData = new DatasourceResource().doGetDSWFilesAsDownload("SalesData"); Assert.assertEquals(salesData.getStatus(), Response.Status.OK.getStatusCode()); Assert.assertNotNull(salesData.getMetadata()); Assert.assertNotNull(salesData.getMetadata().getFirst("Content-Disposition")); Assert.assertEquals( salesData.getMetadata().getFirst("Content-Disposition").getClass(), String.class); Assert.assertTrue( ((String) salesData.getMetadata().getFirst("Content-Disposition")).endsWith(".xmi\"")); }
/** @return String that represents the file path to a temporary file */ protected String[] createTempFile() { // create temporary file names String solutionDir = "system/tmp/"; // $NON-NLS-1$ String fileNamePrefix = "tmp_chart_"; // $NON-NLS-1$ String extension = ".png"; // $NON-NLS-1$ String fileName = null; String filePathWithoutExtension = null; try { File file = PentahoSystem.getApplicationContext() .createTempFile(getSession(), fileNamePrefix, extension, true); fileName = file.getName(); filePathWithoutExtension = solutionDir + fileName.substring(0, fileName.indexOf('.')); } catch (IOException e) { getLogger() .error( Messages.getInstance() .getErrorString("AbstractChartComponent.ERROR_0001_CANT_CREATE_TEMP_CHART"), e); //$NON-NLS-1$ } String[] value = new String[2]; value[AbstractChartComponent.FILENAME_INDEX] = fileName; value[AbstractChartComponent.FILENAME_WITHOUT_EXTENSION_INDEX] = filePathWithoutExtension; return value; }
public IPentahoResultSet getResultSet(final ReportSpec reportSpec) throws Exception { String jndiName = reportSpec.getReportSpecChoice().getJndiSource(); IPentahoConnection connection = null; if (reportSpec.getIsMDX()) { // did this ever work?? String connectStr = ""; // $NON-NLS-1$ IDBDatasourceService datasourceService = PentahoSystem.getObjectFactory().get(IDBDatasourceService.class, null); String dsName = datasourceService.getDSBoundName(jndiName); if (dsName != null) { connectStr = "dataSource=" + dsName + "; Catalog=mondrian"; // $NON-NLS-1$ //$NON-NLS-2$ } else { error( Messages.getInstance() .getErrorString("MDXBaseComponent.ERROR_0005_INVALID_CONNECTION")); // $NON-NLS-1$ return null; } Properties props = new Properties(); props.setProperty(IPentahoConnection.CONNECTION, connectStr); props.setProperty(IPentahoConnection.PROVIDER, reportSpec.getMondrianCubeDefinitionPath()); connection = PentahoConnectionFactory.getConnection( IPentahoConnection.MDX_DATASOURCE, props, getSession(), this); } else { connection = PentahoConnectionFactory.getConnection( IPentahoConnection.SQL_DATASOURCE, jndiName, getSession(), this); } String query = ReportParameterUtility.setupParametersForActionSequence(reportSpec.getQuery()); query = setupQueryParameters(query); IPentahoResultSet res = connection.executeQuery(query); return res; }
/** * Returns a list of catalogs for the current session. * * <p>The cache is stored in the platform's caches in the region {@link #CATALOG_CACHE_REGION}. It * is also segmented by locale, but we only return the correct sub-region according to the session * passed as a parameter. */ @SuppressWarnings("unchecked") protected synchronized List<IOlapService.Catalog> getCache(IPentahoSession session) { // Create the cache region if necessary. final ICacheManager cacheMgr = PentahoSystem.getCacheManager(session); final Object cacheKey = makeCacheSubRegionKey(getLocale()); final Lock writeLock = cacheLock.writeLock(); try { writeLock.lock(); if (!cacheMgr.cacheEnabled(CATALOG_CACHE_REGION)) { // Create the region. This requires write access. cacheMgr.addCacheRegion(CATALOG_CACHE_REGION); } if (cacheMgr.getFromRegionCache(CATALOG_CACHE_REGION, cacheKey) == null) { // Create the sub-region. This requires write access. cacheMgr.putInRegionCache( CATALOG_CACHE_REGION, cacheKey, new ArrayList<IOlapService.Catalog>()); } return (List<IOlapService.Catalog>) cacheMgr.getFromRegionCache(CATALOG_CACHE_REGION, cacheKey); } finally { writeLock.unlock(); } }
protected void validateEtcReadAccess(String path) { IAuthorizationPolicy policy = PentahoSystem.get(IAuthorizationPolicy.class); boolean isAdmin = policy.isAllowed(AdministerSecurityAction.NAME); if (!isAdmin && path.startsWith("/etc")) { throw new RuntimeException("This user is not allowed to access the ETC folder in JCR."); } }
@Override public void setFullyQualifiedServerUrl(String fullyQualifiedServerUrl) { logger.info("Fully Qualified Server URL set to " + fullyQualifiedServerUrl); super.setFullyQualifiedServerUrl(fullyQualifiedServerUrl); // have to set the application context now, so the FQSURL will be available to clients // without having to run #start() PentahoSystem.setApplicationContext(createApplicationContext()); }
public AbstractJcrBackedRoleBindingDao() { cacheManager = PentahoSystem.getCacheManager(null); if (!cacheManager.cacheEnabled(LOGICAL_ROLE_BINDINGS_REGION)) { cacheManager.addCacheRegion(LOGICAL_ROLE_BINDINGS_REGION); } }
/** No-arg constructor for when in Pentaho BI Server. */ public DefaultUnifiedRepositoryWebService() { super(); // repo = new MockUnifiedRepository(); repo = PentahoSystem.get(IUnifiedRepository.class); if (repo == null) { throw new IllegalStateException(); } }
/** * @param aFile * @return a boolean that indicates if this file can have ACLS placed on it. */ public static boolean canHaveACLS(final ISolutionFile aFile) { if (aFile.isDirectory()) { // All Directories can have ACLS return true; } // Otherwise anything in the PentahoSystem extension list. return PentahoSystem.getACLFileExtensionList().contains(aFile.getExtension()); }
public InputStream getInputStream() throws Exception { IUnifiedRepository repository = PentahoSystem.get(IUnifiedRepository.class); RepositoryFile repositoryFile = repository.getFile(inputFilePath); if ((repositoryFile == null) || repositoryFile.isFolder()) { throw new FileNotFoundException(); } return new RepositoryFileInputStream(repositoryFile); }