@Override public Object getPayloadInstance(Method method) { if (POST.equals(method)) { return ""; } return null; }
/** * Indicates if the given method exposes its WADL description. By default, * HEAD and OPTIONS are not exposed. This method is called by * {@link #describe(String, ResourceInfo)}. * * @param method * The method * @return True if the method exposes its description, false otherwise. */ public boolean canDescribe(Method method) { return !(Method.HEAD.equals(method) || Method.OPTIONS.equals(method)); }
protected boolean getReadOnly() { return Method.GET.equals(getMethod()); }
/** * Indicates if a content is available and can be sent. Several conditions * must be met: the method must allow the sending of content, the content * must exists and have some available data. * * @return True if a content is available and can be sent. */ @Override public boolean isEntityAvailable() { if (getMethod().equals(Method.GET) || getMethod().equals(Method.HEAD) || getMethod().equals(Method.DELETE)) { return false; } return super.isEntityAvailable(); }
/** * Indicates if a content is available and can be sent. Several conditions * must be met: the method must allow the sending of content, the content * must exists and have some available data. * * @return True if a content is available and can be sent. */ @Override public boolean isEntityAvailable() { // The declaration of the "result" variable is a workaround for the GWT // platform. boolean result = (Method.GET.equals(getMethod()) || Method.HEAD.equals(getMethod())); if (result) { return false; } return super.isEntityAvailable(); }
@Override protected void handleLocal(Request request, Response response, String decodedPath) { if (Method.GET.equals(request.getMethod()) || Method.HEAD.equals(request.getMethod())) { handleEntityGet(request, response, getEntity(decodedPath)); } else { response.setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); response.getAllowedMethods().add(Method.GET); response.getAllowedMethods().add(Method.HEAD); } } }
protected void handleFile(Request request, Response response, String decodedPath) { if (GET.equals(request.getMethod()) || HEAD.equals(request.getMethod())) { handleEntityGet(request, response, getEntity(decodedPath)); } else if (PUT.equals(request.getMethod())) { handleFilePut(request, response, decodedPath, new File(decodedPath)); } else if (DELETE.equals(request.getMethod())) { handleFileDelete(response, new File(decodedPath)); } else { response.setStatus(CLIENT_ERROR_METHOD_NOT_ALLOWED); response.getAllowedMethods().add(GET); response.getAllowedMethods().add(HEAD); response.getAllowedMethods().add(PUT); response.getAllowedMethods().add(DELETE); } }
public Response sendRequest( Method method, String url, Representation representation ) { this.logger.debug( "Method: " + method.getName() + " url: " + url ); Request request = new Request(); request.setResourceRef( url ); request.setMethod( method ); if ( !Method.GET.equals( method ) && !Method.DELETE.equals( method ) ) { request.setEntity( representation ); } request.setChallengeResponse( this.challenge ); return this.restClient.handle( request ); }
public void handle(Request request, Response response) { if (request.getMethod().equals(Method.GET)) { doGet(request, response); } else { response.setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); } }
private String getUsecaseName( Request request ) { if( request.getMethod().equals( org.restlet.data.Method.DELETE ) ) { return "delete"; } else { return request.getResourceRef().getLastSegment(); } }
/** * Indicates if the request is an attempt to log out and should be intercepted. * * @param request * The current request. * @param response * The current response. * @return True if the request is an attempt to log out and should be intercepted. */ protected boolean isLoggingOut(final Request request, final Response response) { return this.isInterceptingLogout() && this.getLogoutPath().equals(request.getResourceRef().getRemainingPart(false, false)) && (Method.GET.equals(request.getMethod()) || Method.POST.equals(request.getMethod())); }
private String getUsecaseName( Request request ) { if( request.getMethod().equals( org.restlet.data.Method.DELETE ) ) { return "delete"; } else { return request.getResourceRef().getLastSegment(); } }
public void handle(Request request, Response response) { Method met = request.getMethod(); if (met.equals(Method.GET)) { doGet(request, response); } else { throw new RestletException("Method not allowed", Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); } }
private String getUsecaseName( Request request ) { if( request.getMethod().equals( org.restlet.data.Method.DELETE ) ) { return "delete"; } else { return request.getResourceRef().getLastSegment(); } }
/** * Indicates if the request is an attempt to log in and should be intercepted. * * @param request * The current request. * @param response * The current response. * @return True if the request is an attempt to log in and should be intercepted. */ protected boolean isLoggingIn(final Request request, final Response response) { return this.isInterceptingLogin() && this.getLoginPath().equals(request.getResourceRef().getRemainingPart(false, false)) && Method.POST.equals(request.getMethod()); }
public void handle(Request request, Response response) { Method met = request.getMethod(); try { if (met.equals(Method.GET)) { doGet(request, response); } else { throw new RestletException("Method not allowed", Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); } } catch (RestletException re) { response.setEntity(re.getRepresentation()); response.setStatus(re.getStatus()); } catch (Exception e) { // Either GeoWebCacheException or IOException response.setEntity(e.getMessage() + " " + e.toString(), MediaType.TEXT_PLAIN); response.setStatus(Status.SERVER_ERROR_INTERNAL); e.printStackTrace(); } }
public void handle(Request request, Response response) { Method met = request.getMethod(); try { if (met.equals(Method.GET)) { doGet(request, response); } else if (met.equals(Method.POST)) { doPost(request, response); } else { throw new RestletException("Method not allowed", Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); } } catch (RestletException re) { response.setEntity(re.getRepresentation()); response.setStatus(re.getStatus()); } catch (IOException ioe) { response.setEntity("Encountered IO error " + ioe.getMessage(), MediaType.TEXT_PLAIN); response.setStatus(Status.SERVER_ERROR_INTERNAL); } }
@Override public boolean writeRequest(Object requestObject, Request request) throws ResourceException { if (requestObject instanceof Form) { // Form as query parameters if (request.getMethod().equals(Method.GET)) request.getResourceRef().setQuery(((Form)requestObject).getQueryString()); else request.setEntity(((Form)requestObject).getWebRepresentation(CharacterSet.UTF_8)); return true; } return false; } }
public void handle(Request request, Response response) { Method met = request.getMethod(); try { if (met.equals(Method.POST)) { doPost(request, response); } else { throw new RestletException("Method not allowed", Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); } } catch (RestletException re) { response.setEntity(re.getRepresentation()); response.setStatus(re.getStatus()); } }
public void handle(Request request, Response response) { Method met = request.getMethod(); try { if (met.equals(Method.POST)) { doPost(request, response); } else { throw new RestletException("Method not allowed", Status.CLIENT_ERROR_METHOD_NOT_ALLOWED); } } catch (RestletException re) { response.setEntity(re.getRepresentation()); response.setStatus(re.getStatus()); } catch (IOException ioe) { response.setEntity("Encountered IO error " + ioe.getMessage(), MediaType.TEXT_PLAIN); response.setStatus(Status.SERVER_ERROR_INTERNAL); } }