Ignore:
Timestamp:
2022-09-20T11:33:23+12:00 (19 months ago)
Author:
kjdon
Message:

adding pathList into all pages, if not there already. - want to have group info present for breadcrumb display

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/DefaultReceptionist.java

    r32549 r36642  
    33import org.greenstone.gsdl3.util.*;
    44import org.greenstone.gsdl3.action.*;
     5import org.greenstone.gsdl3.service.CollectionGroups;
    56// XML classes
    67import org.w3c.dom.Node;
     
    1112// other java classes
    1213import java.io.File;
     14import java.io.Serializable;
    1315import java.util.HashMap;
    1416import java.util.Enumeration;
     
    2123
    2224    static Logger logger = Logger.getLogger(org.greenstone.gsdl3.core.DefaultReceptionist.class.getName());
     25
     26  // this gets set to the groupInfo service name if there is one.
     27  protected String groupInfoServiceName = null;
    2328
    2429    /**
     
    4954            return;
    5055        }
    51         Element coll_param = GSXML.getNamedElement(param_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT, GSParams.COLLECTION);
    52         if (coll_param == null)
     56                HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
     57                String coll_name = (String)params.get(GSParams.COLLECTION);
     58        if (coll_name == null)
    5359        {
    5460            logger.debug(" coll param is null, returning");
     
    5662        }
    5763
    58         // see if the collection/cluster element is already there
    59         String coll_name = coll_param.getAttribute(GSXML.VALUE_ATT);
    6064        UserContext userContext = new UserContext(page_request);
    6165
    6266        if (coll_name.equals(""))
    6367        {
    64             Element pc_param = GSXML.getNamedElement(param_list, GSXML.PARAM_ELEM, GSXML.NAME_ATT, "p.c");
    65             if (pc_param != null)
    66             {
    67                 coll_name = pc_param.getAttribute(GSXML.VALUE_ATT);
    68             }
     68                  coll_name = (String)params.get("p.c");
    6969        }
    7070
     
    110110        }
    111111       
     112                // have we got group param, and pathList??
     113                String group = (String)params.get(GSParams.GROUP);
     114                if (group != null && !group.equals("")) {
     115                  // ...yes we do. add group path info if not already present
     116                  Element path_list = (Element) GSXML.getChildByTagName(page_response, GSXML.PATH_ELEM + GSXML.LIST_MODIFIER);
     117                  if (path_list == null) {
     118                    // lets get it now
     119
     120                    Element group_info_response = getGroupInfo(group, userContext);
     121                    if (group_info_response != null) {
     122                      path_list = (Element) GSXML.getChildByTagName(group_info_response,GSXML.PATH_ELEM + GSXML.LIST_MODIFIER);
     123                      if (path_list != null) {
     124                        page_response.appendChild(doc.importNode(path_list, true));
     125                      }
     126                    }
     127                  }
     128                }
    112129
    113130        // have got a coll description
     
    195212        }
    196213    }
     214
     215  // copied from pageaction - put in a single place
     216    /** sends a request to GroupCurrentContent service to get group info. null group will give top level info,
     217      otherwise will just give info for specified group */
     218  protected Element getGroupInfo(String group, UserContext userContext) {
     219
     220    if (groupInfoServiceName == null) {
     221      // this is the first time we have come here, set this up
     222     
     223      if (this.mr instanceof MessageRouter && ((MessageRouter)this.mr).pingModule(CollectionGroups.GROUP_CONTENT_SERVICE)) {
     224        this.groupInfoServiceName = CollectionGroups.GROUP_CONTENT_SERVICE;
     225      } else {
     226        this.groupInfoServiceName = "NO_GROUPS";
     227      }
     228    }
     229    if (this.groupInfoServiceName.equals ("NO_GROUPS")) {
     230      return null;
     231    }
     232    // otherwise lets get the group info
     233    Document doc = XMLConverter.newDOM();
     234    // collections and groups list
     235    Element group_info_message = doc.createElement(GSXML.MESSAGE_ELEM);
     236    Element group_info_request = GSXML.createBasicRequest(doc, GSXML.TO_ATT, this.groupInfoServiceName, userContext);
     237    group_info_message.appendChild(group_info_request);
     238    if (group != null) {
     239      Element param_list = doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     240      GSXML.addParameterToList(param_list, GSParams.GROUP, group);
     241      group_info_request.appendChild(param_list);
     242    }
     243    // send off the request
     244    Element group_info_response_message = (Element) this.mr.process(group_info_message);
     245    Element group_info_response = (Element) GSXML.getChildByTagName(group_info_response_message, GSXML.RESPONSE_ELEM);
     246    return group_info_response;
     247  }
     248
    197249}
Note: See TracChangeset for help on using the changeset viewer.