Search in sources :

Example 1 with SynergyScmProviderRepository

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

the class SynergyCheckOutCommand method executeCheckOutCommand.

/**
 * {@inheritDoc}
 */
protected CheckOutScmResult executeCheckOutCommand(ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version, boolean recursive, boolean shallow) throws ScmException {
    if (fileSet.getFileList().size() != 0) {
        throw new ScmException("This provider doesn't support checking out subsets of a project");
    }
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing checkout command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug(fileSet.toString());
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
    File waPath;
    try {
        String projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
        if (projectSpec != null) {
            if (getLogger().isInfoEnabled()) {
                getLogger().info("A working project already exists [" + projectSpec + "].");
            }
            SynergyUtil.synchronize(getLogger(), projectSpec, ccmAddr);
        } else {
            SynergyUtil.checkoutProject(getLogger(), null, repo.getProjectSpec(), version, repo.getProjectPurpose(), repo.getProjectRelease(), ccmAddr);
            projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
            if (getLogger().isInfoEnabled()) {
                getLogger().info("A new working project [" + projectSpec + "] was created.");
            }
        }
        SynergyUtil.reconfigure(getLogger(), projectSpec, ccmAddr);
        waPath = SynergyUtil.getWorkArea(getLogger(), projectSpec, ccmAddr);
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    File source = new File(waPath, repo.getProjectName());
    if (getLogger().isInfoEnabled()) {
        getLogger().info("We will now copy files from Synergy Work Area [" + source + "] to expected folder [" + fileSet.getBasedir() + "]");
    }
    // Move files to the expected folder
    try {
        FileUtils.copyDirectoryStructure(source, fileSet.getBasedir());
    } catch (IOException e1) {
        throw new ScmException("Unable to copy directory structure", e1);
    }
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("We will list content of checkout directory.");
    }
    // We need to list files in the directory
    List<ScmFile> files = new ArrayList<ScmFile>();
    try {
        @SuppressWarnings("unchecked") List<File> realFiles = FileUtils.getFiles(fileSet.getBasedir(), null, "_ccmwaid.inf");
        for (File f : realFiles) {
            files.add(new ScmFile(f.getPath(), ScmFileStatus.CHECKED_OUT));
        }
    } catch (IOException e) {
        throw new ScmException("Unable to list files in checkout directory", e);
    }
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("checkout command end successfully ...");
    }
    return new CheckOutScmResult(files, new ScmResult("multiple commandline", "OK", "OK", true));
}
Also used : ScmException(org.apache.maven.scm.ScmException) SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) ScmResult(org.apache.maven.scm.ScmResult) ArrayList(java.util.ArrayList) CheckOutScmResult(org.apache.maven.scm.command.checkout.CheckOutScmResult) IOException(java.io.IOException) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 2 with SynergyScmProviderRepository

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

the class SynergyRemoveCommand method executeRemoveCommand.

/**
 * {@inheritDoc}
 */
protected ScmResult executeRemoveCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing remove 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, false);
            if (!source.equals(dest)) {
                if (getLogger().isDebugEnabled()) {
                    getLogger().debug("Delete file [" + source + "].");
                }
                dest.delete();
            }
        }
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    List<ScmFile> scmFiles = new ArrayList<ScmFile>();
    for (File file : fileSet.getFileList()) {
        scmFiles.add(new ScmFile(file.getPath(), ScmFileStatus.DELETED));
    }
    return new StatusScmResult("", scmFiles);
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmException(org.apache.maven.scm.ScmException) SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) ArrayList(java.util.ArrayList) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 3 with SynergyScmProviderRepository

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

the class SynergyUpdateCommand method executeUpdateCommand.

/**
 * {@inheritDoc}
 */
protected UpdateScmResult executeUpdateCommand(ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion version) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing update command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("basedir: " + fileSet.getBasedir());
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
    File waPath;
    try {
        String projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
        SynergyUtil.reconfigureProperties(getLogger(), projectSpec, ccmAddr);
        SynergyUtil.reconfigure(getLogger(), projectSpec, ccmAddr);
        // We need to get WA path
        waPath = SynergyUtil.getWorkArea(getLogger(), projectSpec, ccmAddr);
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    File source = new File(waPath, repo.getProjectName());
    // Move file from work area to expected dir if not the same
    List<ScmFile> modifications = new ArrayList<ScmFile>();
    if (!source.equals(fileSet.getBasedir())) {
        if (getLogger().isInfoEnabled()) {
            getLogger().info("We will copy modified files from Synergy Work Area [" + source + "] to expected folder [" + fileSet.getBasedir() + "]");
        }
        try {
            copyDirectoryStructure(source, fileSet.getBasedir(), modifications);
        } catch (IOException e1) {
            throw new ScmException("Unable to copy directory structure", e1);
        }
    }
    return new UpdateScmResult("ccm reconcile -uwa ...", modifications);
}
Also used : ScmException(org.apache.maven.scm.ScmException) SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) ArrayList(java.util.ArrayList) UpdateScmResult(org.apache.maven.scm.command.update.UpdateScmResult) IOException(java.io.IOException) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) ScmFile(org.apache.maven.scm.ScmFile)

Example 4 with SynergyScmProviderRepository

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

the class SynergyChangeLogCommand method executeChangeLogCommand.

/**
 * {@inheritDoc}
 */
protected ChangeLogScmResult executeChangeLogCommand(ScmProviderRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, ScmBranch branch, String datePattern) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing changelog command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("basedir: " + fileSet.getBasedir());
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
    List<ChangeSet> csList = new ArrayList<ChangeSet>();
    try {
        String projectSpec = SynergyUtil.getWorkingProject(getLogger(), repo.getProjectSpec(), repo.getUser(), ccmAddr);
        if (projectSpec == null) {
            throw new ScmException("You should checkout a working project first");
        }
        List<SynergyTask> tasks = SynergyUtil.getCompletedTasks(getLogger(), projectSpec, startDate, endDate, ccmAddr);
        for (SynergyTask t : tasks) {
            ChangeSet cs = new ChangeSet();
            cs.setAuthor(t.getUsername());
            cs.setComment("Task " + t.getNumber() + ": " + t.getComment());
            cs.setDate(t.getModifiedTime());
            cs.setFiles(SynergyUtil.getModifiedObjects(getLogger(), t.getNumber(), ccmAddr));
            csList.add(cs);
        }
    } finally {
        SynergyUtil.stop(getLogger(), ccmAddr);
    }
    return new ChangeLogScmResult("ccm query ...", new ChangeLogSet(csList, startDate, endDate));
}
Also used : ScmException(org.apache.maven.scm.ScmException) ChangeLogSet(org.apache.maven.scm.command.changelog.ChangeLogSet) SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) ArrayList(java.util.ArrayList) SynergyTask(org.apache.maven.scm.provider.synergy.util.SynergyTask) ChangeLogScmResult(org.apache.maven.scm.command.changelog.ChangeLogScmResult) ChangeSet(org.apache.maven.scm.ChangeSet)

Example 5 with SynergyScmProviderRepository

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

the class SynergyCheckInCommand method executeCheckInCommand.

/**
 * {@inheritDoc}
 */
protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, ScmVersion version) throws ScmException {
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("executing checkin command...");
    }
    SynergyScmProviderRepository repo = (SynergyScmProviderRepository) repository;
    if (getLogger().isDebugEnabled()) {
        getLogger().debug(fileSet.toString());
    }
    String ccmAddr = SynergyUtil.start(getLogger(), repo.getUser(), repo.getPassword(), null);
    try {
        SynergyTaskManager.getInstance().checkinDefaultTask(getLogger(), 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.CHECKED_IN));
    }
    return new CheckInScmResult("ccm checkin", scmFiles);
}
Also used : SynergyScmProviderRepository(org.apache.maven.scm.provider.synergy.repository.SynergyScmProviderRepository) ArrayList(java.util.ArrayList) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) 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