| 1 | 
    
            
    
     | 
    
           | 
  
            
  
    | 2 | 
    
            
    
     | 
    
           | 
  
            
  
    | 3 | 
    
            
    
     | 
    
           | 
  
            
  
    | 4 | 
    
            
    
     | 
    
           | 
  
            
  
    | 5 | 
    
            
    
     | 
    
           | 
  
            
  
    | 6 | 
    
            
    
     | 
    
           | 
  
            
  
    | 7 | 
    
            
    
     | 
    
           | 
  
            
  
    | 8 | 
    
            
    
     | 
    
           | 
  
            
  
    | 9 | 
    
            
    
     | 
    
           | 
  
            
  
    | 10 | 
    
            
    
     | 
    
           | 
  
            
  
    | 11 | 
    
            
    
     | 
    
           | 
  
            
  
    | 12 | 
    
            
    
     | 
    
           | 
  
            
  
    | 13 | 
    
            
    
     | 
    
           | 
  
            
  
    | 14 | 
    
            
    
     | 
    
           | 
  
            
  
    | 15 | 
    
            
    
     | 
    
           | 
  
            
  
    | 16 | 
    
            
    
     | 
    
      package org.kuali.rice.kns.util;     | 
  
            
  
    | 17 | 
    
            
    
     | 
    
           | 
  
            
  
    | 18 | 
    
            
    
     | 
    
      import java.io.InputStream;     | 
  
            
  
    | 19 | 
    
            
    
     | 
    
      import java.util.ArrayList;     | 
  
            
  
    | 20 | 
    
            
    
     | 
    
      import java.util.List;     | 
  
            
  
    | 21 | 
    
            
    
     | 
    
           | 
  
            
  
    | 22 | 
    
            
    
     | 
    
      import org.apache.log4j.Logger;     | 
  
            
  
    | 23 | 
    
            
    
     | 
    
      import org.apache.ojb.broker.metadata.ConnectionRepository;     | 
  
            
  
    | 24 | 
    
            
    
     | 
    
      import org.apache.ojb.broker.metadata.DescriptorRepository;     | 
  
            
  
    | 25 | 
    
            
    
     | 
    
      import org.apache.ojb.broker.metadata.MetadataManager;     | 
  
            
  
    | 26 | 
    
            
    
     | 
    
      import org.kuali.rice.core.util.ClassLoaderUtils;     | 
  
            
  
    | 27 | 
    
            
    
     | 
    
      import org.springframework.beans.factory.InitializingBean;     | 
  
            
  
    | 28 | 
    
            
    
     | 
    
      import org.springframework.core.io.DefaultResourceLoader;     | 
  
            
  
    | 29 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 37 (37) | 
           Complexity: 9 | 
           Complexity Density: 0.32 | 
                        
            
        | 
    
  
  
    | 30 | 
    
            
    
     | 
    
      public class OjbMetadataLoader implements InitializingBean {     | 
  
            
  
    | 31 | 
    
            
    
     | 
    
               | 
  
            
  
    | 32 | 
    
            
    
     | 
    
          private static final Logger LOG = Logger.getLogger(OjbMetadataLoader.class);     | 
  
            
  
    | 33 | 
    
            
    
     | 
    
           | 
  
            
  
    | 34 | 
    
            
    
     | 
    
          private List<String> repositoryDescriptors = new ArrayList<String>();     | 
  
            
  
    | 35 | 
    
            
    
     | 
    
          private List<String> connectionDescriptors = new ArrayList<String>();      | 
  
            
  
    | 36 | 
    
            
    
     | 
    
               | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 37 | 
    
           0
    
     | 
    
           public List<String> getConnectionDescriptors() {...     | 
  
            
  
    | 38 | 
    
           0
    
     | 
    
              return connectionDescriptors;     | 
  
            
  
    | 39 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 40 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 41 | 
    
           0
    
     | 
    
           public void setConnectionDescriptors(List<String> connectionDescriptors) {...     | 
  
            
  
    | 42 | 
    
           0
    
     | 
    
              this.connectionDescriptors = connectionDescriptors;     | 
  
            
  
    | 43 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 44 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 45 | 
    
           0
    
     | 
    
           public List<String> getRepositoryDescriptors() {...     | 
  
            
  
    | 46 | 
    
           0
    
     | 
    
              return repositoryDescriptors;     | 
  
            
  
    | 47 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 48 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 49 | 
    
           0
    
     | 
    
           public void setRepositoryDescriptors(List<String> repositoryDescriptors) {...     | 
  
            
  
    | 50 | 
    
           0
    
     | 
    
              this.repositoryDescriptors = repositoryDescriptors;     | 
  
            
  
    | 51 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 52 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 28 (28) | 
           Complexity: 5 | 
           Complexity Density: 0.21 | 
                        
            
        | 
    
  
  
    | 53 | 
    
           0
    
     | 
    
           public void afterPropertiesSet() throws Exception {...     | 
  
            
  
    | 54 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 55 | 
    
           0
    
     | 
    
              MetadataManager mm = MetadataManager.getInstance();     | 
  
            
  
    | 56 | 
    
           0
    
     | 
    
              DefaultResourceLoader resourceLoader = new DefaultResourceLoader(ClassLoaderUtils.getDefaultClassLoader());     | 
  
            
  
    | 57 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 58 | 
    
           0
    
     | 
    
              for (String repositoryDescriptor : repositoryDescriptors) {     | 
  
            
  
    | 59 | 
    
           0
    
     | 
    
                  InputStream is = resourceLoader.getResource(repositoryDescriptor).getInputStream();     | 
  
            
  
    | 60 | 
    
           0
    
     | 
    
                  DescriptorRepository dr = mm.readDescriptorRepository(is);     | 
  
            
  
    | 61 | 
    
           0
    
     | 
    
                  mm.mergeDescriptorRepository(dr);     | 
  
            
  
    | 62 | 
    
           0
    
     | 
    
                  if (LOG.isDebugEnabled()) {     | 
  
            
  
    | 63 | 
    
           0
    
     | 
    
                      LOG.debug("--------------------------------------------------------------------------");     | 
  
            
  
    | 64 | 
    
           0
    
     | 
    
                      LOG.debug("Merging repository descriptor: " + repositoryDescriptor);     | 
  
            
  
    | 65 | 
    
           0
    
     | 
    
                      LOG.debug("--------------------------------------------------------------------------");     | 
  
            
  
    | 66 | 
    
            
    
     | 
    
                  }     | 
  
            
  
    | 67 | 
    
           0
    
     | 
    
                  try {     | 
  
            
  
    | 68 | 
    
           0
    
     | 
    
                      is.close();     | 
  
            
  
    | 69 | 
    
            
    
     | 
    
                  } catch (Exception e) {     | 
  
            
  
    | 70 | 
    
           0
    
     | 
    
                      LOG.warn("Failed to close stream to file " + repositoryDescriptor, e);     | 
  
            
  
    | 71 | 
    
            
    
     | 
    
                  }     | 
  
            
  
    | 72 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 73 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 74 | 
    
           0
    
     | 
    
              for (String connectionDesciptor : connectionDescriptors) {     | 
  
            
  
    | 75 | 
    
           0
    
     | 
    
                  InputStream is = resourceLoader.getResource(connectionDesciptor).getInputStream();     | 
  
            
  
    | 76 | 
    
           0
    
     | 
    
                  ConnectionRepository cr = mm.readConnectionRepository(is);     | 
  
            
  
    | 77 | 
    
           0
    
     | 
    
                  mm.mergeConnectionRepository(cr);     | 
  
            
  
    | 78 | 
    
           0
    
     | 
    
                  if (LOG.isDebugEnabled()) {     | 
  
            
  
    | 79 | 
    
           0
    
     | 
    
                      LOG.debug("--------------------------------------------------------------------------");     | 
  
            
  
    | 80 | 
    
           0
    
     | 
    
                      LOG.debug("Merging connection descriptor: " + connectionDesciptor);     | 
  
            
  
    | 81 | 
    
           0
    
     | 
    
                      LOG.debug("--------------------------------------------------------------------------");     | 
  
            
  
    | 82 | 
    
            
    
     | 
    
                  }     | 
  
            
  
    | 83 | 
    
           0
    
     | 
    
                  try {     | 
  
            
  
    | 84 | 
    
           0
    
     | 
    
                      is.close();     | 
  
            
  
    | 85 | 
    
            
    
     | 
    
                  } catch (Exception e) {     | 
  
            
  
    | 86 | 
    
           0
    
     | 
    
                      LOG.warn("Failed to close stream to file " + connectionDesciptor, e);     | 
  
            
  
    | 87 | 
    
            
    
     | 
    
                  }     | 
  
            
  
    | 88 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 89 | 
    
            
    
     | 
    
                   | 
  
            
  
    | 90 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 91 | 
    
            
    
     | 
    
           | 
  
            
  
    | 92 | 
    
            
    
     | 
    
      }     |