Search in sources :

Example 6 with JazzStatusCommand

use of org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand in project maven-scm by apache.

the class JazzCheckInCommand method executeCheckInCommand.

/**
 * {@inheritDoc}
 */
protected CheckInScmResult executeCheckInCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, ScmVersion scmVersion) throws ScmException {
    if (scmVersion != null && StringUtils.isNotEmpty(scmVersion.getName())) {
        throw new ScmException("This provider command can't handle tags.");
    }
    if (getLogger().isDebugEnabled()) {
        getLogger().debug("Executing checkin command...");
    }
    // Create a changeset. We need to do this, as otherwise the information contained in the message
    // will be lost forever.
    JazzScmCommand createChangesetCmd = createCreateChangesetCommand(repository, fileSet, message);
    DebugLoggerConsumer outputConsumer = new DebugLoggerConsumer(getLogger());
    ErrorConsumer errConsumer = new ErrorConsumer(getLogger());
    int status = createChangesetCmd.execute(outputConsumer, errConsumer);
    if (status != 0) {
        return new CheckInScmResult(createChangesetCmd.getCommandString(), "Error code for Jazz SCM create changeset command - " + status, errConsumer.getOutput(), false);
    }
    // As we just created a change set, we now need to call the status command so we can parse the
    // newly created change set.
    JazzStatusCommand statusCommand = new JazzStatusCommand();
    statusCommand.setLogger(getLogger());
    statusCommand.executeStatusCommand(repository, fileSet);
    // NOTE: For isPushChangesAndHaveFlowTargets() to work, a scm status call must have been called first!!!
    // As the Workspace name and alias, and the Flow Target name and alias are needed.
    // Check to see if we've got a flow target and had a workItem defined (via -DworkItem=XXXX)
    JazzScmProviderRepository jazzRepo = (JazzScmProviderRepository) repository;
    if (jazzRepo.isPushChangesAndHaveFlowTargets() && StringUtils.isNotEmpty(jazzRepo.getWorkItem())) {
        List<Integer> changeSetAliases = jazzRepo.getOutgoingChangeSetAliases();
        if (changeSetAliases != null && !changeSetAliases.isEmpty()) {
            for (Integer changeSetAlias : changeSetAliases) {
                // Associate a work item if we need too.
                JazzScmCommand changesetAssociateCmd = createChangesetAssociateCommand(repository, changeSetAlias);
                outputConsumer = new DebugLoggerConsumer(getLogger());
                errConsumer = new ErrorConsumer(getLogger());
                status = changesetAssociateCmd.execute(outputConsumer, errConsumer);
                if (status != 0) {
                    return new CheckInScmResult(changesetAssociateCmd.getCommandString(), "Error code for Jazz SCM changeset associate command - " + status, errConsumer.getOutput(), false);
                }
            }
        }
    }
    // Now check in the files themselves.
    return executeCheckInCommand(repository, fileSet, scmVersion);
}
Also used : ScmException(org.apache.maven.scm.ScmException) JazzStatusCommand(org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand) ErrorConsumer(org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer) JazzScmCommand(org.apache.maven.scm.provider.jazz.command.JazzScmCommand) DebugLoggerConsumer(org.apache.maven.scm.provider.jazz.command.consumer.DebugLoggerConsumer) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) JazzScmProviderRepository(org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository)

Example 7 with JazzStatusCommand

use of org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand in project maven-scm by apache.

the class JazzScmProvider method list.

/**
 * {@inheritDoc}
 */
protected ListScmResult list(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
    getLogger().debug("JazzScmProvider:list()");
    // We need to call the status command first, so that we can get the details of the stream etc.
    // This is needed for workspace and component names.
    JazzStatusCommand statusCommand = new JazzStatusCommand();
    statusCommand.setLogger(getLogger());
    statusCommand.execute(repository, fileSet, parameters);
    JazzListCommand command = new JazzListCommand();
    command.setLogger(getLogger());
    return (ListScmResult) command.execute(repository, fileSet, parameters);
}
Also used : JazzStatusCommand(org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand) ListScmResult(org.apache.maven.scm.command.list.ListScmResult) JazzListCommand(org.apache.maven.scm.provider.jazz.command.list.JazzListCommand)

Aggregations

JazzStatusCommand (org.apache.maven.scm.provider.jazz.command.status.JazzStatusCommand)7 StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)3 JazzScmCommand (org.apache.maven.scm.provider.jazz.command.JazzScmCommand)3 ErrorConsumer (org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer)3 File (java.io.File)2 ScmFile (org.apache.maven.scm.ScmFile)2 DebugLoggerConsumer (org.apache.maven.scm.provider.jazz.command.consumer.DebugLoggerConsumer)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ScmException (org.apache.maven.scm.ScmException)1 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)1 ChangeLogScmResult (org.apache.maven.scm.command.changelog.ChangeLogScmResult)1 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)1 DiffScmResult (org.apache.maven.scm.command.diff.DiffScmResult)1 ListScmResult (org.apache.maven.scm.command.list.ListScmResult)1 TagScmResult (org.apache.maven.scm.command.tag.TagScmResult)1 JazzChangeLogCommand (org.apache.maven.scm.provider.jazz.command.changelog.JazzChangeLogCommand)1 JazzListCommand (org.apache.maven.scm.provider.jazz.command.list.JazzListCommand)1 JazzTagCommand (org.apache.maven.scm.provider.jazz.command.tag.JazzTagCommand)1 JazzScmProviderRepository (org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository)1