public String getIdentifier(final LogicalPath logicalPath, final String relativePath) { Assert.notNull(logicalPath, "Path required"); Assert.notNull(relativePath, "Relative path cannot be null, although it can be empty"); String initialPath = FileUtils.getCanonicalPath(getPath(logicalPath)); initialPath = FileUtils.ensureTrailingSeparator(initialPath); return initialPath + FileUtils.removeLeadingAndTrailingSeparators(relativePath); }
/** * Returns the canonical path of the given {@link Path} within this module, plus a trailing * separator if found * * @param path the path for which to get the canonical location (required) * @return <code>null</code> if this module has no such path */ public String getPathLocation(final Path path) { final PhysicalPath modulePath = getPhysicalPath(path); if (modulePath == null) { return null; } return FileUtils.ensureTrailingSeparator(modulePath.getLocationPath()); }
public void setup() { if (hasDotGit()) { LOGGER.info("Git is already configured"); return; } if (person == null) { person = new PersonIdent("Roo Git Add-On", "*****@*****.**"); } try { final String repositoryPath = pathResolver.getFocusedIdentifier(Path.ROOT, Constants.DOT_GIT); final Repository repository = new FileRepositoryBuilder().readEnvironment().setGitDir(new File(repositoryPath)).build(); repository.create(); } catch (final Exception e) { throw new IllegalStateException("Could not initialize Git repository", e); } setConfig("user", "name", person.getName()); setConfig("user", "email", person.getEmailAddress()); setConfig("remote \"origin\"", "fetch", "+refs/heads/*:refs/remotes/origin/*"); setConfig("branch \"master\"", "remote", "origin"); setConfig("branch \"master\"", "merge", "refs/heads/master"); final String gitIgnore = pathResolver.getFocusedIdentifier(Path.ROOT, Constants.GITIGNORE_FILENAME); if (!fileManager.exists(gitIgnore)) { InputStream inputStream = null; OutputStream outputStream = null; try { inputStream = FileUtils.getInputStream(getClass(), "gitignore-template"); outputStream = fileManager.createFile(gitIgnore).getOutputStream(); IOUtils.copy(inputStream, outputStream); } catch (final IOException e) { throw new IllegalStateException( "Could not install " + Constants.GITIGNORE_FILENAME + " file in project", e); } finally { IOUtils.closeQuietly(inputStream); IOUtils.closeQuietly(outputStream); } } }
/** * Indicates whether the given canonical path matches the given Ant-style pattern * * @param antPattern the pattern to check against (can't be blank) * @param canonicalPath the path to check (can't be blank) * @return see above * @deprecated use {@link FileUtils#matchesAntPath(String, String)} instead */ @Deprecated public static boolean matchesAntPath(final String antPattern, final String canonicalPath) { return FileUtils.matchesAntPath(antPattern, canonicalPath); }
/** * Each {@link FileDetails} is known by its canonical file name, which is also the format used for * Ant path matching etc. This method provides the canonical file name without forcing the user to * deal with the exceptions that would arise from using {@link File} directly. * * @return the canonical path. */ public String getCanonicalPath() { return FileUtils.getCanonicalPath(file); }
/** * Returns the canonical path of the given {@link File}. * * @param file the file for which to find the canonical path (required) * @return the canonical path * @deprecated use {@link FileUtils#getCanonicalPath(File)} instead */ @Deprecated public static String getCanonicalPath(final File file) { return FileUtils.getCanonicalPath(file); }
/** * Indicates whether this file's canonical path matches the given Ant-style pattern. * * <p>The presented path must be in Ant syntax. It should include a full prefix that is consistent * with the {@link #getCanonicalPath()} method. * * @param antPattern the pattern to check this file against (cannot be blank) * @return whether the path matches or not */ public boolean matchesAntPath(final String antPattern) { return FileUtils.matchesAntPath(antPattern, getCanonicalPath()); }
/** * Indicates whether the presented canonical path is a child of the current {@link FileDetails} * instance. Put differently, returning true indicates the current instance is a parent directory * of the presented possibleChildCanonicalPath. * * <p>This method will return true if the presented child is a child of the current instance, or * if the presented child is identical to the current instance. * * @param possibleChildCanonicalPath to evaluate (required) * @return true if the presented possible child is indeed a child of the current instance */ public boolean isParentOf(final String possibleChildCanonicalPath) { Assert.hasText(possibleChildCanonicalPath, "Possible child to evaluate is required"); return FileUtils.ensureTrailingSeparator(possibleChildCanonicalPath) .startsWith(FileUtils.ensureTrailingSeparator(getCanonicalPath())); }
public InputStream getMessageBundle() { return FileUtils.getInputStream(getClass(), "messages_it.properties"); }
public InputStream getFlagGraphic() { return FileUtils.getInputStream(getClass(), "it.png"); }