public static void isExistingDir(File dir) { isExistingDir(dir, "[" + dir + "] is not an existing directory"); }
/** * @deprecated */ @Deprecated protected List<File> scanFileSystem(MetaInfContext context) { File dir = context.getScanDir(); Assert.isExistingDir(dir); logger.debug("Examining [" + LocationUtils.getCanonicalPath(dir) + "]"); List<String> includes = context.getIncludes(); List<String> excludes = context.getExcludes(); logger.debug("Patterns - {}", LoggerUtils.getLogMsg(includes, excludes)); org.kuali.common.util.SimpleScanner scanner = new org.kuali.common.util.SimpleScanner(dir, includes, excludes); return scanner.getFiles(); }
/** * Get a URL string that can be used to address <code>file</code>. This is usually a Spring pseudo-url classpath location, eg - [<code>classpath:foo/bar.txt</code>] * * @param resourceFile * The file to get a location url for. eg - [<code>/x/y/z/src/main/resources/foo/bar.txt</code>] * @param context * Context information for generating a relative location url. eg - [<code>/x/y/z/src/main/resources</code>] and [<code>classpath:</code>]. * * @return A string representing a fully qualified location URL for <code>file</code>. eg - [<code>classpath:foo/bar.txt</code>] */ protected String getRelativeLocationURL(CanonicalFile resourceFile, MetaInfContext context) { // Extract the parent directory CanonicalFile parent = new CanonicalFile(context.getRelativeDir()); // Make sure it is an existing directory Assert.isExistingDir(parent); // Get a string representing the path to the parent dir String parentPath = parent.getPath(); // Get a string representing the path to the resource file String resourcePath = resourceFile.getPath(); // Make sure the resource file resides underneath the parent dir Assert.isTrue(StringUtils.contains(resourcePath, parentPath), "[" + resourcePath + "] does not contain [" + parentPath + "]"); // Extract the portion of the path to the resource file that is relative to the parent dir int relativePos = parentPath.length() + 1; String relativePath = StringUtils.substring(resourcePath, relativePos); // Prepend the prefix and return return context.getUrlPrefix() + relativePath; }
@Override public void execute() { if (skip) { return; } // Make sure we are configured correctly Assert.notNull(srcDir, "srcDir is null"); Assert.notNull(dstDir, "dstDir is null"); // Source directory has to exist already. We'll create destination directory if necessary Assert.isExistingDir(srcDir, "srcDir is not an existing directory"); try { // Null safe conversion of the lists to CSV String includesCSV = StringUtils.trimToNull(CollectionUtils.getCSV(includes)); String excludesCSV = StringUtils.trimToNull(CollectionUtils.getCSV(excludes)); // Make sure we can create the destination directory FileUtils.forceMkdir(dstDir); // Show what we are up to logCopy(); // Copy files from src to dst FileUtils.copyDirectory(srcDir, dstDir, includesCSV, excludesCSV); } catch (IOException e) { throw new IllegalStateException("Unexpected IO error", e); } }
Assert.isExistingDir(request.getSrcDir(), "srcDir is not an existing directory"); Assert.isExistingDir(request.getScmDir(), "scmDir is not an existing directory");