コード例 #1
0
  private void init(File publicKeyFile)
      throws OpenShiftException, FileNotFoundException, IOException {
    String keyWithIdAndComment = StreamUtils.readToString(new FileReader(publicKeyFile));
    Matcher matcher = PUBLICKEY_PATTERN.matcher(keyWithIdAndComment);
    if (!matcher.find() || matcher.groupCount() < 1) {
      throw new OpenShiftException(
          "Could not load public key from file \"{0}\": unknown key format.",
          publicKeyFile.getAbsolutePath());
    }

    setKeyType(matcher.group(1));
    this.publicKey = matcher.group(2);
  }
コード例 #2
0
 public String restoreSnapshot(IProgressMonitor monitor) throws IOException {
   if (monitor.isCanceled()) {
     return null;
   }
   storeSnapshotToPreferences(filepath, deploymentSnapshot);
   Session session = SSHSessionRepository.getInstance().getSession(application);
   FileInputStream snapshotFileInputStream = new FileInputStream(new File(getFilepath()));
   InputStream saveResponse = null;
   if (isDeploymentSnapshot()) {
     saveResponse =
         new ApplicationSSHSession(application, session)
             .restoreDeploymentSnapshot(snapshotFileInputStream, hotDeploy);
   } else {
     saveResponse =
         new ApplicationSSHSession(application, session)
             .restoreFullSnapshot(snapshotFileInputStream);
   }
   ByteArrayOutputStream byteArrayOut = new ByteArrayOutputStream();
   StreamUtils.writeTo(saveResponse, byteArrayOut);
   return new String(byteArrayOut.toByteArray());
 }