@Test(expected=AuthorizeException.class) public void testUpdateNotAdmin() throws SQLException, AuthorizeException { new NonStrictExpectations() { AuthorizeManager authManager; { AuthorizeManager.isAdmin((Context)any); result = false; } }; bf.update(); fail("Exception should have been thrown"); }
public void update() throws SQLException, AuthorizeException { if (!AuthorizeManager.isAdmin(bfContext)) { throw new AuthorizeException( "Only administrators can modify bitstream formats"); } log.info(LogManager.getHeader(bfContext, "update_bitstream_format", "bitstream_format_id=" + getID())); DatabaseManager.updateQuery(bfContext, "DELETE FROM fileextension WHERE bitstream_format_id= ? ", getID()); for (int i = 0; i < extensions.size(); i++) { String s = extensions.get(i); TableRow r = DatabaseManager.row("fileextension"); r.setColumn("bitstream_format_id", getID()); r.setColumn("extension", s); DatabaseManager.insert(bfContext, r); } DatabaseManager.update(bfContext, bfRow); }
BitstreamFormat { public void update() throws SQLException, AuthorizeException { if (!AuthorizeManager.isAdmin(bfContext)) { throw new AuthorizeException( "Only administrators can modify bitstream formats"); } log.info(LogManager.getHeader(bfContext, "update_bitstream_format", "bitstream_format_id=" + getID())); DatabaseManager.updateQuery(bfContext, "DELETE FROM fileextension WHERE bitstream_format_id= ? ", getID()); for (int i = 0; i < extensions.size(); i++) { String s = extensions.get(i); TableRow r = DatabaseManager.row("fileextension"); r.setColumn("bitstream_format_id", getID()); r.setColumn("extension", s); DatabaseManager.insert(bfContext, r); } DatabaseManager.update(bfContext, bfRow); } }
BitstreamFormat { public void update() throws SQLException, AuthorizeException { if (!AuthorizeManager.isAdmin(bfContext)) { throw new AuthorizeException( "Only administrators can modify bitstream formats"); } log.info(LogManager.getHeader(bfContext, "update_bitstream_format", "bitstream_format_id=" + getID())); DatabaseManager.updateQuery(bfContext, "DELETE FROM fileextension WHERE bitstream_format_id= ? ", getID()); for (int i = 0; i < extensions.size(); i++) { String s = extensions.get(i); TableRow r = DatabaseManager.row("fileextension"); r.setColumn("bitstream_format_id", getID()); r.setColumn("extension", s); DatabaseManager.insert(bfContext, r); } DatabaseManager.update(bfContext, bfRow); } BitstreamFormat(Context context, TableRow row); }
BitstreamFormat { public void update() throws SQLException, AuthorizeException { if (!AuthorizeManager.isAdmin(bfContext)) { throw new AuthorizeException( "Only administrators can modify bitstream formats"); } log.info(LogManager.getHeader(bfContext, "update_bitstream_format", "bitstream_format_id=" + getID())); DatabaseManager.updateQuery(bfContext, "DELETE FROM fileextension WHERE bitstream_format_id= ? ", getID()); for (int i = 0; i < extensions.size(); i++) { String s = extensions.get(i); TableRow r = DatabaseManager.row("fileextension"); r.setColumn("bitstream_format_id", getID()); r.setColumn("extension", s); DatabaseManager.insert(bfContext, r); } DatabaseManager.update(bfContext, bfRow); } BitstreamFormat(Context context, TableRow row); static BitstreamFormat find(Context context, int id); static BitstreamFormat findByMIMEType(Context context,
            String mimeType); static BitstreamFormat findByShortDescription(Context context,
            String desc); static BitstreamFormat findUnknown(Context context); static BitstreamFormat[] findAll(Context context); static BitstreamFormat[] findNonInternal(Context context); static BitstreamFormat create(Context context); final int getID(); final String getShortDescription(); final void setShortDescription(String s); final String getDescription(); final void setDescription(String s); final String getMIMEType(); final void setMIMEType(String s); final int getSupportLevel(); String getSupportLevelText(); final void setSupportLevel(int sl); final boolean isInternal(); final void setInternal(boolean b); void update(); void delete(); String[] getExtensions(); void setExtensions(String[] exts); static int getSupportLevelID(String slevel); }
BitstreamFormat { public void update() throws SQLException, AuthorizeException { if (!AuthorizeManager.isAdmin(bfContext)) { throw new AuthorizeException( "Only administrators can modify bitstream formats"); } log.info(LogManager.getHeader(bfContext, "update_bitstream_format", "bitstream_format_id=" + getID())); DatabaseManager.updateQuery(bfContext, "DELETE FROM fileextension WHERE bitstream_format_id= ? ", getID()); for (int i = 0; i < extensions.size(); i++) { String s = extensions.get(i); TableRow r = DatabaseManager.row("fileextension"); r.setColumn("bitstream_format_id", getID()); r.setColumn("extension", s); DatabaseManager.insert(bfContext, r); } DatabaseManager.update(bfContext, bfRow); } BitstreamFormat(Context context, TableRow row); static BitstreamFormat find(Context context, int id); static BitstreamFormat findByMIMEType(Context context,
            String mimeType); static BitstreamFormat findByShortDescription(Context context,
            String desc); static BitstreamFormat findUnknown(Context context); static BitstreamFormat[] findAll(Context context); static BitstreamFormat[] findNonInternal(Context context); static BitstreamFormat create(Context context); final int getID(); final String getShortDescription(); final void setShortDescription(String s); final String getDescription(); final void setDescription(String s); final String getMIMEType(); final void setMIMEType(String s); final int getSupportLevel(); String getSupportLevelText(); final void setSupportLevel(int sl); final boolean isInternal(); final void setInternal(boolean b); void update(); void delete(); String[] getExtensions(); void setExtensions(String[] exts); static int getSupportLevelID(String slevel); static final int UNKNOWN; static final int KNOWN; static final int SUPPORTED; }