Changeset 36648


Ignore:
Timestamp:
2022-09-21T09:43:32+12:00 (10 days ago)
Author:
kjdon
Message:

made this a bit tidier. configure now gets the groupinfoservicename. we use that to determine whether to query MR for collection list, or the group service. if we are just querying mr, then add collectionlist param to main request - saves making another request for it later.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/action/PageAction.java

    r36641 r36648  
    55
    66import org.apache.log4j.Logger;
     7import org.greenstone.gsdl3.core.MessageRouter;
    78import org.greenstone.gsdl3.service.CollectionGroups;
    89import org.greenstone.gsdl3.util.GSParams;
     
    3132  protected String groupInfoServiceName = null;
    3233
     34  public boolean configure() {
     35
     36    // work out if we have a collection group service or not
     37      if (this.mr instanceof MessageRouter && ((MessageRouter)this.mr).pingModule(CollectionGroups.GROUP_CONTENT_SERVICE)) {
     38        this.groupInfoServiceName = CollectionGroups.GROUP_CONTENT_SERVICE;
     39      } else {
     40        this.groupInfoServiceName = "NO_GROUPS";
     41      }
     42     
     43
     44    return true;
     45  }
     46 
    3347  public Node process(Node message_node)
    3448   
     
    130144    }
    131145
    132     // is this collection part of a group?
    133     String group = (String) params.get(GSParams.GROUP);
    134     if (group != null && !group.equals("")) {
    135       // ...yes it is. get the group path info
    136       Element group_info_response = getGroupInfo(group, userContext);
    137       Element path_list = (Element) GSXML.getChildByTagName(group_info_response,
    138                                 GSXML.PATH_ELEM + GSXML.LIST_MODIFIER);
    139       if (path_list != null) {
    140     response.appendChild(response.getOwnerDocument().importNode(path_list, true));
    141       }
    142     }
    143 
    144146    if (page_name.equals(ABOUT_PAGE)) {
    145147      // get service descriptions. Actually only want displayItems, but get everything for now
     
    181183
    182184    UserContext userContext = new UserContext(request);
     185
     186
    183187    // first, get the message router info
    184188    Element info_message = doc.createElement(GSXML.MESSAGE_ELEM);
     
    187191    Element param_list_element = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    188192    info_request.appendChild(param_list_element);
    189     //Describe params without collectionlist. Collectionlist provided by CollectionGroup service
     193
    190194    GSXML.addParameterToList(param_list_element, GSXML.SUBSET_PARAM, GSXML.CLUSTER_ELEM + GSXML.LIST_MODIFIER);
    191195    GSXML.addParameterToList(param_list_element, GSXML.SUBSET_PARAM, GSXML.SERVICE_ELEM + GSXML.LIST_MODIFIER);
     
    193197    GSXML.addParameterToList(param_list_element, GSXML.SUBSET_PARAM, GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
    194198    GSXML.addParameterToList(param_list_element, GSXML.SUBSET_PARAM, GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER);
     199
     200    // are we using collection groups?
     201    // if not, get the coll list from MR
     202    if (this.groupInfoServiceName.equals ("NO_GROUPS")) {
     203      GSXML.addParameterToList(param_list_element, GSXML.SUBSET_PARAM, GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER);
     204    }
    195205    info_message.appendChild(info_request);
    196206    //Send request to message router
     
    221231    }
    222232
    223     // if we haven't done so already, check for group info type service
    224     if (this.groupInfoServiceName ==  null) {
    225       Element groupInfoService = GSXML.getNamedElement(resp_service_list, GSXML.SERVICE_ELEM, GSXML.NAME_ATT, CollectionGroups.GROUP_CONTENT_SERVICE);
    226          
    227       if (groupInfoService != null) {
    228     this.groupInfoServiceName = CollectionGroups.GROUP_CONTENT_SERVICE;
    229       } else {
    230     this.groupInfoServiceName = "NO_GROUPS";
    231       }
    232     }
    233  
     233    // if we are using the group service, get all the group info now
    234234    if (!this.groupInfoServiceName.equals("NO_GROUPS")) {
    235235      String group = null;
     
    265265      }
    266266         
    267     } else {
    268 
    269       //TODO: if no groups, then add the param into main request and get it with the other stuff.
    270       // don't need to do a separate request.
    271       // If no service with type SERVICE_TYPE_GROUPINFO could be provided
    272       // request message router for all available collections
    273       GSXML.addParameterToList(param_list_element, GSXML.SUBSET_PARAM,
    274                    GSXML.COLLECTION_ELEM + GSXML.LIST_MODIFIER);
    275       info_response_message = (Element) this.mr.process(info_message);
    276 
    277       if (info_response_message == null) {
    278     logger.error(" couldn't query the message router!");
    279     return null;
    280       }
    281       info_response = (Element) GSXML.getChildByTagName(info_response_message, GSXML.RESPONSE_ELEM);
    282       if (info_response == null) {
    283     logger.error("couldn't query the message router!");
    284     return null;
    285       }
    286267    }
    287268
Note: See TracChangeset for help on using the changeset viewer.