ICdeEnvironment environment ) {
if ( StringUtils.isEmpty( resource ) ) {
return null;
}
IContentAccessFactory factory = environment.getContentAccessFactory();
String systemDir = environment.getSystemDir() + "/";
String repoDir = environment.getPluginRepositoryDir() + "/";
resource = StringUtils.strip( resource, "/" );
if ( resource.regionMatches( true, 0, systemDir, 0, systemDir.length() ) ) {
resource = resource.replaceFirst( systemDir, "" );
String pluginId = environment.getPluginId() + "/";
// system dir - this plugin
if ( resource.regionMatches( true, 0, pluginId, 0, pluginId.length() ) ) {
resource = resource.replaceFirst( pluginId, "" );
return factory.getPluginSystemReader( basePath ).fetchFile( resource );
} else {
// system dir - other plugin
pluginId = resource.substring( 0, resource.indexOf( "/" ) );
resource = resource.replaceFirst( pluginId, "" );
return factory.getOtherPluginSystemReader( pluginId, basePath ).fetchFile( resource );
}
} else if ( resource.regionMatches( true, 0, repoDir, 0, repoDir.length() ) ) {
// plugin repository dir
resource = resource.replaceFirst( repoDir, "" );
return factory.getPluginRepositoryReader( basePath ).fetchFile( resource );
} else {
// one of two: already trimmed system resource (ex: 'resources/templates/1-empty-structure.cdfde')
// or a user solution resource (ex: 'plugin-samples/pentaho-cdf-dd/styles/my-style.css')
if ( factory.getPluginSystemReader( basePath ).fileExists( resource ) ) {
return factory.getPluginSystemReader( basePath ).fetchFile( resource );
} else if ( factory.getUserContentAccess( basePath ).fileExists( resource ) ) {
// user solution dir
return factory.getUserContentAccess( basePath ).fetchFile( resource );
}
}
return null;
}