@Test public void testRestoreItem() throws Exception { context.turnOffAuthorisationSystem(); String handle = "1345/567"; Collection col = Collection.create(context); WorkspaceItem is = WorkspaceItem.create(context, col, false); DCDate now = DCDate.getCurrent(); String dayAndTime = now.toString(); String date = dayAndTime.substring(0, dayAndTime.indexOf("T")); String provDescriptionBegins = "Made available in DSpace on " + date; Item result = InstallItem.restoreItem(context, is, handle); context.restoreAuthSystemState(); assertThat("testRestoreItem 0", result, equalTo(is.getItem())); DCValue[] provMsgValues = result.getMetadata("dc", "description", "provenance", Item.ANY); int i = 1; for(DCValue val : provMsgValues) { assertFalse("testRestoreItem " + i, val.value.startsWith(provDescriptionBegins)); i++; } }
public static Item restoreItem(Context c, InProgressSubmission is, String suppliedHandle) throws SQLException, IOException, AuthorizeException { Item item = is.getItem(); String handle; if (suppliedHandle == null) { handle = HandleManager.createHandle(c, item); populateHandleMetadata(item, handle); } else { handle = HandleManager.createHandle(c, item, suppliedHandle); } DCDate now = DCDate.getCurrent(); DCValue[] dateAccessioned = item.getDC("date", "accessioned", Item.ANY); if (dateAccessioned.length == 0) { item.addDC("date", "accessioned", null, now.toString()); } DCValue[] currentDateIssued = item.getDC("date", "issued", Item.ANY); if (currentDateIssued.length == 0) { DCDate issued = new DCDate(now.getYear(),now.getMonth(),now.getDay(),-1,-1,-1); item.addDC("date", "issued", null, issued.toString()); } String provDescription = "Restored into DSpace on "+ now + " (GMT)."; item.addDC("description", "provenance", "en", provDescription); return finishItem(c, item, is, null); }
InstallItem { public static Item restoreItem(Context c, InProgressSubmission is, String suppliedHandle) throws SQLException, IOException, AuthorizeException { Item item = is.getItem(); String handle; if (suppliedHandle == null) { handle = HandleManager.createHandle(c, item); populateHandleMetadata(item, handle); } else { handle = HandleManager.createHandle(c, item, suppliedHandle); } DCDate now = DCDate.getCurrent(); DCValue[] dateAccessioned = item.getDC("date", "accessioned", Item.ANY); if (dateAccessioned.length == 0) { item.addDC("date", "accessioned", null, now.toString()); } DCValue[] currentDateIssued = item.getDC("date", "issued", Item.ANY); if (currentDateIssued.length == 0) { DCDate issued = new DCDate(now.getYear(),now.getMonth(),now.getDay(),-1,-1,-1); item.addDC("date", "issued", null, issued.toString()); } String provDescription = "Restored into DSpace on "+ now + " (GMT)."; item.addDC("description", "provenance", "en", provDescription); return finishItem(c, item, is, null); } }
InstallItem { public static Item restoreItem(Context c, InProgressSubmission is, String suppliedHandle) throws SQLException, IOException, AuthorizeException { Item item = is.getItem(); String handle; if (suppliedHandle == null) { handle = HandleManager.createHandle(c, item); populateHandleMetadata(item, handle); } else { handle = HandleManager.createHandle(c, item, suppliedHandle); } DCDate now = DCDate.getCurrent(); DCValue[] dateAccessioned = item.getDC("date", "accessioned", Item.ANY); if (dateAccessioned.length == 0) { item.addDC("date", "accessioned", null, now.toString()); } DCValue[] currentDateIssued = item.getDC("date", "issued", Item.ANY); if (currentDateIssued.length == 0) { DCDate issued = new DCDate(now.getYear(),now.getMonth(),now.getDay(),-1,-1,-1); item.addDC("date", "issued", null, issued.toString()); } String provDescription = "Restored into DSpace on "+ now + " (GMT)."; item.addDC("description", "provenance", "en", provDescription); return finishItem(c, item, is, null); }  }
InstallItem { public static Item restoreItem(Context c, InProgressSubmission is, String suppliedHandle) throws SQLException, IOException, AuthorizeException { Item item = is.getItem(); String handle; if (suppliedHandle == null) { handle = HandleManager.createHandle(c, item); populateHandleMetadata(item, handle); } else { handle = HandleManager.createHandle(c, item, suppliedHandle); } DCDate now = DCDate.getCurrent(); DCValue[] dateAccessioned = item.getDC("date", "accessioned", Item.ANY); if (dateAccessioned.length == 0) { item.addDC("date", "accessioned", null, now.toString()); } DCValue[] currentDateIssued = item.getDC("date", "issued", Item.ANY); if (currentDateIssued.length == 0) { DCDate issued = new DCDate(now.getYear(),now.getMonth(),now.getDay(),-1,-1,-1); item.addDC("date", "issued", null, issued.toString()); } String provDescription = "Restored into DSpace on "+ now + " (GMT)."; item.addDC("description", "provenance", "en", provDescription); return finishItem(c, item, is, null); }  static Item installItem(Context c, InProgressSubmission is); static Item installItem(Context c, InProgressSubmission is,
            String suppliedHandle); static Item restoreItem(Context c, InProgressSubmission is,
            String suppliedHandle); static String getBitstreamProvenanceMessage(Item myitem); }
InstallItem { public static Item restoreItem(Context c, InProgressSubmission is, String suppliedHandle) throws SQLException, IOException, AuthorizeException { Item item = is.getItem(); String handle; if (suppliedHandle == null) { handle = HandleManager.createHandle(c, item); populateHandleMetadata(item, handle); } else { handle = HandleManager.createHandle(c, item, suppliedHandle); } DCDate now = DCDate.getCurrent(); DCValue[] dateAccessioned = item.getDC("date", "accessioned", Item.ANY); if (dateAccessioned.length == 0) { item.addDC("date", "accessioned", null, now.toString()); } DCValue[] currentDateIssued = item.getDC("date", "issued", Item.ANY); if (currentDateIssued.length == 0) { DCDate issued = new DCDate(now.getYear(),now.getMonth(),now.getDay(),-1,-1,-1); item.addDC("date", "issued", null, issued.toString()); } String provDescription = "Restored into DSpace on "+ now + " (GMT)."; item.addDC("description", "provenance", "en", provDescription); return finishItem(c, item, is, null); }  static Item installItem(Context c, InProgressSubmission is); static Item installItem(Context c, InProgressSubmission is,
            String suppliedHandle); static Item restoreItem(Context c, InProgressSubmission is,
            String suppliedHandle); static String getBitstreamProvenanceMessage(Item myitem);  }