View Javadoc

1   /**
2      This file is part of GoldenGate Project (named also GoldenGate or GG).
3   
4      Copyright 2009, Frederic Bregier, and individual contributors by the @author
5      tags. See the COPYRIGHT.txt in the distribution for a full listing of
6      individual contributors.
7   
8      All GoldenGate Project is free software: you can redistribute it and/or 
9      modify it under the terms of the GNU General Public License as published 
10     by the Free Software Foundation, either version 3 of the License, or
11     (at your option) any later version.
12  
13     GoldenGate is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU General Public License for more details.
17  
18     You should have received a copy of the GNU General Public License
19     along with GoldenGate .  If not, see <http://www.gnu.org/licenses/>.
20   */
21  package openr66.context.task;
22  
23  import goldengate.common.command.exception.CommandAbstractException;
24  import goldengate.common.logging.GgInternalLogger;
25  import goldengate.common.logging.GgInternalLoggerFactory;
26  import openr66.context.ErrorCode;
27  import openr66.context.R66Result;
28  import openr66.context.R66Session;
29  import openr66.protocol.exception.OpenR66ProtocolSystemException;
30  
31  /**
32   * Delete the file. The current file is no more valid.<br>
33   * No arguments are taken into account.
34   *
35   * @author Frederic Bregier
36   *
37   */
38  public class DeleteTask extends AbstractTask {
39      /**
40       * Internal Logger
41       */
42      private static final GgInternalLogger logger = GgInternalLoggerFactory
43              .getLogger(DeleteTask.class);
44  
45      /**
46       * @param argRule
47       * @param delay
48       * @param argTransfer
49       * @param session
50       */
51      public DeleteTask(String argRule, int delay, String argTransfer,
52              R66Session session) {
53          super(TaskType.DELETE, delay, argRule, argTransfer, session);
54      }
55  
56      /*
57       * (non-Javadoc)
58       *
59       * @see openr66.context.task.AbstractTask#run()
60       */
61      @Override
62      public void run() {
63          logger.info("Delete file from session {}",
64                  session);
65          try {
66              session.getFile().delete();
67          } catch (CommandAbstractException e1) {
68              logger.debug("CANNOT Delete file from session {}",
69                      session, e1);
70              R66Result result = new R66Result(session, false,
71                      ErrorCode.FileNotFound, session.getRunner());
72              futureCompletion.setResult(result);
73              futureCompletion.setFailure(new OpenR66ProtocolSystemException(e1));
74              return;
75          }
76          futureCompletion.setSuccess();
77      }
78  
79  }