Ignore:
Timestamp:
2007-06-29T13:22:35+12:00 (17 years ago)
Author:
xiao
Message:

add a method hasOAI() identifying itself whether it's serviceRackList contains the OAIPMH service rack; and a method returning the build time of the collection.

File:
1 edited

Legend:

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

    r13994 r14208  
    5252    /** is this collection public or private */
    5353    protected boolean is_public = true;
     54
     55    /** does this collection provide the OAI service */
     56    protected boolean has_oai = true;
     57    /** time when this collection was built */
     58    protected long lastmodified = 0;
     59
     60    /** An element containing the serviceRackList element of buildConfig.xml, used to determine whether it contains
     61     *  the OAIPMH serviceRack
     62     */
     63    protected Element service_rack_list = null;
     64   
    5465    protected XMLTransformer transformer = null;
    5566    /** same as setClusterName */
     
    93104    Element service_list = (Element)GSXML.getChildByTagName(build_config_xml, GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER);
    94105    configureServiceRack(service_list, coll_config_xml);
    95    
     106
     107  this.service_rack_list = service_list;
     108 
    96109    return true;
    97110   
     
    104117    public boolean isPublic() {
    105118    return is_public;
     119    }
     120    //used by the OAIReceptionist to find out the earliest datestamp amongst all oai collections in the repository
     121    public long getLastmodified() {
     122      return lastmodified;
     123    }
     124    /** whether the service_map in ServiceCluster.java contains the service 'OAIPMH'
     125     *  11/06/2007 xiao
     126     */
     127    public boolean hasOAI() {
     128      if (service_rack_list == null) return false; 
     129      Element oai_service_rack = GSXML.getNamedElement(service_rack_list, GSXML.SERVICE_CLASS_ELEM,
     130                            OAIXML.NAME, OAIXML.OAIPMH);
     131      if (oai_service_rack == null) {
     132        logger.info("No oai for collection: " + this.cluster_name);
     133        return false;
     134      }
     135      return true;//oai_service_rack == null;
    106136    }
    107137    /**
     
    141171        build_config_elem = build_config_doc.getDocumentElement();
    142172    }
     173 
     174  lastmodified = build_config_file.lastModified();
     175 
    143176    return build_config_elem;
    144177    }
     
    149182    protected boolean findAndLoadInfo(Element coll_config_xml,
    150183                      Element build_config_xml){
    151 
    152     // metadata
    153     Element meta_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
    154     addMetadata(meta_list);
    155     meta_list = (Element)GSXML.getChildByTagName(build_config_xml, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
    156     addMetadata(meta_list);
    157 
    158     meta_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
    159     GSXML.addMetadata(this.doc, meta_list, "httpPath", this.site_http_address+"/collect/"+this.cluster_name);
    160     addMetadata(meta_list);
    161 
    162     // display stuff
    163     Element display_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER);
    164     if (display_list != null) {
    165         resolveMacros(display_list);
    166         addDisplayItems(display_list);
    167     }
    168 
    169     //check whether the html are tidy or not
    170     Element import_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.IMPORT_ELEM);
    171     if (import_list != null) {
    172         Element plugin_list = (Element)GSXML.getChildByTagName(import_list, GSXML.PLUGIN_ELEM+GSXML.LIST_MODIFIER);
    173         addPlugins(plugin_list);
    174         if (plugin_list != null){
    175             Element plugin_elem = (Element)GSXML.getNamedElement(plugin_list, GSXML.PLUGIN_ELEM, GSXML.NAME_ATT, "HTMLPlug");
    176             if (plugin_elem != null) {
    177                 //get the option
    178                 Element option_elem = (Element)GSXML.getNamedElement(plugin_elem, GSXML.PARAM_OPTION_ELEM, GSXML.NAME_ATT, "-tidy_html");
    179                 if (option_elem != null) {
    180                     useBook = true;
    181                 }
    182             }
    183         }   
    184     }
    185     meta_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
    186     if (useBook == true)
    187         GSXML.addMetadata(this.doc, meta_list, "tidyoption", "tidy");
    188     else
    189         GSXML.addMetadata(this.doc, meta_list, "tidyoption", "untidy");
    190     addMetadata(meta_list);
    191    
    192     // check whether we are public or not
    193     if (meta_list != null) {
    194         Element meta_elem = (Element) GSXML.getNamedElement(metadata_list, GSXML.METADATA_ELEM, GSXML.NAME_ATT, "public");
    195         if (meta_elem != null) {
    196         String value = GSXML.getValue(meta_elem).toLowerCase().trim();
    197         if (value.equals("false")) {
    198             is_public = false;
    199         }
    200         }
    201     }
    202     return true;
     184     
     185      // metadata
     186      Element meta_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
     187      addMetadata(meta_list);
     188      meta_list = (Element)GSXML.getChildByTagName(build_config_xml, GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER);
     189      addMetadata(meta_list);
     190     
     191      meta_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
     192      GSXML.addMetadata(this.doc, meta_list, "httpPath", this.site_http_address+"/collect/"+this.cluster_name);
     193      addMetadata(meta_list);
     194     
     195      // display stuff
     196      Element display_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.DISPLAY_TEXT_ELEM+GSXML.LIST_MODIFIER);
     197      if (display_list != null) {
     198        resolveMacros(display_list);
     199        addDisplayItems(display_list);
     200      }
     201     
     202      //check whether the html are tidy or not
     203      Element import_list = (Element)GSXML.getChildByTagName(coll_config_xml, GSXML.IMPORT_ELEM);
     204      if (import_list != null) {
     205        Element plugin_list = (Element)GSXML.getChildByTagName(import_list, GSXML.PLUGIN_ELEM+GSXML.LIST_MODIFIER);
     206        addPlugins(plugin_list);
     207        if (plugin_list != null){
     208          Element plugin_elem = (Element)GSXML.getNamedElement(plugin_list, GSXML.PLUGIN_ELEM, GSXML.NAME_ATT, "HTMLPlug");
     209          if (plugin_elem != null) {
     210            //get the option
     211            Element option_elem = (Element)GSXML.getNamedElement(plugin_elem, GSXML.PARAM_OPTION_ELEM, GSXML.NAME_ATT, "-tidy_html");
     212            if (option_elem != null) {
     213              useBook = true;
     214            }
     215          }
     216        }
     217      }
     218      meta_list = this.doc.createElement(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER);
     219      if (useBook == true)
     220        GSXML.addMetadata(this.doc, meta_list, "tidyoption", "tidy");
     221      else
     222        GSXML.addMetadata(this.doc, meta_list, "tidyoption", "untidy");
     223      addMetadata(meta_list);
     224     
     225      // check whether we are public or not
     226      if (meta_list != null) {
     227        Element meta_elem = (Element) GSXML.getNamedElement(metadata_list, GSXML.METADATA_ELEM, GSXML.NAME_ATT, "public");
     228        if (meta_elem != null) {
     229          String value = GSXML.getValue(meta_elem).toLowerCase().trim();
     230          if (value.equals("false")) {
     231            is_public = false;
     232          }
     233        }
     234      }
     235      return true;
    203236
    204237    }
Note: See TracChangeset for help on using the changeset viewer.