views:

33

answers:

0

hey great community, I'm attempting to find empty folders in the CVS and list all folders that are empty in a text file. I would look in the HEAD. Would ideally use a TreeMap (string to store mailer name, boolean to store true or false) and a For loop for the scan. boolean should be set to true at first and if a mailer is empty (folder) then set to false. this is a class we have so far to get branch names... looking for help to modify this to do what it says above. There would be two classes, an interface class and a processor class.

interface class below:

package cvsutils;

import com.epo.core.utilnew.Utils;
import cvsutils.dataobj.Param;
import java.util.TreeSet;
import org.apache.log4j.Logger;


public class RemoveCVSFiles extends CVSUtilsBase {

private static final Logger _logger = Logger.getLogger(RemoveCVSFiles.class);

public RemoveCVSFiles() throws Exception {
    super();
}

private static void usageMessage() {
    System.out.println("usage: cvsutils.GetBranchNames");
}

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    if (args.length < 0) { // no argumets for now
        usageMessage();
    } else {
        try {
            initialize();
            RemoveCVSFiles main = new RemoveCVSFiles();
            main.run(args);
            System.exit(0);
        } catch (Exception ex) {
            _logger.error(Utils.getFormattedErrorMessage(ex));
            System.exit(-1);
        }
    }
}

private void run(String[] args) throws Exception {
    _logger.info("Start");

    TreeSet<String> branchNames = new TreeSet<String>();

    super.run(new Param("branchNames", branchNames));

    String branches = "";
    for (String branchName : branchNames) {
        if (branches.equals("")) {
            branches += branchName;
        } else {
            branches += "," + branchName;
        }
    }

    _logger.info("branches: " + branches);

    _logger.info("End");
}
}

Processor Class:

package cvsutils.processor;

import cvsutils.dataobj.CVSUtilsInit;
import cvsutils.dataobj.CVSFile;
import cvsutils.dataobj.Tag;
import java.util.ArrayList;
import java.util.TreeSet;

public class RemoveCVSProcessor implements ICVSFileProcessor {

    private TreeSet<String> branchNames = null;

    public void init(CVSUtilsInit cvsUtilsInit) {
        this.branchNames = (TreeSet<String>) cvsUtilsInit.getParam("branchNames");
    }

    public void analize(CVSFile cvsFile) throws Exception {
        ArrayList<Tag> tags = cvsFile.getTags(CVSFile.TagTypes.BRANCH);
        for (Tag tag : tags) {
            branchNames.add(tag.getName());
        }
    }
}

thanks so much for your time and effort!