View Javadoc

1   package fr.in2p3.jsaga.adaptor.data;
2   
3   import org.ogf.saga.error.AlreadyExistsException;
4   import org.ogf.saga.error.BadParameterException;
5   import org.ogf.saga.error.DoesNotExistException;
6   import org.ogf.saga.error.NoSuccessException;
7   import org.ogf.saga.error.PermissionDeniedException;
8   import org.ogf.saga.error.TimeoutException;
9   
10  import fr.in2p3.jsaga.adaptor.data.read.FileAttributes;
11  
12  /* ***************************************************
13   * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
14   * ***             http://cc.in2p3.fr/             ***
15   * ***************************************************
16   * File:   GsiftpDPMDataAdaptor
17   * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
18   * Date:   2 juil. 2009
19   * ***************************************************
20   * Description:                                      */
21  /**
22   * workaround for DPM
23   */
24  public class GsiftpDPMDataAdaptor extends Gsiftp2DataAdaptor {
25  
26      public String getType() {
27          return "gsiftp-dpm";
28      }
29  
30      
31      // DPM from version 1.8.8 writes an empty file in GridFTP probably at srmPrepareToPut, so if exclusive flag is
32      // used, the parent class will throw a "AlreadyExistException...
33      @Override
34      protected void checkExists(String absolutePath) throws AlreadyExistsException, NoSuccessException, PermissionDeniedException, BadParameterException, TimeoutException, ParentDoesNotExist {
35          try {
36              super.checkExists(absolutePath);
37          } catch (AlreadyExistsException aee) {
38              // The file has just been written by srmPrepareToPut and has a size of 0
39              try {
40                  FileAttributes fa = this.getAttributes(absolutePath, null);
41                  if (fa.getType() == FileAttributes.TYPE_FILE && fa.getSize() == 0) {
42                      return;
43                  } else {
44                      throw aee;
45                  }
46              } catch (DoesNotExistException e) {
47                  throw new ParentDoesNotExist(e);
48              }
49          }
50      }
51      
52  
53  }