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 SVNLockCommand 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: String message = (String) getCommandLine().getArgumentValue(
41: SVNArgument.MESSAGE);
42: getClientManager().setEventHandler(
43: new SVNCommandEventProcessor(out, err, false));
44: SVNWCClient wcClient = getClientManager().getWCClient();
45:
46: Collection files = new ArrayList();
47: for (int i = 0; i < getCommandLine().getPathCount(); i++) {
48: files.add(new File(getCommandLine().getPathAt(i)));
49: }
50: File[] filesArray = (File[]) files.toArray(new File[files
51: .size()]);
52: if (filesArray.length > 0) {
53: wcClient.doLock(filesArray, force, message);
54: }
55: files.clear();
56:
57: for (int i = 0; i < getCommandLine().getURLCount(); i++) {
58: files.add(getCommandLine().getURL(i));
59: }
60: String[] urls = (String[]) files.toArray(new String[files
61: .size()]);
62: SVNURL[] svnURLs = new SVNURL[urls.length];
63: for (int i = 0; i < urls.length; i++) {
64: svnURLs[i] = SVNURL.parseURIEncoded(urls[i]);
65: }
66: if (urls.length > 0) {
67: wcClient.doLock(svnURLs, force, message);
68: }
69: }
70: }
|