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

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


    return jsonObject;
  }

  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) {
View Full Code Here


        statusHandler.handleRequest(request, response, new ServerStatus(IStatus.ERROR, HttpServletResponse.SC_FORBIDDEN, "User name not specified",
            null));
        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());
                children.put(repo);
View Full Code Here

    config.save();
  }

  private static JSONObject getUserGitConfig(String user) throws CoreException {
    JSONObject userGitConfig = null;
    UserInfo userInfo = OrionConfiguration.getMetaStore().readUser(user);
    if (userInfo != null) {
      String gitUserInfo = userInfo.getProperty("git/config/userInfo"); //$NON-NLS-1$
      if (gitUserInfo != null) {
        try {
          userGitConfig = new JSONObject(gitUserInfo);
        } catch (JSONException e) {
          // treat as no git options available
View Full Code Here

  /**
   * Returns whether the user can access the given project
   */
  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) {
View Full Code Here

   * @return ServerStatus <code>OK</code> if the project has been found and successfully removed, <code>ERROR</code> if an error occurred or the project
   *         couldn't be found
   */
  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())) {
View Full Code Here

    // check if user can authenticate
    request = getGetUsersRequest("", true);

    // 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);
View Full Code Here

  private JSONObject getUserJson(String uid) throws JSONException {
    JSONObject obj = new JSONObject();
    obj.put(UserConstants.KEY_LOGIN, uid);

    try {
      UserInfo userInfo = OrionConfiguration.getMetaStore().readUserByProperty(UserConstants2.USER_NAME, uid, false, false);
      if (userInfo == null) {
        return null;
      }
      obj.put(UserConstants.KEY_UID, uid);
      obj.put(UserConstants.KEY_LOGIN, userInfo.getUserName());
      obj.put(UserConstants.KEY_LOCATION, '/' + UserConstants.KEY_USERS + '/' + uid);
      obj.put(UserConstants2.FULL_NAME, userInfo.getFullName());
      if (userInfo.getProperties().containsKey(UserConstants2.LAST_LOGIN_TIMESTAMP)) {
        Long lastLogin = Long.parseLong(userInfo.getProperty(UserConstants2.LAST_LOGIN_TIMESTAMP));
        obj.put(UserConstants2.LAST_LOGIN_TIMESTAMP, lastLogin);
      }
      if (userInfo.getProperties().containsKey(UserConstants2.DISK_USAGE_TIMESTAMP)) {
        Long lastLogin = Long.parseLong(userInfo.getProperty(UserConstants2.DISK_USAGE_TIMESTAMP));
        obj.put(UserConstants2.DISK_USAGE_TIMESTAMP, lastLogin);
      }
      if (userInfo.getProperties().containsKey(UserConstants2.DISK_USAGE)) {
        Long lastLogin = Long.parseLong(userInfo.getProperty(UserConstants2.DISK_USAGE));
        obj.put(UserConstants2.DISK_USAGE, lastLogin);
      }
    } catch (IllegalArgumentException e) {
      LogHelper.log(e);
    } catch (CoreException e) {
View Full Code Here

*/
public class UserInfoTests {

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

        return null;
      }

      String login = authString.substring(0, authString.indexOf(':'));
      String password = authString.substring(authString.indexOf(':') + 1);
      UserInfo userInfo = getUserForCredentials(login, password);
      if (userInfo != null) {
        //        Authorization authorization = userAdmin.getAuthorization(user);
        // TODO handle authorization
        return userInfo.getUniqueId();
      }
    }
    return null;
  }
View Full Code Here

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

  @Test
  public void testFullName() {
    UserInfo userInfo = new UserInfo();
    String fullName = "Test User";
    userInfo.setFullName(fullName);
    assertEquals(fullName, userInfo.getFullName());
  }
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.