private void checkSystemMetadataAndPutIfPresentReplaceStrategy(AtmosObject object) throws Exception { long time = System.currentTimeMillis(); boolean update = true; try { getApi().getSystemMetadata(privateDirectory + "/object"); } catch (KeyNotFoundException ex) { update = false; } try { if (update) getApi().updateFile(privateDirectory, object); else getApi().createFile(privateDirectory, object); System.err.printf("%s %s; %dms%n", update ? "updated" : "created", object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis() - time); } catch (Exception e) { String message = Throwables.getRootCause(e).getMessage(); System.err.printf("failure %s %s; %dms: [%s]%n", update ? "updating" : "creating", object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis() - time, message); throw e; } } }
private void checkSystemMetadataAndPutIfPresentReplaceStrategy(AtmosObject object) throws Exception { long time = System.currentTimeMillis(); boolean update = true; try { getApi().getSystemMetadata(privateDirectory + "/object"); } catch (KeyNotFoundException ex) { update = false; } try { if (update) getApi().updateFile(privateDirectory, object); else getApi().createFile(privateDirectory, object); System.err.printf("%s %s; %dms%n", update ? "updated" : "created", object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis() - time); } catch (Exception e) { String message = Throwables.getRootCause(e).getMessage(); System.err.printf("failure %s %s; %dms: [%s]%n", update ? "updating" : "creating", object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis() - time, message); throw e; } } }