public void save() { if (!this.where.getParentFile().isDirectory() && !this.where.getParentFile().mkdirs()) throw new RuntimeException("Cannot create directory in " + this.where.getParent()); try { codec.enc().to(this.where).put(data).flush(); assert this.where.isFile(); } catch (Exception e) { throw new RuntimeException("Cannot write settings file " + this.where, e); } }
public Encoder put(Object object) throws Exception { if (app == null) to(); codec.encode(this, object, null, new IdentityHashMap<Object,Type>()); flush(); return this; }
public Encoder put(Object object) throws Exception { if (app == null) to(); codec.encode(this, object, null, new IdentityHashMap<>()); flush(); if (!keepOpen) close(); return this; }
public Encoder put(Object object) throws Exception { if (app == null) to(); codec.encode(this, object, null, new IdentityHashMap<Object,Type>()); flush(); if (!keepOpen) close(); return this; }
public Encoder put(Object object) throws Exception { if (app == null) to(); codec.encode(this, object, null, new IdentityHashMap<Object,Type>()); flush(); if (!keepOpen) close(); return this; }
public Encoder put(Object object) throws Exception { if (app == null) to(); codec.encode(this, object, null, new IdentityHashMap<Object,Type>()); flush(); if (!keepOpen) close(); return this; }
public Encoder put(Object object) throws Exception { if (app == null) to(); codec.encode(this, object, null, new IdentityHashMap<>()); flush(); if (!keepOpen) close(); return this; }
public Encoder put(Object object) throws Exception { if (app == null) to(); codec.encode(this, object, null, new IdentityHashMap<>()); flush(); if (!keepOpen) close(); return this; }
public Encoder put(Object object) throws Exception { if (app == null) to(); codec.encode(this, object, null, new IdentityHashMap<Object,Type>()); flush(); if (!keepOpen) close(); return this; }
public Encoder put(Object object) throws Exception { if (app == null) to(); codec.encode(this, object, null, new IdentityHashMap<Object,Type>()); flush(); if (!keepOpen) close(); return this; }
public Encoder put(Object object) throws Exception { if (app == null) to(); codec.encode(this, object, null, new IdentityHashMap<Object,Type>()); flush(); if (!keepOpen) close(); return this; }
public Encoder put(Object object) throws Exception { if (app == null) to(); codec.encode(this, object, null, new IdentityHashMap<Object,Type>()); flush(); if (!keepOpen) close(); return this; }
@SuppressWarnings("resource") public void save(char[] password) { if (!this.where.getParentFile().isDirectory() && !this.where.getParentFile().mkdirs()) throw new RuntimeException("Cannot create directory in " + this.where.getParent()); try { OutputStream out = new FileOutputStream(this.where); try { if (password != null) { PasswordCryptor cryptor = new PasswordCryptor(); out = cryptor.encrypt(password, out); } else { String secret = System.getenv().get("BND-SETTINGS-PASSWORD"); if (secret != null) { PasswordCryptor cryptor = new PasswordCryptor(); out = cryptor.encrypt(secret.toCharArray(), out); } } codec.enc().to(out).put(data).flush(); } finally { out.close(); } assert this.where.isFile(); } catch (Exception e) { throw new RuntimeException("Cannot write settings file " + this.where, e); } }
@SuppressWarnings("resource") public void save(char[] password) { if (!this.where.getParentFile().isDirectory() && !this.where.getParentFile().mkdirs()) throw new RuntimeException("Cannot create directory in " + this.where.getParent()); try { OutputStream out = new FileOutputStream(this.where); try { if (password != null) { PasswordCryptor cryptor = new PasswordCryptor(); out = cryptor.encrypt(password, out); } else { String secret = System.getenv().get("BND-SETTINGS-PASSWORD"); if (secret != null) { PasswordCryptor cryptor = new PasswordCryptor(); out = cryptor.encrypt(secret.toCharArray(), out); } } codec.enc().to(out).put(data).flush(); } finally { out.close(); } assert this.where.isFile(); } catch (Exception e) { throw new RuntimeException("Cannot write settings file " + this.where, e); } }
private void doOutput(Object put, final URLConnection con, HttpRequest<?> rq) throws IOException, Exception { con.setDoOutput(true); try (OutputStream out = con.getOutputStream()) { if (put instanceof InputStream) { logger.debug("out {} input stream {}", rq.verb, rq.url); IO.copy((InputStream) put, out); } else if (put instanceof String) { logger.debug("out {} string {}", rq.verb, rq.url); IO.store(put, out); } else if (put instanceof byte[]) { logger.debug("out {} byte[] {}", rq.verb, rq.url); IO.copy((byte[]) put, out); } else if (put instanceof File) { logger.debug("out {} file {} {}", rq.verb, put, rq.url); IO.copy((File) put, out); } else { logger.debug("out {} JSON {} {}", rq.verb, put, rq.url); codec.enc() .to(out) .put(put) .flush(); } } }
private void doOutput(Object put, final URLConnection con, HttpRequest<?> rq) throws IOException, Exception { con.setDoOutput(true); try (OutputStream out = con.getOutputStream()) { if (put instanceof InputStream) { logger.debug("out {} input stream {}", rq.verb, rq.url); IO.copy((InputStream) put, out); } else if (put instanceof String) { logger.debug("out {} string {}", rq.verb, rq.url); IO.store(put, out); } else if (put instanceof byte[]) { logger.debug("out {} byte[] {}", rq.verb, rq.url); IO.copy((byte[]) put, out); } else if (put instanceof File) { logger.debug("out {} file {} {}", rq.verb, put, rq.url); IO.copy((File) put, out); } else { logger.debug("out {} JSON {} {}", rq.verb, put, rq.url); codec.enc() .to(out) .put(put) .flush(); } } }
.to(out) .put(data) .flush(); } finally { out.close();
.to(out) .put(data) .flush(); } finally { out.close();
.to(out) .put(data) .flush(); } finally { out.close();