Пример #1
0
 public Response<Boolean> setDefConsignee(Long consigneeId, String appKey) {
   Request request = new BaseRequest();
   request.setParam("consigneeId", consigneeId);
   request.setParam("appKey", appKey);
   request.setCommand(ActionEnum.SET_DEFAULT_CONSIGNEE.getActionName());
   Response<Boolean> response = userDispatchService.execute(request);
   return response;
 }
Пример #2
0
 public Response<UserConsigneeDTO> getConsigneeById(Long userId, Long consigneeId, String appKey) {
   Request request = new BaseRequest();
   request.setParam("userId", userId);
   request.setParam("consigneeId", consigneeId);
   request.setParam("appKey", appKey);
   request.setCommand(ActionEnum.GET_CONSIGNEE_BY_ID.getActionName());
   Response<UserConsigneeDTO> response = userDispatchService.execute(request);
   return response;
 }
Пример #3
0
  public Response<Boolean> updateConsignee(UserConsigneeDTO userConsigneeDTO, String appKey) {
    Request request = new BaseRequest();
    request.setParam("consigneeDTO", userConsigneeDTO);
    request.setParam("appKey", appKey);
    request.setCommand(ActionEnum.UPDATE_CONSIGNEE.getActionName());

    Response<Boolean> response = userDispatchService.execute(request);
    return response;
  }
Пример #4
0
 public Response<List<UserConsigneeDTO>> queryConsignee(Long userId, String appKey) {
   Request request = new BaseRequest();
   request.setParam("userId", userId);
   request.setParam("appKey", appKey);
   request.setCommand(ActionEnum.QUERY_CONSIGNEE.getActionName());
   Response<List<UserConsigneeDTO>> response = userDispatchService.execute(request);
   return response;
 }
Пример #5
0
  protected Request setupRequest(String serviceURI, HttpServletRequest httpRequest, String opType)
      throws IOException {
    // No reader.  Done by standard servlet form processing.
    Request request = new Request(serviceURI, null);
    // params => request items
    @SuppressWarnings("unchecked")
    Enumeration<String> en = httpRequest.getParameterNames();

    for (; en.hasMoreElements(); ) {
      String k = en.nextElement();
      String[] x = httpRequest.getParameterValues(k);

      for (int i = 0; i < x.length; i++) {
        String s = x[i];
        request.setParam(k, s);
      }
    }
    request.setParam(Joseki.OPERATION, opType);
    return request;
  }
Пример #6
0
  protected void doCommon(HttpServletRequest httpRequest, HttpServletResponse httpResponse) {
    try {
      if (log.isDebugEnabled()) log.debug(HttpUtils.fmtRequest(httpRequest));

      // getRequestURL is the exact string used by the caller in the request.
      // Internally, it's the "request URI" that names the service

      // String requestURL = httpRequest.getRequestURL().toString() ;
      String uri = httpRequest.getRequestURI();

      if (uri.length() > urlLimit) {
        httpResponse.setStatus(HttpServletResponse.SC_REQUEST_URI_TOO_LONG);
        return;
      }

      String serviceURI = chooseServiceURI(uri, httpRequest);
      serviceURI = Service.canonical(serviceURI);

      String sender = httpRequest.getRemoteAddr();
      log.info("[" + sender + "] Service URI = <" + serviceURI + ">");

      // MIME-Type
      String contentType = httpRequest.getContentType();

      //            if ( Joseki.contentSPARQLUpdate.equals(contentType) ||
      //                Joseki.contentSPARQLUpdate_X.equals(contentType) )
      //            {}

      Request request = setupRequest(serviceURI, httpRequest);
      request.setParam(Joseki.VERB, httpRequest.getMethod());

      Response response = new ResponseHttp(request, httpRequest, httpResponse);
      Dispatcher.dispatch(serviceURI, request, response);
    } catch (Exception ex) {
      try {
        log.warn("Internal server error", ex);
        //                httpResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR) ;
        //                httpResponse.flushBuffer() ;
        //                httpResponse.getWriter().close() ;
        httpResponse.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
      } catch (Exception e) {
      }
    }
  }