Package org.eclipse.core.filesystem

Examples of org.eclipse.core.filesystem.IFileStore


  private String excuteCmd(String type, String cwd, String args) {
    String result = "";
    try {
      IPath path = new Path(cwd).removeFirstSegments(1);
      IFileStore fStore = NewFileServlet.getFileStore(null, path);
      if (fStore == null) {
        result = "Error: This command must be used in an application folder\n";
        return result;
      }
      String cwdPath = fStore.toString();
      //Getting npm command path from the configuration file
      String npmPath = PreferenceHelper.getString("orion.npmPath");
      if (npmPath == null || npmPath.isEmpty()) {
        result = "Error: Npm path is not defined, contact the server administrator.\n";
        return result;
View Full Code Here


        //if this is not a valid URI or scheme try to parse it as file path
        contentURI = new File(location).toURI();
      }
      if (init) {
        project.setContentLocation(contentURI);
        IFileStore child = NewFileServlet.getFileStore(request, project);
        child.mkdir(EFS.NONE, null);
      }
    }
    project.setContentLocation(contentURI);
  }
View Full Code Here

  /**
   * Generates a file system location for newly created project. Creates a new
   * folder in the file system and ensures it is empty.
   */
  private static URI generateProjectLocation(ProjectInfo project, String user) throws CoreException {
    IFileStore projectStore = OrionConfiguration.getMetaStore().getDefaultContentLocation(project);
    if (projectStore.fetchInfo().exists()) {
      //This folder must be empty initially or we risk showing another user's old private data
      projectStore.delete(EFS.NONE, null);
    }
    projectStore.mkdir(EFS.NONE, null);
    return projectStore.toURI();
  }
View Full Code Here

  public static void removeProject(String user, WorkspaceInfo workspace, ProjectInfo project) throws CoreException {
    // remove the project folder
    URI contentURI = project.getContentLocation();

    // only delete project contents if they are in default location
    IFileStore projectStore = OrionConfiguration.getMetaStore().getDefaultContentLocation(project);
    URI defaultLocation = projectStore.toURI();
    if (URIUtil.sameURI(defaultLocation, contentURI)) {
      projectStore.delete(EFS.NONE, null);
    }

    OrionConfiguration.getMetaStore().deleteProject(workspace.getUniqueId(), project.getFullName());
  }
View Full Code Here

      throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.getDefaultContentLocation: workspace id is null.", null));
    }
    if (projectInfo.getFullName() == null) {
      throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.getDefaultContentLocation: project name is null.", null));
    }
    IFileStore workspaceFolder = getWorkspaceContentLocation(projectInfo.getWorkspaceId());
    String projectId = SimpleMetaStoreUtil.encodeProjectIdFromProjectName(projectInfo.getFullName());
    IFileStore projectFolder = workspaceFolder.getChild(projectId);
    return projectFolder;
  }
View Full Code Here

  protected File getRootLocation() {
    return rootLocation;
  }

  public IFileStore getUserHome(String userId) {
    IFileStore root = OrionConfiguration.getRootLocation();
    if (userId != null) {
      //the format of the user home is /serverworkspace/an/anthony
      String userPrefix = userId.substring(0, Math.min(2, userId.length()));
      return root.getChild(userPrefix).getChild(userId);
    }
    //for backwards compatibility, if userId is null, the old API used to return the root location;
    return root;
  }
View Full Code Here

        //this is the location of the project metadata
        projectObject.put(ProtocolConstants.KEY_LOCATION, URIUtil.append(projectBaseLocation, projectName));
        projects.put(projectObject);

        //remote folders are listed separately
        IFileStore projectStore = null;
        try {
          projectStore = project.getProjectStore();
        } catch (CoreException e) {
          //ignore and treat as local
        }
        JSONObject child = new JSONObject();
        child.put(ProtocolConstants.KEY_NAME, project.getFullName());
        child.put(ProtocolConstants.KEY_DIRECTORY, true);
        //this is the location of the project file contents
        URI contentLocation = computeProjectURI(baseLocation, workspace, project);
        child.put(ProtocolConstants.KEY_LOCATION, contentLocation);
        try {
          if (projectStore != null)
            child.put(ProtocolConstants.KEY_LOCAL_TIMESTAMP, projectStore.fetchInfo(EFS.NONE, null).getLastModified());
        } catch (CoreException coreException) {
          //just omit the timestamp in this case because the project location is unreachable
        }
        try {
          child.put(ProtocolConstants.KEY_CHILDREN_LOCATION, new URI(contentLocation.getScheme(), contentLocation.getUserInfo(), contentLocation.getHost(), contentLocation.getPort(), contentLocation.getPath(), ProtocolConstants.PARM_DEPTH + "=1", contentLocation.getFragment())); //$NON-NLS-1$
View Full Code Here

    }
    String userId = SimpleMetaStoreUtil.decodeUserIdFromWorkspaceId(workspaceId);
    String encodedWorkspaceName = SimpleMetaStoreUtil.decodeWorkspaceNameFromWorkspaceId(workspaceId);
    File userMetaFolder = SimpleMetaStoreUtil.readMetaUserFolder(getRootLocation(), userId);
    File workspaceMetaFolder = SimpleMetaStoreUtil.readMetaFolder(userMetaFolder, encodedWorkspaceName);
    IFileStore userHome = getUserHome(userId);
    IFileStore workspaceFolder = userHome.getChild(workspaceMetaFolder.getName());
    return workspaceFolder;
  }
View Full Code Here

  }

  private boolean handleCopyMoveProject(HttpServletRequest request, HttpServletResponse response, WorkspaceInfo workspace, JSONObject data) throws ServletException, IOException {
    //resolve the source location to a file system location
    String sourceLocation = data.optString(ProtocolConstants.HEADER_LOCATION);
    IFileStore source = null;
    ProjectInfo sourceProject = null;
    try {
      if (sourceLocation != null) {
        //could be either a workspace or file location
        if (sourceLocation.startsWith(Activator.LOCATION_WORKSPACE_SERVLET)) {
          sourceProject = projectForMetadataLocation(getMetaStore(), toOrionLocation(request, sourceLocation));
          if (sourceProject != null)
            source = sourceProject.getProjectStore();
        } else {
          //file location - remove servlet name prefix
          source = resolveSourceLocation(request, sourceLocation);
        }
      }
    } catch (Exception e) {
      handleError(request, response, HttpServletResponse.SC_BAD_REQUEST, NLS.bind("Invalid source location: {0}", sourceLocation), e);
      return true;
    }
    //null result means we didn't find a matching project
    if (source == null) {
      handleError(request, response, HttpServletResponse.SC_BAD_REQUEST, NLS.bind("Source does not exist: {0}", sourceLocation));
      return true;
    }
    int options1 = getCreateOptions(request);
    if (!validateOptions(request, response, options1))
      return true;

    //get the slug first
    String destinationName = request.getHeader(ProtocolConstants.HEADER_SLUG);
    //If the data has a name then it must be used due to UTF-8 issues with names Bug 376671
    try {
      if (data.has(ProtocolConstants.KEY_NAME)) {
        destinationName = data.getString(ProtocolConstants.KEY_NAME);
      }
    } catch (JSONException e) {
      //key is valid so cannot happen
    }

    if (!validateProjectName(workspace, destinationName, request, response))
      return true;

    if ((options1 & CREATE_MOVE) != 0) {
      return handleMoveProject(request, response, workspace, source, sourceProject, sourceLocation, destinationName);
    } else if ((options1 & CREATE_COPY) != 0) {
      //first create the destination project
      JSONObject projectObject = new JSONObject();
      try {
        projectObject.put(ProtocolConstants.KEY_NAME, destinationName);
      } catch (JSONException e) {
        //should never happen
        throw new RuntimeException(e);
      }

      //copy the project data from source
      ProjectInfo destinationProject = createProject(request, response, workspace, projectObject);
      String sourceName = source.getName();
      try {
        source.copy(destinationProject.getProjectStore(), EFS.OVERWRITE, null);
      } catch (CoreException e) {
        handleError(request, response, HttpServletResponse.SC_INTERNAL_SERVER_ERROR, NLS.bind("Error copying project {0} to {1}", sourceName, destinationName));
        return true;
      }
      URI baseLocation = getURI(request);
View Full Code Here

    if (!SimpleMetaStoreUtil.isMetaFile(userMetaFolder, projectInfo.getUniqueId())) {
      throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.updateProject: could not update project: " + projectInfo.getFullName() + " for workspace " + encodedWorkspaceName, null));
    }
    JSONObject jsonObject = SimpleMetaStoreUtil.readMetaFile(userMetaFolder, projectInfo.getUniqueId());
    if (!projectInfo.getUniqueId().equals(SimpleMetaStoreUtil.encodeProjectIdFromProjectName(projectInfo.getFullName()))) {
      IFileStore projectStore = projectInfo.getProjectStore();
      IFileStore defaultProjectStore = getDefaultContentLocation(readProject(projectInfo.getWorkspaceId(), projectInfo.getUniqueId()));
      // full name has changed, this is a project move
      String newProjectId = SimpleMetaStoreUtil.encodeProjectIdFromProjectName(projectInfo.getFullName());
      if (!SimpleMetaStoreUtil.moveMetaFile(userMetaFolder, projectInfo.getUniqueId(), newProjectId)) {
        throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.updateProject: could not move project: " + projectInfo.getUniqueId() + " to " + projectInfo.getFullName() + " for workspace " + encodedWorkspaceName, null));
      }
View Full Code Here

TOP

Related Classes of org.eclipse.core.filesystem.IFileStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.