Examples of ProjectInfo


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

      }
      return null;
    }
    String projectId = SimpleMetaStoreUtil.encodeProjectIdFromProjectName(projectName);
    JSONObject jsonObject = SimpleMetaStoreUtil.readMetaFile(userMetaFolder, projectId);
    ProjectInfo projectInfo = new ProjectInfo();
    if (jsonObject == null) {
      if (SimpleMetaStoreUtil.isMetaFolder(workspaceMetaFolder, projectId) && !SimpleMetaStoreUtil.isMetaFile(userMetaFolder, projectId)) {
        // the project folder exists but the project json file does not, so create it
        File projectMetaFolder = SimpleMetaStoreUtil.readMetaFolder(workspaceMetaFolder, projectId);
        Logger logger = LoggerFactory.getLogger("org.eclipse.orion.server.config"); //$NON-NLS-1$
        if (logger.isDebugEnabled()) {
          logger.info("SimpleMetaStore.readProject: the project folder " + projectMetaFolder.toString() + " exists but the project json file does not, so creating it in " + workspaceId); //$NON-NLS-1$
        }
        URI projectLocation = projectMetaFolder.toURI();
        projectInfo.setFullName(projectName);
        projectInfo.setWorkspaceId(workspaceId);
        projectInfo.setContentLocation(projectLocation);
        createProject(projectInfo);
        jsonObject = SimpleMetaStoreUtil.readMetaFile(userMetaFolder, projectId);
      } else {
        // both the project folder and project json do not exist, no project
        // OR both the project folder and project json exist, but bad project JSON file == no project
        return null;
      }
    }
    try {
      projectInfo.setUniqueId(jsonObject.getString(MetadataInfo.UNIQUE_ID));
      projectInfo.setWorkspaceId(jsonObject.getString("WorkspaceId"));
      projectInfo.setFullName(jsonObject.getString(UserConstants2.FULL_NAME));
      if (jsonObject.has("ContentLocation")) {
        String decodedContentLocation = SimpleMetaStoreUtil.decodeProjectContentLocation(jsonObject.getString("ContentLocation"));
        projectInfo.setContentLocation(new URI(decodedContentLocation));
      }
      setProperties(projectInfo, jsonObject.getJSONObject("Properties"));
      projectInfo.flush();
    } catch (JSONException e) {
      throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.readProject: could not read project " + projectName + " for userId " + userId, e));
    } catch (URISyntaxException e) {
      throw new CoreException(new Status(IStatus.ERROR, ServerConstants.PI_SERVER_CORE, 1, "SimpleMetaStore.readProject: could not read project " + projectName + " for userId " + userId, e));
    }
View Full Code Here

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

          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);
            updateProject(projectInfo);
          }
        }
        // update the UserRights in the properties
        try {
View Full Code Here

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

      Path basePath = new Path(baseLocation);
      if (basePath.segmentCount() < 2)
        return null;
      String workspaceId = basePath.segment(0);
      String projectName = basePath.segment(1);
      ProjectInfo projectInfo = OrionConfiguration.getMetaStore().readProject(workspaceId, projectName);
      if (projectInfo == null) {
        return null;
      }
      IFileStore projectStore = OrionConfiguration.getMetaStore().getDefaultContentLocation(projectInfo);
      String encodedProjectRoot = projectStore.toURI().toString() + "/";
View Full Code Here

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

*/
public class ProjectInfoTests {

  @Test
  public void testUniqueId() {
    ProjectInfo projectInfo = new ProjectInfo();
    String id = "id";
    projectInfo.setUniqueId(id);
    assertEquals(id, projectInfo.getUniqueId());
  }
View Full Code Here

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

    assertEquals(id, projectInfo.getUniqueId());
  }

  @Test
  public void testFullName() {
    ProjectInfo projectInfo = new ProjectInfo();
    String fullName = "Test Project";
    projectInfo.setFullName(fullName);
    assertEquals(fullName, projectInfo.getFullName());
  }
View Full Code Here

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

    assertEquals(fullName, projectInfo.getFullName());
  }

  @Test
  public void testContentLocation() throws URISyntaxException {
    ProjectInfo projectInfo = new ProjectInfo();
    String contentLocation = "file:/home/test/james/root";
    projectInfo.setContentLocation(new URI(contentLocation));
    assertEquals(contentLocation, projectInfo.getContentLocation().toString());
  }
View Full Code Here

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

    assertEquals(contentLocation, projectInfo.getContentLocation().toString());
  }

  @Test
  public void testProperties() {
    ProjectInfo projectInfo = new ProjectInfo();
    String key1 = "key1";
    String value1 = "value1";
    String key2 = "key2";
    String value2 = "value2";
    assertNull(projectInfo.getProperty(key1));
    assertNull(projectInfo.getProperty(key2));
    assertEquals(0, projectInfo.getProperties().size());
    projectInfo.setProperty(key1, value1);
    assertEquals(value1, projectInfo.getProperty(key1));
    assertEquals(1, projectInfo.getProperties().size());
    projectInfo.setProperty(key2, value2);
    assertEquals(value1, projectInfo.getProperty(key1));
    assertEquals(value2, projectInfo.getProperty(key2));
    assertEquals(2, projectInfo.getProperties().size());
    projectInfo.setProperty(key2, null);
    assertNull(projectInfo.getProperty(key2));
    assertEquals(1, projectInfo.getProperties().size());
    projectInfo.setProperty(key1, null);
    assertNull(projectInfo.getProperty(key1));
    assertEquals(0, projectInfo.getProperties().size());
  }
View Full Code Here

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

        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

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

    assertEquals(0, projectInfo.getProperties().size());
  }

  @Test
  public void testUserId() {
    ProjectInfo projectInfo = new ProjectInfo();
    String workspaceId = "id";
    projectInfo.setWorkspaceId(workspaceId);
    assertEquals(workspaceId, projectInfo.getWorkspaceId());
  }
View Full Code Here

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

    IPath path = pathString == null ? Path.EMPTY : new Path(pathString);
    // expected path format is /file/{workspaceId}/{projectId}[/{directoryPath}]
    if (path.segment(0).equals("file") && path.segmentCount() > 2) { //$NON-NLS-1$

      // make sure a clone is addressed
      ProjectInfo webProject = GitUtils.projectFromPath(path);
      if (webProject != null && isAccessAllowed(request.getRemoteUser(), webProject)) {
        File gitDir = GitUtils.getGitDirs(path, Traverse.CURRENT).values().iterator().next();
        Repository repo = FileRepositoryBuilder.create(gitDir);
        repo.close();
        FileUtils.delete(repo.getWorkTree(), FileUtils.RECURSIVE | FileUtils.RETRY);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.