| 
					
				 | 
			
			
				@@ -22,6 +22,7 @@ import kd.bos.logging.LogFactory; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import kd.bos.servicehelper.AttachmentServiceHelper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import kd.bos.url.UrlService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import kd.bos.util.FileUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import kd.bos.util.RevProxyUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import kd.bos.util.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import kd.bos.util.resource.Resources; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.io.IOUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -31,6 +32,7 @@ import org.apache.http.client.methods.HttpGet; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.http.impl.client.CloseableHttpClient; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.io.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.lang.reflect.Method; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.math.RoundingMode; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.net.URLEncoder; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -57,10 +59,6 @@ public class DefaultPreviewCusServiceImpl  implements PreviewService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private Dispatcher fileServerDispatcher; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private Dispatcher previewServerDispatcher; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private static final String rootUrl = "http://127.0.0.1:8012/onlinePreview?url="; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private final Base64.Encoder b64encoder = Base64.getEncoder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private static final String kkViewSupport = "doc,docx,xls,xlsx,ppt,pptx"; // 可查看官网补充 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public DefaultPreviewCusServiceImpl() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -68,12 +66,12 @@ public class DefaultPreviewCusServiceImpl  implements PreviewService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void init(FileService fileService) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         logger.info("DefaultPreviewCusServiceImpl:" + fileService.toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         this.fileService = fileService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.isPreviewcacheEnable = AttachmentFileService.isPreviewcacheEnable() && fileService instanceof AttachmentFileService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.isPreviewcacheRefresh = Boolean.parseBoolean(System.getProperty("filepreview.refresh.enable")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.uploadTimeout = AttachmentFileService.getUploadTimeout(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.fileServerDispatcher = DispatcherFactory.build("attachmentServer.url", BosErrorCode.fileServerNotConfigured); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.previewServerDispatcher = DispatcherFactory.build("yunpan.previewUrl", BosErrorCode.previewFailed); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        this.yunHomeService = new YunHomeService(fileService); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        this.isPreviewcacheEnable = AttachmentFileService.isPreviewcacheEnable() && fileService instanceof AttachmentFileService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        this.isPreviewcacheRefresh = Boolean.parseBoolean(System.getProperty("filepreview.refresh.enable")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        this.uploadTimeout = AttachmentFileService.getUploadTimeout(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        this.fileServerDispatcher = DispatcherFactory.build("attachmentServer.url", BosErrorCode.fileServerNotConfigured); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        this.previewServerDispatcher = DispatcherFactory.build("yunpan.previewUrl", BosErrorCode.previewFailed); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        this.yunHomeService = new YunHomeService(fileService); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -115,80 +113,85 @@ public class DefaultPreviewCusServiceImpl  implements PreviewService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         long startTime = 0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         long endTime = 0L; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Map result; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (YunHomeService.isNotNeedDeal(ext)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            logger.info("testpreviewWPS...10001001"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Map<String, String> headerMap = new HashMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (userAgent != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                headerMap.put("USER-AGENT", userAgent); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                in = this.fileService.download(path, headerMap, new HashMap()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } catch (Exception var19) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                result = ExceptionUtil.setErrorInfo(var19.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                previewResult.put(PreviewParams.STATUS.getEnumName(), PreviewParams.ERROR.getEnumName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                previewResult.put(PreviewParams.RESULT.getEnumName(), result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                return previewResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            previewResult.put(PreviewParams.STATUS.getEnumName(), PreviewParams.NOT_NEED_CHANGE.getEnumName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            previewResult.put(PreviewParams.RESULT.getEnumName(), in); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if ("txt".equalsIgnoreCase(ext)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                previewResult.put(PreviewParams.CHARSET.getEnumName(), FileUtil.getFilecharsetNew(in)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return previewResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } else if (this.isPreviewcacheRefresh) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            logger.info("testpreviewWPS...10001002"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return this.getYunPanCovertRs(path, fileName, ext, userAgent, false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (this.isPreviewcacheEnable) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                logger.info("testpreviewWPS...10001003"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                startTime = System.currentTimeMillis(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                String previewUrl = path + (!"xls".equalsIgnoreCase(ext) && !"xlsx".equalsIgnoreCase(ext) ? ".pdf" : ".zip"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                String previewMetaUrl = path + ".meta"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Map<String, String> headerMap = new HashMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    headerMap.put("preview", "true"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    headerMap.put("preview.url", URLEncoder.encode(previewUrl, StandardCharsets.UTF_8.name())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    headerMap.put("preview.metaUrl", URLEncoder.encode(previewMetaUrl, StandardCharsets.UTF_8.name())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    Map<String, String> resHeader = new HashMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    in = this.fileService.download(path, headerMap, resHeader); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    endTime = System.currentTimeMillis(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if (!"xls".equalsIgnoreCase(ext) && !"xlsx".equalsIgnoreCase(ext)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        previewResult.put(PreviewParams.STATUS.getEnumName(), PreviewParams.PDF_SUCCESS.getEnumName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        previewResult.put(PreviewParams.RESULT.getEnumName(), in); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        logger.info(String.format("从缓存中获取%s所耗费的时间为%s毫秒", fileName, endTime - startTime)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        return previewResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    String id = (String)resHeader.get("cacheId"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if (StringUtils.isNotEmpty(id)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        result = ExcelPreviewFactory.getExcelPreview().preview(id, in); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        if (result.containsKey("url")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            String accountId = TAUtil.getAccountId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            String url = (String)result.get("url"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            url = url + "?kdcdc=" + accountId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            result.put("url", url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        previewResult.put(PreviewParams.STATUS.getEnumName(), PreviewParams.XLSX_SUCCESS.getEnumName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        previewResult.put(PreviewParams.RESULT.getEnumName(), result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        logger.info(String.format("从缓存中获取%s所耗费的时间为%s毫秒", fileName, endTime - startTime)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        return previewResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } catch (Exception var20) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    logger.error("无法从文件服务器获取预览数据,执行getYunPanCovertRs方法,进行文件预览云盘转换", var20.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            logger.info("testpreviewWPS...10001004"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return this.getYunPanCovertRs(path, fileName, ext, userAgent, false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        logger.info("testpreviewWPS..." + path + ", " + ext); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return this.getYunPanCovertRs(path, fileName, ext, userAgent, false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        if (YunHomeService.isNotNeedDeal(ext)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            logger.info("testpreviewWPS...10001001"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            Map<String, String> headerMap = new HashMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            if (userAgent != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                headerMap.put("USER-AGENT", userAgent); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                in = this.fileService.download(path, headerMap, new HashMap()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            } catch (Exception var19) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                result = ExceptionUtil.setErrorInfo(var19.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                previewResult.put(PreviewParams.STATUS.getEnumName(), PreviewParams.ERROR.getEnumName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                previewResult.put(PreviewParams.RESULT.getEnumName(), result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                return previewResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            previewResult.put(PreviewParams.STATUS.getEnumName(), PreviewParams.NOT_NEED_CHANGE.getEnumName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            previewResult.put(PreviewParams.RESULT.getEnumName(), in); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            if ("txt".equalsIgnoreCase(ext)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                previewResult.put(PreviewParams.CHARSET.getEnumName(), FileUtil.getFilecharsetNew(in)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            return previewResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        } else if (this.isPreviewcacheRefresh) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            logger.info("testpreviewWPS...10001002"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            return this.getYunPanCovertRs(path, fileName, ext, userAgent, false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            if (this.isPreviewcacheEnable) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                logger.info("testpreviewWPS...10001003"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                startTime = System.currentTimeMillis(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                String previewUrl = path + (!"xls".equalsIgnoreCase(ext) && !"xlsx".equalsIgnoreCase(ext) ? ".pdf" : ".zip"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                String previewMetaUrl = path + ".meta"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    Map<String, String> headerMap = new HashMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    headerMap.put("preview", "true"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    headerMap.put("preview.url", URLEncoder.encode(previewUrl, StandardCharsets.UTF_8.name())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    headerMap.put("preview.metaUrl", URLEncoder.encode(previewMetaUrl, StandardCharsets.UTF_8.name())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    Map<String, String> resHeader = new HashMap(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    in = this.fileService.download(path, headerMap, resHeader); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    endTime = System.currentTimeMillis(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    if (!"xls".equalsIgnoreCase(ext) && !"xlsx".equalsIgnoreCase(ext)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                        previewResult.put(PreviewParams.STATUS.getEnumName(), PreviewParams.PDF_SUCCESS.getEnumName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                        previewResult.put(PreviewParams.RESULT.getEnumName(), in); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                        logger.info(String.format("从缓存中获取%s所耗费的时间为%s毫秒", fileName, endTime - startTime)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                        return previewResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    String id = (String)resHeader.get("cacheId"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    if (StringUtils.isNotEmpty(id)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                        result = ExcelPreviewFactory.getExcelPreview().preview(id, in); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                        if (result.containsKey("url")) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                            String accountId = TAUtil.getAccountId(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                            String url = (String)result.get("url"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                            url = url + "?kdcdc=" + accountId; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                            result.put("url", url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                        previewResult.put(PreviewParams.STATUS.getEnumName(), PreviewParams.XLSX_SUCCESS.getEnumName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                        previewResult.put(PreviewParams.RESULT.getEnumName(), result); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                        logger.info(String.format("从缓存中获取%s所耗费的时间为%s毫秒", fileName, endTime - startTime)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                        return previewResult; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                } catch (Exception var20) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                    logger.error("无法从文件服务器获取预览数据,执行getYunPanCovertRs方法,进行文件预览云盘转换", var20.getMessage()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            logger.info("testpreviewWPS...10001004"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            return this.getYunPanCovertRs(path, fileName, ext, userAgent, false); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     /** 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -692,40 +695,24 @@ public class DefaultPreviewCusServiceImpl  implements PreviewService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void deletePreviewWps(String path, Map<String, String> config) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public String getExt(String fileName){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String ext; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String[] extTmp = fileName.split("\\."); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ext = extTmp[extTmp.length-1]; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return ext; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private String getKkviewUrl(String url, String filename){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // url构造见KkFileView官方文档 - 注意KkFileView会使用文件名缓存预览文件 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        url += "&fullfilename=" + filename.replaceAll("[\\\\/]", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        url += "&officePreviewType=html"; // image,pdf,html 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String encodeUrl = b64encoder.encodeToString(url.getBytes(StandardCharsets.UTF_8)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return rootUrl + encodeUrl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private boolean isKkViewSupport(String ext) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        ext = ext.replaceAll("\\.", ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return kkViewSupport.contains(ext); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private String getDownloadUrl(String path) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Class<?> clazzUrlService = Class.forName("kd.bos.url.UrlService"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Method getAttachmentFullUrl = clazzUrlService.getMethod("getAttachmentFullUrl", String.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String url = (String)getAttachmentFullUrl.invoke(clazzUrlService.newInstance(), path); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Class<?> clazzEncreptSessionUtils = Class.forName("kd.bos.session.EncreptSessionUtils"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Method encryptSession = clazzEncreptSessionUtils.getMethod("encryptSession", String.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            String downUrl = (String)encryptSession.invoke(clazzEncreptSessionUtils.newInstance(), url); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            downUrl = downUrl + RevProxyUtil.getHttpParamCollectFlag(downUrl) + "source=preview"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (isLog()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                logger.info("yunpan downLoadUrl=" + downUrl); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private String getDownloadUrl(String path){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        String downloadUrl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (path.contains("tempfile/download.do")) { // 临时文件为url链接 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            downloadUrl = path.contains("kdedcba") ? path : AttachmentServiceHelper.getEncreptURL(path); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return downloadUrl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        try { // 轻量级文件服务为本地文件地址 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            path = URLEncoder.encode(path, "utf-8"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } catch (UnsupportedEncodingException e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            throw new KDException(new ErrorCode("previewErr", "url encode err"), e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return downUrl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (Exception var8) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new KDException(BosErrorCode.fileserviceException, "getDownloadUrl error", var8); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        downloadUrl = UrlService.getAttachmentDownloadUrl(path); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        downloadUrl = AttachmentServiceHelper.getEncreptURL(downloadUrl); // 追加临时免登授权 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // 开启csrf校验时,需要增加参数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return downloadUrl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |