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; }
rulesObj = realStorage.createObject(rulesOid); InputStream in = new FileInputStream(externalFile); Payload p = rulesObj.createStoredPayload( externalFile.getName(), in); p.setLabel("Fascinator Indexing Rules");
if(itemConfig.getBoolean(false,"versioning")) { String dateStampedPid = getTimestampedPayload(pid); object.createStoredPayload(dateStampedPid, stream(data)); return object.createStoredPayload(pid, stream(data)); } catch (StorageException ex) {
/** * 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); } }
payload = object.createStoredPayload(payloadId, in);