Package org.eclipse.orion.server.core.metastore

Examples of org.eclipse.orion.server.core.metastore.WorkspaceInfo


      path = path.removeFirstSegments(1);
    }

    //path format is /file/{workspaceId}/{projectName}[/path]
    final IMetaStore metaStore = OrionConfiguration.getMetaStore();
    WorkspaceInfo workspace = metaStore.readWorkspace(path.segment(1));
    assertNotNull(workspace);
    ProjectInfo wp = metaStore.readProject(workspace.getUniqueId(), path.segment(2));
    assertNotNull(wp);
    String userId = workspace.getUserId();
    assertNotNull(userId);
    IFileStore fsStore = getProjectStore(wp, userId);
    fsStore = fsStore.getFileStore(path.removeFirstSegments(3));

    File file = new File(fsStore.toURI());
View Full Code Here


   * not actually create the git clones.
   * @throws CoreException
   */
  protected IPath[] createTestProjects(URI workspaceLocationURI) throws JSONException, IOException, SAXException, CoreException {
    String workspaceId = workspaceIdFromLocation(workspaceLocationURI);
    WorkspaceInfo workspace = OrionConfiguration.getMetaStore().readWorkspace(workspaceId);
    assertNotNull(workspace);
    String name = testName.getMethodName();
    JSONObject projectTop = createProjectOrLink(workspaceLocationURI, name.concat("-top"), null);
    IPath clonePathTop = getClonePath(workspaceId, projectTop);
    JSONObject projectFolder = createProjectOrLink(workspaceLocationURI, name.concat("-folder"), null);
View Full Code Here

   *  - In second pair, both clones are in folders below the project root
   *  - In third pair, one clone is at the root and the other clone is within a child folder
   */
  protected IPath[][] createTestClonePairs(URI workspaceLocationURI) throws IOException, SAXException, JSONException, CoreException {
    String workspaceId = workspaceIdFromLocation(workspaceLocationURI);
    WorkspaceInfo workspace = OrionConfiguration.getMetaStore().readWorkspace(workspaceId);
    assertNotNull(workspace);
    String name = testName.getMethodName();
    JSONObject projectTop1 = createProjectOrLink(workspaceLocationURI, name.concat("-top1"), null);
    IPath clonePathTop1 = getClonePath(workspaceId, projectTop1);

View Full Code Here

      throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.createProject: workspace id is null.", null));
    }
    if (projectInfo.getFullName() == null) {
      throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.createProject: project name is null.", null));
    }
    WorkspaceInfo workspaceInfo;
    try {
      workspaceInfo = readWorkspace(projectInfo.getWorkspaceId());
    } catch (CoreException exception) {
      throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.createProject: could not find workspace with id:" + projectInfo.getWorkspaceId() + ", workspace does not exist.", null));
    }
    if (workspaceInfo == null) {
      throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.createProject: could not find workspace with id:" + projectInfo.getWorkspaceId() + ", workspace does not exist.", null));
    }
    String userId = SimpleMetaStoreUtil.decodeUserIdFromWorkspaceId(projectInfo.getWorkspaceId());
    String encodedWorkspaceName = SimpleMetaStoreUtil.decodeWorkspaceNameFromWorkspaceId(projectInfo.getWorkspaceId());
    String projectId = SimpleMetaStoreUtil.encodeProjectIdFromProjectName(projectInfo.getFullName());
    projectInfo.setUniqueId(projectId);

    JSONObject jsonObject = new JSONObject();
    try {
      jsonObject.put(SimpleMetaStore.ORION_VERSION, VERSION);
      jsonObject.put(MetadataInfo.UNIQUE_ID, projectInfo.getUniqueId());
      jsonObject.put("WorkspaceId", projectInfo.getWorkspaceId());
      jsonObject.put(UserConstants2.FULL_NAME, projectInfo.getFullName());
      if (projectInfo.getContentLocation() != null) {
        URI contentLocation = projectInfo.getContentLocation();
        String encodedContentLocation = SimpleMetaStoreUtil.encodeProjectContentLocation(contentLocation.toString());
        jsonObject.put("ContentLocation", encodedContentLocation);
      }
      JSONObject properties = updateProperties(jsonObject, projectInfo);
      jsonObject.put("Properties", properties);
    } catch (JSONException e) {
      throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.createProject: could not create project: " + projectInfo.getFullName() + " for user " + userId, e));
    }
    File userMetaFolder = SimpleMetaStoreUtil.readMetaUserFolder(getRootLocation(), userId);
    File workspaceMetaFolder = SimpleMetaStoreUtil.readMetaFolder(userMetaFolder, encodedWorkspaceName);
    if (!SimpleMetaStoreUtil.isMetaFolder(workspaceMetaFolder, projectId)) {
      // try to create the project folder if the folder is not linked
      if ((projectInfo.getContentLocation() == null || projectInfo.getProjectStore().equals(getDefaultContentLocation(projectInfo))) && !SimpleMetaStoreUtil.createMetaFolder(workspaceMetaFolder, projectId)) {
        throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.createProject: could not create project: " + projectInfo.getFullName() + " for user " + userId, null));
      }
    }
    if (!SimpleMetaStoreUtil.createMetaFile(userMetaFolder, projectId, jsonObject)) {
      throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.createProject: could not create project: " + projectInfo.getFullName() + " for user " + userId, null));
    }

    // Update the workspace with the new projectName
    List<String> newProjectNames = new ArrayList<String>();
    newProjectNames.addAll(workspaceInfo.getProjectNames());
    newProjectNames.add(projectInfo.getFullName());
    workspaceInfo.setProjectNames(newProjectNames);
    updateWorkspace(workspaceInfo);
  }
View Full Code Here

    String encodedWorkspaceName = SimpleMetaStoreUtil.decodeWorkspaceNameFromWorkspaceId(workspaceId);
    File userMetaFolder = SimpleMetaStoreUtil.readMetaUserFolder(getRootLocation(), userId);
    File workspaceMetaFolder = SimpleMetaStoreUtil.readMetaFolder(userMetaFolder, encodedWorkspaceName);

    // Update the workspace, remove the deleted projectName
    WorkspaceInfo workspaceInfo;
    try {
      workspaceInfo = readWorkspace(workspaceId);
    } catch (CoreException exception) {
      throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.deleteProject: could not find project with name:" + projectName + ", workspace does not exist.", null));
    }
    List<String> newProjectIds = new ArrayList<String>();
    newProjectIds.addAll(workspaceInfo.getProjectNames());
    newProjectIds.remove(projectName);
    workspaceInfo.setProjectNames(newProjectIds);
    updateWorkspace(workspaceInfo);

    String projectId = SimpleMetaStoreUtil.encodeProjectIdFromProjectName(projectName);
    if (!SimpleMetaStoreUtil.deleteMetaFile(userMetaFolder, projectId)) {
      throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.deleteProject: could not delete project: " + projectName + " for user " + userId, null));
View Full Code Here

  public void deleteWorkspace(String userId, String workspaceId) throws CoreException {
    String encodedWorkspaceName = SimpleMetaStoreUtil.decodeWorkspaceNameFromWorkspaceId(workspaceId);
    File userMetaFolder = SimpleMetaStoreUtil.readMetaUserFolder(getRootLocation(), userId);

    // Delete the projects in the workspace
    WorkspaceInfo workspaceInfo = readWorkspace(workspaceId);
    for (String projectName : workspaceInfo.getProjectNames()) {
      deleteProject(workspaceId, projectName);
    }

    // Update the user remove the deleted workspaceId
    UserInfo userInfo;
View Full Code Here

    }
    JSONObject jsonObject = SimpleMetaStoreUtil.readMetaFile(userMetaFolder, workspaceId);
    if (jsonObject == null) {
      return null;
    }
    WorkspaceInfo workspaceInfo = new WorkspaceInfo();
    try {
      workspaceInfo.setUniqueId(jsonObject.getString(MetadataInfo.UNIQUE_ID));
      workspaceInfo.setUserId(jsonObject.getString("UserId"));
      workspaceInfo.setFullName(jsonObject.getString(UserConstants2.FULL_NAME));
      List<String> workspaceProjectNames = new ArrayList<String>();
      JSONArray projectNames = jsonObject.getJSONArray("ProjectNames");
      if (projectNames.length() > 0) {
        for (int i = 0; i < projectNames.length(); i++) {
          workspaceProjectNames.add(projectNames.getString(i));
        }
      }
      workspaceInfo.setProjectNames(workspaceProjectNames);
      setProperties(workspaceInfo, jsonObject.getJSONObject("Properties"));
      workspaceInfo.flush();
    } catch (JSONException e) {
      throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.readWorkspace: could not read workspace " + encodedWorkspaceName + " for user id " + userName, e));
    }
    return workspaceInfo;
  }
View Full Code Here

        if (workspaceMetaFolder.toString().equals(oldContentLocation.getParent())) {
          projectInfo.setContentLocation(new File(workspaceMetaFolder, newProjectId).toURI());
        }
      }
      // Update the workspace with the new projectName
      WorkspaceInfo workspaceInfo;
      try {
        workspaceInfo = readWorkspace(projectInfo.getWorkspaceId());
      } catch (CoreException exception) {
        throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.updateProject: could not find workspace with id:" + projectInfo.getWorkspaceId() + ".", null));
      }
      List<String> newProjectNames = new ArrayList<String>();
      newProjectNames.addAll(workspaceInfo.getProjectNames());
      String oldProjectName = SimpleMetaStoreUtil.decodeProjectNameFromProjectId(projectInfo.getUniqueId());
      newProjectNames.remove(oldProjectName);
      newProjectNames.add(projectInfo.getFullName());
      workspaceInfo.setProjectNames(newProjectNames);
      updateWorkspace(workspaceInfo);
      // update unique id with the new name
      projectInfo.setUniqueId(newProjectId);
    } else if (projectInfo.getProperty("newUserId") != null) {
      // Found the temporary properties to indicate a userId change
View Full Code Here

        // update the workspace JSON with the new userId
        List<String> oldWorkspaceIds = userInfo.getWorkspaceIds();
        List<String> newWorkspaceIds = new ArrayList<String>();
        for (String oldWorkspaceId : oldWorkspaceIds) {
          WorkspaceInfo workspaceInfo = readWorkspace(oldWorkspaceId);
          workspaceInfo.setUserId(newUserId);
          updateWorkspace(workspaceInfo);
          String newWorkspaceId = workspaceInfo.getUniqueId();
          newWorkspaceIds.add(newWorkspaceId);

          // next update each of the project JSON with the new userId and location
          List<String> projectNames = workspaceInfo.getProjectNames();
          for (String projectName : projectNames) {
            ProjectInfo projectInfo = readProject(oldWorkspaceId, projectName);
            // Set temporary properties to indicate a userId change
            projectInfo.setProperty("newUserId", newUserId);
            projectInfo.setProperty("newWorkspaceId", newWorkspaceId);
View Full Code Here

    try {
      if (path.segmentCount() == 0) {
        return null;
      } else if (path.segmentCount() == 1) {
        // Bug 415700: handle path format /workspaceId
        WorkspaceInfo workspace = OrionConfiguration.getMetaStore().readWorkspace(path.segment(0));
        if (workspace != null) {
          return getFileStore(request, workspace);
        }
        return null;
      }
      //path format is /workspaceId/projectName/[suffix]
      ProjectInfo project = OrionConfiguration.getMetaStore().readProject(path.segment(0), path.segment(1));
      if (project != null) {
        return getFileStore(request, project).getFileStore(path.removeFirstSegments(2));
      }
      // Bug 415700: handle path format /workspaceId/[file]
      if (path.segmentCount() == 2) {
        WorkspaceInfo workspace = OrionConfiguration.getMetaStore().readWorkspace(path.segment(0));
        if (workspace != null) {
          return getFileStore(request, workspace).getChild(path.segment(1));
        }
      }
      return null;
View Full Code Here

TOP

Related Classes of org.eclipse.orion.server.core.metastore.WorkspaceInfo

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.