@Queries({@Query(operationDescription=@Operation(description=SESSION_RESOURCE + SERVER_QUERY_ID + "."+ ID_QUERY_DESCRIPTION,errors={@ApiError(code=401,description=SESSION_RESOURCE + ERROR_401_DESCRIPTION)},parameters=@Parameter(name=KEYWORD_SERVER_ID,type="string",description=SESSION_RESOURCE + SERVER_QUERY_ID + "."+ ID_QUERY+ KEYWORD_SERVER_ID+ "."+ PARAMETER_DESCRIPTION)),type=QueryType.ID,id=SERVER_QUERY_ID),@Query(operationDescription=@Operation(description=SESSION_RESOURCE + ALL_QUERY_ID + "."+ ID_QUERY_DESCRIPTION,errors={@ApiError(code=401,description=SESSION_RESOURCE + ERROR_401_DESCRIPTION)}),type=QueryType.ID,id=ALL_QUERY_ID)}) public Promise<QueryResponse,ResourceException> queryCollection(Context context,QueryRequest request,QueryResourceHandler handler){
  String id=request.getQueryId();
  if (KEYWORD_LIST.equals(id)) {
    Collection<String> servers=generateListServers();
    LOGGER.message("SessionResource.queryCollection() :: Retrieved list of servers for query.");
    handler.handleResource(newResourceResponse(KEYWORD_LIST,String.valueOf(currentTimeMillis()),new JsonValue(servers)));
  }
 else {
    Collection<SessionInfo> sessions;
    if (KEYWORD_ALL.equals(id)) {
      sessions=sessionResourceUtil.generateAllSessions();
      LOGGER.message("SessionResource.queryCollection() :: Retrieved list of sessions for query.");
    }
 else {
      if (SERVER_QUERY_ID.equals(id)) {
        id=request.getAdditionalParameter(KEYWORD_SERVER_ID);
      }
      sessions=sessionResourceUtil.generateNamedServerSession(id);
      LOGGER.message("SessionResource.queryCollection() :: Retrieved list of specified servers for query.");
    }
    for (    SessionInfo session : sessions) {
      handler.handleResource(newResourceResponse("Sessions",String.valueOf(currentTimeMillis()),sessionResourceUtil.jsonValueOf(session)));
    }
  }
  return newResultPromise(newQueryResponse());
}

@ Queries ( { @ Query ( operationDescription = @ Operation ( description = SESSION_RESOURCE + SERVER_QUERY_ID + "." + ID_QUERY_DESCRIPTION , errors = { @ ApiError ( code = 401 , description = SESSION_RESOURCE + ERROR_401_DESCRIPTION ) } , parameters = @ Parameter ( name = KEYWORD_SERVER_ID , type = "string" , description = SESSION_RESOURCE + SERVER_QUERY_ID + "." + ID_QUERY + KEYWORD_SERVER_ID + "." + PARAMETER_DESCRIPTION ) ) , type = QueryType . ID , id = SERVER_QUERY_ID ) , @ Query ( operationDescription = @ Operation ( description = SESSION_RESOURCE + ALL_QUERY_ID + "." + ID_QUERY_DESCRIPTION , errors = { @ ApiError ( code = 401 , description = SESSION_RESOURCE + ERROR_401_DESCRIPTION ) } ) , type = QueryType . ID , id = ALL_QUERY_ID ) } ) public Promise < QueryResponse , ResourceException > queryCollection ( Context context , QueryRequest request , QueryResourceHandler handler ) { String id = request . getQueryId ( ) ; if ( KEYWORD_LIST . equals ( id ) ) { Collection < String > servers = generateListServers ( ) ; LOGGER . message ( "SessionResource.queryCollection() :: Retrieved list of servers for query." ) ; handler . handleResource ( newResourceResponse ( KEYWORD_LIST , String . valueOf ( currentTimeMillis ( ) ) , new JsonValue ( servers ) ) ) ; } else { Collection < SessionInfo > sessions ; if ( KEYWORD_ALL . equals ( id ) ) { sessions = sessionResourceUtil . generateAllSessions ( ) ; LOGGER . message ( "SessionResource.queryCollection() :: Retrieved list of sessions for query." ) ; } else { if ( SERVER_QUERY_ID . equals ( id ) ) { id = request . getAdditionalParameter ( KEYWORD_SERVER_ID ) ; } sessions = sessionResourceUtil . generateNamedServerSession ( id ) ; LOGGER . message ( "SessionResource.queryCollection() :: Retrieved list of specified servers for query." ) ; } for ( SessionInfo session : sessions ) { handler . handleResource ( newResourceResponse ( "Sessions" , String . valueOf ( currentTimeMillis ( ) ) , sessionResourceUtil . jsonValueOf ( session ) ) ) ; } } return newResultPromise ( newQueryResponse ( ) ) ; }
queries the session resources using one of the predefined query filters . all - ( default ) will query all sessions across all servers . list - will list the available servers which is useful for the next query [ server - id ] - will list the available sessions on the named server .
