Search in sources :

Example 11 with Option

use of com.mks.api.Option 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);
}
Also used : Response(com.mks.api.response.Response) Command(com.mks.api.Command) Option(com.mks.api.Option) WorkItem(com.mks.api.response.WorkItem)

Example 12 with Option

use of com.mks.api.Option 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);
}
Also used : Response(com.mks.api.response.Response) Command(com.mks.api.Command) FileOption(com.mks.api.FileOption) Option(com.mks.api.Option) FileOption(com.mks.api.FileOption)

Example 13 with Option

use of com.mks.api.Option 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;
}
Also used : Response(com.mks.api.response.Response) Command(com.mks.api.Command) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) Option(com.mks.api.Option) WorkItemIterator(com.mks.api.response.WorkItemIterator) WorkItem(com.mks.api.response.WorkItem) MultiValue(com.mks.api.MultiValue)

Example 14 with Option

use of com.mks.api.Option 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);
}
Also used : Command(com.mks.api.Command) Option(com.mks.api.Option)

Example 15 with Option

use of com.mks.api.Option in project maven-scm by apache.

the class Sandbox method drop.

/**
 * Removes the registration for the Sandbox in the user's profile
 *
 * @return The API Response associated with executing this command
 * @throws APIException
 */
public Response drop() throws APIException {
    File project = new File(siProject.getProjectName());
    File sandboxpj = new File(sandboxDir + fs + project.getName());
    // Check to see if the sandbox file already exists and its OK to use
    api.getLogger().debug("Sandbox Project File: " + sandboxpj.getAbsolutePath());
    Command cmd = new Command(Command.SI, "dropsandbox");
    cmd.addOption(new Option("delete", "members"));
    cmd.addOption(new Option("sandbox", sandboxpj.getAbsolutePath()));
    cmd.addOption(new Option("cwd", sandboxDir));
    return api.runCommand(cmd);
}
Also used : Command(com.mks.api.Command) Option(com.mks.api.Option) ChangeFile(org.apache.maven.scm.ChangeFile) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File)

Aggregations

Command (com.mks.api.Command)20 Option (com.mks.api.Option)20 Response (com.mks.api.response.Response)8 WorkItem (com.mks.api.response.WorkItem)5 WorkItemIterator (com.mks.api.response.WorkItemIterator)5 ArrayList (java.util.ArrayList)4 ChangeFile (org.apache.maven.scm.ChangeFile)4 ScmFile (org.apache.maven.scm.ScmFile)4 MultiValue (com.mks.api.MultiValue)3 APIException (com.mks.api.response.APIException)3 File (java.io.File)3 Item (com.mks.api.response.Item)2 Hashtable (java.util.Hashtable)2 FileOption (com.mks.api.FileOption)1 Field (com.mks.api.response.Field)1 Date (java.util.Date)1 ChangeSet (org.apache.maven.scm.ChangeSet)1 ChangeLogSet (org.apache.maven.scm.command.changelog.ChangeLogSet)1