use of com.mks.api.Command in project maven-scm by apache.
the class Project method checkpoint.
/**
* Performs a checkpoint on the Integrity SCM Project
*
* @param message Checkpoint description
* @param tag Checkpoint label
* @return MKS API Response object
* @throws APIException
*/
public Response checkpoint(String message, String tag) throws APIException {
// Setup the checkpoint command
api.getLogger().debug("Checkpointing project " + fullConfigSyntax + " with label '" + tag + "'");
// Construct the checkpoint command
Command siCheckpoint = new Command(Command.SI, "checkpoint");
siCheckpoint.addOption(new Option("recurse"));
// Set the project name
siCheckpoint.addOption(new Option("project", fullConfigSyntax));
// Set the label
siCheckpoint.addOption(new Option("label", tag));
// Set the description, if specified
if (null != message && message.length() > 0) {
siCheckpoint.addOption(new Option("description", message));
}
// Run the checkpoint command
return api.runCommand(siCheckpoint);
}
use of com.mks.api.Command 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.Command 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);
}
use of com.mks.api.Command in project maven-scm by apache.
the class Project method listFiles.
/**
* Parses the output from the si viewproject command to get a list of members
*
* @param workspaceDir The current workspace directory, which is required for an export
* @return The list of Member objects for this project
* @throws APIException
*/
public List<Member> listFiles(String workspaceDir) throws APIException {
// Re-initialize the member list for this project
List<Member> memberList = new ArrayList<Member>();
// Initialize the project config hash
Hashtable<String, String> pjConfigHash = new Hashtable<String, String>();
// Add the mapping for this project
pjConfigHash.put(projectName, fullConfigSyntax);
// Compute the project root directory
String projectRoot = projectName.substring(0, projectName.lastIndexOf('/'));
// Now, lets parse this project
Command siViewProjectCmd = new Command(Command.SI, "viewproject");
siViewProjectCmd.addOption(new Option("recurse"));
siViewProjectCmd.addOption(new Option("project", fullConfigSyntax));
MultiValue mvFields = new MultiValue(",");
mvFields.add("name");
mvFields.add("context");
mvFields.add("memberrev");
mvFields.add("membertimestamp");
mvFields.add("memberdescription");
siViewProjectCmd.addOption(new Option("fields", mvFields));
api.getLogger().info("Preparing to execute si viewproject for " + fullConfigSyntax);
Response viewRes = api.runCommand(siViewProjectCmd);
// Iterate through the list of members returned by the API
WorkItemIterator wit = viewRes.getWorkItems();
while (wit.hasNext()) {
WorkItem wi = wit.next();
if (wi.getModelType().equals(SIModelTypeName.SI_SUBPROJECT)) {
// Save the configuration path for the current subproject, using the canonical path name
pjConfigHash.put(wi.getField("name").getValueAsString(), wi.getId());
} else if (wi.getModelType().equals(SIModelTypeName.MEMBER)) {
// Figure out this member's parent project's canonical path name
String parentProject = wi.getField("parent").getValueAsString();
// Instantiate our Integrity CM Member object
Member iCMMember = new Member(wi, pjConfigHash.get(parentProject), projectRoot, workspaceDir);
// Add this to the full list of members in this project
memberList.add(iCMMember);
} else {
api.getLogger().warn("View project output contains an invalid model type: " + wi.getModelType());
}
}
// Sort the files list...
Collections.sort(memberList, FILES_ORDER);
return memberList;
}
use of com.mks.api.Command in project maven-scm by apache.
the class Sandbox method unlock.
/**
* Executes a 'si unlock' command using the relativeName of the file
*
* @param memberFile Full path to the member's current sandbox location
* @param relativeName Relative path from the nearest subproject or project
* @return MKS API Response object
* @throws APIException
*/
public Response unlock(File memberFile, String relativeName) throws APIException {
// Setup the unlock command
api.getLogger().debug("Unlocking member: " + memberFile.getAbsolutePath());
Command siUnlock = new Command(Command.SI, "unlock");
siUnlock.addOption(new Option("revision", ":member"));
siUnlock.addOption(new Option("action", "remove"));
siUnlock.addOption(new Option("cwd", memberFile.getParentFile().getAbsolutePath()));
siUnlock.addSelection(relativeName);
// Execute the unlock command
return api.runCommand(siUnlock);
}
Aggregations