@Override public boolean incomingRequestPreProcessed(HttpServletRequest theRequest, HttpServletResponse theResponse) { RequestTypeEnum requestType = RequestTypeEnum.valueOf(theRequest.getMethod()); if (myAllowedMethods.contains(requestType)) { return true; } throw new MethodNotAllowedException("Method not supported: " + theRequest.getMethod()); }
private void updateAllowHeader() { getResponseHeaders().remove(Constants.HEADER_ALLOW); StringBuilder b = new StringBuilder(); for (RequestTypeEnum next : myAllowedMethods) { if (b.length() > 0) { b.append(','); } b.append(next.name()); } addResponseHeader(Constants.HEADER_ALLOW, b.toString()); }
/** * Constructor * * @param theMessage * The message * @param theAllowedMethods * A list of allowed methods (see {@link #setAllowedMethods(RequestTypeEnum...)} ) */ public MethodNotAllowedException(String theMessage, RequestTypeEnum... theAllowedMethods) { super(STATUS_CODE, theMessage); setAllowedMethods(theAllowedMethods); }
/** * Specifies the list of allowed HTTP methods (GET, POST, etc). This is provided in an <code>Allow</code> header, as required by the HTTP specification (RFC 2616). */ public void setAllowedMethods(Set<RequestTypeEnum> theAllowedMethods) { myAllowedMethods = theAllowedMethods; updateAllowHeader(); }
/** * Specifies the list of allowed HTTP methods (GET, POST, etc). This is provided in an <code>Allow</code> header, as required by the HTTP specification (RFC 2616). */ public void setAllowedMethods(RequestTypeEnum... theAllowedMethods) { if (theAllowedMethods == null || theAllowedMethods.length == 0) { myAllowedMethods = null; } else { myAllowedMethods = new LinkedHashSet<RequestTypeEnum>(); for (RequestTypeEnum next : theAllowedMethods) { myAllowedMethods.add(next); } } updateAllowHeader(); }
@Override public boolean incomingServerRequestMatchesMethod(RequestDetails theRequest) { if (theRequest.getRequestType() == RequestTypeEnum.OPTIONS) { if (theRequest.getOperation() == null && theRequest.getResourceName() == null) { return true; } } if (theRequest.getResourceName() != null) { return false; } if ("metadata".equals(theRequest.getOperation())) { if (theRequest.getRequestType() == RequestTypeEnum.GET) { return true; } throw new MethodNotAllowedException("/metadata request must use HTTP GET", RequestTypeEnum.GET); } return false; }
private void updateAllowHeader() { getResponseHeaders().remove(Constants.HEADER_ALLOW); StringBuilder b = new StringBuilder(); for (RequestTypeEnum next : myAllowedMethods) { if (b.length() > 0) { b.append(','); } b.append(next.name()); } addResponseHeader(Constants.HEADER_ALLOW, b.toString()); }
/** * Constructor * * @param theMessage * The message * @param theOperationOutcome * The OperationOutcome resource to return to the client * @param theAllowedMethods * A list of allowed methods (see {@link #setAllowedMethods(RequestTypeEnum...)} ) */ public MethodNotAllowedException(String theMessage, IBaseOperationOutcome theOperationOutcome, RequestTypeEnum... theAllowedMethods) { super(STATUS_CODE, theMessage, theOperationOutcome); setAllowedMethods(theAllowedMethods); }
/** * Specifies the list of allowed HTTP methods (GET, POST, etc). This is provided in an <code>Allow</code> header, as required by the HTTP specification (RFC 2616). */ public void setAllowedMethods(Set<RequestTypeEnum> theAllowedMethods) { myAllowedMethods = theAllowedMethods; updateAllowHeader(); }
HapiLocalizer localizer = theRequest.getServer().getFhirContext().getLocalizer(); String msg = localizer.getMessage(OperationParameter.class, "urlParamNotPrimitive", myOperationName, myName); throw new MethodNotAllowedException(msg, RequestTypeEnum.POST);
/** * Constructor * * @param theMessage * The message * @param theAllowedMethods * A list of allowed methods (see {@link #setAllowedMethods(RequestTypeEnum...)} ) */ public MethodNotAllowedException(String theMessage, RequestTypeEnum... theAllowedMethods) { super(STATUS_CODE, theMessage); setAllowedMethods(theAllowedMethods); }
/** * Specifies the list of allowed HTTP methods (GET, POST, etc). This is provided in an <code>Allow</code> header, as required by the HTTP specification (RFC 2616). */ public void setAllowedMethods(RequestTypeEnum... theAllowedMethods) { if (theAllowedMethods == null || theAllowedMethods.length == 0) { myAllowedMethods = null; } else { myAllowedMethods = new LinkedHashSet<RequestTypeEnum>(); for (RequestTypeEnum next : theAllowedMethods) { myAllowedMethods.add(next); } } updateAllowHeader(); }
throw new MethodNotAllowedException("$expunge is not enabled on this server");
/** * Constructor * * @param theMessage * The message * @param theOperationOutcome * The OperationOutcome resource to return to the client * @param theAllowedMethods * A list of allowed methods (see {@link #setAllowedMethods(RequestTypeEnum...)} ) */ public MethodNotAllowedException(String theMessage, IBaseOperationOutcome theOperationOutcome, RequestTypeEnum... theAllowedMethods) { super(STATUS_CODE, theMessage, theOperationOutcome); setAllowedMethods(theAllowedMethods); }
@Override public Object invokeServer(IRestfulServer<?> theServer, RequestDetails theRequest, Object[] theMethodParams) throws BaseServerResponseException { if (theRequest.getRequestType() == RequestTypeEnum.POST) { // all good } else if (theRequest.getRequestType() == RequestTypeEnum.GET) { if (!myIdempotent) { String message = getContext().getLocalizer().getMessage(OperationMethodBinding.class, "methodNotSupported", theRequest.getRequestType(), RequestTypeEnum.POST.name()); throw new MethodNotAllowedException(message, RequestTypeEnum.POST); } } else { if (!myIdempotent) { String message = getContext().getLocalizer().getMessage(OperationMethodBinding.class, "methodNotSupported", theRequest.getRequestType(), RequestTypeEnum.POST.name()); throw new MethodNotAllowedException(message, RequestTypeEnum.POST); } String message = getContext().getLocalizer().getMessage(OperationMethodBinding.class, "methodNotSupported", theRequest.getRequestType(), RequestTypeEnum.GET.name(), RequestTypeEnum.POST.name()); throw new MethodNotAllowedException(message, RequestTypeEnum.GET, RequestTypeEnum.POST); } if (myIdParamIndex != null) { theMethodParams[myIdParamIndex] = theRequest.getId(); } Object response = invokeServerMethod(theServer, theRequest, theMethodParams); IBundleProvider retVal = toResourceList(response); return retVal; }
break; case Constants.STATUS_HTTP_405_METHOD_NOT_ALLOWED: ex = new MethodNotAllowedException("Server responded with HTTP 405"); break; case Constants.STATUS_HTTP_409_CONFLICT:
break; case Constants.STATUS_HTTP_405_METHOD_NOT_ALLOWED: ex = new MethodNotAllowedException("Server responded with HTTP 405"); break; case Constants.STATUS_HTTP_409_CONFLICT:
for (IQueryParameterType next : nextOrs) { if (next.getMissing() != null) { throw new MethodNotAllowedException(":missing modifier is disabled on this server");
if (id.isContains()) { if (!myDaoConfig.isAllowContainsSearches()) { throw new MethodNotAllowedException(":contains modifier is disabled on this server");
@Override public boolean incomingRequestPreProcessed(HttpServletRequest theRequest, HttpServletResponse theResponse) { RequestTypeEnum requestType = RequestTypeEnum.valueOf(theRequest.getMethod()); if (myAllowedMethods.contains(requestType)) { return true; } throw new MethodNotAllowedException("Method not supported: " + theRequest.getMethod()); }