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

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

The newest version!
package br.com.jarch.svn;

import org.tmatesoft.svn.core.SVNCommitInfo;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.wc.ISVNEventHandler;
import org.tmatesoft.svn.core.wc.SVNCommitClient;
import org.tmatesoft.svn.core.wc.SVNEvent;

import java.net.URL;
import java.util.List;

class DeleteSvn extends BaseSvn {

    /**
     *
     */
    private static final long serialVersionUID = -5194625034163786062L;

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

    public void delete(URL urlRepositorio, String comentario) throws Exception {
        if (!existeRepositorio(urlRepositorio)) {
            throw new Exception("Repositório " + urlRepositorio.toString() + " NÃO localizado");
        }

        SVNURL[] arraySvnUrl = {SVNURL.parseURIEncoded(urlRepositorio.toString())};

        SVNCommitClient svnCommitClient = getCommitClient();

        svnCommitClient.setEventHandler(new ISVNEventHandler() {
            @Override
            public void checkCancelled() {
            }

            @Override
            public void handleEvent(SVNEvent svnEvent, double arg1) {
                if (svnEvent.getFile() == null)
                    return;
                else
                    svnEvent.getFile();

                String mensagem = "DELETE_PHISICAL: " + svnEvent.getFile().getPath();
                logUtil.formatMiddle(log, mensagem);
            }
        });

        SVNCommitInfo svnCommitInfo = svnCommitClient.doDelete(arraySvnUrl, comentario);

        logUtil.formatBeginMiddleEnd(log, "DELETE_PHISICAL", new String[]{"URL: " + urlRepositorio, "REVISÃO(ÕES): " + svnCommitInfo.getNewRevision()});

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy