Changeset 7469


Ignore:
Timestamp:
09/09/10 14:29:06 (9 years ago)
Author:
mnagni
Message:

Better management of the error messages.
Fixed a bug on the processs status advance

Location:
RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization
Files:
7 edited

Legend:

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

    r7360 r7469  
    3434        DO_INGEST_PROCESS_TERMINATED_EMAIL, 
    3535        /** Mail message to be sent when an process fails */     
    36         PROCESS_FAILED_EMAIL 
     36        PROCESS_FAILED_EMAIL, 
     37        /** Mail message to be sent when an process is unavailable */    
     38        PROCESS_UNAVAILABLE_EMAIL 
    3739} 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/AsyncProcessManager.java

    r7465 r7469  
    5353                try { 
    5454                        EJBBeanFactory.getModelManager().updateHarvestingLogAndStatus(hiProcess, null); 
    55                         MailHelper.getInstance().sentProcessFailedMail(hiProcess, formatError(hiProcess.getId(), ex.getMessage())); 
     55                        MailHelper.getInstance().sentProcessFailedMail(hiProcess, formatError(hiProcess.getId(), ex)); 
    5656                } catch (NdgExecutionException e) { 
    5757                        e.printStackTrace(); 
     
    5959        } 
    6060         
    61         private String formatError(int processID, String msg) throws NdgExecutionException { 
     61        private String formatError(int processID, NdgExecutionException ex) throws NdgExecutionException { 
    6262                String failedMsg = EJBBeanFactory.getModelManager().getConfigurationParameter( 
    6363                                ServiceConfigurationParameter.PROCESS_FAILED_EMAIL); 
     64                MessageFormatter mf = new MessageFormatter(); 
     65                String msg = ex.getBundlMessage() != null ? mf.getFormattedText(ex.getBundlMessage()) : ex.getMessage(); 
    6466                return MessageFormatter.getFormattedText(failedMsg, new Object[] {processID, msg}); 
    6567        } 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/ModelManager.java

    r7465 r7469  
    162162 
    163163        @TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW) 
    164         public void updateHarvestingLogAndStatus(HiProcess hiProcess, HarvestLog harvestLog) { 
     164        public HiProcess updateHarvestingLogAndStatus(HiProcess hiProcess, HarvestLog harvestLog) { 
    165165                        // set the process's status to run_harvest 
    166                         processModel.advanceStatus(hiProcess); 
     166                        hiProcess = processModel.advanceStatus(hiProcess); 
    167167                        if (harvestLog == null) 
    168                                 return; 
     168                                return hiProcess; 
    169169                         
    170170                        HarvestLog existingLog = em.find(HarvestLog.class, harvestLog.getReqId()); 
     
    174174                                em.merge(harvestLog); 
    175175                        } 
     176                        return hiProcess; 
    176177        } 
    177178 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/interfaces/ModelManagerLocal.java

    r7393 r7469  
    2929        public List<String> getServiceParameterNamesValues(String parName); 
    3030         
    31         public void updateHarvestingLogAndStatus(HiProcess hiProcess, HarvestLog harvestLog); 
     31        public HiProcess updateHarvestingLogAndStatus(HiProcess hiProcess, HarvestLog harvestLog); 
    3232         
    3333        public List<HarvestLog> getHarvestLog(List<Integer> processIds); 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/ejb/interfaces/ModelManagerRemote.java

    r7393 r7469  
    5353         * @param harvestLog the log harvesting file  
    5454         **/ 
    55         public void updateHarvestingLogAndStatus(HiProcess hiProcess, HarvestLog harvestLog); 
     55        public HiProcess updateHarvestingLogAndStatus(HiProcess hiProcess, HarvestLog harvestLog); 
    5656         
    5757        /** 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/executor/IngesterImpl.java

    r7465 r7469  
    1717 
    1818import ndg.common.MessageFormatter; 
     19import ndg.common.NdgMessage; 
    1920import ndg.common.StreamReader; 
    2021import ndg.common.exception.NdgExecutionException; 
     
    6970 
    7071                        hiProcess = getHiProcess(); 
     72                        //in future a StatePattern could be better 
     73                        if (!hiProcess.getHiStatus().getId().equals("end_harv")) { 
     74                                String msg = EJBBeanFactory.getModelManager().getConfigurationParameter(ServiceConfigurationParameter.PROCESS_UNAVAILABLE_EMAIL); 
     75                                throw new NdgExecutionException(new NdgMessage(msg, new Object[] {hiProcess.getId(), hiProcess.getHiStatus().getId()}, null));   
     76                        } 
     77                         
    7178                        String formattedCmd = MessageFormatter.getFormattedText(cmd, new Object[] {ingestRequest.getProcessID() }); 
    7279                        manageSystemCall(formattedCmd); 
  • RevitalizationWS/ws/DPWS/trunk/src/main/java/ndg/services/revitalization/harvest/HarvesterBase.java

    r7465 r7469  
    4444        private final T request; 
    4545         
    46         private final HiProcess hiProcess; 
     46        private HiProcess hiProcess; 
    4747         
    4848        private final HarvestResult harvestResult = new HarvestResult(); 
     
    6767                        doHarvest();     
    6868                        harvestLog = finalizeHarvesting();                       
    69                         EJBBeanFactory.getModelManager().updateHarvestingLogAndStatus(hiProcess, harvestLog);            
     69                        hiProcess = EJBBeanFactory.getModelManager().updateHarvestingLogAndStatus(hiProcess, harvestLog);                
    7070                        MailHelper.getInstance().terminatedHarvestMail(getHiProcess());                  
    7171                } catch (NdgExecutionException ex) { 
    7272                        //in future a StatePattern could be better 
    7373                        getHiProcess().getHiStatus().setId("failed_harv"); 
    74                         throw new NdgExecutionException(ex); 
     74                        if (ex.getBundlMessage() == null) 
     75                                throw new NdgExecutionException(ex); 
     76                         
     77                        throw new NdgExecutionException(ex.getBundlMessage()); 
    7578                } 
    7679        } 
     
    8588                harvestLog.setStartHarvest(new Timestamp(Calendar.getInstance().getTimeInMillis())); 
    8689                getHarvestResult().setStartTime(harvestLog.getStartHarvest()); 
    87                 EJBBeanFactory.getModelManager().updateHarvestingLogAndStatus(hiProcess, harvestLog); 
     90                hiProcess = EJBBeanFactory.getModelManager().updateHarvestingLogAndStatus(hiProcess, harvestLog); 
    8891        } 
    8992         
Note: See TracChangeset for help on using the changeset viewer.