Source:
public AssetDto editAsset(String resourceId, MultipartFile file, String description, String group, List<String> categories) { try { ResourceInterface resource = resourceManager.loadResource(resourceId); if (resource == null) { throw new RestServerError(String.format("Resource %s not found", resourceId), null); } BaseResourceDataBean resourceFile = new BaseResourceDataBean(); resourceFile.setResourceType(resource.getType()); resourceFile.setResourceId(resourceId); resourceFile.setMetadata(resource.getMetadata()); if (file != null) { validateMimeType(resource.getType(), file.getContentType()); resourceFile.setInputStream(file.getInputStream()); resourceFile.setFileSize(file.getBytes().length / 1000); resourceFile.setFileName(file.getOriginalFilename()); resourceFile.setMimeType(file.getContentType()); resourceFile.setDescr(file.getOriginalFilename()); if ((description == null || description.trim().length() == 0 ) && resource.getDescription().equals(resource.getMasterFileName())) { description = resourceFile.getFileName(); } } if (description != null && !description.trim().isEmpty()) { resourceFile.setDescr(description.trim()); } else { resourceFile.setDescr(resource.getDescription()); } if (group != null && !group.trim().isEmpty()) { resourceFile.setMainGroup(group.trim()); } else { resourceFile.setMainGroup(resource.getMainGroup()); } if (categories != null && categories.size() > 0) { resourceFile.setCategories(categories.stream() .map(code -> categoryManager.getCategory(code)).collect(Collectors.toList())); } else { resourceFile.setCategories(resource.getCategories()); } resourceManager.updateResource(resourceFile); return convertResourceToDto(resource.getType(), resourceManager.loadResource(resourceId)); } catch (ApsSystemException e) { throw new RestServerError("Error updating image resource", e); } catch (IOException e) { throw new RestServerError("Error reading image stream", e); } }

Target:
public AssetDto editAsset(String resourceId, MultipartFile file, String description, String group, List<String> categories) { try { ResourceInterface resource = resourceManager.loadResource(resourceId); if (resource == null) { throw new RestServerError("plugins.jacms.resources.resourceManager.error.notFound", null); } BaseResourceDataBean resourceFile = new BaseResourceDataBean(); resourceFile.setResourceType(resource.getType()); resourceFile.setResourceId(resourceId); resourceFile.setMetadata(resource.getMetadata()); if (file != null) { validateMimeType(resource.getType(), file.getContentType()); resourceFile.setInputStream(file.getInputStream()); resourceFile.setFileSize(file.getBytes().length / 1000); resourceFile.setFileName(file.getOriginalFilename()); resourceFile.setMimeType(file.getContentType()); resourceFile.setDescr(file.getOriginalFilename()); if ((description == null || description.trim().length() == 0 ) && resource.getDescription().equals(resource.getMasterFileName())) { description = resourceFile.getFileName(); } } if (description != null && !description.trim().isEmpty()) { resourceFile.setDescr(description.trim()); } else { resourceFile.setDescr(resource.getDescription()); } if (group != null && !group.trim().isEmpty()) { resourceFile.setMainGroup(group.trim()); } else { resourceFile.setMainGroup(resource.getMainGroup()); } if (categories != null && categories.size() > 0) { resourceFile.setCategories(categories.stream() .map(code -> categoryManager.getCategory(code)).collect(Collectors.toList())); } else { resourceFile.setCategories(resource.getCategories()); } resourceManager.updateResource(resourceFile); return convertResourceToDto(resource.getType(), resourceManager.loadResource(resourceId)); } catch (ApsSystemException e) { throw new RestServerError("plugins.jacms.resources.resourceManager.error.persistence", e); } catch (IOException e) { log.error("Error reading file input stream", e); throw new RestServerError("plugins.jacms.resources.image.errorReadingStream", e); } }