All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.jarch.svn.StatusSvn Maven / Gradle / Ivy

There is a newer version: 24.8.0
Show newest version
package br.com.jarch.svn;

import org.tmatesoft.svn.core.SVNDepth;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.wc.*;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class StatusSvn extends BaseSvn {

    private static final long serialVersionUID = -7046346153335029307L;

    public StatusSvn(List log, String login, String senha) {
        super(log, login, senha);
    }

    public List status(File pastaTrabalho) throws Exception {
        final List listaStatusArquivo = new ArrayList<>();

        if (!pastaTrabalho.exists()) {
            return listaStatusArquivo;
        }

        try {
            SVNStatusClient statusClient = getStatusClient();

            logUtil.formatBegin(log, "STATUS");

            ISVNStatusHandler statusHandler = new ISVNStatusHandler() {

                @Override
                public void handleStatus(SVNStatus svnStatus) {
//                    SVNStatusType statusType = svnStatus.getContentsStatus();
                    SVNStatusType statusType = svnStatus.getNodeStatus();
                    String mensagem = "STATUS: " + svnStatus.getFile().getPath() + " - " + statusType.toString().toUpperCase();
                    System.out.println(mensagem);

                    if (statusType != SVNStatusType.STATUS_NORMAL
                            && statusType != SVNStatusType.STATUS_IGNORED
                            && !SvnUtil.ignora(svnStatus.getFile())) {

                        logUtil.formatMiddle(log, mensagem);

                        StatusArquivoForm statusArquivoForm = new StatusArquivoForm();
                        statusArquivoForm.setArquivo(svnStatus.getFile().getPath());
                        statusArquivoForm.setStatus(statusType.toString().toUpperCase());

                        listaStatusArquivo.add(statusArquivoForm);
                    }
                }
            };

            statusClient.doStatus(pastaTrabalho, SVNRevision.HEAD, SVNDepth.INFINITY, false, false, false, false, statusHandler, null);

            logUtil.formatBegin(log, "FIM");
        } catch (SVNException e) {
            throw new Exception(e.getMessage());
        }

        return listaStatusArquivo;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy