01: /*
02: * ====================================================================
03: * Copyright (c) 2004-2008 TMate Software Ltd. All rights reserved.
04: *
05: * This software is licensed as described in the file COPYING, which
06: * you should have received as part of this distribution. The terms
07: * are also available at http://svnkit.com/license.html.
08: * If newer versions of this license are posted there, you may use a
09: * newer version instead, at your option.
10: * ====================================================================
11: */
12: package org.tmatesoft.svn.cli.command;
13:
14: import java.io.File;
15: import java.io.InputStream;
16: import java.io.PrintStream;
17:
18: import org.tmatesoft.svn.cli.SVNCommand;
19: import org.tmatesoft.svn.core.SVNCancelException;
20: import org.tmatesoft.svn.core.SVNException;
21: import org.tmatesoft.svn.core.wc.SVNEvent;
22: import org.tmatesoft.svn.core.wc.admin.ISVNAdminEventHandler;
23: import org.tmatesoft.svn.core.wc.admin.SVNAdminClient;
24: import org.tmatesoft.svn.core.wc.admin.SVNAdminEvent;
25: import org.tmatesoft.svn.core.wc.admin.SVNAdminEventAction;
26:
27: /**
28: * @version 1.1.2
29: * @author TMate Software Ltd.
30: * @since 1.1.2
31: */
32: public class SVNAdminRemoveLocksCommand extends SVNCommand implements
33: ISVNAdminEventHandler {
34: private PrintStream myOut;
35:
36: public void run(PrintStream out, PrintStream err)
37: throws SVNException {
38: if (!getCommandLine().hasPaths()) {
39: SVNCommand.println(out,
40: "svnadmin: Repository argument required");
41: System.exit(1);
42: }
43: File reposRoot = new File(getCommandLine().getPathAt(0));
44: String[] paths = new String[getCommandLine().getPathCount() - 1];
45: for (int i = 1; i < getCommandLine().getPathCount() - 1; i++) {
46: paths[i] = getCommandLine().getPathAt(i);
47: }
48:
49: myOut = out;
50: SVNAdminClient adminClient = getClientManager()
51: .getAdminClient();
52: adminClient.setEventHandler(this );
53: adminClient.doRemoveLocks(reposRoot, paths);
54: }
55:
56: public void run(InputStream in, PrintStream out, PrintStream err)
57: throws SVNException {
58: run(out, err);
59: }
60:
61: public void handleAdminEvent(SVNAdminEvent event, double progress)
62: throws SVNException {
63: if (event != null) {
64: if (event.getAction() == SVNAdminEventAction.UNLOCKED
65: || event.getAction() == SVNAdminEventAction.NOT_LOCKED
66: || event.getAction() == SVNAdminEventAction.UNLOCK_FAILED) {
67: SVNCommand.println(myOut, event.getMessage());
68: }
69: }
70: }
71:
72: public void checkCancelled() throws SVNCancelException {
73: }
74:
75: public void handleEvent(SVNEvent event, double progress)
76: throws SVNException {
77: }
78:
79: }
|