org.apache.stanbol.contenthub.web.util
Class RestUtil
java.lang.Object
org.apache.stanbol.contenthub.web.util.RestUtil
public class RestUtil
- extends Object
Utility class for REST services
|
Method Summary |
static javax.ws.rs.core.Response |
createResponse(javax.servlet.ServletContext servletContext,
javax.ws.rs.core.Response.Status status,
Object entity,
javax.ws.rs.core.HttpHeaders headers)
Create a Response with the given parameters. |
static javax.ws.rs.core.MediaType |
getAcceptedMediaType(javax.ws.rs.core.HttpHeaders headers,
javax.ws.rs.core.MediaType defaultMediaType)
|
static boolean |
isHTMLaccepted(javax.ws.rs.core.HttpHeaders headers)
|
static boolean |
isJSONaccepted(javax.ws.rs.core.HttpHeaders headers)
|
static String |
nullify(String parameter)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
supportedMediaTypes
public static final Set<String> supportedMediaTypes
RestUtil
public RestUtil()
nullify
public static String nullify(String parameter)
- Parameters:
parameter - parameter to be checked
- Returns:
null if parameter has an empty content, otherwise trimmed parameter
isJSONaccepted
public static boolean isJSONaccepted(javax.ws.rs.core.HttpHeaders headers)
isHTMLaccepted
public static boolean isHTMLaccepted(javax.ws.rs.core.HttpHeaders headers)
getAcceptedMediaType
public static javax.ws.rs.core.MediaType getAcceptedMediaType(javax.ws.rs.core.HttpHeaders headers,
javax.ws.rs.core.MediaType defaultMediaType)
createResponse
public static javax.ws.rs.core.Response createResponse(javax.servlet.ServletContext servletContext,
javax.ws.rs.core.Response.Status status,
Object entity,
javax.ws.rs.core.HttpHeaders headers)
- Create a
Response with the given parameters. It also add the necessary headers for CORS by
calling the CorsHelper#addCORSOrigin(ServletContext, ResponseBuilder, HttpHeaders) method.
- Parameters:
servletContext - status - entity - headers -
- Returns:
Copyright © 2011-2013 The Apache Software Foundation. All Rights Reserved.