org.restlet.data.Request.getMethod()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(10.8k)|赞(0)|评价(0)|浏览(281)

本文整理了Java中org.restlet.data.Request.getMethod方法的一些代码示例,展示了Request.getMethod的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getMethod方法的具体详情如下:
包路径:org.restlet.data.Request
类名称:Request
方法名:getMethod

Request.getMethod介绍

[英]Returns the method.
[中]返回方法。

代码示例

代码示例来源:origin: org.restlet/org.restlet

  1. /**
  2. * Returns the method.
  3. *
  4. * @return The method.
  5. */
  6. @Override
  7. public Method getMethod() {
  8. return getWrappedRequest().getMethod();
  9. }

代码示例来源:origin: org.geoserver/restconfig

  1. @Override
  2. public Resource findTarget(Request request, Response response) {
  3. if (!(request.getMethod() == Method.POST || request.getMethod() == Method.PUT)) {
  4. response.setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
  5. return null;

代码示例来源:origin: org.restlet/org.restlet

  1. /**
  2. * Indicates if a content is available and can be sent. Several conditions
  3. * must be met: the method must allow the sending of content, the content
  4. * must exists and have some available data.
  5. *
  6. * @return True if a content is available and can be sent.
  7. */
  8. @Override
  9. public boolean isEntityAvailable() {
  10. if (getMethod().equals(Method.GET) || getMethod().equals(Method.HEAD)
  11. || getMethod().equals(Method.DELETE)) {
  12. return false;
  13. }
  14. return super.isEntityAvailable();
  15. }

代码示例来源:origin: org.geowebcache/gwc-rest

  1. public void handle(Request request, Response response) {
  2. if (request.getMethod().equals(Method.GET)) {
  3. doGet(request, response);
  4. } else {
  5. response.setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
  6. }
  7. }

代码示例来源:origin: org.geowebcache/gwc-rest

  1. public void handle(Request request, Response response) {
  2. Method met = request.getMethod();
  3. if (met.equals(Method.GET)) {
  4. doGet(request, response);
  5. } else {
  6. throw new RestletException("Method not allowed", Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
  7. }
  8. }

代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher

  1. @Override
  2. public HttpClientCall create(Request request) {
  3. HttpClientCall result = null;
  4. try {
  5. result = new Hc4MethodCall(this, request.getMethod().toString(),
  6. request.getResourceRef().toString(), request
  7. .isEntityAvailable());
  8. }
  9. catch (IOException ioe) {
  10. getLogger().log(Level.WARNING,
  11. "Unable to create the HTTP client call", ioe);
  12. }
  13. return result;
  14. }

代码示例来源:origin: org.geowebcache/gwc-rest

  1. public void handle(Request request, Response response) {
  2. Method met = request.getMethod();
  3. try {
  4. if (met.equals(Method.GET)) {
  5. doGet(request, response);
  6. } else {
  7. throw new RestletException("Method not allowed",
  8. Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
  9. }
  10. } catch (RestletException re) {
  11. response.setEntity(re.getRepresentation());
  12. response.setStatus(re.getStatus());
  13. } catch (Exception e) {
  14. // Either GeoWebCacheException or IOException
  15. response.setEntity(e.getMessage() + " " + e.toString(), MediaType.TEXT_PLAIN);
  16. response.setStatus(Status.SERVER_ERROR_INTERNAL);
  17. e.printStackTrace();
  18. }
  19. }

代码示例来源:origin: org.geoserver/restconfig

  1. @Override
  2. public Resource findTarget(Request request, Response response) {
  3. String workspace = getAttribute(request, "workspace");
  4. if ( workspace == null && request.getMethod() == Method.GET ) {
  5. return new WorkspaceListResource( null, request, response, catalog );
  6. }
  7. if ( workspace != null ) {
  8. //ensure it exists
  9. if ( catalog.getWorkspaceByName( workspace ) == null ) {
  10. throw new RestletException( "No such workspace: " + workspace, Status.CLIENT_ERROR_NOT_FOUND );
  11. }
  12. }
  13. return new WorkspaceResource( null, request, response, catalog );
  14. }

代码示例来源:origin: org.restlet/org.restlet.ext.httpclient

  1. /**
  2. * Creates a low-level HTTP client call from a high-level uniform call.
  3. *
  4. * @param request
  5. * The high-level request.
  6. * @return A low-level HTTP client call.
  7. */
  8. @Override
  9. public HttpClientCall create(Request request) {
  10. HttpClientCall result = null;
  11. try {
  12. result = new HttpMethodCall(this, request.getMethod().toString(),
  13. request.getResourceRef().toString(), request
  14. .isEntityAvailable());
  15. } catch (IOException ioe) {
  16. getLogger().log(Level.WARNING,
  17. "Unable to create the HTTP client call", ioe);
  18. }
  19. return result;
  20. }

代码示例来源:origin: org.geoserver/restconfig

  1. @Override
  2. public Resource findTarget(Request request, Response response) {
  3. String ws = (String) request.getAttributes().get( "workspace" );
  4. String wms = (String) request.getAttributes().get( "wmsstore" );
  5. //ensure referenced resources exist
  6. if ( ws != null && catalog.getWorkspaceByName(ws) == null) {
  7. throw new RestletException( "No such workspace: " + ws, Status.CLIENT_ERROR_NOT_FOUND );
  8. }
  9. if ( wms != null && catalog.getStoreByName(ws, wms, WMSStoreInfo.class) == null) {
  10. throw new RestletException( "No such wms store: " + ws + "," + wms, Status.CLIENT_ERROR_NOT_FOUND );
  11. }
  12. if ( wms == null && request.getMethod() == Method.GET ) {
  13. return new WMSStoreListResource(getContext(),request,response,catalog);
  14. }
  15. return new WMSStoreResource( null, request, response, catalog );
  16. }

代码示例来源:origin: org.geoserver/restconfig

  1. @Override
  2. public Resource findTarget(Request request, Response response) {
  3. String layer = getAttribute(request, "layer");
  4. if ( layer == null && request.getMethod() == Method.GET ) {
  5. return new LayerListResource(getContext(),request,response,catalog);
  6. }
  7. //ensure referenced resources exist
  8. if ( layer != null && catalog.getLayerByName(layer) == null ) {
  9. throw new RestletException( "No such layer: " + layer, Status.CLIENT_ERROR_NOT_FOUND );
  10. }
  11. return new LayerResource(null,request,response,catalog);
  12. }

代码示例来源:origin: org.geoserver/restconfig

  1. @Override
  2. public Resource findTarget(Request request, Response response) {
  3. String namespace = getAttribute(request, "namespace");
  4. if ( namespace == null && request.getMethod() == Method.GET ) {
  5. return new NamespaceListResource( getContext(), request, response, catalog );
  6. }
  7. if ( namespace != null ) {
  8. //ensure it exists
  9. if ( catalog.getNamespaceByPrefix( namespace ) == null ) {
  10. throw new RestletException( "No such namespace: " + namespace, Status.CLIENT_ERROR_NOT_FOUND );
  11. }
  12. }
  13. return new NamespaceResource( null, request, response, catalog );
  14. }

代码示例来源:origin: org.geoserver/restconfig

  1. @Override
  2. public Resource findTarget(Request request, Response response) {
  3. String ws = getAttribute(request, "workspace");
  4. String ds = getAttribute(request, "datastore");
  5. //ensure referenced resources exist
  6. if ( ws != null && catalog.getWorkspaceByName(ws) == null) {
  7. throw new RestletException( "No such workspace: " + ws, Status.CLIENT_ERROR_NOT_FOUND );
  8. }
  9. if ( ds != null && catalog.getDataStoreByName(ws, ds) == null && !"default".equals(ds)) {
  10. throw new RestletException( "No such datastore: " + ws + "," + ds, Status.CLIENT_ERROR_NOT_FOUND );
  11. }
  12. if ( ds == null && request.getMethod() == Method.GET ) {
  13. return new DataStoreListResource(getContext(),request,response,catalog);
  14. }
  15. return new DataStoreResource( null, request, response, catalog );
  16. }

代码示例来源:origin: org.geowebcache/gwc-rest

  1. public void handle(Request request, Response response) {
  2. Method met = request.getMethod();
  3. try {
  4. if (met.equals(Method.POST)) {
  5. doPost(request, response);
  6. } else {
  7. throw new RestletException("Method not allowed",
  8. Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
  9. }
  10. } catch (RestletException re) {
  11. response.setEntity(re.getRepresentation());
  12. response.setStatus(re.getStatus());
  13. }
  14. }

代码示例来源:origin: org.geowebcache/gwc-rest

  1. public void handle(Request request, Response response) {
  2. Method met = request.getMethod();
  3. try {
  4. if (met.equals(Method.POST)) {
  5. doPost(request, response);
  6. } else {
  7. throw new RestletException("Method not allowed",
  8. Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
  9. }
  10. } catch (RestletException re) {
  11. response.setEntity(re.getRepresentation());
  12. response.setStatus(re.getStatus());
  13. } catch (IOException ioe) {
  14. response.setEntity("Encountered IO error " + ioe.getMessage(), MediaType.TEXT_PLAIN);
  15. response.setStatus(Status.SERVER_ERROR_INTERNAL);
  16. }
  17. }

代码示例来源:origin: org.geoserver/xslt

  1. @Override
  2. public Resource findTarget(Request request, Response response) {
  3. String transform = RESTUtils.getAttribute(request, "transform");
  4. // if it's not referencing a particular transform, return the list
  5. if (transform == null && request.getMethod() == Method.GET) {
  6. return new TransformListResource(getContext(), request, response, repository);
  7. }
  8. // ensure referenced transform exist
  9. try {
  10. if (transform != null && repository.getTransformInfo(transform) == null) {
  11. throw new RestletException("No such transform: " + transform,
  12. Status.CLIENT_ERROR_NOT_FOUND);
  13. }
  14. } catch (IOException e) {
  15. throw new RestletException("An error occurred while trying to locate the transform: "
  16. + transform, Status.SERVER_ERROR_INTERNAL, e);
  17. }
  18. // return the specific resource
  19. return new TransformResource(null, request, response, repository, catalog);
  20. }

代码示例来源:origin: org.geowebcache/gwc-rest

  1. public void handle(Request request, Response response) {
  2. Method met = request.getMethod();
  3. try {
  4. if (met.equals(Method.GET)) {
  5. doGet(request, response);
  6. } else if (met.equals(Method.POST)) {
  7. doPost(request, response);
  8. } else {
  9. throw new RestletException("Method not allowed",
  10. Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
  11. }
  12. } catch (RestletException re) {
  13. response.setEntity(re.getRepresentation());
  14. response.setStatus(re.getStatus());
  15. } catch (IOException ioe) {
  16. response.setEntity("Encountered IO error " + ioe.getMessage(), MediaType.TEXT_PLAIN);
  17. response.setStatus(Status.SERVER_ERROR_INTERNAL);
  18. }
  19. }

代码示例来源:origin: org.geoserver/restconfig

  1. @Override
  2. public Resource findTarget(Request request, Response response) {
  3. String ws = getAttribute(request, "workspace");
  4. String lg = getAttribute(request, "layergroup");
  5. if (ws != null && catalog.getWorkspaceByName(ws) == null) {
  6. throw new RestletException("No such workspace: " + ws, Status.CLIENT_ERROR_NOT_FOUND);
  7. }
  8. if ( lg != null) {
  9. if (ws != null && catalog.getLayerGroupByName( ws, lg ) == null) {
  10. throw new RestletException(String.format("No such layer group %s in workspace %s",
  11. lg, ws), Status.CLIENT_ERROR_NOT_FOUND );
  12. }
  13. if (ws == null && catalog.getLayerGroupByName( lg ) == null) {
  14. throw new RestletException( "No such layer group " + lg, Status.CLIENT_ERROR_NOT_FOUND );
  15. }
  16. }
  17. if ( lg == null && request.getMethod() == Method.GET ) {
  18. return new LayerGroupListResource( getContext(), request, response, catalog );
  19. }
  20. return new LayerGroupResource( getContext(), request, response, catalog );
  21. }

代码示例来源:origin: org.geoserver/restconfig

  1. @Override
  2. public Resource findTarget(Request request, Response response) {
  3. String ws = getAttribute(request, "workspace");
  4. String cs = getAttribute(request, "coveragestore");
  5. //ensure referenced resources exist
  6. if ( ws != null && catalog.getWorkspaceByName( ws ) == null ) {
  7. throw new RestletException( "No such workspace: " + ws, Status.CLIENT_ERROR_NOT_FOUND );
  8. }
  9. if ( cs != null && catalog.getCoverageStoreByName(ws, cs) == null ) {
  10. throw new RestletException( "No such coverage store: " + ws + "," + cs, Status.CLIENT_ERROR_NOT_FOUND );
  11. }
  12. if ( cs == null && request.getMethod() == Method.GET ) {
  13. return new CoverageStoreListResource(getContext(),request,response,catalog);
  14. }
  15. return new CoverageStoreResource( null, request, response, catalog );
  16. }
  17. }

代码示例来源:origin: org.geowebcache/gwc-rest

  1. public void handle(Request request, Response response) {
  2. Method met = request.getMethod();
  3. try {
  4. if (met.equals(Method.GET)) {
  5. doGet(request, response);
  6. } else if (met.equals(Method.POST)) {
  7. try {
  8. doPost(request, response);
  9. } catch (GeoWebCacheException e) {
  10. throw new RestletException(e.getMessage(), Status.CLIENT_ERROR_BAD_REQUEST);
  11. }
  12. } else {
  13. throw new RestletException("Method not allowed",
  14. Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
  15. }
  16. } catch (RestletException re) {
  17. response.setEntity(re.getRepresentation());
  18. response.setStatus(re.getStatus());
  19. }
  20. }

相关文章