Skip to content

Commit

Permalink
feat: Make files shareable on publishing conversations #554 (#555)
Browse files Browse the repository at this point in the history
  • Loading branch information
astsiapanay authored Oct 30, 2024
1 parent f88c451 commit d05140d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static class Resource {
}

public enum ResourceAction {
ADD, DELETE
ADD, DELETE, ADD_IF_ABSENT
}

public Set<ResourceTypes> getResourceTypes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private void prepareAndValidatePublicationRequest(ProxyContext context, Publicat
throw new IllegalArgumentException("Resource \"action\" is missing");
}

if (action == Publication.ResourceAction.ADD) {
if (action == Publication.ResourceAction.ADD || action == Publication.ResourceAction.ADD_IF_ABSENT) {
validateResourceForAddition(context, resource, targetFolder, reviewBucket, urls);
} else if (action == Publication.ResourceAction.DELETE) {
validateResourceForDeletion(resource, targetFolder, urls, bucketName, isAdmin);
Expand Down Expand Up @@ -408,7 +408,7 @@ private void validateResourceForAddition(ProxyContext context, Publication.Resou
throw new IllegalArgumentException("Source resource does not exists: " + sourceUrl);
}

if (resourceService.hasResource(target)) {
if (resource.getAction() == Publication.ResourceAction.ADD && resourceService.hasResource(target)) {
throw new IllegalArgumentException("Target resource already exists: " + targetUrl);
}

Expand Down Expand Up @@ -581,7 +581,8 @@ private void copyReviewToTargetResources(List<Publication.Resource> resources) {
app.setReference(ApplicationUtil.generateReference());
app.setIconUrl(replaceLink(replacementLinks, app.getIconUrl()));
});
} else if (!resourceService.copyResource(from, to)) {
} else if (!resourceService.copyResource(from, to, false)
&& resource.getAction() != Publication.ResourceAction.ADD_IF_ABSENT) {
throw new IllegalStateException("Can't copy source resource from: " + from.getUrl() + " to review: " + to.getUrl());
}

Expand Down

0 comments on commit d05140d

Please sign in to comment.