Example #1
0
 private List<String> determineMethodsAllowed(HttpManager manager, Resource res) {
   List<String> list = new ArrayList<String>();
   for (Handler f : manager.getAllHandlers()) {
     if (f.isCompatible(res)) {
       for (String m : f.getMethods()) {
         Method httpMethod = Method.valueOf(m);
         if (!handlerHelper.isNotCompatible(res, httpMethod)) {
           list.add(m);
         }
       }
     }
   }
   return list;
 }
Example #2
0
  public void processResource(
      HttpManager manager, Request request, Response response, Resource resource)
      throws NotAuthorizedException, ConflictException, BadRequestException {
    long t = System.currentTimeMillis();
    try {
      if (enableAuthorisation) {
        if (!handlerHelper.checkAuthorisation(manager, resource, request)) {
          responseHandler.respondUnauthorised(resource, response, request);
          return;
        }
      }

      manager.onProcessResourceStart(request, response, resource);

      List<String> methodsAllowed = determineMethodsAllowed(manager, resource);
      responseHandler.respondWithOptions(resource, response, request, methodsAllowed);

    } finally {
      t = System.currentTimeMillis() - t;
      manager.onProcessResourceFinish(request, response, resource, t);
    }
  }