Example #1
0
 @Get("json")
 public Representation getUserData() {
   try {
     if (getQuery().getValues("search") == null) {
       return mono();
     } else {
       return multi();
     }
   } catch (BadAuthenticationException e) {
     System.err.println(StatusFactory.getErrorMessage(e));
     return new JacksonRepresentation<Status>(StatusFactory.clientUnauthorized(e.getMessage()));
   } catch (Exception e) {
     System.err.println(StatusFactory.getErrorMessage(e));
     return new JacksonRepresentation<Status>(StatusFactory.serverInternalError());
   }
 }
Example #2
0
  private Representation editPasswordData(Form form) {
    String sessionHash = form.getFirstValue("session_hash");
    String oldPassword = form.getFirstValue("old_password");
    String newPassword = form.getFirstValue("new_password");

    try {
      mUserService.editPassword(sessionHash, oldPassword, newPassword);

      return new JacksonRepresentation<Status>(StatusFactory.ok());
    } catch (BadAuthenticationException e) {
      System.err.println(StatusFactory.getErrorMessage(e));
      return new JacksonRepresentation<Status>(StatusFactory.clientUnauthorized(e.getMessage()));
    } catch (IllegalArgumentException e) {
      System.err.println(StatusFactory.getErrorMessage(e));
      return new JacksonRepresentation<Status>(StatusFactory.clientBadRequest(e.getMessage()));
    } catch (Exception e) {
      System.err.println(StatusFactory.getErrorMessage(e));
      return new JacksonRepresentation<Status>(StatusFactory.serverInternalError());
    }
  }
Example #3
0
  private Representation editSimpleData(Form form) {
    String sessionHash = form.getFirstValue("session_hash");
    String fullName = form.getFirstValue("full_name");
    String email = form.getFirstValue("email");

    try {
      mUserService.editSimpleData(sessionHash, fullName, email);

      return new JacksonRepresentation<Status>(StatusFactory.ok());
    } catch (BadAuthenticationException e) {
      System.err.println(StatusFactory.getErrorMessage(e));
      return new JacksonRepresentation<Status>(StatusFactory.clientUnauthorized(e.getMessage()));
    } catch (IllegalArgumentException e) {
      System.err.println(StatusFactory.getErrorMessage(e));
      return new JacksonRepresentation<Status>(StatusFactory.clientBadRequest(e.getMessage()));
    } catch (Exception e) {
      System.err.println(StatusFactory.getErrorMessage(e));
      return new JacksonRepresentation<Status>(StatusFactory.serverInternalError());
    }
  }