| 1 | 
    
            
    
     | 
    
      package org.kuali.maven.mojo.s3;     | 
  
            
  
    | 2 | 
    
            
    
     | 
    
           | 
  
            
  
    | 3 | 
    
            
    
     | 
    
      import static org.apache.commons.lang.StringUtils.leftPad;     | 
  
            
  
    | 4 | 
    
            
    
     | 
    
           | 
  
            
  
    | 5 | 
    
            
    
     | 
    
      import java.io.IOException;     | 
  
            
  
    | 6 | 
    
            
    
     | 
    
      import java.util.List;     | 
  
            
  
    | 7 | 
    
            
    
     | 
    
           | 
  
            
  
    | 8 | 
    
            
    
     | 
    
      import org.slf4j.Logger;     | 
  
            
  
    | 9 | 
    
            
    
     | 
    
      import org.slf4j.LoggerFactory;     | 
  
            
  
    | 10 | 
    
            
    
     | 
    
           | 
  
            
  
    | 11 | 
    
            
    
     | 
    
      import com.amazonaws.AmazonServiceException;     | 
  
            
  
    | 12 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 29 (29) | 
           Complexity: 8 | 
           Complexity Density: 0.4 | 
                        
            
        | 
    
  
  
    | 13 | 
    
            
    
     | 
    
      public class UpdateDirectoryThread implements Runnable {     | 
  
            
  
    | 14 | 
    
            
    
     | 
    
          final Logger logger = LoggerFactory.getLogger(UpdateDirectoryThread.class);     | 
  
            
  
    | 15 | 
    
            
    
     | 
    
           | 
  
            
  
    | 16 | 
    
            
    
     | 
    
          UpdateDirectoryThreadContext context;     | 
  
            
  
    | 17 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 18 | 
    
           0
    
     | 
    
           public UpdateDirectoryThread() {...     | 
  
            
  
    | 19 | 
    
           0
    
     | 
    
              this(null);     | 
  
            
  
    | 20 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 21 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 2 (2) | 
           Complexity: 1 | 
           Complexity Density: 0.5 | 
                        
            
        | 
    
  
  
    | 22 | 
    
           0
    
     | 
    
           public UpdateDirectoryThread(UpdateDirectoryThreadContext context) {...     | 
  
            
  
    | 23 | 
    
           0
    
     | 
    
              super();     | 
  
            
  
    | 24 | 
    
           0
    
     | 
    
              this.context = context;     | 
  
            
  
    | 25 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 26 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 19 (19) | 
           Complexity: 4 | 
           Complexity Density: 0.27 | 
                        
            
        | 
    
  
  
    | 27 | 
    
           0
    
     | 
    
           @Override...     | 
  
            
  
    | 28 | 
    
            
    
     | 
    
          public void run() {     | 
  
            
  
    | 29 | 
    
           0
    
     | 
    
              logger.debug("[Thread-" + context.getId() + "] Starting");     | 
  
            
  
    | 30 | 
    
           0
    
     | 
    
              int offset = context.getOffset();     | 
  
            
  
    | 31 | 
    
           0
    
     | 
    
              int length = context.getLength();     | 
  
            
  
    | 32 | 
    
           0
    
     | 
    
              List<UpdateDirectoryContext> list = context.getContexts();     | 
  
            
  
    | 33 | 
    
           0
    
     | 
    
              BucketUpdater updater = context.getUpdater();     | 
  
            
  
    | 34 | 
    
           0
    
     | 
    
              for (int i = offset; i < offset + length; i++) {     | 
  
            
  
    | 35 | 
    
           0
    
     | 
    
                  if (context.getHandler().isStopThreads()) {     | 
  
            
  
    | 36 | 
    
           0
    
     | 
    
                      break;     | 
  
            
  
    | 37 | 
    
            
    
     | 
    
                  }     | 
  
            
  
    | 38 | 
    
           0
    
     | 
    
                  UpdateDirectoryContext udc = list.get(i);     | 
  
            
  
    | 39 | 
    
           0
    
     | 
    
                  try {     | 
  
            
  
    | 40 | 
    
           0
    
     | 
    
                      updater.updateDirectory(udc);     | 
  
            
  
    | 41 | 
    
            
    
     | 
    
                  } catch (IOException e) {     | 
  
            
  
    | 42 | 
    
           0
    
     | 
    
                      throw new AmazonServiceException("Unexpected error", e);     | 
  
            
  
    | 43 | 
    
            
    
     | 
    
                  }     | 
  
            
  
    | 44 | 
    
           0
    
     | 
    
                  logger.debug(leftPad(context.getId() + "", 2, " ") + " - " + udc.getCopyToKey());     | 
  
            
  
    | 45 | 
    
           0
    
     | 
    
                  context.getTracker().increment();     | 
  
            
  
    | 46 | 
    
            
    
     | 
    
              }     | 
  
            
  
    | 47 | 
    
           0
    
     | 
    
              logger.debug("Thread " + context.getId() + " stopping");     | 
  
            
  
    | 48 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 49 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 50 | 
    
           0
    
     | 
    
           public UpdateDirectoryThreadContext getContext() {...     | 
  
            
  
    | 51 | 
    
           0
    
     | 
    
              return context;     | 
  
            
  
    | 52 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 53 | 
    
            
    
     | 
    
           | 
  
               
        | 
             
         | 
        
       
        | 
       
           
           
            | 0% | 
           Uncovered Elements: 1 (1) | 
           Complexity: 1 | 
           Complexity Density: 1 | 
                        
            
        | 
    
  
  
    | 54 | 
    
           0
    
     | 
    
           public void setContext(UpdateDirectoryThreadContext context) {...     | 
  
            
  
    | 55 | 
    
           0
    
     | 
    
              this.context = context;     | 
  
            
  
    | 56 | 
    
            
    
     | 
    
          }     | 
  
            
  
    | 57 | 
    
            
    
     | 
    
           | 
  
            
  
    | 58 | 
    
            
    
     | 
    
      }     |