/** * Save the provided object data back into storage * * @param data * The data to save * @param oid * The object we want it saved in */ private void saveObjectData(DigitalObject in, JsonSimple data, String pid) throws TransformerException { String jsonString = data.toString(true); try { InputStream inStream = new ByteArrayInputStream( jsonString.getBytes("UTF-8")); in.updatePayload(pid, inStream); } catch (Exception ex) { log.error("Unable to store data '{}': ", pid, ex); throw new TransformerException(ex); } }
public static Payload createOrUpdatePayload(DigitalObject object, String pid, InputStream in, String filePath) throws StorageException { Payload payload = null; try { if (filePath == null) { payload = object.createStoredPayload(pid, in); } else { payload = object.createLinkedPayload(pid, filePath); } } catch (StorageException ex) { try { payload = object.updatePayload(pid, in); } catch (StorageException ex1) { throw ex1; } } return payload; }
/** * Update the data payload (ending in '.tfpackage') in the provided object. * * @param object * The digital object holding our payload * @param input * The String to store * @throws StorageException * if an errors occurs or the payload is not found */ private void updateDataPayload(DigitalObject object, String input) throws StorageException { try { for (String pid : object.getPayloadIdList()) { if (pid.endsWith(DATA_PAYLOAD_SUFFIX)) { InputStream inStream = new ByteArrayInputStream( input.getBytes("UTF-8")); object.updatePayload(pid, inStream); return; } } throw new StorageException("Data payload not found on storage!"); } catch (Exception ex) { throw new StorageException("Error storing payload data!", ex); } } }
rulesObj.updatePayload(externalFile.getName(), in);
/** * Save the provided object data back into storage * * @param data The data to save * @param oid The object we want it saved in */ private void saveObjectData(JsonSimple data, String oid) throws TransactionException { // Get from storage DigitalObject object = null; try { object = storage.getObject(oid); object.getPayload(DATA_PAYLOAD_ID); } catch (StorageException ex) { log.error("Error accessing object '{}' in storage: ", oid, ex); throw new TransactionException(ex); } // Store modifications String jsonString = data.toString(true); try { InputStream inStream = new ByteArrayInputStream( jsonString.getBytes("UTF-8")); object.updatePayload(DATA_PAYLOAD_ID, inStream); } catch (Exception ex) { log.error("Unable to store data '{}': ", oid, ex); throw new TransactionException(ex); } }
object.updatePayload(object.getSourceId(), in);
/** * Store the provided data * * @param object : The object to store the data in * @param pid : The payload ID to use in the object * @param data : The data to store * @return Payload: The payload object successfully stored * @throws TransformerException if storage fails */ protected Payload storeData(DigitalObject object, String pid, String data) throws TransformerException { try { try { return object.createStoredPayload(pid, stream(data)); } catch (StorageException ex) { // Already exists, try an update return object.updatePayload(pid, stream(data)); } } catch (UnsupportedEncodingException ex) { throw new TransformerException("Error in data encoding: ", ex); } catch (StorageException ex) { throw new TransformerException("Error storing payload: ", ex); } }
try { inStream = new ByteArrayInputStream(jsonString.getBytes("UTF-8")); object.updatePayload(DATA_PAYLOAD_ID, inStream); } catch (Exception ex) { log.error("Unable to store data '{}': ", oid, ex);
} catch (StorageException ex) { return object.updatePayload(pid, stream(data));
object.updatePayload(payloadId, in);