Search in sources :

Example 1 with ConfigurationException

use of gmm.ConfigurationException in project GMM by Katharsas.

the class SvnPlugin method verifyExistingWorkingCopy.

private void verifyExistingWorkingCopy() {
    final SvnGetStatus ops = svnOperationFactory.createGetStatus();
    ops.setSingleTarget(workingCopy);
    ops.setReportAll(logger.isDebugEnabled());
    final Collection<SvnStatus> statuses = tryRun(ops, new ArrayList<>(SvnStatus.class));
    for (final SvnStatus entry : statuses) {
        final SVNStatusType type = entry.getNodeStatus();
        final String filePath = entry.getPath().getPath();
        if (type != SVNStatusType.STATUS_NORMAL) {
            logger.error("Existing working copy is in an invalid state (maybe modified)! " + "Pls fix manually or delete working copy at '" + workingCopy + "'.");
            throw new ConfigurationException("Found entry with invalid status in working copy! " + "Relative path: '" + filePath + "'. Status: '" + type + "'.");
        }
    }
}
Also used : SvnGetStatus(org.tmatesoft.svn.core.wc2.SvnGetStatus) ConfigurationException(gmm.ConfigurationException) SVNStatusType(org.tmatesoft.svn.core.wc.SVNStatusType) SvnStatus(org.tmatesoft.svn.core.wc2.SvnStatus)

Example 2 with ConfigurationException

use of gmm.ConfigurationException in project GMM by Katharsas.

the class SvnPlugin method initializeWorkingCopy.

/**
 * @return Current revision of local working copy.
 */
private void initializeWorkingCopy(File workingCopyFile) {
    final String workingCopyString = workingCopyFile.toString();
    if (workingCopyFile.exists()) {
        if (workingCopyFile.isDirectory()) {
            final SvnGetInfo operation = svnOperationFactory.createGetInfo();
            operation.setSingleTarget(workingCopy);
            SvnInfo info = null;
            try {
                info = operation.run();
            } catch (final SVNException e) {
            }
            if (info != null) {
                logger.info("Located existing working copy at path '" + workingCopyString + "'.");
                verifyExistingWorkingCopy();
            } else {
                logger.warn("Could not locate working copy at path '" + workingCopyString + "'! Creating new one.");
                if (workingCopyFile.list().length > 0) {
                    throw new ConfigurationException("Cannot create new working copy because directory is not empty! Path: '" + workingCopyString + "'");
                }
                createNewWorkingCopy();
            }
        } else {
            throw new ConfigurationException("Path to working copy is not a directory! Path:'" + workingCopyString + "'");
        }
    } else {
        logger.warn("Could not locate SVN working copy at path '" + workingCopyString + "'! Creating new one.");
        fileService.createDirectory(workingCopyFile.toPath());
        createNewWorkingCopy();
    }
}
Also used : ConfigurationException(gmm.ConfigurationException) SvnInfo(org.tmatesoft.svn.core.wc2.SvnInfo) SVNException(org.tmatesoft.svn.core.SVNException) SvnGetInfo(org.tmatesoft.svn.core.wc2.SvnGetInfo)

Aggregations

ConfigurationException (gmm.ConfigurationException)2 SVNException (org.tmatesoft.svn.core.SVNException)1 SVNStatusType (org.tmatesoft.svn.core.wc.SVNStatusType)1 SvnGetInfo (org.tmatesoft.svn.core.wc2.SvnGetInfo)1 SvnGetStatus (org.tmatesoft.svn.core.wc2.SvnGetStatus)1 SvnInfo (org.tmatesoft.svn.core.wc2.SvnInfo)1 SvnStatus (org.tmatesoft.svn.core.wc2.SvnStatus)1