Search in sources :

Example 6 with IntegrityScmProviderRepository

use of org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository 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 7 with IntegrityScmProviderRepository

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

the class IntegrityStatusCommand method executeStatusCommand.

/**
 * {@inheritDoc}
 */
@Override
public StatusScmResult executeStatusCommand(ScmProviderRepository repository, ScmFileSet fileSet) throws ScmException {
    StatusScmResult result;
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    getLogger().info("Status of files changed in sandbox " + fileSet.getBasedir().getAbsolutePath());
    try {
        // Initialize the list of ScmFile objects for the StatusScmResult
        List<ScmFile> scmFileList = new ArrayList<ScmFile>();
        // Get a listing for all the changes in the sandbox
        Sandbox siSandbox = iRepo.getSandbox();
        // Get the excludes and includes list from the configuration
        String excludes = Sandbox.formatFilePatterns(fileSet.getExcludes());
        String includes = Sandbox.formatFilePatterns(fileSet.getIncludes());
        // Get the new members found in the sandbox
        List<ScmFile> newMemberList = siSandbox.getNewMembers(excludes, includes);
        // Update the scmFileList with our updates
        scmFileList.addAll(newMemberList);
        // Get the changed/dropped members from the sandbox
        List<WorkItem> changeList = siSandbox.getChangeList();
        for (Iterator<WorkItem> wit = changeList.iterator(); wit.hasNext(); ) {
            WorkItem wi = wit.next();
            File memberFile = new File(wi.getField("name").getValueAsString());
            // Separate the changes into files that have been updated and deleted files
            if (siSandbox.hasWorkingFile((Item) wi.getField("wfdelta").getValue())) {
                scmFileList.add(new ScmFile(memberFile.getAbsolutePath(), ScmFileStatus.UPDATED));
            } else {
                scmFileList.add(new ScmFile(memberFile.getAbsolutePath(), ScmFileStatus.DELETED));
            }
        }
        if (scmFileList.size() == 0) {
            getLogger().info("No local changes found!");
        }
        result = new StatusScmResult(scmFileList, new ScmResult("si viewsandbox", "", "", true));
    } catch (APIException aex) {
        ExceptionHandler eh = new ExceptionHandler(aex);
        getLogger().error("MKS API Exception: " + eh.getMessage());
        getLogger().debug(eh.getCommand() + " exited with return code " + eh.getExitCode());
        result = new StatusScmResult(eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false);
    }
    return result;
}
Also used : StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) ScmResult(org.apache.maven.scm.ScmResult) StatusScmResult(org.apache.maven.scm.command.status.StatusScmResult) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository) ArrayList(java.util.ArrayList) WorkItem(com.mks.api.response.WorkItem) ScmFile(org.apache.maven.scm.ScmFile) Sandbox(org.apache.maven.scm.provider.integrity.Sandbox) ExceptionHandler(org.apache.maven.scm.provider.integrity.ExceptionHandler) APIException(com.mks.api.response.APIException) ScmFile(org.apache.maven.scm.ScmFile) File(java.io.File)

Example 8 with IntegrityScmProviderRepository

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

the class IntegrityListCommand method executeListCommand.

/**
 * {@inheritDoc}
 */
@Override
public ListScmResult executeListCommand(ScmProviderRepository repository, ScmFileSet fileSet, boolean recursive, ScmVersion scmVersion) throws ScmException {
    ListScmResult result;
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    getLogger().info("Listing all files in project " + iRepo.getConfigruationPath());
    try {
        // Get a listing for all the members in the project...
        List<Member> projectMembers = iRepo.getProject().listFiles(fileSet.getBasedir().getAbsolutePath());
        // Initialize the list of ScmFile objects for the ListScmResult
        List<ScmFile> scmFileList = new ArrayList<ScmFile>();
        for (Iterator<Member> it = projectMembers.iterator(); it.hasNext(); ) {
            Member siMember = it.next();
            scmFileList.add(new ScmFile(siMember.getTargetFilePath(), ScmFileStatus.UNKNOWN));
        }
        result = new ListScmResult(scmFileList, new ScmResult("si viewproject", "", "", true));
    } catch (APIException aex) {
        ExceptionHandler eh = new ExceptionHandler(aex);
        getLogger().error("MKS API Exception: " + eh.getMessage());
        getLogger().debug(eh.getCommand() + " exited with return code " + eh.getExitCode());
        result = new ListScmResult(eh.getCommand(), eh.getMessage(), "Exit Code: " + eh.getExitCode(), false);
    }
    return result;
}
Also used : ExceptionHandler(org.apache.maven.scm.provider.integrity.ExceptionHandler) APIException(com.mks.api.response.APIException) ScmResult(org.apache.maven.scm.ScmResult) ListScmResult(org.apache.maven.scm.command.list.ListScmResult) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository) ListScmResult(org.apache.maven.scm.command.list.ListScmResult) ArrayList(java.util.ArrayList) Member(org.apache.maven.scm.provider.integrity.Member) ScmFile(org.apache.maven.scm.ScmFile)

Example 9 with IntegrityScmProviderRepository

use of org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository 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 10 with IntegrityScmProviderRepository

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

the class IntegrityBlameCommand method executeBlameCommand.

/**
 * {@inheritDoc}
 */
@Override
public BlameScmResult executeBlameCommand(ScmProviderRepository repository, ScmFileSet workingDirectory, String filename) throws ScmException {
    getLogger().info("Attempting to display blame results for file: " + filename);
    if (null == filename || filename.length() == 0) {
        throw new ScmException("A single filename is required to execute the blame command!");
    }
    BlameScmResult result;
    IntegrityScmProviderRepository iRepo = (IntegrityScmProviderRepository) repository;
    // Since the si annotate command is not completely API ready, we will use the CLI for this command
    // Ensure shell 'si' client is connected.
    doShellConnect(iRepo, workingDirectory);
    result = doShellAnnotate(iRepo, workingDirectory, filename);
    return result;
}
Also used : ScmException(org.apache.maven.scm.ScmException) BlameScmResult(org.apache.maven.scm.command.blame.BlameScmResult) IntegrityScmProviderRepository(org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository)

Aggregations

IntegrityScmProviderRepository (org.apache.maven.scm.provider.integrity.repository.IntegrityScmProviderRepository)20 APIException (com.mks.api.response.APIException)15 ExceptionHandler (org.apache.maven.scm.provider.integrity.ExceptionHandler)15 Response (com.mks.api.response.Response)11 ScmResult (org.apache.maven.scm.ScmResult)11 Sandbox (org.apache.maven.scm.provider.integrity.Sandbox)11 ScmException (org.apache.maven.scm.ScmException)8 ScmFile (org.apache.maven.scm.ScmFile)8 ArrayList (java.util.ArrayList)6 WorkItem (com.mks.api.response.WorkItem)4 File (java.io.File)4 APISession (org.apache.maven.scm.provider.integrity.APISession)3 Project (org.apache.maven.scm.provider.integrity.Project)3 Result (com.mks.api.response.Result)2 WorkItemIterator (com.mks.api.response.WorkItemIterator)2 Member (org.apache.maven.scm.provider.integrity.Member)2 CommandLineException (org.codehaus.plexus.util.cli.CommandLineException)2 CommandLineUtils (org.codehaus.plexus.util.cli.CommandLineUtils)2 Commandline (org.codehaus.plexus.util.cli.Commandline)2 AddScmResult (org.apache.maven.scm.command.add.AddScmResult)1