| | |
| | | } |
| | | |
| | | /** |
| | | * 发布文件 * |
| | | */ |
| | | private void publishFiles(List<MetaFileEntity> list) { |
| | | for (MetaFileEntity mf : list) { |
| | | if (null != mf.getMsg()) { |
| | | continue; |
| | | } |
| | | switch (mf.getExtName()) { |
| | | case StaticData.MPT: |
| | | linkFiles(mf, StaticData.MPT_EXT, pathHelper.getConfig().getUploadPath() + File.separator + "SG"); |
| | | break; |
| | | case StaticData.D3DML: |
| | | linkFiles(mf, null, pathHelper.getConfig().getUploadPath() + File.separator + "SG"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 链接文件 |
| | | */ |
| | | private void linkFiles(MetaFileEntity mf, List<String> exts, String publishPath) { |
| | | String uploadPath = pathHelper.getConfig().getUploadPath(); |
| | | String source = uploadPath + File.separator + mf.getPath(); |
| | | String target = publishPath + File.separator + mf.getName(); |
| | | |
| | | File sourceFile = new File(source); |
| | | if (!sourceFile.exists() || sourceFile.isDirectory()) { |
| | | return; |
| | | } |
| | | |
| | | createFileLink(source, target); |
| | | if (null == exts) { |
| | | return; |
| | | } |
| | | |
| | | for (String ext : exts) { |
| | | File f = new File(source.replace(mf.getExtName(), ext)); |
| | | if (f.exists() && !f.isDirectory()) { |
| | | createFileLink(source.replace(mf.getExtName(), ext), target.replace(mf.getExtName(), ext)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 创建文件链接 |
| | | */ |
| | | private void createFileLink(String source, String target) { |