Applied patch for SF bug #1145527 Able to delete 'unknown' bitstream format

git-svn-id: http://scm.dspace.org/svn/repo/trunk@1122 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Scott Yeadon
2005-03-11 00:31:12 +00:00
parent 90ac4c6c51
commit 7e14d92cda
2 changed files with 30 additions and 5 deletions

View File

@@ -52,6 +52,9 @@
<%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %> <%@ taglib uri="http://www.dspace.org/dspace-tags.tld" prefix="dspace" %>
<%@ page import="org.dspace.content.BitstreamFormat" %> <%@ page import="org.dspace.content.BitstreamFormat" %>
<%@ page import="org.dspace.core.Context"%>
<%@ page import="org.dspace.app.webui.util.UIUtil"%>
<% <%
BitstreamFormat[] formats = BitstreamFormat[] formats =
@@ -87,6 +90,8 @@
</tr> </tr>
<% <%
Context context = UIUtil.obtainContext(request);
String row = "even"; String row = "even";
for (int i = 0; i < formats.length; i++) for (int i = 0; i < formats.length; i++)
{ {
@@ -109,7 +114,14 @@
<input type="text" name="mimetype" value="<%= formats[i].getMIMEType() %>" size=14> <input type="text" name="mimetype" value="<%= formats[i].getMIMEType() %>" size=14>
</td> </td>
<td class="<%= row %>RowOddCol"> <td class="<%= row %>RowOddCol">
<%
if (BitstreamFormat.findUnknown(context).getID() == formats[i].getID()) {
%>
<i><%= formats[i].getShortDescription() %></i>
<% } else { %>
<input type="text" name="short_description" value="<%= formats[i].getShortDescription() %>" size=10> <input type="text" name="short_description" value="<%= formats[i].getShortDescription() %>" size=10>
<% } %>
</td> </td>
<td class="<%= row %>RowEvenCol"> <td class="<%= row %>RowEvenCol">
<input type="text" name="description" value="<%= formats[i].getDescription() %>" size=20> <input type="text" name="description" value="<%= formats[i].getDescription() %>" size=20>
@@ -132,7 +144,13 @@
<input type="submit" name="submit_update" value="Update"> <input type="submit" name="submit_update" value="Update">
</td> </td>
<td class="<%= row %>RowOddCol"> <td class="<%= row %>RowOddCol">
<%
if (BitstreamFormat.findUnknown(context).getID() != formats[i].getID()) {
%>
<input type="submit" name="submit_delete" value="Delete..."> <input type="submit" name="submit_delete" value="Delete...">
<%
}
%>
</td> </td>
</tr> </tr>
</form> </form>

View File

@@ -409,7 +409,11 @@ public class BitstreamFormat
* the new short description * the new short description
*/ */
public void setShortDescription(String s) public void setShortDescription(String s)
throws SQLException
{ {
// You can not reset the unknown's registry's name
BitstreamFormat unknown = findUnknown(bfContext);
if (unknown.getID() != getID())
bfRow.setColumn("short_description", s); bfRow.setColumn("short_description", s);
} }
@@ -562,12 +566,15 @@ public class BitstreamFormat
"Only administrators can delete bitstream formats"); "Only administrators can delete bitstream formats");
} }
// Remove from cache
bfContext.removeCached(this, getID());
// Find "unknown" type // Find "unknown" type
BitstreamFormat unknown = findUnknown(bfContext); BitstreamFormat unknown = findUnknown(bfContext);
if (unknown.getID() == getID())
throw new IllegalArgumentException("The Unknown bitstream format may not be deleted.");
// Remove from cache
bfContext.removeCached(this, getID());
// Set bitstreams with this format to "unknown" // Set bitstreams with this format to "unknown"
int numberChanged = DatabaseManager.updateQuery(bfContext, int numberChanged = DatabaseManager.updateQuery(bfContext,
"UPDATE bitstream SET bitstream_format_id=" + unknown.getID() "UPDATE bitstream SET bitstream_format_id=" + unknown.getID()