Examples of IMetaStore


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

  }

  @Test
  public void testMoveUser() throws CoreException {
    // create the MetaStore
    IMetaStore metaStore = OrionConfiguration.getMetaStore();

    // create the user
    UserInfo userInfo = new UserInfo();
    userInfo.setUserName(testUserLogin);
    userInfo.setFullName(testUserLogin);
    metaStore.createUser(userInfo);

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

    // create the workspace
    String workspaceName = SimpleMetaStore.DEFAULT_WORKSPACE_NAME;
    WorkspaceInfo workspaceInfo = new WorkspaceInfo();
    workspaceInfo.setFullName(workspaceName);
    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
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.