01 /*
02 * SandboxEventHandler.java
03 * Copyright (c) 1998-2008, The University of Sheffield.
04 *
05 * This code is from the GATE project (http://gate.ac.uk/) and is free
06 * software licenced under the GNU General Public License version 3. It is
07 * distributed without any warranty. For more details see COPYING.txt in the
08 * top level directory (or at http://gatewiki.sf.net/COPYING.txt).
09 *
10 * Hamish Cunningham 8th January 2007
11 *
12 * Based on example code from SVNKit in the
13 * org.tmatesoft.svn.examples.wc
14 * package. Thanks TMate Software Ltd.
15 */
16 package gate.versioning.svnkit;
17
18 import org.tmatesoft.svn.core.wc.ISVNEventHandler;
19 import org.tmatesoft.svn.core.wc.SVNEvent;
20 import org.tmatesoft.svn.core.wc.SVNEventAction;
21
22 import org.apache.log4j.Logger;
23
24 /**
25 * This class is an implementation of ISVNEventHandler intended for processing
26 * events generated by do*() methods of an SVNWCClient object. An instance of
27 * this handler will be provided to an SVNWCClient. When calling, for example,
28 * SVNWCClient.doDelete(..) on some path, that method will generate an event for
29 * each 'delete' action it will perform upon every path being deleted. And this
30 * event is passed to
31 *
32 * ISVNEventHandler.handleEvent(SVNEvent event, double progress)
33 *
34 * to notify the handler. The event contains detailed information about the
35 * path, action performed upon the path and some other.
36 */
37 public class SandboxEventHandler extends SandboxCanceller implements ISVNEventHandler {
38 /** Logger. */
39 static Logger lgr = Logger.getLogger(SandboxEventHandler.class);
40
41 public SandboxEventHandler(Sandbox sandbox) {
42 super(sandbox);
43 }
44
45 /**
46 * progress is currently reserved for future purposes and now is always
47 * ISVNEventHandler.UNKNOWN
48 */
49 public void handleEvent(SVNEvent event, double progress) {
50 /*
51 * Gets the current action. An action is represented by SVNEventAction.
52 */
53 SVNEventAction action = event.getAction();
54 if(action == SVNEventAction.ADD) {
55 /*
56 * The item is scheduled for addition.
57 */
58 lgr.info("A " + event.getFile().getPath());
59 return;
60 } else if(action == SVNEventAction.COPY) {
61 /*
62 * The item is scheduled for addition with history (copied, in other
63 * words).
64 */
65 lgr.info("A + " + event.getFile().getPath());
66 return;
67 } else if(action == SVNEventAction.DELETE) {
68 /*
69 * The item is scheduled for deletion.
70 */
71 lgr.info("D " + event.getFile().getPath());
72 return;
73 } else if(action == SVNEventAction.LOCKED) {
74 /*
75 * The item is locked.
76 */
77 lgr.info("L " + event.getFile().getPath());
78 return;
79 } else if(action == SVNEventAction.LOCK_FAILED) {
80 /*
81 * Locking operation failed.
82 */
83 lgr.info("failed to lock " + event.getFile().getPath());
84 return;
85 }
86 }
87 }
|