Пример #1
0
  private void parseRequest(
      HttpServletRequest request, Map<String, String> parameters, List<file> files)
      throws IOException {
    if (ServletFileUpload.isMultipartContent(request)) {
      List<FileItem> fileItems = parseMultipartRequest(request);

      long fileSizeMaxMB = ServerConfig.webServerUploadMax();
      long fileSizeMax = fileSizeMaxMB > 0 ? fileSizeMaxMB * NumericUtils.Megabyte : Long.MAX_VALUE;

      for (FileItem fileItem : fileItems) {
        if (!fileItem.isFormField()) {
          if (fileItem.getSize() > fileSizeMax)
            throw new RuntimeException(
                Resources.format(
                    "Exception.fileSizeLimitExceeded", fileItem.getName(), fileSizeMaxMB));
          files.add(new file(fileItem));
        } else
          parameters.put(fileItem.getFieldName(), fileItem.getString(encoding.Default.toString()));
      }
    } else {
      @SuppressWarnings("unchecked")
      Map<String, String[]> requestParameters = request.getParameterMap();

      for (String name : requestParameters.keySet()) {
        String[] values = requestParameters.get(name);
        parameters.put(name, values.length != 0 ? values[0] : null);
      }
    }

    parameters.put(Json.ip.get(), request.getRemoteAddr());
  }
Пример #2
0
 public static class displayNames {
   public static final String Title = Resources.get(strings.Title);
   public static final String Read = Resources.get(strings.Read);
   public static final String Write = Resources.get(strings.Write);
   public static final String Create = Resources.get(strings.Create);
   public static final String Copy = Resources.get(strings.Copy);
   public static final String Destroy = Resources.get(strings.Destroy);
 }
Пример #3
0
 @Override
 protected void processAccessDenied(HttpServletResponse response) throws IOException {
   super.processAccessDenied(response);
   writeError(
       response, Resources.get("Exception.accessDenied"), HttpServletResponse.SC_UNAUTHORIZED);
 }