/** * Copyright (c) 2010 Perforce Software. All rights reserved. */ package com.perforce.maven.scm.provider.p4.command; import java.util.ArrayList; import java.util.List; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileStatus; import com.perforce.p4java.core.file.IFileSpec; /** * This class handles the result from the Perforce command. */ public abstract class P4Result { /** Line separator for this system. */ public static final String LINE_SEPARATOR = System .getProperty("line.separator"); /** The success. */ protected boolean success = true; /** The command result. */ protected List<ScmFile> commandResult = new ArrayList<ScmFile>(); /** The command output. */ protected String commandOutput = ""; /** * Processes the command result filespecs. * * @param fileSpecs * the file specs */ public void process(List<IFileSpec> fileSpecs) { processResult(fileSpecs); processOutput(fileSpecs); } /** * Extracts relevant info from the returned command filespecs as a string. * * @param fileSpecs * the file specs */ private void processOutput(List<IFileSpec> fileSpecs) { if (fileSpecs != null) { for (IFileSpec fileSpec : fileSpecs) { if (fileSpec != null) { StringBuilder sb = new StringBuilder(); if (fileSpec.toString() != null) { sb.append("fileSpec").append("=") .append(fileSpec.toString()) .append(LINE_SEPARATOR); } if (fileSpec.getOpStatus() != null) { sb.append("opStatus").append("=") .append(fileSpec.getOpStatus()) .append(LINE_SEPARATOR); } if (fileSpec.getStatusMessage() != null) { sb.append("statusMessage").append("=") .append(fileSpec.getStatusMessage()) .append(LINE_SEPARATOR); } if (fileSpec.getDepotPath() != null) { sb.append("depotPath").append("=") .append(fileSpec.getDepotPath()) .append(LINE_SEPARATOR); } if (fileSpec.getEndRevision() >= 0) { sb.append("endRevision").append("=") .append(fileSpec.getEndRevision()) .append(LINE_SEPARATOR); } if (fileSpec.getChangelistId() >= 0) { sb.append("changelistId").append("=") .append(fileSpec.getChangelistId()) .append(LINE_SEPARATOR); } if (fileSpec.getAction() != null) { sb.append("action").append("=") .append(fileSpec.getAction()) .append(LINE_SEPARATOR); } if (fileSpec.getFileType() != null) { sb.append("fileType").append("=") .append(fileSpec.getFileType()) .append(LINE_SEPARATOR); } if (fileSpec.getDate() != null) { sb.append("date").append("=") .append(fileSpec.getDate()) .append(LINE_SEPARATOR); } commandOutput += sb.toString(); } } } } /** * Converts the returned filespecs into ScmFile objects. * * @param fileSpecs * the file specs */ private void processResult(List<IFileSpec> fileSpecs) { if (fileSpecs != null) { for (IFileSpec fileSpec : fileSpecs) { if (fileSpec != null) { ScmFileStatus status = null; StringBuilder sb = new StringBuilder(); if (fileSpec.getDepotPath() != null) { sb.append(fileSpec.getDepotPath()); if (fileSpec.getEndRevision() >= 0) { sb.append("#").append(fileSpec.getEndRevision()); } if (fileSpec.getAction() != null) { sb.append(" ").append( fileSpec.getAction().toString()); status = P4FileStatusMapper.getFileStatus(fileSpec .getAction().toString()); } if (fileSpec.getClientPathString() != null) { sb.append(" ").append( fileSpec.getClientPathString()); } commandResult.add(new ScmFile(sb.toString(), status)); if (fileSpec.getOpStatus() != null) { // Mark failures switch (fileSpec.getOpStatus()) { case UNKNOWN: success = false; break; case VALID: break; case INFO: break; case CLIENT_ERROR: success = false; break; case ERROR: success = false; break; default: break; } } } } } } } /** * Process message. * * @param message * the message * @return the string */ public abstract String processMessage(String message); /** * Gets the command result. * * @return the command result */ public List<ScmFile> getCommandResult() { return commandResult; } /** * Gets the command output. * * @return the command output */ public String getCommandOutput() { return commandOutput; } /** * Checks if is success. * * @return true, if is success */ public boolean isSuccess() { return success; } /** * Sets the success. * * @param success * the new success */ public void setSuccess(boolean success) { this.success = success; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#4 | 9519 | dantran | folder rename to match with its artifactId | ||
#3 | 9487 | dantran |
Trim down Checkout and ChangeLog results to use only depo path (rather than a concatinating of every thing and not usable. This helps passed mavn-scm-test update command TCK test |
||
#2 | 9422 | dantran | add update, changelog TCK | ||
#1 | 9167 | dantran |
Populate //guest/dantran/p4maven/... from //guest/perforce_software/p4maven/main/.... |
||
//guest/perforce_software/p4maven/main/com.perforce.maven/src/main/java/com/perforce/maven/scm/provider/p4/command/P4Result.java | |||||
#1 | 8496 | Matt Attaway | Move P4Ant and P4Maven into their proper homes | ||
//public/perforce/p4maven/main/com.perforce.maven/src/main/java/com/perforce/maven/scm/provider/p4/command/P4Result.java | |||||
#1 | 8270 | Matt Attaway | Initial add of P4Maven source code |