use of com.mks.api.response.Response in project maven-scm by apache.
the class IntegrityLockCommand method executeLockCommand.
/**
* {@inheritDoc}
*/
@Override
public ScmResult executeLockCommand(ScmProviderRepository repository, File workingDirectory, String filename) throws ScmException {
getLogger().info("Attempting to lock file: " + filename);
if (null == filename || filename.length() == 0) {
throw new ScmException("A single filename is required to execute the lock command!");
}
ScmResult result;
IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
try {
Sandbox siSandbox = iRepo.getSandbox();
File memberFile = new File(workingDirectory.getAbsoluteFile() + File.separator + filename);
Response res = siSandbox.lock(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.Response in project maven-scm by apache.
the class IntegrityMkdirCommand method executeMkdirCommand.
/**
* Creates a subproject in the Integrity repository.
* <br>However, since the subproject automatically creates a folder in
* the local sandbox, the createInLocal argument will be ignored
*/
@Override
public MkdirScmResult executeMkdirCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean createInLocal) throws ScmException {
String dirPath = "";
Iterator<File> fit = fileSet.getFileList().iterator();
if (fit.hasNext()) {
dirPath = fit.next().getPath().replace('\\', '/');
}
if (null == dirPath || dirPath.length() == 0) {
throw new ScmException("A relative directory path is required to execute this command!");
}
getLogger().info("Creating subprojects one per directory, as required for " + dirPath);
MkdirScmResult result;
IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
try {
Response res = iRepo.getSandbox().createSubproject(dirPath);
String subProject = res.getWorkItems().next().getResult().getField("resultant").getItem().getDisplayId();
List<ScmFile> createdDirs = new ArrayList<ScmFile>();
createdDirs.add(new ScmFile(subProject, ScmFileStatus.ADDED));
int exitCode = res.getExitCode();
boolean success = (exitCode == 0 ? true : false);
getLogger().info("Successfully created subproject " + subProject);
result = new MkdirScmResult(createdDirs, 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 MkdirScmResult(eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false);
}
return result;
}
use of com.mks.api.response.Response 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.Response in project maven-scm by apache.
the class Project method createDevPath.
/**
* Creates a Development Path (project branch) for the MKS Integrity SCM Project
*
* @param devPath Development Path Name
* @return MKS API Response object
* @throws APIException
*/
public Response createDevPath(String devPath) throws APIException {
// First we need to obtain a checkpoint from the current configuration (normal or variant)
String chkpt = projectRevision;
if (!isBuild()) {
Response chkptRes = checkpoint("Pre-checkpoint for development path " + devPath, devPath + " Baseline");
WorkItem wi = chkptRes.getWorkItem(fullConfigSyntax);
chkpt = wi.getResult().getField("resultant").getItem().getId();
}
// Now lets setup the create development path command
api.getLogger().debug("Creating development path '" + devPath + "' for project " + projectName + " at revision '" + chkpt + "'");
Command siCreateDevPath = new Command(Command.SI, "createdevpath");
siCreateDevPath.addOption(new Option("devpath", devPath));
// Set the project name
siCreateDevPath.addOption(new Option("project", projectName));
// Set the checkpoint we want to create the development path from
siCreateDevPath.addOption(new Option("projectRevision", chkpt));
// Run the create development path command
return api.runCommand(siCreateDevPath);
}
use of com.mks.api.response.Response in project maven-scm by apache.
the class Member method checkout.
/**
* Performs a checkout of this MKS Integrity Source File to a working file location on the build server represented
* by targetFile
*
* @param api MKS API Session
* @return true if the operation succeeded or false if failed
* @throws APIException
*/
public boolean checkout(APISession api) throws APIException {
// Make sure the directory is created
if (!targetFile.getParentFile().isDirectory()) {
targetFile.getParentFile().mkdirs();
}
// Construct the project check-co command
Command coCMD = new Command(Command.SI, "projectco");
coCMD.addOption(new Option(overwriteExisting));
coCMD.addOption(new Option("nolock"));
coCMD.addOption(new Option("project", projectConfigPath));
coCMD.addOption(new FileOption("targetFile", targetFile));
coCMD.addOption(new Option(restoreTimestamp));
coCMD.addOption(new Option("lineTerminator", lineTerminator));
coCMD.addOption(new Option("revision", memberRev));
// Add the member selection
coCMD.addSelection(memberID);
// Execute the checkout command
Response res = api.runCommand(coCMD);
// Return true if we were successful
return (res.getExitCode() == 0);
}
Aggregations