Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
--

CREATE TABLE public.binary (
resource_id bigint NOT NULL,
id character varying(1024) PRIMARY KEY,
data bytea NOT NULL
);

COMMENT ON TABLE public.binary IS 'This table can be used to store binary data for a resource.';

COMMENT ON COLUMN public.binary.resource_id IS 'This value points to the relevant row in the resource table.';
COMMENT ON COLUMN public.binary.id IS 'This value is the unique identifier for the binary.';
COMMENT ON COLUMN public.binary.data IS 'This holds the binary data itself, limited to 1GB in size';

Original file line number Diff line number Diff line change
Expand Up @@ -535,10 +535,11 @@ databaseChangeLog:
remarks: This table can be used to store binary data for a resource.
columns:
- column:
name: resource_id
type: BIGINT
remarks: This value points to the relevant row in the resource table.
name: id
type: VARCHAR(${id.length})
remarks: This value is the unique identifier for the binary.
constraints:
primaryKey: true
nullable: false
- column:
name: data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import org.apache.commons.rdf.api.IRI;
import org.apache.commons.rdf.api.Quad;
import org.slf4j.Logger;
import org.trellisldp.api.BinaryMetadata;
import org.trellisldp.api.Metadata;
import org.trellisldp.api.Resource;
import org.trellisldp.http.core.ServiceBundler;
Expand Down Expand Up @@ -166,16 +167,20 @@ private CompletionStage<Void> handleResourceDeletion(final Dataset immutable) {
.map(skolemizeQuads(getServices().getResourceService(), getBaseUrl()))
.forEachOrdered(immutable::add);


final CompletionStage<Void> binaryPromise = getBinaryPurgePromise();

// delete the resource
return allOf(
getBinaryPurgePromise().toCompletableFuture(),
binaryPromise.toCompletableFuture(),
getServices().getResourceService().delete(Metadata.builder(getResource()).build()).toCompletableFuture(),
getServices().getResourceService().add(getResource().getIdentifier(), immutable).toCompletableFuture());
}

private CompletionStage<Void> getBinaryPurgePromise() {
if (purgeBinaries && LDP.NonRDFSource.equals(getResource().getInteractionModel())) {
return getServices().getBinaryService().purgeContent(getResource().getIdentifier());
if (purgeBinaries) {
return getResource().getBinaryMetadata().map(BinaryMetadata::getIdentifier)
.map(getServices().getBinaryService()::purgeContent).orElseGet(() -> completedFuture(null));
}
return completedFuture(null);
}
Expand Down