public static Response readLinksHandler ( ParaObject pobj , String id2 , String type2 , MultivaluedMap < String , String > params , Pager pager , boolean childrenOnly ) { try ( final Metrics . Context context = Metrics . time ( null , RestUtils . class , "links" , "read" ) ) { String query = params . getFirst ( "q" ) ; if ( type2 != null ) { if ( id2 != null ) { return Response . ok ( pobj . isLinked ( type2 , id2 ) , MediaType . TEXT_PLAIN_TYPE ) . build ( ) ; } else { List < ParaObject > items = new ArrayList <> ( ) ; if ( childrenOnly ) { if ( params . containsKey ( "count" ) ) { pager . setCount ( pobj . countChildren ( type2 ) ) ; } else { if ( params . containsKey ( "field" ) && params . containsKey ( "term" ) ) { items = pobj . getChildren ( type2 , params . getFirst ( "field" ) , params . getFirst ( "term" ) , pager ) ; } else { if ( StringUtils . isBlank ( query ) ) { items = pobj . getChildren ( type2 , pager ) ; } else { items = pobj . findChildren ( type2 , query , pager ) ; } } } } else { if ( params . containsKey ( "count" ) ) { pager . setCount ( pobj . countLinks ( type2 ) ) ; } else { if ( StringUtils . isBlank ( query ) ) { items = pobj . getLinkedObjects ( type2 , pager ) ; } else { items = pobj . findLinkedObjects ( type2 , params . getFirst ( "field" ) , query , pager ) ; } } } return Response . ok ( buildPageResponse ( items , pager ) ) . build ( ) ; } } else { return getStatusResponse ( Response . Status . BAD_REQUEST , "Parameter 'type' is missing." ) ; } } }
Handles requests to search for linked objects .