use of com.palantir.example.profile.schema.generated.UserPhotosStreamStore in project atlasdb by palantir.
the class ProfileStore method deleteImage.
public void deleteImage(UUID userId) {
Long streamId = getPhotoStreamId(userId);
if (streamId == null) {
return;
}
UserProfileTable table = tables.getUserProfileTable(tx);
table.deletePhotoStreamId(UserProfileRow.of(userId));
UserPhotosStreamStore streamStore = UserPhotosStreamStore.of(txnMgr, tables);
streamStore.unmarkStreamAsUsed(tx, streamId, EncodingUtils.encodeUUID(userId));
}
use of com.palantir.example.profile.schema.generated.UserPhotosStreamStore in project atlasdb by palantir.
the class ProfileStore method getImageForUser.
public InputStream getImageForUser(UUID userId) {
Long photoId = getPhotoStreamId(userId);
if (photoId == null) {
return null;
}
UserPhotosStreamStore streamStore = UserPhotosStreamStore.of(txnMgr, tables);
return streamStore.loadStream(tx, photoId);
}
use of com.palantir.example.profile.schema.generated.UserPhotosStreamStore in project atlasdb by palantir.
the class ProfileStore method updateImage.
public void updateImage(UUID userId, Sha256Hash hash, InputStream imageData) {
UserProfile userData = getUserData(userId);
Preconditions.checkNotNull(userData, "userData cannot be null");
UserPhotosStreamStore streamStore = UserPhotosStreamStore.of(txnMgr, tables);
Long oldStreamId = getPhotoStreamId(userId);
if (oldStreamId != null) {
// Unmark old stream before we overwrite it.
streamStore.unmarkStreamAsUsed(tx, oldStreamId, EncodingUtils.encodeUUID(userId));
}
// This will either store a new stream and mark it as used
// or return an old stream that matches the hash and mark it as used.
long streamId = streamStore.getByHashOrStoreStreamAndMarkAsUsed(tx, hash, imageData, EncodingUtils.encodeUUID(userId));
UserProfileTable table = tables.getUserProfileTable(tx);
table.putPhotoStreamId(UserProfileRow.of(userId), streamId);
}
Aggregations