code: public static ro.nextreports.server.domain.Report renameImagesAsUnique(ro.nextreports.server.domain.Report report) {
          NextContent reportContent = (NextContent) report.getContent();
  		try {
  			String masterContent = new String(reportContent.getNextFile().getDataProvider().getBytes(), "UTF-8");
  			for (JcrFile imageFile : reportContent.getImageFiles()) {
  				String oldName = imageFile.getName();
  				int index = oldName.lastIndexOf(ro.nextreports.server.report.util.ReportUtil.EXTENSION_SEPARATOR);
  				String newName = oldName.substring(0, index) + ro.nextreports.server.report.util.ReportUtil.IMAGE_DELIM
  						+ UUID.randomUUID().toString() + oldName.substring(index);
  				masterContent = masterContent.replaceAll(oldName, newName);
  				imageFile.setName(newName);
  			}
  			JcrFile templateFile = reportContent.getTemplateFile();
  			if (templateFile != null) {
  				String oldName = templateFile.getName();
  				int index = oldName.lastIndexOf(ro.nextreports.server.report.util.ReportUtil.EXTENSION_SEPARATOR);
  				String newName = oldName.substring(0, index) + ro.nextreports.server.report.util.ReportUtil.IMAGE_DELIM
  						+ UUID.randomUUID().toString() + oldName.substring(index);
  				masterContent = masterContent.replaceAll(oldName, newName);
  				templateFile.setName(newName);
  			}
  			
  			reportContent.getNextFile().setDataProvider(new JcrDataProviderImpl(masterContent.getBytes("UTF-8")));
  		} catch (UnsupportedEncodingException e) {
  			LOG.error("Error inside renameImagesAsUnique: " + e.getMessage(), e);
  			e.printStackTrace();
  		}
  
          return report;
      }
docs: Rename images so that their name is unique