Package org.sonatype.nexus.rest.model

Examples of org.sonatype.nexus.rest.model.UserAccount


    resource.addRole("ui-basic");
    resource.setStatus("active");

    this.userMsgUtil.createUser(resource);

    UserAccount dto = accountMsgUtil.readAccount("nxcm897");
    Assert.assertEquals("NXCM 897", dto.getFirstName());
    Assert.assertEquals("nxcm897@changeme.com", dto.getEmail());

    dto.setEmail("nxcm897@changeme2.com");
    dto = accountMsgUtil.updateAccount(dto);
    Assert.assertEquals("nxcm897@changeme2.com", dto.getEmail());
  }
View Full Code Here


    xstream.processAnnotations(UserAccount.class);
    xstream.processAnnotations(UserAccountRequestResponseWrapper.class);
  }

  protected UserAccount nexusToRestModel(User user, Request request) {
    UserAccount dto = new UserAccount();

    dto.setUserId(user.getUserId());

    dto.setFirstName(user.getFirstName());
    dto.setLastName(user.getLastName());

    dto.setEmail(user.getEmailAddress());

    return dto;
  }
View Full Code Here

  public UserAccountRequestResponseWrapper put(Context context, Request request, Response response, Object payload)
      throws ResourceException
  {
    UserAccountRequestResponseWrapper result = new UserAccountRequestResponseWrapper();

    UserAccount dto = ((UserAccountRequestResponseWrapper) payload).getData();

    try {
      User user = getSecuritySystem().getUser(getUserId(request));

      user.setFirstName(dto.getFirstName());
      user.setLastName(dto.getLastName());

      user.setEmailAddress(dto.getEmail());

      userAccountManager.updateAccount(user);

      result.setData(nexusToRestModel(user, request));
    }
    catch (InvalidConfigurationException e) {
      handleInvalidConfigurationException(e);

      return null;
    }
    catch (UserNotFoundException e) {
      String msg = "User account '" + getUserId(request) + "' not found.";

      getLogger().debug(msg, e);

      throw new ResourceException(Status.CLIENT_ERROR_NOT_FOUND, msg);
    }
    catch (NoSuchUserManagerException e) {
      ErrorResponse errorResponse = getErrorResponse("*", e.getMessage());

      throw new PlexusResourceException(Status.CLIENT_ERROR_BAD_REQUEST, "Unable to update account '"
          + dto.getUserId() + "'.", errorResponse);
    }
    catch (AuthorizationException e) {
      throw new ResourceException(Status.CLIENT_ERROR_FORBIDDEN, "Not allowed to update account '" + dto.getUserId()
          + "'.");
    }

    return result;
  }
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.rest.model.UserAccount

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.