public static String path(String... parts) { return concat(parts); }
private File getElementDirectory(String mediaPackageID, String mediaPackageElementID) { return new File(PathSupport.concat(new String[]{rootDirectory, MEDIAPACKAGE_PATH_PREFIX, mediaPackageID, mediaPackageElementID})); }
PathSupport.concat(new String[]{rootDirectory, COLLECTION_PATH_PREFIX, collectionId})); if (!collectionDir.exists()) { if (!create)
String settings = null; File configFile = new File(PathSupport.concat(new String[] { indexSettingsPath, index, "settings.json" })); if (configFile.isFile()) { try (FileInputStream fis = new FileInputStream(configFile)) { .concat(new String[] { "/elasticsearch/", index, "settings.json" }); try (InputStream is = this.getClass().getResourceAsStream(resourcePath)) { if (is != null) {
String mapping = null; File configFile = new File(PathSupport.concat(new String[] { indexSettingsPath, index, documentType + "-mapping.json" })); if (configFile.isFile()) { .concat(new String[] { "/elasticsearch/", index, documentType + "-mapping.json" }); try (InputStream is = this.getClass().getResourceAsStream(resourcePath)) { if (is != null) {
@GET @Path("config.json") @Produces(MediaType.APPLICATION_JSON) @RestQuery(name = "configJson", description = "Paella configuration", reponses = { @RestResponse(description = "Returns the paella configuration", responseCode = HttpServletResponse.SC_OK) }, returnDescription = "") public String getMyInfo() throws IOException { // Add the current user's organizational information Organization org = securityService.getOrganization(); File configFile = new File(PathSupport.concat(new String[] { paellaConfigFolder, org.getId(), "config.json" })); return FileUtils.readFileToString(configFile, "UTF-8"); } }
/** * Transforms a URI into a workspace File. If the file comes from the working file repository, the path in the * workspace mirrors that of the repository. If the file comes from another source, directories are created for each * segment of the URL. Sub-directories may be created as needed. * * @param uri * the uri * @return the local file representation */ File toWorkspaceFile(URI uri) { // MH-11497: Fix for compatibility with stream security: the query parameters are deleted. // TODO Refactor this class to use the URI class and methods instead of String for handling URIs String uriString = UriBuilder.fromUri(uri).replaceQuery(null).build().toString(); String wfrPrefix = wfr.getBaseUri().toString(); String serverPath = FilenameUtils.getPath(uriString); if (uriString.startsWith(wfrPrefix)) { serverPath = serverPath.substring(wfrPrefix.length()); } else { serverPath = serverPath.replaceAll(":/*", "_"); } String wsDirectoryPath = PathSupport.concat(wsRoot, serverPath); File wsDirectory = new File(wsDirectoryPath); wsDirectory.mkdirs(); String safeFileName = PathSupport.toSafeName(FilenameUtils.getName(uriString)); if (StringUtils.isBlank(safeFileName)) safeFileName = UNKNOWN_FILENAME; return new File(wsDirectory, safeFileName); }
/** * Loads the settings for the elastic search configuration. An initial attempt is made to get the configuration from * <code>${opencast.home}/etc/index/< index >/settings.yml</code>. * * @param index * the index name * @return the elastic search settings * @throws IOException * if the index cannot be created in case it is not there already * @throws SearchIndexException * if the index configuration cannot be found */ protected Settings loadSettings(String index, String indexSettingsPath) throws IOException, SearchIndexException { // Check if a local configuration file is present File configFile = new File(PathSupport.concat(new String[] { indexSettingsPath, index, "settings.yml" })); if (!configFile.isFile()) { throw new SearchIndexException("Settings for search index '" + index + "' not found at " + configFile); } // Finally, try and load the index settings try (FileInputStream fis = new FileInputStream(configFile)) { return Settings.settingsBuilder().loadFromStream(configFile.getName(), fis).build(); } catch (FileNotFoundException e) { throw new IOException("Unable to load elasticsearch settings from " + configFile.getAbsolutePath()); } }
/** * Concatenates the path elements with respect to leading and trailing slashes. * * @param parts * the parts to concat * @return the concatenated path */ public static String concat(String[] parts) { if (parts == null) throw new IllegalArgumentException("Argument parts is null"); if (parts.length == 0) throw new IllegalArgumentException("Array parts is empty"); String path = removeDoubleSeparator(adjustSeparator(parts[0])); for (int i = 1; i < parts.length; i++) { path = concat(path, removeDoubleSeparator(adjustSeparator(parts[i]))); } return path; }
checkPathSafe(collectionId); checkPathSafe(fileName); File f = new File(PathSupport.concat(new String[]{rootDirectory, COLLECTION_PATH_PREFIX, collectionId, PathSupport.toSafeName(fileName)})); logger.debug("Attempting to write a file to {}", f.getAbsolutePath());
if (directory == null) { directory = new File(PathSupport.concat(new String[] { rootDirectory, COLLECTION_PATH_PREFIX, collectionId })); throw new NotFoundException(directory.getAbsolutePath());
} else if (ensureContextProp(cc, STORAGE_DIR_KEY)) { this.wsRoot = PathSupport.concat(cc.getBundleContext().getProperty(STORAGE_DIR_KEY), "workspace"); logger.warn("CONFIG " + WORKSPACE_DIR_KEY + " is missing: falling back to " + this.wsRoot); } else {