Changeset 19352

Show
Ignore:
Timestamp:
08.05.2009 12:27:53 (10 years ago)
Author:
oranfry
Message:

fixed whitespace in this file

Files:
1 modified

Legend:

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

    r16688 r19352  
    4747 * The hub of a Greenstone system. 
    4848 * 
    49  * Accepts  XML requests (via process method of ModuleInterface) and routes them to the appropriate collection or 
    50  * service or external entity. 
     49 * Accepts XML requests (via process method of ModuleInterface) and routes them 
     50 * to the appropriate collection or service or external entity. 
    5151 * 
    5252 * contains a map of module objects - may be services, collections, comms 
     
    6161 * @see Communicator 
    6262 * 
    63  * Since some service classes are moved into a separate directory in order for them to be checked out from a different repository, 
    64  * we modify the configureServices method to search some of the classes in other place if they are not found in the service directory. 
     63 * Since some service classes are moved into a separate directory in order for 
     64 * them to be checked out from a different repository, we modify the 
     65 * configureServices method to search some of the classes in other place if they 
     66 * are not found in the service directory. 
    6567 */ 
    6668public class MessageRouter implements  ModuleInterface { 
     
    174176          // set up the authenticator 
    175177          Authenticator.setDefault(new Authenticator(){ 
    176           protected PasswordAuthentication getPasswordAuthentication(){ 
    177         return new PasswordAuthentication(user, new String(passwd).toCharArray()); 
    178           } 
    179         }); 
     178          protected PasswordAuthentication getPasswordAuthentication(){ 
     179            return new PasswordAuthentication(user, new String(passwd).toCharArray()); 
     180          } 
     181        }); 
    180182           
    181183        } catch (Exception e) { 
     
    263265        mainResult.appendChild(this.doc.importNode(result, true)); 
    264266      } else { 
    265     // The message needs to go to another module. The same message can  
    266     // be passed to multiple modules  - they will be in a comma  
    267     // separated list in the 'to' attribute 
     267        // The message needs to go to another module. The same message can  
     268        // be passed to multiple modules  - they will be in a comma  
     269        // separated list in the 'to' attribute 
    268270        String [] modules = path.split(","); 
    269271         
     
    311313  } 
    312314  public Element getCollectionList() { 
    313         return collection_list; 
     315    return collection_list; 
    314316  } 
    315317  public HashMap getModuleMap() { 
    316         return module_map; 
     318    return module_map; 
    317319  } 
    318320  // ******************************************************************** 
     
    327329      while (i.hasNext()) { 
    328330        ((ModuleInterface)i.next()).cleanUp(); 
    329     i.remove(); 
     331        i.remove(); 
    330332      } 
    331333    } 
     
    345347      String potential_site_name = GSPath.getFirstLink(name); 
    346348      if (remote_site != null) { 
    347     if (remote_site.equals(potential_site_name)) { 
    348       list.removeChild(item); 
    349     } 
     349        if (remote_site.equals(potential_site_name)) { 
     350          list.removeChild(item); 
     351        } 
    350352      } else { 
    351     if (name.equals(potential_site_name)) {// there was no site 
    352       list.removeChild(item); 
    353       ModuleInterface m = (ModuleInterface)this.module_map.remove(name); 
    354       m.cleanUp(); // clean up any open files/connections etc  
    355       m=null; 
    356     } 
    357       } 
    358     } 
    359              
    360     logger.error(this.converter.getString(list));        
    361          
     353        if (name.equals(potential_site_name)) {// there was no site 
     354          list.removeChild(item); 
     355          ModuleInterface m = (ModuleInterface)this.module_map.remove(name); 
     356          m.cleanUp(); // clean up any open files/connections etc  
     357          m=null; 
     358        } 
     359      } 
     360    } 
     361    logger.error(this.converter.getString(list)); 
    362362  } 
    363363 
     
    370370      String name = item.getAttribute(GSXML.NAME_ATT); 
    371371      // will remove the node from site_list 
    372       deactivateModule(GSXML.SITE_ELEM, name);       
    373     } 
    374      
    375   } 
     372      deactivateModule(GSXML.SITE_ELEM, name); 
     373    } 
     374 
     375  } 
     376 
    376377  /** read thru own site config file - create services and connect to sites 
    377378   */ 
    378379  protected boolean configureLocalSite() { 
    379      
     380 
    380381    // this may be a reconfigure, so clean up the old moduleMap 
    381382    cleanUpModuleMapEntire(); 
     
    449450      Class service_class = null; 
    450451      try { 
    451     service_class = Class.forName("org.greenstone.gsdl3.service."+service_name); 
     452        service_class = Class.forName("org.greenstone.gsdl3.service."+service_name); 
    452453      } catch(ClassNotFoundException e) { 
    453            
    454     try { 
    455       //try the service_name alone in case the package name is already specified 
    456       service_class = Class.forName(service_name); 
    457                
    458     }catch(ClassNotFoundException ae) { 
    459       logger.info(ae.getMessage()); 
    460     } 
     454        try { 
     455          //try the service_name alone in case the package name is already specified 
     456          service_class = Class.forName(service_name); 
     457        }catch(ClassNotFoundException ae) { 
     458          logger.info(ae.getMessage()); 
     459        } 
    461460      } 
    462461      try { 
    463            
    464         ServiceRack s = (ServiceRack)service_class.newInstance(); 
    465     s.setSiteHome(this.site_home); 
     462        ServiceRack s = (ServiceRack)service_class.newInstance(); 
     463        s.setSiteHome(this.site_home); 
    466464        s.setSiteAddress(this.site_http_address); 
    467     s.setLibraryName(this.library_name); 
     465        s.setLibraryName(this.library_name); 
    468466        s.setMessageRouter(this); 
    469467        // pass the XML node to the service for service configuration 
    470468        if (!s.configure(n, null)) { 
    471       logger.error ("couldn't configure ServiceRack "+service_name); 
    472       continue; 
    473     } 
     469          logger.error ("couldn't configure ServiceRack "+service_name); 
     470          continue; 
     471        } 
    474472         
    475473        // find out the supported services for this service module 
     
    520518      sc.setMessageRouter(this); 
    521519      if (!sc.configure(cluster)) { 
    522     logger.error ("couldn't configure ServiceCluster "+name); 
    523     continue; 
     520        logger.error ("couldn't configure ServiceCluster "+name); 
     521        continue; 
    524522      } 
    525523 
     
    603601        // only public collections will appear on the home page 
    604602        // add short description_ to collection_list_ 
    605     this.collection_list.appendChild(e); 
    606      
     603        this.collection_list.appendChild(e); 
     604 
    607605        if (c.hasOAI()) { 
    608606          Element ane = this.doc.createElement(GSXML.COLLECTION_ELEM); 
     
    616614         
    617615      } else { 
    618     this.private_collection_list.appendChild(e); 
     616        this.private_collection_list.appendChild(e); 
    619617      } 
    620618      return true; 
    621619    } else { 
    622620      logger.error("Couldn't configure collection: "+ 
    623            col_name+"."); 
     621        col_name+"."); 
    624622      return false; 
    625623    } 
     
    803801      // also remove the xml bit from description list 
    804802      if (type.equals(GSXML.COLLECTION_ELEM)) { 
    805     if (((Collection)m).isPublic()) {  
    806       Element this_col = GSXML.getNamedElement(this.collection_list, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name); 
    807       if (this_col != null) { 
    808         this.collection_list.removeChild(this_col); 
    809       } 
    810       if (((Collection)m).hasOAI()) { 
    811         this_col = GSXML.getNamedElement(this.oai_collection_list, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name); 
    812         if (this_col != null) { 
    813           this.oai_collection_list.removeChild(this_col); 
    814         } 
    815       } 
    816     } else { 
    817       // a private collection 
    818       Element this_col = GSXML.getNamedElement(this.private_collection_list, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name); 
    819       if (this_col != null) { 
    820         this.private_collection_list.removeChild(this_col); 
    821       }  
    822     } 
     803        if (((Collection)m).isPublic()) {  
     804          Element this_col = GSXML.getNamedElement(this.collection_list, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name); 
     805          if (this_col != null) { 
     806            this.collection_list.removeChild(this_col); 
     807          } 
     808          if (((Collection)m).hasOAI()) { 
     809            this_col = GSXML.getNamedElement(this.oai_collection_list, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name); 
     810            if (this_col != null) { 
     811              this.oai_collection_list.removeChild(this_col); 
     812            } 
     813          } 
     814        } else { 
     815          // a private collection 
     816          Element this_col = GSXML.getNamedElement(this.private_collection_list, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name); 
     817          if (this_col != null) { 
     818            this.private_collection_list.removeChild(this_col); 
     819          }  
     820        } 
    823821      } else if (type.equals(GSXML.SERVICE_ELEM)) { 
    824822        Element this_service = GSXML.getNamedElement(this.service_list, GSXML.SERVICE_ELEM, GSXML.NAME_ATT, name); 
     
    840838          cleanUpModuleMapSubset(this.cluster_list, name); 
    841839          cleanUpModuleMapSubset(this.service_list, name); 
    842        
    843       // can remote collections be in the oai_coll list, or private coll list ?? 
     840           
     841          // can remote collections be in the oai_coll list, or private coll list ?? 
    844842        } 
    845843      } else { 
    846844        logger.error("invalid module type: "+type+", can't remove info about this module"); 
    847       }  
     845      } 
    848846       
    849847      m.cleanUp(); // clean up any open files/connections etc - can cause trouble on windows 
     
    941939            // else it a specific request 
    942940            if (subset.equals(GSXML.COLLECTION_ELEM+GSXML.LIST_MODIFIER)) { 
    943           // get rid of all the old collection stuff (not counting remote ones) before activating all the new ones 
    944           cleanUpModuleMapSubset(this.collection_list, null); 
    945           cleanUpModuleMapSubset(this.private_collection_list, null); 
     941              // get rid of all the old collection stuff (not counting remote ones) before activating all the new ones 
     942              cleanUpModuleMapSubset(this.collection_list, null); 
     943              cleanUpModuleMapSubset(this.private_collection_list, null); 
    946944              success = configureCollections(); 
    947945            } else { 
     
    972970              } else if (subset.equals(GSXML.SITE_ELEM+GSXML.LIST_MODIFIER)) { 
    973971                Element site_list = (Element)GSXML.getChildByTagName(site_config_elem, GSXML.SITE_ELEM+GSXML.LIST_MODIFIER); 
    974         cleanUpAllExternalSiteInfo(); 
     972                cleanUpAllExternalSiteInfo(); 
    975973                success = configureExternalSites(site_list); 
    976974              } 
     
    993991          if (action.equals(GSXML.SYSTEM_TYPE_DEACTIVATE)) { 
    994992            success = deactivateModule(module_type, module_name); 
    995         if (success) { 
    996           Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, module_type+": "+module_name+" deactivated"); 
    997           response.appendChild(s); 
    998         } else { 
    999           Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, module_type+": "+module_name+" could not be deactivated"); 
    1000           response.appendChild(s); 
    1001         } 
     993            if (success) { 
     994              Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, module_type+": "+module_name+" deactivated"); 
     995              response.appendChild(s); 
     996            } else { 
     997              Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, module_type+": "+module_name+" could not be deactivated"); 
     998              response.appendChild(s); 
     999            } 
    10021000             
    10031001          } else if (action.equals(GSXML.SYSTEM_TYPE_ACTIVATE)) { 
    1004         // we need to deactivate the module first, in case this is a  
    1005         // reconfigure 
    1006         deactivateModule(module_type, module_name); 
     1002            // we need to deactivate the module first, in case this is a  
     1003            // reconfigure 
     1004            deactivateModule(module_type, module_name); 
    10071005            if (module_type.equals(GSXML.COLLECTION_ELEM)) { 
    10081006              success = activateCollectionByName(module_name);