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: import java.util.LinkedList;
18:
19: import org.tmatesoft.svn.cli.SVNCommand;
20: import org.tmatesoft.svn.core.SVNCancelException;
21: import org.tmatesoft.svn.core.SVNException;
22: import org.tmatesoft.svn.core.wc.SVNEvent;
23: import org.tmatesoft.svn.core.wc.admin.ISVNAdminEventHandler;
24: import org.tmatesoft.svn.core.wc.admin.SVNAdminClient;
25: import org.tmatesoft.svn.core.wc.admin.SVNAdminEvent;
26: import org.tmatesoft.svn.core.wc.admin.SVNAdminEventAction;
27:
28: /**
29: * @version 1.1.1
30: * @author TMate Software Ltd.
31: * @since 1.1.1
32: */
33: public class SVNAdminRemoveTransactionsCommand extends SVNCommand
34: implements ISVNAdminEventHandler {
35: private PrintStream myOut;
36:
37: public void run(PrintStream out, PrintStream err)
38: throws SVNException {
39: if (!getCommandLine().hasPaths()) {
40: SVNCommand.println(out,
41: "svnadmin: Repository argument required");
42: System.exit(1);
43: }
44: File reposRoot = new File(getCommandLine().getPathAt(0));
45:
46: LinkedList txnNames = new LinkedList();
47: for (int i = 0; i < getCommandLine().getPathCount(); i++) {
48: txnNames.add(getCommandLine().getPathAt(i));
49: }
50:
51: String[] txns = (String[]) txnNames.toArray(new String[txnNames
52: .size()]);
53:
54: myOut = out;
55: SVNAdminClient adminClient = getClientManager()
56: .getAdminClient();
57: adminClient.setEventHandler(this );
58: adminClient.doRemoveTransactions(reposRoot, txns);
59: }
60:
61: public void run(InputStream in, PrintStream out, PrintStream err)
62: throws SVNException {
63: run(out, err);
64: }
65:
66: public void handleAdminEvent(SVNAdminEvent event, double progress)
67: throws SVNException {
68: if (event != null
69: && event.getAction() == SVNAdminEventAction.TRANSACTION_REMOVED) {
70: String txnName = event.getTxnName();
71: SVNCommand.println(myOut, "Transaction '" + txnName
72: + "' removed.");
73: }
74: }
75:
76: public void handleEvent(SVNEvent event, double progress)
77: throws SVNException {
78: }
79:
80: public void checkCancelled() throws SVNCancelException {
81: }
82:
83: }
|