Search in sources :

Example 21 with Response

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

the class IntegrityRemoveCommand method executeRemoveCommand.

/**
 * {@inheritDoc}
 */
@Override
public RemoveScmResult executeRemoveCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message) throws ScmException {
    getLogger().info("Attempting to un-register sandbox in directory " + fileSet.getBasedir().getAbsolutePath());
    RemoveScmResult result;
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    try {
        Sandbox siSandbox = iRepo.getSandbox();
        Response res = siSandbox.drop();
        int exitCode = res.getExitCode();
        boolean success = (exitCode == 0 ? true : false);
        result = new RemoveScmResult(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 RemoveScmResult(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) APIException(com.mks.api.response.APIException) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository) RemoveScmResult(org.apache.maven.scm.command.remove.RemoveScmResult) Sandbox(org.apache.maven.scm.provider.integrity.Sandbox)

Example 22 with Response

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

the class IntegrityTagCommand method executeTagCommand.

/**
 * {@inheritDoc}
 */
@Override
public TagScmResult executeTagCommand(ScmProviderRepository repository, ScmFileSet fileSet, String tagName, ScmTagParameters scmTagParameters) throws ScmException {
    getLogger().info("Attempting to checkpoint project associated with sandbox " + fileSet.getBasedir().getAbsolutePath());
    TagScmResult result;
    String message = scmTagParameters.getMessage();
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    try {
        // First validate the checkpoint label string by evaluating the groovy script
        String chkptLabel = evalGroovyExpression(tagName);
        Project.validateTag(chkptLabel);
        String msg = ((null == message || message.length() == 0) ? System.getProperty("message") : message);
        // Get information about the Project
        Project siProject = iRepo.getProject();
        // Ensure this is not a build project configuration
        if (!siProject.isBuild()) {
            Response res = siProject.checkpoint(msg, chkptLabel);
            int exitCode = res.getExitCode();
            boolean success = (exitCode == 0 ? true : false);
            WorkItem wi = res.getWorkItem(siProject.getConfigurationPath());
            String chkpt = wi.getResult().getField("resultant").getItem().getId();
            getLogger().info("Successfully checkpointed project " + siProject.getConfigurationPath() + " with label '" + chkptLabel + "', new revision is " + chkpt);
            result = new TagScmResult(res.getCommandString(), wi.getResult().getMessage(), "Exit Code: " + exitCode, success);
        } else {
            getLogger().error("Cannot checkpoint a build project configuration: " + siProject.getConfigurationPath() + "!");
            result = new TagScmResult("si checkpoint", "Cannot checkpoint a build project configuration!", "", false);
        }
    } catch (CompilationFailedException cfe) {
        getLogger().error("Groovy Compilation Exception: " + cfe.getMessage());
        result = new TagScmResult("si checkpoint", cfe.getMessage(), "", false);
    } 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 TagScmResult(eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false);
    } catch (Exception e) {
        getLogger().error("Failed to checkpoint project! " + e.getMessage());
        result = new TagScmResult("si checkpoint", e.getMessage(), "", false);
    }
    return result;
}
Also used : Response(com.mks.api.response.Response) ExceptionHandler(org.apache.maven.scm.provider.integrity.ExceptionHandler) Project(org.apache.maven.scm.provider.integrity.Project) APIException(com.mks.api.response.APIException) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository) CompilationFailedException(org.codehaus.groovy.control.CompilationFailedException) TagScmResult(org.apache.maven.scm.command.tag.TagScmResult) WorkItem(com.mks.api.response.WorkItem) ScmException(org.apache.maven.scm.ScmException) APIException(com.mks.api.response.APIException) CompilationFailedException(org.codehaus.groovy.control.CompilationFailedException)

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