Ejemplo n.º 1
0
    private void write(OaiDcType dc, long timestamp, String message) throws DigitalObjectException {
      EditorResult result = editor.createResult();

      // DO NOT include schemaLocation. Fedora validator does not accept it.
      DcUtils.marshal(result, dc, false);
      editor.write(result, timestamp, message);

      // Label: spec requires identifier + title
      StringBuilder label = new StringBuilder();
      if (!dc.getIdentifiers().isEmpty()) {
        label.append(dc.getIdentifiers().get(0).getValue());
      }
      if (!dc.getTitles().isEmpty()) {
        if (label.length() > 0) {
          label.append(' ');
        }
        label.append(dc.getTitles().get(0).getValue());
      }
      String objLabel = label.toString().trim();
      object.setLabel(objLabel.isEmpty() ? "?" : objLabel);

      // DC
      DcStreamEditor dcEditor = handler.objectMetadata();
      DublinCoreRecord dcr = dcEditor.read();
      dcr.setDc(dc);
      dcEditor.write(handler, dcr, message);
    }
Ejemplo n.º 2
0
 DerMetadataHandler(DigitalObjectHandler handler) {
   this.handler = handler;
   this.object = handler.getFedoraObject();
   this.editor =
       object.getEditor(
           FoxmlUtils.inlineProfile(
               DESCRIPTION_DATASTREAM_ID, DcConstants.NS_OAIDC, DESCRIPTION_DATASTREAM_LABEL));
 }
Ejemplo n.º 3
0
 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;
 }
Ejemplo n.º 4
0
 @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;
 }
Ejemplo n.º 5
0
 @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);
 }