public void addSchemaRichApplicationFiles(Publication publication) {
        if (publication.getResources().isEmpty()) {
            return;
        }

        List<String> sourceUrlsFromRequest = publication.getResources().stream()
                .map(Publication.Resource::getSourceUrl)
                .toList();

        Map<String, Integer> fileNamesTaken = new HashMap<>();

        List<Publication.Resource> newResources = publication.getResources().stream()
                .filter(resource -> resource.getAction() != Publication.ResourceAction.DELETE)
                .filter(this::isApplicationResource)
                .flatMap(resource -> getApplicationFilesAndFolders(resource, fileNamesTaken))
                .toList();

        // Check for duplicates in newResources (overlap folder's content with files alone)
        Map<String, Publication.Resource> sourceUrlMap = new HashMap<>();
        for (Publication.Resource resource : newResources) {
            String sourceUrl = resource.getSourceUrl();
            if (sourceUrlMap.containsKey(sourceUrl)) {
                throw new HttpException(HttpStatus.BAD_REQUEST, "Handling resource twice while publishing application's own resources: " + sourceUrl);
            }
            if (sourceUrlsFromRequest.contains(sourceUrl)) {
                throw new HttpException(HttpStatus.BAD_REQUEST, "Application own resource was already present in the publication request: " + sourceUrl);
            }
            sourceUrlMap.put(sourceUrl, resource);
        }

        publication.getResources().addAll(newResources);
    }
Leaves only required fields for listing.
server/src/main/java/com/epam/aidial/core/server/service/PublicationService.java