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

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


      @SuppressWarnings("unused")
      Activator r = Activator.getDefault();
      final IMetaStore metastore = OrionConfiguration.getMetaStore();
      if (userInfo.getWorkspaceIds().size() > 0) {
        for (String workspaceId : userInfo.getWorkspaceIds()) {
          WorkspaceInfo workspaceInfo = metastore.readWorkspace(workspaceId);
          if (workspaceInfo.getProjectNames().size() > 0) {
            for (String projectName : workspaceInfo.getProjectNames()) {
              ProjectInfo projectInfo = metastore.readProject(workspaceId, projectName);
              if (projectInfo != null) {
                WorkspaceResourceHandler.removeProject(userId, workspaceInfo, projectInfo);
              }
            }
View Full Code Here


  private boolean isAccessAllowed(String userName, ProjectInfo webProject) {
    try {
      UserInfo user = OrionConfiguration.getMetaStore().readUser(userName);
      for (String workspaceId : user.getWorkspaceIds()) {
        WorkspaceInfo workspace = OrionConfiguration.getMetaStore().readWorkspace(workspaceId);
        if (workspace != null && workspace.getProjectNames().contains(webProject.getFullName()))
          return true;
      }
    } catch (Exception e) {
      // fall through and deny access
      LogHelper.log(e);
View Full Code Here

        return false;
      }
      try {
        UserInfo user = OrionConfiguration.getMetaStore().readUser(userId);
        List<String> workspaces = user.getWorkspaceIds();
        WorkspaceInfo workspace = OrionConfiguration.getMetaStore().readWorkspace(workspaces.get(0));
        URI baseLocation = getURI(request);
        URI baseLocationFile = URIUtil.append(baseLocation, "file"); //$NON-NLS-N$
        if (workspace != null) {
          JSONArray children = new JSONArray();
          for (String projectName : workspace.getProjectNames()) {
            ProjectInfo project = OrionConfiguration.getMetaStore().readProject(workspace.getUniqueId(), projectName);
            if (isAccessAllowed(user.getUserName(), project)) {
              IPath projectPath = GitUtils.pathFromProject(workspace, project);
              Map<IPath, File> gitDirs = GitUtils.getGitDirs(projectPath, Traverse.GO_DOWN);
              for (Map.Entry<IPath, File> entry : gitDirs.entrySet()) {
                JSONObject repo = listEntry(entry.getKey().lastSegment(), 0, true, 0, baseLocationFile, entry.getKey().toPortableString());
View Full Code Here

    } else if (workspacePath != null) {
      IPath path = new Path(workspacePath);
      // TODO: move this to CloneJob
      // if so, modify init part to create a new project if necessary
      final IMetaStore metaStore = OrionConfiguration.getMetaStore();
      WorkspaceInfo workspace = metaStore.readWorkspace(path.segment(1));
      if (cloneName == null)
        cloneName = new URIish(url).getHumanishName();
      cloneName = getUniqueProjectName(workspace, cloneName);
      webProjectExists = false;
      project = new ProjectInfo();
      project.setFullName(cloneName);
      project.setWorkspaceId(workspace.getUniqueId());

      try {
        // creating project in the backing store will assign a project id
        metaStore.createProject(project);
      } catch (CoreException e) {
        return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
            "Error persisting project state", e));
      }
      try {
        WorkspaceResourceHandler.computeProjectLocation(request, project, null, false);
        metaStore.updateProject(project);
      } catch (CoreException e) {
        // delete the project so we don't end up with a project in a bad location
        try {
          metaStore.deleteProject(workspace.getUniqueId(), project.getFullName());
        } catch (CoreException e1) {
          // swallow secondary error
          LogHelper.log(e1);
        }
        // we are unable to write in the platform location!
View Full Code Here

    URI baseLocation = getURI(request);
    String user = request.getRemoteUser();
    // expected path format is 'workspace/{workspaceId}' or 'file/{workspaceId}/{projectName}/{path}]'
    if ("workspace".equals(path.segment(0)) && path.segmentCount() == 2) { //$NON-NLS-1$
      // all clones in the workspace
      WorkspaceInfo workspace = OrionConfiguration.getMetaStore().readWorkspace(path.segment(1));
      if (workspace != null) {
        JSONObject result = new JSONObject();
        JSONArray children = new JSONArray();
        for (String projectName : workspace.getProjectNames()) {
          ProjectInfo project = OrionConfiguration.getMetaStore().readProject(workspace.getUniqueId(), projectName);
          // this is the location of the project metadata
          if (isAccessAllowed(user, project)) {
            IPath projectPath = GitUtils.pathFromProject(workspace, project);
            Map<IPath, File> gitDirs = GitUtils.getGitDirs(projectPath, Traverse.GO_DOWN);
            for (Map.Entry<IPath, File> entry : gitDirs.entrySet()) {
View Full Code Here

   */
  private boolean isAccessAllowed(String userName, ProjectInfo webProject) {
    try {
      UserInfo user = OrionConfiguration.getMetaStore().readUser(userName);
      for (String workspaceId : user.getWorkspaceIds()) {
        WorkspaceInfo workspace = OrionConfiguration.getMetaStore().readWorkspace(workspaceId);
        if (workspace != null && workspace.getProjectNames().contains(webProject.getFullName()))
          return true;
      }
    } catch (Exception e) {
      // fall through and deny access
      LogHelper.log(e);
View Full Code Here

   */
  public static ServerStatus removeProject(String userId, ProjectInfo project) {
    try {
      UserInfo user = OrionConfiguration.getMetaStore().readUser(userId);
      for (String workspaceId : user.getWorkspaceIds()) {
        WorkspaceInfo workspace = OrionConfiguration.getMetaStore().readWorkspace(workspaceId);
        if (workspace == null)
          continue;
        for (String projectName : workspace.getProjectNames()) {
          if (projectName.equals(project.getFullName())) {
            // If found, remove project from workspace
            try {
              WorkspaceResourceHandler.removeProject(userId, workspace, project);
            } catch (CoreException e) {
View Full Code Here

    // create some project contents to test that delete user also deletes all project contents
    try {
      UserInfo userInfo = OrionConfiguration.getMetaStore().readUser(params.get(UserConstants.KEY_LOGIN));
      String workspaceName = "Orion Content";
      WorkspaceInfo workspaceInfo = new WorkspaceInfo();
      workspaceInfo.setFullName(workspaceName);
      workspaceInfo.setUserId(userInfo.getUniqueId());
      OrionConfiguration.getMetaStore().createWorkspace(workspaceInfo);

      String projectName = "Orion Project";
      ProjectInfo projectInfo = new ProjectInfo();
      projectInfo.setFullName(projectName);
      projectInfo.setWorkspaceId(workspaceInfo.getUniqueId());
      OrionConfiguration.getMetaStore().createProject(projectInfo);

      IFileStore projectFolder = OrionConfiguration.getMetaStore().getDefaultContentLocation(projectInfo);
      projectInfo.setContentLocation(projectFolder.toURI());
      OrionConfiguration.getMetaStore().updateProject(projectInfo);
View Full Code Here

  private WorkspaceInfo createWorkspace() throws CoreException {
    IMetaStore store = getMetaStore();
    UserInfo user = new UserInfo();
    user.setUserName("MetaStoreTestUser");
    store.createUser(user);
    WorkspaceInfo workspace = new WorkspaceInfo();
    workspace.setFullName(SimpleMetaStore.DEFAULT_WORKSPACE_NAME);
    workspace.setUserId(user.getUniqueId());
    store.createWorkspace(workspace);
    return workspace;
  }
View Full Code Here

  }

  @Test
  public void testUniqueProjectIds() throws CoreException {
    //tests that creating multiple projects will create unique ids
    WorkspaceInfo workspace = createWorkspace();
    IMetaStore metaStore = getMetaStore();
    List<String> ids = new ArrayList<String>();
    for (int i = 0; i < 100; i++) {
      ProjectInfo projectInfo = new ProjectInfo();
      projectInfo.setFullName("Project " + i);
      projectInfo.setWorkspaceId(workspace.getUniqueId());
      IFileStore fileStore = metaStore.getDefaultContentLocation(projectInfo);
      projectInfo.setContentLocation(fileStore.toURI());
      metaStore.createProject(projectInfo);
      String projectId = projectInfo.getUniqueId();
      final java.io.File currentProject = new java.io.File(projectId);
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.