in server/src/main/java/com/epam/aidial/core/server/service/PublicationService.java [184:218]
public Publication deletePublication(ResourceDescriptor resource) {
if (resource.getType() != ResourceTypes.PUBLICATION || resource.isPublic() || resource.isFolder() || resource.getParentPath() != null) {
throw new IllegalArgumentException("Bad publication url: " + resource.getUrl());
}
resourceService.computeResource(PUBLIC_PUBLICATIONS, body -> {
Map<String, Publication> publications = decodePublications(body);
Publication publication = publications.remove(resource.getUrl());
return (publication == null) ? body : encodePublications(publications);
});
MutableObject<Publication> reference = new MutableObject<>();
resourceService.computeResource(publications(resource), body -> {
Map<String, Publication> publications = decodePublications(body);
Publication publication = publications.remove(resource.getUrl());
if (publication == null) {
throw new ResourceNotFoundException("No publication: " + resource.getUrl());
}
reference.setValue(publication);
return encodePublications(publications);
});
Publication publication = reference.getValue();
if (publication.getStatus() == Publication.Status.PENDING) {
List<Publication.Resource> resourcesToAdd = publication.getResources().stream()
.filter(i -> i.getAction() == Publication.ResourceAction.ADD || i.getAction() == Publication.ResourceAction.ADD_IF_ABSENT)
.toList();
deleteReviewResources(resourcesToAdd);
}
return publication;
}