private Source getDataAsSource() throws DigitalObjectException { Source src = editor.read(); if (src == null) { // it should never arise; it would need to create datastream again with default data throw new DigitalObjectException( object.getPid(), null, DESCRIPTION_DATASTREAM_ID, "datastream not initialized!", null); } return src; }
@Override public DescriptionMetadata<OaiDcType> getMetadata() throws DigitalObjectException { Source src = getDataAsSource(); DescriptionMetadata<OaiDcType> dm = new DescriptionMetadata<OaiDcType>(); dm.setPid(object.getPid()); dm.setTimestamp(editor.getLastModified()); // dm.setEditor(editorId); OaiDcType dc = DcUtils.unmarshal(src, OaiDcType.class); dm.setData(dc); return dm; }
@Override public void setMetadataAsJson(DescriptionMetadata<String> json, String message) throws DigitalObjectException { String data = json.getData(); OaiDcType dc; if (data == null) { dc = createDefautDc(); } else { ObjectMapper jsMapper = JsonUtils.defaultObjectMapper(); try { dc = jsMapper.readValue(data, OaiDcType.class); } catch (Exception ex) { throw new DigitalObjectException( object.getPid(), null, editor.getProfile().getDsID(), null, ex); } } write(dc, json.getTimestamp(), message); }