org.opennms.web.rest
Class OnmsRestService

java.lang.Object
  extended by org.opennms.web.rest.OnmsRestService
Direct Known Subclasses:
AcknowledgmentRestService, AlarmRestService, AssetRecordResource, EventRestService, ForeignSourceRestService, GroupRestService, NodeRestService, NotificationRestService, OnmsCategoryResource, OnmsIpInterfaceResource, OnmsMapElementResource, OnmsMapRestService, OnmsMonitoredServiceResource, OnmsSnmpInterfaceResource, OutageRestService, RemotePollerAvailabilityService, RequisitionRestService, ScheduledOutagesRestService, SnmpConfigRestService, UserRestService

public class OnmsRestService
extends Object

OnmsRestService class.

Since:
1.8.1
Version:
$Id: $
Author:
ranger

Nested Class Summary
protected static class OnmsRestService.ComparisonOperation
           
 
Field Summary
protected static int DEFAULT_LIMIT
           
 
Constructor Summary
OnmsRestService()
          Constructor for OnmsRestService.
 
Method Summary
protected  void addFiltersToCriteria(javax.ws.rs.core.MultivaluedMap<String,String> params, OnmsCriteria criteria, Class<?> objectClass)
          Method to pull out all the named params in params and use them to add restriction filters to a criteria object.
protected  void addOrdering(javax.ws.rs.core.MultivaluedMap<String,String> params, OnmsCriteria criteria)
          Does ordering processing; pulled out to a separate method for visual clarity.
protected  void addOrdering(javax.ws.rs.core.MultivaluedMap<String,String> params, OnmsCriteria criteria, boolean addImmediately)
          Same as addOrdering() but you can say whether to add the order to the criteria object immediately.
static String convertNameToPropertyName(String name)
          Convert a column name with underscores to the corresponding property name using "camel case".
protected  OnmsCriteria getDistinctIdCriteria(Class<?> clazz, OnmsCriteria criteria)
          getDistinctIdCriteria
protected
<T> javax.ws.rs.WebApplicationException
getException(javax.ws.rs.core.Response.Status status, String msg)
          throwException
protected
<T> javax.ws.rs.WebApplicationException
getException(javax.ws.rs.core.Response.Status status, Throwable t)
           
protected  ThreadCategory log()
          log
protected  void setLimitOffset(javax.ws.rs.core.MultivaluedMap<String,String> params, OnmsCriteria criteria)
          Convenience for the other setLimitOffset method with the extra parameter, passing a default limit of 10
protected  void setLimitOffset(javax.ws.rs.core.MultivaluedMap<String,String> params, OnmsCriteria criteria, int defaultLimit)
          setLimitOffset
protected  void setLimitOffset(javax.ws.rs.core.MultivaluedMap<String,String> params, OnmsCriteria criteria, int defaultLimit, boolean addImmediately)
          Uses parameters in params to setup criteria with standard limit and offset parameters.
protected  void setProperties(MultivaluedMapImpl params, Object req)
          setProperties
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_LIMIT

protected static final int DEFAULT_LIMIT
See Also:
Constant Field Values
Constructor Detail

OnmsRestService

public OnmsRestService()

Constructor for OnmsRestService.

Method Detail

setLimitOffset

protected void setLimitOffset(javax.ws.rs.core.MultivaluedMap<String,String> params,
                              OnmsCriteria criteria)
Convenience for the other setLimitOffset method with the extra parameter, passing a default limit of 10

Parameters:
params - See other setLimitOffset
criteria - See other setLimitOffset

setLimitOffset

protected void setLimitOffset(javax.ws.rs.core.MultivaluedMap<String,String> params,
                              OnmsCriteria criteria,
                              int defaultLimit)

setLimitOffset

Parameters:
params - a MultivaluedMap object.
criteria - a OnmsCriteria object.
defaultLimit - a int.

setLimitOffset

protected void setLimitOffset(javax.ws.rs.core.MultivaluedMap<String,String> params,
                              OnmsCriteria criteria,
                              int defaultLimit,
                              boolean addImmediately)
Uses parameters in params to setup criteria with standard limit and offset parameters. If "limit" is in params, is used, otherwise default limit is used. If limit is 0, then no limit is set If "offset" is in params, is set as the offset into the result set In both cases, the limit and offset parameters are removed if found.

Parameters:
params - Set of parameters to look in for limit and offset
criteria - The Criteria that will be modified with the limit and offset
defaultLimit - A limit to use if none is specified in the params
addImmediately - a boolean.

addFiltersToCriteria

protected void addFiltersToCriteria(javax.ws.rs.core.MultivaluedMap<String,String> params,
                                    OnmsCriteria criteria,
                                    Class<?> objectClass)
Method to pull out all the named params in params and use them to add restriction filters to a criteria object. Uses the objectClass to determine parameters and types; auto converts from strings to appropriate types, if at all possible. Additionally, the param "comparator", if set, will change the comparision from the default of equality. Acceptable comparators are: "equals", "ilike", "like", "gt", "lt", "ge", "le", "ne" (other values will default to equality). If there is an "orderBy" param, results will be ordered by the property name given. Default is ascending, unless "order" is set to "desc" If there is a "query" param, it will be added to the criteria as a raw hibernate SQL statement (in addition to any other parameters specified The "criteria" object will be populated with the filter and ordering details provided

Parameters:
params - set of string parameters from which various configuration properties are extracted
criteria - the object which will be populated with the filter/ordering
objectClass - the type of thing being filtered.

addOrdering

protected void addOrdering(javax.ws.rs.core.MultivaluedMap<String,String> params,
                           OnmsCriteria criteria)
Does ordering processing; pulled out to a separate method for visual clarity. Configures ordering as defined in addFiltersToCriteria

Parameters:
params - - set of values to look in for the "order" and "orderBy" values
criteria - - the criteria object which will be updated with ordering configuration

addOrdering

protected void addOrdering(javax.ws.rs.core.MultivaluedMap<String,String> params,
                           OnmsCriteria criteria,
                           boolean addImmediately)
Same as addOrdering() but you can say whether to add the order to the criteria object immediately.

Parameters:
params - - set of values to look in for the "order" and "orderBy" values
criteria - - the criteria object which will be updated with ordering configuration
addImmediately - - whether to add immediately to the criteria object. Use "false" if you intend to build a joined/distinct criteria object using getDistinctIdCriteria(Class, OnmsCriteria), or "true" otherwise.

getException

protected <T> javax.ws.rs.WebApplicationException getException(javax.ws.rs.core.Response.Status status,
                                                               String msg)
                                                    throws javax.ws.rs.WebApplicationException

throwException

Type Parameters:
T - a T object.
Parameters:
status - a Response.Status object.
msg - a String object.
Returns:
a T object.
Throws:
javax.ws.rs.WebApplicationException

getException

protected <T> javax.ws.rs.WebApplicationException getException(javax.ws.rs.core.Response.Status status,
                                                               Throwable t)
                                                    throws javax.ws.rs.WebApplicationException
Throws:
javax.ws.rs.WebApplicationException

log

protected ThreadCategory log()

log

Returns:
a ThreadCategory object.

convertNameToPropertyName

public static String convertNameToPropertyName(String name)
Convert a column name with underscores to the corresponding property name using "camel case". A name like "customer_number" would match a "customerNumber" property name.

Parameters:
name - the column name to be converted
Returns:
the name using "camel case"

getDistinctIdCriteria

protected OnmsCriteria getDistinctIdCriteria(Class<?> clazz,
                                             OnmsCriteria criteria)

getDistinctIdCriteria

Parameters:
clazz - a Class object.
criteria - a OnmsCriteria object.
Returns:
a OnmsCriteria object.

setProperties

protected void setProperties(MultivaluedMapImpl params,
                             Object req)

setProperties

Parameters:
params - a MultivaluedMapImpl object.
req - a Object object.


Copyright © 2011. All Rights Reserved.