📄 bitstream.java
字号:
{ return bRow.getStringColumn("source"); } /** * Set the source of the bitstream * * @param n * the new source of the bitstream */ public void setSource(String n) { bRow.setColumn("source", n); } /** * Get the description of this bitstream - optional free text, typically * provided by a user at submission time * * @return the description of the bitstream */ public String getDescription() { return bRow.getStringColumn("description"); } /** * Set the description of the bitstream * * @param n * the new description of the bitstream */ public void setDescription(String n) { bRow.setColumn("description", n); } /** * Get the checksum of the content of the bitstream, for integrity checking * * @return the checksum */ public String getChecksum() { return bRow.getStringColumn("checksum"); } /** * Get the algorithm used to calculate the checksum * * @return the algorithm, e.g. "MD5" */ public String getChecksumAlgorithm() { return bRow.getStringColumn("checksum_algorithm"); } /** * Get the size of the bitstream * * @return the size in bytes */ public long getSize() { return bRow.getLongColumn("size_bytes"); } /** * Set the user's format description. This implies that the format of the * bitstream is uncertain, and the format is set to "unknown." * * @param desc * the user's description of the format * @throws SQLException */ public void setUserFormatDescription(String desc) throws SQLException { // FIXME: Would be better if this didn't throw an SQLException, // but we need to find the unknown format! setFormat(null); bRow.setColumn("user_format_description", desc); } /** * Get the user's format description. Returns null if the format is known by * the system. * * @return the user's format description. */ public String getUserFormatDescription() { return bRow.getStringColumn("user_format_description"); } /** * Get the description of the format - either the user's or the description * of the format defined by the system. * * @return a description of the format. */ public String getFormatDescription() { if (bitstreamFormat.getShortDescription().equals("Unknown")) { // Get user description if there is one String desc = bRow.getStringColumn("user_format_description"); if (desc == null) { return "Unknown"; } return desc; } // not null or Unknown return bitstreamFormat.getShortDescription(); } /** * Get the format of the bitstream * * @return the format of this bitstream */ public BitstreamFormat getFormat() { return bitstreamFormat; } /** * Set the format of the bitstream. If the user has supplied a type * description, it is cleared. Passing in <code>null</code> sets the type * of this bitstream to "unknown". * * @param f * the format of this bitstream, or <code>null</code> for * unknown * @throws SQLException */ public void setFormat(BitstreamFormat f) throws SQLException { // FIXME: Would be better if this didn't throw an SQLException, // but we need to find the unknown format! if (f == null) { // Use "Unknown" format bitstreamFormat = BitstreamFormat.findUnknown(bContext); } else { bitstreamFormat = f; } // Remove user type description bRow.setColumnNull("user_format_description"); // Update the ID in the table row bRow.setColumn("bitstream_format_id", bitstreamFormat.getID()); } /** * Update the bitstream metadata. Note that the content of the bitstream * cannot be changed - for that you need to create a new bitstream. * * @throws SQLException * @throws AuthorizeException */ public void update() throws SQLException, AuthorizeException { // Check authorisation AuthorizeManager.authorizeAction(bContext, this, Constants.WRITE); log.info(LogManager.getHeader(bContext, "update_bitstream", "bitstream_id=" + getID())); DatabaseManager.update(bContext, bRow); } /** * Delete the bitstream, including any mappings to bundles * * @throws SQLException */ void delete() throws SQLException { // changed to a check on remove // Check authorisation //AuthorizeManager.authorizeAction(bContext, this, Constants.DELETE); log.info(LogManager.getHeader(bContext, "delete_bitstream", "bitstream_id=" + getID())); // Remove from cache bContext.removeCached(this, getID()); // Remove policies AuthorizeManager.removeAllPolicies(bContext, this); // Remove bitstream itself BitstreamStorageManager.delete(bContext, bRow .getIntColumn("bitstream_id")); } /** * Retrieve the contents of the bitstream * * @return a stream from which the bitstream can be read. * @throws IOException * @throws SQLException * @throws AuthorizeException */ public InputStream retrieve() throws IOException, SQLException, AuthorizeException { // Maybe should return AuthorizeException?? AuthorizeManager.authorizeAction(bContext, this, Constants.READ); return BitstreamStorageManager.retrieve(bContext, bRow .getIntColumn("bitstream_id")); } /** * Get the bundles this bitstream appears in * * @return array of <code>Bundle</code> s this bitstream appears in * @throws SQLException */ public Bundle[] getBundles() throws SQLException { // Get the bundle table rows TableRowIterator tri = DatabaseManager.query(bContext, "bundle", "SELECT bundle.* FROM bundle, bundle2bitstream WHERE " + "bundle.bundle_id=bundle2bitstream.bundle_id AND " + "bundle2bitstream.bitstream_id=" + bRow.getIntColumn("bitstream_id")); // Build a list of Bundle objects List bundles = new ArrayList(); while (tri.hasNext()) { TableRow r = tri.next(); // First check the cache Bundle fromCache = (Bundle) bContext.fromCache(Bundle.class, r .getIntColumn("bundle_id")); if (fromCache != null) { bundles.add(fromCache); } else { bundles.add(new Bundle(bContext, r)); } } // close the TableRowIterator to free up resources tri.close(); Bundle[] bundleArray = new Bundle[bundles.size()]; bundleArray = (Bundle[]) bundles.toArray(bundleArray); return bundleArray; } /** * return type found in Constants * * @return int Constants.BITSTREAM */ public int getType() { return Constants.BITSTREAM; } /** * Determine if this bitstream is registered * * @return true if the bitstream is registered, false otherwise */ public boolean isRegisteredBitstream() { return BitstreamStorageManager .isRegisteredBitstream(bRow.getStringColumn("internal_id")); } /** * Get the asset store number where this bitstream is stored * * @return the asset store number of the bitstream */ public int getStoreNumber() { return bRow.getIntColumn("store_number"); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -