Search in sources :

Example 6 with SynergyScmProviderRepository

use of org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository in project maven-scm by apache.

the class SynergyTagCommand method executeTagCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeTagCommand(ScmProviderRepository repository, ScmFileSet fileSet, String tag, ScmTagParameters scmTagParameters) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing tag command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("basedir: " + fileSet.getBasedir());
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), SynergyRole.BUILD_MGR);
    try {
        // Make sure, that all changes made until now are reflected in the prep project
        // this is especially true for all changes made by maven (ie versions in the poms).
        SynergyUtil.reconfigureProperties(getLogger(), repo.getProjectSpec(), ccmAddr);
        SynergyUtil.reconfigure(getLogger(), repo.getProjectSpec(), ccmAddr);
        SynergyUtil.createBaseline(getLogger(), repo.getProjectSpec(), tag, repo.getProjectRelease(), repo.getProjectPurpose(), ccmAddr);
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    List<ScmFile> files = new ArrayList<ScmFile>(fileSet.getFileList().size());
    for (File f : fileSet.getFileList()) {
        files.add(new ScmFile(f.getPath(), ScmFileStatus.TAGGED));
    }
    return new TagScmResult("", files);
}
Also used : SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) ArrayList(java.util.ArrayList) TagScmResult(org.apache.maven.scm.command.tag.TagScmResult) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 7 with SynergyScmProviderRepository

use of org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository in project maven-scm by apache.

the class SynergyAddCommand method executeAddCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeAddCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean binary) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing add command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("basedir: " + fileSet.getBasedir());
    }
    if (message == null || message.equals("")) {
        message = "Maven SCM Synergy provider: adding file(s) to project " + repo.getProjectSpec();
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
    try {
        int taskNum = SynergyUtil.createTask(getLogger(), message, repo.getProjectRelease(), true, ccmAddr);
        String projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
        if (projectSpec == null) {
            throw new ScmException("You should checkout a working project first");
        }
        File waPath = SynergyUtil.getWorkArea(getLogger(), projectSpec, ccmAddr);
        File destPath = new File(waPath, repo.getProjectName());
        for (File source : fileSet.getFileList()) {
            File dest = new File(destPath, SynergyUtil.removePrefix(fileSet.getBasedir(), source));
            if (!source.equals(dest)) {
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Copy file [" + source + "] to Synergy Work Area [" + dest + "].");
                }
                try {
                    FileUtils.copyFile(source, dest);
                } catch (IOException e) {
                    throw new ScmException("Unable to copy file in Work Area", e);
                }
            }
            SynergyUtil.create(getLogger(), dest, message, ccmAddr);
        }
        SynergyUtil.checkinTask(getLogger(), taskNum, message, ccmAddr);
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    List<ScmFile> scmFiles = new ArrayList<ScmFile>(fileSet.getFileList().size());
    for (File f : fileSet.getFileList()) {
        scmFiles.add(new ScmFile(f.getPath(), ScmFileStatus.ADDED));
    }
    return new AddScmResult("", scmFiles);
}
Also used : ScmException(org.apache.maven.scm.ScmException) SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) AddScmResult(org.apache.maven.scm.command.add.AddScmResult) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 8 with SynergyScmProviderRepository

use of org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository in project maven-scm by apache.

the class SynergyEditCommand method executeEditCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeEditCommand(ScmProviderRepository repository, ScmFileSet fileSet) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing edit command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug(fileSet.toString());
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
    try {
        String projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
        File waPath = SynergyUtil.getWorkArea(getLogger(), projectSpec, ccmAddr);
        File sourcePath = new File(waPath, repo.getProjectName());
        if (projectSpec == null) {
            throw new ScmException("You should checkout project first");
        }
        int taskNum = SynergyUtil.createTask(getLogger(), "Maven SCM Synergy provider: edit command for project " + repo.getProjectSpec(), repo.getProjectRelease(), true, ccmAddr);
        if (getLogger().isInfoEnabled()) {
            getLogger().info("Task " + taskNum + " was created to perform checkout.");
        }
        for (File f : fileSet.getFileList()) {
            File dest = f;
            File source = new File(sourcePath, SynergyUtil.removePrefix(fileSet.getBasedir(), f));
            List<File> list = new LinkedList<File>();
            list.add(source);
            SynergyUtil.checkoutFiles(getLogger(), list, ccmAddr);
            if (!source.equals(dest)) {
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Copy file [" + source + "] to expected folder [" + dest + "].");
                }
                try {
                    FileUtils.copyFile(source, dest);
                } catch (IOException e) {
                    throw new ScmException("Unable to copy file from Work Area", e);
                }
            }
        }
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    List<ScmFile> scmFiles = new ArrayList<ScmFile>(fileSet.getFileList().size());
    for (File f : fileSet.getFileList()) {
        scmFiles.add(new ScmFile(f.getPath(), ScmFileStatus.EDITED));
    }
    return new EditScmResult("", scmFiles);
}
Also used : ScmException(org.apache.maven.scm.ScmException) SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) ArrayList(java.util.ArrayList) EditScmResult(org.apache.maven.scm.command.edit.EditScmResult) IOException(java.io.IOException) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) LinkedList(java.util.LinkedList) ScmFile(org.apache.maven.scm.ScmFile)

Example 9 with SynergyScmProviderRepository

use of org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository in project maven-scm by apache.

the class SynergyStatusCommand method executeStatusCommand.

/**
 * {@inheritDoc}
 */
protected StatusScmResult executeStatusCommand(ScmProviderRepository repository, ScmFileSet fileSet) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing status command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("basedir: " + fileSet.getBasedir());
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
    List<String> l;
    try {
        l = SynergyUtil.getWorkingFiles(getLogger(), repo.getProjectSpec(), repo.getProjectRelease(), ccmAddr);
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    List<ScmFile> result = new LinkedList<ScmFile>();
    for (String filename : l) {
        ScmFile f = new ScmFile(filename, ScmFileStatus.MODIFIED);
        result.add(f);
    }
    return new StatusScmResult("ccm dir", result);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) LinkedList(java.util.LinkedList) ScmFile(org.apache.maven.scm.ScmFile)

Example 10 with SynergyScmProviderRepository

use of org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository in project maven-scm by apache.

the class SynergyUnEditCommand method executeUnEditCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeUnEditCommand(ScmProviderRepository repository, ScmFileSet fileSet) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing unedit command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("basedir: " + fileSet.getBasedir());
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
    try {
        String projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
        if (projectSpec == null) {
            throw new ScmException("You should checkout a working project first");
        }
        File waPath = SynergyUtil.getWorkArea(getLogger(), projectSpec, ccmAddr);
        File destPath = new File(waPath, repo.getProjectName());
        for (File f : fileSet.getFileList()) {
            File source = new File(fileSet.getBasedir(), f.getPath());
            File dest = new File(destPath, f.getPath());
            SynergyUtil.delete(getLogger(), dest, ccmAddr, true);
            if (!source.equals(dest)) {
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Copy file [" + dest + "] to [" + source + "].");
                }
                try {
                    FileUtils.copyFile(dest, source);
                } catch (IOException e) {
                    throw new ScmException("Unable to restore file in output folder", e);
                }
            }
        }
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    List<ScmFile> files = new ArrayList<ScmFile>();
    for (File f : fileSet.getFileList()) {
        files.add(new ScmFile(f.getPath(), ScmFileStatus.UNKNOWN));
    }
    return new UnEditScmResult("", files);
}
Also used : ScmException(org.apache.maven.scm.ScmException) SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) ArrayList(java.util.ArrayList) UnEditScmResult(org.apache.maven.scm.command.unedit.UnEditScmResult) IOException(java.io.IOException) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Aggregations

SynergyScmProviderRepository (org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository)10 ArrayList (java.util.ArrayList)9 ScmFile (org.apache.maven.scm.ScmFile)9 File (java.io.File)8 ScmException (org.apache.maven.scm.ScmException)7 IOException (java.io.IOException)5 LinkedList (java.util.LinkedList)2 StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)2 ChangeSet (org.apache.maven.scm.ChangeSet)1 ScmResult (org.apache.maven.scm.ScmResult)1 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)1 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)1 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)1 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)1 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)1 EditScmResult (org.apache.maven.scm.command.edit.EditScmResult)1 TagScmResult (org.apache.maven.scm.command.tag.TagScmResult)1 UnEditScmResult (org.apache.maven.scm.command.unedit.UnEditScmResult)1 UpdateScmResult (org.apache.maven.scm.command.update.UpdateScmResult)1 SynergyTask (org.apache.maven.scm.provider.synergy.util.SynergyTask)1