diff --git a/src/main/java/zf47/jdgz1/fi/em/plugin/print/TripReimbursePrintPlugin.java b/src/main/java/zf47/jdgz1/fi/em/plugin/print/TripReimbursePrintPlugin.java index 16e7bab..74b48b6 100644 --- a/src/main/java/zf47/jdgz1/fi/em/plugin/print/TripReimbursePrintPlugin.java +++ b/src/main/java/zf47/jdgz1/fi/em/plugin/print/TripReimbursePrintPlugin.java @@ -33,8 +33,10 @@ import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.net.HttpURLConnection; import java.net.URL; +import java.net.URLEncoder; import java.util.*; /** @@ -146,7 +148,11 @@ public class TripReimbursePrintPlugin extends AbstractPrintPlugin implements Plu try { FileService fs = FileServiceFactory.getAttachmentFileService(); FilePathService fps = new FilePathService(); + String realPath = fps.getRealPath(url); + String fileName = realPath.substring(realPath.lastIndexOf("/") + 1); + realPath = realPath.substring(0, realPath.lastIndexOf("/")) + "/" + URLEncoder.encode(fileName, "utf-8"); + String fileserver = System.getProperty("fileserver"); String abUrl = fileserver + realPath; String abEncreptUrl = AttachmentServiceHelper.getEncreptURL(abUrl); @@ -219,7 +225,11 @@ public class TripReimbursePrintPlugin extends AbstractPrintPlugin implements Plu ArrayList resUrls = new ArrayList<>(); FileService fs = FileServiceFactory.getAttachmentFileService(); FilePathService fps = new FilePathService(); + String realPath = fps.getRealPath(url); + String fileName = realPath.substring(realPath.lastIndexOf("/") + 1); + realPath = realPath.substring(0, realPath.lastIndexOf("/")) + "/" + URLEncoder.encode(fileName, "utf-8"); + String fileserver = System.getProperty("fileserver"); String abUrl = fileserver + realPath; String abEncreptUrl = AttachmentServiceHelper.getEncreptURL(abUrl); @@ -273,8 +283,16 @@ public class TripReimbursePrintPlugin extends AbstractPrintPlugin implements Plu private ArrayList handlePicAttUrl(String url) { ArrayList urls = new ArrayList<>(); FilePathService fps = new FilePathService(); + String realPath = fps.getRealPath(url); - String fileserver = System.getProperty("imageServer.external.url"); + try { + String fileName = realPath.substring(realPath.lastIndexOf("/") + 1); + realPath = realPath.substring(0, realPath.lastIndexOf("/")) + "/" + URLEncoder.encode(fileName, "utf-8"); + } catch (Exception e) { + log.error("TripReimbursePrintPlugin:" + e.getMessage()); + } + + String fileserver = System.getProperty("fileserver"); String abUrl = fileserver + realPath; String abEncreptUrl = AttachmentServiceHelper.getEncreptURL(abUrl); abEncreptUrl = abEncreptUrl.replaceAll("\\s", "%20").replaceAll("'", "%27");