コード例 #1
0
  /** {@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;
  }
コード例 #2
0
 /** {@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));
   }
 }
コード例 #3
0
 /** {@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);
   }
 }