1 package fr.in2p3.jsaga.impl.job.staging.mgr;
2
3 import fr.in2p3.jsaga.adaptor.job.control.staging.StagingJobAdaptorTwoPhase;
4 import fr.in2p3.jsaga.adaptor.job.control.staging.StagingTransfer;
5 import fr.in2p3.jsaga.impl.job.instance.AbstractSyncJobImpl;
6 import org.ogf.saga.error.*;
7 import org.ogf.saga.file.Directory;
8 import org.ogf.saga.file.FileFactory;
9 import org.ogf.saga.namespace.Flags;
10 import org.ogf.saga.url.URL;
11 import org.ogf.saga.url.URLFactory;
12
13
14
15
16
17
18
19
20
21
22
23
24
25 public class DataStagingManagerThroughSandboxTwoPhase extends DataStagingManagerThroughSandbox {
26 public DataStagingManagerThroughSandboxTwoPhase(StagingJobAdaptorTwoPhase adaptor, String uniqId) throws NotImplementedException, BadParameterException, NoSuccessException {
27 super(adaptor, uniqId);
28 }
29
30 public void preStaging(AbstractSyncJobImpl job, String nativeJobId) throws NotImplementedException, AuthenticationFailedException, AuthorizationFailedException, PermissionDeniedException, BadParameterException, DoesNotExistException, TimeoutException, IncorrectStateException, NoSuccessException {
31 StagingJobAdaptorTwoPhase adaptor = (StagingJobAdaptorTwoPhase) m_adaptor;
32
33
34 String stagingDir = adaptor.getStagingDirectory(nativeJobId);
35 if (stagingDir != null) {
36 URL url = URLFactory.createURL(JSAGA_FACTORY, stagingDir);
37 Directory dir = null;
38 try {
39 dir = FileFactory.createDirectory(JSAGA_FACTORY, job.getSession(), url, Flags.CREATE.getValue());
40 } catch (IncorrectURLException e) {
41 throw new NoSuccessException(e);
42 } catch (AlreadyExistsException e) {
43 throw new NoSuccessException(e);
44 }finally{
45 if(dir != null){
46 try{
47 dir.close();
48 }catch (Exception e) {
49
50 }
51 }
52 }
53 }
54
55
56 for (StagingTransfer transfer : adaptor.getInputStagingTransfer(nativeJobId)) {
57 transfer(job.getSession(), transfer);
58 }
59 }
60 }