|
@@ -133,81 +133,6 @@ public class DefaultMagicAPIService implements MagicAPIService, JsonCodeConstant
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void upload(InputStream inputStream, String mode) throws IOException {
|
|
public void upload(InputStream inputStream, String mode) throws IOException {
|
|
-// ZipResource root = new ZipResource(inputStream);
|
|
|
|
-// Set<String> apiPaths = new LinkedHashSet<>();
|
|
|
|
-// Set<String> functionPaths = new LinkedHashSet<>();
|
|
|
|
-// Set<String> websocketPaths = new LinkedHashSet<>();
|
|
|
|
-// Set<Group> groups = new LinkedHashSet<>();
|
|
|
|
-// Set<ApiInfo> apiInfos = new LinkedHashSet<>();
|
|
|
|
-// Set<FunctionInfo> functionInfos = new LinkedHashSet<>();
|
|
|
|
-// Set<WebSocketInfo> websocketInfos = new LinkedHashSet<>();
|
|
|
|
-// boolean checked = !UPLOAD_MODE_FULL.equals(mode);
|
|
|
|
-// // 检查上传资源中是否有冲突
|
|
|
|
-// readPaths(groups, apiPaths, functionPaths, websocketPaths, apiInfos, functionInfos, websocketInfos, "/", root, checked);
|
|
|
|
-// Resource item = root.getResource(GROUP_METABASE);
|
|
|
|
-// if (item.exists()) {
|
|
|
|
-// Group group = groupServiceProvider.readGroup(item);
|
|
|
|
-// // 检查上级分组是否存在
|
|
|
|
-// isTrue("0".equals(group.getParentId()) || groupServiceProvider.getGroupResource(group.getParentId()).exists(), GROUP_NOT_FOUND);
|
|
|
|
-// }
|
|
|
|
-// if (checked) {
|
|
|
|
-// // 检测分组是否有冲突
|
|
|
|
-// groups.forEach(group -> {
|
|
|
|
-// Resource resource;
|
|
|
|
-// if ("0".equals(group.getParentId())) {
|
|
|
|
-// resource = workspace.getDirectory(GROUP_TYPE_API.equals(group.getType()) ? PATH_API : (GROUP_TYPE_WEBSOCKET.equals(group.getType()) ? PATH_WEBSOCKET : PATH_FUNCTION)).getDirectory(group.getName());
|
|
|
|
-// } else {
|
|
|
|
-// resource = groupServiceProvider.getGroupResource(group.getId());
|
|
|
|
-// }
|
|
|
|
-// if (resource != null && resource.exists()) {
|
|
|
|
-// Group src = groupServiceProvider.readGroup(resource.getResource(GROUP_METABASE));
|
|
|
|
-// isTrue(src == null || src.getId().equals(group.getId()), GROUP_CONFLICT);
|
|
|
|
-// }
|
|
|
|
-// });
|
|
|
|
-// } else {
|
|
|
|
-// Resource resource = workspace.getDirectory(PATH_API);
|
|
|
|
-// resource.delete();
|
|
|
|
-// resource.mkdir();
|
|
|
|
-// resource = workspace.getDirectory(PATH_FUNCTION);
|
|
|
|
-// resource.delete();
|
|
|
|
-// resource.mkdir();
|
|
|
|
-// resource = workspace.getDirectory(PATH_WEBSOCKET);
|
|
|
|
-// resource.delete();
|
|
|
|
-// resource.mkdir();
|
|
|
|
-// resource = workspace.getDirectory(PATH_DATASOURCE);
|
|
|
|
-// resource.delete();
|
|
|
|
-// resource.mkdir();
|
|
|
|
-// }
|
|
|
|
-// for (Group group : groups) {
|
|
|
|
-// Resource groupResource = groupServiceProvider.getGroupResource(group.getId());
|
|
|
|
-// if (groupResource != null && groupResource.exists()) {
|
|
|
|
-// groupServiceProvider.update(group);
|
|
|
|
-// } else {
|
|
|
|
-// groupServiceProvider.insert(group);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// // 保存
|
|
|
|
-// write(mappingRegistry.getStoreServiceProvider(), apiInfos);
|
|
|
|
-// write(functionRegistry.getStoreServiceProvider(), functionInfos);
|
|
|
|
-// write(webSocketRegistry.getStoreServiceProvider(), websocketInfos);
|
|
|
|
-// // 备份
|
|
|
|
-// apiInfos.forEach(backupService::backup);
|
|
|
|
-// functionInfos.forEach(backupService::backup);
|
|
|
|
-// websocketInfos.forEach(backupService::backup);
|
|
|
|
-// // 重新注册
|
|
|
|
-// this.mappingRegistries.forEach(AbstractMagicDynamicMappingRegistry::registerAll);
|
|
|
|
-// Resource uploadDatasourceResource = root.getResource(PATH_DATASOURCE + "/");
|
|
|
|
-// if (uploadDatasourceResource.exists()) {
|
|
|
|
-// uploadDatasourceResource.files(".json").forEach(it -> {
|
|
|
|
-// byte[] content = it.read();
|
|
|
|
-// // 保存数据源
|
|
|
|
-// this.datasourceResource.getResource(it.name()).write(content);
|
|
|
|
-// // TODO 备份数据源
|
|
|
|
-// });
|
|
|
|
-// }
|
|
|
|
-// // TODO 会造成闪断,需要上锁处理。
|
|
|
|
-// registerAllDataSource();
|
|
|
|
-// magicNotifyService.sendNotify(new MagicNotify(instanceId));
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|