Пример #1
0
  @Override
  public void handleGet(ActionParameters params) throws ActionException {
    log.info("handleGet");
    final JSONObject response;
    long id = getId(params);
    try {
      if (id > -1) {
        log.info("handleGet: has id");
        User user = userService.getUser(id);
        response = user2Json(user);
      } else {
        log.info("handleGet: no id");
        List<User> users = userService.getUsers();

        log.info("found: " + users.size() + "users");
        response = new JSONObject();
        JSONArray arr = new JSONArray();
        response.put("users", arr);

        List<User> newUsers = userService.getUsersWithRoles();

        for (User user : newUsers) {
          arr.put(user2Json(user));
        }
      }
    } catch (ServiceException se) {
      throw new ActionException(se.getMessage(), se);
    } catch (JSONException je) {
      throw new ActionException(je.getMessage(), je);
    }
    log.info(response);
    ResponseHelper.writeResponse(params, response);
  }
 private AnalysisLayer getAnalysisLayer(
     JSONObject analyseJson, String filter1, String filter2, String baseUrl, String uuid)
     throws ActionParamsException {
   try {
     return analysisParser.parseAnalysisLayer(analyseJson, filter1, filter2, baseUrl, uuid);
   } catch (ServiceException e) {
     throw new ActionParamsException(ERROR_UNABLE_TO_PARSE_ANALYSE, e.getMessage());
   }
 }
Пример #3
0
 @Override
 public void handleDelete(ActionParameters params) throws ActionException {
   log.debug("handleDelete");
   long id = getId(params);
   if (id > -1) {
     try {
       userService.deleteUser(id);
     } catch (ServiceException se) {
       throw new ActionException(se.getMessage(), se);
     }
   } else {
     throw new ActionException("Parameter 'id' not found.");
   }
 }
 private AnalysisLayer getAggregateLayer(
     String analyse,
     String filter1,
     String filter2,
     String baseUrl,
     AnalysisLayer analysisLayer,
     String outputFormat)
     throws ActionParamsException {
   try {
     return analysisParser.parseSwitch2UnionLayer(
         analysisLayer, analyse, filter1, filter2, baseUrl, outputFormat);
   } catch (ServiceException e) {
     throw new ActionParamsException(ERROR_UNABLE_TO_PROCESS_AGGREGATE_UNION, e.getMessage());
   }
 }
  private String executeWPSprocess(AnalysisLayer analysisLayer) throws ActionParamsException {
    String featureSet;
    try {
      featureSet = this.requestFeatureSets(analysisLayer);
    } catch (ServiceException e) {
      throw new ActionParamsException(ERROR_UNABLE_TO_GET_WPS_FEATURES, e.getMessage());
    }
    // Check, if exception result set
    if (featureSet == null || featureSet.indexOf("ows:Exception") > -1) {
      throw new ActionParamsException(ERROR_WPS_EXECUTE_RETURNS_EXCEPTION, featureSet);
    }

    // Check, if any data in result set
    if (featureSet.isEmpty() || featureSet.indexOf("numberOfFeatures=\"0\"") > -1) {
      throw new ActionParamsException(ERROR_WPS_EXECUTE_RETURNS_NO_FEATURES);
    }
    return featureSet;
  }
Пример #6
0
 @Override
 public void handlePut(ActionParameters params) throws ActionException {
   log.debug("handlePut");
   User user = new User();
   getUserParams(user, params);
   String password = params.getRequiredParam(PARAM_PASSWORD);
   String[] roles = params.getRequest().getParameterValues("roles");
   User retUser = null;
   try {
     retUser = userService.createUser(user, roles);
     userService.setUserPassword(retUser.getScreenname(), password);
   } catch (ServiceException se) {
     throw new ActionException(se.getMessage(), se);
   }
   JSONObject response = null;
   try {
     response = user2Json(retUser);
   } catch (JSONException je) {
     throw new ActionException(je.getMessage(), je);
   }
   ResponseHelper.writeResponse(params, response);
 }
Пример #7
0
  @Override
  public void handlePost(ActionParameters params) throws ActionException {
    log.debug("handlePost");
    User user = new User();
    getUserParams(user, params);
    String[] roles = params.getRequest().getParameterValues("roles");
    String password = params.getHttpParam(PARAM_PASSWORD);
    User retUser = null;
    try {
      if (user.getId() > -1) {
        // retUser = userService.modifyUser(user);
        log.debug("roles size: " + roles.length);
        retUser = userService.modifyUserwithRoles(user, roles);
        log.debug("done modifying user");
        if (password != null && !"".equals(password.trim())) {
          userService.updateUserPassword(retUser.getScreenname(), password);
        }
      } else {
        log.debug("NOW IN POST and creating a new user!!!!!!!!!!!!!");
        if (password == null || password.trim().isEmpty()) {
          throw new ActionException("Parameter 'password' not found.");
        }
        retUser = userService.createUser(user);
        userService.setUserPassword(retUser.getScreenname(), password);
      }

    } catch (ServiceException se) {
      throw new ActionException(se.getMessage(), se);
    }
    JSONObject response = null;
    try {
      response = user2Json(retUser);
    } catch (JSONException je) {
      throw new ActionException(je.getMessage(), je);
    }
    ResponseHelper.writeResponse(params, response);
  }