Package org.restsql.core

Examples of org.restsql.core.RequestLogger


    RequestUtil.checkForInvalidMultipleParameters(params);

    final String responseMediaType = RequestUtil.getResponseMediaType(params,
        httpAttributes.getRequestMediaType(), httpAttributes.getResponseMediaType());
    httpAttributes.setResponseMediaType(responseMediaType);
    final RequestLogger requestLogger = Factory.getRequestLogger();
    final Request.Type type = Request.Type.fromHttpMethod(httpAttributes.getMethod());
    return new RequestImpl(httpAttributes, type, resName, resIds, params, null, requestLogger);
  }
View Full Code Here


        .getResponseMediaType(params, requestMediaType, acceptMediaType);
    final HttpRequestAttributes httpAttributes = HttpRequestHelper.getHttpRequestAttributes(httpRequest,
        requestBody, requestMediaType, responseMediaType);

    // Create logger
    final RequestLogger requestLogger = Factory.getRequestLogger();
    requestLogger.setHttpRequestAttributes(httpAttributes);

    // Authorize
    if (!SecurityFactory.getAuthorizer().isAuthorized(new SecurityContextAdapter(securityContext),
        requestType, resName)) {
      Status status = Status.FORBIDDEN;
      requestLogger.log(status.getStatusCode());
      return Response.status(status).build();
    }

    try {
      String responseBody = null;
      if (sqlResource == null) {
        sqlResource = Factory.getSqlResource(resName);
      }

      // Execute request
      if (requestType.equals(Request.Type.SELECT)) {
        final Request request = Factory.getRequest(httpAttributes, requestType, resName, resIds,
            params, null, requestLogger);
        responseBody = sqlResource.read(request, responseMediaType);
      } else { // INSERT, UPDATE or DELETE
        final WriteResponse writeResponse;
        if (requestMediaType != null
            && !requestMediaType.equals(MediaType.APPLICATION_FORM_URLENCODED)
            && requestBody != null && requestBody.length() > 0) {
          // requestBody is not null, use request processor
          writeResponse = Factory.getRequestDeserializer(requestMediaType).execWrite(httpAttributes,
              requestType, resIds, sqlResource, requestBody, requestLogger);
        } else {
          final Request request = Factory.getRequest(httpAttributes, requestType, resName, resIds,
              params, null, requestLogger);
          writeResponse = sqlResource.write(request);
        }
        responseBody = Factory.getResponseSerializer(responseMediaType).serializeWrite(sqlResource, writeResponse);
      }

      // Log response and send it
      requestLogger.log(responseBody);

      // Get cache control

      String cacheControl = Config.properties.getProperty(Config.KEY_HTTP_CACHE_CONTROL,
          Config.DEFAULT_HTTP_CACHE_CONTROL);
View Full Code Here

TOP

Related Classes of org.restsql.core.RequestLogger

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.