org.apache.stanbol.entityhub.jersey.utils
Class JerseyUtils

java.lang.Object
  extended by org.apache.stanbol.entityhub.jersey.utils.JerseyUtils

public final class JerseyUtils
extends java.lang.Object

Utility methods used by several of the RESTful service endpoints of the Entityhub.

Author:
Rupert Westenthaler

Field Summary
static java.util.Set<java.lang.String> ENTITY_SUPPORTED_MEDIA_TYPES
          Unmodifiable Set with the Media Types supported for Entity
static java.util.Set<java.lang.String> QUERY_RESULT_SUPPORTED_MEDIA_TYPES
          Unmodifiable Set with the Media Types supported for QueryResultList
static java.util.Set<java.lang.String> REPRESENTATION_SUPPORTED_MEDIA_TYPES
          Unmodifiable Set with the Media Types supported for Representation
 
Method Summary
static FieldQuery createFieldQueryForFindRequest(java.lang.String name, java.lang.String field, java.lang.String language, java.lang.Integer limit, java.lang.Integer offset, java.lang.String ldpath)
          Creates an FieldQuery for parameters parsed by the /find requests supported by the /symbol, /sites and {siteId} RESTful endpoints.
static java.util.Map<java.lang.String,java.lang.String> parseForm(java.io.InputStream entityStream, java.lang.String charset)
          This Method is intended to parse form data from MediaType.APPLICATION_FORM_URLENCODED requests.
static boolean testType(java.lang.Class<?> required, java.lang.reflect.Type genericType)
          Tests if a generic type (may be <?>, <? extends {required}> or <? super {required}>) is compatible with the required one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REPRESENTATION_SUPPORTED_MEDIA_TYPES

public static final java.util.Set<java.lang.String> REPRESENTATION_SUPPORTED_MEDIA_TYPES
Unmodifiable Set with the Media Types supported for Representation


ENTITY_SUPPORTED_MEDIA_TYPES

public static final java.util.Set<java.lang.String> ENTITY_SUPPORTED_MEDIA_TYPES
Unmodifiable Set with the Media Types supported for Entity


QUERY_RESULT_SUPPORTED_MEDIA_TYPES

public static final java.util.Set<java.lang.String> QUERY_RESULT_SUPPORTED_MEDIA_TYPES
Unmodifiable Set with the Media Types supported for QueryResultList

Method Detail

createFieldQueryForFindRequest

public static FieldQuery createFieldQueryForFindRequest(java.lang.String name,
                                                        java.lang.String field,
                                                        java.lang.String language,
                                                        java.lang.Integer limit,
                                                        java.lang.Integer offset,
                                                        java.lang.String ldpath)
                                                 throws javax.ws.rs.WebApplicationException,
                                                        java.lang.IllegalArgumentException
Creates an FieldQuery for parameters parsed by the /find requests supported by the /symbol, /sites and {siteId} RESTful endpoints. TODO: This has to be refactored to use "EntityQuery" as soon as Multiple query types are implemented for the Entityhub.

Parameters:
name - the name pattern to search entities for (required)
field - the field used to search for entities (required)
language - the language of the parsed name pattern (optional)
limit - the maximum number of result (optional)
offset - the offset of the first result (optional)
Returns:
the FieldQuery representing the parsed parameter
Throws:
javax.ws.rs.WebApplicationException - in case the parsed name pattern is invalid. The validation of this required parameter provided by the Request is done by this method.
java.lang.IllegalArgumentException - in case the parsed field is invalid. Callers of this method need to ensure that this parameter is set to an valid value.

testType

public static boolean testType(java.lang.Class<?> required,
                               java.lang.reflect.Type genericType)
Tests if a generic type (may be <?>, <? extends {required}> or <? super {required}>) is compatible with the required one. TODO: Should be moved to an utility class

Parameters:
required - the required class the generic type MUST BE compatible with
genericType - the required class
Returns:
if the generic type is compatible with the required class

parseForm

public static java.util.Map<java.lang.String,java.lang.String> parseForm(java.io.InputStream entityStream,
                                                                         java.lang.String charset)
                                                                  throws java.io.IOException
This Method is intended to parse form data from MediaType.APPLICATION_FORM_URLENCODED requests. This functionality us usually needed when writing a MessageBodyReader to get the data from the "InputStream entityStream" parameter of the MessageBodyReader.readFrom(Class, Type, java.lang.annotation.Annotation[], MediaType, javax.ws.rs.core.MultivaluedMap, InputStream) method.

Parameters:
entityStream - the stream with the form data
charset - The charset used for the request (if null or empty UTF-8 is used as default.
Returns:
the parsed form data as key value map
Throws:
java.io.IOException - on any exception while reading the data form the stream


Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.