class ReportUnitAttachmentsProcessor implements AttachmentsProcessor<T> {

    @Override
    public T processAttachments(T serverObject,
            Map<String, InputStream> parts) throws MandatoryParameterNotFoundException, IllegalParameterValueException {
        setDataToFileResourceWithValidation(parts.get(ResourceMultipartConstants.REPORT_JRXML_PART_NAME),
                serverObject.getMainReport(), ResourceMultipartConstants.REPORT_JRXML_PART_NAME);
        // Raw type is used in core class. Cast is safe.
        @SuppressWarnings("unchecked")
        final List<ResourceReference> resources = serverObject.getResources();
        for(ResourceReference currentReference : resources){
            if(currentReference.isLocal() && currentReference.getLocalResource() instanceof FileResource
                    && !((FileResource)currentReference.getLocalResource()).isReference()){
                final FileResource fileResource = (FileResource) currentReference.getLocalResource();
                final String filePartName = ResourceMultipartConstants.REPORT_FILE_PART_NAME_PREFIX + fileResource.getName();
                setDataToFileResourceWithValidation(parts.get(filePartName), currentReference, filePartName);
            }
        }
        return serverObject;
    }

}