Beispiel #1
0
 public void execute(Map<String, Object> context) throws Exception {
   Result result = new Result();
   if (request.getParameter("url") != null) {
     url = URL.valueOf(URL.decode(request.getParameter("url")));
   }
   if (context.get(WebConstants.CURRENT_USER_KEY) != null) {
     User user = (User) context.get(WebConstants.CURRENT_USER_KEY);
     currentUser = user;
     operator = user.getUsername();
     role = user.getRoles();
     context.put(WebConstants.CURRENT_USER_KEY, user);
   }
   operatorAddress = (String) context.get("clientid");
   if (operatorAddress == null || operatorAddress.isEmpty()) {
     operatorAddress = (String) context.get("request.remoteHost");
   }
   context.put("operator", operator);
   context.put("operatorAddress", operatorAddress);
   String jsonResult = null;
   try {
     result = doExecute(context);
     result.setStatus("OK");
   } catch (IllegalArgumentException t) {
     result.setStatus("ERROR");
     result.setCode(3);
     result.setMessage(t.getMessage());
   }
   //        catch (InvalidRequestException t) {
   //            result.setStatus("ERROR");
   //            result.setCode(2);
   //            result.setMessage(t.getMessage());
   //        }
   catch (Throwable t) {
     result.setStatus("ERROR");
     result.setCode(1);
     result.setMessage(t.getMessage());
   }
   response.setContentType("application/javascript");
   ServletOutputStream os = response.getOutputStream();
   try {
     jsonResult = JSON.toJSONString(result);
     os.print(jsonResult);
   } catch (Exception e) {
     response.setStatus(500);
     os.print(e.getMessage());
   } finally {
     os.flush();
   }
 }
 public static Result NotFound(String message) {
   Result result = new Result();
   result.setStatus("Not found");
   result.setMessage(message);
   return result;
 }
 public static Result AccessDenied(String message) {
   Result result = new Result();
   result.setStatus("AccessDenied");
   result.setMessage(message);
   return result;
 }
 public static Result NotAuthorized(String message) {
   Result result = new Result();
   result.setStatus("NotAuthorized");
   result.setMessage(message);
   return result;
 }
 public static Result EmailNotSend(String message) {
   Result result = new Result();
   result.setStatus("EmailNotSend");
   result.setMessage(message);
   return result;
 }
 public static Result SessionFailed(String message) {
   Result result = new Result();
   result.setStatus("SessionFailed");
   result.setMessage(message);
   return result;
 }
 public static Result Complete(String message) {
   Result result = new Result();
   result.setStatus("Complete");
   result.setMessage(message);
   return result;
 }