in server/src/main/java/com/epam/aidial/core/server/service/PublicationService.java [506:537]
private void validateResourceForDeletion(Publication.Resource resource, String targetFolder, Set<String> urls,
String bucketName, boolean isAdmin) {
String targetUrl = resource.getTargetUrl();
ResourceDescriptor target = ResourceDescriptorFactory.fromPublicUrl(targetUrl);
verifyResourceType(target);
if (target.isFolder()) {
throw new IllegalArgumentException("Target resource is folder: " + targetUrl);
}
String targetSuffix = targetUrl.substring(target.getType().group().length() + 1);
if (!targetSuffix.startsWith(targetFolder)) {
throw new IllegalArgumentException("Target resource folder does not match with target folder: " + targetUrl);
}
if (!urls.add(targetUrl)) {
throw new IllegalArgumentException("Target resources have duplicate urls: " + targetUrl);
}
if (!resourceService.hasResource(target)) {
throw new IllegalArgumentException("Target resource does not exists: " + targetUrl);
}
if (target.getType() == ResourceTypes.APPLICATION && !isAdmin) {
Application application = applicationService.getApplication(target).getValue();
if (application.getFunction() != null && !application.getFunction().getAuthorBucket().equals(bucketName)) {
throw new IllegalArgumentException("Target application has a different author: " + targetUrl);
}
}
resource.setTargetUrl(targetUrl);
}