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.ArrayList;
18: import java.util.Collection;
19:
20: import org.tmatesoft.svn.cli.SVNArgument;
21: import org.tmatesoft.svn.cli.SVNCommand;
22: import org.tmatesoft.svn.core.SVNException;
23: import org.tmatesoft.svn.core.SVNURL;
24: import org.tmatesoft.svn.core.wc.SVNWCClient;
25:
26: /**
27: * @version 1.1.1
28: * @author TMate Software Ltd.
29: */
30: public class SVNUnlockCommand extends SVNCommand {
31:
32: public void run(InputStream in, PrintStream out, PrintStream err)
33: throws SVNException {
34: run(out, err);
35: }
36:
37: public void run(PrintStream out, PrintStream err)
38: throws SVNException {
39: boolean force = getCommandLine().hasArgument(SVNArgument.FORCE);
40:
41: Collection files = new ArrayList();
42: for (int i = 0; i < getCommandLine().getPathCount(); i++) {
43: files.add(new File(getCommandLine().getPathAt(i)));
44: }
45: File[] filesArray = (File[]) files.toArray(new File[files
46: .size()]);
47: getClientManager().setEventHandler(
48: new SVNCommandEventProcessor(out, err, false));
49: SVNWCClient wcClient = getClientManager().getWCClient();
50: if (filesArray.length > 0) {
51: wcClient.doUnlock(filesArray, force);
52: }
53: files.clear();
54:
55: for (int i = 0; i < getCommandLine().getURLCount(); i++) {
56: files.add(getCommandLine().getURL(i));
57: }
58: String[] urls = (String[]) files.toArray(new String[files
59: .size()]);
60: SVNURL[] svnURLs = new SVNURL[urls.length];
61: for (int i = 0; i < urls.length; i++) {
62: svnURLs[i] = SVNURL.parseURIEncoded(urls[i]);
63: }
64: if (urls.length > 0) {
65: wcClient.doUnlock(svnURLs, force);
66: }
67: }
68:
69: }
|