Search in sources :

Example 1 with RequestedServiceTypeType

use of com.sun.identity.liberty.ws.disco.jaxb.QueryType.RequestedServiceTypeType in project OpenAM by OpenRock.

the class DiscoEntryHandlerImplUtils method getQueryResults.

/*
     * Finds the matching resource offering according to RequestedServiceType.
     * Used by <code>DiscoEntryHandler</code>s.
     *
     * @param discoEntries all discovery entries
     * @param reqServiceTypes List of requested service types
     * @return Map of matching discovery entries. In this map,
     *  key is <code>entryId</code>, value is <code>DiscoEntryElement</code>.
     */
public static Map getQueryResults(Map discoEntries, List reqServiceTypes) {
    Map results = null;
    if ((reqServiceTypes == null) || (reqServiceTypes.size() == 0)) {
        if (debug.messageEnabled()) {
            debug.message("DiscoEntryHandlerImplUtils.getQueryResults: " + "no reqServiceTypes");
        }
        results = discoEntries;
    } else {
        results = new HashMap();
        Iterator i = discoEntries.keySet().iterator();
        while (i.hasNext()) {
            String curKey = (String) i.next();
            DiscoEntryElement cur = (DiscoEntryElement) discoEntries.get(curKey);
            ResourceOfferingType offering = cur.getResourceOffering();
            String serviceType = offering.getServiceInstance().getServiceType();
            List options = null;
            if (offering.getOptions() != null) {
                options = offering.getOptions().getOption();
            }
            Iterator j = reqServiceTypes.iterator();
            while (j.hasNext()) {
                RequestedServiceTypeType curReqType = (RequestedServiceTypeType) j.next();
                String requestedServiceType = curReqType.getServiceType();
                if (!requestedServiceType.equals(serviceType)) {
                    continue;
                }
                List queryOptions = null;
                if (curReqType.getOptions() != null) {
                    queryOptions = curReqType.getOptions().getOption();
                }
                if (evaluateOptionsRules(queryOptions, options)) {
                    /* code for proxy support
                        if (proxyServiceTypes.contains(serviceType)) {
                            if (this cur is that proxy) {
                                results.add(cur);
                            } else if (requester is the provider) {
                                results.add(cur);
                            }
                        } else {
                            results.add(cur);
                        }
                        */
                    results.put(curKey, cur);
                    break;
                }
            }
        }
    }
    return results;
}
Also used : RequestedServiceTypeType(com.sun.identity.liberty.ws.disco.jaxb.QueryType.RequestedServiceTypeType) HashMap(java.util.HashMap) Iterator(java.util.Iterator) ResourceOfferingType(com.sun.identity.liberty.ws.disco.jaxb.ResourceOfferingType) LinkedList(java.util.LinkedList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map) DiscoEntryElement(com.sun.identity.liberty.ws.disco.plugins.jaxb.DiscoEntryElement)

Aggregations

RequestedServiceTypeType (com.sun.identity.liberty.ws.disco.jaxb.QueryType.RequestedServiceTypeType)1 ResourceOfferingType (com.sun.identity.liberty.ws.disco.jaxb.ResourceOfferingType)1 DiscoEntryElement (com.sun.identity.liberty.ws.disco.plugins.jaxb.DiscoEntryElement)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1