/** * Get a date representing the current instant in time. * * @return a DSpaceDate object representing the current instant. */ public static DCDate getCurrent() { return (new DCDate(new Date())); }
public String getDatestamp(Object nativeItem) { Date d = ((HarvestedItemInfo) nativeItem).datestamp; // Return as ISO8601 return new DCDate(d).toString(); }
protected DCDate recoverEmbargoDate(Item item) { DCDate liftDate = null; List<MetadataValue> lift = itemService.getMetadata(item, lift_schema, lift_element, lift_qualifier, Item.ANY); if (lift.size() > 0) { liftDate = new DCDate(lift.get(0).getValue()); // sanity check: do not allow an embargo lift date in the past. if (liftDate.toDate().before(new Date())) { liftDate = null; } } return liftDate; }
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; } }
/** * Parse the terms into a definite date. Only terms expressions processed * are those defined in 'embargo.terms.days' configuration property. * * @param context the DSpace context * @param item the item to embargo * @param terms the embargo terms * @return parsed date in DCDate format */ @Override public DCDate parseTerms(Context context, Item item, String terms) throws SQLException, AuthorizeException { String termsOpen = DSpaceServicesFactory.getInstance().getConfigurationService() .getProperty("embargo.terms.open"); Properties termProps = getTermProperties(); if (terms != null) { if (termsOpen.equals(terms)) { return EmbargoServiceImpl.FOREVER; } String days = termProps.getProperty(terms); if (days != null && days.length() > 0) { long lift = System.currentTimeMillis() + (Long.parseLong(days) * 24 * 60 * 60 * 1000); return new DCDate(new Date(lift)); } } return null; }
/** * Parse the terms into a definite date. Terms are expected to consist of * either: a token (value configured in 'embargo.terms.open' property) to indicate * indefinite embargo, or a literal lift date formatted in ISO 8601 format (yyyy-mm-dd) * * @param context the DSpace context * @param item the item to embargo * @param terms the embargo terms * @return parsed date in DCDate format */ @Override public DCDate parseTerms(Context context, Item item, String terms) throws SQLException, AuthorizeException { String termsOpen = DSpaceServicesFactory.getInstance().getConfigurationService() .getProperty("embargo.terms.open"); if (terms != null && terms.length() > 0) { if (termsOpen.equals(terms)) { return EmbargoService.FOREVER; } else { return new DCDate(terms); } } return null; }
/** * 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()); } } }
SimpleDateFormat formatter = new SimpleDateFormat(dateFormat); Date date = formatter.parse(dateString); dcDate = new DCDate(date); } catch (ParseException e) {
DCDate liftDate = new DCDate(lift.get(0).getValue());
@Override public Version createNewVersion(Context c, Item item, String summary) { try { VersionHistory vh = versionHistoryService.findByItem(c, item); if (vh == null) { // first time: create 2 versions: old and new one vh = versionHistoryService.create(c); // get dc:date.accessioned to be set as first version date... List<MetadataValue> values = itemService.getMetadata(item, "dc", "date", "accessioned", Item.ANY); Date versionDate = new Date(); if (values != null && values.size() > 0) { String date = values.get(0).getValue(); versionDate = new DCDate(date).toDate(); } createVersion(c, vh, item, "", versionDate); } // Create new Item Item itemNew = provider.createNewItemAndAddItInWorkspace(c, item); // create new version Version version = createVersion(c, vh, itemNew, summary, new Date()); // Complete any update of the Item and new Identifier generation that needs to happen provider.updateItemState(c, itemNew, item); return version; } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
/** * 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()); } } }
/** * 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"); }
itemService.clearMetadata(context, item, dc.schema, dc.element, dc.qualifier, Item.ANY); DCDate date = new DCDate(new Date()); itemService.addMetadata(context, item, dc.schema, dc.element, dc.qualifier, null, date.toString());
itemService.clearMetadata(context, item, info.schema, info.element, info.qualifier, Item.ANY); DCDate date = new DCDate(new Date()); itemService.addMetadata(context, item, info.schema, info.element, info.qualifier, null, date.toString());
itemService.clearMetadata(context, item, info.schema, info.element, info.qualifier, Item.ANY); DCDate date = new DCDate(new Date()); itemService.addMetadata(context, item, info.schema, info.element, info.qualifier, null, date.toString());
acceptanceDCDate = new DCDate(acceptanceDate);
.propertiesBuilder(solrConfigDir); PropertiesConfiguration config = builder.getConfiguration(); config.setProperty("workflow-start-date", new DCDate(oldestDate)); builder.save(); } catch (ConfigurationException e) { .setProperty("usage-statistics.workflow-start-date", new DCDate(oldestDate).toString()); return new DCDate(workflowStartDate).toDate();
for (MetadataValue dcv : currentDateIssued) { if (dcv.getValue() != null && dcv.getValue().equalsIgnoreCase("today")) { DCDate issued = new DCDate(now.getYear(), now.getMonth(), now.getDay(), -1, -1, -1); itemService.addMetadata(c, item, dcv.getMetadataField(), dcv.getLanguage(), issued.toString()); } else if (dcv.getValue() != null) { String previousDateIssued = currentDateIssued.get(0).getValue(); if (previousDateIssued != null && !previousDateIssued.equalsIgnoreCase("today")) { DCDate d = new DCDate(previousDateIssued); provDescription = provDescription + " Previous issue date: " + d.toString();
for (MetadataValue dcv : currentDateIssued) { if (dcv.getValue() != null && dcv.getValue().equalsIgnoreCase("today")) { DCDate issued = new DCDate(now.getYear(), now.getMonth(), now.getDay(), -1, -1, -1); itemService.addMetadata(c, item, dcv.getMetadataField(), dcv.getLanguage(), issued.toString()); } else if (dcv.getValue() != null) {