@Override public boolean isRegisteredBitstream(Bitstream bitstream) { return bitstreamStorageService.isRegisteredBitstream(bitstream.getInternalId()); }
/** * Retrieve the bits for the asset with ID. If the asset does not * exist, returns null. * * @param bitstream The ID of the asset to retrieve * @return The stream of bits, or null * @throws java.io.IOException If a problem occurs while retrieving the bits */ public InputStream get(Bitstream bitstream) throws IOException { try { return new FileInputStream(getFile(bitstream)); } catch (Exception e) { log.error("get(" + bitstream.getInternalId() + ")", e); throw new IOException(e); } }
/** * Remove an asset from the asset store. An irreversible operation. * * @param bitstream The asset to delete * @throws java.io.IOException If a problem occurs while removing the asset */ public void remove(Bitstream bitstream) throws IOException { try { File file = getFile(bitstream); if (file != null) { if (file.delete()) { deleteParents(file); } } else { log.warn("Attempt to remove non-existent asset. ID: " + bitstream.getInternalId()); } } catch (Exception e) { log.error("remove(" + bitstream.getInternalId() + ")", e); throw new IOException(e); } }
/** * Remove an asset from the asset store. An irreversible operation. * * @param bitstream The asset to delete * @throws java.io.IOException If a problem occurs while removing the asset */ public void remove(Bitstream bitstream) throws IOException { String key = getFullKey(bitstream.getInternalId()); try { s3Service.deleteObject(bucketName, key); } catch (Exception e) { log.error("remove(" + key + ")", e); throw new IOException(e); } }
/** * Retrieve the bits for the asset with ID. If the asset does not * exist, returns null. * * @param bitstream The ID of the asset to retrieve * @return The stream of bits, or null * @throws java.io.IOException If a problem occurs while retrieving the bits */ public InputStream get(Bitstream bitstream) throws IOException { String key = getFullKey(bitstream.getInternalId()); try { S3Object object = s3Service.getObject(new GetObjectRequest(bucketName, key)); return (object != null) ? object.getObjectContent() : null; } catch (Exception e) { log.error("get(" + key + ")", e); throw new IOException(e); } }
@Override public List<Bitstream> findDuplicateInternalIdentifier(Context context, Bitstream bitstream) throws SQLException { CriteriaBuilder criteriaBuilder = getCriteriaBuilder(context); CriteriaQuery criteriaQuery = getCriteriaQuery(criteriaBuilder, Bitstream.class); Root<Bitstream> bitstreamRoot = criteriaQuery.from(Bitstream.class); criteriaQuery.select(bitstreamRoot); criteriaQuery.where(criteriaBuilder.and( criteriaBuilder.equal(bitstreamRoot.get(Bitstream_.internalId), bitstream.getInternalId()), criteriaBuilder.notEqual(bitstreamRoot.get(Bitstream_.id), bitstream.getID()) ) ); return list(context, criteriaQuery, false, Bitstream.class, -1, -1); }
String sInternalId = bitstream.getInternalId();
log.error("about(" + bitstream.getInternalId() + ")", e); throw new IOException(e);
String key = getFullKey(bitstream.getInternalId()); File scratchFile = File.createTempFile(bitstream.getInternalId(), "s3bs"); try { FileUtils.copyInputStreamToFile(in, scratchFile); log.error("put(" + bitstream.getInternalId() + ", is)", e); throw new IOException(e); } finally {
info.getChecksumAlgorithm()).append("\n"); buf.append(msg("internal-id")).append(" = ").append( info.getInternalId()).append("\n"); buf.append(msg("name")).append(" = ").append(info.getName()) .append("\n");
String key = getFullKey(bitstream.getInternalId()); try { ObjectMetadata objectMetadata = s3Service.getObjectMetadata(bucketName, key);
log.error("put(" + bitstream.getInternalId() + ", inputstream)", e); throw new IOException(e);
if (isRegisteredBitstream(bitstream.getInternalId())) { context.uncacheEntity(bitstream); continue; // do not delete registered bitstreams stores.get(bitstream.getStoreNumber()).remove(bitstream); String message = ("Deleted bitstreamID " + bid + ", internalID " + bitstream.getInternalId()); if (log.isDebugEnabled()) { log.debug(message);
LOG.info(msg("bitstream-found") + ": " + info.isBitstreamFound()); LOG.info(msg("to-be-processed") + ": " + info.isToBeProcessed()); LOG.info(msg("internal-id") + ": " + bitstream.getInternalId()); LOG.info(msg("name") + ": " + bitstream.getName()); LOG.info(msg("store-number") + ": " + bitstream.getStoreNumber());
.format("md5 checksum FAILED (%s): %s id: %s bitstream-id: %s\n was: %s\n is: %s\n", bi.getChecksumResult(), bi.getBitstream().getName(), bi.getBitstream().getInternalId(), bi.getBitstream().getID(), bi.getExpectedChecksum(), bi.getCurrentChecksum());
@Override public Bitstream clone(Context context, Bitstream bitstream) throws SQLException { // Create a new bitstream with a new ID. Bitstream clonedBitstream = bitstreamDAO.create(context, new Bitstream()); // Set the internal identifier, file size, checksum, and // checksum algorithm as same as the given bitstream. clonedBitstream.setInternalId(bitstream.getInternalId()); clonedBitstream.setSizeBytes(bitstream.getSizeBytes()); clonedBitstream.setChecksum(bitstream.getChecksum()); clonedBitstream.setChecksumAlgorithm(bitstream.getChecksumAlgorithm()); clonedBitstream.setFormat(bitstream.getBitstreamFormat()); try { //Update our bitstream but turn off the authorization system since permissions //haven't been set at this point in time. context.turnOffAuthorisationSystem(); update(context, clonedBitstream); } catch (AuthorizeException e) { log.error(e); //Can never happen since we turn off authorization before we update } finally { context.restoreAuthSystemState(); } return clonedBitstream; }