Exemple #1
0
 private static void getGitDirsInParents(File file, Map<IPath, File> gitDirs) {
   int levelUp = 0;
   File workspaceRoot = Activator.getDefault().getPlatformLocation().toFile();
   while (file != null && !file.getAbsolutePath().equals(workspaceRoot.getAbsolutePath())) {
     if (file.exists()) {
       if (RepositoryCache.FileKey.isGitRepository(file, FS.DETECTED)) {
         gitDirs.put(getPathForLevelUp(levelUp), file);
         return;
       } else if (RepositoryCache.FileKey.isGitRepository(
           new File(file, Constants.DOT_GIT), FS.DETECTED)) {
         gitDirs.put(getPathForLevelUp(levelUp), new File(file, Constants.DOT_GIT));
         return;
       }
     }
     file = file.getParentFile();
     levelUp++;
   }
   return;
 }
  /**
   * Returns the root location where user data files for the given user are stored. In some
   * configurations this location might be shared across users, so clients will need to ensure
   * resulting files are segmented appropriately by user.
   */
  public static IFileStore getUserHome(String userId) {
    URI platformLocationURI = Activator.getDefault().getRootLocationURI();
    IFileStore root = null;
    try {
      root = EFS.getStore(platformLocationURI);
    } catch (CoreException e) {
      // this is fatal, we can't access the platform instance location
      throw new Error("Failed to access platform instance location", e); // $NON-NLS-1$
    }

    // consult layout preference
    String layout =
        PreferenceHelper.getString(ServerConstants.CONFIG_FILE_LAYOUT, "flat")
            .toLowerCase(); //$NON-NLS-1$

    if ("usertree".equals(layout) && userId != null) { // $NON-NLS-1$
      // the user-tree layout organises projects by the user who created it
      String userPrefix = userId.substring(0, Math.min(2, userId.length()));
      return root.getChild(userPrefix).getChild(userId);
    }
    // default layout is a flat list of projects at the root
    return root;
  }
 /**
  * Returns the currently configured {@link IMetaStore} for this server.
  *
  * @throws IllegalStateException if the server is not properly configured to have an @link {@link
  *     IMetaStore}.
  */
 public static IMetaStore getMetaStore() {
   return Activator.getDefault().getMetastore();
 }