/*
(non-Javadoc)

@see com.github.maven_nar.NarFileLayout#getNarInfoFile(java.lang.String,
java.lang.String,
java.lang.String)
331541
@Override
  public String getNarInfoFile(final String groupId, final String artifactId, final String type) {
    return "META-INF/nar/" + groupId + "/" + artifactId + "/" + NarInfo.NAR_PROPERTIES;
  }
976345
@Override
    public String getFilename() {
        try {
            if (hasDescriptionProperty(FILENAME)) {
                return getDescriptionProperty(FILENAME).getString().replace(FIELD_DELIMITER + XSDstring.getURI(), "");
            }
            return node.getName();
        } catch (final RepositoryException e) {
            throw new RepositoryRuntimeException(e);
        }
    }
218779
public static String getImageFilename(String strFilename, String strSubDirectory)
   {
       if ((strFilename == null) || (strFilename.length() == 0))
           return null;    // A null will tell a JButton not to load an image
       if (strFilename.indexOf('.') == -1)
           strFilename += ".gif";
       strFilename = Util.getFullFilename(strFilename, strSubDirectory, Constant.IMAGE_LOCATION, true);
       return strFilename;
   }
737351
@Override
    public String getPath() {
        try {
            final String path = node.getPath();
            return path.endsWith("/" + JCR_CONTENT) ? path.substring(0, path.length() - JCR_CONTENT.length() - 1)
                : path;
        } catch (final RepositoryException e) {
            throw new RepositoryRuntimeException(e);
        }
    }
257560
NameWithINode getSourceFile(String parity, String prefix) throws IOException {
    if (isHarFile(parity)) {
      return null;
    }
    // remove the prefix
    String src = parity.substring(prefix.length());
    byte[][] components = INodeDirectory.getPathComponents(src);
    INode inode = namesystem.dir.getINode(components);
    return new NameWithINode(src, inode);
  }
938116
String getPathName(boolean url) {
        if (pathName == null || pathName.isEmpty()) {
            VirtualFile[] path = getParentFiles();
            final StringBuilder builder = new StringBuilder(path.length * 30 + 50);
            for (int i = path.length - 1; i > -1; i--) {
                final VirtualFile parent = path[i].parent;
                if (parent == null) {
                    builder.append(path[i].name);
                } else {
                    if (parent.parent != null) {
                        builder.append('/');
                    }
                    builder.append(path[i].name);
                }
            }
            pathName = builder.toString();
        }
        // Perhaps this should be cached to avoid the fs stat call?
        return (url && isDirectory()) ? pathName.concat("/") : pathName;
    }
970724
static String getVersionForFile(final File file)  {
        try {
            final PluginMeta pluginMeta = loadMeta(file);
            return pluginMeta.getVersion();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
1312380
public JBBPNamedFieldInfo findFieldForPath(final String fieldPath) {

    JBBPNamedFieldInfo result = null;

    for (final JBBPNamedFieldInfo f : this.namedFieldData) {
      if (f.getFieldPath().equals(fieldPath)) {
        result = f;
        break;
      }
    }
    return result;
  }
1041055
@Override
  public FileInfo generateClientFileInfo(String path) {
    FileInfo ret = new FileInfo();
    ret.setFileId(getId());
    ret.setName(getName());
    ret.setPath(path);
    ret.setBlockSizeBytes(0);
    ret.setCreationTimeMs(getCreationTimeMs());
    ret.setCompleted(true);
    ret.setFolder(isDirectory());
    ret.setPinned(isPinned());
    ret.setCacheable(false);
    ret.setPersisted(isPersisted());
    ret.setLastModificationTimeMs(getLastModificationTimeMs());
    ret.setTtl(mTtl);
    ret.setTtlAction(mTtlAction);
    ret.setOwner(getOwner());
    ret.setGroup(getGroup());
    ret.setMode(getMode());
    ret.setPersistenceState(getPersistenceState().toString());
    ret.setMountPoint(isMountPoint());
    ret.setUfsFingerprint(Constants.INVALID_UFS_FINGERPRINT);
    ret.setAcl(mAcl);
    ret.setDefaultAcl(mDefaultAcl);
    return ret;
  }
929660
public FileStatus getFileInfo(String src)  throws IOException {
    myMetrics.numFileInfoOps.inc();
    return namesystem.getFileInfo(src);
  }
1297103
private static int parsePlanFile()
  {
    int ret = -1;
    try {
      FileInputStream fis = new FileInputStream(planfilePath_);
      DataInputStream dis = new DataInputStream(fis);
      BufferedReader br = new BufferedReader(new InputStreamReader(dis));

      if (prefix_.isEmpty()) {
        prefix_ = "PATH_PREFIX_";
      }

      String line;
      while ((line = br.readLine()) != null) {
        if (line.length() == 0 || line.startsWith("#")) {
          continue;
        }
        if (line.startsWith("type=")) {
          type_ = line.substring(5);
          continue;
        }
        if (line.startsWith("levels=")) {
          levels_ = Integer.parseInt(line.substring(7));
          continue;
        }
        if (line.startsWith("inodes=")) {
          inodesPerLevel_ = Integer.parseInt(line.substring(7));
          continue;
        }
        if (line.startsWith("nstat=")) {
          pathsToStat_ = Integer.parseInt(line.substring(6));
          continue;
        }
      }
      dis.close();
      if (levels_ > 0 && !type_.isEmpty() && inodesPerLevel_ > 0 && pathsToStat_ > 0) {
        ret = 0;
      }
    } catch (Exception e) {
      System.out.println("Error: " + e.getMessage());
    }
    return ret;
  }
480202
public PRIndirectReference getRefByName(String name) {
        FieldInformation fi = (FieldInformation)fieldByName.get(name);
        if (fi == null) return null;
        return fi.getRef();
    }
584881
@Override
    public JavaFileObject getOverviewPath() {
        if (overviewpath != null && getFileManager() instanceof StandardJavaFileManager) {
            StandardJavaFileManager fm = (StandardJavaFileManager) getFileManager();
            return fm.getJavaFileObjects(overviewpath).iterator().next();
        }
        return null;
    }
502820
@Override
  public final File
      getBinDirectory(final File baseDir, final String artifactId, final String version, final String aol) {
    final File dir = new File(baseDir, this.fileLayout.getBinDirectory(aol));
    return dir;
  }
687851
public ProjectFileHandler getProjectFile(final int projectId, final int version) {
    log.info(
        String.format("Fetching project file. project ID: %d version: %d", projectId, version));
    // TODO spyne: remove huge hack ! There should not be any special handling for Database Storage.
    if (this.storage instanceof DatabaseStorage) {
      return ((DatabaseStorage) this.storage).get(projectId, version);
    }

    /* Fetch meta data from db */
    final ProjectFileHandler pfh = this.projectLoader.fetchProjectMetaData(projectId, version);

    /* Fetch project file from storage and copy to local file */
    final String resourceId = requireNonNull(pfh.getResourceId(),
        String.format("URI is null. project ID: %d version: %d",
            pfh.getProjectId(), pfh.getVersion()));
    try (InputStream is = this.storage.get(resourceId)) {
      final File file = createTempOutputFile(pfh);

      /* Copy from storage to output stream */
      try (FileOutputStream fos = new FileOutputStream(file)) {
        IOUtils.copy(is, fos);
      }

      /* Validate checksum */
      validateChecksum(file, pfh);

      /* Attach file to handler */
      pfh.setLocalFile(file);

      return pfh;
    } catch (final IOException e) {
      throw new StorageException(e);
    }
  }
109442
protected String resolveJarFile() {
        Class resourceClass = resourceInfo.getResourceClass();
        if (resourceClass == null) return null;
        String classFile = resourceClass.getName().replace(".", "/") + ".class";
        URL classUrl = IOUtils.getResource(classFile);
        String urlProtocol = classUrl.getProtocol();
        if (urlProtocol.equals("jar")) {
            String path = classUrl.getPath();
            return path.substring(0, path.length() - classFile.length() - 1);
        }
        return null;
    }
702103
private static File getWarLocation() {
        URL resource = JettyConsoleBootstrapMainClass.class.getResource("/META-INF/jettyconsole/jettyconsole.properties");
        String file = resource.getFile();
        file = file.substring("file:".length(), file.indexOf("!"));
        try {
            file = URLDecoder.decode(file, "utf-8");
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        return new File(file);
    }