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.SVNException;
20: import org.tmatesoft.svn.core.SVNLock;
21: import org.tmatesoft.svn.core.internal.util.SVNPathUtil;
22: import org.tmatesoft.svn.core.wc.admin.SVNLookClient;
23:
24: /**
25: * @version 1.1.1
26: * @author TMate Software Ltd.
27: * @since 1.1.1
28: */
29: public class SVNLookLockCommand extends SVNCommand {
30:
31: public void run(PrintStream out, PrintStream err)
32: throws SVNException {
33: if (!getCommandLine().hasPaths()) {
34: SVNCommand.println(err,
35: "jsvnlook: Repository argument required");
36: System.exit(1);
37: }
38: if (getCommandLine().getPathCount() < 2) {
39: SVNCommand.println(err, "jsvnlook: Missing path argument");
40: System.exit(1);
41: }
42: File reposRoot = new File(getCommandLine().getPathAt(0));
43: String path = SVNPathUtil.canonicalizeAbsPath(getCommandLine()
44: .getPathAt(1));
45:
46: SVNLookClient lookClient = getClientManager().getLookClient();
47: SVNLock lock = lookClient.doGetLock(reposRoot, path);
48: if (lock != null) {
49: String creationTime = SVNLookDateCommand.formatDate(lock
50: .getCreationDate());
51: String expirationTime = lock.getExpirationDate() != null ? SVNLookDateCommand
52: .formatDate(lock.getExpirationDate())
53: : "";
54: int commentLines = 0;
55: if (lock.getComment() != null) {
56: commentLines = getLinesCount(lock.getComment());
57: }
58: SVNCommand.println(out, "UUID Token: " + lock.getID());
59: SVNCommand.println(out, "Owner: " + lock.getOwner());
60: SVNCommand.println(out, "Created: " + creationTime);
61: SVNCommand.println(out, "Expires: " + expirationTime);
62: if (commentLines != 1) {
63: SVNCommand.println(out, "Comment (" + commentLines
64: + " lines):");
65: SVNCommand.println(out,
66: lock.getComment() != null ? lock.getComment()
67: : "");
68: } else {
69: SVNCommand.println(out, "Comment (" + commentLines
70: + " line):");
71: SVNCommand.println(out,
72: lock.getComment() != null ? lock.getComment()
73: : "");
74: }
75: }
76: }
77:
78: public void run(InputStream in, PrintStream out, PrintStream err)
79: throws SVNException {
80: run(out, err);
81: }
82:
83: }
|