Search in sources :

Example 6 with Sandbox

use of org.apache.maven.scm.provider.integrity.Sandbox in project maven-scm by apache.

the class IntegrityCheckInCommand method executeCheckInCommand.

/**
 * {@inheritDoc}
 */
@Override
public CheckInScmResult executeCheckInCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, ScmVersion scmVersion) throws ScmException {
    getLogger().info("Attempting to check-in updates from sandbox " + fileSet.getBasedir().getAbsolutePath());
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    Sandbox siSandbox = iRepo.getSandbox();
    List<ScmFile> changedFiles = siSandbox.checkInUpdates(message);
    if (siSandbox.getOverallCheckInSuccess()) {
        return new CheckInScmResult("si ci/drop", changedFiles);
    } else {
        return new CheckInScmResult(changedFiles, new ScmResult("si ci/drop", "There was a problem updating the repository", "", false));
    }
}
Also used : ScmResult(org.apache.maven.scm.ScmResult) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository) CheckInScmResult(org.apache.maven.scm.command.checkin.CheckInScmResult) Sandbox(org.apache.maven.scm.provider.integrity.Sandbox) ScmFile(org.apache.maven.scm.ScmFile)

Example 7 with Sandbox

use of org.apache.maven.scm.provider.integrity.Sandbox in project maven-scm by apache.

the class IntegrityAddCommand method executeAddCommand.

/**
 * {@inheritDoc}
 */
@Override
public AddScmResult executeAddCommand(ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean binary) throws ScmException {
    getLogger().info("Attempting to add new files from directory " + fileSet.getBasedir().getAbsolutePath());
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    Sandbox siSandbox = iRepo.getSandbox();
    String excludes = Sandbox.formatFilePatterns(fileSet.getExcludes());
    String includes = Sandbox.formatFilePatterns(fileSet.getIncludes());
    String msg = ((null == message || message.length() == 0) ? System.getProperty("message") : message);
    List<ScmFile> addedFiles = siSandbox.addNonMembers(excludes, includes, msg);
    if (siSandbox.getOverallAddSuccess()) {
        return new AddScmResult("si add", addedFiles);
    } else {
        return new AddScmResult(addedFiles, new ScmResult("si add", "There was a problem adding files to the repository", "", false));
    }
}
Also used : AddScmResult(org.apache.maven.scm.command.add.AddScmResult) ScmResult(org.apache.maven.scm.ScmResult) AddScmResult(org.apache.maven.scm.command.add.AddScmResult) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository) Sandbox(org.apache.maven.scm.provider.integrity.Sandbox) ScmFile(org.apache.maven.scm.ScmFile)

Example 8 with Sandbox

use of org.apache.maven.scm.provider.integrity.Sandbox in project maven-scm by apache.

the class IntegrityUnEditCommand method executeUnEditCommand.

/**
 * {@inheritDoc}
 */
@Override
public UnEditScmResult executeUnEditCommand(ScmProviderRepository repository, ScmFileSet fileSet) throws ScmException {
    getLogger().info("Attempting to revert members in sandbox " + fileSet.getBasedir().getAbsolutePath());
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    UnEditScmResult result;
    try {
        Sandbox siSandbox = iRepo.getSandbox();
        Response res = siSandbox.revertMembers();
        int exitCode = res.getExitCode();
        boolean success = (exitCode == 0 ? true : false);
        result = new UnEditScmResult(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 UnEditScmResult(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) UnEditScmResult(org.apache.maven.scm.command.unedit.UnEditScmResult) Sandbox(org.apache.maven.scm.provider.integrity.Sandbox)

Example 9 with Sandbox

use of org.apache.maven.scm.provider.integrity.Sandbox in project maven-scm by apache.

the class IntegrityUpdateCommand method executeUpdateCommand.

/**
 * {@inheritDoc}
 */
@Override
public UpdateScmResult executeUpdateCommand(ScmProviderRepository repository, ScmFileSet fileSet, ScmVersion scmVersion) throws ScmException {
    getLogger().info("Attempting to synchronize sandbox in " + fileSet.getBasedir().getAbsolutePath());
    List<ScmFile> updatedFiles = new ArrayList<ScmFile>();
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    Sandbox siSandbox = iRepo.getSandbox();
    try {
        // Make sure we've got a valid sandbox, otherwise create it...
        if (siSandbox.create()) {
            Response res = siSandbox.resync();
            // Lets capture what we got from running this resync
            WorkItemIterator wit = res.getWorkItems();
            while (wit.hasNext()) {
                WorkItem wi = wit.next();
                if (wi.getModelType().equals(SIModelTypeName.MEMBER)) {
                    Result message = wi.getResult();
                    getLogger().debug(wi.getDisplayId() + " " + (null != message ? message.getMessage() : ""));
                    if (null != message && message.getMessage().length() > 0) {
                        updatedFiles.add(new ScmFile(wi.getDisplayId(), message.getMessage().equalsIgnoreCase("removed") ? ScmFileStatus.DELETED : ScmFileStatus.UPDATED));
                    }
                }
            }
            return new UpdateScmResult(res.getCommandString(), updatedFiles);
        } else {
            return new UpdateScmResult("si resync", "Failed to synchronize workspace", "", 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());
        return new UpdateScmResult(eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false);
    }
}
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) ArrayList(java.util.ArrayList) UpdateScmResult(org.apache.maven.scm.command.update.UpdateScmResult) WorkItemIterator(com.mks.api.response.WorkItemIterator) WorkItem(com.mks.api.response.WorkItem) ScmFile(org.apache.maven.scm.ScmFile) Sandbox(org.apache.maven.scm.provider.integrity.Sandbox) UpdateScmResult(org.apache.maven.scm.command.update.UpdateScmResult) Result(com.mks.api.response.Result)

Example 10 with Sandbox

use of org.apache.maven.scm.provider.integrity.Sandbox in project maven-scm by apache.

the class IntegrityLoginCommand method executeLoginCommand.

/**
 * {@inheritDoc}
 */
@Override
public LoginScmResult executeLoginCommand(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters params) throws ScmException {
    getLogger().info("Attempting to connect with the MKS Integrity Server");
    LoginScmResult result;
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    APISession api = iRepo.getAPISession();
    try {
        // First we will establish a connection to the MKS Integrity Server
        Response res = api.connect(iRepo.getHost(), iRepo.getPort(), iRepo.getUser(), iRepo.getPassword());
        int exitCode = res.getExitCode();
        boolean success = (exitCode == 0 ? true : false);
        result = new LoginScmResult(res.getCommandString(), "", "Exit Code: " + exitCode, success);
        // Next we will prepare the Project and Sandbox for the other commands
        Project siProject = new Project(api, iRepo.getConfigruationPath());
        Sandbox siSandbox = new Sandbox(api, siProject, fileSet.getBasedir().getAbsolutePath());
        iRepo.setProject(siProject);
        iRepo.setSandbox(siSandbox);
    } 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 LoginScmResult(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) Project(org.apache.maven.scm.provider.integrity.Project) APIException(com.mks.api.response.APIException) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository) LoginScmResult(org.apache.maven.scm.command.login.LoginScmResult) APISession(org.apache.maven.scm.provider.integrity.APISession) Sandbox(org.apache.maven.scm.provider.integrity.Sandbox)

Aggregations

Sandbox (org.apache.maven.scm.provider.integrity.Sandbox)11 IntegrityScmProviderRepository (org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository)11 APIException (com.mks.api.response.APIException)9 ExceptionHandler (org.apache.maven.scm.provider.integrity.ExceptionHandler)9 Response (com.mks.api.response.Response)8 ScmResult (org.apache.maven.scm.ScmResult)5 ScmFile (org.apache.maven.scm.ScmFile)4 WorkItem (com.mks.api.response.WorkItem)3 File (java.io.File)3 Result (com.mks.api.response.Result)2 WorkItemIterator (com.mks.api.response.WorkItemIterator)2 ArrayList (java.util.ArrayList)2 ScmException (org.apache.maven.scm.ScmException)2 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)1 CheckInScmResult (org.apache.maven.scm.command.checkin.CheckInScmResult)1 CheckOutScmResult (org.apache.maven.scm.command.checkout.CheckOutScmResult)1 EditScmResult (org.apache.maven.scm.command.edit.EditScmResult)1 LoginScmResult (org.apache.maven.scm.command.login.LoginScmResult)1 RemoveScmResult (org.apache.maven.scm.command.remove.RemoveScmResult)1 StatusScmResult (org.apache.maven.scm.command.status.StatusScmResult)1