private BinaryData getBinaryData( ContentBinaryDataEntity contentBinaryData, boolean anonAccess, long timestamp) { BinaryData binaryData = new BinaryData(); binaryData.key = contentBinaryData.getBinaryData().getKey(); binaryData.contentKey = contentBinaryData.getContentVersion().getContent().getKey().toInt(); binaryData.setSafeFileName(contentBinaryData.getBinaryData().getName()); binaryData.timestamp = contentBinaryData.getBinaryData().getCreatedAt(); binaryData.anonymousAccess = anonAccess; if (binaryData.timestamp.getTime() > timestamp) { BlobRecord blob = this.binaryDataDao.getBlob(contentBinaryData.getBinaryData()); binaryData.data = blob.getAsBytes(); } return binaryData; }
public BinaryData getBinaryData(User oldUser, int binaryKey, long timestamp) { UserEntity user = securityService.getUser(oldUser); BinaryDataEntity binaryData = binaryDataDao.findByKey(new BinaryDataKey(binaryKey)); if (!binaryAccessResolver.hasReadAndIsAccessibleOnline(binaryData, user, new DateTime())) { return null; } ContentBinaryDataEntity contentBinaryData = contentBinaryDataDao.findByBinaryKey(binaryData.getKey()); ContentVersionEntity contentVersion = contentBinaryData.getContentVersion(); ContentEntity content = contentVersion.getContent(); // fast check if anonymous have read UserEntity anonymousUser = securityService.getUser(securityService.getAnonymousUserKey()); boolean anonAccess = content.hasAccessRightSet(anonymousUser.getUserGroup(), ContentAccessType.READ); return getBinaryData(contentBinaryData, anonAccess, timestamp); }