/** * 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); }
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); }
/** * Constructor * * @param logicalPath (required) * @param location the physical location of this path (required) */ public PhysicalPath(final LogicalPath logicalPath, final File location) { Validate.notNull(logicalPath, "Module path required"); Validate.notNull(location, "Location required"); canonicalPath = FileUtils.getCanonicalPath(location); this.logicalPath = logicalPath; this.location = location; }
public String getMeaningfulName(final File file) { Validate.notNull(file, "File required"); return pathResolver.getFriendlyName(FileUtils.getCanonicalPath(file)); } }
public String getRoot(final LogicalPath logicalPath) { Validate.notNull(logicalPath, "Path required"); final PhysicalPath pathInfo = rootModulePaths.get(logicalPath.getPath()); Validate.notNull(pathInfo, "Unable to determine information for path '" + logicalPath + "'"); final File root = pathInfo.getLocation(); return FileUtils.getCanonicalPath(root); }
protected void activate(final ComponentContext cContext) { context = cContext.getBundleContext(); final File projectDirectory = new File(StringUtils.defaultIfEmpty(OSGiUtils.getRooWorkingDirectory(cContext), FileUtils.CURRENT_DIRECTORY)); projectRootDirectory = FileUtils.getCanonicalPath(projectDirectory); }
protected void activate(final ComponentContext context) { final File projectDirectory = new File(StringUtils.defaultIfEmpty(OSGiUtils.getRooWorkingDirectory(context), CURRENT_DIRECTORY)); rootPath = FileUtils.getCanonicalPath(projectDirectory); }
public String getIdentifier(final LogicalPath logicalPath, final String relativePath) { Validate.notNull(logicalPath, "Path required"); Validate.notNull(relativePath, "Relative path cannot be null, although it can be empty"); String initialPath = FileUtils.getCanonicalPath(getPath(logicalPath)); initialPath = FileUtils.ensureTrailingSeparator(initialPath); return initialPath + StringUtils.strip(relativePath, File.separator); }
private String getProposedJavaType(final String fileCanonicalPath) { Validate.notBlank(fileCanonicalPath, "File canonical path required"); // Determine the JavaType for this file String relativePath = ""; final Pom moduleForFileIdentifier = getProjectOperations().getModuleForFileIdentifier(fileCanonicalPath); if (moduleForFileIdentifier == null) { return relativePath; } for (final PhysicalPath physicalPath : moduleForFileIdentifier.getPhysicalPaths()) { final String moduleCanonicalPath = FileUtils.ensureTrailingSeparator(FileUtils.getCanonicalPath(physicalPath.getLocation())); if (fileCanonicalPath.startsWith(moduleCanonicalPath)) { relativePath = File.separator + StringUtils.replace(fileCanonicalPath, moduleCanonicalPath, "", 1); break; } } Validate.notBlank(relativePath, "Could not determine compilation unit name for file '%s'", fileCanonicalPath); Validate.isTrue(relativePath.startsWith(File.separator), "Relative path unexpectedly dropped the '%s' prefix (received '%s' from '%s')", File.separator, relativePath, fileCanonicalPath); relativePath = relativePath.substring(1); Validate.isTrue(relativePath.endsWith(".java"), "The relative path unexpectedly dropped the .java extension for file '%s'", fileCanonicalPath); relativePath = relativePath.substring(0, relativePath.lastIndexOf(".java")); return relativePath.replace(File.separatorChar, '.'); }
public String backup() { Validate.isTrue(isBackupPossible(), "Project metadata unavailable"); // For Windows, make a date format that can legally form part of a // filename (ROO-277) final String pattern = File.separatorChar == '\\' ? "yyyy-MM-dd_HH.mm.ss" : "yyyy-MM-dd_HH:mm:ss"; final DateFormat df = new SimpleDateFormat(pattern); final long start = System.nanoTime(); ZipOutputStream zos = null; try { final File projectDirectory = new File(getProjectOperations().getPathResolver().getFocusedIdentifier(Path.ROOT, ".")); final MutableFile file = getFileManager().createFile( FileUtils.getCanonicalPath(new File(projectDirectory, getProjectOperations() .getFocusedProjectName() + "_" + df.format(new Date()) + ".zip"))); zos = new ZipOutputStream(file.getOutputStream()); zip(projectDirectory, projectDirectory, zos); } catch (final FileNotFoundException e) { LOGGER.fine("Could not determine project directory"); } catch (final IOException e) { LOGGER.fine("Could not create backup archive"); } finally { IOUtils.closeQuietly(zos); } final long milliseconds = (System.nanoTime() - start) / 1000000; return "Backup completed in " + milliseconds + " ms"; }
/** * 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); }
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); }
private String getProposedJavaType(final String fileCanonicalPath) { Validate.notBlank(fileCanonicalPath, "File canonical path required"); // Determine the JavaType for this file String relativePath = ""; final Pom moduleForFileIdentifier = getProjectOperations().getModuleForFileIdentifier(fileCanonicalPath); if (moduleForFileIdentifier == null) { return relativePath; } for (final PhysicalPath physicalPath : moduleForFileIdentifier.getPhysicalPaths()) { final String moduleCanonicalPath = FileUtils.ensureTrailingSeparator(FileUtils.getCanonicalPath(physicalPath.getLocation())); if (fileCanonicalPath.startsWith(moduleCanonicalPath)) { relativePath = File.separator + StringUtils.replace(fileCanonicalPath, moduleCanonicalPath, "", 1); break; } } Validate.notBlank(relativePath, "Could not determine compilation unit name for file '%s'", fileCanonicalPath); Validate.isTrue(relativePath.startsWith(File.separator), "Relative path unexpectedly dropped the '%s' prefix (received '%s' from '%s')", File.separator, relativePath, fileCanonicalPath); relativePath = relativePath.substring(1); Validate.isTrue(relativePath.endsWith(".java"), "The relative path unexpectedly dropped the .java extension for file '%s'", fileCanonicalPath); relativePath = relativePath.substring(0, relativePath.lastIndexOf(".java")); return relativePath.replace(File.separatorChar, '.'); }