private void loadFile()

in clearcase-server/src/jetbrains/buildServer/buildTriggers/vcs/clearcase/CCPatchProvider.java [154:205]


  private void loadFile(final String line, final PatchBuilder builder, String relativePath) throws VcsException {
    try {
      final File tempFile = getTempFile();
      FileUtil.delete(tempFile);

      myConnection.loadFileContent(tempFile, line);
      if (tempFile.isFile()) {
        final String pathWithoutVersion =
          CCPathElement.replaceLastVersionAndReturnFullPathWithVersions(line, myConnection.getViewWholePath(), null);
        ClearCaseFileAttr fileAttr = myConnection.loadFileAttr(pathWithoutVersion + CCParseUtil.CC_VERSION_SEPARATOR);

        final String fileMode = fileAttr.isIsExecutable() ? EXECUTABLE_ATTR : null;
        if (fileAttr.isIsText()) {
          final FileInputStream input = new FileInputStream(tempFile);
          try {
            builder.changeOrCreateTextFile(new File(relativePath), fileMode, input, tempFile.length(), null);
          } finally {
            input.close();
          }
        }
        else {
          final FileInputStream input = new FileInputStream(tempFile);
          try {
            builder.changeOrCreateBinaryFile(new File(relativePath), fileMode, input, tempFile.length());
          } finally {
            input.close();
          }
        }

      }
    } catch (ExecutionException e) {
      throw new VcsException(e);
    } catch (InterruptedException e) {
      throw new VcsException(e);
    } catch (IOException primary) {
      //TODO: apply ILineFilter for such errors?
      //TW-10811 hotfix: threat files that cannot get own context as "rmelem'ed"
      if (primary.getMessage().contains("Operation \"get cleartext\" failed: not a ClearCase object.")) {
        try {
          LOG.warn(
            String.format("Could not get content of \"%s\", perhaps element was \"rmelem\"'ed. 'll produce deletion. Original message: %s",
                          line,
                          primary.getMessage()));
          builder.deleteFile(new File(relativePath), false);
        } catch (IOException secondary) {
          throw new VcsException(secondary.initCause(primary));//keep source exception as cause
        }
        return;
      }
      throw new VcsException(primary);
    }
  }