Class JazzStatusConsumer
- java.lang.Object
-
- org.apache.maven.scm.util.AbstractConsumer
-
- org.apache.maven.scm.provider.jazz.command.consumer.AbstractRepositoryConsumer
-
- org.apache.maven.scm.provider.jazz.command.status.JazzStatusConsumer
-
- All Implemented Interfaces:
org.codehaus.plexus.util.cli.StreamConsumer
public class JazzStatusConsumer extends AbstractRepositoryConsumer
Consume the output of the scm command for the "status" operation.It is normally just used to build up a list of ScmFile objects that have their ScmFileStatus set. This class has been expanded so that the Workspace, Component and Baseline are also collected and set back in the JazzScmProviderRepository. The Workspace and Component names are needed for some other commands (list, for example), so we can easily get this information here.
As this class has expanded over time, it has become more and more of a state machine, one that needs to parse the output of the "scm status --wide" command. If there are any issues with this provider, I would suggest this is a good place to start.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.regex.Pattern
BASELINE_PATTERN
private static java.util.regex.Pattern
CHANGESET_PATTERN
private static java.util.regex.Pattern
COMPONENT_PATTERN1
private static java.util.regex.Pattern
COMPONENT_PATTERN2
private java.util.List<ScmFile>
fChangedFiles
A List of ScmFile objects that have their ScmFileStatus set.private boolean
seenIncomingChangeSets
Implement a simple state machine: Have we seen the "Change sets:" (incoming) line or not?private boolean
seenOutgoingChangeSets
Implement a simple state machine: Have we seen the "Change sets:" (outgoing) line or not?static java.lang.String
STATUS_CMD_ADD_FLAG
The "Status" command status flag for a resource that has been added.static java.lang.String
STATUS_CMD_BASELINE
The "Status" command output line that contains the "Baseline" name.static java.lang.String
STATUS_CMD_BASELINES
The "Status" command output line that contains the "Baselines" eye catcher.static java.lang.String
STATUS_CMD_CHANGE_FLAG
The "Status" command status flag for when the content or properties of a file have been modified, or the properties of a directory have changed.static java.lang.String
STATUS_CMD_CHANGE_SETS
The "Status" command output line that contains the line "Change sets:".static java.lang.String
STATUS_CMD_COMPONENT
The "Status" command output line that contains the "Component" name.static java.lang.String
STATUS_CMD_DELETE_FLAG
The "Status" command status flag for a resource that has been deleted.static java.lang.String
STATUS_CMD_INCOMING
The "Status" command output line that contains the "Incoming" eye catcher.static java.lang.String
STATUS_CMD_MOVED_FLAG
The "Status" command status flag for a resource that has been renamed or moved.static java.lang.String
STATUS_CMD_OUTGOING
The "Status" command output line that contains the "Outgoing" eye catcher.static java.lang.String
STATUS_CMD_WORKSPACE
The "Status" command output line that contains the "Workspace" name.private static java.util.regex.Pattern
WORKSPACE_PATTERN
-
Fields inherited from class org.apache.maven.scm.provider.jazz.command.consumer.AbstractRepositoryConsumer
fed
-
-
Constructor Summary
Constructors Constructor Description JazzStatusConsumer(ScmProviderRepository repo, ScmLogger logger)
Constructor for our "scm status" consumer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
consumeLine(java.lang.String line)
Process one line of output from the execution of the "scm status" command.private boolean
containsBaseline(java.lang.String line)
private boolean
containsBaselines(java.lang.String line)
private boolean
containsComponent(java.lang.String line)
private boolean
containsIncoming(java.lang.String line)
private boolean
containsOutgoing(java.lang.String line)
private boolean
containsStatusFlag(java.lang.String line)
private boolean
containsWorkspace(java.lang.String line)
private void
extractBaseline(java.lang.String line)
private void
extractChangedFile(java.lang.String line)
private java.lang.Integer
extractChangeSetAlias(java.lang.String line)
Extract and return an Integer of a change set alias, from both incoming and outgoing changesets.private void
extractComponent(java.lang.String line)
private void
extractWorkspace(java.lang.String line)
java.util.List<ScmFile>
getChangedFiles()
-
Methods inherited from class org.apache.maven.scm.provider.jazz.command.consumer.AbstractRepositoryConsumer
getRepository, isFed, setFed, setRepository
-
Methods inherited from class org.apache.maven.scm.util.AbstractConsumer
getLogger, parseDate, parseDate, setLogger
-
-
-
-
Field Detail
-
WORKSPACE_PATTERN
private static final java.util.regex.Pattern WORKSPACE_PATTERN
-
COMPONENT_PATTERN1
private static final java.util.regex.Pattern COMPONENT_PATTERN1
-
COMPONENT_PATTERN2
private static final java.util.regex.Pattern COMPONENT_PATTERN2
-
BASELINE_PATTERN
private static final java.util.regex.Pattern BASELINE_PATTERN
-
CHANGESET_PATTERN
private static final java.util.regex.Pattern CHANGESET_PATTERN
-
STATUS_CMD_WORKSPACE
public static final java.lang.String STATUS_CMD_WORKSPACE
The "Status" command output line that contains the "Workspace" name.- See Also:
- Constant Field Values
-
STATUS_CMD_COMPONENT
public static final java.lang.String STATUS_CMD_COMPONENT
The "Status" command output line that contains the "Component" name.- See Also:
- Constant Field Values
-
STATUS_CMD_BASELINE
public static final java.lang.String STATUS_CMD_BASELINE
The "Status" command output line that contains the "Baseline" name.- See Also:
- Constant Field Values
-
STATUS_CMD_OUTGOING
public static final java.lang.String STATUS_CMD_OUTGOING
The "Status" command output line that contains the "Outgoing" eye catcher.- See Also:
- Constant Field Values
-
STATUS_CMD_INCOMING
public static final java.lang.String STATUS_CMD_INCOMING
The "Status" command output line that contains the "Incoming" eye catcher.- See Also:
- Constant Field Values
-
STATUS_CMD_CHANGE_SETS
public static final java.lang.String STATUS_CMD_CHANGE_SETS
The "Status" command output line that contains the line "Change sets:". This will be followed by the change set lines themselves.- See Also:
- Constant Field Values
-
STATUS_CMD_BASELINES
public static final java.lang.String STATUS_CMD_BASELINES
The "Status" command output line that contains the "Baselines" eye catcher.- See Also:
- Constant Field Values
-
STATUS_CMD_ADD_FLAG
public static final java.lang.String STATUS_CMD_ADD_FLAG
The "Status" command status flag for a resource that has been added.- See Also:
- Constant Field Values
-
STATUS_CMD_CHANGE_FLAG
public static final java.lang.String STATUS_CMD_CHANGE_FLAG
The "Status" command status flag for when the content or properties of a file have been modified, or the properties of a directory have changed.- See Also:
- Constant Field Values
-
STATUS_CMD_DELETE_FLAG
public static final java.lang.String STATUS_CMD_DELETE_FLAG
The "Status" command status flag for a resource that has been deleted.- See Also:
- Constant Field Values
-
STATUS_CMD_MOVED_FLAG
public static final java.lang.String STATUS_CMD_MOVED_FLAG
The "Status" command status flag for a resource that has been renamed or moved.- See Also:
- Constant Field Values
-
fChangedFiles
private java.util.List<ScmFile> fChangedFiles
A List of ScmFile objects that have their ScmFileStatus set.
-
seenOutgoingChangeSets
private boolean seenOutgoingChangeSets
Implement a simple state machine: Have we seen the "Change sets:" (outgoing) line or not?
-
seenIncomingChangeSets
private boolean seenIncomingChangeSets
Implement a simple state machine: Have we seen the "Change sets:" (incoming) line or not?
-
-
Constructor Detail
-
JazzStatusConsumer
public JazzStatusConsumer(ScmProviderRepository repo, ScmLogger logger)
Constructor for our "scm status" consumer.- Parameters:
repo
- The JazzScmProviderRepository being used.logger
- The ScmLogger to use.
-
-
Method Detail
-
consumeLine
public void consumeLine(java.lang.String line)
Process one line of output from the execution of the "scm status" command.- Specified by:
consumeLine
in interfaceorg.codehaus.plexus.util.cli.StreamConsumer
- Overrides:
consumeLine
in classAbstractRepositoryConsumer
- Parameters:
line
- The line of output from the external command that has been pumped to us.- See Also:
StreamConsumer.consumeLine(java.lang.String)
-
containsWorkspace
private boolean containsWorkspace(java.lang.String line)
-
extractWorkspace
private void extractWorkspace(java.lang.String line)
-
containsComponent
private boolean containsComponent(java.lang.String line)
-
extractComponent
private void extractComponent(java.lang.String line)
-
containsBaseline
private boolean containsBaseline(java.lang.String line)
-
extractBaseline
private void extractBaseline(java.lang.String line)
-
containsStatusFlag
private boolean containsStatusFlag(java.lang.String line)
-
extractChangedFile
private void extractChangedFile(java.lang.String line)
-
getChangedFiles
public java.util.List<ScmFile> getChangedFiles()
-
containsOutgoing
private boolean containsOutgoing(java.lang.String line)
-
containsIncoming
private boolean containsIncoming(java.lang.String line)
-
containsBaselines
private boolean containsBaselines(java.lang.String line)
-
extractChangeSetAlias
private java.lang.Integer extractChangeSetAlias(java.lang.String line)
Extract and return an Integer of a change set alias, from both incoming and outgoing changesets.- Parameters:
line
- The line to extract the change sets from.- Returns:
- A parsed Integer value, or null if not able to parse.
-
-