use of org.pentaho.platform.api.engine.IPluginResourceLoader in project pentaho-platform by pentaho.
the class PentahoSystemPluginManager method getStaticResource.
@Override
public InputStream getStaticResource(String path) {
for (IPlatformPlugin plugin : PentahoSystem.getAll(IPlatformPlugin.class)) {
Map<String, String> resourceMap = plugin.getStaticResourceMap();
for (String url : resourceMap.keySet()) {
if (isRequested(url, path)) {
IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null);
ClassLoader classLoader = PentahoSystem.get(ClassLoader.class, null, Collections.singletonMap(PLUGIN_ID, plugin.getId()));
String resourcePath = path.replace(url, resourceMap.get(url));
return resLoader.getResourceAsStream(classLoader, resourcePath);
}
}
}
return null;
}
use of org.pentaho.platform.api.engine.IPluginResourceLoader in project pdi-platform-plugin by pentaho.
the class ParameterUIContentGenerator method createContent.
@Override
public void createContent(OutputStream outputStream) throws Exception {
IPluginResourceLoader resourceLoader = PentahoSystem.get(IPluginResourceLoader.class);
IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class);
ClassLoader classLoader = pluginManager.getClassLoader(pluginId);
String filePath = !viewerFilePath.startsWith("/") ? "/" + viewerFilePath : viewerFilePath;
String viewer = IOUtils.toString(resourceLoader.getResourceAsStream(classLoader, filePath), LocaleHelper.getSystemEncoding());
viewer = doResourceReplacement(viewer);
InputStream is = IOUtils.toInputStream(viewer, LocaleHelper.getSystemEncoding());
IOUtils.copy(is, outputStream);
outputStream.flush();
}
use of org.pentaho.platform.api.engine.IPluginResourceLoader in project data-access by pentaho.
the class AgileMartDatasourceLifecycleManager method getInstance.
public static AgileMartDatasourceLifecycleManager getInstance() {
if (instance == null) {
TransactionTemplate txnTemplate = PentahoSystem.get(TransactionTemplate.class, "jcrTransactionTemplate", PentahoSessionHolder.getSession());
JcrTemplate adminJcrTemplate = PentahoSystem.get(JcrTemplate.class, "adminJcrTemplate", PentahoSessionHolder.getSession());
IPathConversionHelper pathConversionHelper = PentahoSystem.get(IPathConversionHelper.class, "pathConversionHelper", PentahoSessionHolder.getSession());
IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, PentahoSessionHolder.getSession());
IDatasourceMgmtService datasourceMgmtService = PentahoSystem.get(IDatasourceMgmtService.class, PentahoSessionHolder.getSession());
instance = new AgileMartDatasourceLifecycleManager(txnTemplate, adminJcrTemplate, pathConversionHelper, datasourceMgmtService, resLoader);
}
return instance;
}
use of org.pentaho.platform.api.engine.IPluginResourceLoader in project data-access by pentaho.
the class DataAccessLifecycleListener method ready.
@Override
public void ready() throws PluginLifecycleException {
// the platform is booted, spring initialized, all plugins init and loaded
boolean enableAgilemartDatasource = false;
try {
IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null);
enableAgilemartDatasource = Boolean.parseBoolean(resLoader.getPluginSetting(DataAccessLifecycleListener.class, ENABLE_AGILEMART_DATASOURCE, "false"));
} catch (Throwable t) {
log.warn(t.getMessage(), t);
}
if (enableAgilemartDatasource) {
try {
SecurityHelper.getInstance().runAsSystem(new Callable<Void>() {
public Void call() throws Exception {
AgileMartDatasourceLifecycleManager.getInstance().startup();
return null;
}
});
} catch (Exception e) {
log.warn(e.getMessage(), e);
}
DelegatingBackingRepositoryLifecycleManager manager = PentahoSystem.get(DelegatingBackingRepositoryLifecycleManager.class, "backingRepositoryLifecycleManager", null);
manager.addLifeCycleManager(AgileMartDatasourceLifecycleManager.getInstance());
}
}
use of org.pentaho.platform.api.engine.IPluginResourceLoader in project data-access by pentaho.
the class SimpleDataAccessViewPermissionHandler method getPermittedRoleList.
public List<String> getPermittedRoleList(IPentahoSession session) {
List<String> roleList = new ArrayList<String>();
Authentication auth = SecurityHelper.getInstance().getAuthentication(session, true);
IPluginResourceLoader resLoader = PentahoSystem.get(IPluginResourceLoader.class, null);
String roles = null;
try {
// $NON-NLS-1$
roles = resLoader.getPluginSetting(getClass(), "settings/data-access-view-roles");
} catch (Exception e) {
logger.debug("Error getting plugin setting", e);
}
if (roles != null && roles.length() > 0) {
// $NON-NLS-1$
String[] roleArr = roles.split(",");
for (String role : roleArr) {
if (role != null && role.trim().length() > 0) {
roleList.add(role);
}
}
}
return roleList;
}
Aggregations