View Javadoc

1   package fr.in2p3.jsaga.adaptor.data;
2   
3   import java.io.IOException;
4   
5   import org.globus.ftp.exception.ServerException;
6   import org.ogf.saga.error.AlreadyExistsException;
7   import org.ogf.saga.error.BadParameterException;
8   import org.ogf.saga.error.DoesNotExistException;
9   import org.ogf.saga.error.NoSuccessException;
10  import org.ogf.saga.error.PermissionDeniedException;
11  import org.ogf.saga.error.TimeoutException;
12  
13  /* ***************************************************
14  * *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
15  * ***             http://cc.in2p3.fr/             ***
16  * ***************************************************
17  * File:   GsiftpDCacheDataAdaptor
18  * Author: Sylvain Reynaud (sreynaud@in2p3.fr)
19  * Date:   2 nov. 2007
20  * ***************************************************
21  * Description:                                      */
22  /**
23   *
24   */
25  public class GsiftpStoRMDataAdaptor extends Gsiftp2DataAdaptor {
26      public String getType() {
27          return "gsiftp-storm";
28      }
29  
30      protected void checkExists(String absolutePath) throws AlreadyExistsException, NoSuccessException, PermissionDeniedException, BadParameterException, TimeoutException, ParentDoesNotExist {
31          boolean exists;
32          try {
33              exists = m_client.exists(absolutePath);
34          } catch (Exception e) {
35              try {
36                  throw rethrowExceptionFull(e);
37              } catch (DoesNotExistException e1) {
38                  throw new ParentDoesNotExist(e);
39              }
40          }
41          if (exists) {
42          	/*
43          	 * The StoRM PrepareToPut does create empty file
44          	 * So, the "exists" method return true
45          	 * If the file is empty, do not throw AlreadyExistsException
46          	 */
47          	try {
48  				if (m_client.getSize(absolutePath) > 0)
49  					throw new AlreadyExistsException("File already exists: "+absolutePath);
50  			} catch (ServerException e) {
51  				throw new NoSuccessException(e);
52  			} catch (IOException e) {
53  				throw new NoSuccessException(e);
54  			}
55          }
56      }
57      
58  
59      
60  }