|
|
@@ -69,7 +69,7 @@ public class OnlyServiceAPIImpl implements OnlyServiceAPI {
|
|
69
|
69
|
* @return
|
|
70
|
70
|
*/
|
|
71
|
71
|
@Override
|
|
72
|
|
- public Map openDocument(Map<String, Object> map, String mode, boolean collaborativeEditing) {
|
|
|
72
|
+ public Map openDocument(Map<String, Object> map, String mode, boolean collaborativeEditing, String clientType) {
|
|
73
|
73
|
long fileSize = (long) map.get("fileSize");
|
|
74
|
74
|
|
|
75
|
75
|
if (fileSize > onlyProperties.getMaxSize()) {
|
|
|
@@ -78,34 +78,32 @@ public class OnlyServiceAPIImpl implements OnlyServiceAPI {
|
|
78
|
78
|
}
|
|
79
|
79
|
|
|
80
|
80
|
if (EDIT.equals(mode)) {
|
|
81
|
|
- return documentEdit(map, collaborativeEditing);
|
|
|
81
|
+ return documentEdit(map, collaborativeEditing, clientType);
|
|
82
|
82
|
}
|
|
83
|
83
|
if (VIEW.equals(mode)) {
|
|
84
|
|
- return documentView(map);
|
|
|
84
|
+ return documentView(map, clientType);
|
|
85
|
85
|
}
|
|
86
|
86
|
return null;
|
|
87
|
87
|
}
|
|
88
|
88
|
|
|
89
|
|
- private Map documentEdit(Map<String, Object> map, boolean collaborativeEditing) {
|
|
90
|
|
- FileConfig fileConfigDTO = openEditConfig(map, "edit", collaborativeEditing);
|
|
|
89
|
+ private Map documentEdit(Map<String, Object> map, boolean collaborativeEditing, String clientType) {
|
|
|
90
|
+ FileConfig fileConfigDTO = openEditConfig(map, "edit", collaborativeEditing,clientType);
|
|
91
|
91
|
String json = JSON.toJSONString(fileConfigDTO);
|
|
92
|
|
-
|
|
93
|
92
|
Map<String, Object> config = JSON.parseObject(json, Map.class);
|
|
94
|
|
-
|
|
95
|
|
-
|
|
|
93
|
+ config.put("type", clientType);
|
|
96
|
94
|
return config;
|
|
97
|
95
|
}
|
|
98
|
96
|
|
|
99
|
97
|
|
|
100
|
|
- private Map documentView(Map<String, Object> map) {
|
|
101
|
|
- FileConfig fileConfigDTO = openEditConfig(map, "view", false);
|
|
|
98
|
+ private Map documentView(Map<String, Object> map,String clientType) {
|
|
|
99
|
+ FileConfig fileConfigDTO = openEditConfig(map, "view", false,clientType);
|
|
102
|
100
|
String json = JSON.toJSONString(fileConfigDTO);
|
|
103
|
101
|
Map<String, Object> config = JSON.parseObject(json, Map.class);
|
|
104
|
|
-
|
|
|
102
|
+ config.put("type", clientType);
|
|
105
|
103
|
return config;
|
|
106
|
104
|
}
|
|
107
|
105
|
|
|
108
|
|
- private FileConfig openEditConfig(Map<String, Object> map, String mode, boolean collaborativeEditing) {
|
|
|
106
|
+ private FileConfig openEditConfig(Map<String, Object> map, String mode, boolean collaborativeEditing,String clientType) {
|
|
109
|
107
|
try {
|
|
110
|
108
|
map.put("mode", mode);
|
|
111
|
109
|
log.info("开始生成文件信息");
|
|
|
@@ -113,7 +111,7 @@ public class OnlyServiceAPIImpl implements OnlyServiceAPI {
|
|
113
|
111
|
FileMetadata tempFileInfo = fileHandler.handlerFile(map, collaborativeEditing);
|
|
114
|
112
|
//生成配置文件 TODO: 控制文件权限
|
|
115
|
113
|
log.info("开始生成编辑器配置信息");
|
|
116
|
|
- FileConfig fileConfigDTO = onlyOfficeConfigFactory.buildInitConfig(tempFileInfo.getUrl(), mode, tempFileInfo.getKey(), tempFileInfo.getOldName());
|
|
|
114
|
+ FileConfig fileConfigDTO = onlyOfficeConfigFactory.buildInitConfig(tempFileInfo.getUrl(), mode, tempFileInfo.getKey(), tempFileInfo.getOldName(),clientType);
|
|
117
|
115
|
log.info("生成编辑器配置信息结束");
|
|
118
|
116
|
// TODO: 添加更多详细的自定义信息
|
|
119
|
117
|
return fileConfigDTO;
|
|
|
@@ -167,6 +165,7 @@ public class OnlyServiceAPIImpl implements OnlyServiceAPI {
|
|
167
|
165
|
int status = jsonObject.getIntValue("status");
|
|
168
|
166
|
log.info("status[{}]:{}", status, jsonObject);
|
|
169
|
167
|
String key = (String) jsonObject.get("key");
|
|
|
168
|
+ String caseId = jsonObject.getString("caseId");
|
|
170
|
169
|
|
|
171
|
170
|
FileHandler tempFileHandler = tempFileContext.getHandlerByKey(key);
|
|
172
|
171
|
if (Objects.nonNull(tempFileHandler)) {
|
|
|
@@ -189,6 +188,10 @@ public class OnlyServiceAPIImpl implements OnlyServiceAPI {
|
|
189
|
188
|
if (!tempFile.isPresent()) {
|
|
190
|
189
|
throw new RuntimeException("文件元信息不存在");
|
|
191
|
190
|
}
|
|
|
191
|
+ Map<String, Object> fileInfoMap = tempFile.get().getFileInfo();
|
|
|
192
|
+ if (caseId != null) {
|
|
|
193
|
+ fileInfoMap.put("caseId", caseId);
|
|
|
194
|
+ }
|
|
192
|
195
|
saveFileProcessor.saveBeforeInitialization(tempFile.get().getFileInfo(), fileByte, fileExtension);
|
|
193
|
196
|
|
|
194
|
197
|
// 保存文件
|
|
|
@@ -287,6 +290,18 @@ public class OnlyServiceAPIImpl implements OnlyServiceAPI {
|
|
287
|
290
|
int i = iskey(jsonObject.getString("key"), null);
|
|
288
|
291
|
//如果没有人使用当前文档,清空临时信息
|
|
289
|
292
|
if (i <= 0) {
|
|
|
293
|
+ //清空之前保存临时文件
|
|
|
294
|
+ String key = jsonObject.getString("key");
|
|
|
295
|
+ FileHandler tempFileHandler = tempFileContext.getHandlerByKey(key);
|
|
|
296
|
+ if (Objects.nonNull(tempFileHandler)) {
|
|
|
297
|
+ String url = jsonObject.getString("url");
|
|
|
298
|
+ String changesurl = jsonObject.getString("changesurl");
|
|
|
299
|
+ log.info("编辑后的文档下载路径url:" + url);
|
|
|
300
|
+ log.info("文件变动信息文件url:" + changesurl);
|
|
|
301
|
+ // 下载修改后文件
|
|
|
302
|
+ byte[] fileByte = FileUtil.getFileByte(url);
|
|
|
303
|
+ saveFileProcessor.save(tempFile.getFileInfo(), fileByte, null, jsonObject.getString("key"));
|
|
|
304
|
+ }
|
|
290
|
305
|
removeTempFile(jsonObject);
|
|
291
|
306
|
String id = (String) cache.get("getID_" + jsonObject.getString("key"));
|
|
292
|
307
|
cache.remove("getID_" + id);
|