1 40 package org.dspace.content; 41 42 import java.io.IOException ; 43 import java.sql.SQLException ; 44 45 import org.dspace.authorize.AuthorizeException; 46 import org.dspace.core.ConfigurationManager; 47 import org.dspace.core.Context; 48 import org.dspace.handle.HandleManager; 49 import org.dspace.search.DSIndexer; 50 51 57 public class InstallItem 58 { 59 70 public static Item installItem(Context c, InProgressSubmission is) 71 throws SQLException , IOException , AuthorizeException 72 { 73 return installItem(c, is, null); 74 } 75 76 87 public static Item installItem(Context c, InProgressSubmission is, 88 String suppliedHandle) throws SQLException , 89 IOException , AuthorizeException 90 { 91 Item item = is.getItem(); 92 String handle; 93 94 DCDate now = DCDate.getCurrent(); 96 item.addDC("date", "accessioned", null, now.toString()); 97 item.addDC("date", "available", null, now.toString()); 98 99 DCValue[] currentDateIssued = item.getDC("date", "issued", Item.ANY); 101 102 if (currentDateIssued.length == 0) 103 { 104 item.addDC("date", "issued", null, now.toString()); 105 } 106 107 if (suppliedHandle == null) 109 { 110 handle = HandleManager.createHandle(c, item); 112 } 113 else 114 { 115 handle = HandleManager.createHandle(c, item, suppliedHandle); 116 } 117 118 String handleref = HandleManager.getCanonicalForm(handle); 119 120 item.addDC("identifier", "uri", null, handleref); 122 123 String provDescription = "Made available in DSpace on " + now 124 + " (GMT). " + getBitstreamProvenanceMessage(item); 125 126 if (currentDateIssued.length != 0) 127 { 128 DCDate d = new DCDate(currentDateIssued[0].value); 129 provDescription = provDescription + " Previous issue date: " 130 + d.toString(); 131 } 132 133 item.addDC("description", "provenance", "en", provDescription); 135 136 is.getCollection().addItem(item); 138 139 item.setOwningCollection(is.getCollection()); 141 142 item.setArchived(true); 144 145 item.update(); 147 148 DSIndexer.indexContent(c, item); 150 151 is.deleteWrapper(); 153 154 item.inheritCollectionDefaultPolicies(is.getCollection()); 157 158 return item; 159 } 160 161 162 170 public static String getBitstreamProvenanceMessage(Item myitem) 171 throws SQLException 172 { 173 Bitstream[] bitstreams = myitem.getNonInternalBitstreams(); 175 176 String mymessage = "No. of bitstreams: " + bitstreams.length + "\n"; 178 179 for (int j = 0; j < bitstreams.length; j++) 181 { 182 mymessage = mymessage + bitstreams[j].getName() + ": " 183 + bitstreams[j].getSize() + " bytes, checksum: " 184 + bitstreams[j].getChecksum() + " (" 185 + bitstreams[j].getChecksumAlgorithm() + ")\n"; 186 } 187 188 return mymessage; 189 } 190 } 191 | Popular Tags |