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

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


  }

  private static UserInfo getUser(OAuthConsumer oauthConsumer) {
    try {
      // Get user by oauth property
      UserInfo userInfo = OrionConfiguration.getMetaStore().readUserByProperty(UserConstants2.OAUTH, ".*\\Q" + oauthConsumer.getIdentifier() + "\\E.*", true, false);
      if (userInfo != null) {
        return userInfo;
      }
      // Might need migration, try openid property
      String openidIdentifier = oauthConsumer.getOpenidIdentifier();
      if (openidIdentifier == null)
        return null;
      userInfo = OrionConfiguration.getMetaStore().readUserByProperty(UserConstants2.OPENID, ".*\\Q" + openidIdentifier + "\\E.*", true, false);
      if (userInfo != null) {
        // Remove old property
        String openidsString = (String) userInfo.getProperty(UserConstants2.OPENID);
        String[] openIds = openidsString.split("\n");
        if (openIds.length == 1) {
          userInfo.setProperty(UserConstants2.OPENID, null);
        } else {
          // Multiple open id's
          // Remove the current one
          String newOpenIds = "";
          for (String openid : openIds) {
            if (!openid.equals(oauthConsumer.getOpenidIdentifier())) {
              newOpenIds += openid + "\n";
            }
          }
          newOpenIds = newOpenIds.substring(0, newOpenIds.length() - 1);
          userInfo.setProperty(UserConstants2.OPENID, newOpenIds);
        }
        // Add new property
        String oauths = userInfo.getProperty(UserConstants2.OAUTH);
        if (oauths != null && !oauths.equals("")) {
          oauths += '\n';
        } else {
          oauths = "";
        }
        oauths += oauthConsumer.getIdentifier();
        userInfo.setProperty(UserConstants2.OAUTH, oauths);
        OrionConfiguration.getMetaStore().updateUser(userInfo);
        return userInfo;
      }
    } catch (CoreException e) {
      // just log that there is some internal issue.
View Full Code Here


    WebResponse createResp = createSite(name, workspaceId, null, null, null);
    JSONObject site = new JSONObject(createResp.getText());
    final String siteId = site.getString(ProtocolConstants.KEY_ID);
    String location = site.getString(ProtocolConstants.HEADER_LOCATION);

    UserInfo user = OrionConfiguration.getMetaStore().readUser(testUserId);
    SiteInfo siteInfo = SiteInfo.getSite(user, siteId);
    assertNotNull(siteInfo);

    // Delete site
    WebRequest deleteReq = getDeleteSiteRequest(location);
View Full Code Here

      // the workbench is not running, just pass the test
      return;
    }

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

    // create the workspace
    String workspaceName = SimpleMetaStore.DEFAULT_WORKSPACE_NAME;
    WorkspaceInfo workspaceInfo = new WorkspaceInfo();
    workspaceInfo.setFullName(workspaceName);
    workspaceInfo.setUserId(userInfo.getUniqueId());
    metaStore.createWorkspace(workspaceInfo);

    // create a folder and project.json for the bad project on the filesystem
    String projectName = "Bad Project";
    File rootLocation = OrionConfiguration.getRootLocation().toLocalFile(EFS.NONE, null);
    String workspaceId = SimpleMetaStoreUtil.encodeWorkspaceId(userInfo.getUniqueId(), workspaceName);
    String encodedWorkspaceName = SimpleMetaStoreUtil.decodeWorkspaceNameFromWorkspaceId(workspaceId);
    File userMetaFolder = SimpleMetaStoreUtil.readMetaUserFolder(rootLocation, userInfo.getUniqueId());
    File workspaceMetaFolder = SimpleMetaStoreUtil.readMetaFolder(userMetaFolder, encodedWorkspaceName);

    assertTrue(SimpleMetaStoreUtil.createMetaFolder(workspaceMetaFolder, projectName));
    String corruptedProjectJson = "{\n\"OrionVersion\": 4,";
    File newFile = SimpleMetaStoreUtil.retrieveMetaFile(userMetaFolder, projectName);
View Full Code Here

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

    // read the user, should return null as the user is corrupted on disk
    UserInfo readUserInfo = metaStore.readUser(baduser);
    assertNull(readUserInfo);

    // make sure we delete the corruptedUserFile afterwards or we break the indexer
    corruptedUserFile.delete();
    assertFalse(corruptedUserFile.exists());
View Full Code Here

      // the workbench is not running, just pass the test
      return;
    }

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

    // create a folder and workspace.json for the bad workspace on the filesystem
    File rootLocation = OrionConfiguration.getRootLocation().toLocalFile(EFS.NONE, null);
    String workspaceName = SimpleMetaStore.DEFAULT_WORKSPACE_NAME;
    String workspaceId = SimpleMetaStoreUtil.encodeWorkspaceId(userInfo.getUniqueId(), workspaceName);
    String encodedWorkspaceName = SimpleMetaStoreUtil.decodeWorkspaceNameFromWorkspaceId(workspaceId);
    File userMetaFolder = SimpleMetaStoreUtil.readMetaUserFolder(rootLocation, userInfo.getUniqueId());
    assertTrue(SimpleMetaStoreUtil.createMetaFolder(userMetaFolder, encodedWorkspaceName));
    String corruptedWorkspaceJson = "{\n\"OrionVersion\": 4,";
    File newFile = SimpleMetaStoreUtil.retrieveMetaFile(userMetaFolder, encodedWorkspaceName);
    FileWriter fileWriter = new FileWriter(newFile);
    fileWriter.write(corruptedWorkspaceJson);
View Full Code Here

  public void testReadProject() 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);

    // 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 projectName1 = "Orion Project";
    ProjectInfo projectInfo1 = new ProjectInfo();
View Full Code Here

  public void testReadProjectThatDoesNotExist() 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);

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

  public void testReadProjectWithWorkspaceThatDoesNotExist() 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);

    // 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

  public void testReadUser() 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
    UserInfo readUserInfo = metaStore.readUser(userInfo.getUniqueId());
    assertNotNull(readUserInfo);
    assertEquals(readUserInfo.getUniqueId(), userInfo.getUniqueId());
  }
View Full Code Here

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

    // create the user
    UserInfo userInfo = new UserInfo();
    userInfo.setUserName(testUserLogin);
    userInfo.setFullName(testUserLogin);
    String emailConfirmationId = "1413302977602-0.2258318922458089";
    userInfo.setProperty(UserConstants2.EMAIL_CONFIRMATION_ID, emailConfirmationId);
    metaStore.createUser(userInfo);

    // read the user back again
    UserInfo readUserInfo = metaStore.readUser(testUserLogin);
    assertNotNull(readUserInfo);
    assertEquals(testUserLogin, readUserInfo.getUserName());
    assertEquals(emailConfirmationId, readUserInfo.getProperty(UserConstants2.EMAIL_CONFIRMATION_ID));

    // update the UserInfo
    emailConfirmationId = "1381865755658-0.34789953865892875";
    userInfo.setProperty(UserConstants2.EMAIL_CONFIRMATION_ID, emailConfirmationId);

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

    // read the user back again
    UserInfo readUserInfo2 = metaStore.readUser(testUserLogin);
    assertNotNull(readUserInfo2);
    assertEquals(testUserLogin, readUserInfo2.getUserName());
    String readEmail_confirmation = readUserInfo2.getProperty(UserConstants2.EMAIL_CONFIRMATION_ID);
    assertEquals(emailConfirmationId, readEmail_confirmation);

    // delete the email_confirmation property and update the user
    userInfo.setProperty(UserConstants2.EMAIL_CONFIRMATION_ID, null);
    metaStore.updateUser(userInfo);

    // read the user
    UserInfo readUserInfo3 = metaStore.readUser(userInfo.getUniqueId());
    assertNotNull(readUserInfo3);
    assertEquals(readUserInfo3.getUniqueId(), userInfo.getUniqueId());
    assertNull(readUserInfo3.getProperty(UserConstants2.EMAIL_CONFIRMATION_ID));

    // update the UserInfo again
    emailConfirmationId = "1381865755658-0.34789953865892875";
    userInfo.setProperty(UserConstants2.EMAIL_CONFIRMATION_ID, emailConfirmationId);

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

    // read the user back again
    UserInfo readUserInfo4 = metaStore.readUser(testUserLogin);
    assertNotNull(readUserInfo4);
    assertEquals(testUserLogin, readUserInfo4.getUserName());
    assertEquals(emailConfirmationId, readUserInfo4.getProperty(UserConstants2.EMAIL_CONFIRMATION_ID));
  }
View Full Code Here

TOP

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

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.