本文整理了Java中org.restlet.data.Request.getMethod
方法的一些代码示例,展示了Request.getMethod
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getMethod
方法的具体详情如下:
包路径:org.restlet.data.Request
类名称:Request
方法名:getMethod
[英]Returns the method.
[中]返回方法。
代码示例来源:origin: org.restlet/org.restlet
/**
* Returns the method.
*
* @return The method.
*/
@Override
public Method getMethod() {
return getWrappedRequest().getMethod();
}
代码示例来源:origin: org.geoserver/restconfig
@Override
public Resource findTarget(Request request, Response response) {
if (!(request.getMethod() == Method.POST || request.getMethod() == Method.PUT)) {
response.setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
return null;
代码示例来源:origin: org.restlet/org.restlet
/**
* 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();
}
代码示例来源:origin: org.geowebcache/gwc-rest
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);
}
}
代码示例来源:origin: org.geowebcache/gwc-rest
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);
}
}
代码示例来源:origin: org.sonatype.nexus/nexus-test-harness-launcher
@Override
public HttpClientCall create(Request request) {
HttpClientCall result = null;
try {
result = new Hc4MethodCall(this, request.getMethod().toString(),
request.getResourceRef().toString(), request
.isEntityAvailable());
}
catch (IOException ioe) {
getLogger().log(Level.WARNING,
"Unable to create the HTTP client call", ioe);
}
return result;
}
代码示例来源:origin: org.geowebcache/gwc-rest
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();
}
}
代码示例来源:origin: org.geoserver/restconfig
@Override
public Resource findTarget(Request request, Response response) {
String workspace = getAttribute(request, "workspace");
if ( workspace == null && request.getMethod() == Method.GET ) {
return new WorkspaceListResource( null, request, response, catalog );
}
if ( workspace != null ) {
//ensure it exists
if ( catalog.getWorkspaceByName( workspace ) == null ) {
throw new RestletException( "No such workspace: " + workspace, Status.CLIENT_ERROR_NOT_FOUND );
}
}
return new WorkspaceResource( null, request, response, catalog );
}
代码示例来源:origin: org.restlet/org.restlet.ext.httpclient
/**
* Creates a low-level HTTP client call from a high-level uniform call.
*
* @param request
* The high-level request.
* @return A low-level HTTP client call.
*/
@Override
public HttpClientCall create(Request request) {
HttpClientCall result = null;
try {
result = new HttpMethodCall(this, request.getMethod().toString(),
request.getResourceRef().toString(), request
.isEntityAvailable());
} catch (IOException ioe) {
getLogger().log(Level.WARNING,
"Unable to create the HTTP client call", ioe);
}
return result;
}
代码示例来源:origin: org.geoserver/restconfig
@Override
public Resource findTarget(Request request, Response response) {
String ws = (String) request.getAttributes().get( "workspace" );
String wms = (String) request.getAttributes().get( "wmsstore" );
//ensure referenced resources exist
if ( ws != null && catalog.getWorkspaceByName(ws) == null) {
throw new RestletException( "No such workspace: " + ws, Status.CLIENT_ERROR_NOT_FOUND );
}
if ( wms != null && catalog.getStoreByName(ws, wms, WMSStoreInfo.class) == null) {
throw new RestletException( "No such wms store: " + ws + "," + wms, Status.CLIENT_ERROR_NOT_FOUND );
}
if ( wms == null && request.getMethod() == Method.GET ) {
return new WMSStoreListResource(getContext(),request,response,catalog);
}
return new WMSStoreResource( null, request, response, catalog );
}
代码示例来源:origin: org.geoserver/restconfig
@Override
public Resource findTarget(Request request, Response response) {
String layer = getAttribute(request, "layer");
if ( layer == null && request.getMethod() == Method.GET ) {
return new LayerListResource(getContext(),request,response,catalog);
}
//ensure referenced resources exist
if ( layer != null && catalog.getLayerByName(layer) == null ) {
throw new RestletException( "No such layer: " + layer, Status.CLIENT_ERROR_NOT_FOUND );
}
return new LayerResource(null,request,response,catalog);
}
代码示例来源:origin: org.geoserver/restconfig
@Override
public Resource findTarget(Request request, Response response) {
String namespace = getAttribute(request, "namespace");
if ( namespace == null && request.getMethod() == Method.GET ) {
return new NamespaceListResource( getContext(), request, response, catalog );
}
if ( namespace != null ) {
//ensure it exists
if ( catalog.getNamespaceByPrefix( namespace ) == null ) {
throw new RestletException( "No such namespace: " + namespace, Status.CLIENT_ERROR_NOT_FOUND );
}
}
return new NamespaceResource( null, request, response, catalog );
}
代码示例来源:origin: org.geoserver/restconfig
@Override
public Resource findTarget(Request request, Response response) {
String ws = getAttribute(request, "workspace");
String ds = getAttribute(request, "datastore");
//ensure referenced resources exist
if ( ws != null && catalog.getWorkspaceByName(ws) == null) {
throw new RestletException( "No such workspace: " + ws, Status.CLIENT_ERROR_NOT_FOUND );
}
if ( ds != null && catalog.getDataStoreByName(ws, ds) == null && !"default".equals(ds)) {
throw new RestletException( "No such datastore: " + ws + "," + ds, Status.CLIENT_ERROR_NOT_FOUND );
}
if ( ds == null && request.getMethod() == Method.GET ) {
return new DataStoreListResource(getContext(),request,response,catalog);
}
return new DataStoreResource( null, request, response, catalog );
}
代码示例来源:origin: org.geowebcache/gwc-rest
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());
}
}
代码示例来源:origin: org.geowebcache/gwc-rest
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);
}
}
代码示例来源:origin: org.geoserver/xslt
@Override
public Resource findTarget(Request request, Response response) {
String transform = RESTUtils.getAttribute(request, "transform");
// if it's not referencing a particular transform, return the list
if (transform == null && request.getMethod() == Method.GET) {
return new TransformListResource(getContext(), request, response, repository);
}
// ensure referenced transform exist
try {
if (transform != null && repository.getTransformInfo(transform) == null) {
throw new RestletException("No such transform: " + transform,
Status.CLIENT_ERROR_NOT_FOUND);
}
} catch (IOException e) {
throw new RestletException("An error occurred while trying to locate the transform: "
+ transform, Status.SERVER_ERROR_INTERNAL, e);
}
// return the specific resource
return new TransformResource(null, request, response, repository, catalog);
}
代码示例来源:origin: org.geowebcache/gwc-rest
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);
}
}
代码示例来源:origin: org.geoserver/restconfig
@Override
public Resource findTarget(Request request, Response response) {
String ws = getAttribute(request, "workspace");
String lg = getAttribute(request, "layergroup");
if (ws != null && catalog.getWorkspaceByName(ws) == null) {
throw new RestletException("No such workspace: " + ws, Status.CLIENT_ERROR_NOT_FOUND);
}
if ( lg != null) {
if (ws != null && catalog.getLayerGroupByName( ws, lg ) == null) {
throw new RestletException(String.format("No such layer group %s in workspace %s",
lg, ws), Status.CLIENT_ERROR_NOT_FOUND );
}
if (ws == null && catalog.getLayerGroupByName( lg ) == null) {
throw new RestletException( "No such layer group " + lg, Status.CLIENT_ERROR_NOT_FOUND );
}
}
if ( lg == null && request.getMethod() == Method.GET ) {
return new LayerGroupListResource( getContext(), request, response, catalog );
}
return new LayerGroupResource( getContext(), request, response, catalog );
}
代码示例来源:origin: org.geoserver/restconfig
@Override
public Resource findTarget(Request request, Response response) {
String ws = getAttribute(request, "workspace");
String cs = getAttribute(request, "coveragestore");
//ensure referenced resources exist
if ( ws != null && catalog.getWorkspaceByName( ws ) == null ) {
throw new RestletException( "No such workspace: " + ws, Status.CLIENT_ERROR_NOT_FOUND );
}
if ( cs != null && catalog.getCoverageStoreByName(ws, cs) == null ) {
throw new RestletException( "No such coverage store: " + ws + "," + cs, Status.CLIENT_ERROR_NOT_FOUND );
}
if ( cs == null && request.getMethod() == Method.GET ) {
return new CoverageStoreListResource(getContext(),request,response,catalog);
}
return new CoverageStoreResource( null, request, response, catalog );
}
}
代码示例来源:origin: org.geowebcache/gwc-rest
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)) {
try {
doPost(request, response);
} catch (GeoWebCacheException e) {
throw new RestletException(e.getMessage(), Status.CLIENT_ERROR_BAD_REQUEST);
}
} else {
throw new RestletException("Method not allowed",
Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
}
} catch (RestletException re) {
response.setEntity(re.getRepresentation());
response.setStatus(re.getStatus());
}
}
内容来源于网络,如有侵权,请联系作者删除!