public String getDatestamp(Object nativeItem) { Date d = ((HarvestedItemInfo) nativeItem).datestamp; // Return as ISO8601 return new DCDate(d).toString(); }
private boolean itemsChanged(Context context, DSpaceObject dso, long timeStamp) throws SQLException { // construct start and end dates DCDate dcStartDate = new DCDate( new Date(timeStamp) ); DCDate dcEndDate = new DCDate( new Date(System.currentTimeMillis()) ); // convert dates to ISO 8601, stripping the time String startDate = dcStartDate.toString().substring(0, 10); String endDate = dcEndDate.toString().substring(0, 10); // this invocation should return a non-empty list if even 1 item has changed try { return (Harvest.harvest(context, dso, startDate, endDate, 0, 1, !includeAll, false, false, includeAll).size() > 0); } catch (ParseException pe) { // This should never get thrown as we have generated the dates ourselves return false; } }
/** * Add date for bitstream granted (used into the use case for license grant the * {@link LicenseUtils#grantLicense(Context, Item, String, String)} * * @param context the dspace context * @param acceptanceDate the granted date * @throws SQLException */ public void setAcceptanceDate(Context context, DCDate acceptanceDate) throws SQLException { getBitstreamService() .setMetadataSingleValue(context, this, "dcterms", "accessRights", null, null, acceptanceDate.toString()); }
/** * Add the date that this item was last updated */ protected void addLastUpdatedDate() { String config = ConfigurationManager .getProperty("sword-server", "updated.field"); List<MetadataValue> dcv = itemService .getMetadataByMetadataString(item, config); if (dcv != null && dcv.size() == 1) { DCDate dcd = new DCDate(dcv.get(0).getValue()); entry.setUpdated(dcd.toString()); } } }
@Override public DCDate getEmbargoTermsAsDate(Context context, Item item) throws SQLException, AuthorizeException { List<MetadataValue> terms = itemService.getMetadata(item, terms_schema, terms_element, terms_qualifier, Item.ANY); DCDate result = null; // Its poor form to blindly use an object that could be null... if (terms == null) { return null; } result = setter.parseTerms(context, item, terms.size() > 0 ? terms.get(0).getValue() : null); if (result == null) { return null; } // new DCDate(non-date String) means toDate() will return null Date liftDate = result.toDate(); if (liftDate == null) { throw new IllegalArgumentException( "Embargo lift date is uninterpretable: " + result.toString()); } /* * NOTE: We do not check here for past dates as it can result in errors during AIP restoration. * Therefore, UIs should perform any such date validation on input. See DS-3348 */ return result; }
/** * Add the current date to the item metadata. This looks up * the field in which to store this metadata in the configuration * sword.updated.field * * @param item * @throws DSpaceSWORDException */ private void setUpdatedDate(Item item) throws DSpaceSWORDException { String field = ConfigurationManager.getProperty("sword-server", "updated.field"); if (field == null || "".equals(field)) { throw new DSpaceSWORDException("No configuration, or configuration is invalid for: sword.updated.field"); } DCValue dc = this.configToDC(field, null); item.clearMetadata(dc.schema, dc.element, dc.qualifier, Item.ANY); DCDate date = new DCDate(new Date()); item.addMetadata(dc.schema, dc.element, dc.qualifier, null, date.toString()); swordService.message("Updated date added to response from item metadata where available"); }
/** * Add the date that this item was last updated * */ protected void addLastUpdatedDate() { String config = ConfigurationManager.getProperty("sword-server", "updated.field"); DCValue[] dcv = item.getMetadata(config); if (dcv != null && dcv.length == 1) { DCDate dcd = new DCDate(dcv[0].value); entry.setUpdated(dcd.toString()); } } }
@Override public void liftEmbargo(Context context, Item item) throws SQLException, AuthorizeException, IOException { // Since 3.0 the lift process for all embargoes is performed through the dates // on the authorization process (see DS-2588) // lifter.liftEmbargo(context, item); itemService.clearMetadata(context, item, lift_schema, lift_element, lift_qualifier, Item.ANY); // set the dc.date.available value to right now itemService.clearMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "available", Item.ANY); itemService.addMetadata(context, item, MetadataSchema.DC_SCHEMA, "date", "available", null, DCDate.getCurrent().toString()); log.info("Lifting embargo on Item " + item.getHandle()); itemService.update(context, item); }
DCDate date = new DCDate(new Date()); itemService.addMetadata(context, item, dc.schema, dc.element, dc.qualifier, null, date.toString()); } catch (SQLException e) { log.error("Caught exception: ", e);
DCDate date = new DCDate(new Date()); itemService.addMetadata(context, item, info.schema, info.element, info.qualifier, null, date.toString()); } catch (SQLException e) { log.error("Exception caught trying to set updated date", e);
DCDate date = new DCDate(new Date()); itemService.addMetadata(context, item, info.schema, info.element, info.qualifier, null, date.toString()); } catch (SQLException e) { log.error("Caught exception trying to set update date", e);
String timestamp = DCDate.getCurrent().toString();
protected void recordStart(Context context, Item myitem) throws SQLException, IOException, AuthorizeException { // get date DCDate now = DCDate.getCurrent(); // Create provenance description String provmessage; if (myitem.getSubmitter() != null) { provmessage = "Submitted by " + myitem.getSubmitter().getFullName() + " (" + myitem.getSubmitter().getEmail() + ") on " + now.toString() + "\n"; } else { // else, null submitter provmessage = "Submitted by unknown (probably automated) on" + now.toString() + "\n"; } // add sizes and checksums of bitstreams provmessage += installItemService.getBitstreamProvenanceMessage(context, myitem); // Add message to the DC itemService .addMetadata(context, myitem, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provmessage); itemService.update(context, myitem); }
protected void recordApproval(Context context, BasicWorkflowItem workflowItem, EPerson e) throws SQLException, IOException, AuthorizeException { Item item = workflowItem.getItem(); // Get user's name + email address String usersName = getEPersonName(e); // Get current date String now = DCDate.getCurrent().toString(); // Here's what happened String provDescription = "Approved for entry into archive by " + usersName + " on " + now + " (GMT) "; // add bitstream descriptions (name, size, checksums) provDescription += installItemService.getBitstreamProvenanceMessage(context, item); // Add to item as a DC field itemService .addMetadata(context, item, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription); itemService.update(context, item); }
protected void recordStart(Context context, Item myitem, Action action) throws SQLException, IOException, AuthorizeException { // get date DCDate now = DCDate.getCurrent(); // Create provenance description String provmessage = ""; if (myitem.getSubmitter() != null) { provmessage = "Submitted by " + myitem.getSubmitter().getFullName() + " (" + myitem.getSubmitter().getEmail() + ") on " + now.toString() + " workflow start=" + action.getProvenanceStartId() + "\n"; } else { // else, null submitter provmessage = "Submitted by unknown (probably automated) on" + now.toString() + " workflow start=" + action.getProvenanceStartId() + "\n"; } // add sizes and checksums of bitstreams provmessage += installItemService.getBitstreamProvenanceMessage(context, myitem); // Add message to the DC itemService .addMetadata(context, myitem, MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provmessage); itemService.update(context, myitem); }
@Override public void setEmbargo(Context context, Item item) throws SQLException, AuthorizeException { // if lift is null, we might be restoring an item from an AIP DCDate myLift = getEmbargoTermsAsDate(context, item); if (myLift == null) { if ((myLift = recoverEmbargoDate(item)) == null) { return; } } String slift = myLift.toString(); try { context.turnOffAuthorisationSystem(); itemService.clearMetadata(context, item, lift_schema, lift_element, lift_qualifier, Item.ANY); itemService.addMetadata(context, item, lift_schema, lift_element, lift_qualifier, null, slift); log.info("Set embargo on Item " + item.getHandle() + ", expires on: " + slift); setter.setEmbargo(context, item); itemService.update(context, item); } finally { context.restoreAuthSystemState(); } }
private void addApprovedProvenance(Context c, XmlWorkflowItem wfi) throws SQLException, AuthorizeException { //Add the provenance for the accept String now = DCDate.getCurrent().toString(); // Get user's name + email address String usersName = XmlWorkflowServiceFactory.getInstance().getXmlWorkflowService() .getEPersonName(c.getCurrentUser()); String provDescription = getProvenanceStartId() + " Approved for entry into archive by " + usersName + " on " + now + " (GMT) "; // Add to item as a DC field itemService.addMetadata(c, wfi.getItem(), MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription); itemService.update(c, wfi.getItem()); }
private void addApprovedProvenance(Context c, XmlWorkflowItem wfi) throws SQLException, AuthorizeException { //Add the provenance for the accept String now = DCDate.getCurrent().toString(); // Get user's name + email address String usersName = XmlWorkflowServiceFactory.getInstance().getXmlWorkflowService() .getEPersonName(c.getCurrentUser()); String provDescription = getProvenanceStartId() + " Approved for entry into archive by " + usersName + " on " + now + " (GMT) "; // Add to item as a DC field itemService.addMetadata(c, wfi.getItem(), MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription); itemService.update(c, wfi.getItem()); }
private void addApprovedProvenance(Context c, XmlWorkflowItem wfi) throws SQLException, AuthorizeException { //Add the provenance for the accept String now = DCDate.getCurrent().toString(); // Get user's name + email address String usersName = XmlWorkflowServiceFactory.getInstance().getXmlWorkflowService() .getEPersonName(c.getCurrentUser()); String provDescription = getProvenanceStartId() + " Approved for entry into archive by " + usersName + " on " + now + " (GMT) "; // Add to item as a DC field itemService.addMetadata(c, wfi.getItem(), MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription); itemService.update(c, wfi.getItem()); }
private void addApprovedProvenance(Context c, XmlWorkflowItem wfi) throws SQLException, AuthorizeException { //Add the provenance for the accept String now = DCDate.getCurrent().toString(); // Get user's name + email address String usersName = XmlWorkflowServiceFactory.getInstance().getXmlWorkflowService() .getEPersonName(c.getCurrentUser()); String provDescription = getProvenanceStartId() + " Approved for entry into archive by " + usersName + " on " + now + " (GMT) "; // Add to item as a DC field itemService.addMetadata(c, wfi.getItem(), MetadataSchema.DC_SCHEMA, "description", "provenance", "en", provDescription); itemService.update(c, wfi.getItem()); } }