Log in Help
Print
Homegatewikicowtestintegrationorgtmatesoftsvnexampleswc 〉 InfoHandler.java
 
/*
 * ====================================================================
 * Copyright (c) 2004-2006 TMate Software Ltd.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://svnkit.com/license.html
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 * ====================================================================
 */
package org.tmatesoft.svn.examples.wc;

import org.apache.log4j.Logger;

import org.tmatesoft.svn.core.SVNNodeKind;
import org.tmatesoft.svn.core.wc.ISVNInfoHandler;
import org.tmatesoft.svn.core.wc.SVNInfo;

/*
 * An implementation of ISVNInfoHandler that is  used  in  WorkingCopy.java  to 
 * display  info  on  a  working  copy path.  This implementation is passed  to
 * 
 * SVNWCClient.doInfo(File path, SVNRevision revision, boolean recursive, 
 * ISVNInfoHandler handler) 
 * 
 * For each item to be processed doInfo(..) collects information and creates an 
 * SVNInfo which keeps that information. Then  doInfo(..)  calls  implementor's 
 * handler.handleInfo(SVNInfo) where it passes the gathered info.
 */
public class InfoHandler implements ISVNInfoHandler {
    static Logger lgr = Logger.getLogger(InfoHandler.class);

    /*
     * This is an implementation  of  ISVNInfoHandler.handleInfo(SVNInfo info).
     * Just prints out information on a Working Copy path in the manner of  the
     * native SVN command line client.
     */
    public void handleInfo(SVNInfo info) {
        lgr.info("-----------------INFO-----------------");
        lgr.info("Local Path: " + info.getFile().getPath());
        lgr.info("URL: " + info.getURL());
        if (info.isRemote() && info.getRepositoryRootURL() != null) {
            lgr.info("Repository Root URL: "
                    + info.getRepositoryRootURL());
        }
        if(info.getRepositoryUUID() != null){
            lgr.info("Repository UUID: " + info.getRepositoryUUID());
        }
        lgr.info("Revision: " + info.getRevision().getNumber());
        lgr.info("Node Kind: " + info.getKind().toString());
        if(!info.isRemote()){
            lgr.info("Schedule: "
                    + (info.getSchedule() != null ? info.getSchedule() : "normal"));
        }
        lgr.info("Last Changed Author: " + info.getAuthor());
        lgr.info("Last Changed Revision: "
                + info.getCommittedRevision().getNumber());
        lgr.info("Last Changed Date: " + info.getCommittedDate());
        if (info.getPropTime() != null) {
            System.out
                    .println("Properties Last Updated: " + info.getPropTime());
        }
        if (info.getKind() == SVNNodeKind.FILE && info.getChecksum() != null) {
            if (info.getTextTime() != null) {
                lgr.info("Text Last Updated: " + info.getTextTime());
            }
            lgr.info("Checksum: " + info.getChecksum());
        }
        if (info.getLock() != null) {
            if (info.getLock().getID() != null) {
                lgr.info("Lock Token: " + info.getLock().getID());
            }
            lgr.info("Lock Owner: " + info.getLock().getOwner());
            lgr.info("Lock Created: "
                    + info.getLock().getCreationDate());
            if (info.getLock().getExpirationDate() != null) {
                lgr.info("Lock Expires: "
                        + info.getLock().getExpirationDate());
            }
            if (info.getLock().getComment() != null) {
                lgr.info("Lock Comment: "
                        + info.getLock().getComment());
            }
        }
    }
}