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

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


      JSONException, ServletException {
    IPath path = pathString == null ? Path.EMPTY : new Path(pathString);
    if (path.segment(0).equals("file") && path.segmentCount() > 1) { //$NON-NLS-1$

      // make sure a clone is addressed
      ProjectInfo webProject = GitUtils.projectFromPath(path);
      if (isAccessAllowed(request.getRemoteUser(), webProject)) {
        Map<IPath, File> gitDirs = GitUtils.getGitDirs(path, Traverse.CURRENT);
        if (gitDirs.isEmpty()) {
          String msg = NLS.bind("Request path is not a git repository: {0}", EncodingUtils.encodeForHTML(path.toString()));
          return statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_BAD_REQUEST, msg, null));
View Full Code Here


    workspaceInfo.setUserId(userInfo.getUniqueId());
    metaStore.createWorkspace(workspaceInfo);

    // create the project
    String projectName = "Orion Project";
    ProjectInfo projectInfo = new ProjectInfo();
    projectInfo.setFullName(projectName);
    projectInfo.setWorkspaceId(workspaceInfo.getUniqueId());
    metaStore.createProject(projectInfo);

    // get the default content location
    IFileStore defaultContentLocation = metaStore.getDefaultContentLocation(projectInfo);
    String location = defaultContentLocation.toLocalFile(EFS.NONE, null).toString();
View Full Code Here

    workspaceInfo.setUserId(userInfo.getUniqueId());
    metaStore.createWorkspace(workspaceInfo);

    // create the project
    String projectName = "Orion Project";
    ProjectInfo projectInfo = new ProjectInfo();
    projectInfo.setFullName(projectName);
    projectInfo.setWorkspaceId(workspaceInfo.getUniqueId());
    IFileStore linkedFolder = metaStore.getUserHome(userInfo.getUniqueId()).getChild("Linked Project");
    projectInfo.setContentLocation(linkedFolder.toURI());

    metaStore.createProject(projectInfo);

    // create a project directory and file
    IFileStore projectFolder = projectInfo.getProjectStore();
    if (!projectFolder.fetchInfo().exists()) {
      projectFolder.mkdir(EFS.NONE, null);
    }
    assertTrue(projectFolder.fetchInfo().exists() && projectFolder.fetchInfo().isDirectory());
    String fileName = "file.html";
    IFileStore file = projectFolder.getChild(fileName);
    try {
      OutputStream outputStream = file.openOutputStream(EFS.NONE, null);
      outputStream.write("<!doctype html>".getBytes());
      outputStream.close();
    } catch (IOException e) {
      fail("Count not create a test file in the Orion Project:" + e.getLocalizedMessage());
    }
    assertTrue("the file in the project folder should exist.", file.fetchInfo().exists());

    // move the project by renaming the project by changing the projectName
    String movedProjectName = "Moved Orion Project";
    projectInfo.setFullName(movedProjectName);

    // update the project
    metaStore.updateProject(projectInfo);

    // read the project back again
    ProjectInfo readProjectInfo = metaStore.readProject(workspaceInfo.getUniqueId(), projectInfo.getFullName());
    assertNotNull(readProjectInfo);
    assertTrue(readProjectInfo.getFullName().equals(movedProjectName));

    // linked folder hasn't moved
    projectFolder = readProjectInfo.getProjectStore();
    assertTrue("the linked project folder should stay the same", projectFolder.equals(linkedFolder));
    assertTrue("the linked project folder should exist.", projectFolder.fetchInfo().exists());
    file = projectFolder.getChild(fileName);
    assertTrue("the file in the linked project folder should exist.", file.fetchInfo().exists());
View Full Code Here

    workspaceInfo.setUserId(userInfo.getUniqueId());
    metaStore.createWorkspace(workspaceInfo);

    // create the project with a bar in the project name
    String projectName = "anthony | Project";
    ProjectInfo projectInfo = new ProjectInfo();
    projectInfo.setFullName(projectName);
    try {
      projectInfo.setContentLocation(new URI("file:/home/anthony/orion/project"));
    } catch (URISyntaxException e) {
      // should not get an exception here, simple URI
    }
    projectInfo.setWorkspaceId(workspaceInfo.getUniqueId());
    metaStore.createProject(projectInfo);

    // move the project by renaming the project by changing the projectName
    String movedProjectName = "anthony | Moved Orion Project";
    projectInfo.setFullName(movedProjectName);

    // update the project
    metaStore.updateProject(projectInfo);

    // read the project back again
    ProjectInfo readProjectInfo = metaStore.readProject(workspaceInfo.getUniqueId(), projectInfo.getFullName());
    assertNotNull(readProjectInfo);
    assertTrue(readProjectInfo.getFullName().equals(movedProjectName));
  }
View Full Code Here

    workspaceInfo.setUserId(userInfo.getUniqueId());
    metaStore.createWorkspace(workspaceInfo);

    // create the project
    String projectName = "Orion Project";
    ProjectInfo projectInfo = new ProjectInfo();
    projectInfo.setFullName(projectName);
    projectInfo.setWorkspaceId(workspaceInfo.getUniqueId());
    metaStore.createProject(projectInfo);

    // create a project directory and file
    IFileStore projectFolder = metaStore.getDefaultContentLocation(projectInfo);
    if (!projectFolder.fetchInfo().exists()) {
      projectFolder.mkdir(EFS.NONE, null);
    }
    assertTrue(projectFolder.fetchInfo().exists());
    assertTrue(projectFolder.fetchInfo().isDirectory());
    String fileName = "file.html";
    IFileStore file = projectFolder.getChild(fileName);
    try {
      OutputStream outputStream = file.openOutputStream(EFS.NONE, null);
      outputStream.write("<!doctype html>".getBytes());
      outputStream.close();
    } catch (IOException e) {
      fail("Count not create a test file in the Orion Project:" + e.getLocalizedMessage());
    }
    assertTrue("the file in the project folder should exist.", file.fetchInfo().exists());

    // update the project with the content location
    projectInfo.setContentLocation(projectFolder.toLocalFile(EFS.NONE, null).toURI());
    metaStore.updateProject(projectInfo);

    // move the project by renaming the project by changing the projectName
    String movedProjectName = "Moved Orion Project";
    projectInfo.setFullName(movedProjectName);

    // update the project
    metaStore.updateProject(projectInfo);

    // read the project back again
    ProjectInfo readProjectInfo = metaStore.readProject(workspaceInfo.getUniqueId(), projectInfo.getFullName());
    assertNotNull(readProjectInfo);
    assertTrue(readProjectInfo.getFullName().equals(movedProjectName));

    // verify the local project has moved
    IFileStore workspaceFolder = metaStore.getWorkspaceContentLocation(workspaceInfo.getUniqueId());
    projectFolder = workspaceFolder.getChild(projectName);
    assertFalse("the original project folder should not exist.", projectFolder.fetchInfo().exists());
View Full Code Here

    workspaceInfo.setUserId(userInfo.getUniqueId());
    metaStore.createWorkspace(workspaceInfo);

    // create the project
    String projectName = "Orion Project";
    ProjectInfo projectInfo = new ProjectInfo();
    projectInfo.setFullName(projectName);
    projectInfo.setWorkspaceId(workspaceInfo.getUniqueId());
    metaStore.createProject(projectInfo);

    // update the content location
    IFileStore projectLocation = metaStore.getDefaultContentLocation(projectInfo);
    projectInfo.setContentLocation(projectLocation.toURI());
    metaStore.updateProject(projectInfo);

    // read the user back again
    userInfo = metaStore.readUser(testUserLogin);
    assertNotNull(userInfo);
    assertTrue(userInfo.getUserName().equals(testUserLogin));

    // move the user by changing the userName
    String newUserName = "ahunter";
    userInfo.setUserName(newUserName);

    // update the user
    metaStore.updateUser(userInfo);

    // read the user back again
    UserInfo readUserInfo2 = metaStore.readUser(newUserName);
    assertNotNull(readUserInfo2);
    assertTrue(readUserInfo2.getUserName().equals(newUserName));

    // read the user using the cache
    UserInfo readUserInfo3 = metaStore.readUserByProperty(UserConstants2.USER_NAME, testUserLogin, false, false);
    assertNull(readUserInfo3);

    // read the user using the cache
    UserInfo readUserInfo4 = metaStore.readUserByProperty(UserConstants2.USER_NAME, newUserName, false, false);
    assertNotNull(readUserInfo4);
    assertEquals(readUserInfo4.getUniqueId(), userInfo.getUniqueId());

    // read the moved workspace
    List<String> workspaceIds = userInfo.getWorkspaceIds();
    assertNotNull(workspaceIds);
    assertEquals(1, workspaceIds.size());
    String readWorkspaceId = workspaceIds.get(0);
    assertTrue(readWorkspaceId.startsWith(newUserName));
    WorkspaceInfo readWorkspaceInfo = metaStore.readWorkspace(readWorkspaceId);
    assertNotNull(readWorkspaceInfo);
    assertEquals(1, readWorkspaceInfo.getProjectNames().size());

    // read the moved project
    String readProjectName = readWorkspaceInfo.getProjectNames().get(0);
    assertEquals(readProjectName, projectName);
    ProjectInfo readProjectInfo = metaStore.readProject(readWorkspaceId, readProjectName);
    assertNotNull(readProjectInfo);
    assertEquals(readWorkspaceInfo.getUniqueId(), readProjectInfo.getWorkspaceId());
  }
View Full Code Here

    fileWriter.write("\n");
    fileWriter.flush();
    fileWriter.close();

    // read the project, should return null as the project is corrupted on disk
    ProjectInfo readProjectInfo = metaStore.readProject(workspaceInfo.getUniqueId(), projectName);
    assertNull(readProjectInfo);
  }
View Full Code Here

    workspaceInfo.setUserId(userInfo.getUniqueId());
    metaStore.createWorkspace(workspaceInfo);

    // create the project
    String projectName1 = "Orion Project";
    ProjectInfo projectInfo1 = new ProjectInfo();
    projectInfo1.setFullName(projectName1);
    try {
      projectInfo1.setContentLocation(new URI("file://root/folder/orion"));
    } catch (URISyntaxException e) {
      // should not get an exception here, simple URI
    }
    projectInfo1.setWorkspaceId(workspaceInfo.getUniqueId());
    metaStore.createProject(projectInfo1);

    // create another project
    String projectName2 = "Another Project";
    ProjectInfo projectInfo2 = new ProjectInfo();
    projectInfo2.setFullName(projectName2);
    try {
      projectInfo2.setContentLocation(new URI("file://root/folder/another"));
    } catch (URISyntaxException e) {
      // should not get an exception here, simple URI
    }
    projectInfo2.setWorkspaceId(workspaceInfo.getUniqueId());
    metaStore.createProject(projectInfo2);

    // read the workspace
    WorkspaceInfo readWorkspaceInfo = metaStore.readWorkspace(workspaceInfo.getUniqueId());
    assertNotNull(readWorkspaceInfo);
    assertEquals(readWorkspaceInfo.getFullName(), workspaceInfo.getFullName());
    assertEquals(2, readWorkspaceInfo.getProjectNames().size());
    assertTrue(readWorkspaceInfo.getProjectNames().contains(projectInfo1.getFullName()));
    assertTrue(readWorkspaceInfo.getProjectNames().contains(projectInfo2.getFullName()));

    // read the project
    ProjectInfo readProjectInfo = metaStore.readProject(workspaceInfo.getUniqueId(), projectInfo2.getFullName());
    assertNotNull(readProjectInfo);
    assertEquals(readProjectInfo.getFullName(), projectInfo2.getFullName());
  }
View Full Code Here

    workspaceInfo1.setFullName(workspaceName);
    workspaceInfo1.setUserId(userInfo.getUniqueId());
    metaStore.createWorkspace(workspaceInfo1);

    // read the project
    ProjectInfo readProjectInfo = metaStore.readProject(workspaceInfo1.getUniqueId(), "Project Zero");
    assertNull(readProjectInfo);
  }
View Full Code Here

    // create the workspace id of a workspace that does not exist
    String workspaceName = SimpleMetaStore.DEFAULT_WORKSPACE_NAME;
    String workspaceId = SimpleMetaStoreUtil.encodeWorkspaceId(userInfo.getUniqueId(), workspaceName);

    // read the project
    ProjectInfo readProjectInfo = metaStore.readProject(workspaceId, "Project Zero");
    assertNull(readProjectInfo);
  }
View Full Code Here

TOP

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

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.