use of com.mks.api.response.APIException in project maven-scm by apache.
the class IntegrityStatusCommand method executeStatusCommand.
/**
* {@inheritDoc}
*/
@Override
public StatusScmResult executeStatusCommand(ScmProviderRepository repository, ScmFileSet fileSet) throws ScmException {
StatusScmResult result;
IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
getLogger().info("Status of files changed in sandbox " + fileSet.getBasedir().getAbsolutePath());
try {
// Initialize the list of ScmFile objects for the StatusScmResult
List<ScmFile> scmFileList = new ArrayList<ScmFile>();
// Get a listing for all the changes in the sandbox
Sandbox siSandbox = iRepo.getSandbox();
// Get the excludes and includes list from the configuration
String excludes = Sandbox.formatFilePatterns(fileSet.getExcludes());
String includes = Sandbox.formatFilePatterns(fileSet.getIncludes());
// Get the new members found in the sandbox
List<ScmFile> newMemberList = siSandbox.getNewMembers(excludes, includes);
// Update the scmFileList with our updates
scmFileList.addAll(newMemberList);
// Get the changed/dropped members from the sandbox
List<WorkItem> changeList = siSandbox.getChangeList();
for (Iterator<WorkItem> wit = changeList.iterator(); wit.hasNext(); ) {
WorkItem wi = wit.next();
File memberFile = new File(wi.getField("name").getValueAsString());
// Separate the changes into files that have been updated and deleted files
if (siSandbox.hasWorkingFile((Item) wi.getField("wfdelta").getValue())) {
scmFileList.add(new ScmFile(memberFile.getAbsolutePath(), ScmFileStatus.UPDATED));
} else {
scmFileList.add(new ScmFile(memberFile.getAbsolutePath(), ScmFileStatus.DELETED));
}
}
if (scmFileList.size() == 0) {
getLogger().info("No local changes found!");
}
result = new StatusScmResult(scmFileList, new ScmResult("si viewsandbox", "", "", true));
} catch (APIException aex) {
ExceptionHandler eh = new ExceptionHandler(aex);
getLogger().error("MKS API Exception: " + eh.getMessage());
getLogger().debug(eh.getCommand() + " exited with return code " + eh.getExitCode());
result = new StatusScmResult(eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false);
}
return result;
}
use of com.mks.api.response.APIException in project maven-scm by apache.
the class IntegrityListCommand method executeListCommand.
/**
* {@inheritDoc}
*/
@Override
public ListScmResult executeListCommand(ScmProviderRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion scmVersion) throws ScmException {
ListScmResult result;
IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
getLogger().info("Listing all files in project " + iRepo.getConfigruationPath());
try {
// Get a listing for all the members in the project...
List<Member> projectMembers = iRepo.getProject().listFiles(fileSet.getBasedir().getAbsolutePath());
// Initialize the list of ScmFile objects for the ListScmResult
List<ScmFile> scmFileList = new ArrayList<ScmFile>();
for (Iterator<Member> it = projectMembers.iterator(); it.hasNext(); ) {
Member siMember = it.next();
scmFileList.add(new ScmFile(siMember.getTargetFilePath(), ScmFileStatus.UNKNOWN));
}
result = new ListScmResult(scmFileList, new ScmResult("si viewproject", "", "", true));
} catch (APIException aex) {
ExceptionHandler eh = new ExceptionHandler(aex);
getLogger().error("MKS API Exception: " + eh.getMessage());
getLogger().debug(eh.getCommand() + " exited with return code " + eh.getExitCode());
result = new ListScmResult(eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false);
}
return result;
}
use of com.mks.api.response.APIException in project maven-scm by apache.
the class IntegrityUnlockCommand method executeUnlockCommand.
/**
* {@inheritDoc}
*/
@Override
public ScmResult executeUnlockCommand(ScmProviderRepository repository, File workingDirectory) throws ScmException {
getLogger().info("Attempting to unlock file: " + filename);
if (null == filename || filename.length() == 0) {
throw new ScmException("A single filename is required to execute the unlock command!");
}
ScmResult result;
IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
try {
Sandbox siSandbox = iRepo.getSandbox();
File memberFile = new File(workingDirectory.getAbsoluteFile() + File.separator + filename);
Response res = siSandbox.unlock(memberFile, filename);
int exitCode = res.getExitCode();
boolean success = (exitCode == 0 ? true : false);
result = new ScmResult(res.getCommandString(), "", "Exit Code: " + exitCode, success);
} catch (APIException aex) {
ExceptionHandler eh = new ExceptionHandler(aex);
getLogger().error("MKS API Exception: " + eh.getMessage());
getLogger().info(eh.getCommand() + " exited with return code " + eh.getExitCode());
result = new ScmResult(eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false);
}
return result;
}
use of com.mks.api.response.APIException in project maven-scm by apache.
the class Sandbox method addNonMembers.
/**
* Adds a list of files to the MKS Integrity SCM Project
*
* @param exclude Pattern containing the exclude file list
* @param include Pattern containing the include file list
* @param message Description for the member's archive
* @return
*/
public List<ScmFile> addNonMembers(String exclude, String include, String message) {
// Re-initialize the overall addSuccess to be true for now
addSuccess = true;
// Store a list of files that were actually added to the repository
List<ScmFile> filesAdded = new ArrayList<ScmFile>();
api.getLogger().debug("Looking for new members in sandbox dir: " + sandboxDir);
try {
List<ScmFile> newFileList = getNewMembers(exclude, include);
for (Iterator<ScmFile> sit = newFileList.iterator(); sit.hasNext(); ) {
try {
ScmFile localFile = sit.next();
// Attempt to add the file to the Integrity repository
add(new File(localFile.getPath()), message);
// If it was a success, then add it to the list of files that were actually added
filesAdded.add(localFile);
} catch (APIException aex) {
// Set the addSuccess to false, since we ran into a problem
addSuccess = false;
ExceptionHandler eh = new ExceptionHandler(aex);
api.getLogger().error("MKS API Exception: " + eh.getMessage());
api.getLogger().debug(eh.getCommand() + " completed with exit Code " + eh.getExitCode());
}
}
} catch (APIException aex) {
// Set the addSuccess to false, since we ran into a problem
addSuccess = false;
ExceptionHandler eh = new ExceptionHandler(aex);
api.getLogger().error("MKS API Exception: " + eh.getMessage());
api.getLogger().debug(eh.getCommand() + " completed with exit Code " + eh.getExitCode());
}
return filesAdded;
}
use of com.mks.api.response.APIException in project maven-scm by apache.
the class IntegrityChangeLogCommand method executeChangeLogCommand.
/**
* {@inheritDoc}
*/
@Override
public ChangeLogScmResult executeChangeLogCommand(ScmProviderRepository repository, ScmFileSet fileSet, Date startDate, Date endDate, ScmBranch branch, String datePattern) throws ScmException {
// First lets validate the date range provided
if (null == startDate || null == endDate) {
throw new ScmException("Both 'startDate' and 'endDate' must be specified!");
}
if (startDate.after(endDate)) {
throw new ScmException("'stateDate' is not allowed to occur after 'endDate'!");
}
getLogger().info("Attempting to obtain change log for date range: '" + Sandbox.RLOG_DATEFORMAT.format(startDate) + "' to '" + Sandbox.RLOG_DATEFORMAT.format(endDate) + "'");
ChangeLogScmResult result;
IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
try {
result = new ChangeLogScmResult(iRepo.getSandbox().getChangeLog(startDate, endDate), new ScmResult("si rlog", "", "", true));
} catch (APIException aex) {
ExceptionHandler eh = new ExceptionHandler(aex);
getLogger().error("MKS API Exception: " + eh.getMessage());
getLogger().info(eh.getCommand() + " exited with return code " + eh.getExitCode());
result = new ChangeLogScmResult(eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false);
}
return result;
}
Aggregations