Changeset 37614


Ignore:
Timestamp:
2023-04-06T16:54:00+12:00 (13 months ago)
Author:
kjdon
Message:

now looks for a ccServices element (cross collection) - and stores its format elements. if the coll gets a format request come in, with a service attribute, it looks up that service name to see if there is a format element for it, and returns it if there is.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection/Collection.java

    r34154 r37614  
    8989    protected ArrayList<HashMap<String, ArrayList<String>>> _securityExceptions = new ArrayList<HashMap<String, ArrayList<String>>>();
    9090
     91  protected HashMap<String, Element> _ccServiceFormats = new HashMap<String, Element>();
    9192    protected XMLTransformer transformer = null;
    9293
     
    161162        this.description.setAttribute(GSXML.DB_TYPE_ATT, db_type);
    162163
    163         _globalFormat = (Element) GSXML.getChildByTagName(coll_config_xml, GSXML.FORMAT_ELEM);
    164164        // process the metadata and display items and default library params
    165165        super.configureLocalData(coll_config_xml);
    166166        super.configureLocalData(build_config_xml);
     167               
    167168        // get extra collection specific stuff
     169                _globalFormat = (Element) GSXML.getChildByTagName(coll_config_xml, GSXML.FORMAT_ELEM);
     170                loadCCServiceFormats(coll_config_xml);
     171
    168172        findAndLoadInfo(coll_config_xml, build_config_xml);
    169173
     
    309313    }
    310314
     315  protected void loadCCServiceFormats(Element coll_config_xml) {
     316
     317    Element ccservice = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.CC_SERVICES_ELEM);
     318    if (ccservice == null) return;
     319    NodeList format_elems = GSXML.getChildrenByTagName(ccservice, GSXML.FORMAT_ELEM);
     320    for (int i = 0; i < format_elems.getLength(); i++)
     321    {
     322      Element child = (Element)format_elems.item(i);
     323      String service_name = child.getAttribute(GSXML.SERVICE_ATT);
     324      if (!service_name.equals("")) {
     325        _ccServiceFormats.put(service_name, child);
     326      }
     327    }
     328  }
    311329    protected void loadSecurityInformation(Element coll_config_xml)
    312330    {
     
    489507    {
    490508        String type = request.getAttribute(GSXML.TYPE_ATT);
     509
    491510        if (type.equals(GSXML.REQUEST_TYPE_FORMAT_STRING))
    492511        {
     
    499518        else if (type.equals(GSXML.REQUEST_TYPE_FORMAT))
    500519        {
    501 
    502             Element response = result_doc.createElement(GSXML.RESPONSE_ELEM);
    503             response.setAttribute(GSXML.FROM_ATT, this.cluster_name);
    504             response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_FORMAT);
    505             if (_globalFormat != null)
    506             {
    507                 response.appendChild(result_doc.importNode(_globalFormat, true));
    508             }
    509             return response;
     520                  Element response = result_doc.createElement(GSXML.RESPONSE_ELEM);
     521                  response.setAttribute(GSXML.FROM_ATT, this.cluster_name);
     522                  response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_FORMAT);
     523       
     524                  // if we have a service arg, return format for that service - if any
     525                  String service_name = request.getAttribute(GSXML.SERVICE_ATT);
     526                  if (!service_name.equals("")) {
     527                    Element this_format = _ccServiceFormats.get(service_name);
     528                    if (this_format != null) {
     529                      response.appendChild(result_doc.importNode(this_format, true));
     530                    }
     531                    return response; // if a service_name was specified, return
     532                      // the format, or empty response
     533                  }
     534                 
     535                  // no service_name specified, return global format
     536                  if (_globalFormat != null)
     537                  {
     538                    response.appendChild(result_doc.importNode(_globalFormat, true));
     539                  }
     540                  return response;
    510541        }
    511542        // unknown type
Note: See TracChangeset for help on using the changeset viewer.