Changeset 28984


Ignore:
Timestamp:
2014-04-17T13:13:28+12:00 (10 years ago)
Author:
kjdon
Message:

made a new OAICollection class. Inherits from Collection. ALll OAI stuff is taken out of Collection and put in new class. OAICollection is a much simpler collection as it only loads in OAIPMH service rack, not any of the others. This will be used by new OAIMessageRouter instead of Collection

Location:
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/collection
Files:
1 added
1 edited

Legend:

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

    r28966 r28984  
    6969    /** database type : gdbm, jdbm or sqlite */
    7070    protected String db_type = "";
    71 
    72     /** does this collection provide the OAI service */
    73     protected boolean has_oai = false;
    74     /** time when this collection was built */
     71    /** time when this collection was built Used by RSS */
    7572    protected long lastmodified = 0;
    76     /** earliestDatestamp of this collection. Necessary for OAI */
    77     protected long earliestDatestamp = 0;
     73    /** earliestDatestamp of this collection. Used by OAI/RSS */
     74        protected long earliestDatestamp = 0;
    7875
    7976    /** Stores the default accessibility of guest users */
     
    174171    }
    175172
    176     // Used by OAI Receptionist to determine whether to expire a resumption token - if a token was issued before a collection is rebuilt, then the token must be expired.
     173    // Used by OAI Receptionist and RSSRetrieve
    177174    public long getLastmodified()
    178175    {
     
    180177    }
    181178
    182     // used by the OAIReceptionist to find out the earliest datestamp amongst all oai collections in the repository
     179    // used by the OAIReceptionist and RSSRetrieve
    183180    public long getEarliestDatestamp()
    184181    {
    185182        return earliestDatestamp;
    186     }
    187 
    188     /**
    189      * whether the service_map in ServiceCluster.java contains the service
    190      * 'OAIPMH' 11/06/2007 xiao
    191      */
    192     public boolean hasOAI()
    193     {
    194         return has_oai;
    195183    }
    196184
     
    248236    protected boolean findAndLoadInfo(Element coll_config_xml, Element build_config_xml)
    249237    {
    250         // Element meta_list = (Element) GSXML.getChildByTagName(coll_config_xml, GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
    251         // addMetadata(meta_list);
    252         // meta_list = (Element) GSXML.getChildByTagName(build_config_xml, GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
    253         // addMetadata(meta_list);
    254         addMetadata("httpPath", this.site_http_address + "/collect/" + this.cluster_name);
    255 
    256         // display stuff
    257         // Element display_list = (Element) GSXML.getChildByTagName(coll_config_xml, GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER);
    258         // if (display_list != null)
    259         // {
    260         //  resolveMacros(display_list);
    261         //  addDisplayItems(display_list);
    262         // }
     238      addMetadata("httpPath", this.site_http_address + "/collect/" + this.cluster_name);
     239
    263240
    264241        //check whether the html are tidy or not
     
    285262        addMetadata("tidyoption", tidy);
    286263
    287         // check whether we are public or not
     264       
    288265        if (this.metadata_list != null)
    289266        {
     267          // check whether we are public or not
    290268            Element meta_elem = (Element) GSXML.getNamedElement(this.metadata_list, GSXML.METADATA_ELEM, GSXML.NAME_ATT, "public");
    291269            if (meta_elem != null)
     
    297275                }
    298276            }
     277            // earliest datestamp is the time the collection was created.
     278            meta_elem = (Element) GSXML.getNamedElement(this.metadata_list, GSXML.METADATA_ELEM, GSXML.NAME_ATT, OAIXML.EARLIEST_DATESTAMP);
     279            if (meta_elem != null) {
     280              String earliestDatestampStr = GSXML.getValue(meta_elem);
     281              if (!earliestDatestampStr.equals("")) {
     282                  earliestDatestamp = Long.parseLong(earliestDatestampStr) * 1000; // stored in seconds, convert to milliseconds
     283              }
     284            }
     285       
    299286        }
    300287        return true;
     
    393380        clearServices();
    394381        Element service_list = (Element) GSXML.getChildByTagName(build_config_xml, GSXML.SERVICE_CLASS_ELEM + GSXML.LIST_MODIFIER);
    395         Element oai_service_rack = null;
    396382        if (service_list != null)
    397383        {
    398384            configureServiceRackList(service_list, coll_config_xml);
    399             oai_service_rack = GSXML.getNamedElement(service_list, GSXML.SERVICE_CLASS_ELEM, GSXML.NAME_ATT, OAIXML.OAIPMH);
    400385        }
    401386        // collection Config may also contain manually added service racks
     
    404389        {
    405390            configureServiceRackList(service_list, build_config_xml);
    406             // this oai used in preference to one in buildConfig.xml
    407             oai_service_rack = GSXML.getNamedElement(service_list, GSXML.SERVICE_CLASS_ELEM, GSXML.NAME_ATT, OAIXML.OAIPMH);
    408         }
    409         // Check for oai
    410 
    411         if (oai_service_rack != null)
    412         {
    413             has_oai = true;
    414             logger.info(this.cluster_name + " has OAI services");
    415             // extract earliestDatestamp from the buildconfig.xml for OAI
    416             Element metadata_list = (Element) GSXML.getChildByTagName(build_config_xml, GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
    417 
    418             if (metadata_list != null)
    419             {
    420                 NodeList children = metadata_list.getElementsByTagName(GSXML.METADATA_ELEM);
    421                 // can't do getChildNodes(), because whitespace, such as newlines, creates Text nodes
    422                 for (int i = 0; i < children.getLength(); i++)
    423                 {
    424                     Element metadata = (Element) children.item(i);
    425                     if (metadata.getAttribute(GSXML.NAME_ATT).equals(OAIXML.EARLIEST_DATESTAMP))
    426                     {
    427                         String earliestDatestampStr = GSXML.getValue(metadata);
    428                         if (!earliestDatestampStr.equals(""))
    429                         {
    430                           earliestDatestamp = Long.parseLong(earliestDatestampStr) * 1000; // stored in seconds, convert to milliseconds
    431                            
    432                         }
    433                         break; // found a metadata element with name=earliestDatestamp in buildconfig
    434                     }
    435                 }
    436             }
    437 
    438             // If at the end of this, there is no value for earliestDatestamp, print out a warning
    439             logger.warn("No earliestDatestamp in buildConfig.xml for collection: " + this.cluster_name + ". Defaulting to 0.");
    440 
    441         } // if oai_service_rack != null
    442 
     391        }
    443392        return true;
    444393    }
Note: See TracChangeset for help on using the changeset viewer.