예제 #1
0
  @Override
  public Object runCommand() throws RepositoryException {
    UserRepository userRepository = getContext().getUserRepository();

    // if (username == null) {
    // return userRepository.listAllProjectNames(null);
    // } else {
    OpsUser user = userRepository.findUser(username.getKey());
    if (user == null) {
      throw new IllegalArgumentException("User not found");
    }
    return userRepository.listProjectsByUserId(user.id);
    // }
  }
  @Override
  public Object runCommand() throws RepositoryException, IOException {
    UserRepository userRepository = getContext().getUserRepository();

    OpsUser me = getContext().login();
    OpsProject project = userRepository.findProjectByKey(projectKey.getKey());
    if (project == null) {
      throw new IllegalArgumentException("Project not found");
    }

    SecretStore secretStore = new SecretStore(project.secretData);
    SecretKey projectKey = secretStore.getSecretFromUser(me);

    userRepository.addUserToProject(username.getKey(), project.key, projectKey);

    return project;
  }