Changeset 7302


Ignore:
Timestamp:
06/08/10 17:33:55 (9 years ago)
Author:
mnagni
Message:

Created an HarvestFactory? to isolate the specific harvest instance from the general code

Location:
RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/ModelManager.java

    r7301 r7302  
    124124         * @return an Harvester instance, otherwise <code>null</code>  
    125125         * */ 
    126         public Object getHarvesterConfiguration(int commonID){ 
    127                 Object ret = null; 
     126        public ProviderCommon getHarvesterConfiguration(int commonID){ 
     127                ProviderCommon ret = null; 
    128128                ret = getProvider(commonID, GET_OAI_PROVIDER); 
    129129                if (ret == null) 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/interfaces/ModelManagerLocal.java

    r7301 r7302  
    3838        public String getConfigurationParameter(String param); 
    3939         
    40         public Object getHarvesterConfiguration(int commonID); 
     40        public ProviderCommon getHarvesterConfiguration(int commonID); 
    4141} 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/interfaces/ModelManagerRemote.java

    r7301 r7302  
    3838        public String getConfigurationParameter(String parameterName); 
    3939         
    40         public Object getHarvesterConfiguration(int commonID); 
     40        public ProviderCommon getHarvesterConfiguration(int commonID); 
    4141         
    4242        public ProviderCommon getProviderCommon(int commonId); 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/harvest/ejb/HarvestRequestConsumer.java

    r7301 r7302  
    11package ndg.services.revitalization.harvest.ejb; 
    2  
    3 import java.io.File; 
    4 import java.util.Calendar; 
    52 
    63import javax.annotation.Resource; 
     
    1512import javax.jms.ObjectMessage; 
    1613 
    17 import ndg.common.NdgMessage; 
    1814import ndg.common.exception.NdgExecutionException; 
    19 import ndg.services.revitalization.dictionary.ServiceConfigurationParameter; 
     15import ndg.services.revitalization.HarvesterFactory; 
    2016import ndg.services.revitalization.ejb.interfaces.ModelManagerLocal; 
    2117import ndg.services.revitalization.exception.NdgHarvestNotExistingException; 
     
    2420import ndg.services.revitalization.harvest.Harvester; 
    2521import ndg.services.revitalization.harvest.ejb.interfaces.AsyncHarvesterLocal; 
    26 import ndg.services.revitalization.harvest.oai.OAIHarvestRequest; 
    27 import ndg.services.revitalization.harvest.oai.OAIHarvester; 
    28 import ndg.services.revitalization.jpa.OaiProvider; 
    29 import ndg.services.schemas.revitalization.DoHarvestRequest; 
    3022 
    3123@MessageDriven(activationConfig = { 
     
    6052         
    6153        private <T extends HarvestRequest> Harvester<T> getHarvester(DispatchedHarvestRequest request) throws NdgHarvestNotExistingException, NdgExecutionException { 
    62                 Harvester harvester = null; 
    63                 DoHarvestRequest doRequest = request.getDoHarvestRequest(); 
    64                 if (doRequest == null) 
    65                         throw new NdgHarvestNotExistingException(new NdgMessage("null.object", new Object[]{"DoHarvestRequest"})); 
    66                  
    67                 Object harvConfig = hmm.getHarvesterConfiguration(doRequest.getProviderID()); 
    68                 if (harvConfig instanceof OaiProvider) { 
    69                         OAIHarvestRequest harvesterReq = new OAIHarvestRequest((OaiProvider)harvConfig, doRequest); 
    70                         File tmpDir = new File(hmm.getConfigurationParameter(ServiceConfigurationParameter.HARVEST_ROOT_PATH.name()) + "/" + Long.toString(Calendar.getInstance().getTimeInMillis())); 
    71                         if (!tmpDir.mkdir()) 
    72                                 throw new NdgExecutionException(new NdgMessage("execution.error", new Object[] {"createNewFile()", "Cannot create " + tmpDir.getAbsolutePath()}, null)); 
    73                         harvesterReq.setOutdir(tmpDir.getAbsolutePath());                        
    74                         harvester = new OAIHarvester(harvesterReq, request.getHiProcess());                      
    75                 } 
    76  
    77                 // ADD HERE OTHER Harvester types 
    78                 /* 
    79                 if (harvConfig instanceof CSWProvider) { 
    80                         CSWHarvestRequest harvesterReq = new CSWHarvestRequest((CswProvider)harvConfig, doRequest); 
    81                         harvester = new CSWHarvester(harvesterReq);                      
    82                 } 
    83                 */ 
    84                  
    85                  
    86                 if (harvester == null) 
    87                         throw new NdgHarvestNotExistingException(new NdgMessage("no.object.with.id", new Object[]{"Harvester", doRequest.getProviderID()})); 
    88                  
    89                 return harvester; 
     54                return HarvesterFactory.getInstance().getHarvester(request); 
    9055        } 
    9156         
Note: See TracChangeset for help on using the changeset viewer.