Search in sources :

Example 11 with Response

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;
}
Also used : Response(com.mks.api.response.Response) ExceptionHandler(org.apache.maven.scm.provider.integrity.ExceptionHandler) ScmException(org.apache.maven.scm.ScmException) APIException(com.mks.api.response.APIException) ScmResult(org.apache.maven.scm.ScmResult) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository) File(java.io.File) Sandbox(org.apache.maven.scm.provider.integrity.Sandbox)

Example 12 with Response

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;
}
Also used : ScmException(org.apache.maven.scm.ScmException) MkdirScmResult(org.apache.maven.scm.command.mkdir.MkdirScmResult) ScmResult(org.apache.maven.scm.ScmResult) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository) ArrayList(java.util.ArrayList) ScmFile(org.apache.maven.scm.ScmFile) Response(com.mks.api.response.Response) ExceptionHandler(org.apache.maven.scm.provider.integrity.ExceptionHandler) APIException(com.mks.api.response.APIException) MkdirScmResult(org.apache.maven.scm.command.mkdir.MkdirScmResult) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File)

Example 13 with Response

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;
}
Also used : Response(com.mks.api.response.Response) ExceptionHandler(org.apache.maven.scm.provider.integrity.ExceptionHandler) ScmException(org.apache.maven.scm.ScmException) APIException(com.mks.api.response.APIException) ScmResult(org.apache.maven.scm.ScmResult) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository) File(java.io.File) Sandbox(org.apache.maven.scm.provider.integrity.Sandbox)

Example 14 with Response

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);
}
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 15 with Response

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);
}
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)

Aggregations

Response (com.mks.api.response.Response)22 APIException (com.mks.api.response.APIException)13 ExceptionHandler (org.apache.maven.scm.provider.integrity.ExceptionHandler)11 IntegrityScmProviderRepository (org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository)11 Command (com.mks.api.Command)9 Option (com.mks.api.Option)8 WorkItem (com.mks.api.response.WorkItem)8 Sandbox (org.apache.maven.scm.provider.integrity.Sandbox)8 WorkItemIterator (com.mks.api.response.WorkItemIterator)7 ArrayList (java.util.ArrayList)7 ScmException (org.apache.maven.scm.ScmException)5 File (java.io.File)4 ScmFile (org.apache.maven.scm.ScmFile)4 ScmResult (org.apache.maven.scm.ScmResult)4 CmdRunner (com.mks.api.CmdRunner)3 MultiValue (com.mks.api.MultiValue)3 Project (org.apache.maven.scm.provider.integrity.Project)3 Item (com.mks.api.response.Item)2 Result (com.mks.api.response.Result)2 Hashtable (java.util.Hashtable)2