@Override public int hashCode() { int hash = 5; hash += 70 * hash + getID(); return hash; }
/** * Return <code>true</code> if <code>other</code> is the same Collection * as this object, <code>false</code> otherwise * * @param other object to compare to * @return <code>true</code> if object passed in represents the same * collection as this object */ @Override public boolean equals(Object other) { if (other == null) { return false; } Class<?> objClass = HibernateProxyHelper.getClassWithoutInitializingProxy(other); if (this.getClass() != objClass) { return false; } final BitstreamFormat otherBitstreamFormat = (BitstreamFormat) other; if (this.getID() != otherBitstreamFormat.getID()) { return false; } return true; }
@Override public void setShortDescription(Context context, BitstreamFormat bitstreamFormat, String shortDescription) throws SQLException { // You can not reset the unknown's registry's name BitstreamFormat unknown = null; try { unknown = findUnknown(context); } catch (IllegalStateException e) { // No short_description='Unknown' found in bitstreamformatregistry // table. On first load of registries this is expected because it // hasn't been inserted yet! So, catch but ignore this runtime // exception thrown by method findUnknown. } // If the exception was thrown, unknown will == null so goahead and // load s. If not, check that the unknown's registry's name is not // being reset. if (unknown == null || unknown.getID() != bitstreamFormat.getID()) { bitstreamFormat.setShortDescriptionInternal(shortDescription); } }
@Override public void delete(Context context, BitstreamFormat bitstreamFormat) throws SQLException, AuthorizeException { // Check authorisation - only administrators can delete formats if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "Only administrators can delete bitstream formats"); } // Find "unknown" type BitstreamFormat unknown = findUnknown(context); if (unknown.getID() == bitstreamFormat.getID()) { throw new IllegalArgumentException("The Unknown bitstream format may not be deleted."); } // Set bitstreams with this format to "unknown" int numberChanged = bitstreamFormatDAO.updateRemovedBitstreamFormat(context, bitstreamFormat, unknown); // Delete this format from database bitstreamFormatDAO.delete(context, bitstreamFormat); log.info(LogManager.getHeader(context, "delete_bitstream_format", "bitstream_format_id=" + bitstreamFormat.getID() + ",bitstreams_changed=" + numberChanged)); }
@Override public void update(Context context, List<BitstreamFormat> bitstreamFormats) throws SQLException, AuthorizeException { if (CollectionUtils.isNotEmpty(bitstreamFormats)) { // Check authorisation - only administrators can change formats if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "Only administrators can modify bitstream formats"); } for (BitstreamFormat bitstreamFormat : bitstreamFormats) { log.info(LogManager.getHeader(context, "update_bitstream_format", "bitstream_format_id=" + bitstreamFormat.getID())); bitstreamFormatDAO.save(context, bitstreamFormat); } } }
buf.append("------------------------------------------------ \n"); buf.append(msg("format-id")).append(" = ").append( info.getFormat(context).getID()).append("\n"); buf.append(msg("deleted")).append(" = ").append(info.isDeleted()) .append("\n");
@Override public void removeLicenses(Context context, Item item) throws SQLException, AuthorizeException, IOException { // Find the License format BitstreamFormat bf = bitstreamFormatService.findByShortDescription(context, "License"); int licensetype = bf.getID(); // search through bundles, looking for bitstream type license List<Bundle> bunds = item.getBundles(); for (Bundle bund : bunds) { boolean removethisbundle = false; List<Bitstream> bits = bund.getBitstreams(); for (Bitstream bit : bits) { BitstreamFormat bft = bit.getFormat(context); if (bft.getID() == licensetype) { removethisbundle = true; } } // probably serious troubles with Authorizations // fix by telling system not to check authorization? if (removethisbundle) { removeBundle(context, item, bund); } } }
@Override public BitstreamFormat create(Context context) throws SQLException, AuthorizeException { // Check authorisation - only administrators can create new formats if (!authorizeService.isAdmin(context)) { throw new AuthorizeException( "Only administrators can create bitstream formats"); } // Create a table row BitstreamFormat bitstreamFormat = bitstreamFormatDAO.create(context, new BitstreamFormat()); log.info(LogManager.getHeader(context, "create_bitstream_format", "bitstream_format_id=" + bitstreamFormat.getID())); return bitstreamFormat; }
LOG.info(msg("size") + ": " + bitstream.getSizeBytes()); LOG.info(msg("bitstream-format") + ": " + (bitstream.getFormat(context) != null ? bitstream.getFormat(context) .getID() : "-1")); LOG.info(msg("user-format-description") + ": " + bitstream.getUserFormatDescription());
String formatID = String.valueOf(format.getID()); String mimetype = format.getMIMEType(); String name = format.getShortDescription();
result.setOutcome(true); result.setMessage(T_edit_bitstream_format_success_notice); result.setParameter("formatID",format.getID());
if (currentFormat == null || currentFormat.getID() != formatID)
if (format != null && format.getID() == 1)