public static final List<String> getCanonicalPaths(List<File> files) { List<String> paths = new ArrayList<String>(); for (File file : files) { String path = getCanonicalPath(file); paths.add(path); } return paths; }
public static final void addIdentityFile(List<String> args, File identityFile) { if (identityFile != null) { String path = LocationUtils.getCanonicalPath(identityFile); logger.debug("Private key=[{}]", path); args.add("-i"); args.add(path); } }
public static final void addIdentityFile(List<String> args, File identityFile) { if (identityFile != null) { String path = LocationUtils.getCanonicalPath(identityFile); logger.debug("Private key=[{}]", path); args.add("-i"); args.add(path); } }
public static String getRelativePath(File dir, File file) { String dirPath = LocationUtils.getCanonicalPath(dir); String filePath = LocationUtils.getCanonicalPath(file); if (!StringUtils.contains(filePath, dirPath)) { throw new IllegalArgumentException(file + " does not reside under " + dir); } return StringUtils.remove(filePath, dirPath); }
public static List<File> getFullPaths(File dir, List<String> relativePaths) { List<File> files = new ArrayList<File>(); for (String relativePath : relativePaths) { File file = new File(dir, relativePath); File canonical = new File(LocationUtils.getCanonicalPath(file)); files.add(canonical); } return files; }
/** * Get the contents of <code>file</code> as a list of <code>String's</code> one entry per line using the platform default encoding */ public static final List<String> readLines(File file) { return readLines(getCanonicalPath(file)); }
/** * Get the MD5 checksum of the file */ public static String getMD5Checksum(File file) { return getChecksum(getCanonicalPath(file), MD5); }
/** * Return a new <code>Properties</code> object loaded from <code>file</code>. */ public static final Properties loadSilently(File file) { return loadSilently(LocationUtils.getCanonicalPath(file)); }
/** * Return a new <code>Properties</code> object loaded from <code>file</code> where the properties are stored in Rice XML style syntax * * @deprecated use loadRiceProps() instead */ @Deprecated public static final Properties loadRiceProperties(File file) { return loadRiceProperties(LocationUtils.getCanonicalPath(file)); }
protected static String getCanonicalLocation(String location) { if (LocationUtils.isExistingFile(location)) { return LocationUtils.getCanonicalPath(new File(location)); } else { return location; } }
/** * Get the contents of <code>file</code> as a <code>String</code> using the specified character encoding. */ public static final String toString(File file, String encoding) { return toString(getCanonicalPath(file), encoding); }
protected JSch getJSch() throws JSchException { JSch jsch = getJSch(privateKeys, privateKeyStrings); if (strictHostKeyChecking && knownHosts.exists()) { String path = LocationUtils.getCanonicalPath(knownHosts); jsch.setKnownHosts(path); } return jsch; }
@Override public void execute() { logger.info("Copying [{}] -> [{}]", locationListing, LocationUtils.getCanonicalPath(directory)); List<String> locations = LocationUtils.getLocations(locationListing); List<File> files = getFiles(locations); LocationUtils.copyLocationsToFiles(locations, files); logger.info("Copied {} files", locations.size()); }
protected JSch getJSch() throws JSchException { List<File> uniquePrivateKeyFiles = getUniquePrivateKeyFiles(); logger.debug("Located {} private keys on the file system", uniquePrivateKeyFiles.size()); JSch jsch = getJSch(uniquePrivateKeyFiles, privateKeyStrings); if (strictHostKeyChecking && knownHosts != null) { String path = LocationUtils.getCanonicalPath(knownHosts); jsch.setKnownHosts(path); } return jsch; }
public static void doProperties(org.kuali.common.util.metainf.MetaInfContext context, List<MetaInfResource> resources) { logger.debug("doProperties()"); Properties properties = getProperties(context, resources); File propertiesFile = new File(LocationUtils.getCanonicalPath(context.getOutputFile()) + ".properties"); PropertyUtils.store(properties, propertiesFile, Encodings.UTF8); }
public static void doLocations(org.kuali.common.util.metainf.MetaInfContext context, List<MetaInfResource> resources) throws IOException { List<String> locations = getLocations(resources); if (context.isSort()) { Collections.sort(locations); } String path1 = LocationUtils.getCanonicalPath(context.getBaseDir()); String path2 = LocationUtils.getCanonicalPath(context.getOutputFile()); String path = StringUtils.remove(path2, path1); logger.info("Creating [" + path + "] - {} resources", locations.size()); FileUtils.writeLines(context.getOutputFile(), locations); }
protected void beforeDump(MySqlDumpContext context) { String username = StringUtils.trimToEmpty(context.getUsername()); String hostname = StringUtils.trimToEmpty(context.getHostname()); int port = context.getPort(); String database = context.getDatabase(); String path = LocationUtils.getCanonicalPath(context.getOutputFile()); Object[] args = { username, hostname, port, database, path }; logger.info("Dumping [{}@{}:{}/{}] -> [{}]", args); }
@Override public <T> T getObject(File file, Class<T> type) { Assert.exists(file); Assert.noNulls(type); return getObject(LocationUtils.getCanonicalPath(file), type); }
/** * Return the relative path to <code>file</code> from <code>parentDir</code>. <code>parentDir</code> is optional and can be <code>null</code>. If <code>parentDir</code> is not * supplied (or is not a parent directory to <code>file</code> the canonical path to <code>file</code> is returned. */ public static String getRelativePathQuietly(File parentDir, File file) { Assert.notNull(file, "file is null"); if (isParent(parentDir, file)) { return getRelativePath(parentDir, file); } else { return LocationUtils.getCanonicalPath(file); } }
@Override public String getObject() { Assert.notNull(localRepositoryDir); Assert.hasText(getGroupId()); Assert.hasText(getArtifactId()); Assert.hasText(getVersion()); Assert.hasText(getType()); File file = org.kuali.common.util.RepositoryUtils.getFile(localRepositoryDir, this); validate(file); return LocationUtils.getCanonicalPath(file); }