// @Exposed(accessLevel = AccessLevel.PUBLIC) // TODO: this has to go into cda-pentaho or needs to be refactored @Deprecated public void editFile( final OutputStream out, final String path, final String solution, final String file, IResponseTypeHandler response) throws Exception { IRepositoryAccess repository = CdaEngine.getEnvironment().getRepositoryAccess(); // Check if the file exists and we have permissions to write to it String relativePath = getRelativePath(path, solution, file); if (repository.canWrite(relativePath)) { boolean hasCde = repository.resourceExists("system/pentaho-cdf-dd"); final String editorPath = "system/" + PLUGIN_NAME + (hasCde ? EXT_EDITOR_SOURCE : EDITOR_SOURCE); writeOut(out, getResourceAsString(editorPath, FileAccess.EXECUTE, response)); } else { setResponseHeaders("text/plain"); out.write("Access Denied".getBytes()); } }
public String getResourceAsString(final String path, final HashMap<String, String> tokens) throws IOException { // Read file IRepositoryAccess repository = CdaEngine.getEnvironment().getRepositoryAccess(); String resourceContents = StringUtils.EMPTY; if (repository.resourceExists(path)) { InputStream in = null; try { in = repository.getResourceInputStream(path, FileAccess.READ); resourceContents = IOUtils.toString(in); } finally { IOUtils.closeQuietly(in); } } // Make replacement of tokens if (tokens != null) { for (final String key : tokens.keySet()) { resourceContents = StringUtils.replace(resourceContents, key, tokens.get(key)); } } return resourceContents; }