From 5dbec4e63aa7e866959e3ae479878b82ea3eaef1 Mon Sep 17 00:00:00 2001 From: casionone Date: Sat, 18 Sep 2021 18:29:06 +0800 Subject: [PATCH 01/29] [[linkis-bmlserver] replace jersey with spring web --- .../linkis/server/BDPJettyServerHelper.scala | 9 +- .../restful/SpringRestfulCatchAOP.scala | 60 +++++++ .../linkis/bml/restful/BmlProjectRestful.java | 98 +++++------ .../linkis/bml/restful/BmlRestfulApi.java | 160 ++++++++---------- .../bml/service/BmlShareResourceService.java | 6 +- .../linkis/bml/service/ResourceService.java | 6 +- .../linkis/bml/service/TaskService.java | 7 +- .../linkis/bml/service/VersionService.java | 6 +- .../impl/BmlShareResourceServiceImpl.java | 6 +- .../bml/service/impl/ResourceServiceImpl.java | 15 +- .../bml/service/impl/TaskServiceImpl.java | 12 +- .../bml/service/impl/VersionServiceImpl.java | 12 +- 12 files changed, 210 insertions(+), 187 deletions(-) create mode 100644 linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/restful/SpringRestfulCatchAOP.scala diff --git a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/BDPJettyServerHelper.scala b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/BDPJettyServerHelper.scala index 12e2c25753..39503677f8 100644 --- a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/BDPJettyServerHelper.scala +++ b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/BDPJettyServerHelper.scala @@ -29,7 +29,7 @@ import com.webank.wedatasphere.linkis.server.conf.ServerConfiguration._ import com.webank.wedatasphere.linkis.server.restful.RestfulApplication import com.webank.wedatasphere.linkis.server.socket.ControllerServer import com.webank.wedatasphere.linkis.server.socket.controller.{ServerEventService, ServerListenerEventBus} -import javax.servlet.{DispatcherType, Filter} +import javax.servlet.{DispatcherType, Filter, MultipartConfigElement} import org.apache.commons.io.FileUtils import org.eclipse.jetty.server.session.SessionHandler import org.eclipse.jetty.servlet.{DefaultServlet, FilterHolder, ServletContextHandler, ServletHolder} @@ -47,6 +47,9 @@ private[linkis] object BDPJettyServerHelper extends Logging { private var controllerServer: ControllerServer = _ private val services = mutable.Buffer[ServerEventService]() + private val TMP_FOLDER = "/tmp" + private val MAX_UPLOAD_SIZE = 20 * 1024 * 1024 + private[server] def getControllerServer = controllerServer private def createServerListenerEventBus(): Unit = { @@ -90,6 +93,10 @@ private[linkis] object BDPJettyServerHelper extends Logging { servletHolder.setName("springrestful") servletHolder.setForcedPath("springrestful") + //todo file size parameter configuration + val multipartConfigElement = new MultipartConfigElement(TMP_FOLDER, MAX_UPLOAD_SIZE, MAX_UPLOAD_SIZE * 2, MAX_UPLOAD_SIZE / 2) + servletHolder.getRegistration.setMultipartConfig(multipartConfigElement) + val p = BDP_SERVER_SPRING_RESTFUL_URI.getValue val restfulPath = if(p.endsWith("/*")) p else if(p.endsWith("/")) p + "*" diff --git a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/restful/SpringRestfulCatchAOP.scala b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/restful/SpringRestfulCatchAOP.scala new file mode 100644 index 0000000000..0d2568b75a --- /dev/null +++ b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/restful/SpringRestfulCatchAOP.scala @@ -0,0 +1,60 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.webank.wedatasphere.linkis.server.restful + +import com.webank.wedatasphere.linkis.common.utils.Logging +import com.webank.wedatasphere.linkis.server.{Message, catchIt} +import javax.servlet.http.HttpServletResponse +import org.aspectj.lang.ProceedingJoinPoint +import org.aspectj.lang.annotation.{Around, Aspect, Pointcut} +import org.springframework.stereotype.Component +import org.springframework.web.context.request.{RequestContextHolder, ServletRequestAttributes} + + +@Aspect +@Component +class SpringRestfulCatchAOP extends Logging { + + @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping) && execution(public com.webank.wedatasphere.linkis.server.Message *(..)))") + def restfulResponseCatch1() : Unit = {} + + @Around("restfulResponseCatch1()") + def dealResponseRestful(proceedingJoinPoint: ProceedingJoinPoint): Object = { + val resp: Message = catchIt { + return proceedingJoinPoint.proceed() + } + // convert http status code + getCurrentHttpResponse.setStatus(messageToHttpStatus(resp)) + resp + } + + def getCurrentHttpResponse: HttpServletResponse = { + val requestAttributes = RequestContextHolder.getRequestAttributes + if (requestAttributes.isInstanceOf[ServletRequestAttributes]) { + val response = requestAttributes.asInstanceOf[ServletRequestAttributes].getResponse + return response + } + null + } + def messageToHttpStatus(message: Message): Int = message.getStatus match { + case -1 => 401 + case 0 => 200 + case 1 => 400 + case 2 => 412 + case 3 => 403 + case 4 => 206 + } + +} diff --git a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/restful/BmlProjectRestful.java b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/restful/BmlProjectRestful.java index 22278ecdda..789f437828 100644 --- a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/restful/BmlProjectRestful.java +++ b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/restful/BmlProjectRestful.java @@ -17,9 +17,7 @@ import com.webank.wedatasphere.linkis.bml.Entity.DownloadModel; import com.webank.wedatasphere.linkis.bml.Entity.ResourceTask; -import com.webank.wedatasphere.linkis.bml.common.BmlPermissionDeniedException; import com.webank.wedatasphere.linkis.bml.common.BmlProjectNoEditException; -import com.webank.wedatasphere.linkis.bml.common.BmlResourceExpiredException; import com.webank.wedatasphere.linkis.bml.common.BmlServerParaErrorException; import com.webank.wedatasphere.linkis.bml.conf.BmlServerConfiguration; import com.webank.wedatasphere.linkis.bml.service.*; @@ -30,28 +28,24 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.codehaus.jackson.JsonNode; -import org.glassfish.jersey.media.multipart.FormDataMultiPart; -import org.glassfish.jersey.media.multipart.FormDataParam; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; import java.io.IOException; import java.util.*; import static com.webank.wedatasphere.linkis.bml.restful.BmlRestfulApi.URL_PREFIX; -@Path("bml") -@Component +@RequestMapping(path = "/bml") +@RestController public class BmlProjectRestful { private static final Logger LOGGER = LoggerFactory.getLogger(BmlProjectRestful.class); @@ -76,9 +70,8 @@ public class BmlProjectRestful { @Autowired private DownloadService downloadService; - @POST - @Path("createBmlProject") - public Response createBmlProject(@Context HttpServletRequest request, JsonNode jsonNode){ + @RequestMapping(path = "createBmlProject",method = RequestMethod.POST) + public Message createBmlProject(HttpServletRequest request, JsonNode jsonNode){ String username = SecurityFilter.getLoginUsername(request); String projectName = jsonNode.get(PROJECT_NAME_STR).getTextValue(); LOGGER.info("{} begins to create a project {} in bml", username, projectName); @@ -98,19 +91,19 @@ public Response createBmlProject(@Context HttpServletRequest request, JsonNode j } bmlProjectService.createBmlProject(projectName, username, editUsers, accessUsers); - return Message.messageToResponse(Message.ok("success to create project(创建工程ok)")); + return Message.ok("success to create project(创建工程ok)"); } - @POST - @Path("uploadShareResource") - public Response uploadShareResource(@Context HttpServletRequest request, @FormDataParam("system") String system, - @FormDataParam("resourceHeader") String resourceHeader, - @FormDataParam("isExpire") String isExpire, - @FormDataParam("expireType") String expireType, - @FormDataParam("expireTime") String expireTime, - @FormDataParam("maxVersion") int maxVersion, - @FormDataParam("projectName") String projectName, - FormDataMultiPart form) throws ErrorException{ + @RequestMapping(path = "uploadShareResource",method = RequestMethod.POST) + public Message uploadShareResource(HttpServletRequest request, + @RequestParam("system") String system, + @RequestParam("resourceHeader") String resourceHeader, + @RequestParam("isExpire") String isExpire, + @RequestParam("expireType") String expireType, + @RequestParam("expireTime") String expireTime, + @RequestParam("maxVersion") int maxVersion, + @RequestParam("projectName") String projectName, + @RequestParam("file") List files) throws ErrorException{ String username = SecurityFilter.getLoginUsername(request); Message message; try{ @@ -128,7 +121,7 @@ public Response uploadShareResource(@Context HttpServletRequest request, @FormDa properties.put("maxVersion", maxVersion); String clientIp = HttpRequestHelper.getIp(request); properties.put("clientIp", clientIp); - ResourceTask resourceTask = taskService.createUploadTask(form, DEFAULT_PROXY_USER, properties); + ResourceTask resourceTask = taskService.createUploadTask(files, DEFAULT_PROXY_USER, properties); bmlProjectService.addProjectResource(resourceTask.getResourceId(), projectName); message = Message.ok("The task of submitting and uploading resources was successful(提交上传资源任务成功)"); message.data("resourceId", resourceTask.getResourceId()); @@ -141,18 +134,17 @@ public Response uploadShareResource(@Context HttpServletRequest request, @FormDa exception.initCause(e); throw exception; } - return Message.messageToResponse(message); + return message; } - @POST - @Path("updateShareResource") - public Response updateShareResource(@Context HttpServletRequest request, - @FormDataParam("resourceId") String resourceId, - FormDataMultiPart form)throws ErrorException{ + @RequestMapping(path = "updateShareResource",method = RequestMethod.POST) + public Message updateShareResource(HttpServletRequest request, + @RequestParam("resourceId") String resourceId, + @RequestParam("file") MultipartFile file)throws ErrorException{ String username = SecurityFilter.getLoginUsername(request); if (StringUtils.isEmpty(resourceId) || !resourceService.checkResourceId(resourceId)) { LOGGER.error("the error resourceId is {} ", resourceId); @@ -175,7 +167,7 @@ public Response updateShareResource(@Context HttpServletRequest request, properties.put("clientIp", clientIp); ResourceTask resourceTask = null; synchronized (resourceId.intern()){ - resourceTask = taskService.createUpdateTask(resourceId, DEFAULT_PROXY_USER, form, properties); + resourceTask = taskService.createUpdateTask(resourceId, DEFAULT_PROXY_USER, file, properties); } message = Message.ok("The update resource task was submitted successfully(提交更新资源任务成功)"); message.data("resourceId",resourceId).data("version", resourceTask.getVersion()).data("taskId", resourceTask.getId()); @@ -189,15 +181,14 @@ public Response updateShareResource(@Context HttpServletRequest request, throw exception; } LOGGER.info("User {} ends updating resources {} (用户 {} 结束更新资源 {} )", username, resourceId, username, resourceId); - return Message.messageToResponse(message); + return message; } - @GET - @Path("downloadShareResource") - public Response downloadShareResource(@QueryParam("resourceId") String resourceId, - @QueryParam("version") String version, - @Context HttpServletResponse resp, - @Context HttpServletRequest request) throws IOException, ErrorException { + @RequestMapping(path = "downloadShareResource",method = RequestMethod.GET) + public Message downloadShareResource(@RequestParam(value="resourceId",required=false) String resourceId, + @RequestParam(value="version",required=false) String version, + HttpServletResponse resp, + HttpServletRequest request) throws IOException, ErrorException { String user = RestfulUtils.getUserName(request); Message message = null; resp.setContentType("application/x-msdownload"); @@ -244,32 +235,29 @@ public Response downloadShareResource(@QueryParam("resourceId") String resourceI IOUtils.closeQuietly(resp.getOutputStream()); } LOGGER.info("{} Download resource {} successfully ({} 下载资源 {} 成功)", user, resourceId, user, resourceId); - return Message.messageToResponse(message); + return message; } - @GET - @Path("getProjectInfo") - public Response getProjectInfo(@Context HttpServletRequest request, @QueryParam("projectName") String projectName){ - return Message.messageToResponse(Message.ok("Obtain project information successfully (获取工程信息成功)")); + @RequestMapping(path = "getProjectInfo",method = RequestMethod.GET) + public Message getProjectInfo(HttpServletRequest request, @RequestParam(value="projectName",required=false) String projectName){ + return Message.ok("Obtain project information successfully (获取工程信息成功)"); } - @POST - @Path("attachResourceAndProject") - public Response attachResourceAndProject(@Context HttpServletRequest request, JsonNode jsonNode) throws ErrorException{ + @RequestMapping(path = "attachResourceAndProject",method = RequestMethod.POST) + public Message attachResourceAndProject(HttpServletRequest request, JsonNode jsonNode) throws ErrorException{ String username = SecurityFilter.getLoginUsername(request); String projectName = jsonNode.get(PROJECT_NAME_STR).getTextValue(); String resourceId = jsonNode.get("resourceId").getTextValue(); LOGGER.info("begin to attach {} and {}", projectName, username); bmlProjectService.attach(projectName, resourceId); - return Message.messageToResponse(Message.ok("attach resource and project ok")); + return Message.ok("attach resource and project ok"); } - @POST - @Path("updateProjectUsers") - public Response updateProjectUsers(@Context HttpServletRequest request, JsonNode jsonNode) throws ErrorException{ + @RequestMapping(path = "updateProjectUsers",method = RequestMethod.POST) + public Message updateProjectUsers(HttpServletRequest request, JsonNode jsonNode) throws ErrorException{ String username = SecurityFilter.getLoginUsername(request); String projectName = jsonNode.get("projectName").getTextValue(); LOGGER.info("{} begins to update project users for {}", username, projectName); @@ -284,7 +272,7 @@ public Response updateProjectUsers(@Context HttpServletRequest request, JsonNode accessUsersNode.forEach(node -> accessUsers.add(node.getTextValue())); } bmlProjectService.updateProjectUsers(username, projectName, editUsers, accessUsers); - return Message.messageToResponse(Message.ok("Updated project related user success(更新工程的相关用户成功)")); + return Message.ok("Updated project related user success(更新工程的相关用户成功)"); } diff --git a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/restful/BmlRestfulApi.java b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/restful/BmlRestfulApi.java index a0e73a996f..541989a2b6 100644 --- a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/restful/BmlRestfulApi.java +++ b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/restful/BmlRestfulApi.java @@ -38,13 +38,14 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.codehaus.jackson.JsonNode; -import org.glassfish.jersey.media.multipart.FormDataMultiPart; -import org.glassfish.jersey.media.multipart.FormDataParam; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.util.ArrayList; @@ -53,22 +54,11 @@ import java.util.Iterator; import java.util.List; import java.util.Map; - import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - - -@Path("bml") -@Component + +@RequestMapping(path = "/bml") +@RestController public class BmlRestfulApi { @Autowired @@ -90,12 +80,11 @@ public class BmlRestfulApi { public static final String URL_PREFIX = "/bml/"; - @GET - @Path("getVersions") - public Response getVersions(@QueryParam("resourceId") String resourceId, - @QueryParam("currentPage") String currentPage, - @QueryParam("pageSize") String pageSize, - @Context HttpServletRequest request)throws ErrorException{ + @RequestMapping(path = "getVersions",method = RequestMethod.GET) + public Message getVersions(@RequestParam(value="resourceId",required=false) String resourceId, + @RequestParam(value="currentPage",required=false) String currentPage, + @RequestParam(value="pageSize",required=false) String pageSize, + HttpServletRequest request)throws ErrorException{ String user = RestfulUtils.getUserName(request); if (StringUtils.isEmpty(resourceId) || !resourceService.checkResourceId(resourceId)){ @@ -144,16 +133,15 @@ public Response getVersions(@QueryParam("resourceId") String resourceId, throw new BmlQueryFailException("Sorry, the query for version information failed(抱歉,查询版本信息失败)"); } - return Message.messageToResponse(message); + return message; } - @GET - @Path("getResources") - public Response getResources(@QueryParam("system") String system, - @QueryParam("currentPage") String currentPage, - @QueryParam("pageSize") String pageSize, - @Context HttpServletRequest request, - @Context HttpServletResponse response)throws ErrorException { + @RequestMapping(path = "getResources",method = RequestMethod.GET) + public Message getResources(@RequestParam(value="system",required=false) String system, + @RequestParam(value="currentPage",required=false) String currentPage, + @RequestParam(value="pageSize",required=false) String pageSize, + HttpServletRequest request, + HttpServletResponse response)throws ErrorException { String user = RestfulUtils.getUserName(request); @@ -204,17 +192,14 @@ public Response getResources(@QueryParam("system") String system, throw new BmlQueryFailException("Failed to get all system resource information(获取系统所有资源信息失败)"); } - return Message.messageToResponse(message); + return message; } - @POST - @Path("deleteVersion") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response deleteVersion(JsonNode jsonNode, - @Context HttpServletRequest request) throws IOException, ErrorException{ + @RequestMapping(path = "deleteVersion",method = RequestMethod.POST) + public Message deleteVersion(JsonNode jsonNode, + HttpServletRequest request) throws IOException, ErrorException{ String user = RestfulUtils.getUserName(request); @@ -250,15 +235,12 @@ public Response deleteVersion(JsonNode jsonNode, logger.info("Update task tasKid :{} -ResourceId :{} with {} state(删除版本成功.更新任务 taskId:{}-resourceId:{} 为 {} 状态).", resourceTask.getId(), resourceTask.getResourceId(), TaskState.SUCCESS.getValue(),resourceTask.getId(), resourceTask.getResourceId(), TaskState.SUCCESS.getValue()); throw new BmlQueryFailException("Failed to delete the resource version(删除资源版本失败)"); } - return Message.messageToResponse(message); + return message; } - @POST - @Path("deleteResource") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public Response deleteResource(JsonNode jsonNode, - @Context HttpServletRequest request) throws IOException, ErrorException{ + @RequestMapping(path = "deleteResource",method = RequestMethod.POST) + public Message deleteResource(JsonNode jsonNode, + HttpServletRequest request) throws IOException, ErrorException{ String user = RestfulUtils.getUserName(request); @@ -291,14 +273,13 @@ public Response deleteResource(JsonNode jsonNode, throw new BmlQueryFailException("Delete resource operation failed(删除资源操作失败)"); } - return Message.messageToResponse(message); + return message; } - @POST - @Path("deleteResources") - public Response deleteResources(JsonNode jsonNode, - @Context HttpServletRequest request) throws IOException, ErrorException{ + @RequestMapping(path = "deleteResources",method = RequestMethod.POST) + public Message deleteResources(JsonNode jsonNode, + HttpServletRequest request) throws IOException, ErrorException{ String user = RestfulUtils.getUserName(request); List resourceIds = new ArrayList<>(); @@ -319,7 +300,7 @@ public Response deleteResources(JsonNode jsonNode, Message message = Message.error("ResourceID :"+ resourceId +" is empty, illegal or has been deleted(resourceId:"+resourceId+"为空,非法或已被删除)"); message.setMethod(URL_PREFIX + "deleteResources"); message.setStatus(1); - return Message.messageToResponse(message); + return message; } } } @@ -341,7 +322,7 @@ public Response deleteResources(JsonNode jsonNode, logger.info("Failed to delete resources in bulk. Update task tasKid :{} -ResourceId :{} is in the {} state (批量删除资源失败.更新任务 taskId:{}-resourceId:{} 为 {} 状态.)", resourceTask.getId(), resourceTask.getResourceId(), TaskState.FAILED.getValue(),resourceTask.getId(), resourceTask.getResourceId(), TaskState.FAILED.getValue()); throw new BmlQueryFailException("The bulk delete resource operation failed(批量删除资源操作失败)"); } - return Message.messageToResponse(message); + return message; } /** @@ -350,23 +331,22 @@ public Response deleteResources(JsonNode jsonNode, * @param version 资源版本,如果不指定,默认为最新 * @param resp httpServletResponse * @param request httpServletRequest - * @return Response + * @return Message * @throws IOException * @throws ErrorException */ - @GET - @Path("download") - public Response download(@QueryParam("resourceId") String resourceId, - @QueryParam("version") String version, - @Context HttpServletResponse resp, - @Context HttpServletRequest request) throws IOException, ErrorException { + @RequestMapping(path = "download",method = RequestMethod.GET) + public Message download(@RequestParam(value="resourceId",required=false) String resourceId, + @RequestParam(value="version",required=false) String version, + HttpServletResponse resp, + HttpServletRequest request) throws IOException, ErrorException { String user = RestfulUtils.getUserName(request); if (StringUtils.isBlank(resourceId) || !resourceService.checkResourceId(resourceId)) { Message message = Message.error("ResourceID :"+ resourceId +" is empty, illegal or has been deleted (resourceId:"+resourceId+"为空,非法或者已被删除!)"); message.setMethod(URL_PREFIX + "download"); message.setStatus(1); - return Message.messageToResponse(message); + return message; } if (!resourceService.checkAuthority(user, resourceId)){ @@ -381,7 +361,7 @@ public Response download(@QueryParam("resourceId") String resourceId, Message message = Message.error("version:"+version+"is empty, illegal or has been deleted"); message.setMethod(URL_PREFIX + "download"); message.setStatus(1); - return Message.messageToResponse(message); + return message; } //判resourceId和version是否过期 if (!resourceService.checkExpire(resourceId, version)){ @@ -428,19 +408,18 @@ public Response download(@QueryParam("resourceId") String resourceId, IOUtils.closeQuietly(resp.getOutputStream()); } logger.info("{} Download resource {} successfully {} 下载资源 {} 成功", user, resourceId, user, resourceId); - return Message.messageToResponse(message); + return message; } - @POST - @Path("upload") - public Response uploadResource(@Context HttpServletRequest req, - @FormDataParam("system") String system, - @FormDataParam("resourceHeader") String resourceHeader, - @FormDataParam("isExpire") String isExpire, - @FormDataParam("expireType") String expireType, - @FormDataParam("expireTime") String expireTime, - @FormDataParam("maxVersion") int maxVersion, - FormDataMultiPart form) throws ErrorException { + @RequestMapping(path = "upload",method = RequestMethod.POST) + public Message uploadResource(HttpServletRequest req, + @RequestParam("system") String system, + @RequestParam("resourceHeader") String resourceHeader, + @RequestParam("isExpire") String isExpire, + @RequestParam("expireType") String expireType, + @RequestParam("expireTime") String expireTime, + @RequestParam("maxVersion") int maxVersion, + @RequestParam("file") List files) throws ErrorException { String user = RestfulUtils.getUserName(req); Message message; try{ @@ -454,7 +433,7 @@ public Response uploadResource(@Context HttpServletRequest req, properties.put("maxVersion", maxVersion); String clientIp = HttpRequestHelper.getIp(req); properties.put("clientIp", clientIp); - ResourceTask resourceTask = taskService.createUploadTask(form, user, properties); + ResourceTask resourceTask = taskService.createUploadTask(files, user, properties); message = Message.ok("The task of submitting and uploading resources was successful(提交上传资源任务成功)"); message.setMethod(URL_PREFIX + "upload"); message.setStatus(0); @@ -468,21 +447,20 @@ public Response uploadResource(@Context HttpServletRequest req, exception.initCause(e); throw exception; } - return Message.messageToResponse(message); + return message; } /** * 用户通过http的方式更新资源文件 * @param request httpServletRequest * @param resourceId 用户希望更新资源的resourceId - * @param formDataMultiPart form表单内容 + * @param file file文件 * @return resourceId 以及 新的版本号 */ - @POST - @Path("updateVersion") - public Response updateVersion(@Context HttpServletRequest request, - @FormDataParam("resourceId") String resourceId, - FormDataMultiPart formDataMultiPart)throws Exception{ + @RequestMapping(path = "updateVersion",method = RequestMethod.POST) + public Message updateVersion(HttpServletRequest request, + @RequestParam("resourceId") String resourceId, + @RequestParam("file") MultipartFile file)throws Exception{ String user = RestfulUtils.getUserName(request); if (StringUtils.isEmpty(resourceId) || !resourceService.checkResourceId(resourceId)) { logger.error("error resourceId is {} ", resourceId); @@ -500,7 +478,7 @@ public Response updateVersion(@Context HttpServletRequest request, properties.put("clientIp", clientIp); ResourceTask resourceTask = null; synchronized (resourceId.intern()){ - resourceTask = taskService.createUpdateTask(resourceId, user, formDataMultiPart, properties); + resourceTask = taskService.createUpdateTask(resourceId, user, file, properties); } message = Message.ok("The update resource task was submitted successfully(提交更新资源任务成功)"); message.data("resourceId",resourceId).data("version", resourceTask.getVersion()).data("taskId", resourceTask.getId()); @@ -514,14 +492,13 @@ public Response updateVersion(@Context HttpServletRequest request, throw exception; } logger.info("User {} ends updating resources {}(用户 {} 结束更新资源 {}) ", user, resourceId, user, resourceId); - return Message.messageToResponse(message); + return message; } - @GET - @Path("getBasic") - public Response getBasic(@QueryParam("resourceId") String resourceId, - @Context HttpServletRequest request)throws ErrorException{ + @RequestMapping(path = "getBasic",method = RequestMethod.GET) + public Message getBasic(@RequestParam(value="resourceId",required=false) String resourceId, + HttpServletRequest request)throws ErrorException{ String user = RestfulUtils.getUserName(request); if (StringUtils.isEmpty(resourceId) || !resourceService.checkResourceId(resourceId)){ @@ -560,14 +537,13 @@ public Response getBasic(@QueryParam("resourceId") String resourceId, throw new BmlQueryFailException("Failed to obtain resource basic information (获取资源基本信息失败)"); } - return Message.messageToResponse(message); + return message; } - @GET - @Path("getResourceInfo") - public Response getResourceInfo(@Context HttpServletRequest request, @QueryParam("resourceId") String resourceId){ - return Message.messageToResponse(Message.ok("Obtained information successfully(获取信息成功)")); + @RequestMapping(path = "getResourceInfo",method = RequestMethod.GET) + public Message getResourceInfo(HttpServletRequest request, @RequestParam(value="resourceId",required=false) String resourceId){ + return Message.ok("Obtained information successfully(获取信息成功)"); } diff --git a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/BmlShareResourceService.java b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/BmlShareResourceService.java index 67c67d416d..6cf86e233f 100644 --- a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/BmlShareResourceService.java +++ b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/BmlShareResourceService.java @@ -15,16 +15,16 @@ */ package com.webank.wedatasphere.linkis.bml.service; -import org.glassfish.jersey.media.multipart.FormDataMultiPart; +import org.springframework.web.multipart.MultipartFile; import java.io.OutputStream; import java.util.Map; public interface BmlShareResourceService { - void uploadShareResource(FormDataMultiPart formDataMultiPart, String user, Map properties); + void uploadShareResource(MultipartFile multipartFile, String user, Map properties); - void updateShareResource(FormDataMultiPart formDataMultiPart, String user, Map properties); + void updateShareResource(MultipartFile multipartFile, String user, Map properties); void downloadShareResource(String user, String resourceId, String version, OutputStream outputStream, Map properties); diff --git a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/ResourceService.java b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/ResourceService.java index 19b18e507c..9dee7a92f0 100644 --- a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/ResourceService.java +++ b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/ResourceService.java @@ -18,7 +18,7 @@ import com.webank.wedatasphere.linkis.bml.Entity.Resource; import com.webank.wedatasphere.linkis.bml.service.impl.ResourceServiceImpl; -import org.glassfish.jersey.media.multipart.FormDataMultiPart; +import org.springframework.web.multipart.MultipartFile; import java.util.List; import java.util.Map; @@ -38,11 +38,11 @@ public interface ResourceService { * 3.二进制流的存储方式有两种,根据资源文件的大小选择合并或者是单独存储 * 4.生成resourceID * 4.更新resource 和 resource_version表 - * @param formDataMultiPart notnull + * @param files notnull * @param user um_user * @param properties Map */ - List upload(FormDataMultiPart formDataMultiPart, String user, Map properties)throws Exception; + List upload(List files, String user, Map properties)throws Exception; boolean checkResourceId(String resourceId); diff --git a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/TaskService.java b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/TaskService.java index 8b53ae5133..ec9fc02cb8 100644 --- a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/TaskService.java +++ b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/TaskService.java @@ -17,8 +17,7 @@ import com.webank.wedatasphere.linkis.bml.Entity.ResourceTask; -import org.apache.ibatis.annotations.Param; -import org.glassfish.jersey.media.multipart.FormDataMultiPart; +import org.springframework.web.multipart.MultipartFile; import java.util.Date; import java.util.List; @@ -26,10 +25,10 @@ public interface TaskService { - ResourceTask createUploadTask(FormDataMultiPart form, String user, Map properties) + ResourceTask createUploadTask(List files, String user, Map properties) throws Exception; - ResourceTask createUpdateTask(String resourceId, String user, FormDataMultiPart formDataMultiPart, Map properties) + ResourceTask createUpdateTask(String resourceId, String user, MultipartFile file, Map properties) throws Exception; ResourceTask createDownloadTask(String resourceId, String version, String user, String clientIp); diff --git a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/VersionService.java b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/VersionService.java index 1b33e95408..18417e36c7 100644 --- a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/VersionService.java +++ b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/VersionService.java @@ -18,7 +18,7 @@ import com.webank.wedatasphere.linkis.bml.Entity.ResourceVersion; import com.webank.wedatasphere.linkis.bml.Entity.Version; -import org.glassfish.jersey.media.multipart.FormDataMultiPart; +import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.io.OutputStream; @@ -62,12 +62,12 @@ public interface VersionService { * 2.将资源的二进制流append到path对应的文件末尾 * @param resourceId resourceId * @param user 用户信息 - * @param formDataMultiPart 上传的二进制流 + * @param file 上传的二进制流文件 * @param params 可选参数 * @return 新的version * @throws Exception */ - String updateVersion(String resourceId, String user, FormDataMultiPart formDataMultiPart, Map params)throws Exception; + String updateVersion(String resourceId, String user, MultipartFile file, Map params)throws Exception; String getNewestVersion(String resourceId); diff --git a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/impl/BmlShareResourceServiceImpl.java b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/impl/BmlShareResourceServiceImpl.java index 9e55a68986..c64ab2c8ee 100644 --- a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/impl/BmlShareResourceServiceImpl.java +++ b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/impl/BmlShareResourceServiceImpl.java @@ -16,19 +16,19 @@ package com.webank.wedatasphere.linkis.bml.service.impl; import com.webank.wedatasphere.linkis.bml.service.BmlShareResourceService; -import org.glassfish.jersey.media.multipart.FormDataMultiPart; +import org.springframework.web.multipart.MultipartFile; import java.io.OutputStream; import java.util.Map; public class BmlShareResourceServiceImpl implements BmlShareResourceService { @Override - public void uploadShareResource(FormDataMultiPart formDataMultiPart, String user, Map properties) { + public void uploadShareResource(MultipartFile multipartFile, String user, Map properties) { } @Override - public void updateShareResource(FormDataMultiPart formDataMultiPart, String user, Map properties) { + public void updateShareResource(MultipartFile multipartFile, String user, Map properties) { } diff --git a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/impl/ResourceServiceImpl.java b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/impl/ResourceServiceImpl.java index a48badf456..2a7b5d789d 100644 --- a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/impl/ResourceServiceImpl.java +++ b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/impl/ResourceServiceImpl.java @@ -24,14 +24,12 @@ import com.webank.wedatasphere.linkis.bml.dao.VersionDao; import com.webank.wedatasphere.linkis.bml.service.ResourceService; import org.apache.commons.lang.StringUtils; -import org.glassfish.jersey.media.multipart.FormDataBodyPart; -import org.glassfish.jersey.media.multipart.FormDataContentDisposition; -import org.glassfish.jersey.media.multipart.FormDataMultiPart; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; import javax.validation.constraints.NotNull; import java.io.InputStream; @@ -72,15 +70,14 @@ public void batchDeleteResources(List resourceIds) { @Transactional(rollbackFor = Exception.class) @Override - public List upload(FormDataMultiPart formDataMultiPart, String user, Map properties) throws Exception{ + public List upload(List files, String user, Map properties) throws Exception{ ResourceHelper resourceHelper = ResourceHelperFactory.getResourceHelper(); - List files = formDataMultiPart.getFields("file"); + //List files = formDataMultiPart.getFields("file"); List results = new ArrayList<>(); - for (FormDataBodyPart p : files) { + for (MultipartFile p : files) { String resourceId = (String) properties.get("resourceId"); - InputStream inputStream = p.getValueAs(InputStream.class); - FormDataContentDisposition fileDetail = p.getFormDataContentDisposition(); - String fileName = new String(fileDetail.getFileName().getBytes(Constant.ISO_ENCODE), Constant.UTF8_ENCODE); + InputStream inputStream = p.getInputStream(); + String fileName = new String(p.getOriginalFilename().getBytes(Constant.ISO_ENCODE), Constant.UTF8_ENCODE); fileName = resourceId; String path = resourceHelper.generatePath(user, fileName, properties); StringBuilder sb = new StringBuilder(); diff --git a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/impl/TaskServiceImpl.java b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/impl/TaskServiceImpl.java index b80209c32b..eb3ab74412 100644 --- a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/impl/TaskServiceImpl.java +++ b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/impl/TaskServiceImpl.java @@ -28,12 +28,12 @@ import com.webank.wedatasphere.linkis.bml.common.*; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang.StringUtils; -import org.glassfish.jersey.media.multipart.FormDataMultiPart; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; import java.util.Date; import java.util.List; @@ -63,8 +63,8 @@ public class TaskServiceImpl implements TaskService { @Override @Transactional(rollbackFor = Exception.class) - public ResourceTask createUploadTask(FormDataMultiPart form, String user, - Map properties) throws Exception { + public ResourceTask createUploadTask(List files, String user, + Map properties) throws Exception { //Create upload task record. String resourceId = UUID.randomUUID().toString(); ResourceTask resourceTask = ResourceTask.createUploadTask(resourceId, user, properties); @@ -74,7 +74,7 @@ public ResourceTask createUploadTask(FormDataMultiPart form, String user, LOGGER.info("Successful update task (成功更新任务 ) taskId:{}-resourceId:{} status is {} .", resourceTask.getId(), resourceTask.getResourceId(), TaskState.RUNNING.getValue()); properties.put("resourceId", resourceTask.getResourceId()); try { - ResourceServiceImpl.UploadResult result = resourceService.upload(form, user, properties).get(0); + ResourceServiceImpl.UploadResult result = resourceService.upload(files, user, properties).get(0); if (result.isSuccess()){ taskDao.updateState(resourceTask.getId(), TaskState.SUCCESS.getValue(), new Date()); LOGGER.info("Upload resource successfully. Update task(上传资源成功.更新任务) taskId:{}-resourceId:{} status is {} .", resourceTask.getId(), resourceTask.getResourceId(), TaskState.SUCCESS.getValue()); @@ -94,7 +94,7 @@ public ResourceTask createUploadTask(FormDataMultiPart form, String user, @Override @Transactional(rollbackFor = Exception.class) public ResourceTask createUpdateTask(String resourceId, String user, - FormDataMultiPart formDataMultiPart, Map properties) throws Exception{ + MultipartFile file, Map properties) throws Exception{ final String resourceIdLock = resourceId.intern(); /* 多个BML服务器实例对同一资源resourceId同时更新,规定只能有一个实例能更新成功, @@ -119,7 +119,7 @@ public ResourceTask createUpdateTask(String resourceId, String user, LOGGER.info("Successful update task (成功更新任务 ) taskId:{}-resourceId:{} status is {} .", resourceTask.getId(), resourceTask.getResourceId(), TaskState.RUNNING.getValue()); properties.put("newVersion", resourceTask.getVersion()); try { - versionService.updateVersion(resourceTask.getResourceId(), user, formDataMultiPart, properties); + versionService.updateVersion(resourceTask.getResourceId(), user, file, properties); taskDao.updateState(resourceTask.getId(), TaskState.SUCCESS.getValue(), new Date()); LOGGER.info("Upload resource successfully. Update task (上传资源失败.更新任务) taskId:{}-resourceId:{} status is {}.", resourceTask.getId(), resourceTask.getResourceId(), TaskState.SUCCESS.getValue()); } catch (Exception e) { diff --git a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/impl/VersionServiceImpl.java b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/impl/VersionServiceImpl.java index d3466c7790..65947f71cc 100644 --- a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/impl/VersionServiceImpl.java +++ b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/service/impl/VersionServiceImpl.java @@ -30,13 +30,11 @@ import com.webank.wedatasphere.linkis.storage.FSFactory; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; -import org.glassfish.jersey.media.multipart.FormDataBodyPart; -import org.glassfish.jersey.media.multipart.FormDataContentDisposition; -import org.glassfish.jersey.media.multipart.FormDataMultiPart; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; import java.io.IOException; import java.io.InputStream; @@ -89,14 +87,12 @@ public void deleteResourcesVersions(List resourceIds, List versi } @Override - public String updateVersion(String resourceId, String user, FormDataMultiPart formDataMultiPart, + public String updateVersion(String resourceId, String user, MultipartFile file, Map params) throws Exception { ResourceHelper resourceHelper = ResourceHelperFactory.getResourceHelper(); - FormDataBodyPart file = formDataMultiPart.getField("file"); - InputStream inputStream = file.getValueAs(InputStream.class); + InputStream inputStream = file.getInputStream(); final String resourceIdLock = resourceId.intern(); - FormDataContentDisposition fileDetail = file.getFormDataContentDisposition(); - String fileName = new String(fileDetail.getFileName().getBytes("ISO8859-1"), "UTF-8"); + String fileName = new String(file.getOriginalFilename().getBytes("ISO8859-1"), "UTF-8"); //获取资源的path String newVersion = params.get("newVersion").toString(); String path = versionDao.getResourcePath(resourceId) + "_" + newVersion; From 6f317d504c81eacf31d8fa65aee852c5e90c2468 Mon Sep 17 00:00:00 2001 From: casionone Date: Sat, 18 Sep 2021 19:12:11 +0800 Subject: [PATCH 02/29] [linkis-cs-server] replace jersey with spring web --- .../restful/ContextHistoryRestfulApi.java | 59 +++++------- .../server/restful/ContextIDRestfulApi.java | 57 ++++++----- .../restful/ContextListenerRestfulApi.java | 41 ++++---- .../cs/server/restful/ContextRestfulApi.java | 95 +++++++++---------- .../cs/server/restful/HelloRestfulApi.java | 25 ++--- .../cs/server/ContextHistoryRestfulApi.java | 39 ++++---- .../linkis/cs/server/ContextIDRestfulApi.java | 41 ++++---- .../cs/server/ContextListenerRestfulApi.java | 34 +++---- .../linkis/cs/server/ContextRestfulApi.java | 63 +++++------- .../linkis/cs/server/CsRestfulParent.java | 11 +-- 10 files changed, 198 insertions(+), 267 deletions(-) diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextHistoryRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextHistoryRestfulApi.java index da2f796dba..fc9a0b2a4f 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextHistoryRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextHistoryRestfulApi.java @@ -27,24 +27,16 @@ import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import java.io.IOException; - -@Component -@Path("/contextservice") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) +@RestController +@RequestMapping(path = "/contextservice") public class ContextHistoryRestfulApi implements CsRestfulParent { @Autowired @@ -52,9 +44,9 @@ public class ContextHistoryRestfulApi implements CsRestfulParent { private ObjectMapper objectMapper = new ObjectMapper(); - @POST - @Path("createHistory") - public Response createHistory(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + + @RequestMapping(path = "createHistory",method = RequestMethod.POST) + public Message createHistory(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextHistory history = getContextHistoryFromJsonNode(jsonNode); ContextID contextID = getContextIDFromJsonNode(jsonNode); //source and contextid cannot be empty @@ -65,12 +57,12 @@ public Response createHistory(@Context HttpServletRequest req, JsonNode jsonNode throw new CSErrorException(97000, "contxtId cannot be empty"); } HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.CREATE, contextID, history); - return Message.messageToResponse(generateResponse(answerJob, "")); + return generateResponse(answerJob, ""); } - @POST - @Path("removeHistory") - public Response removeHistory(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + + @RequestMapping(path = "removeHistory",method = RequestMethod.POST) + public Message removeHistory(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextHistory history = getContextHistoryFromJsonNode(jsonNode); ContextID contextID = getContextIDFromJsonNode(jsonNode); //source and contextid cannot be empty @@ -81,25 +73,26 @@ public Response removeHistory(@Context HttpServletRequest req, JsonNode jsonNode throw new CSErrorException(97000, "contxtId cannot be empty"); } HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.REMOVE, contextID, history); - return Message.messageToResponse(generateResponse(answerJob, "")); + return generateResponse(answerJob, ""); + } - @POST - @Path("getHistories") - public Response getHistories(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + + @RequestMapping(path = "getHistories",method = RequestMethod.POST) + public Message getHistories(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); if (StringUtils.isEmpty(contextID.getContextId())) { throw new CSErrorException(97000, "contxtId cannot be empty"); } HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.GET, contextID); Message message = generateResponse(answerJob, "contextHistory"); - return Message.messageToResponse(message); + return message; } - @POST - @Path("getHistory") - public Response getHistory(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + + @RequestMapping(path = "getHistory",method = RequestMethod.POST) + public Message getHistory(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { //ContextID contextID, String source String source = jsonNode.get("source").getTextValue(); ContextID contextID = getContextIDFromJsonNode(jsonNode); @@ -112,12 +105,12 @@ public Response getHistory(@Context HttpServletRequest req, JsonNode jsonNode) t } HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.GET, contextID, source); Message message = generateResponse(answerJob, "contextHistory"); - return Message.messageToResponse(message); + return message; } - @POST - @Path("searchHistory") - public Response searchHistory(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + + @RequestMapping(path = "searchHistory",method = RequestMethod.POST) + public Message searchHistory(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { //ContextID contextID, String[] keywords ContextID contextID = getContextIDFromJsonNode(jsonNode); String[] keywords = objectMapper.readValue(jsonNode.get("keywords"), String[].class); @@ -126,7 +119,7 @@ public Response searchHistory(@Context HttpServletRequest req, JsonNode jsonNode } HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.SEARCH, contextID, keywords); Message message = generateResponse(answerJob, "contextHistory"); - return Message.messageToResponse(message); + return message; } diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextIDRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextIDRestfulApi.java index 15ec0dff63..8f026c5ef3 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextIDRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextIDRestfulApi.java @@ -26,77 +26,74 @@ import com.webank.wedatasphere.linkis.server.Message; import org.codehaus.jackson.JsonNode; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import java.io.IOException; - -@Component -@Path("/contextservice") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) +@RestController +@RequestMapping(path = "/contextservice") public class ContextIDRestfulApi implements CsRestfulParent { @Autowired private CsScheduler csScheduler; - @POST - @Path("createContextID") - public Response createContextID(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, ClassNotFoundException, IOException, CSErrorException { + + @RequestMapping(path = "createContextID",method = RequestMethod.POST) + public Message createContextID(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, ClassNotFoundException, IOException, CSErrorException { ContextID contextID = getContextIDFromJsonNode(jsonNode); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.CREATE, contextID); - return Message.messageToResponse(generateResponse(answerJob, "contextId")); + return generateResponse(answerJob, "contextId"); } - @GET - @Path("getContextID") - public Response getContextID(@Context HttpServletRequest req, @QueryParam("contextId") String id) throws InterruptedException, CSErrorException { + + @RequestMapping(path = "getContextID",method = RequestMethod.GET) + public Message getContextID(HttpServletRequest req, + @RequestParam(value="contextId",required=false) String id) throws InterruptedException, CSErrorException { if (StringUtils.isEmpty(id)) { throw new CSErrorException(97000, "contxtId cannot be empty"); } HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.GET, id); Message message = generateResponse(answerJob, "contextID"); - return Message.messageToResponse(message); + return message; } - @POST - @Path("updateContextID") - public Response updateContextID(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + + @RequestMapping(path = "updateContextID",method = RequestMethod.POST) + public Message updateContextID(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); if (StringUtils.isEmpty(contextID.getContextId())) { throw new CSErrorException(97000, "contxtId cannot be empty"); } HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.UPDATE, contextID); - return Message.messageToResponse(generateResponse(answerJob, "")); + return generateResponse(answerJob, ""); } - @POST - @Path("resetContextID") - public Response resetContextID(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException { + + @RequestMapping(path = "resetContextID",method = RequestMethod.POST) + public Message resetContextID(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException { if (!jsonNode.has(ContextHTTPConstant.CONTEXT_ID_STR)) { throw new CSErrorException(97000, ContextHTTPConstant.CONTEXT_ID_STR + " cannot be empty"); } String id = jsonNode.get(ContextHTTPConstant.CONTEXT_ID_STR).getTextValue(); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.RESET, id); - return Message.messageToResponse(generateResponse(answerJob, "")); + return generateResponse(answerJob, ""); } - @POST - @Path("removeContextID") - public Response removeContextID(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException { + + @RequestMapping(path = "removeContextID",method = RequestMethod.POST) + public Message removeContextID(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException { String id = jsonNode.get("contextId").getTextValue(); if (StringUtils.isEmpty(id)) { throw new CSErrorException(97000, "contxtId cannot be empty"); } HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.REMOVE, id); - return Message.messageToResponse(generateResponse(answerJob, "")); + return generateResponse(answerJob, ""); } @Override diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextListenerRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextListenerRestfulApi.java index d68d02ead7..2830977ce9 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextListenerRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextListenerRestfulApi.java @@ -30,23 +30,16 @@ import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import java.io.IOException; -@Component -@Path("/contextservice") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) +@RestController +@RequestMapping(path = "/contextservice") public class ContextListenerRestfulApi implements CsRestfulParent { @Autowired @@ -54,35 +47,35 @@ public class ContextListenerRestfulApi implements CsRestfulParent { private ObjectMapper objectMapper = new ObjectMapper(); - @POST - @Path("onBindIDListener") - public Response onBindIDListener(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + + @RequestMapping(path = "onBindIDListener",method = RequestMethod.POST) + public Message onBindIDListener(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { String source = jsonNode.get("source").getTextValue(); ContextID contextID = getContextIDFromJsonNode(jsonNode); ContextIDListenerDomain listener = new CommonContextIDListenerDomain(); listener.setSource(source); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.BIND, contextID, listener); - return Message.messageToResponse(generateResponse(answerJob, "")); + return generateResponse(answerJob, ""); } - @POST - @Path("onBindKeyListener") - public Response onBindKeyListener(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + + @RequestMapping(path = "onBindKeyListener",method = RequestMethod.POST) + public Message onBindKeyListener(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { String source = jsonNode.get("source").getTextValue(); ContextID contextID = getContextIDFromJsonNode(jsonNode); ContextKey contextKey = getContextKeyFromJsonNode(jsonNode); CommonContextKeyListenerDomain listener = new CommonContextKeyListenerDomain(); listener.setSource(source); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.BIND, contextID, contextKey, listener); - return Message.messageToResponse(generateResponse(answerJob, "")); + return generateResponse(answerJob, ""); } - @POST - @Path("heartbeat") - public Response heartbeat(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, IOException, CSErrorException { + + @RequestMapping(path = "heartbeat",method = RequestMethod.POST) + public Message heartbeat(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, IOException, CSErrorException { String source = jsonNode.get("source").getTextValue(); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.HEARTBEAT, source); - return Message.messageToResponse(generateResponse(answerJob, "ContextKeyValueBean")); + return generateResponse(answerJob, "ContextKeyValueBean"); } @Override diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextRestfulApi.java index 4840d67a14..bfed226eaf 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextRestfulApi.java @@ -34,25 +34,18 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import java.io.IOException; import java.util.Map; -@Component -@Path("contextservice") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) +@RestController +@RequestMapping(path = "/contextservice") public class ContextRestfulApi implements CsRestfulParent { private static final Logger LOGGER = LoggerFactory.getLogger(ContextRestfulApi.class); @@ -62,100 +55,100 @@ public class ContextRestfulApi implements CsRestfulParent { private ObjectMapper objectMapper = new ObjectMapper(); - @POST - @Path("getContextValue") - public Response getContextValue(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + + @RequestMapping(path = "getContextValue",method = RequestMethod.POST) + public Message getContextValue(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); ContextKey contextKey = getContextKeyFromJsonNode(jsonNode); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.GET, contextID, contextKey); Message message = generateResponse(answerJob, "contextValue"); - return Message.messageToResponse(message); + return message; } - @POST - @Path("searchContextValue") - public Response searchContextValue(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + + @RequestMapping(path = "searchContextValue",method = RequestMethod.POST) + public Message searchContextValue(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); JsonNode condition = jsonNode.get("condition"); Map conditionMap = objectMapper.convertValue(condition, new TypeReference>() { }); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.SEARCH, contextID, conditionMap); Message message = generateResponse(answerJob, "contextKeyValue"); - return Message.messageToResponse(message); + return message; } -/* @GET - @Path("searchContextValueByCondition") - public Response searchContextValueByCondition(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { + /* + @RequestMapping(path = "searchContextValueByCondition",method = RequestMethod.GET) + public Message searchContextValueByCondition(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { Condition condition = null; HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.SEARCH, condition); return generateResponse(answerJob,""); }*/ - @POST - @Path("setValueByKey") - public Response setValueByKey(@Context HttpServletRequest req, JsonNode jsonNode) throws CSErrorException, IOException, ClassNotFoundException, InterruptedException { + + @RequestMapping(path = "setValueByKey",method = RequestMethod.POST) + public Message setValueByKey(HttpServletRequest req, JsonNode jsonNode) throws CSErrorException, IOException, ClassNotFoundException, InterruptedException { ContextID contextID = getContextIDFromJsonNode(jsonNode); ContextKey contextKey = getContextKeyFromJsonNode(jsonNode); ContextValue contextValue = getContextValueFromJsonNode(jsonNode); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.SET, contextID, contextKey, contextValue); - return Message.messageToResponse(generateResponse(answerJob, "")); + return generateResponse(answerJob, ""); } - @POST - @Path("setValue") - public Response setValue(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + + @RequestMapping(path = "setValue",method = RequestMethod.POST) + public Message setValue(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); ContextKeyValue contextKeyValue = getContextKeyValueFromJsonNode(jsonNode); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.SET, contextID, contextKeyValue); - return Message.messageToResponse(generateResponse(answerJob, "")); + return generateResponse(answerJob, ""); } - @POST - @Path("resetValue") - public Response resetValue(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + + @RequestMapping(path = "resetValue",method = RequestMethod.POST) + public Message resetValue(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); ContextKey contextKey = getContextKeyFromJsonNode(jsonNode); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.RESET, contextID, contextKey); - return Message.messageToResponse(generateResponse(answerJob, "")); + return generateResponse(answerJob, ""); } - @POST - @Path("removeValue") - public Response removeValue(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + + @RequestMapping(path = "removeValue",method = RequestMethod.POST) + public Message removeValue(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); ContextKey contextKey = getContextKeyFromJsonNode(jsonNode); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.REMOVE, contextID, contextKey); - return Message.messageToResponse(generateResponse(answerJob, "")); + return generateResponse(answerJob, ""); } - @POST - @Path("removeAllValue") - public Response removeAllValue(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + + @RequestMapping(path = "removeAllValue",method = RequestMethod.POST) + public Message removeAllValue(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.REMOVEALL, contextID); - return Message.messageToResponse(generateResponse(answerJob, "")); + return generateResponse(answerJob, ""); } - @POST - @Path("removeAllValueByKeyPrefixAndContextType") - public Response removeAllValueByKeyPrefixAndContextType(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + + @RequestMapping(path = "removeAllValueByKeyPrefixAndContextType",method = RequestMethod.POST) + public Message removeAllValueByKeyPrefixAndContextType(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); String contextType = jsonNode.get(ContextHTTPConstant.CONTEXT_KEY_TYPE_STR).getTextValue(); String keyPrefix = jsonNode.get(ContextHTTPConstant.CONTEXT_KEY_PREFIX_STR).getTextValue(); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.REMOVEALL, contextID, ContextType.valueOf(contextType),keyPrefix); - return Message.messageToResponse(generateResponse(answerJob, "")); + return generateResponse(answerJob, ""); } - @POST - @Path("removeAllValueByKeyPrefix") - public Response removeAllValueByKeyPrefix(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + + @RequestMapping(path = "removeAllValueByKeyPrefix",method = RequestMethod.POST) + public Message removeAllValueByKeyPrefix(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); String keyPrefix = jsonNode.get(ContextHTTPConstant.CONTEXT_KEY_PREFIX_STR).getTextValue(); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.REMOVEALL, contextID,keyPrefix); - return Message.messageToResponse(generateResponse(answerJob, "")); + return generateResponse(answerJob, ""); } @Override diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/HelloRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/HelloRestfulApi.java index b964bfb8e5..eedb629f77 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/HelloRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/HelloRestfulApi.java @@ -17,27 +17,20 @@ package com.webank.wedatasphere.linkis.cs.server.restful; import com.webank.wedatasphere.linkis.server.Message; -import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -@Component -@Path("/contextservice") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) +@RestController +@RequestMapping(path = "/contextservice") public class HelloRestfulApi { - @GET - @Path("hello") - public Response getContextID(@Context HttpServletRequest req, String id) throws InterruptedException { - return Message.messageToResponse(Message.ok()); + + @RequestMapping(path = "hello",method = RequestMethod.GET) + public Message getContextID(HttpServletRequest req, String id) throws InterruptedException { + return Message.ok(); } } diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextHistoryRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextHistoryRestfulApi.java index 87d1365ed8..b99f356af0 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextHistoryRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextHistoryRestfulApi.java @@ -26,29 +26,26 @@ import com.webank.wedatasphere.linkis.cs.server.enumeration.ServiceType; import com.webank.wedatasphere.linkis.cs.server.scheduler.CsScheduler; import com.webank.wedatasphere.linkis.cs.server.scheduler.HttpAnswerJob; +import com.webank.wedatasphere.linkis.server.Message; import org.codehaus.jackson.JsonNode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -@Component -@Path("/contextservice") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) +@RestController +@RequestMapping(path = "/contextservice") public class ContextHistoryRestfulApi implements CsRestfulParent { @Autowired private CsScheduler csScheduler; - @POST - @Path("createHistory") - public Response createHistory(@Context HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { + @RequestMapping(path = "createHistory",method = RequestMethod.POST) + public Message createHistory(HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { ContextHistory history = new PersistenceContextHistory(); history.setSource("server1:prot1"); history.setContextType(ContextType.METADATA); @@ -66,9 +63,8 @@ public Response createHistory(@Context HttpServletRequest req, JsonNode json) th return generateResponse(answerJob, ""); } - @POST - @Path("removeHistory") - public Response removeHistory(@Context HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { + @RequestMapping(path = "removeHistory",method = RequestMethod.POST) + public Message removeHistory( HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { ContextHistory history = new PersistenceContextHistory(); history.setSource("server1:prot1"); ContextID contextID = new PersistenceContextID(); @@ -85,9 +81,8 @@ public Response removeHistory(@Context HttpServletRequest req, JsonNode json) th } - @GET - @Path("getHistories") - public Response getHistories(@Context HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { + @RequestMapping(path = "getHistories",method = RequestMethod.GET) + public Message getHistories( HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { ContextID contextID = new PersistenceContextID(); contextID.setContextId("84716"); if (StringUtils.isEmpty(contextID.getContextId())) { @@ -97,9 +92,8 @@ public Response getHistories(@Context HttpServletRequest req, JsonNode json) thr return generateResponse(answerJob, ""); } - @GET - @Path("getHistory") - public Response getHistory(@Context HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { + @RequestMapping(path = "getHistory",method = RequestMethod.GET) + public Message getHistory( HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { //ContextID contextID, String source String source = "server1:prot1"; ContextID contextID = new PersistenceContextID(); @@ -115,9 +109,8 @@ public Response getHistory(@Context HttpServletRequest req, JsonNode json) throw return generateResponse(answerJob, ""); } - @GET - @Path("searchHistory") - public Response searchHistory(@Context HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { + @RequestMapping(path = "searchHistory",method = RequestMethod.GET) + public Message searchHistory( HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { //ContextID contextID, String[] keywords ContextID contextID = new PersistenceContextID(); contextID.setContextId("84716"); diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextIDRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextIDRestfulApi.java index 6f20e71eff..1e92562286 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextIDRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextIDRestfulApi.java @@ -23,31 +23,28 @@ import com.webank.wedatasphere.linkis.cs.server.enumeration.ServiceType; import com.webank.wedatasphere.linkis.cs.server.scheduler.CsScheduler; import com.webank.wedatasphere.linkis.cs.server.scheduler.HttpAnswerJob; +import com.webank.wedatasphere.linkis.server.Message; import org.codehaus.jackson.JsonNode; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import java.util.Date; -@Component -@Path("/contextservice") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) +@RestController +@RequestMapping(path = "/contextservice") public class ContextIDRestfulApi implements CsRestfulParent { @Autowired private CsScheduler csScheduler; - @POST - @Path("createContextID") - public Response createContextID(@Context HttpServletRequest req, JsonNode json) throws InterruptedException { + @RequestMapping(path = "createContextID",method = RequestMethod.POST) + public Message createContextID(HttpServletRequest req, JsonNode json) throws InterruptedException { //contextID是client传过来的序列化的id PersistenceContextID contextID = new PersistenceContextID(); contextID.setUser("neiljianliu"); @@ -60,9 +57,8 @@ public Response createContextID(@Context HttpServletRequest req, JsonNode json) return generateResponse(answerJob, "contextId"); } - @GET - @Path("getContextID") - public Response getContextID(@Context HttpServletRequest req, @QueryParam("contextId") String id) throws InterruptedException, CSErrorException { + @RequestMapping(path = "getContextID",method = RequestMethod.GET) + public Message getContextID( HttpServletRequest req, @RequestParam(value="contextId",required=false) String id) throws InterruptedException, CSErrorException { if (StringUtils.isEmpty(id)) { throw new CSErrorException(97000, "contxtId cannot be empty"); } @@ -70,9 +66,8 @@ public Response getContextID(@Context HttpServletRequest req, @QueryParam("conte return generateResponse(answerJob, ""); } - @POST - @Path("updateContextID") - public Response updateContextID(@Context HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { + @RequestMapping(path = "updateContextID",method = RequestMethod.POST) + public Message updateContextID( HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { PersistenceContextID contextID = new PersistenceContextID(); contextID.setUser("johnnwang"); contextID.setExpireType(ExpireType.NEVER); @@ -89,9 +84,8 @@ public Response updateContextID(@Context HttpServletRequest req, JsonNode json) return generateResponse(answerJob, ""); } - @POST - @Path("resetContextID") - public Response resetContextID(@Context HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { + @RequestMapping(path = "resetContextID",method = RequestMethod.POST) + public Message resetContextID( HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { String id = null; if (StringUtils.isEmpty(id)) { throw new CSErrorException(97000, "contxtId cannot be empty"); @@ -101,9 +95,8 @@ public Response resetContextID(@Context HttpServletRequest req, JsonNode json) t } - @POST - @Path("removeContextID") - public Response removeContextID(@Context HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { + @RequestMapping(path = "removeContextID",method = RequestMethod.POST) + public Message removeContextID( HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { String id = json.get("contextId").getTextValue(); if (StringUtils.isEmpty(id)) { throw new CSErrorException(97000, "contxtId cannot be empty"); diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextListenerRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextListenerRestfulApi.java index 734d69c973..78c1fb7716 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextListenerRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextListenerRestfulApi.java @@ -24,31 +24,25 @@ import com.webank.wedatasphere.linkis.cs.server.enumeration.ServiceType; import com.webank.wedatasphere.linkis.cs.server.scheduler.CsScheduler; import com.webank.wedatasphere.linkis.cs.server.scheduler.HttpAnswerJob; +import com.webank.wedatasphere.linkis.server.Message; import org.codehaus.jackson.JsonNode; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -@Component -@Path("/contextservice") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) + +@RestController +@RequestMapping(path = "/contextservice") public class ContextListenerRestfulApi implements CsRestfulParent { @Autowired private CsScheduler csScheduler; - @POST - @Path("onBindIDListener") - public Response onBindIDListener(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { + @RequestMapping(path = "onBindIDListener",method = RequestMethod.POST) + public Message onBindIDListener(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { //ContextIDListener listener ContextIDListener listener = null; ContextID contextID = null; @@ -56,9 +50,8 @@ public Response onBindIDListener(@Context HttpServletRequest req, JsonNode jsonN return generateResponse(answerJob, ""); } - @POST - @Path("onBindKeyListener") - public Response onBindKeyListener(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { + @RequestMapping(path = "onBindKeyListener",method = RequestMethod.POST) + public Message onBindKeyListener( HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { ContextKeyListener listener = null; ContextID contextID = null; ContextKey contextKey = null; @@ -66,9 +59,8 @@ public Response onBindKeyListener(@Context HttpServletRequest req, JsonNode json return generateResponse(answerJob, ""); } - @POST - @Path("heartbeat") - public Response heartbeat(@Context HttpServletRequest req) throws InterruptedException { + @RequestMapping(path = "heartbeat",method = RequestMethod.POST) + public Message heartbeat( HttpServletRequest req) throws InterruptedException { String source = null; HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.HEARTBEAT, source); return generateResponse(answerJob, ""); diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextRestfulApi.java index 8d74f1b397..fed23f1975 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextRestfulApi.java @@ -25,28 +25,22 @@ import com.webank.wedatasphere.linkis.cs.server.enumeration.ServiceType; import com.webank.wedatasphere.linkis.cs.server.scheduler.CsScheduler; import com.webank.wedatasphere.linkis.cs.server.scheduler.HttpAnswerJob; +import com.webank.wedatasphere.linkis.server.Message; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import java.util.Map; -@Component -@Path("contextservice") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) +@RestController +@RequestMapping(path = "/contextservice") public class ContextRestfulApi implements CsRestfulParent { @@ -56,9 +50,8 @@ public class ContextRestfulApi implements CsRestfulParent { private CsScheduler csScheduler; private ObjectMapper objectMapper = new ObjectMapper(); - @POST - @Path("createContext") - public Response createContext(@Context HttpServletRequest request) throws Exception{ + @RequestMapping(path = "createContext",method = RequestMethod.POST) + public Message createContext(HttpServletRequest request) throws Exception{ //request.getAuthType() // if (null == jsonNode.get(ContextHTTPConstant.PROJECT_NAME_STR) || null == jsonNode.get(ContextHTTPConstant.FLOW_NAME_STR)){ @@ -74,9 +67,8 @@ public Response createContext(@Context HttpServletRequest request) throws Except } - @POST - @Path("getContextValue") - public Response getContextValue(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { + @RequestMapping(path = "getContextValue",method = RequestMethod.POST) + public Message getContextValue( HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { //ContextID contextID, ContextKey contextKey ContextID contextID = new PersistenceContextID(); contextID.setContextId("84716"); @@ -105,9 +97,8 @@ public Response getContextValue(@Context HttpServletRequest req, JsonNode jsonNo } } }*/ - @POST - @Path("searchContextValue") - public Response searchContextValue(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { + @RequestMapping(path = "searchContextValue",method = RequestMethod.POST) + public Message searchContextValue( HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { ContextID contextID = objectMapper.convertValue(jsonNode.get("contextID"), PersistenceContextID.class); Map conditionMap = objectMapper.convertValue(jsonNode.get("condition"), new org.codehaus.jackson.type.TypeReference>() { }); @@ -115,18 +106,16 @@ public Response searchContextValue(@Context HttpServletRequest req, JsonNode jso return generateResponse(answerJob, ""); } -/* @GET - @Path("searchContextValueByCondition") - public Response searchContextValueByCondition(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { +/* @RequestMapping(path = "searchContextValueByCondition",method = RequestMethod.GET) + public Message searchContextValueByCondition( HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { Condition condition = null; HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.SEARCH, condition); return generateResponse(answerJob,""); }*/ - @POST - @Path("setValueByKey") - public Response setValueByKey(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException { + @RequestMapping(path = "setValueByKey",method = RequestMethod.POST) + public Message setValueByKey( HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException { /*JSONSerializer jsonSerializer = new JSONSerializer(); PersistenceContextID contextID = new PersistenceContextID(); //// TODO: 2020/2/26 手动修改contextid @@ -148,9 +137,8 @@ public Response setValueByKey(@Context HttpServletRequest req, JsonNode jsonNode return null; } - @POST - @Path("setValue") - public Response setValue(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException { + @RequestMapping(path = "setValue",method = RequestMethod.POST) + public Message setValue( HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException { /*JSONSerializer jsonSerializer = new JSONSerializer(); PersistenceContextID contextID = new PersistenceContextID(); //// TODO: 2020/2/26 手动修改contextid @@ -176,18 +164,16 @@ public Response setValue(@Context HttpServletRequest req, JsonNode jsonNode) thr return null; } - @POST - @Path("resetValue") - public Response resetValue(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { + @RequestMapping(path = "resetValue",method = RequestMethod.POST) + public Message resetValue( HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { ContextID contextID = null; ContextKey contextKey = null; HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.RESET, contextID, contextKey); return generateResponse(answerJob,""); } - @POST - @Path("removeValue") - public Response removeValue(@Context HttpServletRequest req,JsonNode jsonNode) throws InterruptedException { + @RequestMapping(path = "removeValue",method = RequestMethod.POST) + public Message removeValue( HttpServletRequest req,JsonNode jsonNode) throws InterruptedException { ContextID contextID = new PersistenceContextID(); contextID.setContextId("84716"); ContextKey contextKey = new PersistenceContextKey(); @@ -196,9 +182,8 @@ public Response removeValue(@Context HttpServletRequest req,JsonNode jsonNode) t return generateResponse(answerJob,""); } - @POST - @Path("removeAllValue") - public Response removeAllValue(@Context HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { + @RequestMapping(path = "removeAllValue",method = RequestMethod.POST) + public Message removeAllValue( HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { ContextID contextID = new PersistenceContextID(); contextID.setContextId("84716"); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.REMOVEALL, contextID); diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/CsRestfulParent.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/CsRestfulParent.java index e2c5f3e4c7..9c75807b79 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/CsRestfulParent.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/CsRestfulParent.java @@ -28,7 +28,6 @@ import com.webank.wedatasphere.linkis.server.security.SecurityFilter; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.Response; public interface CsRestfulParent { @@ -44,25 +43,25 @@ default HttpAnswerJob submitRestJob(HttpServletRequest req, return job; } - default Response generateResponse(HttpAnswerJob job, String responseKey) { + default Message generateResponse(HttpAnswerJob job, String responseKey) { HttpResponseProtocol responseProtocol = job.getResponseProtocol(); if (responseProtocol instanceof RestResponseProtocol) { Message message = ((RestResponseProtocol) responseProtocol).get(); if (message == null) { - return Message.messageToResponse(Message.error("job execute timeout")); + return Message.error("job execute timeout"); } int status = ((RestResponseProtocol) responseProtocol).get().getStatus(); if (status == 1) { //failed - return Message.messageToResponse(((RestResponseProtocol) responseProtocol).get()); + return ((RestResponseProtocol) responseProtocol).get(); } else if (status == 0) { Object data = job.getResponseProtocol().getResponseData(); - return Message.messageToResponse(Message.ok().data(responseKey, data)); + return Message.ok().data(responseKey, data); } else { } } - return Message.messageToResponse(Message.ok()); + return Message.ok(); } ServiceType getServiceType(); From add5cd52cca009a9865fbd23304447b2e67fca06 Mon Sep 17 00:00:00 2001 From: casionone Date: Sat, 18 Sep 2021 20:10:54 +0800 Subject: [PATCH 03/29] [linkis-configuration] replace jersey with spring web --- .../restful/api/ConfigurationRestfulApi.java | 116 ++++++++---------- .../restful/api/VariableRestfulApi.java | 42 +++---- 2 files changed, 68 insertions(+), 90 deletions(-) diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/java/com/webank/wedatasphere/linkis/configuration/restful/api/ConfigurationRestfulApi.java b/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/java/com/webank/wedatasphere/linkis/configuration/restful/api/ConfigurationRestfulApi.java index 128d2b745d..967b6a94f6 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/java/com/webank/wedatasphere/linkis/configuration/restful/api/ConfigurationRestfulApi.java +++ b/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/java/com/webank/wedatasphere/linkis/configuration/restful/api/ConfigurationRestfulApi.java @@ -32,24 +32,20 @@ import com.webank.wedatasphere.linkis.server.security.SecurityFilter; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; -import org.json4s.jackson.Json; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import java.io.IOException; import java.util.ArrayList; import java.util.List; -@Component -@Path("/configuration") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) +@RestController +@RequestMapping(path = "/configuration") public class ConfigurationRestfulApi { @Autowired @@ -62,13 +58,12 @@ public class ConfigurationRestfulApi { private static final String NULL = "null"; - @GET - @Path("/addKeyForEngine") - public Response addKeyForEngine(@Context HttpServletRequest req, - @QueryParam("engineType") String engineType, - @QueryParam("version") String version, - @QueryParam("token") String token, - @QueryParam("keyJson") String keyJson) throws ConfigurationException { + @RequestMapping(path = "/addKeyForEngine",method = RequestMethod.GET) + public Message addKeyForEngine(HttpServletRequest req, + @RequestParam(value="engineType",required=false) String engineType, + @RequestParam(value="version",required=false) String version, + @RequestParam(value="token",required=false) String token, + @RequestParam(value="keyJson",required=false) String keyJson) throws ConfigurationException { String username = SecurityFilter.getLoginUsername(req); if(StringUtils.isEmpty(engineType) || StringUtils.isEmpty(version) || StringUtils.isEmpty(token)){ throw new ConfigurationException("params cannot be empty!"); @@ -80,7 +75,7 @@ public Response addKeyForEngine(@Context HttpServletRequest req, ConfigKey configKey = BDPJettyServerHelper.gson().fromJson(keyJson, ConfigKey.class); configurationService.addKeyForEngine(engineType,version,configKey); // TODO: 2019/12/30 configKey参数校验 - return Message.messageToResponse(Message.ok()); + return Message.ok(); } @@ -88,11 +83,11 @@ public Response addKeyForEngine(@Context HttpServletRequest req, // @GET // @Path("/addKeyForCreator") -// public Response addKeyForCreator(@Context HttpServletRequest req, -// @QueryParam("engineType") String engineType, -// @QueryParam("creator") String creator, -// @QueryParam("token") String token, -// @QueryParam("keyJson") String keyJson) throws ConfigurationException { +// public Message addKeyForCreator(HttpServletRequest req, +// @RequestParam(value="engineType",required=false) String engineType, +// @RequestParam(value="creator",required=false) String creator, +// @RequestParam(value="token",required=false) String token, +// @RequestParam(value="keyJson",required=false) String keyJson) throws ConfigurationException { // String username = SecurityFilter.getLoginUsername(req); // if(StringUtils.isEmpty(engineType) || StringUtils.isEmpty(creator) || StringUtils.isEmpty(token)){ // throw new ConfigurationException("params cannot be empty!"); @@ -109,7 +104,7 @@ public Response addKeyForEngine(@Context HttpServletRequest req, // ConfigKey configKey = BDPJettyServerHelper.gson().fromJson(keyJson, ConfigKey.class); // // TODO: 2019/12/30 configKey参数校验 // configurationService.addKey(creator,engineType,configKey); -// return Message.messageToResponse(Message.ok()); +// return Message.ok(); // } @@ -118,10 +113,10 @@ public Response addKeyForEngine(@Context HttpServletRequest req, // @GET // @Path("/copyKeyFromIDE") -// public Response copyKeyFromIDE(@Context HttpServletRequest req, -// @QueryParam("appName") String appName, -// @QueryParam("creator") String creator, -// @QueryParam("token") String token) throws ConfigurationException { +// public Message copyKeyFromIDE(HttpServletRequest req, +// @RequestParam(value="appName",required=false) String appName, +// @RequestParam(value="creator",required=false) String creator, +// @RequestParam(value="token",required=false) String token) throws ConfigurationException { // String username = SecurityFilter.getLoginUsername(req); // if(StringUtils.isEmpty(appName) || StringUtils.isEmpty(creator) || StringUtils.isEmpty(token)){ // throw new ConfigurationException("params cannot be empty!"); @@ -140,12 +135,11 @@ public Response addKeyForEngine(@Context HttpServletRequest req, // throw new ConfigurationException("IDE:"+ appName + ",cannot find any key to copy"); // } // IDEkeys.forEach(k ->configurationService.copyKeyFromIDE(k,creator,appName)); -// return Message.messageToResponse(Message.ok()); +// return Message.ok(); // } - @GET - @Path("/getFullTreesByAppName") - public Response getFullTreesByAppName(@Context HttpServletRequest req, @QueryParam("engineType") String engineType, @QueryParam("version") String version, @QueryParam("creator") String creator) throws ConfigurationException { + @RequestMapping(path = "/getFullTreesByAppName",method = RequestMethod.GET) + public Message getFullTreesByAppName(HttpServletRequest req, @RequestParam(value="engineType",required=false) String engineType, @RequestParam(value="version",required=false) String version, @RequestParam(value="creator",required=false) String creator) throws ConfigurationException { String username = SecurityFilter.getLoginUsername(req); if(creator != null && (creator.equals("通用设置") || creator.equals("全局设置"))){ engineType = "*"; @@ -154,20 +148,18 @@ public Response getFullTreesByAppName(@Context HttpServletRequest req, @QueryPar } List labelList = LabelEntityParser.generateUserCreatorEngineTypeLabelList(username, creator, engineType, version); ArrayList configTrees = configurationService.getFullTreeByLabelList(labelList,true); - return Message.messageToResponse(Message.ok().data("fullTree", configTrees)); + return Message.ok().data("fullTree", configTrees); } - @GET - @Path("/getCategory") - public Response getCategory(@Context HttpServletRequest req){ + @RequestMapping(path = "/getCategory",method = RequestMethod.GET) + public Message getCategory(HttpServletRequest req){ String username = SecurityFilter.getLoginUsername(req); List categoryLabelList = categoryService.getAllCategory(); - return Message.messageToResponse(Message.ok().data("Category", categoryLabelList)); + return Message.ok().data("Category", categoryLabelList); } - @POST - @Path("/createFirstCategory") - public Response createFirstCategory(@Context HttpServletRequest request, JsonNode jsonNode) throws ConfigurationException { + @RequestMapping(path = "/createFirstCategory",method = RequestMethod.POST) + public Message createFirstCategory(HttpServletRequest request, JsonNode jsonNode) throws ConfigurationException { String username = SecurityFilter.getLoginUsername(request); String categoryName = jsonNode.get("categoryName").asText(); String description = jsonNode.get("description").asText(); @@ -175,22 +167,20 @@ public Response createFirstCategory(@Context HttpServletRequest request, JsonNod throw new ConfigurationException("categoryName is null, cannot be added"); } categoryService.createFirstCategory(categoryName, description); - return Message.messageToResponse(Message.ok()); + return Message.ok(); } - @POST - @Path("/deleteCategory") - public Response deleteCategory(@Context HttpServletRequest request, JsonNode jsonNode){ + @RequestMapping(path = "/deleteCategory",method = RequestMethod.POST) + public Message deleteCategory(HttpServletRequest request, JsonNode jsonNode){ String username = SecurityFilter.getLoginUsername(request); Integer categoryId = jsonNode.get("categoryId").asInt(); categoryService.deleteCategory(categoryId); - return Message.messageToResponse(Message.ok()); + return Message.ok(); } - @POST - @Path("/createSecondCategory") - public Response createSecondCategory(@Context HttpServletRequest request, JsonNode jsonNode) throws ConfigurationException { + @RequestMapping(path = "/createSecondCategory",method = RequestMethod.POST) + public Message createSecondCategory(HttpServletRequest request, JsonNode jsonNode) throws ConfigurationException { String username = SecurityFilter.getLoginUsername(request); Integer categoryId = jsonNode.get("categoryId").asInt(); String engineType = jsonNode.get("engineType").asText(); @@ -206,13 +196,12 @@ public Response createSecondCategory(@Context HttpServletRequest request, JsonNo version = LabelUtils.COMMON_VALUE; } categoryService.createSecondCategory(categoryId, engineType, version, description); - return Message.messageToResponse(Message.ok()); + return Message.ok(); } - @POST - @Path("/saveFullTree") - public Response saveFullTree(@Context HttpServletRequest req, JsonNode json) throws IOException, ConfigurationException { + @RequestMapping(path = "/saveFullTree",method = RequestMethod.POST) + public Message saveFullTree(HttpServletRequest req, JsonNode json) throws IOException, ConfigurationException { List fullTrees = mapper.readValue(json.get("fullTree"), List.class); String creator = JsonNodeUtil.getStringValue(json.get("creator")); String engineType = JsonNodeUtil.getStringValue(json.get("engineType")); @@ -244,19 +233,17 @@ public Response saveFullTree(@Context HttpServletRequest req, JsonNode json) thr configurationService.updateUserValue(createList, updateList); configurationService.clearAMCacheConf(username,creator,engine,version); Message message = Message.ok(); - return Message.messageToResponse(message); + return message; } - @GET - @Path("/engineType") - public Response listAllEngineType(@Context HttpServletRequest request){ + @RequestMapping(path = "/engineType",method = RequestMethod.GET) + public Message listAllEngineType(HttpServletRequest request){ String[] engineType = configurationService.listAllEngineType(); - return Message.messageToResponse(Message.ok().data("engineType",engineType)); + return Message.ok().data("engineType",engineType); } - @POST - @Path("/updateCategoryInfo") - public Response updateCategoryInfo(@Context HttpServletRequest request, JsonNode jsonNode) throws ConfigurationException { + @RequestMapping(path = "/updateCategoryInfo",method = RequestMethod.POST) + public Message updateCategoryInfo(HttpServletRequest request, JsonNode jsonNode) throws ConfigurationException { String username = SecurityFilter.getLoginUsername(request); String description = null; Integer categoryId = null; @@ -269,12 +256,11 @@ public Response updateCategoryInfo(@Context HttpServletRequest request, JsonNode if(description != null){ categoryService.updateCategory(categoryId, description); } - return Message.messageToResponse(Message.ok()); + return Message.ok(); } - @GET - @Path("/rpcTest") - public Response rpcTest(@QueryParam("username") String username, @QueryParam("creator") String creator, @QueryParam("engineType") String engineType,@QueryParam("version") String version){ + @RequestMapping(path = "/rpcTest",method = RequestMethod.GET) + public Message rpcTest(@RequestParam(value="username",required=false) String username, @RequestParam(value="creator",required=false) String creator, @RequestParam(value="engineType",required=false) String engineType,@RequestParam(value="version",required=false) String version){ configurationService.queryGlobalConfig(username); EngineTypeLabel engineTypeLabel = new EngineTypeLabel(); engineTypeLabel.setVersion(version); @@ -285,7 +271,7 @@ public Response rpcTest(@QueryParam("username") String username, @QueryParam("cr userCreatorLabel.setUser(username); configurationService.queryConfig(userCreatorLabel,engineTypeLabel,"wds.linkis.rm"); Message message = Message.ok(); - return Message.messageToResponse(message); + return message; } } diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-variable/src/main/java/com/webank/wedatasphere/linkis/variable/restful/api/VariableRestfulApi.java b/linkis-public-enhancements/linkis-publicservice/linkis-variable/src/main/java/com/webank/wedatasphere/linkis/variable/restful/api/VariableRestfulApi.java index 3c6faa55ae..552a77839b 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-variable/src/main/java/com/webank/wedatasphere/linkis/variable/restful/api/VariableRestfulApi.java +++ b/linkis-public-enhancements/linkis-publicservice/linkis-variable/src/main/java/com/webank/wedatasphere/linkis/variable/restful/api/VariableRestfulApi.java @@ -26,21 +26,17 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import java.io.IOException; import java.util.List; -@Component -@Path("/variable") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) +@RestController +@RequestMapping(path = "/variable") public class VariableRestfulApi { @Autowired @@ -50,42 +46,38 @@ public class VariableRestfulApi { private Logger logger = LoggerFactory.getLogger(this.getClass()); - /*@POST - @Path("addGlobalVariable") - public Response addGlobalVariable(@Context HttpServletRequest req, JsonNode json) throws IOException { + /*@RequestMapping(path = "addGlobalVariable",method = RequestMethod.POST) + public Message addGlobalVariable(HttpServletRequest req, JsonNode json) throws IOException { String userName = SecurityFilter.getLoginUsername(req); List globalVariables = mapper.readValue(json.get("globalVariables"), List.class); globalVariables.stream().forEach(f -> { String j = BDPJettyServerHelper.gson().toJson(f); variableService.addGlobalVariable(BDPJettyServerHelper.gson().fromJson(j, VarKeyValueVO.class), userName); }); - return Message.messageToResponse(Message.ok()); + return Message.ok(); } - @POST - @Path("removeGlobalVariable") - public Response removeGlobalVariable(@Context HttpServletRequest req, JsonNode json) { + @RequestMapping(path = "removeGlobalVariable",method = RequestMethod.POST) + public Message removeGlobalVariable(HttpServletRequest req, JsonNode json) { String userName = SecurityFilter.getLoginUsername(req); Long keyID = json.get("keyID").getLongValue(); variableService.removeGlobalVariable(keyID); - return Message.messageToResponse(Message.ok()); + return Message.ok(); }*/ - @GET - @Path("listGlobalVariable") - public Response listGlobalVariable(@Context HttpServletRequest req) { + @RequestMapping(path = "listGlobalVariable",method = RequestMethod.GET) + public Message listGlobalVariable(HttpServletRequest req) { String userName = SecurityFilter.getLoginUsername(req); List kvs = variableService.listGlobalVariable(userName); - return Message.messageToResponse(Message.ok().data("globalVariables", kvs)); + return Message.ok().data("globalVariables", kvs); } - @POST - @Path("saveGlobalVariable") - public Response saveGlobalVariable(@Context HttpServletRequest req, JsonNode json) throws IOException, VariableException { + @RequestMapping(path = "saveGlobalVariable",method = RequestMethod.POST) + public Message saveGlobalVariable(HttpServletRequest req, JsonNode json) throws IOException, VariableException { String userName = SecurityFilter.getLoginUsername(req); List userVariables = variableService.listGlobalVariable(userName); List globalVariables = mapper.readValue(json.get("globalVariables"), List.class); variableService.saveGlobalVaraibles(globalVariables, userVariables, userName); - return Message.messageToResponse(Message.ok()); + return Message.ok(); } } From c8c0dc3506fdc0fb2ce1c985a3e923b1488c8ec2 Mon Sep 17 00:00:00 2001 From: casionone Date: Sat, 18 Sep 2021 20:11:39 +0800 Subject: [PATCH 04/29] [linkis-entrance] replace jersey with spring web --- .../entrance/restful/EntranceRestfulApi.java | 102 ++++++-------- .../restful/EntranceRestfulRemote.scala | 128 +++++++++--------- 2 files changed, 108 insertions(+), 122 deletions(-) diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java b/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java index 0a25a10fd7..b32ed34c0e 100644 --- a/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java +++ b/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java @@ -38,24 +38,18 @@ import org.codehaus.jackson.JsonNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.*; import scala.Option; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import java.util.*; /** * Description: an implementation class of EntranceRestfulRemote */ -@Path("/entrance") -@Component -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) -public class EntranceRestfulApi implements EntranceRestfulRemote { +@RestController +@RequestMapping(path = "/entrance") +public class EntranceRestfulApi{ private EntranceServer entranceServer; @@ -72,10 +66,9 @@ public void setEntranceServer(EntranceServer entranceServer) { * json Incoming key-value pair(传入的键值对) * Repsonse */ - @Override - @POST - @Path("/execute") - public Response execute(@Context HttpServletRequest req, Map json) { + + @RequestMapping(path = "/execute",method = RequestMethod.POST) + public Message execute(HttpServletRequest req, Map json) { Message message = null; // try{ logger.info("Begin to get an execID"); @@ -107,14 +100,13 @@ public Response execute(@Context HttpServletRequest req, Map jso // message.setStatus(1); // message.setMethod("/api/entrance/execute"); // } - return Message.messageToResponse(message); + return message; } - @Override - @POST - @Path("/submit") - public Response submit(@Context HttpServletRequest req, Map json) { + + @RequestMapping(path = "/submit",method = RequestMethod.POST) + public Message submit(HttpServletRequest req, Map json) { Message message = null; logger.info("Begin to get an execID"); json.put(TaskConstant.SUBMIT_USER, SecurityFilter.getLoginUsername(req)); @@ -140,17 +132,16 @@ public Response submit(@Context HttpServletRequest req, Map json message.data("execID", execID); message.data("taskID", taskID); logger.info("End to get an an execID: {}, taskID: {}", execID, taskID); - return Message.messageToResponse(message); + return message; } private void pushLog(String log, Job job) { entranceServer.getEntranceContext().getOrCreateLogManager().onLogUpdate(job, log); } - @Override - @GET - @Path("/{id}/status") - public Response status(@PathParam("id") String id, @QueryParam("taskID") String taskID) { + + @RequestMapping(path = "/{id}/status",method = RequestMethod.GET) + public Message status(@PathVariable("id") String id, @RequestParam(value = "taskID",required = false) String taskID) { Message message = null; String realId = ZuulEntranceUtils.parseExecID(id)[3]; Option job = Option.apply(null); @@ -163,7 +154,7 @@ public Response status(@PathParam("id") String id, @QueryParam("taskID") String message = Message.ok(); message.setMethod("/api/entrance/" + id + "/status"); message.data("status", status).data("execID", id); - return Message.messageToResponse(message); + return message; } if (job.isDefined()) { message = Message.ok(); @@ -172,16 +163,15 @@ public Response status(@PathParam("id") String id, @QueryParam("taskID") String } else { message = Message.error("ID The corresponding job is empty and cannot obtain the corresponding task status.(ID 对应的job为空,不能获取相应的任务状态)"); } - return Message.messageToResponse(message); + return message; } - @Override - @GET - @Path("/{id}/progress") - public Response progress(@PathParam("id") String id) { + + @RequestMapping(path = "/{id}/progress",method = RequestMethod.GET) + public Message progress(@PathVariable("id") String id) { Message message = null; String realId = ZuulEntranceUtils.parseExecID(id)[3]; Option job = entranceServer.getJob(realId); @@ -219,13 +209,12 @@ public Response progress(@PathParam("id") String id) { } else { message = Message.error("The job corresponding to the ID is empty, and the corresponding task progress cannot be obtained.(ID 对应的job为空,不能获取相应的任务进度)"); } - return Message.messageToResponse(message); + return message; } - @Override - @GET - @Path("/{id}/log") - public Response log(@Context HttpServletRequest req, @PathParam("id") String id) { + + @RequestMapping(path = "/{id}/log",method = RequestMethod.GET) + public Message log(HttpServletRequest req, @PathVariable("id") String id) { String realId = ZuulEntranceUtils.parseExecID(id)[3]; Option job = Option.apply(null); Message message = null; @@ -234,7 +223,7 @@ public Response log(@Context HttpServletRequest req, @PathParam("id") String id) } catch (final Throwable t) { message = Message.error("The job you just executed has ended. This interface no longer provides a query. It is recommended that you download the log file for viewing.(您刚刚执行的job已经结束,本接口不再提供查询,建议您下载日志文件进行查看)"); message.setMethod("/api/entrance/" + id + "/log"); - return Message.messageToResponse(message); + return message; } if (job.isDefined()) { logger.debug("begin to get log for {}(开始获取 {} 的日志)", job.get().getId(),job.get().getId()); @@ -279,13 +268,13 @@ public Response log(@Context HttpServletRequest req, @PathParam("id") String id) message = Message.ok(); message.setMethod("/api/entrance/" + id + "/log"); message.data("log", "").data("execID", id).data("fromLine", retFromLine + fromLine); - return Message.messageToResponse(message); + return message; } catch (final Exception e1) { logger.debug("Failed to get log information for :{}(为 {} 获取日志失败)", job.get().getId(), job.get().getId(),e1); message = Message.error("Failed to get log information(获取日志信息失败)"); message.setMethod("/api/entrance/" + id + "/log"); message.data("log", "").data("execID", id).data("fromLine", retFromLine + fromLine); - return Message.messageToResponse(message); + return message; } finally { if (null != logReader && job.get().isCompleted()) { IOUtils.closeQuietly(logReader); @@ -299,21 +288,20 @@ public Response log(@Context HttpServletRequest req, @PathParam("id") String id) message = Message.error("Can't find execID(不能找到execID): " + id + "Corresponding job, can not get the corresponding log(对应的job,不能获得对应的日志)"); message.setMethod("/api/entrance/" + id + "/log"); } - return Message.messageToResponse(message); + return message; } - @Override - @POST - @Path("/{id}/killJobs") - public Response killJobs(@Context HttpServletRequest req, JsonNode jsonNode, @PathParam("id") String strongExecId) { + + @RequestMapping(path = "/{id}/killJobs",method = RequestMethod.POST) + public Message killJobs(HttpServletRequest req, JsonNode jsonNode, @PathVariable("id") String strongExecId) { JsonNode idNode = jsonNode.get("idList"); JsonNode taskIDNode = jsonNode.get("taskIDList"); ArrayList waitToForceKill = new ArrayList<>(); if(idNode.size() != taskIDNode.size()){ - return Message.messageToResponse(Message.error("The length of the ID list does not match the length of the TASKID list(id列表的长度与taskId列表的长度不一致)")); + return Message.error("The length of the ID list does not match the length of the TASKID list(id列表的长度与taskId列表的长度不一致)"); } if(!idNode.isArray() || !taskIDNode.isArray()){ - return Message.messageToResponse(Message.error("Request parameter error, please use array(请求参数错误,请使用数组)")); + return Message.error("Request parameter error, please use array(请求参数错误,请使用数组)"); } ArrayList messages = new ArrayList<>(); for(int i = 0; i < idNode.size(); i++){ @@ -375,13 +363,12 @@ public Response killJobs(@Context HttpServletRequest req, JsonNode jsonNode, @Pa if(!waitToForceKill.isEmpty()){ JobHistoryHelper.forceBatchKill(waitToForceKill); } - return Message.messageToResponse(Message.ok("停止任务成功").data("messages", messages)); + return Message.ok("停止任务成功").data("messages", messages); } - @Override - @GET - @Path("/{id}/kill") - public Response kill(@PathParam("id") String id, @QueryParam("taskID") long taskID) { + + @RequestMapping(path = "/{id}/kill",method = RequestMethod.GET) + public Message kill(@PathVariable("id") String id, @RequestParam(value = "taskID",required = false) long taskID) { String realId = ZuulEntranceUtils.parseExecID(id)[3]; //通过jobid获取job,可能会由于job找不到而导致有looparray的报错,一旦报错的话,就可以将该任务直接置为Cancenlled Option job = Option.apply(null); @@ -394,7 +381,7 @@ public Response kill(@PathParam("id") String id, @QueryParam("taskID") long task Message message = Message.ok("Forced Kill task (强制杀死任务)"); message.setMethod("/api/entrance/" + id + "/kill"); message.setStatus(0); - return Message.messageToResponse(message); + return message; } Message message = null; if (job.isEmpty()) { @@ -404,7 +391,7 @@ public Response kill(@PathParam("id") String id, @QueryParam("taskID") long task message = Message.ok("Forced Kill task (强制杀死任务)"); message.setMethod("/api/entrance/" + id + "/kill"); message.setStatus(0); - return Message.messageToResponse(message); + return message; } else { try { logger.info("begin to kill job {} ", job.get().getId()); @@ -428,13 +415,12 @@ public Response kill(@PathParam("id") String id, @QueryParam("taskID") long task message.setStatus(1); } } - return Message.messageToResponse(message); + return message; } - @Override - @GET - @Path("/{id}/pause") - public Response pause(@PathParam("id") String id) { + + @RequestMapping(path = "/{id}/pause",method = RequestMethod.GET) + public Message pause(@PathVariable("id") String id) { String realId = ZuulEntranceUtils.parseExecID(id)[3]; Option job = entranceServer.getJob(realId); Message message = null; @@ -460,7 +446,7 @@ public Response pause(@PathParam("id") String id) { } } - return Message.messageToResponse(message); + return message; } } diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulRemote.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulRemote.scala index 676fbe3ecf..9b9262fcf4 100644 --- a/linkis-computation-governance/linkis-entrance/src/main/scala/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulRemote.scala +++ b/linkis-computation-governance/linkis-entrance/src/main/scala/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulRemote.scala @@ -1,64 +1,64 @@ -/* - * Copyright 2019 WeBank - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.webank.wedatasphere.linkis.entrance.restful - -import java.util - -import javax.servlet.http.HttpServletRequest -import javax.ws.rs.QueryParam -import javax.ws.rs.core.{Context, Response} -import org.codehaus.jackson.JsonNode -import org.springframework.web.bind.annotation.{PathVariable, RequestBody, RequestMapping, RequestMethod} - - -trait EntranceRestfulRemote { - - @RequestMapping(value = Array("/entrance/execute"), method = Array(RequestMethod.POST)) - def execute(@Context req: HttpServletRequest, @RequestBody json: util.Map[String, Any]): Response - - @RequestMapping(value = Array("/entrance/submit"), method = Array(RequestMethod.POST)) - def submit(@Context req: HttpServletRequest, @RequestBody json: util.Map[String, Any]): Response - - // @RequestMapping(value = Array("/api/entrance/{id}"), method = Array(RequestMethod.GET)) -// def get(@PathVariable("id") id: String): Response - - @RequestMapping(value = Array("/entrance/{id}/status"), method = Array(RequestMethod.GET)) - def status(@PathVariable("id") id: String, @QueryParam("taskID") taskID:String): Response - - - @RequestMapping(value = Array("/entrance/{id}/progress"), method = Array(RequestMethod.POST)) - def progress(@PathVariable("id") id: String): Response - - //TODO The resultSet interface is provided here, you need to think about it again, temporarily remove it.(resultSet这个接口是否在这里提供,还需再思考一下,先暂时去掉) -// @RequestMapping(value = Array("/api/entrance/{id}/resultSet"), method = Array(RequestMethod.POST)) -// def resultSet(@PathVariable("id") id: String): Response - - @RequestMapping(value = Array("/entrance/{id}/log"), method = Array(RequestMethod.POST)) - def log(@Context req: HttpServletRequest, @PathVariable("id") id: String): Response - - @RequestMapping(value = Array("/entrance/{id}/killJobs"), method = Array(RequestMethod.POST)) - def killJobs(@Context req: HttpServletRequest, jsonNode: JsonNode, @PathVariable("id") id: String): Response - - @RequestMapping(value = Array("/entrance/{id}/kill"), method = Array(RequestMethod.POST)) - def kill(@PathVariable("id") id: String, @QueryParam("taskID") taskID:Long): Response - - @RequestMapping(value = Array("/entrance/{id}/pause"), method = Array(RequestMethod.POST)) - def pause(@PathVariable("id") id: String): Response - - - -} \ No newline at end of file +///* +// * Copyright 2019 WeBank +// * +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ +// +//package com.webank.wedatasphere.linkis.entrance.restful +// +//import java.util +// +//import javax.servlet.http.HttpServletRequest +//import javax.ws.rs.QueryParam +//import javax.ws.rs.core.{Context, Response} +//import org.codehaus.jackson.JsonNode +//import org.springframework.web.bind.annotation.{PathVariable, RequestBody, RequestMapping, RequestMethod} +// +// +//trait EntranceRestfulRemote { +// +// @RequestMapping(value = Array("/entrance/execute"), method = Array(RequestMethod.POST)) +// def execute(@Context req: HttpServletRequest, @RequestBody json: util.Map[String, Any]): Response +// +// @RequestMapping(value = Array("/entrance/submit"), method = Array(RequestMethod.POST)) +// def submit(@Context req: HttpServletRequest, @RequestBody json: util.Map[String, Any]): Response +// +// // @RequestMapping(value = Array("/api/entrance/{id}"), method = Array(RequestMethod.GET)) +//// def get(@PathVariable("id") id: String): Response +// +// @RequestMapping(value = Array("/entrance/{id}/status"), method = Array(RequestMethod.GET)) +// def status(@PathVariable("id") id: String, @QueryParam("taskID") taskID:String): Response +// +// +// @RequestMapping(value = Array("/entrance/{id}/progress"), method = Array(RequestMethod.POST)) +// def progress(@PathVariable("id") id: String): Response +// +// //TODO The resultSet interface is provided here, you need to think about it again, temporarily remove it.(resultSet这个接口是否在这里提供,还需再思考一下,先暂时去掉) +//// @RequestMapping(value = Array("/api/entrance/{id}/resultSet"), method = Array(RequestMethod.POST)) +//// def resultSet(@PathVariable("id") id: String): Response +// +// @RequestMapping(value = Array("/entrance/{id}/log"), method = Array(RequestMethod.POST)) +// def log(@Context req: HttpServletRequest, @PathVariable("id") id: String): Response +// +// @RequestMapping(value = Array("/entrance/{id}/killJobs"), method = Array(RequestMethod.POST)) +// def killJobs(@Context req: HttpServletRequest, jsonNode: JsonNode, @PathVariable("id") id: String): Response +// +// @RequestMapping(value = Array("/entrance/{id}/kill"), method = Array(RequestMethod.POST)) +// def kill(@PathVariable("id") id: String, @QueryParam("taskID") taskID:Long): Response +// +// @RequestMapping(value = Array("/entrance/{id}/pause"), method = Array(RequestMethod.POST)) +// def pause(@PathVariable("id") id: String): Response +// +// +// +//} \ No newline at end of file From e927e749365ffb5a092c6bc558215b1a2064ac97 Mon Sep 17 00:00:00 2001 From: casionone Date: Sat, 18 Sep 2021 20:12:23 +0800 Subject: [PATCH 05/29] [linkis-error-code-server] replace jersey with spring web --- .../restful/LinkisErrorCodeRestful.java | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-error-code/linkis-error-code-server/src/main/java/com/webank/wedatasphere/linkis/errorcode/server/restful/LinkisErrorCodeRestful.java b/linkis-public-enhancements/linkis-publicservice/linkis-error-code/linkis-error-code-server/src/main/java/com/webank/wedatasphere/linkis/errorcode/server/restful/LinkisErrorCodeRestful.java index 4fa40164ab..fbe23f3acb 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-error-code/linkis-error-code-server/src/main/java/com/webank/wedatasphere/linkis/errorcode/server/restful/LinkisErrorCodeRestful.java +++ b/linkis-public-enhancements/linkis-publicservice/linkis-error-code/linkis-error-code-server/src/main/java/com/webank/wedatasphere/linkis/errorcode/server/restful/LinkisErrorCodeRestful.java @@ -20,35 +20,26 @@ import com.webank.wedatasphere.linkis.errorcode.server.service.LinkisErrorCodeService; import com.webank.wedatasphere.linkis.server.Message; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.Consumes; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import java.util.List; - -@Path("/errorcode") -@Component -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) +@RestController +@RequestMapping(path = "/errorcode") public class LinkisErrorCodeRestful { @Autowired private LinkisErrorCodeService linkisErrorCodeService; - @GET - @Path(CommonConf.GET_ERRORCODE_URL) - public Response getErrorCodes(@Context HttpServletRequest request){ + @RequestMapping(path = CommonConf.GET_ERRORCODE_URL,method = RequestMethod.GET) + public Message getErrorCodes(HttpServletRequest request){ List errorCodes = linkisErrorCodeService.getAllErrorCodes(); Message message = Message.ok(); message.data("errorCodes", errorCodes); - return Message.messageToResponse(message); + return message; } } From 3d1b5e17dfd537e7ffd3715fa09ca5a47b64f54b Mon Sep 17 00:00:00 2001 From: casionone Date: Sat, 18 Sep 2021 20:13:11 +0800 Subject: [PATCH 06/29] [linkis-instance-label-server] replace jersey with spring web --- .../label/restful/InstanceRestful.java | 46 ++++++++----------- 1 file changed, 19 insertions(+), 27 deletions(-) diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-server/src/main/java/com/webank/wedatasphere/linkis/instance/label/restful/InstanceRestful.java b/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-server/src/main/java/com/webank/wedatasphere/linkis/instance/label/restful/InstanceRestful.java index f1540816bb..18e0208979 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-server/src/main/java/com/webank/wedatasphere/linkis/instance/label/restful/InstanceRestful.java +++ b/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-server/src/main/java/com/webank/wedatasphere/linkis/instance/label/restful/InstanceRestful.java @@ -34,19 +34,15 @@ import org.apache.commons.logging.LogFactory; import org.codehaus.jackson.JsonNode; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.GET; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; import java.util.*; - -@Path("/microservice") -@Component +@RestController +@RequestMapping(path = "/microservice") public class InstanceRestful { private final static Log logger = LogFactory.getLog(InstanceRestful.class); @@ -56,21 +52,19 @@ public class InstanceRestful { @Autowired private DefaultInsLabelService insLabelService; - @GET - @Path("/allInstance") - public Response listAllInstanceWithLabel(@Context HttpServletRequest req){ + @RequestMapping(path = "/allInstance",method = RequestMethod.GET) + public Message listAllInstanceWithLabel( HttpServletRequest req){ String username = SecurityFilter.getLoginUsername(req); logger.info("start to get all instance informations....."); List instances = insLabelService.listAllInstanceWithLabel(); insLabelService.markInstanceLabel(instances); List instanceVos = EntityParser.parseToInstanceVo(instances); logger.info("Done, all instance:" + instances); - return Message.messageToResponse(Message.ok().data("instances",instanceVos)); + return Message.ok().data("instances",instanceVos); } - @PUT - @Path("/instanceLabel") - public Response upDateInstanceLabel(@Context HttpServletRequest req, JsonNode jsonNode) throws Exception { + @RequestMapping(path = "/instanceLabel",method = RequestMethod.PUT) + public Message upDateInstanceLabel( HttpServletRequest req, JsonNode jsonNode) throws Exception { String username = SecurityFilter.getLoginUsername(req); String[] adminArray = InstanceConfigration.GOVERNANCE_STATION_ADMIN().getValue().split(","); if(adminArray != null && !Arrays.asList(adminArray).contains(username)){ @@ -79,10 +73,10 @@ public Response upDateInstanceLabel(@Context HttpServletRequest req, JsonNode js String instanceName = jsonNode.get("instance").asText(); String instanceType = jsonNode.get("applicationName").asText(); if(StringUtils.isEmpty(instanceName)){ - return Message.messageToResponse(Message.error("instance cannot be empty(实例名不能为空")); + return Message.error("instance cannot be empty(实例名不能为空"); } if(StringUtils.isEmpty(instanceType)){ - return Message.messageToResponse(Message.error("instance cannot be empty(实例类型不能为空")); + return Message.error("instance cannot be empty(实例类型不能为空"); } JsonNode labelsNode = jsonNode.get("labels"); Iterator labelKeyIterator = labelsNode.iterator(); @@ -111,21 +105,19 @@ public Response upDateInstanceLabel(@Context HttpServletRequest req, JsonNode js InstanceInfo instanceInfo = insLabelService.getInstanceInfoByServiceInstance(instance); instanceInfo.setUpdateTime(new Date()); insLabelService.updateInstance(instanceInfo); - return Message.messageToResponse(Message.ok("success").data("labels",labels)); + return Message.ok("success").data("labels",labels); } - @GET - @Path("/modifiableLabelKey") - public Response listAllModifiableLabelKey(@Context HttpServletRequest req){ + @RequestMapping(path = "/modifiableLabelKey",method = RequestMethod.GET) + public Message listAllModifiableLabelKey( HttpServletRequest req){ Set keyList = LabelUtils.listAllUserModifiableLabel(); - return Message.messageToResponse(Message.ok().data("keyList",keyList)); + return Message.ok().data("keyList",keyList); } - @GET - @Path("/eurekaURL") - public Response getEurekaURL(@Context HttpServletRequest request) throws Exception { + @RequestMapping(path = "/eurekaURL",method = RequestMethod.GET) + public Message getEurekaURL( HttpServletRequest request) throws Exception { String eurekaURL = insLabelService.getEurekaURL(); - return Message.messageToResponse(Message.ok().data("url", eurekaURL)); + return Message.ok().data("url", eurekaURL); } } From 32d38396d8c47424be74d5cd5dbd39481add2540 Mon Sep 17 00:00:00 2001 From: casionone Date: Sat, 18 Sep 2021 20:13:43 +0800 Subject: [PATCH 07/29] [linkis-jobhistory] replace jersey with spring web --- .../restful/api/QueryRestfulApi.java | 47 ++++++++----------- 1 file changed, 19 insertions(+), 28 deletions(-) diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-jobhistory/src/main/java/com/webank/wedatasphere/linkis/jobhistory/restful/api/QueryRestfulApi.java b/linkis-public-enhancements/linkis-publicservice/linkis-jobhistory/src/main/java/com/webank/wedatasphere/linkis/jobhistory/restful/api/QueryRestfulApi.java index 7163ce4fd1..194c277baf 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-jobhistory/src/main/java/com/webank/wedatasphere/linkis/jobhistory/restful/api/QueryRestfulApi.java +++ b/linkis-public-enhancements/linkis-publicservice/linkis-jobhistory/src/main/java/com/webank/wedatasphere/linkis/jobhistory/restful/api/QueryRestfulApi.java @@ -33,14 +33,10 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -48,10 +44,8 @@ import java.util.List; import java.sql.Date; -@Component -@Path("/jobhistory") -@Produces(MediaType.APPLICATION_JSON) -@Consumes(MediaType.APPLICATION_JSON) +@RestController +@RequestMapping(path = "/jobhistory") public class QueryRestfulApi { private Logger log = LoggerFactory.getLogger(this.getClass()); @@ -61,18 +55,16 @@ public class QueryRestfulApi { @Autowired private JobDetailMapper jobDetailMapper; - @GET - @Path("/governanceStationAdmin") - public Response governanceStationAdmin(@Context HttpServletRequest req) { + @RequestMapping(path = "/governanceStationAdmin",method = RequestMethod.GET) + public Message governanceStationAdmin(HttpServletRequest req) { String username = SecurityFilter.getLoginUsername(req); String[] split = JobhistoryConfiguration.GOVERNANCE_STATION_ADMIN().getValue().split(","); boolean match = Arrays.stream(split).anyMatch(username::equalsIgnoreCase); - return Message.messageToResponse(Message.ok().data("admin", match)); + return Message.ok().data("admin", match); } - @GET - @Path("/{id}/get") - public Response getTaskByID(@Context HttpServletRequest req, @PathParam("id") Long jobId) { + @RequestMapping(path = "/{id}/get",method = RequestMethod.GET) + public Message getTaskByID(HttpServletRequest req, @PathVariable("id") Long jobId) { String username = SecurityFilter.getLoginUsername(req); if (QueryUtils.isJobHistoryAdmin(username) || !JobhistoryConfiguration.JOB_HISTORY_SAFE_TRIGGER()) { username = null; @@ -82,8 +74,8 @@ public Response getTaskByID(@Context HttpServletRequest req, @PathParam("id") Lo QueryTaskVO taskVO = TaskConversions.jobHistory2TaskVO(jobHistory, subJobDetails); // todo check if(taskVO == null){ - return Message.messageToResponse(Message.error("The corresponding job was not found, or there may be no permission to view the job" + - "(没有找到对应的job,也可能是没有查看该job的权限)")); + return Message.error("The corresponding job was not found, or there may be no permission to view the job" + + "(没有找到对应的job,也可能是没有查看该job的权限)"); } for (SubJobDetail subjob : subJobDetails) { if (!StringUtils.isEmpty(subjob.getResultLocation())) { @@ -91,19 +83,18 @@ public Response getTaskByID(@Context HttpServletRequest req, @PathParam("id") Lo break; } } - return Message.messageToResponse(Message.ok().data(TaskConstant.TASK, taskVO)); + return Message.ok().data(TaskConstant.TASK, taskVO); } /** * Method list should not contain subjob, which may cause performance problems. */ - @GET - @Path("/list") - public Response list(@Context HttpServletRequest req, @QueryParam("startDate") Long startDate, - @QueryParam("endDate") Long endDate, @QueryParam("status") String status, - @QueryParam("pageNow") Integer pageNow, @QueryParam("pageSize") Integer pageSize, - @QueryParam("taskID") Long taskID, @QueryParam("executeApplicationName") String executeApplicationName, - @QueryParam("proxyUser") String proxyUser) throws IOException, QueryException { + @RequestMapping(path = "/list",method = RequestMethod.GET) + public Message list(HttpServletRequest req, @RequestParam(value="startDate",required=false) Long startDate, + @RequestParam(value="endDate",required=false) Long endDate, @RequestParam(value="status",required=false) String status, + @RequestParam(value="pageNow",required=false) Integer pageNow, @RequestParam(value="pageSize",required=false) Integer pageSize, + @RequestParam(value="taskID",required=false) Long taskID, @RequestParam(value="executeApplicationName",required=false) String executeApplicationName, + @RequestParam(value="proxyUser",required=false) String proxyUser) throws IOException, QueryException { String username = SecurityFilter.getLoginUsername(req); if (StringUtils.isEmpty(pageNow)) { pageNow = 1; @@ -158,7 +149,7 @@ public Response list(@Context HttpServletRequest req, @QueryParam("startDate") L break; }*/ } - return Message.messageToResponse(Message.ok().data(TaskConstant.TASKS, vos) - .data(JobRequestConstants.TOTAL_PAGE(), total)); + return Message.ok().data(TaskConstant.TASKS, vos) + .data(JobRequestConstants.TOTAL_PAGE(), total); } } From ed8bcb1c096ef95f01754dceb575730b12ff9885 Mon Sep 17 00:00:00 2001 From: casionone Date: Sat, 18 Sep 2021 20:14:22 +0800 Subject: [PATCH 08/29] [linkis-metadata] replace jersey with spring web --- .../restful/api/DataSourceRestfulApi.java | 70 +++++++--------- .../restful/api/MdqTableRestfulApi.java | 83 +++++++++---------- .../remote/DataSourceRestfulRemote.java | 14 ++-- 3 files changed, 74 insertions(+), 93 deletions(-) diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/api/DataSourceRestfulApi.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/api/DataSourceRestfulApi.java index 75307e66e6..1c67604e14 100644 --- a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/api/DataSourceRestfulApi.java +++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/api/DataSourceRestfulApi.java @@ -23,19 +23,15 @@ import org.apache.log4j.Logger; import org.codehaus.jackson.JsonNode; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; - -@Path("datasource") -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -@Component +@RestController +@RequestMapping(path = "/datasource") public class DataSourceRestfulApi implements DataSourceRestfulRemote { private static final Logger logger = Logger.getLogger(DataSourceRestfulApi.class); @@ -44,62 +40,57 @@ public class DataSourceRestfulApi implements DataSourceRestfulRemote { DataSourceService dataSourceService; - @GET - @Path("dbs") - public Response queryDatabaseInfo(@Context HttpServletRequest req) { + @RequestMapping(path = "dbs",method = RequestMethod.GET) + public Message queryDatabaseInfo(HttpServletRequest req) { String userName = SecurityFilter.getLoginUsername(req); try { JsonNode dbs = dataSourceService.getDbs(userName); - return Message.messageToResponse(Message.ok("").data("dbs", dbs)); + return Message.ok("").data("dbs", dbs); } catch (Exception e) { logger.error("Failed to get database(获取数据库失败)", e); - return Message.messageToResponse(Message.error("Failed to get database(获取数据库失败)", e)); + return Message.error("Failed to get database(获取数据库失败)", e); } } - @GET - @Path("all") - public Response queryDbsWithTables(@Context HttpServletRequest req){ + @RequestMapping(path = "all",method = RequestMethod.GET) + public Message queryDbsWithTables(HttpServletRequest req){ String userName = SecurityFilter.getLoginUsername(req); try { JsonNode dbs = dataSourceService.getDbsWithTables(userName); - return Message.messageToResponse(Message.ok("").data("dbs", dbs)); + return Message.ok("").data("dbs", dbs); } catch (Exception e) { logger.error("Failed to queryDbsWithTables", e); - return Message.messageToResponse(Message.error("Failed to queryDbsWithTables", e)); + return Message.error("Failed to queryDbsWithTables", e); } } - @GET - @Path("tables") - public Response queryTables(@QueryParam("database") String database, @Context HttpServletRequest req){ + @RequestMapping(path = "tables",method = RequestMethod.GET) + public Message queryTables(@RequestParam(value="database",required=false) String database, HttpServletRequest req){ String userName = SecurityFilter.getLoginUsername(req); try { JsonNode tables = dataSourceService.queryTables(database, userName); - return Message.messageToResponse(Message.ok("").data("tables", tables)); + return Message.ok("").data("tables", tables); } catch (Exception e) { logger.error("Failed to queryTables", e); - return Message.messageToResponse(Message.error("Failed to queryTables", e)); + return Message.error("Failed to queryTables", e); } } - @GET - @Path("columns") - public Response queryTableMeta(@QueryParam("database") String database, @QueryParam("table") String table, @Context HttpServletRequest req){ + @RequestMapping(path = "columns",method = RequestMethod.GET) + public Message queryTableMeta(@RequestParam(value="database",required=false) String database, @RequestParam(value="table",required=false) String table, HttpServletRequest req){ String userName = SecurityFilter.getLoginUsername(req); try { JsonNode columns = dataSourceService.queryTableMeta(database, table, userName); - return Message.messageToResponse(Message.ok("").data("columns", columns)); + return Message.ok("").data("columns", columns); } catch (Exception e) { logger.error("Failed to get data table structure(获取数据表结构失败)", e); - return Message.messageToResponse(Message.error("Failed to get data table structure(获取数据表结构失败)", e)); + return Message.error("Failed to get data table structure(获取数据表结构失败)", e); } } - @GET - @Path("size") - public Response sizeOf(@QueryParam("database") String database, @QueryParam("table") String table, @QueryParam("partition") String partition, @Context HttpServletRequest req){ + @RequestMapping(path = "size",method = RequestMethod.GET) + public Message sizeOf(@RequestParam(value="database",required=false) String database, @RequestParam(value="table",required=false) String table, @RequestParam(value="partition",required=false) String partition, HttpServletRequest req){ String userName = SecurityFilter.getLoginUsername(req); try { JsonNode sizeNode; @@ -108,23 +99,22 @@ public Response sizeOf(@QueryParam("database") String database, @QueryParam("ta } else { sizeNode = dataSourceService.getPartitionSize(database, table, partition, userName); } - return Message.messageToResponse(Message.ok("").data("sizeInfo", sizeNode)); + return Message.ok("").data("sizeInfo", sizeNode); } catch (Exception e) { logger.error("Failed to get table partition size(获取表分区大小失败)", e); - return Message.messageToResponse(Message.error("Failed to get table partition size(获取表分区大小失败)", e)); + return Message.error("Failed to get table partition size(获取表分区大小失败)", e); } } - @GET - @Path("partitions") - public Response partitions(@QueryParam("database") String database, @QueryParam("table") String table, @Context HttpServletRequest req){ + @RequestMapping(path = "partitions",method = RequestMethod.GET) + public Message partitions(@RequestParam(value="database",required=false) String database, @RequestParam(value="table",required=false) String table, HttpServletRequest req){ String userName = SecurityFilter.getLoginUsername(req); try{ JsonNode partitionNode = dataSourceService.getPartitions(database, table, userName); - return Message.messageToResponse(Message.ok("").data("partitionInfo", partitionNode)); + return Message.ok("").data("partitionInfo", partitionNode); } catch (Exception e) { logger.error("Failed to get table partition(获取表分区失败)", e); - return Message.messageToResponse(Message.error("Failed to get table partition(获取表分区失败)", e)); + return Message.error("Failed to get table partition(获取表分区失败)", e); } } } diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/api/MdqTableRestfulApi.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/api/MdqTableRestfulApi.java index 6bcda1104e..7c8c553e3a 100644 --- a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/api/MdqTableRestfulApi.java +++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/api/MdqTableRestfulApi.java @@ -33,23 +33,20 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import java.io.IOException; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; -@Path("datasource") -@Consumes(MediaType.APPLICATION_JSON) -@Produces(MediaType.APPLICATION_JSON) -@Component +@RestController +@RequestMapping(path = "/datasource") public class MdqTableRestfulApi { private static final Logger logger = LoggerFactory.getLogger(MdqTableRestfulApi.class); @@ -60,10 +57,9 @@ public class MdqTableRestfulApi { private MdqService mdqService; ObjectMapper mapper = new ObjectMapper(); - @GET - @Path("getTableBaseInfo") - public Response getTableBaseInfo(@QueryParam("database") String database, @QueryParam("tableName") String tableName, - @Context HttpServletRequest req) { + @RequestMapping(path = "getTableBaseInfo",method = RequestMethod.GET) + public Message getTableBaseInfo(@RequestParam(value="database",required=false) String database, @RequestParam(value="tableName",required=false) String tableName, + HttpServletRequest req) { String userName = SecurityFilter.getLoginUsername(req); MdqTableBaseInfoVO tableBaseInfo; if (mdqService.isExistInMdq(database, tableName, userName)) { @@ -71,13 +67,12 @@ public Response getTableBaseInfo(@QueryParam("database") String database, @Query } else { tableBaseInfo = mdqService.getTableBaseInfoFromHive(database, tableName, userName); } - return Message.messageToResponse(Message.ok().data("tableBaseInfo", tableBaseInfo)); + return Message.ok().data("tableBaseInfo", tableBaseInfo); } - @GET - @Path("getTableFieldsInfo") - public Response getTableFieldsInfo(@QueryParam("database") String database, @QueryParam("tableName") String tableName, - @Context HttpServletRequest req) { + @RequestMapping(path = "getTableFieldsInfo",method = RequestMethod.GET) + public Message getTableFieldsInfo(@RequestParam(value="database",required=false) String database, @RequestParam(value="tableName",required=false) String tableName, + HttpServletRequest req) { String userName = SecurityFilter.getLoginUsername(req); List tableFieldsInfo; if (mdqService.isExistInMdq(database, tableName, userName)) { @@ -85,16 +80,16 @@ public Response getTableFieldsInfo(@QueryParam("database") String database, @Que } else { tableFieldsInfo = mdqService.getTableFieldsInfoFromHive(database, tableName, userName); } - return Message.messageToResponse(Message.ok().data("tableFieldsInfo", tableFieldsInfo)); + return Message.ok().data("tableFieldsInfo", tableFieldsInfo); } - @GET - @Path("getTableStatisticInfo") - public Response getTableStatisticInfo(@QueryParam("database") String database, @QueryParam("tableName") String tableName, - @DefaultValue("1") @QueryParam("pageNow") int pageNow, - @DefaultValue("1000") @QueryParam("pageSize") int pageSize, - @DefaultValue("desc") @QueryParam("partitionSort") String partitionSort, - @Context HttpServletRequest req) throws IOException { + @RequestMapping(path = "getTableStatisticInfo",method = RequestMethod.GET) + public Message getTableStatisticInfo( @RequestParam(value="database",required=false) String database, + @RequestParam(value="tableName",required=false) String tableName, + @RequestParam(value="pageNow",defaultValue="1") int pageNow, + @RequestParam(value="pageSize",defaultValue="1000") int pageSize, + @RequestParam(value="partitionSort",defaultValue="desc") String partitionSort, + HttpServletRequest req) throws IOException { String userName = SecurityFilter.getLoginUsername(req); MdqTableStatisticInfoVO tableStatisticInfo = mdqService.getTableStatisticInfo(database, tableName, userName); int totalSize = 0; @@ -129,39 +124,35 @@ public Response getTableStatisticInfo(@QueryParam("database") String database, @ .data("totalSize", totalSize) .data("pageNow", pageNow) .data("pageSize", pageSize); - return Message.messageToResponse(data); + return data; } - @GET - @Path("getPartitionStatisticInfo") - public Response getPartitionStatisticInfo(@QueryParam("database") String database, @QueryParam("tableName") String tableName, - @QueryParam("partitionPath") String partitionName, - @Context HttpServletRequest req) throws IOException, MdqIllegalParamException { + @RequestMapping(path = "getPartitionStatisticInfo",method = RequestMethod.GET) + public Message getPartitionStatisticInfo(@RequestParam(value="database",required=false) String database, @RequestParam(value="tableName",required=false) String tableName, + @RequestParam(value="partitionPath",required=false) String partitionName, + HttpServletRequest req) throws IOException, MdqIllegalParamException { String userName = SecurityFilter.getLoginUsername(req); MdqTablePartitionStatisticInfoVO partition = mdqService.getPartitionStatisticInfo(database, tableName, userName, partitionName); - return Message.messageToResponse(Message.ok().data("partitionStatisticInfo", partition)); + return Message.ok().data("partitionStatisticInfo", partition); } - @GET - @Path("active") - public Response active(@QueryParam("tableId") Long tableId, @Context HttpServletRequest req) { + @RequestMapping(path = "active",method = RequestMethod.GET) + public Message active(@RequestParam(value="tableId",required=false) Long tableId, HttpServletRequest req) { mdqService.activateTable(tableId); - return Message.messageToResponse(Message.ok()); + return Message.ok(); } - @POST - @Path("persistTable") - public Response persistTable(@Context HttpServletRequest req, JsonNode json) throws IOException { + @RequestMapping(path = "persistTable",method = RequestMethod.POST) + public Message persistTable( HttpServletRequest req, JsonNode json) throws IOException { String userName = SecurityFilter.getLoginUsername(req); MdqTableBO table = mapper.readValue(json.get("table"), MdqTableBO.class); mdqService.persistTable(table, userName); - return Message.messageToResponse(Message.ok()); + return Message.ok(); } - @POST - @Path("displaysql") - public Response displaySql(@Context HttpServletRequest request, JsonNode json) { + @RequestMapping(path = "displaysql",method = RequestMethod.POST) + public Message displaySql( HttpServletRequest request, JsonNode json) { String userName = SecurityFilter.getLoginUsername(request); logger.info("display sql for user {} ", userName); StringBuilder sb = new StringBuilder(); @@ -178,7 +169,7 @@ public Response displaySql(@Context HttpServletRequest request, JsonNode json) { } catch (Exception e) { logger.error("json parse to bean failed", e); Message message = Message.error("display ddl failed"); - return Message.messageToResponse(message); + return message; } String tableName = tableBO.getTableBaseInfo().getBase().getName(); String dbName = tableBO.getTableBaseInfo().getBase().getDatabase(); @@ -186,7 +177,7 @@ public Response displaySql(@Context HttpServletRequest request, JsonNode json) { Message message = Message.ok(retStr); message.setMethod("/api/datasource/display"); message.data("sql", retSql); - return Message.messageToResponse(message); + return message; } } diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/remote/DataSourceRestfulRemote.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/remote/DataSourceRestfulRemote.java index 613d438b76..1add4d5e11 100644 --- a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/remote/DataSourceRestfulRemote.java +++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/remote/DataSourceRestfulRemote.java @@ -17,32 +17,32 @@ package com.webank.wedatasphere.linkis.metadata.restful.remote; import com.webank.wedatasphere.linkis.metadata.util.Constants; +import com.webank.wedatasphere.linkis.server.Message; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.core.Response; @FeignClient(name = Constants.APPLICATION_NAME) public interface DataSourceRestfulRemote { @GetMapping("/api/datasource/dbs") - public Response queryDatabaseInfo(HttpServletRequest req); + public Message queryDatabaseInfo(HttpServletRequest req); @GetMapping("/api/datasource/all") - public Response queryDbsWithTables(HttpServletRequest req); + public Message queryDbsWithTables(HttpServletRequest req); @GetMapping("/api/datasource/tables") - public Response queryTables(@RequestParam("database") String database, HttpServletRequest req); + public Message queryTables(@RequestParam("database") String database, HttpServletRequest req); @GetMapping("/api/datasource/columns") - public Response queryTableMeta(@RequestParam("database") String database, @RequestParam("table") String table, HttpServletRequest req); + public Message queryTableMeta(@RequestParam("database") String database, @RequestParam("table") String table, HttpServletRequest req); @GetMapping("/api/datasource/size") - public Response sizeOf(@RequestParam("database") String database, @RequestParam("table") String table, @RequestParam("partition") String partition, HttpServletRequest req); + public Message sizeOf(@RequestParam("database") String database, @RequestParam("table") String table, @RequestParam("partition") String partition, HttpServletRequest req); @GetMapping("/api/datasource/partitions") - public Response partitions(@RequestParam("database") String database, @RequestParam("table") String table, HttpServletRequest req); + public Message partitions(@RequestParam("database") String database, @RequestParam("table") String table, HttpServletRequest req); } \ No newline at end of file From 02609687a9b9a49cac9c5b967aa5b299c5dfe937 Mon Sep 17 00:00:00 2001 From: casionone Date: Sat, 18 Sep 2021 20:15:02 +0800 Subject: [PATCH 09/29] [linkis-storage-script-dev-server] replace jersey with spring web --- .../restful/api/BMLFsRestfulApi.java | 56 +++--- .../filesystem/restful/api/FsRestfulApi.java | 169 ++++++++---------- 2 files changed, 96 insertions(+), 129 deletions(-) diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/BMLFsRestfulApi.java b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/BMLFsRestfulApi.java index 8e994a1049..caab19eb2a 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/BMLFsRestfulApi.java +++ b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/BMLFsRestfulApi.java @@ -29,38 +29,30 @@ import org.apache.commons.math3.util.Pair; import org.apache.http.Consts; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import java.io.IOException; import java.io.InputStream; import java.util.*; import java.util.stream.Collectors; -@Produces(MediaType.APPLICATION_JSON) -@Consumes({MediaType.APPLICATION_JSON}) -@Component -@Path("filesystem") +@RestController +@RequestMapping(path = "/filesystem") public class BMLFsRestfulApi { @Autowired BMLHelper bmlHelper; - @GET - @Path("/openScriptFromBML") - public Response openScriptFromBML(@Context HttpServletRequest req, - @QueryParam("resourceId") String resourceId, - @QueryParam("version") String version, - @QueryParam("creator") String creator, - @QueryParam("projectName") String projectName, - @DefaultValue("test.sql") @QueryParam("fileName") String fileName) throws IOException, WorkSpaceException { + @RequestMapping(path = "/openScriptFromBML",method = RequestMethod.GET) + public Message openScriptFromBML(HttpServletRequest req, + @RequestParam(value="resourceId",required=false) String resourceId, + @RequestParam(value="version",required=false) String version, + @RequestParam(value="creator",required=false) String creator, + @RequestParam(value="projectName",required=false) String projectName, + @RequestParam(value="fileName",defaultValue ="test.sql" ) String fileName) throws IOException, WorkSpaceException { String userName = SecurityFilter.getLoginUsername(req); Map query = bmlHelper.query(userName, resourceId, version); InputStream inputStream = (InputStream) query.get("stream"); @@ -71,23 +63,22 @@ public Response openScriptFromBML(@Context HttpServletRequest req, message = new Gson().fromJson(collect.getSecond().get(0)[0], Message.class); if (message == null) throw WorkspaceExceptionManager.createException(80019); } catch (Exception e) { - return Message.messageToResponse(Message.ok().data("scriptContent", collect.getSecond().get(0)[0]).data("metadata", collect.getFirst())); + return Message.ok().data("scriptContent", collect.getSecond().get(0)[0]).data("metadata", collect.getFirst()); } if (message.getStatus() != 0) { throw new WorkSpaceException(80020, message.getMessage()); } - return Message.messageToResponse(Message.ok().data("scriptContent", collect.getSecond().get(0)[0]).data("metadata", collect.getFirst())); + return Message.ok().data("scriptContent", collect.getSecond().get(0)[0]).data("metadata", collect.getFirst()); } } - @GET - @Path("/product/openScriptFromBML") - public Response openScriptFromProductBML(@Context HttpServletRequest req, - @QueryParam("resourceId") String resourceId, - @QueryParam("version") String version, - @QueryParam("creator") String creator, - @DefaultValue("test.sql") @QueryParam("fileName") String fileName) throws IOException, WorkSpaceException { + @RequestMapping(path = "/product/openScriptFromBML",method = RequestMethod.GET) + public Message openScriptFromProductBML(HttpServletRequest req, + @RequestParam(value="resourceId",required=false) String resourceId, + @RequestParam(value="version",required=false) String version, + @RequestParam(value="creator",required=false) String creator, + @RequestParam(value="fileName",defaultValue = "test.sql") String fileName) throws IOException, WorkSpaceException { String userName = SecurityFilter.getLoginUsername(req); if (!StringUtils.isEmpty(creator)){ userName = creator; @@ -103,20 +94,19 @@ public Response openScriptFromProductBML(@Context HttpServletRequest req, throw WorkspaceExceptionManager.createException(80019); } } catch (Exception e) { - return Message.messageToResponse(Message.ok().data("scriptContent", collect.getSecond().get(0)[0]).data("metadata", collect.getFirst())); + return Message.ok().data("scriptContent", collect.getSecond().get(0)[0]).data("metadata", collect.getFirst()); } if (message.getStatus() != 0) { throw new WorkSpaceException(80020, message.getMessage()); } - return Message.messageToResponse(Message.ok().data("scriptContent", collect.getSecond().get(0)[0]).data("metadata", collect.getFirst())); + return Message.ok().data("scriptContent", collect.getSecond().get(0)[0]).data("metadata", collect.getFirst()); } } - @POST - @Path("/saveScriptToBML") - public Response saveScriptToBML(@Context HttpServletRequest req, @RequestBody Map json) throws IOException { + @RequestMapping(path = "/saveScriptToBML",method = RequestMethod.POST) + public Message saveScriptToBML(HttpServletRequest req, @RequestBody Map json) throws IOException { String userName = SecurityFilter.getLoginUsername(req); String scriptContent = (String) json.get("scriptContent"); Map params = (Map) json.get("metadata"); @@ -147,7 +137,7 @@ public Response saveScriptToBML(@Context HttpServletRequest req, @RequestBody Ma resourceId = bmlResponse.get("resourceId").toString(); version = bmlResponse.get("version").toString(); } - return Message.messageToResponse(Message.ok().data("resourceId", resourceId).data("version", version)); + return Message.ok().data("resourceId", resourceId).data("version", version); } } } diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/FsRestfulApi.java b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/FsRestfulApi.java index 3e6244af33..0fb2072801 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/FsRestfulApi.java +++ b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/FsRestfulApi.java @@ -45,21 +45,15 @@ import org.glassfish.jersey.media.multipart.FormDataBodyPart; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataMultiPart; -import org.glassfish.jersey.media.multipart.FormDataParam; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.*; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; import java.io.*; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -74,10 +68,8 @@ * johnnwang * 2018/10/25 */ -@Produces(MediaType.APPLICATION_JSON) -@Consumes({MediaType.APPLICATION_JSON, MediaType.MULTIPART_FORM_DATA}) -@Component -@Path("filesystem") +@RestController +@RequestMapping(path = "/filesystem") public class FsRestfulApi { @Autowired @@ -85,9 +77,8 @@ public class FsRestfulApi { private final Logger LOGGER = LoggerFactory.getLogger(getClass()); - @GET - @Path("/getUserRootPath") - public Response getUserRootPath(@Context HttpServletRequest req, @QueryParam("pathType") String pathType) throws IOException, WorkSpaceException { + @RequestMapping(path = "/getUserRootPath",method = RequestMethod.GET) + public Message getUserRootPath(HttpServletRequest req, @RequestParam(value="pathType",required=false) String pathType) throws IOException, WorkSpaceException { String userName = SecurityFilter.getLoginUsername(req); String hdfsUserRootPathPrefix = WorkspaceUtil.suffixTuning(HDFS_USER_ROOT_PATH_PREFIX.getValue()); String hdfsUserRootPathSuffix = HDFS_USER_ROOT_PATH_SUFFIX.getValue(); @@ -106,12 +97,11 @@ public Response getUserRootPath(@Context HttpServletRequest req, @QueryParam("pa if (!fileSystem.exists(fsPath)) { throw WorkspaceExceptionManager.createException(80003); } - return Message.messageToResponse(Message.ok().data(String.format("user%sRootPath", returnType), path)); + return Message.ok().data(String.format("user%sRootPath", returnType), path); } - @POST - @Path("/createNewDir") - public Response createNewDir(@Context HttpServletRequest req, JsonNode json) throws IOException, WorkSpaceException { + @RequestMapping(path = "/createNewDir",method = RequestMethod.POST) + public Message createNewDir(HttpServletRequest req, JsonNode json) throws IOException, WorkSpaceException { String userName = SecurityFilter.getLoginUsername(req); String path = json.get("path").getTextValue(); if (StringUtils.isEmpty(path)) { @@ -124,12 +114,11 @@ public Response createNewDir(@Context HttpServletRequest req, JsonNode json) thr throw WorkspaceExceptionManager.createException(80005); } fileSystem.mkdirs(fsPath); - return Message.messageToResponse(Message.ok()); + return Message.ok(); } - @POST - @Path("/createNewFile") - public Response createNewFile(@Context HttpServletRequest req, JsonNode json) throws IOException, WorkSpaceException { + @RequestMapping(path = "/createNewFile",method = RequestMethod.POST) + public Message createNewFile(HttpServletRequest req, JsonNode json) throws IOException, WorkSpaceException { String userName = SecurityFilter.getLoginUsername(req); String path = json.get("path").getTextValue(); if (StringUtils.isEmpty(path)) { @@ -142,12 +131,11 @@ public Response createNewFile(@Context HttpServletRequest req, JsonNode json) th throw WorkspaceExceptionManager.createException(80006); } fileSystem.createNewFile(fsPath); - return Message.messageToResponse(Message.ok()); + return Message.ok(); } - @POST - @Path("/rename") - public Response rename(@Context HttpServletRequest req, JsonNode json) throws IOException, WorkSpaceException { + @RequestMapping(path = "/rename",method = RequestMethod.POST) + public Message rename(HttpServletRequest req, JsonNode json) throws IOException, WorkSpaceException { String oldDest = json.get("oldDest").getTextValue(); String newDest = json.get("newDest").getTextValue(); String userName = SecurityFilter.getLoginUsername(req); @@ -161,7 +149,7 @@ public Response rename(@Context HttpServletRequest req, JsonNode json) throws IO } if (StringUtils.isEmpty(newDest)) { //No change in file name(文件名字无变化) - return Message.messageToResponse(Message.ok()); + return Message.ok(); } WorkspaceUtil.fileAndDirNameSpecialCharCheck(newDest); FsPath fsPathOld = new FsPath(oldDest); @@ -171,13 +159,12 @@ public Response rename(@Context HttpServletRequest req, JsonNode json) throws IO throw WorkspaceExceptionManager.createException(80007); } fileSystem.renameTo(fsPathOld, fsPathNew); - return Message.messageToResponse(Message.ok()); + return Message.ok(); } - @POST - @Path("/upload") - public Response upload(@Context HttpServletRequest req, - @FormDataParam("path") String path, + @RequestMapping(path = "/upload",method = RequestMethod.POST) + public Message upload(HttpServletRequest req, + @RequestParam("path") String path, FormDataMultiPart form) throws IOException, WorkSpaceException { String userName = SecurityFilter.getLoginUsername(req); if (StringUtils.isEmpty(path)) { @@ -197,12 +184,11 @@ public Response upload(@Context HttpServletRequest req, IOUtils.copy(is, outputStream); } } - return Message.messageToResponse(Message.ok()); + return Message.ok(); } - @POST - @Path("/deleteDirOrFile") - public Response deleteDirOrFile(@Context HttpServletRequest req, JsonNode json) throws IOException, WorkSpaceException { + @RequestMapping(path = "/deleteDirOrFile",method = RequestMethod.POST) + public Message deleteDirOrFile(HttpServletRequest req, JsonNode json) throws IOException, WorkSpaceException { String userName = SecurityFilter.getLoginUsername(req); String path = json.get("path").getTextValue(); if (StringUtils.isEmpty(path)) { @@ -217,13 +203,12 @@ public Response deleteDirOrFile(@Context HttpServletRequest req, JsonNode json) throw WorkspaceExceptionManager.createException(80009); } deleteAllFiles(fileSystem, fsPath); - return Message.messageToResponse(Message.ok()); + return Message.ok(); } - @GET - @Path("/getDirFileTrees") - public Response getDirFileTrees(@Context HttpServletRequest req, - @QueryParam("path") String path) throws IOException, WorkSpaceException { + @RequestMapping(path = "/getDirFileTrees",method = RequestMethod.GET) + public Message getDirFileTrees(HttpServletRequest req, + @RequestParam(value="path",required=false) String path) throws IOException, WorkSpaceException { String userName = SecurityFilter.getLoginUsername(req); if (StringUtils.isEmpty(path)) { throw WorkspaceExceptionManager.createException(80004, path); @@ -231,7 +216,7 @@ public Response getDirFileTrees(@Context HttpServletRequest req, FsPath fsPath = new FsPath(path); FileSystem fileSystem = fsService.getFileSystem(userName, fsPath); if (!fileSystem.exists(fsPath)) { - return Message.messageToResponse(Message.ok().data("dirFileTrees", null)); + return Message.ok().data("dirFileTrees", null); } DirFileTree dirFileTree = new DirFileTree(); dirFileTree.setPath(fsPath.getSchemaPath()); @@ -257,13 +242,12 @@ public Response getDirFileTrees(@Context HttpServletRequest req, dirFileTree.getChildren().add(dirFileTreeChildren); } } - return Message.messageToResponse(Message.ok().data("dirFileTrees", dirFileTree)); + return Message.ok().data("dirFileTrees", dirFileTree); } - @POST - @Path("/download") - public void download(@Context HttpServletRequest req, - @Context HttpServletResponse response, + @RequestMapping(path = "/download",method = RequestMethod.POST) + public void download(HttpServletRequest req, + HttpServletResponse response, @RequestBody Map json) throws IOException, WorkSpaceException { InputStream inputStream = null; ServletOutputStream outputStream = null; @@ -313,26 +297,24 @@ public void download(@Context HttpServletRequest req, } } - @GET - @Path("/isExist") - public Response isExist(@Context HttpServletRequest req, - @QueryParam("path") String path) throws IOException, WorkSpaceException { + @RequestMapping(path = "/isExist",method = RequestMethod.GET) + public Message isExist(HttpServletRequest req, + @RequestParam(value="path",required=false) String path) throws IOException, WorkSpaceException { String userName = SecurityFilter.getLoginUsername(req); FsPath fsPath = new FsPath(path); if (StringUtils.isEmpty(path)) { throw WorkspaceExceptionManager.createException(80004, path); } FileSystem fileSystem = fsService.getFileSystem(userName, fsPath); - return Message.messageToResponse(Message.ok().data("isExist", fileSystem.exists(fsPath))); + return Message.ok().data("isExist", fileSystem.exists(fsPath)); } - @GET - @Path("/openFile") - public Response openFile(@Context HttpServletRequest req, - @QueryParam("path") String path, - @DefaultValue("1") @QueryParam("page") Integer page, - @DefaultValue("5000") @QueryParam("pageSize") Integer pageSize, - @DefaultValue("utf-8") @QueryParam("charset") String charset) throws IOException, WorkSpaceException { + @RequestMapping(path = "/openFile",method = RequestMethod.GET) + public Message openFile(HttpServletRequest req, + @RequestParam(value="path",required=false) String path, + @RequestParam(value="page",defaultValue = "1") Integer page, + @RequestParam(value="pageSize",defaultValue="5000") Integer pageSize, + @RequestParam(value="charset",defaultValue="utf-8") String charset) throws IOException, WorkSpaceException { String userName = SecurityFilter.getLoginUsername(req); Message message = Message.ok(); if (StringUtils.isEmpty(path)) { @@ -355,7 +337,7 @@ public Response openFile(@Context HttpServletRequest req, message.data("metadata", result.getFirst()).data("fileContent", result.getSecond()); message.data("type", fileSource.getFileSplits()[0].type()); message.data("totalLine", fileSource.getTotalLine()); - return Message.messageToResponse(message.data("page", page).data("totalPage", 0)); + return message.data("page", page).data("totalPage", 0); } finally { IOUtils.closeQuietly(fileSource); } @@ -368,9 +350,8 @@ public Response openFile(@Context HttpServletRequest req, * @return * @throws IOException */ - @POST - @Path("/saveScript") - public Response saveScript(@Context HttpServletRequest req, @RequestBody Map json) throws IOException, WorkSpaceException { + @RequestMapping(path = "/saveScript",method = RequestMethod.POST) + public Message saveScript(HttpServletRequest req, @RequestBody Map json) throws IOException, WorkSpaceException { String userName = SecurityFilter.getLoginUsername(req); String path = (String) json.get("path"); if (StringUtils.isEmpty(path)) { @@ -403,22 +384,21 @@ public Response saveScript(@Context HttpServletRequest req, @RequestBody Map snd = collect.getSecond(); LogLevel start = new LogLevel(LogLevel.Type.ALL); snd.stream().map(f -> f[0]).forEach(s -> WorkspaceUtil.logMatch(s, start).forEach(i -> log[i].append(s).append("\n"))); - return Message.messageToResponse(Message.ok().data("log", Arrays.stream(log).map(StringBuilder::toString).toArray(String[]::new))); + return Message.ok().data("log", Arrays.stream(log).map(StringBuilder::toString).toArray(String[]::new)); } } From 8d5a68a6e8c13f19ee8c204cd1a04f6b1f3685e2 Mon Sep 17 00:00:00 2001 From: casionone Date: Sat, 18 Sep 2021 20:15:24 +0800 Subject: [PATCH 10/29] [linkis-udf-service] replace jersey with spring web --- .../wedatasphere/linkis/udf/api/UDFApi.java | 113 +++++++----------- 1 file changed, 46 insertions(+), 67 deletions(-) diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-service/src/main/java/com/webank/wedatasphere/linkis/udf/api/UDFApi.java b/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-service/src/main/java/com/webank/wedatasphere/linkis/udf/api/UDFApi.java index c11dbd73bd..d7b881bd4b 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-service/src/main/java/com/webank/wedatasphere/linkis/udf/api/UDFApi.java +++ b/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-service/src/main/java/com/webank/wedatasphere/linkis/udf/api/UDFApi.java @@ -29,29 +29,22 @@ import com.webank.wedatasphere.linkis.udf.service.UDFService; import com.webank.wedatasphere.linkis.udf.service.UDFTreeService; import com.webank.wedatasphere.linkis.udf.utils.ConstantVar; -import org.apache.commons.beanutils.BeanUtils; -import org.apache.commons.beanutils.BeanUtilsBean; -import org.apache.commons.beanutils.converters.DateConverter; import org.apache.commons.collections.CollectionUtils; import org.apache.log4j.Logger; import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.map.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; -import javax.ws.rs.*; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.Response; import java.util.*; - -@Path("udf") -@Component +@RestController +@RequestMapping(path = "udf") public class UDFApi { private static final Logger logger = Logger.getLogger(UDFApi.class); @@ -65,9 +58,8 @@ public class UDFApi { ObjectMapper mapper = new ObjectMapper(); - @POST - @Path("all") - public Response allUDF(@Context HttpServletRequest req, String jsonString){ + @RequestMapping(path = "all",method = RequestMethod.POST) + public Message allUDF(HttpServletRequest req, String jsonString){ Message message = null; try { String userName = SecurityFilter.getLoginUsername(req); @@ -104,7 +96,7 @@ public Response allUDF(@Context HttpServletRequest req, String jsonString){ logger.error("Failed to list Tree: ", e); message = Message.error(e.getMessage()); } - return Message.messageToResponse(message); + return message; } private void fetchUdfInfoRecursively(List allInfo, UDFTree udfTree, String realUser) throws Throwable{ @@ -128,9 +120,8 @@ private void fetchUdfInfoRecursively(List allInfo, UDFTree udfTree, Str } } - @POST - @Path("list") - public Response listUDF(@Context HttpServletRequest req, Map json){ + @RequestMapping(path = "list",method = RequestMethod.POST) + public Message listUDF(HttpServletRequest req, Map json){ Message message = null; try { String userName = SecurityFilter.getLoginUsername(req); @@ -145,12 +136,11 @@ public Response listUDF(@Context HttpServletRequest req, Map json message = Message.error(e.getMessage()); } - return Message.messageToResponse(message); + return message; } - @POST - @Path("add") - public Response addUDF(@Context HttpServletRequest req, JsonNode json) { + @RequestMapping(path = "add",method = RequestMethod.POST) + public Message addUDF(HttpServletRequest req, JsonNode json) { Message message = null; try { String userName = SecurityFilter.getLoginUsername(req); @@ -165,12 +155,11 @@ public Response addUDF(@Context HttpServletRequest req, JsonNode json) { logger.error("Failed to add UDF: ", e); message = Message.error(e.getMessage()); } - return Message.messageToResponse(message); + return message; } - @POST - @Path("update") - public Response updateUDF(@Context HttpServletRequest req, JsonNode json) { + @RequestMapping(path = "update",method = RequestMethod.POST) + public Message updateUDF(HttpServletRequest req, JsonNode json) { Message message = null; try { String userName = SecurityFilter.getLoginUsername(req); @@ -184,12 +173,11 @@ public Response updateUDF(@Context HttpServletRequest req, JsonNode json) { logger.error("Failed to update UDF: ", e); message = Message.error(e.getMessage()); } - return Message.messageToResponse(message); + return message; } - @GET - @Path("delete/{id}") - public Response deleteUDF(@Context HttpServletRequest req,@PathParam("id") Long id){ + @RequestMapping(path = "delete/{id}",method = RequestMethod.GET) + public Message deleteUDF(HttpServletRequest req,@PathVariable("id") Long id){ String userName = SecurityFilter.getLoginUsername(req); Message message = null; try { @@ -199,13 +187,12 @@ public Response deleteUDF(@Context HttpServletRequest req,@PathParam("id") Long logger.error("Failed to delete UDF: ", e); message = Message.error(e.getMessage()); } - return Message.messageToResponse(message); + return message; } - @GET - @Path("isload") - public Response isLoad(@Context HttpServletRequest req, - @QueryParam("udfId") Long udfId,@QueryParam("isLoad") Boolean isLoad){ + @RequestMapping(path = "isload",method = RequestMethod.GET) + public Message isLoad(HttpServletRequest req, + @RequestParam(value="udfId",required=false) Long udfId,@RequestParam(value="isLoad",required=false) Boolean isLoad){ String userName = SecurityFilter.getLoginUsername(req); Message message = null; try { @@ -219,12 +206,11 @@ public Response isLoad(@Context HttpServletRequest req, logger.error("Failed to isLoad UDF: ", e); message = Message.error(e.getMessage()); } - return Message.messageToResponse(message); + return message; } - @POST - @Path("/tree/add") - public Response addTree(@Context HttpServletRequest req, UDFTree udfTree){ + @RequestMapping(path = "/tree/add",method = RequestMethod.POST) + public Message addTree(HttpServletRequest req, UDFTree udfTree){ String userName = SecurityFilter.getLoginUsername(req); Message message = null; try { @@ -239,12 +225,11 @@ public Response addTree(@Context HttpServletRequest req, UDFTree udfTree){ message = Message.error(e.getMessage()); } - return Message.messageToResponse(message); + return message; } - @POST - @Path("/tree/update") - public Response updateTree(@Context HttpServletRequest req, UDFTree udfTree){ + @RequestMapping(path = "/tree/update",method = RequestMethod.POST) + public Message updateTree(HttpServletRequest req, UDFTree udfTree){ String userName = SecurityFilter.getLoginUsername(req); Message message = null; try { @@ -258,12 +243,11 @@ public Response updateTree(@Context HttpServletRequest req, UDFTree udfTree){ message = Message.error(e.getMessage()); } - return Message.messageToResponse(message); + return message; } - @GET - @Path("/tree/delete/{id}") - public Response deleteTree(@Context HttpServletRequest req,@PathParam("id") Long id){ + @RequestMapping(path = "/tree/delete/{id}",method = RequestMethod.GET) + public Message deleteTree(HttpServletRequest req,@PathVariable("id") Long id){ String userName = SecurityFilter.getLoginUsername(req); Message message = null; try { @@ -273,12 +257,11 @@ public Response deleteTree(@Context HttpServletRequest req,@PathParam("id") Long logger.error("Failed to delete Tree: ", e); message = Message.error(e.getMessage()); } - return Message.messageToResponse(message); + return message; } - @POST - @Path("/authenticate") - public Response Authenticate(@Context HttpServletRequest req, JsonNode json){ + @RequestMapping(path = "/authenticate",method = RequestMethod.POST) + public Message Authenticate(HttpServletRequest req, JsonNode json){ Message message = null; try { String userName = SecurityFilter.getLoginUsername(req); @@ -292,13 +275,12 @@ public Response Authenticate(@Context HttpServletRequest req, JsonNode json){ logger.error("Failed to authenticate identification: ", e); message = Message.error(e.getMessage()); } - return Message.messageToResponse(message); + return message; } - @POST - @Path("/setExpire") + @RequestMapping(path = "/setExpire",method = RequestMethod.POST) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,rollbackFor = Throwable.class) - public Response setExpire(@Context HttpServletRequest req, JsonNode json){ + public Message setExpire(HttpServletRequest req, JsonNode json){ Message message = null; try { String userName = SecurityFilter.getLoginUsername(req); @@ -330,13 +312,12 @@ public Response setExpire(@Context HttpServletRequest req, JsonNode json){ logger.error("Failed to setExpire: ", e); message = Message.error(e.getMessage()); } - return Message.messageToResponse(message); + return message; } - @POST - @Path("/shareUDF") + @RequestMapping(path = "/shareUDF",method = RequestMethod.POST) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,rollbackFor = Throwable.class) - public Response shareUDF(@Context HttpServletRequest req, JsonNode json)throws Throwable{ + public Message shareUDF(HttpServletRequest req, JsonNode json)throws Throwable{ Message message = null; try { String userName = SecurityFilter.getLoginUsername(req); @@ -382,13 +363,12 @@ public Response shareUDF(@Context HttpServletRequest req, JsonNode json)throws logger.error("Failed to share: ", e); message = Message.error(e.toString()); } - return Message.messageToResponse(message); + return message; } - @POST - @Path("/getSharedUsers") + @RequestMapping(path = "/getSharedUsers",method = RequestMethod.POST) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,rollbackFor = Throwable.class) - public Response getSharedUsers(@Context HttpServletRequest req, JsonNode json){ + public Message getSharedUsers(HttpServletRequest req, JsonNode json){ Message message = null; try { String userName = SecurityFilter.getLoginUsername(req); @@ -406,12 +386,11 @@ public Response getSharedUsers(@Context HttpServletRequest req, JsonNode json){ logger.error("Failed to setExpire: ", e); message = Message.error(e.getMessage()); } - return Message.messageToResponse(message); + return message; } - @POST - @Path("/updateSharedUsers") - public Response updateSharedUsers(@Context HttpServletRequest req, JsonNode json){ + @RequestMapping(path = "/updateSharedUsers",method = RequestMethod.POST) + public Message updateSharedUsers(HttpServletRequest req, JsonNode json){ Message message = null; try { @@ -448,6 +427,6 @@ public Response updateSharedUsers(@Context HttpServletRequest req, JsonNode jso logger.error("Failed to updateSharedUsers: ", e); message = Message.error(e.getMessage()); } - return Message.messageToResponse(message); + return message; } } \ No newline at end of file From 4964833999d61ab094945a6f0cfb1b51c4ca917d Mon Sep 17 00:00:00 2001 From: casionone Date: Sat, 18 Sep 2021 20:34:10 +0800 Subject: [PATCH 11/29] [linkis-message-scheduler] replace jersey with spring web --- .../linkis/rpc/MessageRPCReceiveRestful.scala | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/linkis-commons/linkis-message-scheduler/src/main/scala/com/webank/wedatasphere/linkis/rpc/MessageRPCReceiveRestful.scala b/linkis-commons/linkis-message-scheduler/src/main/scala/com/webank/wedatasphere/linkis/rpc/MessageRPCReceiveRestful.scala index 56331e8d73..8b03336950 100644 --- a/linkis-commons/linkis-message-scheduler/src/main/scala/com/webank/wedatasphere/linkis/rpc/MessageRPCReceiveRestful.scala +++ b/linkis-commons/linkis-message-scheduler/src/main/scala/com/webank/wedatasphere/linkis/rpc/MessageRPCReceiveRestful.scala @@ -24,22 +24,17 @@ import com.webank.wedatasphere.linkis.rpc.transform.{RPCConsumer, RPCProduct} import com.webank.wedatasphere.linkis.server.{Message, catchIt} import javax.annotation.PostConstruct import javax.servlet.http.HttpServletRequest -import javax.ws.rs.core.MediaType -import javax.ws.rs.{Consumes, POST, Path, Produces} import org.apache.commons.lang.StringUtils import org.springframework.beans.factory.annotation.Autowired import org.springframework.context.annotation.{Import, Primary} -import org.springframework.stereotype.Component +import org.springframework.web.bind.annotation.{RequestMapping, RequestMethod, RestController} import org.springframework.web.context.request.{RequestContextHolder, ServletRequestAttributes} import scala.concurrent.duration.Duration import scala.runtime.BoxedUnit - -@Component -@Path("/rpc") -@Produces(Array(MediaType.APPLICATION_JSON)) -@Consumes(Array(MediaType.APPLICATION_JSON)) +@RestController +@RequestMapping(path = Array("/rpc")) @Primary @Import(Array(classOf[MessageRPCConsumer])) class MessageRPCReceiveRestful extends RPCReceiveRestful { @@ -95,8 +90,7 @@ class MessageRPCReceiveRestful extends RPCReceiveRestful { null } - @Path("receive") - @POST + @RequestMapping(path = Array("receive"),method = Array(RequestMethod.POST)) override def receive(message: Message): Message = invokeReceiver(message, _.receive(_, _)) private def invokeReceiver(message: Message, opEvent: (Receiver, Any, Sender) => Message)(implicit req: HttpServletRequest): Message = catchIt { @@ -107,12 +101,10 @@ class MessageRPCReceiveRestful extends RPCReceiveRestful { event.map(opEvent(_, obj, event)).getOrElse(RPCProduct.getRPCProduct.notFound()) } - @Path("receiveAndReply") - @POST + @RequestMapping(path = Array("receiveAndReply"),method =Array(RequestMethod.POST)) override def receiveAndReply(message: Message): Message = invokeReceiver(message, _.receiveAndReply(_, _)) - @Path("replyInMills") - @POST + @RequestMapping(path = Array("replyInMills"),method = Array(RequestMethod.POST)) override def receiveAndReplyInMills(message: Message): Message = catchIt { val duration = message.getData.get("duration") if (duration == null || StringUtils.isEmpty(duration.toString)) throw new DWCURIException(10002, "The timeout period is not set!(超时时间未设置!)") From 892ce69869d6c614f15d8d94b9cbb4bd4283280a Mon Sep 17 00:00:00 2001 From: casionone Date: Sat, 18 Sep 2021 20:34:36 +0800 Subject: [PATCH 12/29] [linkis-resource-manager] replace jersey with spring web --- .../restful/RMMonitorRest.scala | 38 ++++++++----------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/linkis-computation-governance/linkis-manager/linkis-resource-manager/src/main/scala/com/webank/wedatasphere/linkis/resourcemanager/restful/RMMonitorRest.scala b/linkis-computation-governance/linkis-manager/linkis-resource-manager/src/main/scala/com/webank/wedatasphere/linkis/resourcemanager/restful/RMMonitorRest.scala index 2897785f90..c56bcec108 100644 --- a/linkis-computation-governance/linkis-manager/linkis-resource-manager/src/main/scala/com/webank/wedatasphere/linkis/resourcemanager/restful/RMMonitorRest.scala +++ b/linkis-computation-governance/linkis-manager/linkis-resource-manager/src/main/scala/com/webank/wedatasphere/linkis/resourcemanager/restful/RMMonitorRest.scala @@ -46,21 +46,19 @@ import com.webank.wedatasphere.linkis.resourcemanager.utils.{RMConfiguration, RM import com.webank.wedatasphere.linkis.server.{BDPJettyServerHelper, Message} import com.webank.wedatasphere.linkis.server.security.SecurityFilter import javax.servlet.http.HttpServletRequest -import javax.ws.rs.core.{Context, Response} -import javax.ws.rs.{POST, Path} import org.codehaus.jackson.map.ObjectMapper import org.json4s.DefaultFormats import org.json4s.jackson.Serialization.write import org.springframework.beans.factory.annotation.Autowired -import org.springframework.stereotype.Component +import org.springframework.web.bind.annotation.{RequestMapping, RequestMethod, RestController} import scala.collection.JavaConversions._ import scala.collection.mutable import scala.collection.mutable.ArrayBuffer -@Path("/linkisManager/rm") -@Component +@RestController +@RequestMapping(path = Array("/linkisManager/rm")) class RMMonitorRest extends Logging { implicit val formats = DefaultFormats + ResourceSerializer + NodeResourceSerializer @@ -96,9 +94,8 @@ class RMMonitorRest extends Logging { def appendMessageData(message: Message, key: String, value: AnyRef) = message.data(key, mapper.readTree(write(value))) - @POST - @Path("applicationlist") - def getApplicationList(@Context request: HttpServletRequest, param: util.Map[String, AnyRef]): Response = { + @RequestMapping(path =Array("applicationlist"),method = Array(RequestMethod.POST)) + def getApplicationList(request: HttpServletRequest, param: util.Map[String, AnyRef]): Message = { val message = Message.ok("") val userName = SecurityFilter.getLoginUsername(request) val userCreator = param.get("userCreator").asInstanceOf[String] @@ -149,9 +146,8 @@ class RMMonitorRest extends Logging { message } - @POST - @Path("userresources") - def getUserResource(@Context request: HttpServletRequest, param: util.Map[String, AnyRef]): Response = { + @RequestMapping(path = Array("userresources"),method =Array( RequestMethod.POST)) + def getUserResource(request: HttpServletRequest, param: util.Map[String, AnyRef]): Message = { val message = Message.ok("") val userName = SecurityFilter.getLoginUsername(request) var nodes = getEngineNodes(userName, true) @@ -205,9 +201,8 @@ class RMMonitorRest extends Logging { "(" + engineTypeLabel.getEngineType + "," + engineTypeLabel.getVersion + ")" } - @POST - @Path("engines") - def getEngines(@Context request: HttpServletRequest, param: util.Map[String, AnyRef]): Response = { + @RequestMapping(path = Array("engines"),method = Array(RequestMethod.POST)) + def getEngines(request: HttpServletRequest, param: util.Map[String, AnyRef]): Message = { val message = Message.ok("") val userName = SecurityFilter.getLoginUsername(request) val nodes = getEngineNodes(userName, true) @@ -243,9 +238,8 @@ class RMMonitorRest extends Logging { * @param param * @return */ - @POST - @Path("enginekill") - def killEngine(@Context request: HttpServletRequest, param: util.ArrayList[util.Map[String, AnyRef]]): Response = { + @RequestMapping(path = Array("enginekill"),method = Array(RequestMethod.POST)) + def killEngine(request: HttpServletRequest, param: util.ArrayList[util.Map[String, AnyRef]]): Message = { val userName = SecurityFilter.getLoginUsername(request) for (engineParam <- param) { val moduleName = engineParam.get("applicationName").asInstanceOf[String] @@ -259,9 +253,8 @@ class RMMonitorRest extends Logging { } - @POST - @Path("queueresources") - def getQueueResource(@Context request: HttpServletRequest, param: util.Map[String, AnyRef]): Response = { + @RequestMapping(path = Array("queueresources"),method = Array(RequestMethod.POST)) + def getQueueResource(request: HttpServletRequest, param: util.Map[String, AnyRef]): Message = { val message = Message.ok("") val yarnIdentifier = new YarnResourceIdentifier(param.get("queuename").asInstanceOf[String]) val clusterLabel = labelFactory.createLabel(classOf[ClusterLabel]) @@ -375,9 +368,8 @@ class RMMonitorRest extends Logging { }.filter(_ != null).toArray } - @POST - @Path("queues") - def getQueues(@Context request: HttpServletRequest, param: util.Map[String, AnyRef]): Response = { + @RequestMapping(path = Array("queues"),method =Array(RequestMethod.POST)) + def getQueues(request: HttpServletRequest, param: util.Map[String, AnyRef]): Message = { val message = Message.ok() val userName = SecurityFilter.getLoginUsername(request) val clusters = new mutable.ArrayBuffer[Any]() From 2b47e891f83a0317ffe1458a5887c4e6b1f59dbc Mon Sep 17 00:00:00 2001 From: casionone Date: Sat, 18 Sep 2021 20:34:55 +0800 Subject: [PATCH 13/29] [linkis-rpc] replace jersey with spring web --- .../linkis/rpc/RPCReceiveRestful.scala | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/RPCReceiveRestful.scala b/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/RPCReceiveRestful.scala index 11e014db09..b5dd971381 100644 --- a/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/RPCReceiveRestful.scala +++ b/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/RPCReceiveRestful.scala @@ -25,20 +25,15 @@ import com.webank.wedatasphere.linkis.rpc.exception.DWCURIException import com.webank.wedatasphere.linkis.rpc.transform.{RPCConsumer, RPCProduct} import com.webank.wedatasphere.linkis.server.{Message, catchIt} import javax.annotation.PostConstruct -import javax.ws.rs.core.MediaType -import javax.ws.rs.{Consumes, POST, Path, Produces} import org.apache.commons.lang.StringUtils import org.springframework.beans.factory.annotation.Autowired -import org.springframework.stereotype.Component +import org.springframework.web.bind.annotation.{RequestMapping, RequestMethod, RestController} import scala.concurrent.duration.Duration import scala.runtime.BoxedUnit - -@Component -@Path("/rpc") -@Produces(Array(MediaType.APPLICATION_JSON)) -@Consumes(Array(MediaType.APPLICATION_JSON)) +@RestController +@RequestMapping(path = Array("/rpc")) private[rpc] class RPCReceiveRestful extends RPCReceiveRemote with Logging { @Autowired(required = false) @@ -117,8 +112,7 @@ private[rpc] class RPCReceiveRestful extends RPCReceiveRemote with Logging { RPCProduct.getRPCProduct.toMessage(obj) } - @Path("receive") - @POST + @RequestMapping(path = Array("receive"),method = Array(RequestMethod.POST)) override def receive(message: Message): Message = catchIt { val obj = RPCConsumer.getRPCConsumer.toObject(message) val event = RPCMessageEvent(obj, BaseRPCSender.getInstanceInfo(message.getData)) @@ -132,12 +126,10 @@ private[rpc] class RPCReceiveRestful extends RPCReceiveRemote with Logging { event.map(opEvent(_, obj, event)).getOrElse(RPCProduct.getRPCProduct.notFound()) } - @Path("receiveAndReply") - @POST + @RequestMapping(path = Array("receiveAndReply"),method = Array(RequestMethod.POST)) override def receiveAndReply(message: Message): Message = receiveAndReply(message, _.receiveAndReply(_, _)) - @Path("replyInMills") - @POST + @RequestMapping(path = Array("replyInMills"),method = Array(RequestMethod.POST)) override def receiveAndReplyInMills(message: Message): Message = catchIt { val duration = message.getData.get("duration") if(duration == null || StringUtils.isEmpty(duration.toString)) throw new DWCURIException(10002, "The timeout period is not set!(超时时间未设置!)") From 1f894c4dd8ee11509b5c00daee1c99268a7385b2 Mon Sep 17 00:00:00 2001 From: casionxia Date: Thu, 23 Sep 2021 09:37:03 +0800 Subject: [PATCH 14/29] upgrade version to 1.0.3 --- assembly-combined-package/assembly-combined/pom.xml | 2 +- .../assembly-combined/public-module-combined/pom.xml | 2 +- assembly-combined-package/pom.xml | 2 +- linkis-commons/linkis-common/pom.xml | 2 +- linkis-commons/linkis-hadoop-common/pom.xml | 2 +- linkis-commons/linkis-httpclient/pom.xml | 2 +- linkis-commons/linkis-message-scheduler/pom.xml | 2 +- linkis-commons/linkis-module/pom.xml | 2 +- linkis-commons/linkis-mybatis/pom.xml | 2 +- linkis-commons/linkis-protocol/pom.xml | 2 +- linkis-commons/linkis-rpc/pom.xml | 2 +- linkis-commons/linkis-scheduler/pom.xml | 2 +- linkis-commons/linkis-storage/pom.xml | 2 +- linkis-commons/pom.xml | 2 +- .../linkis-cli/linkis-cli-application/pom.xml | 2 +- .../linkis-client/linkis-cli/linkis-cli-common/pom.xml | 2 +- .../linkis-client/linkis-cli/linkis-cli-core/pom.xml | 2 +- .../linkis-client/linkis-cli/pom.xml | 2 +- .../linkis-client/linkis-computation-client/pom.xml | 2 +- .../linkis-computation-governance-common/pom.xml | 2 +- .../linkis-engineconn-linux-launch/pom.xml | 2 +- .../linkis-engineconn-manager-core/pom.xml | 2 +- .../linkis-engineconn-manager-server/pom.xml | 2 +- .../linkis-engineconn-manager/pom.xml | 2 +- .../linkis-once-engineconn/pom.xml | 3 +-- .../linkis-streaming-engineconn/pom.xml | 3 +-- .../linkis-computation-engineconn/pom.xml | 2 +- .../linkis-engineconn/linkis-engineconn-common/pom.xml | 2 +- .../linkis-engineconn/linkis-engineconn-core/pom.xml | 2 +- .../accessible-executor/pom.xml | 2 +- .../linkis-engineconn-executor/callback-service/pom.xml | 3 +-- .../linkis-engineconn-executor/executor-core/pom.xml | 3 +-- .../linkis-engineconn-executor/resource-executor/pom.xml | 3 +-- .../linkis-engineconn/linkis-engineconn-launch/pom.xml | 2 +- linkis-computation-governance/linkis-engineconn/pom.xml | 2 +- .../linkis-entrance-client/pom.xml | 2 +- linkis-computation-governance/linkis-entrance/pom.xml | 2 +- linkis-computation-governance/linkis-jdbc-driver/pom.xml | 2 +- .../linkis-manager/label-common/pom.xml | 2 +- .../linkis-manager/label-manager/pom.xml | 2 +- .../linkis-manager/linkis-application-manager/pom.xml | 2 +- .../linkis-manager/linkis-manager-client/pom.xml | 2 +- .../linkis-manager-commons/linkis-manager-common/pom.xml | 2 +- .../linkis-manager-service-common/pom.xml | 2 +- .../linkis-resource-manager-common/pom.xml | 2 +- .../linkis-manager/linkis-manager-monitor/pom.xml | 2 +- .../linkis-manager/linkis-manager-persistence/pom.xml | 2 +- .../linkis-manager/linkis-resource-manager/pom.xml | 2 +- linkis-computation-governance/linkis-manager/pom.xml | 2 +- linkis-computation-governance/pom.xml | 2 +- .../engineconn-plugins/flink/pom.xml | 2 +- linkis-engineconn-plugins/engineconn-plugins/hive/pom.xml | 2 +- .../engineconn-plugins/io_file/pom.xml | 2 +- linkis-engineconn-plugins/engineconn-plugins/jdbc/pom.xml | 2 +- .../engineconn-plugins/pipeline/pom.xml | 2 +- .../engineconn-plugins/python/pom.xml | 2 +- .../engineconn-plugins/shell/pom.xml | 2 +- .../engineconn-plugins/spark/pom.xml | 2 +- .../linkis-engineconn-plugin-cache/pom.xml | 2 +- .../linkis-engineconn-plugin-core/pom.xml | 2 +- .../linkis-engineconn-plugin-loader/pom.xml | 2 +- .../linkis-engineconn-plugin-server/pom.xml | 2 +- linkis-engineconn-plugins/pom.xml | 2 +- linkis-extensions/linkis-io-file-client/pom.xml | 2 +- linkis-extensions/pom.xml | 2 +- linkis-orchestrator/linkis-code-orchestrator/pom.xml | 2 +- .../linkis-computation-orchestrator/pom.xml | 2 +- linkis-orchestrator/linkis-orchestrator-core/pom.xml | 2 +- .../plugin/linkis-orchestrator-ecm-plugin/pom.xml | 2 +- linkis-orchestrator/pom.xml | 2 +- .../linkis-bml/linkis-bml-client/pom.xml | 2 +- .../linkis-bml/linkis-bml-common/pom.xml | 2 +- .../linkis-bml/linkis-bml-engine-hook/pom.xml | 2 +- .../linkis-bml/linkis-bml-server/pom.xml | 2 +- linkis-public-enhancements/linkis-bml/pom.xml | 2 +- .../linkis-context-service/linkis-cs-cache/pom.xml | 2 +- .../linkis-context-service/linkis-cs-client/pom.xml | 2 +- .../linkis-context-service/linkis-cs-common/pom.xml | 2 +- .../linkis-cs-engine-support/pom.xml | 2 +- .../linkis-cs-highavailable/pom.xml | 2 +- .../linkis-context-service/linkis-cs-listener/pom.xml | 4 ++-- .../linkis-context-service/linkis-cs-persistence/pom.xml | 2 +- .../linkis-context-service/linkis-cs-search/pom.xml | 2 +- .../linkis-context-service/linkis-cs-server/pom.xml | 2 +- linkis-public-enhancements/linkis-context-service/pom.xml | 2 +- .../linkis-datasource/datasourcemanager/common/pom.xml | 8 ++++---- .../linkis-datasource/datasourcemanager/server/pom.xml | 8 ++++---- .../linkis-datasource/linkis-metadata/pom.xml | 2 +- .../linkis-datasource/metadatamanager/common/pom.xml | 2 +- .../linkis-datasource/metadatamanager/server/pom.xml | 8 ++++---- .../metadatamanager/service/elasticsearch/pom.xml | 8 ++++---- .../metadatamanager/service/hive/pom.xml | 8 ++++---- .../metadatamanager/service/mysql/pom.xml | 2 +- .../linkis-publicservice/linkis-configuration/pom.xml | 2 +- .../linkis-error-code/linkis-error-code-client/pom.xml | 2 +- .../linkis-error-code/linkis-error-code-common/pom.xml | 2 +- .../linkis-error-code/linkis-error-code-server/pom.xml | 2 +- .../linkis-publicservice/linkis-error-code/pom.xml | 2 +- .../linkis-instance-label-client/pom.xml | 2 +- .../linkis-instance-label-server/pom.xml | 2 +- .../linkis-publicservice/linkis-jobhistory/pom.xml | 2 +- .../linkis-storage-script-dev-client/pom.xml | 2 +- .../linkis-storage-script-dev-server/pom.xml | 2 +- .../linkis-udf/linkis-udf-client/pom.xml | 2 +- .../linkis-udf/linkis-udf-common/pom.xml | 2 +- .../linkis-udf/linkis-udf-service/pom.xml | 2 +- .../linkis-publicservice/linkis-variable/pom.xml | 2 +- linkis-public-enhancements/linkis-publicservice/pom.xml | 2 +- linkis-public-enhancements/pom.xml | 2 +- .../linkis-service-discovery/linkis-eureka/pom.xml | 2 +- .../linkis-service-gateway/linkis-gateway-core/pom.xml | 2 +- .../linkis-gateway-httpclient-support/pom.xml | 2 +- .../linkis-gateway-server-support/pom.xml | 2 +- .../linkis-spring-cloud-gateway/pom.xml | 2 +- .../plugins/linkis-gateway-datasource-ruler/pom.xml | 2 +- .../linkis-service-gateway/pom.xml | 2 +- linkis-spring-cloud-services/pom.xml | 2 +- pom.xml | 4 ++-- 118 files changed, 135 insertions(+), 140 deletions(-) diff --git a/assembly-combined-package/assembly-combined/pom.xml b/assembly-combined-package/assembly-combined/pom.xml index 0d34df37fd..1878716631 100644 --- a/assembly-combined-package/assembly-combined/pom.xml +++ b/assembly-combined-package/assembly-combined/pom.xml @@ -18,7 +18,7 @@ com.webank.wedatasphere.linkis linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/assembly-combined-package/assembly-combined/public-module-combined/pom.xml b/assembly-combined-package/assembly-combined/public-module-combined/pom.xml index aad9ba2925..6585f501f2 100644 --- a/assembly-combined-package/assembly-combined/public-module-combined/pom.xml +++ b/assembly-combined-package/assembly-combined/public-module-combined/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/assembly-combined-package/pom.xml b/assembly-combined-package/pom.xml index 031d5d5cd2..eb90fda7b6 100644 --- a/assembly-combined-package/pom.xml +++ b/assembly-combined-package/pom.xml @@ -18,7 +18,7 @@ com.webank.wedatasphere.linkis linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-commons/linkis-common/pom.xml b/linkis-commons/linkis-common/pom.xml index cafab8d346..50baf78119 100644 --- a/linkis-commons/linkis-common/pom.xml +++ b/linkis-commons/linkis-common/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-commons/linkis-hadoop-common/pom.xml b/linkis-commons/linkis-hadoop-common/pom.xml index f47dcbd75f..e006fd7ecf 100644 --- a/linkis-commons/linkis-hadoop-common/pom.xml +++ b/linkis-commons/linkis-hadoop-common/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-commons/linkis-httpclient/pom.xml b/linkis-commons/linkis-httpclient/pom.xml index 28cd2a7afb..741818b6c6 100644 --- a/linkis-commons/linkis-httpclient/pom.xml +++ b/linkis-commons/linkis-httpclient/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-commons/linkis-message-scheduler/pom.xml b/linkis-commons/linkis-message-scheduler/pom.xml index 1fd75b9d22..1e110cddaf 100644 --- a/linkis-commons/linkis-message-scheduler/pom.xml +++ b/linkis-commons/linkis-message-scheduler/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-commons/linkis-module/pom.xml b/linkis-commons/linkis-module/pom.xml index 98f30b4efa..4054626d86 100644 --- a/linkis-commons/linkis-module/pom.xml +++ b/linkis-commons/linkis-module/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-commons/linkis-mybatis/pom.xml b/linkis-commons/linkis-mybatis/pom.xml index 54197d76a7..d2500c6454 100644 --- a/linkis-commons/linkis-mybatis/pom.xml +++ b/linkis-commons/linkis-mybatis/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-commons/linkis-protocol/pom.xml b/linkis-commons/linkis-protocol/pom.xml index f40f69b9b5..77f7c05cf7 100644 --- a/linkis-commons/linkis-protocol/pom.xml +++ b/linkis-commons/linkis-protocol/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-commons/linkis-rpc/pom.xml b/linkis-commons/linkis-rpc/pom.xml index 28bd73a03e..77b1ab9384 100644 --- a/linkis-commons/linkis-rpc/pom.xml +++ b/linkis-commons/linkis-rpc/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-commons/linkis-scheduler/pom.xml b/linkis-commons/linkis-scheduler/pom.xml index 2bcb34a9c1..2f78df67b6 100644 --- a/linkis-commons/linkis-scheduler/pom.xml +++ b/linkis-commons/linkis-scheduler/pom.xml @@ -19,7 +19,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 linkis-scheduler diff --git a/linkis-commons/linkis-storage/pom.xml b/linkis-commons/linkis-storage/pom.xml index f2b2836265..610d3ceabf 100644 --- a/linkis-commons/linkis-storage/pom.xml +++ b/linkis-commons/linkis-storage/pom.xml @@ -18,9 +18,9 @@ 4.0.0 - 1.0.2 com.webank.wedatasphere.linkis linkis + 1.0.3 diff --git a/linkis-commons/pom.xml b/linkis-commons/pom.xml index c767823a23..a44414a528 100644 --- a/linkis-commons/pom.xml +++ b/linkis-commons/pom.xml @@ -5,7 +5,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/pom.xml b/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/pom.xml index 336f18dc92..590c95b339 100644 --- a/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/pom.xml +++ b/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/pom.xml @@ -23,7 +23,7 @@ com.webank.wedatasphere.linkis linkis-cli - 1.0.2 + 1.0.3 ../pom.xml linkis-cli-application diff --git a/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-common/pom.xml b/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-common/pom.xml index 6d7334fc5b..213f0ea20d 100644 --- a/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-common/pom.xml +++ b/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-common/pom.xml @@ -23,7 +23,7 @@ com.webank.wedatasphere.linkis linkis-cli - 1.0.2 + 1.0.3 ../pom.xml linkis-cli-common diff --git a/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-core/pom.xml b/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-core/pom.xml index deb91846ed..e3839814c3 100644 --- a/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-core/pom.xml +++ b/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-core/pom.xml @@ -23,7 +23,7 @@ com.webank.wedatasphere.linkis linkis-cli - 1.0.2 + 1.0.3 ../pom.xml linkis-cli-core diff --git a/linkis-computation-governance/linkis-client/linkis-cli/pom.xml b/linkis-computation-governance/linkis-client/linkis-cli/pom.xml index 0c461d9b21..dff311cfc1 100644 --- a/linkis-computation-governance/linkis-client/linkis-cli/pom.xml +++ b/linkis-computation-governance/linkis-client/linkis-cli/pom.xml @@ -23,7 +23,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 linkis-cli pom diff --git a/linkis-computation-governance/linkis-client/linkis-computation-client/pom.xml b/linkis-computation-governance/linkis-client/linkis-computation-client/pom.xml index c52a8ce9d9..d32a970fa9 100644 --- a/linkis-computation-governance/linkis-client/linkis-computation-client/pom.xml +++ b/linkis-computation-governance/linkis-client/linkis-computation-client/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 linkis-computation-client diff --git a/linkis-computation-governance/linkis-computation-governance-common/pom.xml b/linkis-computation-governance/linkis-computation-governance-common/pom.xml index 2a2c4f66df..db0c006f6d 100644 --- a/linkis-computation-governance/linkis-computation-governance-common/pom.xml +++ b/linkis-computation-governance/linkis-computation-governance-common/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-linux-launch/pom.xml b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-linux-launch/pom.xml index 12588d2e4d..e14a4dfb66 100644 --- a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-linux-launch/pom.xml +++ b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-linux-launch/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../../pom.xml 4.0.0 diff --git a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/pom.xml b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/pom.xml index b3391c0fd9..261686305e 100644 --- a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/pom.xml +++ b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-core/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/pom.xml b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/pom.xml index 1553b592e3..e2458f7771 100644 --- a/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/pom.xml +++ b/linkis-computation-governance/linkis-engineconn-manager/linkis-engineconn-manager-server/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-computation-governance/linkis-engineconn-manager/pom.xml b/linkis-computation-governance/linkis-engineconn-manager/pom.xml index 4707b28557..4451b3d491 100644 --- a/linkis-computation-governance/linkis-engineconn-manager/pom.xml +++ b/linkis-computation-governance/linkis-engineconn-manager/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-computation-governance/linkis-engineconn/linkis-clustered-engineconn/linkis-once-engineconn/pom.xml b/linkis-computation-governance/linkis-engineconn/linkis-clustered-engineconn/linkis-once-engineconn/pom.xml index 4770b53b5b..a6ee388ea5 100644 --- a/linkis-computation-governance/linkis-engineconn/linkis-clustered-engineconn/linkis-once-engineconn/pom.xml +++ b/linkis-computation-governance/linkis-engineconn/linkis-clustered-engineconn/linkis-once-engineconn/pom.xml @@ -20,8 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 - + 1.0.3 4.0.0 diff --git a/linkis-computation-governance/linkis-engineconn/linkis-clustered-engineconn/linkis-streaming-engineconn/pom.xml b/linkis-computation-governance/linkis-engineconn/linkis-clustered-engineconn/linkis-streaming-engineconn/pom.xml index 22818fe565..f8850568bb 100644 --- a/linkis-computation-governance/linkis-engineconn/linkis-clustered-engineconn/linkis-streaming-engineconn/pom.xml +++ b/linkis-computation-governance/linkis-engineconn/linkis-clustered-engineconn/linkis-streaming-engineconn/pom.xml @@ -20,8 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 - + 1.0.3 4.0.0 diff --git a/linkis-computation-governance/linkis-engineconn/linkis-computation-engineconn/pom.xml b/linkis-computation-governance/linkis-engineconn/linkis-computation-engineconn/pom.xml index 8058494dde..5c81d72337 100644 --- a/linkis-computation-governance/linkis-engineconn/linkis-computation-engineconn/pom.xml +++ b/linkis-computation-governance/linkis-engineconn/linkis-computation-engineconn/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-common/pom.xml b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-common/pom.xml index b9744982e5..c5f3215430 100644 --- a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-common/pom.xml +++ b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-common/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../../pom.xml 4.0.0 diff --git a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-core/pom.xml b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-core/pom.xml index a351336658..a34f5b4df8 100644 --- a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-core/pom.xml +++ b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-core/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../../pom.xml 4.0.0 diff --git a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/accessible-executor/pom.xml b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/accessible-executor/pom.xml index 61223f492a..f12fd0dc02 100644 --- a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/accessible-executor/pom.xml +++ b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/accessible-executor/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../../pom.xml 4.0.0 diff --git a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/callback-service/pom.xml b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/callback-service/pom.xml index 7cd18d25c4..12d31c4c2b 100644 --- a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/callback-service/pom.xml +++ b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/callback-service/pom.xml @@ -21,8 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 - + 1.0.3 4.0.0 diff --git a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/executor-core/pom.xml b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/executor-core/pom.xml index 1694149f64..3ab594d4ee 100644 --- a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/executor-core/pom.xml +++ b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/executor-core/pom.xml @@ -21,8 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 - + 1.0.3 4.0.0 diff --git a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/resource-executor/pom.xml b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/resource-executor/pom.xml index ba507145df..3861f4cefa 100644 --- a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/resource-executor/pom.xml +++ b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/resource-executor/pom.xml @@ -21,8 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 - + 1.0.3 4.0.0 diff --git a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-launch/pom.xml b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-launch/pom.xml index 0c1a11b0f0..0db957b8f5 100644 --- a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-launch/pom.xml +++ b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-launch/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../../pom.xml 4.0.0 diff --git a/linkis-computation-governance/linkis-engineconn/pom.xml b/linkis-computation-governance/linkis-engineconn/pom.xml index 533f47bca5..df1e9e9b06 100644 --- a/linkis-computation-governance/linkis-engineconn/pom.xml +++ b/linkis-computation-governance/linkis-engineconn/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-computation-governance/linkis-entrance-client/pom.xml b/linkis-computation-governance/linkis-entrance-client/pom.xml index f8917782c3..c29c000114 100644 --- a/linkis-computation-governance/linkis-entrance-client/pom.xml +++ b/linkis-computation-governance/linkis-entrance-client/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 linkis-entrance-client diff --git a/linkis-computation-governance/linkis-entrance/pom.xml b/linkis-computation-governance/linkis-entrance/pom.xml index 06a58b5599..5e94494bd3 100644 --- a/linkis-computation-governance/linkis-entrance/pom.xml +++ b/linkis-computation-governance/linkis-entrance/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 linkis-entrance diff --git a/linkis-computation-governance/linkis-jdbc-driver/pom.xml b/linkis-computation-governance/linkis-jdbc-driver/pom.xml index 0a385edcdc..fe31ca4416 100644 --- a/linkis-computation-governance/linkis-jdbc-driver/pom.xml +++ b/linkis-computation-governance/linkis-jdbc-driver/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 linkis-jdbc-driver diff --git a/linkis-computation-governance/linkis-manager/label-common/pom.xml b/linkis-computation-governance/linkis-manager/label-common/pom.xml index 09e20208c3..29992090e7 100644 --- a/linkis-computation-governance/linkis-manager/label-common/pom.xml +++ b/linkis-computation-governance/linkis-manager/label-common/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-computation-governance/linkis-manager/label-manager/pom.xml b/linkis-computation-governance/linkis-manager/label-manager/pom.xml index 07771e9561..222dc3f2ab 100644 --- a/linkis-computation-governance/linkis-manager/label-manager/pom.xml +++ b/linkis-computation-governance/linkis-manager/label-manager/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-computation-governance/linkis-manager/linkis-application-manager/pom.xml b/linkis-computation-governance/linkis-manager/linkis-application-manager/pom.xml index 3178dbf940..88f009548c 100644 --- a/linkis-computation-governance/linkis-manager/linkis-application-manager/pom.xml +++ b/linkis-computation-governance/linkis-manager/linkis-application-manager/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../pom.xml 4.0.0 diff --git a/linkis-computation-governance/linkis-manager/linkis-manager-client/pom.xml b/linkis-computation-governance/linkis-manager/linkis-manager-client/pom.xml index 920e81896a..c53667b582 100644 --- a/linkis-computation-governance/linkis-manager/linkis-manager-client/pom.xml +++ b/linkis-computation-governance/linkis-manager/linkis-manager-client/pom.xml @@ -17,7 +17,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - 1.0.2 + 1.0.3 com.webank.wedatasphere.linkis linkis diff --git a/linkis-computation-governance/linkis-manager/linkis-manager-commons/linkis-manager-common/pom.xml b/linkis-computation-governance/linkis-manager/linkis-manager-commons/linkis-manager-common/pom.xml index 7b332a4a01..5c62d67573 100644 --- a/linkis-computation-governance/linkis-manager/linkis-manager-commons/linkis-manager-common/pom.xml +++ b/linkis-computation-governance/linkis-manager/linkis-manager-commons/linkis-manager-common/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-computation-governance/linkis-manager/linkis-manager-commons/linkis-manager-service-common/pom.xml b/linkis-computation-governance/linkis-manager/linkis-manager-commons/linkis-manager-service-common/pom.xml index 13848183df..1991ea31c4 100644 --- a/linkis-computation-governance/linkis-manager/linkis-manager-commons/linkis-manager-service-common/pom.xml +++ b/linkis-computation-governance/linkis-manager/linkis-manager-commons/linkis-manager-service-common/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-computation-governance/linkis-manager/linkis-manager-commons/linkis-resource-manager-common/pom.xml b/linkis-computation-governance/linkis-manager/linkis-manager-commons/linkis-resource-manager-common/pom.xml index 8bd62b475a..bdac2439d6 100644 --- a/linkis-computation-governance/linkis-manager/linkis-manager-commons/linkis-resource-manager-common/pom.xml +++ b/linkis-computation-governance/linkis-manager/linkis-manager-commons/linkis-resource-manager-common/pom.xml @@ -18,7 +18,7 @@ 4.0.0 - 1.0.2 + 1.0.3 com.webank.wedatasphere.linkis linkis diff --git a/linkis-computation-governance/linkis-manager/linkis-manager-monitor/pom.xml b/linkis-computation-governance/linkis-manager/linkis-manager-monitor/pom.xml index 63f01635eb..79046d99ff 100644 --- a/linkis-computation-governance/linkis-manager/linkis-manager-monitor/pom.xml +++ b/linkis-computation-governance/linkis-manager/linkis-manager-monitor/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-computation-governance/linkis-manager/linkis-manager-persistence/pom.xml b/linkis-computation-governance/linkis-manager/linkis-manager-persistence/pom.xml index d4efaf34b9..08a9f03699 100644 --- a/linkis-computation-governance/linkis-manager/linkis-manager-persistence/pom.xml +++ b/linkis-computation-governance/linkis-manager/linkis-manager-persistence/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-computation-governance/linkis-manager/linkis-resource-manager/pom.xml b/linkis-computation-governance/linkis-manager/linkis-resource-manager/pom.xml index b543b80805..496ffbd311 100644 --- a/linkis-computation-governance/linkis-manager/linkis-resource-manager/pom.xml +++ b/linkis-computation-governance/linkis-manager/linkis-resource-manager/pom.xml @@ -18,7 +18,7 @@ 4.0.0 - 1.0.2 + 1.0.3 com.webank.wedatasphere.linkis linkis diff --git a/linkis-computation-governance/linkis-manager/pom.xml b/linkis-computation-governance/linkis-manager/pom.xml index 00fcc7991e..4f01f939de 100644 --- a/linkis-computation-governance/linkis-manager/pom.xml +++ b/linkis-computation-governance/linkis-manager/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-computation-governance/pom.xml b/linkis-computation-governance/pom.xml index 99cd6f3cd1..f04d80572e 100644 --- a/linkis-computation-governance/pom.xml +++ b/linkis-computation-governance/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-engineconn-plugins/engineconn-plugins/flink/pom.xml b/linkis-engineconn-plugins/engineconn-plugins/flink/pom.xml index 003eacc22c..516667092c 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/flink/pom.xml +++ b/linkis-engineconn-plugins/engineconn-plugins/flink/pom.xml @@ -20,7 +20,7 @@ linkis-engineconn-plugins com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-engineconn-plugins/engineconn-plugins/hive/pom.xml b/linkis-engineconn-plugins/engineconn-plugins/hive/pom.xml index 83636b0476..3a0ec05aba 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/hive/pom.xml +++ b/linkis-engineconn-plugins/engineconn-plugins/hive/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../../pom.xml 4.0.0 diff --git a/linkis-engineconn-plugins/engineconn-plugins/io_file/pom.xml b/linkis-engineconn-plugins/engineconn-plugins/io_file/pom.xml index c9c5cf4a04..3eb35e6cdb 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/io_file/pom.xml +++ b/linkis-engineconn-plugins/engineconn-plugins/io_file/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../../pom.xml 4.0.0 diff --git a/linkis-engineconn-plugins/engineconn-plugins/jdbc/pom.xml b/linkis-engineconn-plugins/engineconn-plugins/jdbc/pom.xml index 1351ac8d5a..dc194ec499 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/jdbc/pom.xml +++ b/linkis-engineconn-plugins/engineconn-plugins/jdbc/pom.xml @@ -22,7 +22,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../../pom.xml 4.0.0 diff --git a/linkis-engineconn-plugins/engineconn-plugins/pipeline/pom.xml b/linkis-engineconn-plugins/engineconn-plugins/pipeline/pom.xml index 0e99a504f0..b930739047 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/pipeline/pom.xml +++ b/linkis-engineconn-plugins/engineconn-plugins/pipeline/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../../pom.xml 4.0.0 diff --git a/linkis-engineconn-plugins/engineconn-plugins/python/pom.xml b/linkis-engineconn-plugins/engineconn-plugins/python/pom.xml index 7d4ebd4712..40903447db 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/python/pom.xml +++ b/linkis-engineconn-plugins/engineconn-plugins/python/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../../pom.xml 4.0.0 diff --git a/linkis-engineconn-plugins/engineconn-plugins/shell/pom.xml b/linkis-engineconn-plugins/engineconn-plugins/shell/pom.xml index 5f05580ddd..e98b19261e 100755 --- a/linkis-engineconn-plugins/engineconn-plugins/shell/pom.xml +++ b/linkis-engineconn-plugins/engineconn-plugins/shell/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-engineconn-plugins/engineconn-plugins/spark/pom.xml b/linkis-engineconn-plugins/engineconn-plugins/spark/pom.xml index 346e3eb5df..10678555db 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/spark/pom.xml +++ b/linkis-engineconn-plugins/engineconn-plugins/spark/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../../pom.xml 4.0.0 diff --git a/linkis-engineconn-plugins/linkis-engineconn-plugin-framework/linkis-engineconn-plugin-cache/pom.xml b/linkis-engineconn-plugins/linkis-engineconn-plugin-framework/linkis-engineconn-plugin-cache/pom.xml index 1476fe6dea..b5b4843f8a 100644 --- a/linkis-engineconn-plugins/linkis-engineconn-plugin-framework/linkis-engineconn-plugin-cache/pom.xml +++ b/linkis-engineconn-plugins/linkis-engineconn-plugin-framework/linkis-engineconn-plugin-cache/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-engineconn-plugins/linkis-engineconn-plugin-framework/linkis-engineconn-plugin-core/pom.xml b/linkis-engineconn-plugins/linkis-engineconn-plugin-framework/linkis-engineconn-plugin-core/pom.xml index 5d621d9cc5..c368b24da0 100644 --- a/linkis-engineconn-plugins/linkis-engineconn-plugin-framework/linkis-engineconn-plugin-core/pom.xml +++ b/linkis-engineconn-plugins/linkis-engineconn-plugin-framework/linkis-engineconn-plugin-core/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-engineconn-plugins/linkis-engineconn-plugin-framework/linkis-engineconn-plugin-loader/pom.xml b/linkis-engineconn-plugins/linkis-engineconn-plugin-framework/linkis-engineconn-plugin-loader/pom.xml index 13cc3fdf0e..e657144e86 100644 --- a/linkis-engineconn-plugins/linkis-engineconn-plugin-framework/linkis-engineconn-plugin-loader/pom.xml +++ b/linkis-engineconn-plugins/linkis-engineconn-plugin-framework/linkis-engineconn-plugin-loader/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-engineconn-plugins/linkis-engineconn-plugin-framework/linkis-engineconn-plugin-server/pom.xml b/linkis-engineconn-plugins/linkis-engineconn-plugin-framework/linkis-engineconn-plugin-server/pom.xml index f5e89cf2c3..6872e5d61a 100644 --- a/linkis-engineconn-plugins/linkis-engineconn-plugin-framework/linkis-engineconn-plugin-server/pom.xml +++ b/linkis-engineconn-plugins/linkis-engineconn-plugin-framework/linkis-engineconn-plugin-server/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../../pom.xml 4.0.0 diff --git a/linkis-engineconn-plugins/pom.xml b/linkis-engineconn-plugins/pom.xml index 2dbb21ef88..1542a8e2ed 100644 --- a/linkis-engineconn-plugins/pom.xml +++ b/linkis-engineconn-plugins/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-extensions/linkis-io-file-client/pom.xml b/linkis-extensions/linkis-io-file-client/pom.xml index 17f475e6c2..b5866289ed 100644 --- a/linkis-extensions/linkis-io-file-client/pom.xml +++ b/linkis-extensions/linkis-io-file-client/pom.xml @@ -17,7 +17,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - 1.0.2 + 1.0.3 com.webank.wedatasphere.linkis linkis ../../pom.xml diff --git a/linkis-extensions/pom.xml b/linkis-extensions/pom.xml index dd432d3edb..9fd4baa5cc 100644 --- a/linkis-extensions/pom.xml +++ b/linkis-extensions/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-orchestrator/linkis-code-orchestrator/pom.xml b/linkis-orchestrator/linkis-code-orchestrator/pom.xml index 1d21f88bef..b7f94eba25 100644 --- a/linkis-orchestrator/linkis-code-orchestrator/pom.xml +++ b/linkis-orchestrator/linkis-code-orchestrator/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-orchestrator/linkis-computation-orchestrator/pom.xml b/linkis-orchestrator/linkis-computation-orchestrator/pom.xml index 2fe3b0a849..9c2fe10529 100644 --- a/linkis-orchestrator/linkis-computation-orchestrator/pom.xml +++ b/linkis-orchestrator/linkis-computation-orchestrator/pom.xml @@ -22,7 +22,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-orchestrator/linkis-orchestrator-core/pom.xml b/linkis-orchestrator/linkis-orchestrator-core/pom.xml index 4ef70f4723..ed36a938bf 100644 --- a/linkis-orchestrator/linkis-orchestrator-core/pom.xml +++ b/linkis-orchestrator/linkis-orchestrator-core/pom.xml @@ -21,7 +21,7 @@ linkis-orchestrator com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-orchestrator/plugin/linkis-orchestrator-ecm-plugin/pom.xml b/linkis-orchestrator/plugin/linkis-orchestrator-ecm-plugin/pom.xml index c94c2a835a..21c0c1584b 100644 --- a/linkis-orchestrator/plugin/linkis-orchestrator-ecm-plugin/pom.xml +++ b/linkis-orchestrator/plugin/linkis-orchestrator-ecm-plugin/pom.xml @@ -21,7 +21,7 @@ linkis-orchestrator com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-orchestrator/pom.xml b/linkis-orchestrator/pom.xml index 732dd839d5..21a9de939d 100644 --- a/linkis-orchestrator/pom.xml +++ b/linkis-orchestrator/pom.xml @@ -5,7 +5,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-public-enhancements/linkis-bml/linkis-bml-client/pom.xml b/linkis-public-enhancements/linkis-bml/linkis-bml-client/pom.xml index 3621befff5..13410df160 100644 --- a/linkis-public-enhancements/linkis-bml/linkis-bml-client/pom.xml +++ b/linkis-public-enhancements/linkis-bml/linkis-bml-client/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-public-enhancements/linkis-bml/linkis-bml-common/pom.xml b/linkis-public-enhancements/linkis-bml/linkis-bml-common/pom.xml index 11c9ee91ed..677db0a19c 100644 --- a/linkis-public-enhancements/linkis-bml/linkis-bml-common/pom.xml +++ b/linkis-public-enhancements/linkis-bml/linkis-bml-common/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-public-enhancements/linkis-bml/linkis-bml-engine-hook/pom.xml b/linkis-public-enhancements/linkis-bml/linkis-bml-engine-hook/pom.xml index 98aed697a9..73232c17d0 100644 --- a/linkis-public-enhancements/linkis-bml/linkis-bml-engine-hook/pom.xml +++ b/linkis-public-enhancements/linkis-bml/linkis-bml-engine-hook/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-public-enhancements/linkis-bml/linkis-bml-server/pom.xml b/linkis-public-enhancements/linkis-bml/linkis-bml-server/pom.xml index 6c3107ed59..a77ce22c7e 100644 --- a/linkis-public-enhancements/linkis-bml/linkis-bml-server/pom.xml +++ b/linkis-public-enhancements/linkis-bml/linkis-bml-server/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-public-enhancements/linkis-bml/pom.xml b/linkis-public-enhancements/linkis-bml/pom.xml index 54fd12c040..cacae598f6 100644 --- a/linkis-public-enhancements/linkis-bml/pom.xml +++ b/linkis-public-enhancements/linkis-bml/pom.xml @@ -5,7 +5,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-cache/pom.xml b/linkis-public-enhancements/linkis-context-service/linkis-cs-cache/pom.xml index 5719a33157..b6dfbfcd73 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-cache/pom.xml +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-cache/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-client/pom.xml b/linkis-public-enhancements/linkis-context-service/linkis-cs-client/pom.xml index 8654a3cc6b..d464a6644b 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-client/pom.xml +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-client/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/pom.xml b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/pom.xml index 6879d73fa1..4c138545d6 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/pom.xml +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-engine-support/pom.xml b/linkis-public-enhancements/linkis-context-service/linkis-cs-engine-support/pom.xml index 5613289ee2..f77630c8bc 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-engine-support/pom.xml +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-engine-support/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-highavailable/pom.xml b/linkis-public-enhancements/linkis-context-service/linkis-cs-highavailable/pom.xml index cabb976ea5..d3331ae39a 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-highavailable/pom.xml +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-highavailable/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-listener/pom.xml b/linkis-public-enhancements/linkis-context-service/linkis-cs-listener/pom.xml index bf4c3d4e8d..14045b8f0f 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-listener/pom.xml +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-listener/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 @@ -35,7 +35,7 @@ com.webank.wedatasphere.linkis linkis-cs-common - 1.0.2 + 1.0.3 junit diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/pom.xml b/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/pom.xml index e305f624bb..7b168b6dd9 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/pom.xml +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-persistence/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-search/pom.xml b/linkis-public-enhancements/linkis-context-service/linkis-cs-search/pom.xml index ae5c89249f..de1c53c28c 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-search/pom.xml +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-search/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/pom.xml b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/pom.xml index 227edfde4f..d5492423eb 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/pom.xml +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../../pom.xml 4.0.0 diff --git a/linkis-public-enhancements/linkis-context-service/pom.xml b/linkis-public-enhancements/linkis-context-service/pom.xml index 1b92c16097..3c3d5763d9 100644 --- a/linkis-public-enhancements/linkis-context-service/pom.xml +++ b/linkis-public-enhancements/linkis-context-service/pom.xml @@ -5,7 +5,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-public-enhancements/linkis-datasource/datasourcemanager/common/pom.xml b/linkis-public-enhancements/linkis-datasource/datasourcemanager/common/pom.xml index 237cbd7e61..65cc7f2d30 100644 --- a/linkis-public-enhancements/linkis-datasource/datasourcemanager/common/pom.xml +++ b/linkis-public-enhancements/linkis-datasource/datasourcemanager/common/pom.xml @@ -16,10 +16,10 @@ - linkis - com.webank.wedatasphere.linkis - 1.0.2 - + linkis + com.webank.wedatasphere.linkis + 1.0.3 + 4.0.0 linkis-datasourcemanager-common diff --git a/linkis-public-enhancements/linkis-datasource/datasourcemanager/server/pom.xml b/linkis-public-enhancements/linkis-datasource/datasourcemanager/server/pom.xml index 7d29bb71eb..83d67184c6 100644 --- a/linkis-public-enhancements/linkis-datasource/datasourcemanager/server/pom.xml +++ b/linkis-public-enhancements/linkis-datasource/datasourcemanager/server/pom.xml @@ -16,10 +16,10 @@ - linkis - com.webank.wedatasphere.linkis - 1.0.2 - + linkis + com.webank.wedatasphere.linkis + 1.0.3 + 4.0.0 linkis-datasourcemanager-server diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata/pom.xml b/linkis-public-enhancements/linkis-datasource/linkis-metadata/pom.xml index 09cde9bae8..6fb2320605 100644 --- a/linkis-public-enhancements/linkis-datasource/linkis-metadata/pom.xml +++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 jar diff --git a/linkis-public-enhancements/linkis-datasource/metadatamanager/common/pom.xml b/linkis-public-enhancements/linkis-datasource/metadatamanager/common/pom.xml index 9d4ac0e79c..e36069463d 100644 --- a/linkis-public-enhancements/linkis-datasource/metadatamanager/common/pom.xml +++ b/linkis-public-enhancements/linkis-datasource/metadatamanager/common/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-public-enhancements/linkis-datasource/metadatamanager/server/pom.xml b/linkis-public-enhancements/linkis-datasource/metadatamanager/server/pom.xml index 6bc8c2ae4a..1478b885f8 100644 --- a/linkis-public-enhancements/linkis-datasource/metadatamanager/server/pom.xml +++ b/linkis-public-enhancements/linkis-datasource/metadatamanager/server/pom.xml @@ -16,10 +16,10 @@ - linkis - com.webank.wedatasphere.linkis - 1.0.2 - + linkis + com.webank.wedatasphere.linkis + 1.0.3 + 4.0.0 linkis-metadatamanager-server diff --git a/linkis-public-enhancements/linkis-datasource/metadatamanager/service/elasticsearch/pom.xml b/linkis-public-enhancements/linkis-datasource/metadatamanager/service/elasticsearch/pom.xml index 362a96509d..205d1b6ea8 100644 --- a/linkis-public-enhancements/linkis-datasource/metadatamanager/service/elasticsearch/pom.xml +++ b/linkis-public-enhancements/linkis-datasource/metadatamanager/service/elasticsearch/pom.xml @@ -16,10 +16,10 @@ - linkis - com.webank.wedatasphere.linkis - 1.0.2 - + linkis + com.webank.wedatasphere.linkis + 1.0.3 + 4.0.0 linkis-metadatamanager-service-es diff --git a/linkis-public-enhancements/linkis-datasource/metadatamanager/service/hive/pom.xml b/linkis-public-enhancements/linkis-datasource/metadatamanager/service/hive/pom.xml index ce78609ba7..2b30d63d02 100644 --- a/linkis-public-enhancements/linkis-datasource/metadatamanager/service/hive/pom.xml +++ b/linkis-public-enhancements/linkis-datasource/metadatamanager/service/hive/pom.xml @@ -16,10 +16,10 @@ - linkis - com.webank.wedatasphere.linkis - 1.0.2 - + linkis + com.webank.wedatasphere.linkis + 1.0.3 + 4.0.0 linkis-metadatamanager-service-hive diff --git a/linkis-public-enhancements/linkis-datasource/metadatamanager/service/mysql/pom.xml b/linkis-public-enhancements/linkis-datasource/metadatamanager/service/mysql/pom.xml index ca3db45877..5e794ab75a 100644 --- a/linkis-public-enhancements/linkis-datasource/metadatamanager/service/mysql/pom.xml +++ b/linkis-public-enhancements/linkis-datasource/metadatamanager/service/mysql/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-configuration/pom.xml b/linkis-public-enhancements/linkis-publicservice/linkis-configuration/pom.xml index da79b6a930..e0ab742405 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-configuration/pom.xml +++ b/linkis-public-enhancements/linkis-publicservice/linkis-configuration/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 linkis-configuration diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-error-code/linkis-error-code-client/pom.xml b/linkis-public-enhancements/linkis-publicservice/linkis-error-code/linkis-error-code-client/pom.xml index 642f9e11c7..781f3e7164 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-error-code/linkis-error-code-client/pom.xml +++ b/linkis-public-enhancements/linkis-publicservice/linkis-error-code/linkis-error-code-client/pom.xml @@ -17,7 +17,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-error-code/linkis-error-code-common/pom.xml b/linkis-public-enhancements/linkis-publicservice/linkis-error-code/linkis-error-code-common/pom.xml index fe595e1837..7a46ebc9f9 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-error-code/linkis-error-code-common/pom.xml +++ b/linkis-public-enhancements/linkis-publicservice/linkis-error-code/linkis-error-code-common/pom.xml @@ -17,7 +17,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-error-code/linkis-error-code-server/pom.xml b/linkis-public-enhancements/linkis-publicservice/linkis-error-code/linkis-error-code-server/pom.xml index d4a4820810..9fe53958c4 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-error-code/linkis-error-code-server/pom.xml +++ b/linkis-public-enhancements/linkis-publicservice/linkis-error-code/linkis-error-code-server/pom.xml @@ -17,7 +17,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-error-code/pom.xml b/linkis-public-enhancements/linkis-publicservice/linkis-error-code/pom.xml index bab99a9c98..8e99fbfc99 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-error-code/pom.xml +++ b/linkis-public-enhancements/linkis-publicservice/linkis-error-code/pom.xml @@ -17,7 +17,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-client/pom.xml b/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-client/pom.xml index 4337a5735f..3181a9fd16 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-client/pom.xml +++ b/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-client/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-server/pom.xml b/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-server/pom.xml index e59d87fd60..06e7b0c868 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-server/pom.xml +++ b/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-server/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../../pom.xml 4.0.0 diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-jobhistory/pom.xml b/linkis-public-enhancements/linkis-publicservice/linkis-jobhistory/pom.xml index 2981e0e43a..a553635c02 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-jobhistory/pom.xml +++ b/linkis-public-enhancements/linkis-publicservice/linkis-jobhistory/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 linkis-jobhistory diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-client/pom.xml b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-client/pom.xml index 4b6161eb2e..2388534fe0 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-client/pom.xml +++ b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-client/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 linkis-storage-script-dev-client diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/pom.xml b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/pom.xml index 2abb4a1af8..923c416315 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/pom.xml +++ b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 linkis-storage-script-dev-server jar diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-client/pom.xml b/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-client/pom.xml index ed3e93e295..286fabb70b 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-client/pom.xml +++ b/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-client/pom.xml @@ -18,7 +18,7 @@ com.webank.wedatasphere.linkis linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-common/pom.xml b/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-common/pom.xml index f2e51005ea..14cfa993bd 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-common/pom.xml +++ b/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-common/pom.xml @@ -18,7 +18,7 @@ com.webank.wedatasphere.linkis linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-service/pom.xml b/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-service/pom.xml index 75b449310e..76dc5e26b6 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-service/pom.xml +++ b/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-service/pom.xml @@ -18,7 +18,7 @@ com.webank.wedatasphere.linkis linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-variable/pom.xml b/linkis-public-enhancements/linkis-publicservice/linkis-variable/pom.xml index b1f8c5d610..88a50d0f29 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-variable/pom.xml +++ b/linkis-public-enhancements/linkis-publicservice/linkis-variable/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 linkis-variable diff --git a/linkis-public-enhancements/linkis-publicservice/pom.xml b/linkis-public-enhancements/linkis-publicservice/pom.xml index c87d74fcb2..87f0908e69 100644 --- a/linkis-public-enhancements/linkis-publicservice/pom.xml +++ b/linkis-public-enhancements/linkis-publicservice/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-public-enhancements/pom.xml b/linkis-public-enhancements/pom.xml index 6a669de047..9e1542e8d8 100644 --- a/linkis-public-enhancements/pom.xml +++ b/linkis-public-enhancements/pom.xml @@ -5,7 +5,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-spring-cloud-services/linkis-service-discovery/linkis-eureka/pom.xml b/linkis-spring-cloud-services/linkis-service-discovery/linkis-eureka/pom.xml index ad55f45504..7fd242b53f 100644 --- a/linkis-spring-cloud-services/linkis-service-discovery/linkis-eureka/pom.xml +++ b/linkis-spring-cloud-services/linkis-service-discovery/linkis-eureka/pom.xml @@ -18,7 +18,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 linkis-eureka diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/pom.xml b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/pom.xml index 9c321883dc..fda5be5030 100644 --- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/pom.xml +++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/pom.xml @@ -19,7 +19,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 linkis-gateway-core diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/pom.xml b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/pom.xml index a542b711fd..00f9abc320 100644 --- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/pom.xml +++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-httpclient-support/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 linkis-gateway-httpclient-support diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/pom.xml b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/pom.xml index 8a4e9241b0..50f42eec7c 100644 --- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/pom.xml +++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-server-support/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../../pom.xml diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/pom.xml b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/pom.xml index db26d2b2f5..d4064e8b84 100644 --- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/pom.xml +++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/pom.xml @@ -20,7 +20,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../../pom.xml linkis-spring-cloud-gateway diff --git a/linkis-spring-cloud-services/linkis-service-gateway/plugins/linkis-gateway-datasource-ruler/pom.xml b/linkis-spring-cloud-services/linkis-service-gateway/plugins/linkis-gateway-datasource-ruler/pom.xml index eb17364422..c4513af992 100644 --- a/linkis-spring-cloud-services/linkis-service-gateway/plugins/linkis-gateway-datasource-ruler/pom.xml +++ b/linkis-spring-cloud-services/linkis-service-gateway/plugins/linkis-gateway-datasource-ruler/pom.xml @@ -5,7 +5,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/linkis-spring-cloud-services/linkis-service-gateway/pom.xml b/linkis-spring-cloud-services/linkis-service-gateway/pom.xml index 03f12362fe..205f5a053b 100644 --- a/linkis-spring-cloud-services/linkis-service-gateway/pom.xml +++ b/linkis-spring-cloud-services/linkis-service-gateway/pom.xml @@ -21,7 +21,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 ../../pom.xml 4.0.0 diff --git a/linkis-spring-cloud-services/pom.xml b/linkis-spring-cloud-services/pom.xml index a97643a411..25e9479aa6 100644 --- a/linkis-spring-cloud-services/pom.xml +++ b/linkis-spring-cloud-services/pom.xml @@ -5,7 +5,7 @@ linkis com.webank.wedatasphere.linkis - 1.0.2 + 1.0.3 4.0.0 diff --git a/pom.xml b/pom.xml index 4b63ca7704..80847bf503 100644 --- a/pom.xml +++ b/pom.xml @@ -19,7 +19,7 @@ com.webank.wedatasphere.linkis linkis - 1.0.2 + 1.0.3 pom Linkis Project Parent POM @@ -69,7 +69,7 @@ - 1.0.2 + 1.0.3 2.7.2 2.2.1.RELEASE 2.2.1.RELEASE From 62b45907e9b59003d8bd0962b06851954e8d9d9b Mon Sep 17 00:00:00 2001 From: casionxia Date: Fri, 24 Sep 2021 11:17:15 +0800 Subject: [PATCH 15/29] only use spring DispatcherServlet --- .../linkis/DataWorkCloudApplication.java | 2 +- .../linkis/server/BDPJettyServerHelper.scala | 30 +++++++++---------- .../server/conf/ServerConfiguration.scala | 2 +- .../test/TestContextHAManager.java | 3 +- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/DataWorkCloudApplication.java b/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/DataWorkCloudApplication.java index 0bc0dda169..8ab3a6e57d 100644 --- a/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/DataWorkCloudApplication.java +++ b/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/DataWorkCloudApplication.java @@ -192,7 +192,7 @@ public void customize(Server server) { filterHolder.setInitParameter("encoding", Configuration.BDP_ENCODING().getValue()); filterHolder.setInitParameter("forceEncoding", "true"); webApp.addFilter(filterHolder, "/*", EnumSet.allOf(DispatcherType.class)); - BDPJettyServerHelper.setupRestApiContextHandler(webApp); + // BDPJettyServerHelper.setupRestApiContextHandler(webApp); //set servletHolder for spring restful api BDPJettyServerHelper.setupSpringRestApiContextHandler(webApp); diff --git a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/BDPJettyServerHelper.scala b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/BDPJettyServerHelper.scala index 39503677f8..10c8c90868 100644 --- a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/BDPJettyServerHelper.scala +++ b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/BDPJettyServerHelper.scala @@ -67,20 +67,20 @@ private[linkis] object BDPJettyServerHelper extends Logging { private def getSecurityFilter(): Class[Filter] = Class.forName(BDP_SERVER_SECURITY_FILTER.getValue).asInstanceOf[Class[Filter]] - def setupRestApiContextHandler(webApp: ServletContextHandler) { - val servletHolder = new ServletHolder(classOf[ServletContainer]) - servletHolder.setInitParameter("javax.ws.rs.Application", classOf[RestfulApplication].getName) - servletHolder.setName("restful") - servletHolder.setForcedPath("restful") - webApp.setSessionHandler(new SessionHandler) - val p = BDP_SERVER_RESTFUL_URI.getValue - val restfulPath = if(p.endsWith("/*")) p - else if(p.endsWith("/")) p + "*" - else p + "/*" - webApp.addServlet(servletHolder, restfulPath) - val filterHolder = new FilterHolder(getSecurityFilter()) - webApp.addFilter(filterHolder, restfulPath, EnumSet.allOf(classOf[DispatcherType])) - } +// def setupRestApiContextHandler(webApp: ServletContextHandler) { +// val servletHolder = new ServletHolder(classOf[ServletContainer]) +// servletHolder.setInitParameter("javax.ws.rs.Application", classOf[RestfulApplication].getName) +// servletHolder.setName("restful") +// servletHolder.setForcedPath("restful") +// webApp.setSessionHandler(new SessionHandler) +// val p = "/api/rest_xx/" +// val restfulPath = if(p.endsWith("/*")) p +// else if(p.endsWith("/")) p + "*" +// else p + "/*" +// webApp.addServlet(servletHolder, restfulPath) +// val filterHolder = new FilterHolder(getSecurityFilter()) +// webApp.addFilter(filterHolder, restfulPath, EnumSet.allOf(classOf[DispatcherType])) + // } def setupSpringRestApiContextHandler(webApp: ServletContextHandler) { val context = new AnnotationConfigWebApplicationContext @@ -97,7 +97,7 @@ private[linkis] object BDPJettyServerHelper extends Logging { val multipartConfigElement = new MultipartConfigElement(TMP_FOLDER, MAX_UPLOAD_SIZE, MAX_UPLOAD_SIZE * 2, MAX_UPLOAD_SIZE / 2) servletHolder.getRegistration.setMultipartConfig(multipartConfigElement) - val p = BDP_SERVER_SPRING_RESTFUL_URI.getValue + val p = BDP_SERVER_RESTFUL_URI.getValue val restfulPath = if(p.endsWith("/*")) p else if(p.endsWith("/")) p + "*" else p + "/*" diff --git a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/conf/ServerConfiguration.scala b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/conf/ServerConfiguration.scala index fba8c80847..5400381eef 100644 --- a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/conf/ServerConfiguration.scala +++ b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/conf/ServerConfiguration.scala @@ -75,7 +75,7 @@ object ServerConfiguration extends Logging{ val BDP_SERVER_SERVER_CONTEXT_PATH = CommonVars("wds.linkis.server.context.path", "/") val BDP_SERVER_RESTFUL_URI = CommonVars("wds.linkis.server.restful.uri", "/api/rest_j/" + BDP_SERVER_VERSION) - val BDP_SERVER_SPRING_RESTFUL_URI = CommonVars("wds.linkis.server.restful.uri", "/api/rest_s/" + BDP_SERVER_VERSION) + // val BDP_SERVER_SPRING_RESTFUL_URI = CommonVars("wds.linkis.server.restful.uri", "/api/rest_s/" + BDP_SERVER_VERSION) val BDP_SERVER_USER_URI = CommonVars("wds.linkis.server.user.restful.uri", "/api/rest_j/" + BDP_SERVER_VERSION + "/user") val BDP_SERVER_RESTFUL_LOGIN_URI = CommonVars("wds.linkis.server.user.restful.login.uri", new File(BDP_SERVER_USER_URI.getValue, "login").getPath) val BDP_SERVER_SECURITY_SSL_URI = CommonVars("wds.linkis.server.user.security.ssl.uri", new File(BDP_SERVER_USER_URI.getValue, "publicKey").getPath) diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-highavailable/src/test/java/com/webank/wedatasphere/linkis/cs/highavailable/test/TestContextHAManager.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-highavailable/src/test/java/com/webank/wedatasphere/linkis/cs/highavailable/test/TestContextHAManager.java index bd5d31dc5e..f9eecdc7e1 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-highavailable/src/test/java/com/webank/wedatasphere/linkis/cs/highavailable/test/TestContextHAManager.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-highavailable/src/test/java/com/webank/wedatasphere/linkis/cs/highavailable/test/TestContextHAManager.java @@ -165,7 +165,8 @@ public void customize(Server server) { filterHolder.setInitParameter("encoding", Configuration.BDP_ENCODING().getValue()); filterHolder.setInitParameter("forceEncoding", "true"); webApp.addFilter(filterHolder, "/*", EnumSet.allOf(DispatcherType.class)); - BDPJettyServerHelper.setupRestApiContextHandler(webApp); + //BDPJettyServerHelper.setupRestApiContextHandler(webApp); + BDPJettyServerHelper.setupSpringRestApiContextHandler(webApp); if(ServerConfiguration.BDP_SERVER_SOCKET_MODE().getValue()) { BDPJettyServerHelper.setupControllerServer(webApp); } From 5610e8caa1e663fb8ba433237a24cfce93d5d300 Mon Sep 17 00:00:00 2001 From: casionxia Date: Sat, 25 Sep 2021 22:03:30 +0800 Subject: [PATCH 16/29] replace codehaus json with fastxml --- .../entrance/restful/EntranceRestfulApi.java | 6 +- .../restful/EntranceRestfulRemote.scala | 4 +- .../manager/am/restful/EMRestfulApi.java | 5 +- .../manager/am/restful/EngineRestfulApi.java | 19 +-- .../restful/RMMonitorRest.scala | 2 +- .../scala/com/webank/test/TestResource.scala | 2 +- .../linkis/bml/restful/BmlProjectRestful.java | 25 +-- .../linkis/bml/restful/BmlRestfulApi.java | 19 ++- .../linkis/cs/parser/ApiJsonTest.java | 6 +- .../restful/ContextHistoryRestfulApi.java | 19 +-- .../server/restful/ContextIDRestfulApi.java | 15 +- .../restful/ContextListenerRestfulApi.java | 17 +- .../cs/server/restful/ContextRestfulApi.java | 31 ++-- .../cs/server/restful/CsRestfulParent.java | 4 +- .../cs/server/ContextHistoryRestfulApi.java | 13 +- .../linkis/cs/server/ContextIDRestfulApi.java | 13 +- .../cs/server/ContextListenerRestfulApi.java | 7 +- .../linkis/cs/server/ContextRestfulApi.java | 24 +-- .../restful/api/DataSourceRestfulApi.java | 8 +- .../restful/api/MdqTableRestfulApi.java | 14 +- .../metadata/service/DataSourceService.java | 2 +- .../service/impl/DataSourceServiceImpl.java | 8 +- .../linkis/metadata/ddl/DDLHelper.scala | 4 +- .../metadata/receiver/MDQReceiver.scala | 6 +- .../restful/api/ConfigurationRestfulApi.java | 17 +- .../configuration/util/JsonNodeUtil.scala | 2 +- .../label/restful/InstanceRestful.java | 5 +- .../filesystem/restful/api/FsRestfulApi.java | 20 +-- .../validator/SpringPathValidator.scala | 146 ++++++++++++++++++ .../wedatasphere/linkis/udf/api/UDFApi.java | 36 ++--- .../restful/api/VariableRestfulApi.java | 11 +- 31 files changed, 338 insertions(+), 172 deletions(-) create mode 100644 linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/SpringPathValidator.scala diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java b/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java index b32ed34c0e..e9d41dae30 100644 --- a/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java +++ b/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java @@ -35,7 +35,7 @@ import com.webank.wedatasphere.linkis.server.security.SecurityFilter; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; -import org.codehaus.jackson.JsonNode; +import com.fasterxml.jackson.databind.JsonNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.web.bind.annotation.*; @@ -291,9 +291,9 @@ public Message log(HttpServletRequest req, @PathVariable("id") String id) { return message; } - + @RequestMapping(path = "/{id}/killJobs",method = RequestMethod.POST) - public Message killJobs(HttpServletRequest req, JsonNode jsonNode, @PathVariable("id") String strongExecId) { + public Message killJobs(HttpServletRequest req,@RequestBody JsonNode jsonNode, @PathVariable("id") String strongExecId) { JsonNode idNode = jsonNode.get("idList"); JsonNode taskIDNode = jsonNode.get("taskIDList"); ArrayList waitToForceKill = new ArrayList<>(); diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulRemote.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulRemote.scala index 9b9262fcf4..74c73b1ebb 100644 --- a/linkis-computation-governance/linkis-entrance/src/main/scala/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulRemote.scala +++ b/linkis-computation-governance/linkis-entrance/src/main/scala/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulRemote.scala @@ -18,10 +18,10 @@ // //import java.util // +//import com.fasterxml.jackson.databind.JsonNode //import javax.servlet.http.HttpServletRequest //import javax.ws.rs.QueryParam //import javax.ws.rs.core.{Context, Response} -//import org.codehaus.jackson.JsonNode //import org.springframework.web.bind.annotation.{PathVariable, RequestBody, RequestMapping, RequestMethod} // // @@ -51,7 +51,7 @@ // def log(@Context req: HttpServletRequest, @PathVariable("id") id: String): Response // // @RequestMapping(value = Array("/entrance/{id}/killJobs"), method = Array(RequestMethod.POST)) -// def killJobs(@Context req: HttpServletRequest, jsonNode: JsonNode, @PathVariable("id") id: String): Response +// def killJobs(@Context req: HttpServletRequest, @RequestBody jsonNode: JsonNode, @PathVariable("id") id: String): Response // // @RequestMapping(value = Array("/entrance/{id}/kill"), method = Array(RequestMethod.POST)) // def kill(@PathVariable("id") id: String, @QueryParam("taskID") taskID:Long): Response diff --git a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/com/webank/wedatasphere/linkis/manager/am/restful/EMRestfulApi.java b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/com/webank/wedatasphere/linkis/manager/am/restful/EMRestfulApi.java index 60daf173a2..35bb65b841 100644 --- a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/com/webank/wedatasphere/linkis/manager/am/restful/EMRestfulApi.java +++ b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/com/webank/wedatasphere/linkis/manager/am/restful/EMRestfulApi.java @@ -39,11 +39,12 @@ import com.webank.wedatasphere.linkis.server.security.SecurityFilter; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; -import org.codehaus.jackson.JsonNode; +import com.fasterxml.jackson.databind.JsonNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -113,7 +114,7 @@ public Message listAllNodeHealthyStatus( HttpServletRequest req, @RequestMapping(path = "/modifyEMInfo", method = RequestMethod.PUT) @Transactional(rollbackFor = Exception.class) - public Message modifyEMInfo( HttpServletRequest req, JsonNode jsonNode) throws AMErrorException, LabelErrorException { + public Message modifyEMInfo( HttpServletRequest req, @RequestBody JsonNode jsonNode) throws AMErrorException, LabelErrorException { String username = SecurityFilter.getLoginUsername(req); String[] adminArray = AMConfiguration.GOVERNANCE_STATION_ADMIN().getValue().split(","); if(adminArray != null && !Arrays.asList(adminArray).contains(username)){ diff --git a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/com/webank/wedatasphere/linkis/manager/am/restful/EngineRestfulApi.java b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/com/webank/wedatasphere/linkis/manager/am/restful/EngineRestfulApi.java index f1dfbefd22..89edead7ff 100644 --- a/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/com/webank/wedatasphere/linkis/manager/am/restful/EngineRestfulApi.java +++ b/linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/java/com/webank/wedatasphere/linkis/manager/am/restful/EngineRestfulApi.java @@ -17,6 +17,7 @@ */ package com.webank.wedatasphere.linkis.manager.am.restful; +import com.fasterxml.jackson.databind.ObjectMapper; import com.webank.wedatasphere.linkis.common.ServiceInstance; import com.webank.wedatasphere.linkis.common.utils.ByteTimeUtils; import com.webank.wedatasphere.linkis.manager.am.conf.AMConfiguration; @@ -53,11 +54,11 @@ import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.exception.ExceptionUtils; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -86,10 +87,10 @@ public class EngineRestfulApi { private Logger logger = LoggerFactory.getLogger(EMRestfulApi.class); @RequestMapping(path = "/createEngineConn", method = RequestMethod.POST) - public Message createEngineConn( HttpServletRequest req, JsonNode jsonNode) + public Message createEngineConn( HttpServletRequest req, @RequestBody JsonNode jsonNode) throws IOException, InterruptedException { String userName = SecurityFilter.getLoginUsername(req); - EngineCreateRequest engineCreateRequest = objectMapper.readValue(jsonNode, EngineCreateRequest.class); + EngineCreateRequest engineCreateRequest = objectMapper.treeToValue(jsonNode, EngineCreateRequest.class); engineCreateRequest.setUser(userName); long timeout = engineCreateRequest.getTimeOut(); if(timeout <= 0) { @@ -122,7 +123,7 @@ public Message createEngineConn( HttpServletRequest req, JsonNode jsonNode) @RequestMapping(path = "/getEngineConn", method = RequestMethod.POST) - public Message getEngineConn( HttpServletRequest req, JsonNode jsonNode) throws AMErrorException { + public Message getEngineConn( HttpServletRequest req, @RequestBody JsonNode jsonNode) throws AMErrorException { String userName = SecurityFilter.getLoginUsername(req); ServiceInstance serviceInstance = getServiceInstance(jsonNode); EngineNode engineNode = engineCreateService.getEngineNode(serviceInstance); @@ -133,7 +134,7 @@ public Message getEngineConn( HttpServletRequest req, JsonNode jsonNode) throws } @RequestMapping(path = "/killEngineConn", method = RequestMethod.POST) - public Message killEngineConn( HttpServletRequest req, JsonNode jsonNode) throws Exception { + public Message killEngineConn( HttpServletRequest req, @RequestBody JsonNode jsonNode) throws Exception { String userName = SecurityFilter.getLoginUsername(req); ServiceInstance serviceInstance = getServiceInstance(jsonNode); logger.info("User {} try to kill engineConn {}.", userName, serviceInstance); @@ -156,12 +157,12 @@ public Message listUserEngines( HttpServletRequest req) { } @RequestMapping(path = "/listEMEngines", method = RequestMethod.POST) - public Message listEMEngines( HttpServletRequest req, JsonNode jsonNode) throws IOException, AMErrorException { + public Message listEMEngines( HttpServletRequest req, @RequestBody JsonNode jsonNode) throws IOException, AMErrorException { String username = SecurityFilter.getLoginUsername(req); if(!isAdmin(username)){ throw new AMErrorException(210003,"Only admin can search engine information(只有管理员才能查询所有引擎信息)."); } - AMEMNode amemNode = objectMapper.readValue(jsonNode.get("em"), AMEMNode.class); + AMEMNode amemNode = objectMapper.treeToValue(jsonNode.get("em"), AMEMNode.class); JsonNode emInstace = jsonNode.get("emInstance"); JsonNode nodeStatus = jsonNode.get("nodeStatus"); JsonNode engineType = jsonNode.get("engineType"); @@ -188,7 +189,7 @@ public Message listEMEngines( HttpServletRequest req, JsonNode jsonNode) throws } @RequestMapping(path = "/modifyEngineInfo", method = RequestMethod.PUT) - public Message modifyEngineInfo( HttpServletRequest req, JsonNode jsonNode) throws AMErrorException, LabelErrorException { + public Message modifyEngineInfo( HttpServletRequest req, @RequestBody JsonNode jsonNode) throws AMErrorException, LabelErrorException { String username = SecurityFilter.getLoginUsername(req); if(!isAdmin(username)){ throw new AMErrorException(210003,"Only admin can modify engineConn information(只有管理员才能修改引擎信息)."); diff --git a/linkis-computation-governance/linkis-manager/linkis-resource-manager/src/main/scala/com/webank/wedatasphere/linkis/resourcemanager/restful/RMMonitorRest.scala b/linkis-computation-governance/linkis-manager/linkis-resource-manager/src/main/scala/com/webank/wedatasphere/linkis/resourcemanager/restful/RMMonitorRest.scala index c56bcec108..0fff9fe189 100644 --- a/linkis-computation-governance/linkis-manager/linkis-resource-manager/src/main/scala/com/webank/wedatasphere/linkis/resourcemanager/restful/RMMonitorRest.scala +++ b/linkis-computation-governance/linkis-manager/linkis-resource-manager/src/main/scala/com/webank/wedatasphere/linkis/resourcemanager/restful/RMMonitorRest.scala @@ -21,6 +21,7 @@ import java.util import java.util.concurrent.TimeUnit import java.util.{Comparator, TimeZone} +import com.fasterxml.jackson.databind.ObjectMapper import com.google.common.collect.Lists import com.webank.wedatasphere.linkis.common.ServiceInstance import com.webank.wedatasphere.linkis.common.utils.{Logging, Utils} @@ -46,7 +47,6 @@ import com.webank.wedatasphere.linkis.resourcemanager.utils.{RMConfiguration, RM import com.webank.wedatasphere.linkis.server.{BDPJettyServerHelper, Message} import com.webank.wedatasphere.linkis.server.security.SecurityFilter import javax.servlet.http.HttpServletRequest -import org.codehaus.jackson.map.ObjectMapper import org.json4s.DefaultFormats import org.json4s.jackson.Serialization.write import org.springframework.beans.factory.annotation.Autowired diff --git a/linkis-computation-governance/linkis-manager/linkis-resource-manager/src/test/scala/com/webank/test/TestResource.scala b/linkis-computation-governance/linkis-manager/linkis-resource-manager/src/test/scala/com/webank/test/TestResource.scala index 02f6516485..4f3dcf8e9d 100644 --- a/linkis-computation-governance/linkis-manager/linkis-resource-manager/src/test/scala/com/webank/test/TestResource.scala +++ b/linkis-computation-governance/linkis-manager/linkis-resource-manager/src/test/scala/com/webank/test/TestResource.scala @@ -16,10 +16,10 @@ package com.webank.test +import com.fasterxml.jackson.databind.ObjectMapper import com.webank.wedatasphere.linkis.manager.common.entity.resource.{Resource, ResourceSerializer, ResourceType} import com.webank.wedatasphere.linkis.manager.common.serializer.NodeResourceSerializer import com.webank.wedatasphere.linkis.server.Message -import org.codehaus.jackson.map.ObjectMapper import org.json4s.DefaultFormats import org.json4s.jackson.Serialization.write diff --git a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/restful/BmlProjectRestful.java b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/restful/BmlProjectRestful.java index 789f437828..d37f48b56d 100644 --- a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/restful/BmlProjectRestful.java +++ b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/restful/BmlProjectRestful.java @@ -27,10 +27,11 @@ import com.webank.wedatasphere.linkis.server.security.SecurityFilter; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; -import org.codehaus.jackson.JsonNode; +import com.fasterxml.jackson.databind.JsonNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -71,9 +72,9 @@ public class BmlProjectRestful { private DownloadService downloadService; @RequestMapping(path = "createBmlProject",method = RequestMethod.POST) - public Message createBmlProject(HttpServletRequest request, JsonNode jsonNode){ + public Message createBmlProject(HttpServletRequest request,@RequestBody JsonNode jsonNode){ String username = SecurityFilter.getLoginUsername(request); - String projectName = jsonNode.get(PROJECT_NAME_STR).getTextValue(); + String projectName = jsonNode.get(PROJECT_NAME_STR).textValue(); LOGGER.info("{} begins to create a project {} in bml", username, projectName); JsonNode editUserNode = jsonNode.get(EDIT_USERS_STR); JsonNode accessUserNode = jsonNode.get(ACCESS_USERS_STR); @@ -81,12 +82,12 @@ public Message createBmlProject(HttpServletRequest request, JsonNode jsonNode){ List editUsers = new ArrayList<>(); if (editUserNode.isArray()){ for (JsonNode node : editUserNode) { - editUsers.add(node.getTextValue()); + editUsers.add(node.textValue()); } } if (accessUserNode.isArray()){ for (JsonNode node : accessUserNode) { - accessUsers.add(node.getTextValue()); + accessUsers.add(node.textValue()); } } bmlProjectService.createBmlProject(projectName, username, editUsers, accessUsers); @@ -247,29 +248,29 @@ public Message getProjectInfo(HttpServletRequest request, @RequestParam(value="p @RequestMapping(path = "attachResourceAndProject",method = RequestMethod.POST) - public Message attachResourceAndProject(HttpServletRequest request, JsonNode jsonNode) throws ErrorException{ + public Message attachResourceAndProject(HttpServletRequest request, @RequestBody JsonNode jsonNode) throws ErrorException{ String username = SecurityFilter.getLoginUsername(request); - String projectName = jsonNode.get(PROJECT_NAME_STR).getTextValue(); - String resourceId = jsonNode.get("resourceId").getTextValue(); + String projectName = jsonNode.get(PROJECT_NAME_STR).textValue(); + String resourceId = jsonNode.get("resourceId").textValue(); LOGGER.info("begin to attach {} and {}", projectName, username); bmlProjectService.attach(projectName, resourceId); return Message.ok("attach resource and project ok"); } @RequestMapping(path = "updateProjectUsers",method = RequestMethod.POST) - public Message updateProjectUsers(HttpServletRequest request, JsonNode jsonNode) throws ErrorException{ + public Message updateProjectUsers(HttpServletRequest request, @RequestBody JsonNode jsonNode) throws ErrorException{ String username = SecurityFilter.getLoginUsername(request); - String projectName = jsonNode.get("projectName").getTextValue(); + String projectName = jsonNode.get("projectName").textValue(); LOGGER.info("{} begins to update project users for {}", username, projectName); List editUsers = new ArrayList<>(); List accessUsers = new ArrayList<>(); JsonNode editUsersNode = jsonNode.get("editUsers"); if (editUsersNode.isArray()){ - editUsersNode.forEach(node -> editUsers.add(node.getTextValue())); + editUsersNode.forEach(node -> editUsers.add(node.textValue())); } JsonNode accessUsersNode = jsonNode.get("accessUsers"); if (accessUsersNode.isArray()){ - accessUsersNode.forEach(node -> accessUsers.add(node.getTextValue())); + accessUsersNode.forEach(node -> accessUsers.add(node.textValue())); } bmlProjectService.updateProjectUsers(username, projectName, editUsers, accessUsers); return Message.ok("Updated project related user success(更新工程的相关用户成功)"); diff --git a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/restful/BmlRestfulApi.java b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/restful/BmlRestfulApi.java index 541989a2b6..dd12dce543 100644 --- a/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/restful/BmlRestfulApi.java +++ b/linkis-public-enhancements/linkis-bml/linkis-bml-server/src/main/java/com/webank/wedatasphere/linkis/bml/restful/BmlRestfulApi.java @@ -37,10 +37,11 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; -import org.codehaus.jackson.JsonNode; +import com.fasterxml.jackson.databind.JsonNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -205,14 +206,14 @@ public Message deleteVersion(JsonNode jsonNode, String user = RestfulUtils.getUserName(request); if (null == jsonNode.get("resourceId") || null == jsonNode.get("version") || - StringUtils.isEmpty(jsonNode.get("resourceId").getTextValue()) || StringUtils.isEmpty(jsonNode.get("version").getTextValue())) { + StringUtils.isEmpty(jsonNode.get("resourceId").textValue()) || StringUtils.isEmpty(jsonNode.get("version").textValue())) { throw new BmlServerParaErrorException("ResourceID and version are required to delete the specified version(删除指定版本,需要指定resourceId 和 version)"); } - String resourceId = jsonNode.get("resourceId").getTextValue(); - String version = jsonNode.get("version").getTextValue(); + String resourceId = jsonNode.get("resourceId").textValue(); + String version = jsonNode.get("version").textValue(); //检查资源和版本是否存在 if (!resourceService.checkResourceId(resourceId) || !versionService.checkVersion(resourceId, version) || !versionService.canAccess(resourceId, version)){ @@ -239,8 +240,7 @@ public Message deleteVersion(JsonNode jsonNode, } @RequestMapping(path = "deleteResource",method = RequestMethod.POST) - public Message deleteResource(JsonNode jsonNode, - HttpServletRequest request) throws IOException, ErrorException{ + public Message deleteResource(HttpServletRequest request,@RequestBody JsonNode jsonNode) throws IOException, ErrorException{ String user = RestfulUtils.getUserName(request); @@ -249,7 +249,7 @@ public Message deleteResource(JsonNode jsonNode, throw new BmlServerParaErrorException("You did not pass a valid ResourceID(您未传入有效的resourceId)"); } - String resourceId = jsonNode.get("resourceId").getTextValue(); + String resourceId = jsonNode.get("resourceId").textValue(); if (StringUtils.isEmpty(resourceId) || !resourceService.checkResourceId(resourceId)) { logger.error("the error resourceId is {} ", resourceId); throw new BmlServerParaErrorException("the resourceId"+resourceId+" is null ,Illegal or deleted (resourceId:"+resourceId+"为空,非法或者已被删除!)"); @@ -278,8 +278,7 @@ public Message deleteResource(JsonNode jsonNode, } @RequestMapping(path = "deleteResources",method = RequestMethod.POST) - public Message deleteResources(JsonNode jsonNode, - HttpServletRequest request) throws IOException, ErrorException{ + public Message deleteResources(HttpServletRequest request,@RequestBody JsonNode jsonNode) throws IOException, ErrorException{ String user = RestfulUtils.getUserName(request); List resourceIds = new ArrayList<>(); @@ -287,7 +286,7 @@ public Message deleteResources(JsonNode jsonNode, throw new BmlServerParaErrorException("Bulk deletion of unpassed resourceIDS parameters(批量删除未传入resourceIds参数)"); } - Iterator jsonNodeIter = jsonNode.get("resourceIds").getElements(); + Iterator jsonNodeIter = jsonNode.get("resourceIds").elements(); while (jsonNodeIter.hasNext()) { resourceIds.add(jsonNodeIter.next().asText()); } diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-search/src/test/java/com/webank/wedatasphere/linkis/cs/parser/ApiJsonTest.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-search/src/test/java/com/webank/wedatasphere/linkis/cs/parser/ApiJsonTest.java index db348d8f74..c56e9de4e6 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-search/src/test/java/com/webank/wedatasphere/linkis/cs/parser/ApiJsonTest.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-search/src/test/java/com/webank/wedatasphere/linkis/cs/parser/ApiJsonTest.java @@ -16,6 +16,8 @@ package com.webank.wedatasphere.linkis.cs.parser; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Sets; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -23,9 +25,7 @@ import com.webank.wedatasphere.linkis.cs.condition.ConditionType; import com.webank.wedatasphere.linkis.cs.condition.construction.ConditionParser; import com.webank.wedatasphere.linkis.server.BDPJettyServerHelper; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; import org.junit.Assert; import org.junit.Test; diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextHistoryRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextHistoryRestfulApi.java index fc9a0b2a4f..6d273ff076 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextHistoryRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextHistoryRestfulApi.java @@ -16,6 +16,7 @@ package com.webank.wedatasphere.linkis.cs.server.restful; +import com.fasterxml.jackson.databind.ObjectMapper; import com.webank.wedatasphere.linkis.cs.common.entity.history.ContextHistory; import com.webank.wedatasphere.linkis.cs.common.entity.source.ContextID; import com.webank.wedatasphere.linkis.cs.common.exception.CSErrorException; @@ -24,10 +25,10 @@ import com.webank.wedatasphere.linkis.cs.server.scheduler.CsScheduler; import com.webank.wedatasphere.linkis.cs.server.scheduler.HttpAnswerJob; import com.webank.wedatasphere.linkis.server.Message; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -46,7 +47,7 @@ public class ContextHistoryRestfulApi implements CsRestfulParent { @RequestMapping(path = "createHistory",method = RequestMethod.POST) - public Message createHistory(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + public Message createHistory(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextHistory history = getContextHistoryFromJsonNode(jsonNode); ContextID contextID = getContextIDFromJsonNode(jsonNode); //source and contextid cannot be empty @@ -62,7 +63,7 @@ public Message createHistory(HttpServletRequest req, JsonNode jsonNode) throws I @RequestMapping(path = "removeHistory",method = RequestMethod.POST) - public Message removeHistory(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + public Message removeHistory(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextHistory history = getContextHistoryFromJsonNode(jsonNode); ContextID contextID = getContextIDFromJsonNode(jsonNode); //source and contextid cannot be empty @@ -80,7 +81,7 @@ public Message removeHistory(HttpServletRequest req, JsonNode jsonNode) throws I @RequestMapping(path = "getHistories",method = RequestMethod.POST) - public Message getHistories(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + public Message getHistories(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); if (StringUtils.isEmpty(contextID.getContextId())) { throw new CSErrorException(97000, "contxtId cannot be empty"); @@ -92,9 +93,9 @@ public Message getHistories(HttpServletRequest req, JsonNode jsonNode) throws In @RequestMapping(path = "getHistory",method = RequestMethod.POST) - public Message getHistory(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + public Message getHistory(HttpServletRequest req, @RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { //ContextID contextID, String source - String source = jsonNode.get("source").getTextValue(); + String source = jsonNode.get("source").textValue(); ContextID contextID = getContextIDFromJsonNode(jsonNode); //source and contextid cannot be empty if (StringUtils.isEmpty(source)) { @@ -110,10 +111,10 @@ public Message getHistory(HttpServletRequest req, JsonNode jsonNode) throws Inte @RequestMapping(path = "searchHistory",method = RequestMethod.POST) - public Message searchHistory(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + public Message searchHistory(HttpServletRequest req, @RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { //ContextID contextID, String[] keywords ContextID contextID = getContextIDFromJsonNode(jsonNode); - String[] keywords = objectMapper.readValue(jsonNode.get("keywords"), String[].class); + String[] keywords = objectMapper.treeToValue(jsonNode.get("keywords"), String[].class); if (StringUtils.isEmpty(contextID.getContextId())) { throw new CSErrorException(97000, "contxtId cannot be empty"); } diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextIDRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextIDRestfulApi.java index 8f026c5ef3..95fb271f3b 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextIDRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextIDRestfulApi.java @@ -24,9 +24,10 @@ import com.webank.wedatasphere.linkis.cs.server.scheduler.CsScheduler; import com.webank.wedatasphere.linkis.cs.server.scheduler.HttpAnswerJob; import com.webank.wedatasphere.linkis.server.Message; -import org.codehaus.jackson.JsonNode; +import com.fasterxml.jackson.databind.JsonNode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -44,7 +45,7 @@ public class ContextIDRestfulApi implements CsRestfulParent { @RequestMapping(path = "createContextID",method = RequestMethod.POST) - public Message createContextID(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, ClassNotFoundException, IOException, CSErrorException { + public Message createContextID(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, ClassNotFoundException, IOException, CSErrorException { ContextID contextID = getContextIDFromJsonNode(jsonNode); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.CREATE, contextID); return generateResponse(answerJob, "contextId"); @@ -64,7 +65,7 @@ public Message getContextID(HttpServletRequest req, @RequestMapping(path = "updateContextID",method = RequestMethod.POST) - public Message updateContextID(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + public Message updateContextID(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); if (StringUtils.isEmpty(contextID.getContextId())) { throw new CSErrorException(97000, "contxtId cannot be empty"); @@ -75,11 +76,11 @@ public Message updateContextID(HttpServletRequest req, JsonNode jsonNode) throws @RequestMapping(path = "resetContextID",method = RequestMethod.POST) - public Message resetContextID(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException { + public Message resetContextID(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException { if (!jsonNode.has(ContextHTTPConstant.CONTEXT_ID_STR)) { throw new CSErrorException(97000, ContextHTTPConstant.CONTEXT_ID_STR + " cannot be empty"); } - String id = jsonNode.get(ContextHTTPConstant.CONTEXT_ID_STR).getTextValue(); + String id = jsonNode.get(ContextHTTPConstant.CONTEXT_ID_STR).textValue(); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.RESET, id); return generateResponse(answerJob, ""); } @@ -87,8 +88,8 @@ public Message resetContextID(HttpServletRequest req, JsonNode jsonNode) throws @RequestMapping(path = "removeContextID",method = RequestMethod.POST) - public Message removeContextID(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException { - String id = jsonNode.get("contextId").getTextValue(); + public Message removeContextID(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException { + String id = jsonNode.get("contextId").textValue(); if (StringUtils.isEmpty(id)) { throw new CSErrorException(97000, "contxtId cannot be empty"); } diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextListenerRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextListenerRestfulApi.java index 2830977ce9..3f7ad96ab6 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextListenerRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextListenerRestfulApi.java @@ -16,6 +16,7 @@ package com.webank.wedatasphere.linkis.cs.server.restful; +import com.fasterxml.jackson.databind.ObjectMapper; import com.webank.wedatasphere.linkis.cs.common.entity.listener.CommonContextIDListenerDomain; import com.webank.wedatasphere.linkis.cs.common.entity.listener.CommonContextKeyListenerDomain; import com.webank.wedatasphere.linkis.cs.common.entity.listener.ContextIDListenerDomain; @@ -27,9 +28,9 @@ import com.webank.wedatasphere.linkis.cs.server.scheduler.CsScheduler; import com.webank.wedatasphere.linkis.cs.server.scheduler.HttpAnswerJob; import com.webank.wedatasphere.linkis.server.Message; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -49,8 +50,8 @@ public class ContextListenerRestfulApi implements CsRestfulParent { @RequestMapping(path = "onBindIDListener",method = RequestMethod.POST) - public Message onBindIDListener(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { - String source = jsonNode.get("source").getTextValue(); + public Message onBindIDListener(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + String source = jsonNode.get("source").textValue(); ContextID contextID = getContextIDFromJsonNode(jsonNode); ContextIDListenerDomain listener = new CommonContextIDListenerDomain(); listener.setSource(source); @@ -60,8 +61,8 @@ public Message onBindIDListener(HttpServletRequest req, JsonNode jsonNode) throw @RequestMapping(path = "onBindKeyListener",method = RequestMethod.POST) - public Message onBindKeyListener(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { - String source = jsonNode.get("source").getTextValue(); + public Message onBindKeyListener(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + String source = jsonNode.get("source").textValue(); ContextID contextID = getContextIDFromJsonNode(jsonNode); ContextKey contextKey = getContextKeyFromJsonNode(jsonNode); CommonContextKeyListenerDomain listener = new CommonContextKeyListenerDomain(); @@ -72,8 +73,8 @@ public Message onBindKeyListener(HttpServletRequest req, JsonNode jsonNode) thro @RequestMapping(path = "heartbeat",method = RequestMethod.POST) - public Message heartbeat(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, IOException, CSErrorException { - String source = jsonNode.get("source").getTextValue(); + public Message heartbeat(HttpServletRequest req, @RequestBody JsonNode jsonNode) throws InterruptedException, IOException, CSErrorException { + String source = jsonNode.get("source").textValue(); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.HEARTBEAT, source); return generateResponse(answerJob, "ContextKeyValueBean"); } diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextRestfulApi.java index bfed226eaf..2e1c5585e1 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextRestfulApi.java @@ -16,6 +16,8 @@ package com.webank.wedatasphere.linkis.cs.server.restful; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import com.webank.wedatasphere.linkis.cs.common.entity.enumeration.ContextType; import com.webank.wedatasphere.linkis.cs.common.entity.source.ContextID; import com.webank.wedatasphere.linkis.cs.common.entity.source.ContextKey; @@ -28,12 +30,11 @@ import com.webank.wedatasphere.linkis.cs.server.scheduler.CsScheduler; import com.webank.wedatasphere.linkis.cs.server.scheduler.HttpAnswerJob; import com.webank.wedatasphere.linkis.server.Message; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.type.TypeReference; +import com.fasterxml.jackson.databind.JsonNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -57,7 +58,7 @@ public class ContextRestfulApi implements CsRestfulParent { @RequestMapping(path = "getContextValue",method = RequestMethod.POST) - public Message getContextValue(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + public Message getContextValue(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); ContextKey contextKey = getContextKeyFromJsonNode(jsonNode); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.GET, contextID, contextKey); @@ -68,7 +69,7 @@ public Message getContextValue(HttpServletRequest req, JsonNode jsonNode) throws @RequestMapping(path = "searchContextValue",method = RequestMethod.POST) - public Message searchContextValue(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + public Message searchContextValue(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); JsonNode condition = jsonNode.get("condition"); Map conditionMap = objectMapper.convertValue(condition, new TypeReference>() { @@ -89,7 +90,7 @@ public Message searchContextValueByCondition(HttpServletRequest req, JsonNode js @RequestMapping(path = "setValueByKey",method = RequestMethod.POST) - public Message setValueByKey(HttpServletRequest req, JsonNode jsonNode) throws CSErrorException, IOException, ClassNotFoundException, InterruptedException { + public Message setValueByKey(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws CSErrorException, IOException, ClassNotFoundException, InterruptedException { ContextID contextID = getContextIDFromJsonNode(jsonNode); ContextKey contextKey = getContextKeyFromJsonNode(jsonNode); ContextValue contextValue = getContextValueFromJsonNode(jsonNode); @@ -99,7 +100,7 @@ public Message setValueByKey(HttpServletRequest req, JsonNode jsonNode) throws C @RequestMapping(path = "setValue",method = RequestMethod.POST) - public Message setValue(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + public Message setValue(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); ContextKeyValue contextKeyValue = getContextKeyValueFromJsonNode(jsonNode); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.SET, contextID, contextKeyValue); @@ -108,7 +109,7 @@ public Message setValue(HttpServletRequest req, JsonNode jsonNode) throws Interr @RequestMapping(path = "resetValue",method = RequestMethod.POST) - public Message resetValue(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + public Message resetValue(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); ContextKey contextKey = getContextKeyFromJsonNode(jsonNode); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.RESET, contextID, contextKey); @@ -117,7 +118,7 @@ public Message resetValue(HttpServletRequest req, JsonNode jsonNode) throws Inte @RequestMapping(path = "removeValue",method = RequestMethod.POST) - public Message removeValue(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + public Message removeValue(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); ContextKey contextKey = getContextKeyFromJsonNode(jsonNode); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.REMOVE, contextID, contextKey); @@ -126,7 +127,7 @@ public Message removeValue(HttpServletRequest req, JsonNode jsonNode) throws Int @RequestMapping(path = "removeAllValue",method = RequestMethod.POST) - public Message removeAllValue(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + public Message removeAllValue(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.REMOVEALL, contextID); return generateResponse(answerJob, ""); @@ -134,19 +135,19 @@ public Message removeAllValue(HttpServletRequest req, JsonNode jsonNode) throws @RequestMapping(path = "removeAllValueByKeyPrefixAndContextType",method = RequestMethod.POST) - public Message removeAllValueByKeyPrefixAndContextType(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + public Message removeAllValueByKeyPrefixAndContextType(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); - String contextType = jsonNode.get(ContextHTTPConstant.CONTEXT_KEY_TYPE_STR).getTextValue(); - String keyPrefix = jsonNode.get(ContextHTTPConstant.CONTEXT_KEY_PREFIX_STR).getTextValue(); + String contextType = jsonNode.get(ContextHTTPConstant.CONTEXT_KEY_TYPE_STR).textValue(); + String keyPrefix = jsonNode.get(ContextHTTPConstant.CONTEXT_KEY_PREFIX_STR).textValue(); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.REMOVEALL, contextID, ContextType.valueOf(contextType),keyPrefix); return generateResponse(answerJob, ""); } @RequestMapping(path = "removeAllValueByKeyPrefix",method = RequestMethod.POST) - public Message removeAllValueByKeyPrefix(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { + public Message removeAllValueByKeyPrefix(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException, IOException, ClassNotFoundException { ContextID contextID = getContextIDFromJsonNode(jsonNode); - String keyPrefix = jsonNode.get(ContextHTTPConstant.CONTEXT_KEY_PREFIX_STR).getTextValue(); + String keyPrefix = jsonNode.get(ContextHTTPConstant.CONTEXT_KEY_PREFIX_STR).textValue(); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.REMOVEALL, contextID,keyPrefix); return generateResponse(answerJob, ""); } diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/CsRestfulParent.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/CsRestfulParent.java index 5c50ac201a..2aa640018c 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/CsRestfulParent.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/CsRestfulParent.java @@ -33,7 +33,7 @@ import com.webank.wedatasphere.linkis.cs.server.util.CsUtils; import com.webank.wedatasphere.linkis.server.Message; import com.webank.wedatasphere.linkis.server.security.SecurityFilter; -import org.codehaus.jackson.JsonNode; +import com.fasterxml.jackson.databind.JsonNode; import javax.servlet.http.HttpServletRequest; import java.io.IOException; @@ -98,7 +98,7 @@ default ContextID getContextIDFromJsonNode(JsonNode jsonNode) throws CSErrorExce } default T deserialize(JsonNode jsonNode, String key) throws CSErrorException { - String str = jsonNode.get(key).getTextValue(); + String str = jsonNode.get(key).textValue(); return (T) CsUtils.SERIALIZE.deserialize(str); } diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextHistoryRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextHistoryRestfulApi.java index b99f356af0..0239e2effc 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextHistoryRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextHistoryRestfulApi.java @@ -27,10 +27,11 @@ import com.webank.wedatasphere.linkis.cs.server.scheduler.CsScheduler; import com.webank.wedatasphere.linkis.cs.server.scheduler.HttpAnswerJob; import com.webank.wedatasphere.linkis.server.Message; -import org.codehaus.jackson.JsonNode; +import com.fasterxml.jackson.databind.JsonNode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -45,7 +46,7 @@ public class ContextHistoryRestfulApi implements CsRestfulParent { private CsScheduler csScheduler; @RequestMapping(path = "createHistory",method = RequestMethod.POST) - public Message createHistory(HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { + public Message createHistory(HttpServletRequest req,@RequestBody JsonNode json) throws InterruptedException, CSErrorException { ContextHistory history = new PersistenceContextHistory(); history.setSource("server1:prot1"); history.setContextType(ContextType.METADATA); @@ -64,7 +65,7 @@ public Message createHistory(HttpServletRequest req, JsonNode json) throws Inter } @RequestMapping(path = "removeHistory",method = RequestMethod.POST) - public Message removeHistory( HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { + public Message removeHistory( HttpServletRequest req, @RequestBody JsonNode json) throws InterruptedException, CSErrorException { ContextHistory history = new PersistenceContextHistory(); history.setSource("server1:prot1"); ContextID contextID = new PersistenceContextID(); @@ -82,7 +83,7 @@ public Message removeHistory( HttpServletRequest req, JsonNode json) throws Inte @RequestMapping(path = "getHistories",method = RequestMethod.GET) - public Message getHistories( HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { + public Message getHistories( HttpServletRequest req, @RequestBody JsonNode json) throws InterruptedException, CSErrorException { ContextID contextID = new PersistenceContextID(); contextID.setContextId("84716"); if (StringUtils.isEmpty(contextID.getContextId())) { @@ -93,7 +94,7 @@ public Message getHistories( HttpServletRequest req, JsonNode json) throws Inter } @RequestMapping(path = "getHistory",method = RequestMethod.GET) - public Message getHistory( HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { + public Message getHistory( HttpServletRequest req, @RequestBody JsonNode json) throws InterruptedException, CSErrorException { //ContextID contextID, String source String source = "server1:prot1"; ContextID contextID = new PersistenceContextID(); @@ -110,7 +111,7 @@ public Message getHistory( HttpServletRequest req, JsonNode json) throws Interru } @RequestMapping(path = "searchHistory",method = RequestMethod.GET) - public Message searchHistory( HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { + public Message searchHistory( HttpServletRequest req, @RequestBody JsonNode json) throws InterruptedException, CSErrorException { //ContextID contextID, String[] keywords ContextID contextID = new PersistenceContextID(); contextID.setContextId("84716"); diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextIDRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextIDRestfulApi.java index 1e92562286..4dba58930a 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextIDRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextIDRestfulApi.java @@ -24,9 +24,10 @@ import com.webank.wedatasphere.linkis.cs.server.scheduler.CsScheduler; import com.webank.wedatasphere.linkis.cs.server.scheduler.HttpAnswerJob; import com.webank.wedatasphere.linkis.server.Message; -import org.codehaus.jackson.JsonNode; +import com.fasterxml.jackson.databind.JsonNode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -44,7 +45,7 @@ public class ContextIDRestfulApi implements CsRestfulParent { private CsScheduler csScheduler; @RequestMapping(path = "createContextID",method = RequestMethod.POST) - public Message createContextID(HttpServletRequest req, JsonNode json) throws InterruptedException { + public Message createContextID(HttpServletRequest req, @RequestBody JsonNode json) throws InterruptedException { //contextID是client传过来的序列化的id PersistenceContextID contextID = new PersistenceContextID(); contextID.setUser("neiljianliu"); @@ -67,7 +68,7 @@ public Message getContextID( HttpServletRequest req, @RequestParam(value="contex } @RequestMapping(path = "updateContextID",method = RequestMethod.POST) - public Message updateContextID( HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { + public Message updateContextID( HttpServletRequest req, @RequestBody JsonNode json) throws InterruptedException, CSErrorException { PersistenceContextID contextID = new PersistenceContextID(); contextID.setUser("johnnwang"); contextID.setExpireType(ExpireType.NEVER); @@ -85,7 +86,7 @@ public Message updateContextID( HttpServletRequest req, JsonNode json) throws In } @RequestMapping(path = "resetContextID",method = RequestMethod.POST) - public Message resetContextID( HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { + public Message resetContextID( HttpServletRequest req, @RequestBody JsonNode json) throws InterruptedException, CSErrorException { String id = null; if (StringUtils.isEmpty(id)) { throw new CSErrorException(97000, "contxtId cannot be empty"); @@ -96,8 +97,8 @@ public Message resetContextID( HttpServletRequest req, JsonNode json) throws Int @RequestMapping(path = "removeContextID",method = RequestMethod.POST) - public Message removeContextID( HttpServletRequest req, JsonNode json) throws InterruptedException, CSErrorException { - String id = json.get("contextId").getTextValue(); + public Message removeContextID( HttpServletRequest req, @RequestBody JsonNode json) throws InterruptedException, CSErrorException { + String id = json.get("contextId").textValue(); if (StringUtils.isEmpty(id)) { throw new CSErrorException(97000, "contxtId cannot be empty"); } diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextListenerRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextListenerRestfulApi.java index 78c1fb7716..333b272380 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextListenerRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextListenerRestfulApi.java @@ -25,8 +25,9 @@ import com.webank.wedatasphere.linkis.cs.server.scheduler.CsScheduler; import com.webank.wedatasphere.linkis.cs.server.scheduler.HttpAnswerJob; import com.webank.wedatasphere.linkis.server.Message; -import org.codehaus.jackson.JsonNode; +import com.fasterxml.jackson.databind.JsonNode; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -42,7 +43,7 @@ public class ContextListenerRestfulApi implements CsRestfulParent { private CsScheduler csScheduler; @RequestMapping(path = "onBindIDListener",method = RequestMethod.POST) - public Message onBindIDListener(HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { + public Message onBindIDListener(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException { //ContextIDListener listener ContextIDListener listener = null; ContextID contextID = null; @@ -51,7 +52,7 @@ public Message onBindIDListener(HttpServletRequest req, JsonNode jsonNode) throw } @RequestMapping(path = "onBindKeyListener",method = RequestMethod.POST) - public Message onBindKeyListener( HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { + public Message onBindKeyListener( HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException { ContextKeyListener listener = null; ContextID contextID = null; ContextKey contextKey = null; diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextRestfulApi.java index fed23f1975..5668335ceb 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextRestfulApi.java @@ -16,6 +16,8 @@ package com.webank.wedatasphere.linkis.cs.server; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import com.webank.wedatasphere.linkis.cs.common.entity.source.ContextID; import com.webank.wedatasphere.linkis.cs.common.entity.source.ContextKey; import com.webank.wedatasphere.linkis.cs.common.exception.CSErrorException; @@ -26,11 +28,11 @@ import com.webank.wedatasphere.linkis.cs.server.scheduler.CsScheduler; import com.webank.wedatasphere.linkis.cs.server.scheduler.HttpAnswerJob; import com.webank.wedatasphere.linkis.server.Message; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -68,7 +70,7 @@ public Message createContext(HttpServletRequest request) throws Exception{ @RequestMapping(path = "getContextValue",method = RequestMethod.POST) - public Message getContextValue( HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { + public Message getContextValue( HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException { //ContextID contextID, ContextKey contextKey ContextID contextID = new PersistenceContextID(); contextID.setContextId("84716"); @@ -98,16 +100,16 @@ public Message getContextValue( HttpServletRequest req, JsonNode jsonNode) throw } }*/ @RequestMapping(path = "searchContextValue",method = RequestMethod.POST) - public Message searchContextValue( HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { + public Message searchContextValue( HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException { ContextID contextID = objectMapper.convertValue(jsonNode.get("contextID"), PersistenceContextID.class); - Map conditionMap = objectMapper.convertValue(jsonNode.get("condition"), new org.codehaus.jackson.type.TypeReference>() { + Map conditionMap = objectMapper.convertValue(jsonNode.get("condition"), new TypeReference>() { }); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.SEARCH, contextID, conditionMap); return generateResponse(answerJob, ""); } /* @RequestMapping(path = "searchContextValueByCondition",method = RequestMethod.GET) - public Message searchContextValueByCondition( HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { + public Message searchContextValueByCondition( HttpServletRequest req, @RequestBody JsonNode jsonNode) throws InterruptedException { Condition condition = null; HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.SEARCH, condition); return generateResponse(answerJob,""); @@ -115,7 +117,7 @@ public Message searchContextValueByCondition( HttpServletRequest req, JsonNode j @RequestMapping(path = "setValueByKey",method = RequestMethod.POST) - public Message setValueByKey( HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException { + public Message setValueByKey( HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException { /*JSONSerializer jsonSerializer = new JSONSerializer(); PersistenceContextID contextID = new PersistenceContextID(); //// TODO: 2020/2/26 手动修改contextid @@ -138,7 +140,7 @@ public Message setValueByKey( HttpServletRequest req, JsonNode jsonNode) throws } @RequestMapping(path = "setValue",method = RequestMethod.POST) - public Message setValue( HttpServletRequest req, JsonNode jsonNode) throws InterruptedException, CSErrorException { + public Message setValue( HttpServletRequest req, @RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException { /*JSONSerializer jsonSerializer = new JSONSerializer(); PersistenceContextID contextID = new PersistenceContextID(); //// TODO: 2020/2/26 手动修改contextid @@ -165,7 +167,7 @@ public Message setValue( HttpServletRequest req, JsonNode jsonNode) throws Inter } @RequestMapping(path = "resetValue",method = RequestMethod.POST) - public Message resetValue( HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { + public Message resetValue( HttpServletRequest req, @RequestBody JsonNode jsonNode) throws InterruptedException { ContextID contextID = null; ContextKey contextKey = null; HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.RESET, contextID, contextKey); @@ -173,7 +175,7 @@ public Message resetValue( HttpServletRequest req, JsonNode jsonNode) throws Int } @RequestMapping(path = "removeValue",method = RequestMethod.POST) - public Message removeValue( HttpServletRequest req,JsonNode jsonNode) throws InterruptedException { + public Message removeValue( HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException { ContextID contextID = new PersistenceContextID(); contextID.setContextId("84716"); ContextKey contextKey = new PersistenceContextKey(); @@ -183,7 +185,7 @@ public Message removeValue( HttpServletRequest req,JsonNode jsonNode) throws Int } @RequestMapping(path = "removeAllValue",method = RequestMethod.POST) - public Message removeAllValue( HttpServletRequest req, JsonNode jsonNode) throws InterruptedException { + public Message removeAllValue( HttpServletRequest req, @RequestBody JsonNode jsonNode) throws InterruptedException { ContextID contextID = new PersistenceContextID(); contextID.setContextId("84716"); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.REMOVEALL, contextID); diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/api/DataSourceRestfulApi.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/api/DataSourceRestfulApi.java index 1c67604e14..fb31362268 100644 --- a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/api/DataSourceRestfulApi.java +++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/api/DataSourceRestfulApi.java @@ -21,7 +21,7 @@ import com.webank.wedatasphere.linkis.server.Message; import com.webank.wedatasphere.linkis.server.security.SecurityFilter; import org.apache.log4j.Logger; -import org.codehaus.jackson.JsonNode; +import com.fasterxml.jackson.databind.JsonNode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -40,6 +40,7 @@ public class DataSourceRestfulApi implements DataSourceRestfulRemote { DataSourceService dataSourceService; + @Override @RequestMapping(path = "dbs",method = RequestMethod.GET) public Message queryDatabaseInfo(HttpServletRequest req) { String userName = SecurityFilter.getLoginUsername(req); @@ -52,6 +53,7 @@ public Message queryDatabaseInfo(HttpServletRequest req) { } } + @Override @RequestMapping(path = "all",method = RequestMethod.GET) public Message queryDbsWithTables(HttpServletRequest req){ String userName = SecurityFilter.getLoginUsername(req); @@ -65,6 +67,7 @@ public Message queryDbsWithTables(HttpServletRequest req){ } + @Override @RequestMapping(path = "tables",method = RequestMethod.GET) public Message queryTables(@RequestParam(value="database",required=false) String database, HttpServletRequest req){ String userName = SecurityFilter.getLoginUsername(req); @@ -77,6 +80,7 @@ public Message queryTables(@RequestParam(value="database",required=false) String } } + @Override @RequestMapping(path = "columns",method = RequestMethod.GET) public Message queryTableMeta(@RequestParam(value="database",required=false) String database, @RequestParam(value="table",required=false) String table, HttpServletRequest req){ String userName = SecurityFilter.getLoginUsername(req); @@ -89,6 +93,7 @@ public Message queryTableMeta(@RequestParam(value="database",required=false) Str } } + @Override @RequestMapping(path = "size",method = RequestMethod.GET) public Message sizeOf(@RequestParam(value="database",required=false) String database, @RequestParam(value="table",required=false) String table, @RequestParam(value="partition",required=false) String partition, HttpServletRequest req){ String userName = SecurityFilter.getLoginUsername(req); @@ -106,6 +111,7 @@ public Message sizeOf(@RequestParam(value="database",required=false) String data } } + @Override @RequestMapping(path = "partitions",method = RequestMethod.GET) public Message partitions(@RequestParam(value="database",required=false) String database, @RequestParam(value="table",required=false) String table, HttpServletRequest req){ String userName = SecurityFilter.getLoginUsername(req); diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/api/MdqTableRestfulApi.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/api/MdqTableRestfulApi.java index 7c8c553e3a..3c372a3744 100644 --- a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/api/MdqTableRestfulApi.java +++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/restful/api/MdqTableRestfulApi.java @@ -15,7 +15,6 @@ */ package com.webank.wedatasphere.linkis.metadata.restful.api; - import com.webank.wedatasphere.linkis.metadata.ddl.ImportDDLCreator; import com.webank.wedatasphere.linkis.metadata.ddl.ScalaDDLCreator; import com.webank.wedatasphere.linkis.metadata.domain.mdq.bo.MdqTableBO; @@ -28,11 +27,12 @@ import com.webank.wedatasphere.linkis.metadata.service.MdqService; import com.webank.wedatasphere.linkis.server.Message; import com.webank.wedatasphere.linkis.server.security.SecurityFilter; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -143,23 +143,23 @@ public Message active(@RequestParam(value="tableId",required=false) Long tableId } @RequestMapping(path = "persistTable",method = RequestMethod.POST) - public Message persistTable( HttpServletRequest req, JsonNode json) throws IOException { + public Message persistTable( HttpServletRequest req, @RequestBody JsonNode json) throws IOException { String userName = SecurityFilter.getLoginUsername(req); - MdqTableBO table = mapper.readValue(json.get("table"), MdqTableBO.class); + MdqTableBO table = mapper.treeToValue(json.get("table"), MdqTableBO.class); mdqService.persistTable(table, userName); return Message.ok(); } @RequestMapping(path = "displaysql",method = RequestMethod.POST) - public Message displaySql( HttpServletRequest request, JsonNode json) { + public Message displaySql( HttpServletRequest request, @RequestBody JsonNode json) { String userName = SecurityFilter.getLoginUsername(request); logger.info("display sql for user {} ", userName); StringBuilder sb = new StringBuilder(); String retSql = ""; MdqTableBO tableBO = null; try { - tableBO = mapper.readValue(json.get("table"), MdqTableBO.class); + tableBO = mapper.treeToValue(json.get("table"), MdqTableBO.class); MdqTableImportInfoBO importInfo = tableBO.getImportInfo(); if (importInfo != null) { retSql = ImportDDLCreator.createDDL(tableBO, userName); diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/service/DataSourceService.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/service/DataSourceService.java index ba742039ca..f6a3d630f3 100644 --- a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/service/DataSourceService.java +++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/service/DataSourceService.java @@ -16,7 +16,7 @@ package com.webank.wedatasphere.linkis.metadata.service; -import org.codehaus.jackson.JsonNode; +import com.fasterxml.jackson.databind.JsonNode; public interface DataSourceService { diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/service/impl/DataSourceServiceImpl.java b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/service/impl/DataSourceServiceImpl.java index c8e9b8b371..7621f7373e 100644 --- a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/service/impl/DataSourceServiceImpl.java +++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/java/com/webank/wedatasphere/linkis/metadata/service/impl/DataSourceServiceImpl.java @@ -13,6 +13,9 @@ package com.webank.wedatasphere.linkis.metadata.service.impl; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ArrayNode; +import com.fasterxml.jackson.databind.node.ObjectNode; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.webank.wedatasphere.linkis.common.utils.ByteTimeUtils; @@ -27,10 +30,7 @@ import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.apache.log4j.Logger; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.node.ArrayNode; -import org.codehaus.jackson.node.ObjectNode; +import com.fasterxml.jackson.databind.JsonNode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/scala/com/webank/wedatasphere/linkis/metadata/ddl/DDLHelper.scala b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/scala/com/webank/wedatasphere/linkis/metadata/ddl/DDLHelper.scala index 363434d929..9f9ab5ee13 100644 --- a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/scala/com/webank/wedatasphere/linkis/metadata/ddl/DDLHelper.scala +++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/scala/com/webank/wedatasphere/linkis/metadata/ddl/DDLHelper.scala @@ -18,11 +18,11 @@ package com.webank.wedatasphere.linkis.metadata.ddl import java.util +import com.fasterxml.jackson.databind.ObjectMapper import com.webank.wedatasphere.linkis.common.exception.ErrorException import com.webank.wedatasphere.linkis.common.utils.Logging import com.webank.wedatasphere.linkis.metadata.ddl.ScalaDDLCreator.{CODE, USER} import com.webank.wedatasphere.linkis.metadata.domain.mdq.bo.MdqTableBO -import org.codehaus.jackson.map.ObjectMapper object DDLHelper extends Logging { def createDDL(params:util.Map[String, Object]):String = { @@ -34,7 +34,7 @@ object DDLHelper extends Logging { //val mdqTableVO = MdqUtils.gson.fromJson(code, classOf[MdqTableVO]) val mapper = new ObjectMapper val jsonNode = mapper.readTree(code) - val mdqTableBO = mapper.readValue(jsonNode, classOf[MdqTableBO]) + val mdqTableBO = mapper.treeToValue(jsonNode, classOf[MdqTableBO]) val importInfo = mdqTableBO.getImportInfo if (importInfo != null){ //如果importInfo 不是空的话,就走的导入hive流程 diff --git a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/scala/com/webank/wedatasphere/linkis/metadata/receiver/MDQReceiver.scala b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/scala/com/webank/wedatasphere/linkis/metadata/receiver/MDQReceiver.scala index 512360315e..0564f4603d 100644 --- a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/scala/com/webank/wedatasphere/linkis/metadata/receiver/MDQReceiver.scala +++ b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/main/scala/com/webank/wedatasphere/linkis/metadata/receiver/MDQReceiver.scala @@ -18,6 +18,7 @@ package com.webank.wedatasphere.linkis.metadata.receiver import java.util +import com.fasterxml.jackson.databind.ObjectMapper import com.webank.wedatasphere.linkis.common.utils.{Logging, Utils} import com.webank.wedatasphere.linkis.metadata.ddl.DDLHelper import com.webank.wedatasphere.linkis.metadata.domain.mdq.bo.MdqTableBO @@ -25,7 +26,6 @@ import com.webank.wedatasphere.linkis.metadata.service.MdqService import com.webank.wedatasphere.linkis.metadata.utils.MdqUtils import com.webank.wedatasphere.linkis.protocol.mdq.{DDLCompleteResponse, DDLExecuteResponse, DDLRequest, DDLResponse} import com.webank.wedatasphere.linkis.rpc.{Receiver, Sender} -import org.codehaus.jackson.map.ObjectMapper import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Component @@ -55,7 +55,7 @@ class MDQReceiver extends Receiver with Logging{ // val mdqTableBO = MdqUtils.gson.fromJson(code, classOf[MdqTableBO]) val mapper = new ObjectMapper val jsonNode = mapper.readTree(code) - val mdqTableBO = mapper.readValue(jsonNode, classOf[MdqTableBO]) + val mdqTableBO = mapper.treeToValue(jsonNode, classOf[MdqTableBO]) val tableName = mdqTableBO.getTableBaseInfo.getBase.getName val dbName = mdqTableBO.getTableBaseInfo.getBase.getDatabase logger.info(s"begin to persist table $dbName $tableName") @@ -85,7 +85,7 @@ class MDQReceiver extends Receiver with Logging{ //存储数据 val mapper = new ObjectMapper val jsonNode = mapper.readTree(code) - val mdqTableBO = mapper.readValue(jsonNode, classOf[MdqTableBO]) + val mdqTableBO = mapper.treeToValue(jsonNode, classOf[MdqTableBO]) val tableName = mdqTableBO.getTableBaseInfo.getBase.getName val dbName = mdqTableBO.getTableBaseInfo.getBase.getDatabase logger.info(s"begin to persist table $dbName $tableName") diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/java/com/webank/wedatasphere/linkis/configuration/restful/api/ConfigurationRestfulApi.java b/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/java/com/webank/wedatasphere/linkis/configuration/restful/api/ConfigurationRestfulApi.java index 967b6a94f6..4277bda358 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/java/com/webank/wedatasphere/linkis/configuration/restful/api/ConfigurationRestfulApi.java +++ b/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/java/com/webank/wedatasphere/linkis/configuration/restful/api/ConfigurationRestfulApi.java @@ -16,6 +16,7 @@ package com.webank.wedatasphere.linkis.configuration.restful.api; +import com.fasterxml.jackson.databind.ObjectMapper; import com.netflix.discovery.converters.Auto; import com.webank.wedatasphere.linkis.configuration.entity.*; import com.webank.wedatasphere.linkis.configuration.exception.ConfigurationException; @@ -30,10 +31,10 @@ import com.webank.wedatasphere.linkis.server.BDPJettyServerHelper; import com.webank.wedatasphere.linkis.server.Message; import com.webank.wedatasphere.linkis.server.security.SecurityFilter; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -159,7 +160,7 @@ public Message getCategory(HttpServletRequest req){ } @RequestMapping(path = "/createFirstCategory",method = RequestMethod.POST) - public Message createFirstCategory(HttpServletRequest request, JsonNode jsonNode) throws ConfigurationException { + public Message createFirstCategory(HttpServletRequest request, @RequestBody JsonNode jsonNode) throws ConfigurationException { String username = SecurityFilter.getLoginUsername(request); String categoryName = jsonNode.get("categoryName").asText(); String description = jsonNode.get("description").asText(); @@ -171,7 +172,7 @@ public Message createFirstCategory(HttpServletRequest request, JsonNode jsonNode } @RequestMapping(path = "/deleteCategory",method = RequestMethod.POST) - public Message deleteCategory(HttpServletRequest request, JsonNode jsonNode){ + public Message deleteCategory(HttpServletRequest request, @RequestBody JsonNode jsonNode){ String username = SecurityFilter.getLoginUsername(request); Integer categoryId = jsonNode.get("categoryId").asInt(); categoryService.deleteCategory(categoryId); @@ -180,7 +181,7 @@ public Message deleteCategory(HttpServletRequest request, JsonNode jsonNode){ @RequestMapping(path = "/createSecondCategory",method = RequestMethod.POST) - public Message createSecondCategory(HttpServletRequest request, JsonNode jsonNode) throws ConfigurationException { + public Message createSecondCategory(HttpServletRequest request, @RequestBody JsonNode jsonNode) throws ConfigurationException { String username = SecurityFilter.getLoginUsername(request); Integer categoryId = jsonNode.get("categoryId").asInt(); String engineType = jsonNode.get("engineType").asText(); @@ -201,8 +202,8 @@ public Message createSecondCategory(HttpServletRequest request, JsonNode jsonNod @RequestMapping(path = "/saveFullTree",method = RequestMethod.POST) - public Message saveFullTree(HttpServletRequest req, JsonNode json) throws IOException, ConfigurationException { - List fullTrees = mapper.readValue(json.get("fullTree"), List.class); + public Message saveFullTree(HttpServletRequest req, @RequestBody JsonNode json) throws IOException, ConfigurationException { + List fullTrees = mapper.treeToValue(json.get("fullTree"), List.class); String creator = JsonNodeUtil.getStringValue(json.get("creator")); String engineType = JsonNodeUtil.getStringValue(json.get("engineType")); if(creator != null && (creator.equals("通用设置") || creator.equals("全局设置"))){ @@ -243,7 +244,7 @@ public Message listAllEngineType(HttpServletRequest request){ } @RequestMapping(path = "/updateCategoryInfo",method = RequestMethod.POST) - public Message updateCategoryInfo(HttpServletRequest request, JsonNode jsonNode) throws ConfigurationException { + public Message updateCategoryInfo(HttpServletRequest request, @RequestBody JsonNode jsonNode) throws ConfigurationException { String username = SecurityFilter.getLoginUsername(request); String description = null; Integer categoryId = null; diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/scala/com/webank/wedatasphere/linkis/configuration/util/JsonNodeUtil.scala b/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/scala/com/webank/wedatasphere/linkis/configuration/util/JsonNodeUtil.scala index 7e2f118cc3..58a5f89bdd 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/scala/com/webank/wedatasphere/linkis/configuration/util/JsonNodeUtil.scala +++ b/linkis-public-enhancements/linkis-publicservice/linkis-configuration/src/main/scala/com/webank/wedatasphere/linkis/configuration/util/JsonNodeUtil.scala @@ -1,6 +1,6 @@ package com.webank.wedatasphere.linkis.configuration.util -import org.codehaus.jackson.JsonNode +import com.fasterxml.jackson.databind.JsonNode object JsonNodeUtil { diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-server/src/main/java/com/webank/wedatasphere/linkis/instance/label/restful/InstanceRestful.java b/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-server/src/main/java/com/webank/wedatasphere/linkis/instance/label/restful/InstanceRestful.java index 18e0208979..4c3fff39fe 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-server/src/main/java/com/webank/wedatasphere/linkis/instance/label/restful/InstanceRestful.java +++ b/linkis-public-enhancements/linkis-publicservice/linkis-instance-label/linkis-instance-label-server/src/main/java/com/webank/wedatasphere/linkis/instance/label/restful/InstanceRestful.java @@ -32,8 +32,9 @@ import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.codehaus.jackson.JsonNode; +import com.fasterxml.jackson.databind.JsonNode; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -64,7 +65,7 @@ public Message listAllInstanceWithLabel( HttpServletRequest req){ } @RequestMapping(path = "/instanceLabel",method = RequestMethod.PUT) - public Message upDateInstanceLabel( HttpServletRequest req, JsonNode jsonNode) throws Exception { + public Message upDateInstanceLabel( HttpServletRequest req, @RequestBody JsonNode jsonNode) throws Exception { String username = SecurityFilter.getLoginUsername(req); String[] adminArray = InstanceConfigration.GOVERNANCE_STATION_ADMIN().getValue().split(","); if(adminArray != null && !Arrays.asList(adminArray).contains(username)){ diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/FsRestfulApi.java b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/FsRestfulApi.java index 0fb2072801..f66ef2dd4b 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/FsRestfulApi.java +++ b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/FsRestfulApi.java @@ -41,7 +41,7 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.math3.util.Pair; import org.apache.http.Consts; -import org.codehaus.jackson.JsonNode; +import com.fasterxml.jackson.databind.JsonNode; import org.glassfish.jersey.media.multipart.FormDataBodyPart; import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataMultiPart; @@ -101,9 +101,9 @@ public Message getUserRootPath(HttpServletRequest req, @RequestParam(value="path } @RequestMapping(path = "/createNewDir",method = RequestMethod.POST) - public Message createNewDir(HttpServletRequest req, JsonNode json) throws IOException, WorkSpaceException { + public Message createNewDir(HttpServletRequest req,@RequestBody JsonNode json) throws IOException, WorkSpaceException { String userName = SecurityFilter.getLoginUsername(req); - String path = json.get("path").getTextValue(); + String path = json.get("path").textValue(); if (StringUtils.isEmpty(path)) { throw WorkspaceExceptionManager.createException(80004, path); } @@ -118,9 +118,9 @@ public Message createNewDir(HttpServletRequest req, JsonNode json) throws IOExce } @RequestMapping(path = "/createNewFile",method = RequestMethod.POST) - public Message createNewFile(HttpServletRequest req, JsonNode json) throws IOException, WorkSpaceException { + public Message createNewFile(HttpServletRequest req,@RequestBody JsonNode json) throws IOException, WorkSpaceException { String userName = SecurityFilter.getLoginUsername(req); - String path = json.get("path").getTextValue(); + String path = json.get("path").textValue(); if (StringUtils.isEmpty(path)) { throw WorkspaceExceptionManager.createException(80004, path); } @@ -135,9 +135,9 @@ public Message createNewFile(HttpServletRequest req, JsonNode json) throws IOExc } @RequestMapping(path = "/rename",method = RequestMethod.POST) - public Message rename(HttpServletRequest req, JsonNode json) throws IOException, WorkSpaceException { - String oldDest = json.get("oldDest").getTextValue(); - String newDest = json.get("newDest").getTextValue(); + public Message rename(HttpServletRequest req,@RequestBody JsonNode json) throws IOException, WorkSpaceException { + String oldDest = json.get("oldDest").textValue(); + String newDest = json.get("newDest").textValue(); String userName = SecurityFilter.getLoginUsername(req); if (FILESYSTEM_PATH_CHECK_TRIGGER.getValue()) { LOGGER.info(String.format("path check trigger is open,now check the path,oldDest:%s,newDest:%s", oldDest, newDest)); @@ -188,9 +188,9 @@ public Message upload(HttpServletRequest req, } @RequestMapping(path = "/deleteDirOrFile",method = RequestMethod.POST) - public Message deleteDirOrFile(HttpServletRequest req, JsonNode json) throws IOException, WorkSpaceException { + public Message deleteDirOrFile(HttpServletRequest req,@RequestBody JsonNode json) throws IOException, WorkSpaceException { String userName = SecurityFilter.getLoginUsername(req); - String path = json.get("path").getTextValue(); + String path = json.get("path").textValue(); if (StringUtils.isEmpty(path)) { throw WorkspaceExceptionManager.createException(80004, path); } diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/SpringPathValidator.scala b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/SpringPathValidator.scala new file mode 100644 index 0000000000..4b9c665a86 --- /dev/null +++ b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/SpringPathValidator.scala @@ -0,0 +1,146 @@ +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.webank.wedatasphere.linkis.filesystem.validator + +import java.io.File + +import com.fasterxml.jackson.databind.JsonNode +import com.webank.wedatasphere.linkis.common.utils.Logging +import com.webank.wedatasphere.linkis.filesystem.conf.WorkSpaceConfiguration._ +import com.webank.wedatasphere.linkis.filesystem.exception.WorkSpaceException +import com.webank.wedatasphere.linkis.filesystem.util.WorkspaceUtil +import com.webank.wedatasphere.linkis.server +import com.webank.wedatasphere.linkis.server.{Message, catchIt} +import com.webank.wedatasphere.linkis.server.security.SecurityFilter +import com.webank.wedatasphere.linkis.storage.utils.StorageUtils +import javax.servlet.http.{HttpServletRequest, HttpServletResponse} +import org.aspectj.lang.ProceedingJoinPoint +import org.aspectj.lang.annotation.{Around, Aspect, Pointcut} +import org.aspectj.lang.reflect.MethodSignature +import org.springframework.stereotype.Component +import org.springframework.util.StringUtils +import org.springframework.web.context.request.{RequestContextHolder, ServletRequestAttributes} + +@Aspect +@Component +class SpringPathValidator extends Logging { + + @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping) && within(com.webank.wedatasphere.linkis.filesystem.restful.api.*)") + def restfulResponseCatch1(): Unit = {} + + def getPath(args: Array[Object], paramNames: Array[String]): String = { + var path: String = null + var index: Int = paramNames.indexOf("path") + if (index != -1) { + path = args(index).asInstanceOf[String] + } else { + index = paramNames.indexOf("json") + if (index != -1) { + args(index) match { + case j: JsonNode if j.get("path") != null => path = j.get("path").textValue() + case m: java.util.Map[String, Object] if m.get("path") != null => path = m.get("path").asInstanceOf[String] + case _ => + } + } + } + path + } + + def getUserName(args: Array[Object], paramNames: Array[String]): String = { + var username: String = null + paramNames.indexOf("req") match { + case -1 => + case index: Int => { + val proxyUser = paramNames.indexOf("proxyUser") + if (proxyUser == -1 || StringUtils.isEmpty(args(proxyUser))) { + username = SecurityFilter.getLoginUsername(args(index).asInstanceOf[HttpServletRequest]) + } else { + //增加proxyuser的判断 + username = args(proxyUser).toString + } + } + } + username + } + + def checkPath(path: String, username: String) = { + //校验path的逻辑 + val userLocalRootPath: String = WorkspaceUtil.suffixTuning(LOCAL_USER_ROOT_PATH.getValue) + + username + var userHdfsRootPath: String = WorkspaceUtil.suffixTuning(HDFS_USER_ROOT_PATH_PREFIX.getValue) + + username + HDFS_USER_ROOT_PATH_SUFFIX.getValue + if (!(path.contains(StorageUtils.FILE_SCHEMA)) && !(path.contains(StorageUtils.HDFS_SCHEMA))) { + throw new WorkSpaceException(80025, "the path should contain schema") + } + userHdfsRootPath = StringUtils.trimTrailingCharacter(userHdfsRootPath, File.separatorChar) + if (path.contains("../")) { + throw new WorkSpaceException(80026, "Relative path not allowed") + } + if (!(path.contains(userLocalRootPath)) && !(path.contains(userHdfsRootPath))) { + throw new WorkSpaceException(80027, "The path needs to be within the user's own workspace path") + } + } + + def validate(args: Array[Object], paramNames: Array[String]) = { + //获取path:String,json:JsonNode,json:Map中的path 参数 + val path: String = getPath(args, paramNames) + val username: String = getUserName(args, paramNames) + if (!StringUtils.isEmpty(path) && !StringUtils.isEmpty(username)) { + logger.info(String.format("user:%s,path:%s", username, path)) + checkPath(path, username) + } + } + + @Around("restfulResponseCatch1()") + def dealResponseRestful(proceedingJoinPoint: ProceedingJoinPoint): Object = { + val resp: Message = server.catchIt { + val signature = proceedingJoinPoint.getSignature.asInstanceOf[MethodSignature] + logger.info("enter the path validator,the method is {}", signature.getName) + if (FILESYSTEM_PATH_CHECK_TRIGGER.getValue) { + logger.info("path check trigger is open,now check the path") + validate(proceedingJoinPoint.getArgs, signature.getParameterNames) + } + Message.ok() + } + if ( messageToHttpStatus(resp)==200 != 200) resp else proceedingJoinPoint.proceed() + } + + def getCurrentHttpResponse: HttpServletResponse = { + val requestAttributes = RequestContextHolder.getRequestAttributes + if (requestAttributes.isInstanceOf[ServletRequestAttributes]) { + val response = requestAttributes.asInstanceOf[ServletRequestAttributes].getResponse + return response + } + null + } + def messageToHttpStatus(message: Message): Int = message.getStatus match { + case -1 => 401 + case 0 => 200 + case 1 => 400 + case 2 => 412 + case 3 => 403 + case 4 => 206 + } + +} + +object SpringPathValidator { + val validator = new SpringPathValidator() + + def validate(path: String, username: String): Unit = { + validator.checkPath(path, username) + } +} + + diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-service/src/main/java/com/webank/wedatasphere/linkis/udf/api/UDFApi.java b/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-service/src/main/java/com/webank/wedatasphere/linkis/udf/api/UDFApi.java index d7b881bd4b..659069e12e 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-service/src/main/java/com/webank/wedatasphere/linkis/udf/api/UDFApi.java +++ b/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-service/src/main/java/com/webank/wedatasphere/linkis/udf/api/UDFApi.java @@ -18,6 +18,7 @@ +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.webank.wedatasphere.linkis.common.io.FsPath; @@ -31,8 +32,7 @@ import com.webank.wedatasphere.linkis.udf.utils.ConstantVar; import org.apache.commons.collections.CollectionUtils; import org.apache.log4j.Logger; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; @@ -140,11 +140,11 @@ public Message listUDF(HttpServletRequest req, Map json){ } @RequestMapping(path = "add",method = RequestMethod.POST) - public Message addUDF(HttpServletRequest req, JsonNode json) { + public Message addUDF(HttpServletRequest req,@RequestBody JsonNode json) { Message message = null; try { String userName = SecurityFilter.getLoginUsername(req); - UDFInfo udfInfo = mapper.readValue(json.get("udfInfo"), UDFInfo.class); + UDFInfo udfInfo = mapper.treeToValue(json.get("udfInfo"), UDFInfo.class); udfInfo.setCreateUser(userName); udfInfo.setCreateTime(new Date()); udfInfo.setUpdateTime(new Date()); @@ -159,11 +159,11 @@ public Message addUDF(HttpServletRequest req, JsonNode json) { } @RequestMapping(path = "update",method = RequestMethod.POST) - public Message updateUDF(HttpServletRequest req, JsonNode json) { + public Message updateUDF(HttpServletRequest req,@RequestBody JsonNode json) { Message message = null; try { String userName = SecurityFilter.getLoginUsername(req); - UDFInfo udfInfo = mapper.readValue(json.get("udfInfo"), UDFInfo.class); + UDFInfo udfInfo = mapper.treeToValue(json.get("udfInfo"), UDFInfo.class); udfInfo.setCreateUser(userName); udfInfo.setUpdateTime(new Date()); udfService.updateUDF(udfInfo, userName); @@ -261,7 +261,7 @@ public Message deleteTree(HttpServletRequest req,@PathVariable("id") Long id){ } @RequestMapping(path = "/authenticate",method = RequestMethod.POST) - public Message Authenticate(HttpServletRequest req, JsonNode json){ + public Message Authenticate(HttpServletRequest req,@RequestBody JsonNode json){ Message message = null; try { String userName = SecurityFilter.getLoginUsername(req); @@ -280,18 +280,18 @@ public Message Authenticate(HttpServletRequest req, JsonNode json){ @RequestMapping(path = "/setExpire",method = RequestMethod.POST) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,rollbackFor = Throwable.class) - public Message setExpire(HttpServletRequest req, JsonNode json){ + public Message setExpire(HttpServletRequest req,@RequestBody JsonNode json){ Message message = null; try { String userName = SecurityFilter.getLoginUsername(req); if (StringUtils.isEmpty(userName)){ throw new UDFException("UserName is Empty!"); } - Long udfId =json.get("udfId").getLongValue(); + Long udfId =json.get("udfId").longValue(); if (StringUtils.isEmpty(udfId)){ throw new UDFException("udfId is Empty!"); } - String udfName = json.get("udfName").getTextValue(); + String udfName = json.get("udfName").textValue(); if (StringUtils.isEmpty(udfName)){ throw new UDFException("udfName is Empty!"); } @@ -317,21 +317,21 @@ public Message setExpire(HttpServletRequest req, JsonNode json){ @RequestMapping(path = "/shareUDF",method = RequestMethod.POST) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,rollbackFor = Throwable.class) - public Message shareUDF(HttpServletRequest req, JsonNode json)throws Throwable{ + public Message shareUDF(HttpServletRequest req,@RequestBody JsonNode json)throws Throwable{ Message message = null; try { String userName = SecurityFilter.getLoginUsername(req); if (StringUtils.isEmpty(userName)){ throw new UDFException("UserName is Empty!"); } - List sharedUsers = mapper.readValue(json.get("sharedUsers"), List.class); + List sharedUsers = mapper.treeToValue(json.get("sharedUsers"), List.class); if (CollectionUtils.isEmpty(sharedUsers)){ throw new UDFException("SharedUsers is Empty!"); } //Verify shared user identity(校验分享的用户身份) udfService.checkSharedUsers(sharedUsers,userName);//Throws an exception without passing the checksum (---no deduplication--)(不通过校验则抛异常(---没有去重--)) //Verify that the udf function has been shared(校验udf函数是否已经被分享) - UDFInfo udfInfo = mapper.readValue(json.get("udfInfo"), UDFInfo.class); + UDFInfo udfInfo = mapper.treeToValue(json.get("udfInfo"), UDFInfo.class); Long shareParentId = json.get("shareParentId").asLong(); @@ -368,14 +368,14 @@ public Message shareUDF(HttpServletRequest req, JsonNode json)throws Throwable{ @RequestMapping(path = "/getSharedUsers",method = RequestMethod.POST) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT,rollbackFor = Throwable.class) - public Message getSharedUsers(HttpServletRequest req, JsonNode json){ + public Message getSharedUsers(HttpServletRequest req,@RequestBody JsonNode json){ Message message = null; try { String userName = SecurityFilter.getLoginUsername(req); if (StringUtils.isEmpty(userName)){ throw new UDFException("UserName is Empty!"); } - String udfName = json.get("udfName").getTextValue(); + String udfName = json.get("udfName").textValue(); if (StringUtils.isEmpty(userName)){ throw new UDFException("udfName is Empty!"); } @@ -390,11 +390,11 @@ public Message getSharedUsers(HttpServletRequest req, JsonNode json){ } @RequestMapping(path = "/updateSharedUsers",method = RequestMethod.POST) - public Message updateSharedUsers(HttpServletRequest req, JsonNode json){ + public Message updateSharedUsers(HttpServletRequest req,@RequestBody JsonNode json){ Message message = null; try { - List sharedUsers = mapper.readValue(json.get("sharedUsers"), List.class); + List sharedUsers = mapper.treeToValue(json.get("sharedUsers"), List.class); if (CollectionUtils.isEmpty(sharedUsers)){ throw new UDFException("SharedUsers is Empty!"); } @@ -404,7 +404,7 @@ public Message updateSharedUsers(HttpServletRequest req, JsonNode json){ } //Verify shared user identity(校验分享的用户身份) udfService.checkSharedUsers(sharedUsers,userName);//Throws an exception without passing the checksum (---no deduplication--)(不通过校验则抛异常(---没有去重--)) - String udfName = json.get("udfName").getTextValue(); + String udfName = json.get("udfName").textValue(); if (StringUtils.isEmpty(userName)){ throw new UDFException("udfName is Empty!"); } diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-variable/src/main/java/com/webank/wedatasphere/linkis/variable/restful/api/VariableRestfulApi.java b/linkis-public-enhancements/linkis-publicservice/linkis-variable/src/main/java/com/webank/wedatasphere/linkis/variable/restful/api/VariableRestfulApi.java index 552a77839b..5430156e99 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-variable/src/main/java/com/webank/wedatasphere/linkis/variable/restful/api/VariableRestfulApi.java +++ b/linkis-public-enhancements/linkis-publicservice/linkis-variable/src/main/java/com/webank/wedatasphere/linkis/variable/restful/api/VariableRestfulApi.java @@ -16,16 +16,17 @@ package com.webank.wedatasphere.linkis.variable.restful.api; +import com.fasterxml.jackson.databind.ObjectMapper; import com.webank.wedatasphere.linkis.server.Message; import com.webank.wedatasphere.linkis.server.security.SecurityFilter; import com.webank.wedatasphere.linkis.variable.entity.VarKeyValueVO; import com.webank.wedatasphere.linkis.variable.exception.VariableException; import com.webank.wedatasphere.linkis.variable.service.VariableService; -import org.codehaus.jackson.JsonNode; -import org.codehaus.jackson.map.ObjectMapper; +import com.fasterxml.jackson.databind.JsonNode; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; @@ -47,7 +48,7 @@ public class VariableRestfulApi { private Logger logger = LoggerFactory.getLogger(this.getClass()); /*@RequestMapping(path = "addGlobalVariable",method = RequestMethod.POST) - public Message addGlobalVariable(HttpServletRequest req, JsonNode json) throws IOException { + public Message addGlobalVariable(HttpServletRequest req,@RequestBody JsonNode json) throws IOException { String userName = SecurityFilter.getLoginUsername(req); List globalVariables = mapper.readValue(json.get("globalVariables"), List.class); globalVariables.stream().forEach(f -> { @@ -73,10 +74,10 @@ public Message listGlobalVariable(HttpServletRequest req) { } @RequestMapping(path = "saveGlobalVariable",method = RequestMethod.POST) - public Message saveGlobalVariable(HttpServletRequest req, JsonNode json) throws IOException, VariableException { + public Message saveGlobalVariable(HttpServletRequest req,@RequestBody JsonNode json) throws IOException, VariableException { String userName = SecurityFilter.getLoginUsername(req); List userVariables = variableService.listGlobalVariable(userName); - List globalVariables = mapper.readValue(json.get("globalVariables"), List.class); + List globalVariables = mapper.treeToValue(json.get("globalVariables"), List.class); variableService.saveGlobalVaraibles(globalVariables, userVariables, userName); return Message.ok(); } From 6be06dc4d65f426d4fa97a7d1dbc376ab5828222 Mon Sep 17 00:00:00 2001 From: casionxia Date: Sat, 25 Sep 2021 22:05:20 +0800 Subject: [PATCH 17/29] add some logger info --- .../linkis/common/conf/BDPConfiguration.scala | 17 +++++++++++++---- .../wedatasphere/linkis/rpc/BaseRPCSender.scala | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/linkis-commons/linkis-common/src/main/scala/com/webank/wedatasphere/linkis/common/conf/BDPConfiguration.scala b/linkis-commons/linkis-common/src/main/scala/com/webank/wedatasphere/linkis/common/conf/BDPConfiguration.scala index dca8dff603..e07ed229fd 100644 --- a/linkis-commons/linkis-common/src/main/scala/com/webank/wedatasphere/linkis/common/conf/BDPConfiguration.scala +++ b/linkis-commons/linkis-common/src/main/scala/com/webank/wedatasphere/linkis/common/conf/BDPConfiguration.scala @@ -43,14 +43,20 @@ private[conf] object BDPConfiguration extends Logging { // load pub linkis conf val propertyFile = sysProps.getOrElse("wds.linkis.configuration", DEFAULT_PROPERTY_FILE_NAME) val configFileURL = getClass.getClassLoader.getResource(propertyFile) - if (configFileURL != null && new File(configFileURL.getPath).exists) initConfig(config, configFileURL.getPath) + if (configFileURL != null && new File(configFileURL.getPath).exists) { + initConfig(config, configFileURL.getPath) + info(s"******************************** Info: The Linkis read $propertyFile file from $configFileURL !***************************") + } else warn(s"******************************** Notice: The Linkis configuration file $propertyFile is not exists! ***************************") // load pub linkis conf val serverConf = sysProps.getOrElse("wds.linkis.server.conf", DEFAULT_SERVER_CONF_FILE_NAME) val serverConfFileURL = getClass.getClassLoader.getResource(serverConf) - if (serverConfFileURL != null && new File(serverConfFileURL.getPath).exists) initConfig(config, serverConfFileURL.getPath) - else warn(s"******************************** Notice: The Linkis serverConf file $serverConfFileURL is not exists! ***************************") + if (serverConfFileURL != null && new File(serverConfFileURL.getPath).exists) { + initConfig(config, serverConfFileURL.getPath) + info(s"******************************** Info: The Linkis read $serverConf file from $serverConfFileURL !***************************") + } + else warn(s"******************************** Notice: The Linkis serverConf file $serverConf is not exists! ***************************") // load server confs val propertyFileOptions = sysProps.get("wds.linkis.server.confs") @@ -58,7 +64,10 @@ private[conf] object BDPConfiguration extends Logging { val propertyFiles = propertyFileOptions.get.split(",") propertyFiles.foreach { propertyF => val configFileURL = getClass.getClassLoader.getResource(propertyF) - if (configFileURL != null && new File(configFileURL.getPath).exists) initConfig(config, configFileURL.getPath) + if (configFileURL != null && new File(configFileURL.getPath).exists) { + initConfig(config, configFileURL.getPath) + info(s"******************************** Info: The Linkis read $propertyF file from $configFileURL !***************************") + } else warn(s"******************************** Notice: The Linkis configuration file $propertyF is not exists! ***************************") } } diff --git a/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/BaseRPCSender.scala b/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/BaseRPCSender.scala index bcf45a194c..aeb8c88373 100644 --- a/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/BaseRPCSender.scala +++ b/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/BaseRPCSender.scala @@ -28,6 +28,7 @@ import com.webank.wedatasphere.linkis.rpc.interceptor._ import com.webank.wedatasphere.linkis.rpc.transform.{RPCConsumer, RPCProduct} import com.webank.wedatasphere.linkis.server.Message import com.webank.wedatasphere.linkis.server.conf.ServerConfiguration +import feign.slf4j.Slf4jLogger import feign.{Feign, Retryer} import scala.concurrent.duration.Duration @@ -63,7 +64,7 @@ private[rpc] class BaseRPCSender extends Sender with Logging { builder.retryer(Retryer.NEVER_RETRY) protected def newRPC: RPCReceiveRemote = { - val builder = Feign.builder + val builder = Feign.builder.logger(new Slf4jLogger()).logLevel(feign.Logger.Level.FULL) doBuilder(builder) var url = if(name.startsWith("http://")) name else "http://" + name if(url.endsWith("/")) url = url.substring(0, url.length - 1) From 00f2cc2957265625d8749e615d7eaa42b244b721 Mon Sep 17 00:00:00 2001 From: casionxia Date: Sun, 26 Sep 2021 14:42:46 +0800 Subject: [PATCH 18/29] add requestbody --- .../linkis/rpc/MessageRPCReceiveRestful.scala | 18 +++++++++-------- .../linkis/rpc/RPCReceiveRestful.scala | 20 ++++++++++--------- .../rpc/conf/RPCSpringConfiguration.scala | 2 +- .../entrance/restful/EntranceRestfulApi.java | 4 ++-- 4 files changed, 24 insertions(+), 20 deletions(-) diff --git a/linkis-commons/linkis-message-scheduler/src/main/scala/com/webank/wedatasphere/linkis/rpc/MessageRPCReceiveRestful.scala b/linkis-commons/linkis-message-scheduler/src/main/scala/com/webank/wedatasphere/linkis/rpc/MessageRPCReceiveRestful.scala index 8b03336950..6e58122027 100644 --- a/linkis-commons/linkis-message-scheduler/src/main/scala/com/webank/wedatasphere/linkis/rpc/MessageRPCReceiveRestful.scala +++ b/linkis-commons/linkis-message-scheduler/src/main/scala/com/webank/wedatasphere/linkis/rpc/MessageRPCReceiveRestful.scala @@ -27,14 +27,16 @@ import javax.servlet.http.HttpServletRequest import org.apache.commons.lang.StringUtils import org.springframework.beans.factory.annotation.Autowired import org.springframework.context.annotation.{Import, Primary} -import org.springframework.web.bind.annotation.{RequestMapping, RequestMethod, RestController} +import org.springframework.stereotype.Component +import org.springframework.web.bind.annotation.{RequestBody, RequestMapping, RequestMethod, RestController} import org.springframework.web.context.request.{RequestContextHolder, ServletRequestAttributes} import scala.concurrent.duration.Duration import scala.runtime.BoxedUnit +//@Component +//@RequestMapping(path = Array("/rpc")) @RestController -@RequestMapping(path = Array("/rpc")) @Primary @Import(Array(classOf[MessageRPCConsumer])) class MessageRPCReceiveRestful extends RPCReceiveRestful { @@ -90,8 +92,8 @@ class MessageRPCReceiveRestful extends RPCReceiveRestful { null } - @RequestMapping(path = Array("receive"),method = Array(RequestMethod.POST)) - override def receive(message: Message): Message = invokeReceiver(message, _.receive(_, _)) + @RequestMapping(path = Array("/rpc/receive"),method = Array(RequestMethod.POST)) + override def receive(@RequestBody message: Message): Message = invokeReceiver(message, _.receive(_, _)) private def invokeReceiver(message: Message, opEvent: (Receiver, Any, Sender) => Message)(implicit req: HttpServletRequest): Message = catchIt { message.getData.put(REQUEST_KEY, req) @@ -101,11 +103,11 @@ class MessageRPCReceiveRestful extends RPCReceiveRestful { event.map(opEvent(_, obj, event)).getOrElse(RPCProduct.getRPCProduct.notFound()) } - @RequestMapping(path = Array("receiveAndReply"),method =Array(RequestMethod.POST)) - override def receiveAndReply(message: Message): Message = invokeReceiver(message, _.receiveAndReply(_, _)) + @RequestMapping(path = Array("/rpc/receiveAndReply"),method =Array(RequestMethod.POST)) + override def receiveAndReply(@RequestBody message: Message): Message = invokeReceiver(message, _.receiveAndReply(_, _)) - @RequestMapping(path = Array("replyInMills"),method = Array(RequestMethod.POST)) - override def receiveAndReplyInMills(message: Message): Message = catchIt { + @RequestMapping(path = Array("/rpc/replyInMills"),method = Array(RequestMethod.POST)) + override def receiveAndReplyInMills(@RequestBody message: Message): Message = catchIt { val duration = message.getData.get("duration") if (duration == null || StringUtils.isEmpty(duration.toString)) throw new DWCURIException(10002, "The timeout period is not set!(超时时间未设置!)") val timeout = Duration(duration.toString.toLong, TimeUnit.MILLISECONDS) diff --git a/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/RPCReceiveRestful.scala b/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/RPCReceiveRestful.scala index b5dd971381..58da794e95 100644 --- a/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/RPCReceiveRestful.scala +++ b/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/RPCReceiveRestful.scala @@ -27,13 +27,15 @@ import com.webank.wedatasphere.linkis.server.{Message, catchIt} import javax.annotation.PostConstruct import org.apache.commons.lang.StringUtils import org.springframework.beans.factory.annotation.Autowired -import org.springframework.web.bind.annotation.{RequestMapping, RequestMethod, RestController} +import org.springframework.stereotype.Component +import org.springframework.web.bind.annotation.{RequestBody, RequestMapping, RequestMethod, RestController} import scala.concurrent.duration.Duration import scala.runtime.BoxedUnit -@RestController -@RequestMapping(path = Array("/rpc")) +@Component +//@RequestMapping(path = Array("/rpc")) +//@RestController private[rpc] class RPCReceiveRestful extends RPCReceiveRemote with Logging { @Autowired(required = false) @@ -112,8 +114,8 @@ private[rpc] class RPCReceiveRestful extends RPCReceiveRemote with Logging { RPCProduct.getRPCProduct.toMessage(obj) } - @RequestMapping(path = Array("receive"),method = Array(RequestMethod.POST)) - override def receive(message: Message): Message = catchIt { + @RequestMapping(path = Array("/rpc/receive"),method = Array(RequestMethod.POST)) + override def receive(@RequestBody message: Message): Message = catchIt { val obj = RPCConsumer.getRPCConsumer.toObject(message) val event = RPCMessageEvent(obj, BaseRPCSender.getInstanceInfo(message.getData)) rpcReceiverListenerBus.post(event) @@ -126,11 +128,11 @@ private[rpc] class RPCReceiveRestful extends RPCReceiveRemote with Logging { event.map(opEvent(_, obj, event)).getOrElse(RPCProduct.getRPCProduct.notFound()) } - @RequestMapping(path = Array("receiveAndReply"),method = Array(RequestMethod.POST)) - override def receiveAndReply(message: Message): Message = receiveAndReply(message, _.receiveAndReply(_, _)) + @RequestMapping(path = Array("/rpc/receiveAndReply"),method = Array(RequestMethod.POST)) + override def receiveAndReply(@RequestBody message: Message): Message = receiveAndReply(message, _.receiveAndReply(_, _)) - @RequestMapping(path = Array("replyInMills"),method = Array(RequestMethod.POST)) - override def receiveAndReplyInMills(message: Message): Message = catchIt { + @RequestMapping(path = Array("/rpc/replyInMills"),method = Array(RequestMethod.POST)) + override def receiveAndReplyInMills(@RequestBody message: Message): Message = catchIt { val duration = message.getData.get("duration") if(duration == null || StringUtils.isEmpty(duration.toString)) throw new DWCURIException(10002, "The timeout period is not set!(超时时间未设置!)") val timeout = Duration(duration.toString.toLong, TimeUnit.MILLISECONDS) diff --git a/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/conf/RPCSpringConfiguration.scala b/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/conf/RPCSpringConfiguration.scala index cb19997336..b0269f9775 100644 --- a/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/conf/RPCSpringConfiguration.scala +++ b/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/conf/RPCSpringConfiguration.scala @@ -52,4 +52,4 @@ class RPCSpringConfiguration extends Logging { info("DataWorkCloud RPC need register RPCReceiveRestful, now add it to configuration.") } -} +} \ No newline at end of file diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java b/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java index e9d41dae30..3896244cc5 100644 --- a/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java +++ b/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java @@ -68,7 +68,7 @@ public void setEntranceServer(EntranceServer entranceServer) { */ @RequestMapping(path = "/execute",method = RequestMethod.POST) - public Message execute(HttpServletRequest req, Map json) { + public Message execute(HttpServletRequest req,@RequestBody Map json) { Message message = null; // try{ logger.info("Begin to get an execID"); @@ -106,7 +106,7 @@ public Message execute(HttpServletRequest req, Map json) { @RequestMapping(path = "/submit",method = RequestMethod.POST) - public Message submit(HttpServletRequest req, Map json) { + public Message submit(HttpServletRequest req, @RequestBody Map json) { Message message = null; logger.info("Begin to get an execID"); json.put(TaskConstant.SUBMIT_USER, SecurityFilter.getLoginUsername(req)); From cc96e8de509732883b8f3a1bf3c3f12552277b65 Mon Sep 17 00:00:00 2001 From: casionxia Date: Sun, 26 Sep 2021 20:10:23 +0800 Subject: [PATCH 19/29] bugfix for MappingJackson2HttpMessageConverter set ObjectMapper WRITE_DATES_AS_TIMESTAMPS=true --- .../linkis/rpc/MessageRPCReceiveRestful.scala | 1 - .../linkis/DataWorkCloudApplication.java | 13 +++++++++++++ .../linkis/rpc/RPCReceiveRestful.scala | 10 +++++++--- .../rpc/conf/RPCReceiveRestfulCondition.scala | 16 ++++++++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/conf/RPCReceiveRestfulCondition.scala diff --git a/linkis-commons/linkis-message-scheduler/src/main/scala/com/webank/wedatasphere/linkis/rpc/MessageRPCReceiveRestful.scala b/linkis-commons/linkis-message-scheduler/src/main/scala/com/webank/wedatasphere/linkis/rpc/MessageRPCReceiveRestful.scala index 6e58122027..fe7f2d1b70 100644 --- a/linkis-commons/linkis-message-scheduler/src/main/scala/com/webank/wedatasphere/linkis/rpc/MessageRPCReceiveRestful.scala +++ b/linkis-commons/linkis-message-scheduler/src/main/scala/com/webank/wedatasphere/linkis/rpc/MessageRPCReceiveRestful.scala @@ -35,7 +35,6 @@ import scala.concurrent.duration.Duration import scala.runtime.BoxedUnit //@Component -//@RequestMapping(path = Array("/rpc")) @RestController @Primary @Import(Array(classOf[MessageRPCConsumer])) diff --git a/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/DataWorkCloudApplication.java b/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/DataWorkCloudApplication.java index 8ab3a6e57d..9e1cf2c461 100644 --- a/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/DataWorkCloudApplication.java +++ b/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/DataWorkCloudApplication.java @@ -16,6 +16,10 @@ package com.webank.wedatasphere.linkis; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import com.webank.wedatasphere.linkis.common.ServiceInstance; import com.webank.wedatasphere.linkis.common.conf.BDPConfiguration; import com.webank.wedatasphere.linkis.common.conf.Configuration; @@ -178,6 +182,15 @@ protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { return builder.sources(DataWorkCloudApplication.class); } + //todo confirm + @Bean + public ObjectMapper get() { + ObjectMapper objectMapper = new ObjectMapper() + .registerModule(new JavaTimeModule()) + .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true); + return objectMapper; + } + @Bean public WebServerFactoryCustomizer jettyFactoryCustomizer() { return new WebServerFactoryCustomizer() { diff --git a/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/RPCReceiveRestful.scala b/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/RPCReceiveRestful.scala index 58da794e95..c9afd0c6e9 100644 --- a/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/RPCReceiveRestful.scala +++ b/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/RPCReceiveRestful.scala @@ -21,21 +21,25 @@ import java.util.concurrent.TimeUnit import com.webank.wedatasphere.linkis.common.utils.Logging import com.webank.wedatasphere.linkis.protocol.BroadcastProtocol import com.webank.wedatasphere.linkis.rpc.conf.RPCConfiguration.{BDP_RPC_RECEIVER_ASYN_CONSUMER_THREAD_FREE_TIME_MAX, BDP_RPC_RECEIVER_ASYN_CONSUMER_THREAD_MAX, BDP_RPC_RECEIVER_ASYN_QUEUE_CAPACITY} +import com.webank.wedatasphere.linkis.rpc.conf.RPCReceiveRestfulCondition import com.webank.wedatasphere.linkis.rpc.exception.DWCURIException import com.webank.wedatasphere.linkis.rpc.transform.{RPCConsumer, RPCProduct} import com.webank.wedatasphere.linkis.server.{Message, catchIt} import javax.annotation.PostConstruct import org.apache.commons.lang.StringUtils import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty +import org.springframework.context.annotation.Conditional import org.springframework.stereotype.Component import org.springframework.web.bind.annotation.{RequestBody, RequestMapping, RequestMethod, RestController} import scala.concurrent.duration.Duration import scala.runtime.BoxedUnit -@Component -//@RequestMapping(path = Array("/rpc")) -//@RestController +//@Component +@RestController +//@ConditionalOnProperty(name = Array("wds.linkis.rpc.default.recevie.enable"), matchIfMissing = false) +@Conditional(Array(classOf[RPCReceiveRestfulCondition])) private[rpc] class RPCReceiveRestful extends RPCReceiveRemote with Logging { @Autowired(required = false) diff --git a/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/conf/RPCReceiveRestfulCondition.scala b/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/conf/RPCReceiveRestfulCondition.scala new file mode 100644 index 0000000000..72b1a3aab0 --- /dev/null +++ b/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/conf/RPCReceiveRestfulCondition.scala @@ -0,0 +1,16 @@ +package com.webank.wedatasphere.linkis.rpc.conf + +import com.webank.wedatasphere.linkis.common.conf.CommonVars +import org.springframework.context.annotation.{Condition, ConditionContext} +import org.springframework.core.`type`.AnnotatedTypeMetadata + +/** + * @author casionxia + * @Date 2021/9/26 + */ +class RPCReceiveRestfulCondition extends Condition{ + val condition = CommonVars("wds.linkis.rpc.default.recevie.enable",false).getValue + override def matches(conditionContext: ConditionContext, annotatedTypeMetadata: AnnotatedTypeMetadata): Boolean = { + condition + } +} \ No newline at end of file From e29d860f1b269cab9b88a7c66ee0f9f4bc7b4c24 Mon Sep 17 00:00:00 2001 From: casionxia Date: Mon, 27 Sep 2021 21:26:53 +0800 Subject: [PATCH 20/29] bugfix:add @RequestBody for params of map --- .../resourcemanager/restful/RMMonitorRest.scala | 16 ++++++++-------- .../validator/SpringPathValidator.scala | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/linkis-computation-governance/linkis-manager/linkis-resource-manager/src/main/scala/com/webank/wedatasphere/linkis/resourcemanager/restful/RMMonitorRest.scala b/linkis-computation-governance/linkis-manager/linkis-resource-manager/src/main/scala/com/webank/wedatasphere/linkis/resourcemanager/restful/RMMonitorRest.scala index 0fff9fe189..4d3fba2ded 100644 --- a/linkis-computation-governance/linkis-manager/linkis-resource-manager/src/main/scala/com/webank/wedatasphere/linkis/resourcemanager/restful/RMMonitorRest.scala +++ b/linkis-computation-governance/linkis-manager/linkis-resource-manager/src/main/scala/com/webank/wedatasphere/linkis/resourcemanager/restful/RMMonitorRest.scala @@ -44,13 +44,13 @@ import com.webank.wedatasphere.linkis.resourcemanager.external.service.ExternalR import com.webank.wedatasphere.linkis.resourcemanager.external.yarn.{YarnAppInfo, YarnResourceIdentifier} import com.webank.wedatasphere.linkis.resourcemanager.service.LabelResourceService import com.webank.wedatasphere.linkis.resourcemanager.utils.{RMConfiguration, RMUtils, UserConfiguration} -import com.webank.wedatasphere.linkis.server.{BDPJettyServerHelper, Message} +import com.webank.wedatasphere.linkis.server.Message import com.webank.wedatasphere.linkis.server.security.SecurityFilter import javax.servlet.http.HttpServletRequest import org.json4s.DefaultFormats import org.json4s.jackson.Serialization.write import org.springframework.beans.factory.annotation.Autowired -import org.springframework.web.bind.annotation.{RequestMapping, RequestMethod, RestController} +import org.springframework.web.bind.annotation.{RequestBody, RequestMapping, RequestMethod, RestController} import scala.collection.JavaConversions._ import scala.collection.mutable @@ -95,7 +95,7 @@ class RMMonitorRest extends Logging { def appendMessageData(message: Message, key: String, value: AnyRef) = message.data(key, mapper.readTree(write(value))) @RequestMapping(path =Array("applicationlist"),method = Array(RequestMethod.POST)) - def getApplicationList(request: HttpServletRequest, param: util.Map[String, AnyRef]): Message = { + def getApplicationList(request: HttpServletRequest,@RequestBody param: util.Map[String, AnyRef]): Message = { val message = Message.ok("") val userName = SecurityFilter.getLoginUsername(request) val userCreator = param.get("userCreator").asInstanceOf[String] @@ -147,7 +147,7 @@ class RMMonitorRest extends Logging { } @RequestMapping(path = Array("userresources"),method =Array( RequestMethod.POST)) - def getUserResource(request: HttpServletRequest, param: util.Map[String, AnyRef]): Message = { + def getUserResource(request: HttpServletRequest,@RequestBody(required=false) param: util.Map[String, AnyRef]): Message = { val message = Message.ok("") val userName = SecurityFilter.getLoginUsername(request) var nodes = getEngineNodes(userName, true) @@ -202,7 +202,7 @@ class RMMonitorRest extends Logging { } @RequestMapping(path = Array("engines"),method = Array(RequestMethod.POST)) - def getEngines(request: HttpServletRequest, param: util.Map[String, AnyRef]): Message = { + def getEngines(request: HttpServletRequest, @RequestBody(required=false) param: util.Map[String, AnyRef]): Message = { val message = Message.ok("") val userName = SecurityFilter.getLoginUsername(request) val nodes = getEngineNodes(userName, true) @@ -239,7 +239,7 @@ class RMMonitorRest extends Logging { * @return */ @RequestMapping(path = Array("enginekill"),method = Array(RequestMethod.POST)) - def killEngine(request: HttpServletRequest, param: util.ArrayList[util.Map[String, AnyRef]]): Message = { + def killEngine(request: HttpServletRequest, @RequestBody param: util.ArrayList[util.Map[String, AnyRef]]): Message = { val userName = SecurityFilter.getLoginUsername(request) for (engineParam <- param) { val moduleName = engineParam.get("applicationName").asInstanceOf[String] @@ -254,7 +254,7 @@ class RMMonitorRest extends Logging { @RequestMapping(path = Array("queueresources"),method = Array(RequestMethod.POST)) - def getQueueResource(request: HttpServletRequest, param: util.Map[String, AnyRef]): Message = { + def getQueueResource(request: HttpServletRequest, @RequestBody param: util.Map[String, AnyRef]): Message = { val message = Message.ok("") val yarnIdentifier = new YarnResourceIdentifier(param.get("queuename").asInstanceOf[String]) val clusterLabel = labelFactory.createLabel(classOf[ClusterLabel]) @@ -369,7 +369,7 @@ class RMMonitorRest extends Logging { } @RequestMapping(path = Array("queues"),method =Array(RequestMethod.POST)) - def getQueues(request: HttpServletRequest, param: util.Map[String, AnyRef]): Message = { + def getQueues(request: HttpServletRequest,@RequestBody(required=false) param: util.Map[String, AnyRef]): Message = { val message = Message.ok() val userName = SecurityFilter.getLoginUsername(request) val clusters = new mutable.ArrayBuffer[Any]() diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/SpringPathValidator.scala b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/SpringPathValidator.scala index 4b9c665a86..3f82fb9b07 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/SpringPathValidator.scala +++ b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/SpringPathValidator.scala @@ -113,7 +113,7 @@ class SpringPathValidator extends Logging { } Message.ok() } - if ( messageToHttpStatus(resp)==200 != 200) resp else proceedingJoinPoint.proceed() + if ( messageToHttpStatus(resp)!= 200) resp else proceedingJoinPoint.proceed() } def getCurrentHttpResponse: HttpServletResponse = { From b92b24a1e00880895a2e11db693c6bf43f5a6a16 Mon Sep 17 00:00:00 2001 From: casionxia Date: Mon, 27 Sep 2021 21:31:14 +0800 Subject: [PATCH 21/29] add some spring properties --- .../assembly-combined/conf/linkis.properties | 4 ++++ .../common/conf/DWCArgumentsParser.scala | 4 +++- .../linkis/server/BDPJettyServerHelper.scala | 10 ++++----- .../LinkisClientApplicationTest.java | 22 +++++++++---------- .../hook/CallbackEngineConnHook.scala | 5 ++++- .../resources/linkis-engineconn.properties | 3 +++ .../resources/linkis-engineconn.properties | 6 ++++- .../resources/linkis-engineconn.properties | 6 ++++- .../resources/linkis-engineconn.properties | 4 ++++ .../resources/linkis-engineconn.properties | 4 ++++ .../resources/linkis-engineconn.properties | 7 +++++- .../resources/linkis-engineconn.properties | 4 ++++ .../resources/linkis-engineconn.properties | 3 +++ 13 files changed, 61 insertions(+), 21 deletions(-) diff --git a/assembly-combined-package/assembly-combined/conf/linkis.properties b/assembly-combined-package/assembly-combined/conf/linkis.properties index a906aa32a8..88b278199e 100644 --- a/assembly-combined-package/assembly-combined/conf/linkis.properties +++ b/assembly-combined-package/assembly-combined/conf/linkis.properties @@ -52,3 +52,7 @@ wds.linkis.home=/appcom/Install/LinkisInstall #Linkis governance station administrators wds.linkis.governance.station.admin=hadoop wds.linkis.gateway.conf.publicservice.list=query,jobhistory,application,configuration,filesystem,udf,variable,microservice,errorcode,bml,datasource + +spring.spring.mvc.servlet.path=/api/rest_j/v1 +spring.spring.servlet.multipart.max-file-size=200MB +spring.spring.servlet.multipart.max-request-size=200MB \ No newline at end of file diff --git a/linkis-commons/linkis-common/src/main/scala/com/webank/wedatasphere/linkis/common/conf/DWCArgumentsParser.scala b/linkis-commons/linkis-common/src/main/scala/com/webank/wedatasphere/linkis/common/conf/DWCArgumentsParser.scala index c6e4f61a01..cb829a4306 100644 --- a/linkis-commons/linkis-common/src/main/scala/com/webank/wedatasphere/linkis/common/conf/DWCArgumentsParser.scala +++ b/linkis-commons/linkis-common/src/main/scala/com/webank/wedatasphere/linkis/common/conf/DWCArgumentsParser.scala @@ -25,6 +25,7 @@ import scala.collection.{JavaConversions, mutable} object DWCArgumentsParser { protected val DWC_CONF = "--engineconn-conf" protected val SPRING_CONF = "--spring-conf" + private val SPRING_STAR = "spring." private var dwcOptionMap = Map.empty[String, String] private[linkis] def setDWCOptionMap(dwcOptionMap: Map[String, String]) = this.dwcOptionMap = dwcOptionMap @@ -74,7 +75,8 @@ object DWCArgumentsParser { val options = ArrayBuffer[String]() springOptionMap.foreach { case (key, value) => if (StringUtils.isNotEmpty(key) && StringUtils.isNotEmpty(value)) { - options += ("--" + key + "=" + value) + val realKey = key.substring(SPRING_STAR.length) + options += ("--" + realKey + "=" + value) } } options.toArray diff --git a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/BDPJettyServerHelper.scala b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/BDPJettyServerHelper.scala index 10c8c90868..f9e8dff192 100644 --- a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/BDPJettyServerHelper.scala +++ b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/BDPJettyServerHelper.scala @@ -24,9 +24,9 @@ import java.util.EnumSet import com.fasterxml.jackson.databind.ObjectMapper import com.google.gson._ +import com.webank.wedatasphere.linkis.DataWorkCloudApplication import com.webank.wedatasphere.linkis.common.utils.Logging import com.webank.wedatasphere.linkis.server.conf.ServerConfiguration._ -import com.webank.wedatasphere.linkis.server.restful.RestfulApplication import com.webank.wedatasphere.linkis.server.socket.ControllerServer import com.webank.wedatasphere.linkis.server.socket.controller.{ServerEventService, ServerListenerEventBus} import javax.servlet.{DispatcherType, Filter, MultipartConfigElement} @@ -34,7 +34,6 @@ import org.apache.commons.io.FileUtils import org.eclipse.jetty.server.session.SessionHandler import org.eclipse.jetty.servlet.{DefaultServlet, FilterHolder, ServletContextHandler, ServletHolder} import org.eclipse.jetty.webapp.WebAppContext -import org.glassfish.jersey.servlet.ServletContainer import org.springframework.web.context.support.AnnotationConfigWebApplicationContext import org.springframework.web.servlet.DispatcherServlet @@ -47,8 +46,8 @@ private[linkis] object BDPJettyServerHelper extends Logging { private var controllerServer: ControllerServer = _ private val services = mutable.Buffer[ServerEventService]() - private val TMP_FOLDER = "/tmp" - private val MAX_UPLOAD_SIZE = 20 * 1024 * 1024 + private val TMP_FOLDER = "" + private val MAX_UPLOAD_SIZE = 200 * 1024 * 1024 private[server] def getControllerServer = controllerServer @@ -94,7 +93,8 @@ private[linkis] object BDPJettyServerHelper extends Logging { servletHolder.setForcedPath("springrestful") //todo file size parameter configuration - val multipartConfigElement = new MultipartConfigElement(TMP_FOLDER, MAX_UPLOAD_SIZE, MAX_UPLOAD_SIZE * 2, MAX_UPLOAD_SIZE / 2) + //val multipartConfigElement = new MultipartConfigElement(null, MAX_UPLOAD_SIZE, MAX_UPLOAD_SIZE * 2, MAX_UPLOAD_SIZE / 2) + val multipartConfigElement=DataWorkCloudApplication.getApplicationContext.getBean(classOf[MultipartConfigElement]); servletHolder.getRegistration.setMultipartConfig(multipartConfigElement) val p = BDP_SERVER_RESTFUL_URI.getValue diff --git a/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/java/com/webank/wedatasphere/linkis/cli/application/LinkisClientApplicationTest.java b/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/java/com/webank/wedatasphere/linkis/cli/application/LinkisClientApplicationTest.java index 2f3f3b2f24..95c2043986 100644 --- a/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/java/com/webank/wedatasphere/linkis/cli/application/LinkisClientApplicationTest.java +++ b/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/java/com/webank/wedatasphere/linkis/cli/application/LinkisClientApplicationTest.java @@ -29,7 +29,7 @@ public class LinkisClientApplicationTest { @Before public void before() throws Exception { System.setProperty("conf.root", "src/test/resources/conf/"); -// System.setProperty("user.name", "notshangda"); + System.setProperty("user.name", "hadoop"); cmdStr2 = new String[]{ // "--gatewayUrl", "http://127.0.0.1:8090", // "--authStg", "token", @@ -46,7 +46,7 @@ public void before() throws Exception { }; cmdStr = new String[]{ - "--gatewayUrl", "http://127.0.0.1:9001", + "--gatewayUrl", "http://172.21.8.149:9001", "--authStg", "token", "--authKey", "Validation-Code", "--authVal", "BML-AUTH", @@ -64,9 +64,9 @@ public void before() throws Exception { "-submitUser", "hadoop", "-proxyUser", "hadoop", // "-sourceMap", "scriptPath=1234", - "-outPath", "./data/bdp-job/test/", +// "-outPath", "./data/bdp-job/test/", // "-labelMap", "codeType=sql", - "-confMap", "wds.linkis.yarnqueue=q02", +// "-confMap", "wds.linkis.yarnqueue=q02", // "-confMap", "wds.linkis.yarnqueue=q02", // "-confMap", "spark.num.executor=3", // "-varMap", "wds.linkis.yarnqueue=q02", @@ -76,14 +76,14 @@ public void before() throws Exception { * Test different task type */ - "-engineType", "spark-2.4.3", - "-codeType", "sql", - "-code", "show tables;show tables;show tables", +// "-engineType", "spark-2.4.3", +// "-codeType", "sql", +// "-code", "show tables;show tables;show tables", // -// "-engineType", "hive-1.2.1", -// "-codeType", "sql", -// "-code", "show tables;show tables;show tables;show tables;show tables;show tables;", + "-engineType", "hive-1.2.1", + "-codeType", "sql", + "-code", "show tables;show tables;show tables;show tables;show tables;show tables;", // "-engineType", "spark-2.4.3", // "-codeType", "py", @@ -162,7 +162,7 @@ public void testProcessInput() throws Exception { */ @Test public void testExec() throws Exception { -// LinkisClientApplication.main(cmdStr); + LinkisClientApplication.main(cmdStr); // LinkisClientApplication.main(cmdStr2); /* try { diff --git a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/callback-service/src/main/scala/com/webank/wedatasphere/linkis/engineconn/callback/hook/CallbackEngineConnHook.scala b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/callback-service/src/main/scala/com/webank/wedatasphere/linkis/engineconn/callback/hook/CallbackEngineConnHook.scala index 2716029770..03e246274f 100644 --- a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/callback-service/src/main/scala/com/webank/wedatasphere/linkis/engineconn/callback/hook/CallbackEngineConnHook.scala +++ b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/callback-service/src/main/scala/com/webank/wedatasphere/linkis/engineconn/callback/hook/CallbackEngineConnHook.scala @@ -46,8 +46,11 @@ class CallbackEngineConnHook extends EngineConnHook with Logging { if (!StringUtils.isEmpty(existsExcludePackages)) DataWorkCloudApplication.setProperty(ServerConfiguration.BDP_SERVER_EXCLUDE_PACKAGES.key, existsExcludePackages) // 加载spring类 +// val map = new mutable.HashMap[String, String]() +// val newMap = map.++(parser.getSpringConfMap) +// newMap.put("spring.mvc.servlet.path", "/api/rest_j/v1") +// DataWorkCloudApplication.main(DWCArgumentsParser.formatSpringOptions(newMap.toMap)) DataWorkCloudApplication.main(DWCArgumentsParser.formatSpringOptions(parser.getSpringConfMap)) - val engineConnPidCallBack = new EngineConnPidCallback(engineCreationContext.getEMInstance) Utils.tryAndError(engineConnPidCallBack.callback()) info("<--------------------SpringBoot App init succeed-------------------->") diff --git a/linkis-engineconn-plugins/engineconn-plugins/flink/src/main/resources/linkis-engineconn.properties b/linkis-engineconn-plugins/engineconn-plugins/flink/src/main/resources/linkis-engineconn.properties index a5c5b9631d..abdb9f01d9 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/flink/src/main/resources/linkis-engineconn.properties +++ b/linkis-engineconn-plugins/engineconn-plugins/flink/src/main/resources/linkis-engineconn.properties @@ -29,3 +29,6 @@ wds.linkis.engine.connector.hooks=com.webank.wedatasphere.linkis.engineconn.comp wds.linkis.engineconn.executor.manager.class=com.webank.wedatasphere.linkis.engineconnplugin.flink.executormanager.FlinkExecutorManager +spring.spring.mvc.servlet.path=/api/rest_j/v1 +spring.spring.servlet.multipart.max-file-size=200MB +spring.spring.servlet.multipart.max-request-size=200MB \ No newline at end of file diff --git a/linkis-engineconn-plugins/engineconn-plugins/hive/src/main/resources/linkis-engineconn.properties b/linkis-engineconn-plugins/engineconn-plugins/hive/src/main/resources/linkis-engineconn.properties index 7b06ef9c36..b598ffe412 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/hive/src/main/resources/linkis-engineconn.properties +++ b/linkis-engineconn-plugins/engineconn-plugins/hive/src/main/resources/linkis-engineconn.properties @@ -26,4 +26,8 @@ wds.linkis.engineconn.plugin.default.class=com.webank.wedatasphere.linkis.engine wds.linkis.bdp.hive.init.sql.enable=true -wds.linkis.engine.connector.hooks=com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ComputationEngineConnHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.JarUdfEngineHook \ No newline at end of file +wds.linkis.engine.connector.hooks=com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ComputationEngineConnHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.JarUdfEngineHook + +spring.spring.mvc.servlet.path=/api/rest_j/v1 +spring.spring.servlet.multipart.max-file-size=200MB +spring.spring.servlet.multipart.max-request-size=200MB \ No newline at end of file diff --git a/linkis-engineconn-plugins/engineconn-plugins/io_file/src/main/resources/linkis-engineconn.properties b/linkis-engineconn-plugins/engineconn-plugins/io_file/src/main/resources/linkis-engineconn.properties index 015a5c3382..0282aa6a35 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/io_file/src/main/resources/linkis-engineconn.properties +++ b/linkis-engineconn-plugins/engineconn-plugins/io_file/src/main/resources/linkis-engineconn.properties @@ -30,4 +30,8 @@ wds.linkis.engineconn.io.version=1 wds.linkis.engineconn.support.parallelism=true wds.linkis.engineconn.max.free.time=0 -wds.linkis.engine.push.log.enable=false \ No newline at end of file +wds.linkis.engine.push.log.enable=false + +spring.spring.mvc.servlet.path=/api/rest_j/v1 +spring.spring.servlet.multipart.max-file-size=200MB +spring.spring.servlet.multipart.max-request-size=200MB \ No newline at end of file diff --git a/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/resources/linkis-engineconn.properties b/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/resources/linkis-engineconn.properties index 376d6ecd18..7c4fb88884 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/resources/linkis-engineconn.properties +++ b/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/resources/linkis-engineconn.properties @@ -27,3 +27,7 @@ wds.linkis.engineconn.plugin.default.class=com.webank.wedatasphere.linkis.manage wds.linkis.engineconn.support.parallelism=true +spring.spring.mvc.servlet.path=/api/rest_j/v1 +spring.spring.servlet.multipart.max-file-size=200MB +spring.spring.servlet.multipart.max-request-size=200MB + diff --git a/linkis-engineconn-plugins/engineconn-plugins/pipeline/src/main/resources/linkis-engineconn.properties b/linkis-engineconn-plugins/engineconn-plugins/pipeline/src/main/resources/linkis-engineconn.properties index 380724d838..9a0f9a1882 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/pipeline/src/main/resources/linkis-engineconn.properties +++ b/linkis-engineconn-plugins/engineconn-plugins/pipeline/src/main/resources/linkis-engineconn.properties @@ -27,3 +27,7 @@ wds.linkis.engineconn.plugin.default.class=com.webank.wedatasphere.linkis.manage wds.linkis.engineconn.max.free.time=5m + +spring.spring.mvc.servlet.path=/api/rest_j/v1 +spring.spring.servlet.multipart.max-file-size=200MB +spring.spring.servlet.multipart.max-request-size=200MB diff --git a/linkis-engineconn-plugins/engineconn-plugins/python/src/main/resources/linkis-engineconn.properties b/linkis-engineconn-plugins/engineconn-plugins/python/src/main/resources/linkis-engineconn.properties index 17f72996b0..ec94af17fe 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/python/src/main/resources/linkis-engineconn.properties +++ b/linkis-engineconn-plugins/engineconn-plugins/python/src/main/resources/linkis-engineconn.properties @@ -25,4 +25,9 @@ wds.linkis.engineconn.debug.enable=true wds.linkis.engineconn.plugin.default.class=com.webank.wedatasphere.linkis.manager.engineplugin.python.PythonEngineConnPlugin -wds.linkis.engine.connector.hooks=com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ComputationEngineConnHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.PyFunctionEngineHook \ No newline at end of file +wds.linkis.engine.connector.hooks=com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ComputationEngineConnHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.PyFunctionEngineHook + + +spring.spring.mvc.servlet.path=/api/rest_j/v1 +spring.spring.servlet.multipart.max-file-size=200MB +spring.spring.servlet.multipart.max-request-size=200MB \ No newline at end of file diff --git a/linkis-engineconn-plugins/engineconn-plugins/shell/src/main/resources/linkis-engineconn.properties b/linkis-engineconn-plugins/engineconn-plugins/shell/src/main/resources/linkis-engineconn.properties index 4b8cdf1b0f..158701637d 100755 --- a/linkis-engineconn-plugins/engineconn-plugins/shell/src/main/resources/linkis-engineconn.properties +++ b/linkis-engineconn-plugins/engineconn-plugins/shell/src/main/resources/linkis-engineconn.properties @@ -17,3 +17,7 @@ wds.linkis.server.version=v1 wds.linkis.engineconn.plugin.default.class=com.webank.wedatasphere.linkis.manager.engineplugin.shell.ShellEngineConnPlugin + +spring.spring.mvc.servlet.path=/api/rest_j/v1 +spring.spring.servlet.multipart.max-file-size=200MB +spring.spring.servlet.multipart.max-request-size=200MB diff --git a/linkis-engineconn-plugins/engineconn-plugins/spark/src/main/resources/linkis-engineconn.properties b/linkis-engineconn-plugins/engineconn-plugins/spark/src/main/resources/linkis-engineconn.properties index 629bc8b3b8..82d3d9daf1 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/spark/src/main/resources/linkis-engineconn.properties +++ b/linkis-engineconn-plugins/engineconn-plugins/spark/src/main/resources/linkis-engineconn.properties @@ -28,3 +28,6 @@ wds.linkis.engineconn.plugin.default.class=com.webank.wedatasphere.linkis.engine wds.linkis.engine.connector.hooks=com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ComputationEngineConnHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.PyUdfEngineHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ScalaUdfEngineHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.JarUdfEngineHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.PyFunctionEngineHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ScalaFunctionEngineHook +spring.spring.mvc.servlet.path=/api/rest_j/v1 +spring.spring.servlet.multipart.max-file-size=200MB +spring.spring.servlet.multipart.max-request-size=200MB \ No newline at end of file From c7522ea21406701c57fdab9f38e3cca60f74d2e7 Mon Sep 17 00:00:00 2001 From: casionxia Date: Tue, 28 Sep 2021 17:17:03 +0800 Subject: [PATCH 22/29] bugfix:http params of Long --- .../linkis/common/conf/DWCArgumentsParser.scala | 8 ++++++-- .../callback/hook/CallbackEngineConnHook.scala | 12 +++++++----- .../linkis/entrance/restful/EntranceRestfulApi.java | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/linkis-commons/linkis-common/src/main/scala/com/webank/wedatasphere/linkis/common/conf/DWCArgumentsParser.scala b/linkis-commons/linkis-common/src/main/scala/com/webank/wedatasphere/linkis/common/conf/DWCArgumentsParser.scala index cb829a4306..08adfbbc04 100644 --- a/linkis-commons/linkis-common/src/main/scala/com/webank/wedatasphere/linkis/common/conf/DWCArgumentsParser.scala +++ b/linkis-commons/linkis-common/src/main/scala/com/webank/wedatasphere/linkis/common/conf/DWCArgumentsParser.scala @@ -75,8 +75,12 @@ object DWCArgumentsParser { val options = ArrayBuffer[String]() springOptionMap.foreach { case (key, value) => if (StringUtils.isNotEmpty(key) && StringUtils.isNotEmpty(value)) { - val realKey = key.substring(SPRING_STAR.length) - options += ("--" + realKey + "=" + value) + var realKey=key +// if(key.startsWith(SPRING_STAR+SPRING_STAR)){ +// realKey = key.substring(SPRING_STAR.length) +// } +// options += ("--" + realKey + "=" + value) + options += ("--" + key + "=" + value) } } options.toArray diff --git a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/callback-service/src/main/scala/com/webank/wedatasphere/linkis/engineconn/callback/hook/CallbackEngineConnHook.scala b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/callback-service/src/main/scala/com/webank/wedatasphere/linkis/engineconn/callback/hook/CallbackEngineConnHook.scala index 03e246274f..7c6a57f04a 100644 --- a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/callback-service/src/main/scala/com/webank/wedatasphere/linkis/engineconn/callback/hook/CallbackEngineConnHook.scala +++ b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/callback-service/src/main/scala/com/webank/wedatasphere/linkis/engineconn/callback/hook/CallbackEngineConnHook.scala @@ -34,6 +34,8 @@ import com.webank.wedatasphere.linkis.server.conf.ServerConfiguration import org.apache.commons.lang.StringUtils import org.apache.commons.lang.exception.ExceptionUtils +import scala.collection.mutable + class CallbackEngineConnHook extends EngineConnHook with Logging { @@ -46,11 +48,11 @@ class CallbackEngineConnHook extends EngineConnHook with Logging { if (!StringUtils.isEmpty(existsExcludePackages)) DataWorkCloudApplication.setProperty(ServerConfiguration.BDP_SERVER_EXCLUDE_PACKAGES.key, existsExcludePackages) // 加载spring类 -// val map = new mutable.HashMap[String, String]() -// val newMap = map.++(parser.getSpringConfMap) -// newMap.put("spring.mvc.servlet.path", "/api/rest_j/v1") -// DataWorkCloudApplication.main(DWCArgumentsParser.formatSpringOptions(newMap.toMap)) - DataWorkCloudApplication.main(DWCArgumentsParser.formatSpringOptions(parser.getSpringConfMap)) + val map = new mutable.HashMap[String, String]() + val newMap = map.++(parser.getSpringConfMap) + newMap.put("spring.mvc.servlet.path", "/api/rest_j/v1") + DataWorkCloudApplication.main(DWCArgumentsParser.formatSpringOptions(newMap.toMap)) + val engineConnPidCallBack = new EngineConnPidCallback(engineCreationContext.getEMInstance) Utils.tryAndError(engineConnPidCallBack.callback()) info("<--------------------SpringBoot App init succeed-------------------->") diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java b/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java index 3896244cc5..124417a854 100644 --- a/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java +++ b/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java @@ -368,7 +368,7 @@ public Message killJobs(HttpServletRequest req,@RequestBody JsonNode jsonNode, @ @RequestMapping(path = "/{id}/kill",method = RequestMethod.GET) - public Message kill(@PathVariable("id") String id, @RequestParam(value = "taskID",required = false) long taskID) { + public Message kill(@PathVariable("id") String id, @RequestParam(value = "taskID",required = false) Long taskID) { String realId = ZuulEntranceUtils.parseExecID(id)[3]; //通过jobid获取job,可能会由于job找不到而导致有looparray的报错,一旦报错的话,就可以将该任务直接置为Cancenlled Option job = Option.apply(null); From 77e3fe1dcf616f100c68ea542adc2ecfb8fd52c6 Mon Sep 17 00:00:00 2001 From: shangda Date: Tue, 28 Sep 2021 20:30:37 +0800 Subject: [PATCH 23/29] 1. [entrance] Fixed a problem for kill 2. Added NOTICE and DISCLAIMER --- DISCLAIMER-WIP | 19 ++++++++++++++++ NOTICE | 5 +++++ .../LinkisClientApplicationTest.java | 22 ++++++++++++------- .../test/resources/conf/linkis-cli.properties | 12 +++++----- .../src/test/resources/linkis-cli.properties | 12 +++++----- .../entrance/restful/EntranceRestfulApi.java | 2 +- 6 files changed, 51 insertions(+), 21 deletions(-) create mode 100644 DISCLAIMER-WIP create mode 100644 NOTICE diff --git a/DISCLAIMER-WIP b/DISCLAIMER-WIP new file mode 100644 index 0000000000..4fb31110d8 --- /dev/null +++ b/DISCLAIMER-WIP @@ -0,0 +1,19 @@ +Apache Linkis is an effort undergoing incubation at The Apache Software Foundation (ASF), +sponsored by the Apache Incubator PMC. + +Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, +communications, and decision-making process have stabilized in a manner consistent with other successful ASF projects. + +While incubation status is not necessarily a reflection of the completeness or stability of the code, +it does indicate that the project has yet to be fully endorsed by the ASF. + +Some of the incubating project’s releases may not be fully compliant with ASF policy. +For example, releases may have incomplete or un-reviewed licensing conditions. +What follows is a list of issues the project is currently aware of (this list is likely to be incomplete): + +1- Releases may have incomplete licensing conditions + + +If you are planning to incorporate this work into your product/project, +please be aware that you will need to conduct a thorough licensing review to determine the overall implications of including this work. +For the current status of this project through the Apache Incubator, visit: https://incubator.apache.org/projects/linkis.html \ No newline at end of file diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000000..d3bedd032b --- /dev/null +++ b/NOTICE @@ -0,0 +1,5 @@ +Apache Linkis (incubating) +Copyright 2021 The Apache Software Foundation + +This product includes software developed at +The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/java/com/webank/wedatasphere/linkis/cli/application/LinkisClientApplicationTest.java b/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/java/com/webank/wedatasphere/linkis/cli/application/LinkisClientApplicationTest.java index 2f3f3b2f24..c79db83d14 100644 --- a/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/java/com/webank/wedatasphere/linkis/cli/application/LinkisClientApplicationTest.java +++ b/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/java/com/webank/wedatasphere/linkis/cli/application/LinkisClientApplicationTest.java @@ -46,13 +46,13 @@ public void before() throws Exception { }; cmdStr = new String[]{ - "--gatewayUrl", "http://127.0.0.1:9001", + "--gatewayUrl", "http://172.21.8.149:9001", "--authStg", "token", "--authKey", "Validation-Code", "--authVal", "BML-AUTH", // "--help", // "--kill", "8249", -// "--status", "123" +// "--status", "379", // "--userConf", "src/test/resources/linkis-cli.properties", @@ -64,9 +64,9 @@ public void before() throws Exception { "-submitUser", "hadoop", "-proxyUser", "hadoop", // "-sourceMap", "scriptPath=1234", - "-outPath", "./data/bdp-job/test/", +// "-outPath", "./data/bdp-job/test/", // "-labelMap", "codeType=sql", - "-confMap", "wds.linkis.yarnqueue=q02", +// "-confMap", "wds.linkis.yarnqueue=q02", // "-confMap", "wds.linkis.yarnqueue=q02", // "-confMap", "spark.num.executor=3", // "-varMap", "wds.linkis.yarnqueue=q02", @@ -76,14 +76,19 @@ public void before() throws Exception { * Test different task type */ - "-engineType", "spark-2.4.3", - "-codeType", "sql", - "-code", "show tables;show tables;show tables", +// "-engineType", "spark-2.4.3", +// "-codeType", "sql", +// "-code", "show tables;show tables;show tables", // // "-engineType", "hive-1.2.1", // "-codeType", "sql", -// "-code", "show tables;show tables;show tables;show tables;show tables;show tables;", +// "-code", "show tables;", + + "-engineType", "shell-1", + "-codeType", "shell", + "-code", "whoami", + // "-engineType", "spark-2.4.3", // "-codeType", "py", @@ -104,6 +109,7 @@ public void before() throws Exception { // "-engineType", "python-python2", // "-codeType", "python", //// "-code", "print(\'hello\')\nprint(\'hello\')\nprint(\'hello\') ", + }; } diff --git a/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/resources/conf/linkis-cli.properties b/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/resources/conf/linkis-cli.properties index 1f48da2afe..f97542204e 100644 --- a/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/resources/conf/linkis-cli.properties +++ b/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/resources/conf/linkis-cli.properties @@ -20,12 +20,12 @@ wds.linkis.client.noncustomizable.enable.user.specification=true #wds.linkis.client.common.submitUser #wds.linkis.client.common.submitPassword #wds.linkis.client.common.proxyUser -wds.linkis.client.param.conf.wds.linkis.yarnqueue=q02 -wds.linkis.client.param.conf.yarnqueue.cores.max=233 -wds.linkis.client.param.conf.yarnqueue.memory.max=233G -wds.linkis.client.param.conf.spark.executor.instances=9 -wds.linkis.client.param.conf.spark.executor.cores=9 -wds.linkis.client.param.conf.spark.executor.memory=9 +#wds.linkis.client.param.conf.wds.linkis.yarnqueue=q02 +#wds.linkis.client.param.conf.yarnqueue.cores.max=233 +#wds.linkis.client.param.conf.yarnqueue.memory.max=233G +#wds.linkis.client.param.conf.spark.executor.instances=9 +#wds.linkis.client.param.conf.spark.executor.cores=9 +#wds.linkis.client.param.conf.spark.executor.memory=9 #wds.linkis.client.label="key1=val1,key2=val2" #wds.linkis.client.param.conf="key1=val1,key2=val2" #wds.linkis.client.param.var="key1=val1,key2=val2" diff --git a/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/resources/linkis-cli.properties b/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/resources/linkis-cli.properties index a2920435b6..b03fdee38f 100644 --- a/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/resources/linkis-cli.properties +++ b/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/resources/linkis-cli.properties @@ -19,12 +19,12 @@ wds.linkis.client.common.tokenValue=BML-AUTH #wds.linkis.client.common.submitUser #wds.linkis.client.common.submitPassword #wds.linkis.client.common.proxyUser -wds.linkis.client.param.conf.wds.linkis.yarnqueue=233 -wds.linkis.client.param.conf.yarnqueue.cores.max=233 -wds.linkis.client.param.conf.yarnqueue.memory.max=233G -wds.linkis.client.param.conf.spark.executor.instances=233 -wds.linkis.client.param.conf.spark.executor.cores=233 -wds.linkis.client.param.conf.spark.executor.memory=233 +#wds.linkis.client.param.conf.wds.linkis.yarnqueue=233 +#wds.linkis.client.param.conf.yarnqueue.cores.max=233 +#wds.linkis.client.param.conf.yarnqueue.memory.max=233G +#wds.linkis.client.param.conf.spark.executor.instances=233 +#wds.linkis.client.param.conf.spark.executor.cores=233 +#wds.linkis.client.param.conf.spark.executor.memory=233 #wds.linkis.client.label="key1=val1,key2=val2" #wds.linkis.client.param.conf="key1=val1,key2=val2" #wds.linkis.client.param.var="key1=val1,key2=val2" diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java b/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java index 3896244cc5..124417a854 100644 --- a/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java +++ b/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java @@ -368,7 +368,7 @@ public Message killJobs(HttpServletRequest req,@RequestBody JsonNode jsonNode, @ @RequestMapping(path = "/{id}/kill",method = RequestMethod.GET) - public Message kill(@PathVariable("id") String id, @RequestParam(value = "taskID",required = false) long taskID) { + public Message kill(@PathVariable("id") String id, @RequestParam(value = "taskID",required = false) Long taskID) { String realId = ZuulEntranceUtils.parseExecID(id)[3]; //通过jobid获取job,可能会由于job找不到而导致有looparray的报错,一旦报错的话,就可以将该任务直接置为Cancenlled Option job = Option.apply(null); From db05eca8ac9bc66526a5c0eb2013b30bfad27549 Mon Sep 17 00:00:00 2001 From: casionxia Date: Wed, 29 Sep 2021 21:41:16 +0800 Subject: [PATCH 24/29] 1.remove unused about jersey code 2.bugfix for some http api --- .../linkis/DataWorkCloudApplication.java | 3 +- .../server/restful/RestfulApplication.java | 100 +++---- .../wedatasphere/linkis/server/Message.scala | 23 +- .../server/restful/RestfulCatchAOP.scala | 100 +++---- .../restful/SpringRestfulCatchAOP.scala | 14 +- .../entrance/restful/EntranceRestfulApi.java | 1 + .../server/restful/ContextIDRestfulApi.java | 2 +- .../cs/server/ContextHistoryRestfulApi.java | 10 +- .../linkis/cs/server/ContextIDRestfulApi.java | 6 +- .../cs/server/ContextListenerRestfulApi.java | 4 +- .../linkis/cs/server/ContextRestfulApi.java | 12 +- .../filesystem/restful/api/FsRestfulApi.java | 26 +- .../filesystem/validator/PathValidator.scala | 252 +++++++++--------- .../validator/SpringPathValidator.scala | 11 +- .../wedatasphere/linkis/udf/api/UDFApi.java | 13 +- 15 files changed, 270 insertions(+), 307 deletions(-) diff --git a/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/DataWorkCloudApplication.java b/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/DataWorkCloudApplication.java index 9e1cf2c461..b21085436c 100644 --- a/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/DataWorkCloudApplication.java +++ b/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/DataWorkCloudApplication.java @@ -60,7 +60,6 @@ import org.springframework.web.filter.CharacterEncodingFilter; import javax.servlet.DispatcherType; -import javax.ws.rs.ext.RuntimeDelegate; import java.util.EnumSet; @@ -81,7 +80,7 @@ public static ApplicationContext getApplicationContext() { public static void main(String[] args) throws ReflectiveOperationException { - RuntimeDelegate.setInstance(new org.glassfish.jersey.internal.RuntimeDelegateImpl()); + //RuntimeDelegate.setInstance(new org.glassfish.jersey.internal.RuntimeDelegateImpl()); final SpringApplication application = new SpringApplication(DataWorkCloudApplication.class); application.addListeners(new ApplicationListener(){ public void onApplicationEvent(ApplicationPreparedEvent applicationPreparedEvent) { diff --git a/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/server/restful/RestfulApplication.java b/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/server/restful/RestfulApplication.java index b7b6f343a0..512c329665 100644 --- a/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/server/restful/RestfulApplication.java +++ b/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/server/restful/RestfulApplication.java @@ -1,50 +1,50 @@ -/* - * Copyright 2019 WeBank - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.webank.wedatasphere.linkis.server.restful; - -import com.webank.wedatasphere.linkis.server.conf.ServerConfiguration; -import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.codehaus.jackson.jaxrs.JacksonJsonProvider; -import org.glassfish.jersey.jackson.JacksonFeature; -import org.glassfish.jersey.media.multipart.MultiPartFeature; -import org.glassfish.jersey.server.ResourceConfig; - - -public class RestfulApplication extends ResourceConfig { - - private static final Log logger = LogFactory.getLog(RestfulApplication.class); - - public RestfulApplication() throws ClassNotFoundException { - register(JacksonFeature.class); - register(JacksonJsonProvider.class); - register(MultiPartFeature.class); - String registerClasses = ServerConfiguration.BDP_SERVER_RESTFUL_REGISTER_CLASSES().acquireNew(); - if(StringUtils.isNotBlank(registerClasses)) { - for(String clazz : registerClasses.split(",")) { - logger.info("register " + clazz); - register(Class.forName(clazz, true, Thread.currentThread().getContextClassLoader())); - } - } - String packages = ServerConfiguration.BDP_SERVER_RESTFUL_SCAN_PACKAGES().acquireNew(); - if(StringUtils.isNotBlank(packages)) { - logger.info("packages " + packages); - packages(packages.split(",")); - } - } -} +///* +// * Copyright 2019 WeBank +// * +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ +// +//package com.webank.wedatasphere.linkis.server.restful; +// +//import com.webank.wedatasphere.linkis.server.conf.ServerConfiguration; +//import org.apache.commons.lang.StringUtils; +//import org.apache.commons.logging.Log; +//import org.apache.commons.logging.LogFactory; +//import org.codehaus.jackson.jaxrs.JacksonJsonProvider; +//import org.glassfish.jersey.jackson.JacksonFeature; +//import org.glassfish.jersey.media.multipart.MultiPartFeature; +//import org.glassfish.jersey.server.ResourceConfig; +// +// +//public class RestfulApplication extends ResourceConfig { +// +// private static final Log logger = LogFactory.getLog(RestfulApplication.class); +// +// public RestfulApplication() throws ClassNotFoundException { +// register(JacksonFeature.class); +// register(JacksonJsonProvider.class); +// register(MultiPartFeature.class); +// String registerClasses = ServerConfiguration.BDP_SERVER_RESTFUL_REGISTER_CLASSES().acquireNew(); +// if(StringUtils.isNotBlank(registerClasses)) { +// for(String clazz : registerClasses.split(",")) { +// logger.info("register " + clazz); +// register(Class.forName(clazz, true, Thread.currentThread().getContextClassLoader())); +// } +// } +// String packages = ServerConfiguration.BDP_SERVER_RESTFUL_SCAN_PACKAGES().acquireNew(); +// if(StringUtils.isNotBlank(packages)) { +// logger.info("packages " + packages); +// packages(packages.split(",")); +// } +// } +//} diff --git a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/Message.scala b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/Message.scala index 4cc79f2933..9ef9799d9c 100644 --- a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/Message.scala +++ b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/Message.scala @@ -15,14 +15,11 @@ package com.webank.wedatasphere.linkis.server import java.util -import com.webank.wedatasphere.linkis.server.Message.getCurrentHttpRequest + import javax.servlet.http.HttpServletRequest -import javax.ws.rs.Path -import javax.ws.rs.core.Response import javax.xml.bind.annotation.XmlRootElement import org.apache.commons.lang.StringUtils import org.apache.commons.lang.exception.ExceptionUtils -import org.reflections.ReflectionUtils import org.springframework.web.context.request.{RequestContextHolder, ServletRequestAttributes} @@ -72,20 +69,7 @@ object Message { if (StringUtils.isEmpty(method)) { Thread.currentThread().getStackTrace.find(_.getClassName.toLowerCase.endsWith("restfulapi")).foreach { stack => { - val clazz = ReflectionUtils.forName(stack.getClassName) - var annotation = clazz.getAnnotation(classOf[Path]) var path = "" - if (annotation != null) { - path = clazz.getAnnotation(classOf[Path]).value() - clazz.getDeclaredMethods.find(m => m.getName == stack.getMethodName && m.getAnnotation(classOf[Path]) != null) - .foreach { m => - val path1 = m.getAnnotation(classOf[Path]).value() - var method = if (path.startsWith("/")) path else "/" + path - if (method.endsWith("/")) method = method.substring(0, method.length - 1) - method = if (path1.startsWith("/")) "/api" + method + path1 else "/api" + method + "/" + path1 - return new Message(method, status, message, data) - } - } else { val httpRequest:HttpServletRequest=getCurrentHttpRequest if(httpRequest!=null){ val path1=httpRequest.getPathInfo; @@ -95,7 +79,6 @@ object Message { return new Message(method, status, message, data) } } - } } } new Message(method, status, message, data) @@ -140,9 +123,7 @@ object Message { message } def noLogin(msg: String): Message = noLogin(msg, null) - implicit def messageToResponse(message: Message): Response = - Response.status(messageToHttpStatus(message)).entity(message).build() - implicit def responseToMessage(response: Response): Message = response.readEntity(classOf[Message]) + def messageToHttpStatus(message: Message): Int = message.getStatus match { case -1 => 401 case 0 => 200 diff --git a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/restful/RestfulCatchAOP.scala b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/restful/RestfulCatchAOP.scala index e408ecc2c3..c55c5a4994 100644 --- a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/restful/RestfulCatchAOP.scala +++ b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/restful/RestfulCatchAOP.scala @@ -1,50 +1,50 @@ -/* - * Copyright 2019 WeBank - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.webank.wedatasphere.linkis.server.restful - -import com.webank.wedatasphere.linkis.common.utils.Logging -import com.webank.wedatasphere.linkis.server.{Message, catchIt} -import javax.ws.rs.core.Response -import org.aspectj.lang.ProceedingJoinPoint -import org.aspectj.lang.annotation.{Around, Aspect, Pointcut} -import org.springframework.stereotype.Component - - -@Aspect -@Component -class RestfulCatchAOP extends Logging { - - @Pointcut("@annotation(javax.ws.rs.Path) && execution(public com.webank.wedatasphere.linkis.server.Message *(..))") - def restfulMessageCatch() : Unit = {} - - @Around("restfulMessageCatch()") - def dealMessageRestful(proceedingJoinPoint: ProceedingJoinPoint): Object = catchIt { - proceedingJoinPoint.proceed().asInstanceOf[Message] - } - - @Pointcut("@annotation(javax.ws.rs.Path) && execution(public javax.ws.rs.core.Response *(..)))") - def restfulResponseCatch() : Unit = {} - - @Around("restfulResponseCatch()") - def dealResponseRestful(proceedingJoinPoint: ProceedingJoinPoint): Object = { - val resp: Response = catchIt { - return proceedingJoinPoint.proceed() - } - resp - } - -} +///* +// * Copyright 2019 WeBank +// * +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * +// * http://www.apache.org/licenses/LICENSE-2.0 +// * +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ +// +//package com.webank.wedatasphere.linkis.server.restful +// +//import com.webank.wedatasphere.linkis.common.utils.Logging +//import com.webank.wedatasphere.linkis.server.{Message, catchIt} +//import javax.ws.rs.core.Response +//import org.aspectj.lang.ProceedingJoinPoint +//import org.aspectj.lang.annotation.{Around, Aspect, Pointcut} +//import org.springframework.stereotype.Component +// +// +//@Aspect +//@Component +//class RestfulCatchAOP extends Logging { +// +// @Pointcut("@annotation(javax.ws.rs.Path) && execution(public com.webank.wedatasphere.linkis.server.Message *(..))") +// def restfulMessageCatch() : Unit = {} +// +// @Around("restfulMessageCatch()") +// def dealMessageRestful(proceedingJoinPoint: ProceedingJoinPoint): Object = catchIt { +// proceedingJoinPoint.proceed().asInstanceOf[Message] +// } +// +// @Pointcut("@annotation(javax.ws.rs.Path) && execution(public javax.ws.rs.core.Response *(..)))") +// def restfulResponseCatch() : Unit = {} +// +// @Around("restfulResponseCatch()") +// def dealResponseRestful(proceedingJoinPoint: ProceedingJoinPoint): Object = { +// val resp: Response = catchIt { +// return proceedingJoinPoint.proceed() +// } +// resp +// } +// +//} diff --git a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/restful/SpringRestfulCatchAOP.scala b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/restful/SpringRestfulCatchAOP.scala index 0d2568b75a..0517eac31b 100644 --- a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/restful/SpringRestfulCatchAOP.scala +++ b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/restful/SpringRestfulCatchAOP.scala @@ -28,15 +28,15 @@ import org.springframework.web.context.request.{RequestContextHolder, ServletReq class SpringRestfulCatchAOP extends Logging { @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping) && execution(public com.webank.wedatasphere.linkis.server.Message *(..)))") - def restfulResponseCatch1() : Unit = {} + def springRestfulResponseCatch() : Unit = {} - @Around("restfulResponseCatch1()") + @Around("springRestfulResponseCatch()") def dealResponseRestful(proceedingJoinPoint: ProceedingJoinPoint): Object = { val resp: Message = catchIt { return proceedingJoinPoint.proceed() } // convert http status code - getCurrentHttpResponse.setStatus(messageToHttpStatus(resp)) + getCurrentHttpResponse.setStatus(Message.messageToHttpStatus(resp)) resp } @@ -48,13 +48,5 @@ class SpringRestfulCatchAOP extends Logging { } null } - def messageToHttpStatus(message: Message): Int = message.getStatus match { - case -1 => 401 - case 0 => 200 - case 1 => 400 - case 2 => 412 - case 3 => 403 - case 4 => 206 - } } diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java b/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java index 124417a854..5e2794fb2c 100644 --- a/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java +++ b/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java @@ -292,6 +292,7 @@ public Message log(HttpServletRequest req, @PathVariable("id") String id) { } + //todo confirm params of strongExecId? @RequestMapping(path = "/{id}/killJobs",method = RequestMethod.POST) public Message killJobs(HttpServletRequest req,@RequestBody JsonNode jsonNode, @PathVariable("id") String strongExecId) { JsonNode idNode = jsonNode.get("idList"); diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextIDRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextIDRestfulApi.java index 95fb271f3b..d122443b10 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextIDRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/ContextIDRestfulApi.java @@ -54,7 +54,7 @@ public Message createContextID(HttpServletRequest req,@RequestBody JsonNode json @RequestMapping(path = "getContextID",method = RequestMethod.GET) public Message getContextID(HttpServletRequest req, - @RequestParam(value="contextId",required=false) String id) throws InterruptedException, CSErrorException { + @RequestParam(value="contextId",required=false) String id) throws InterruptedException, CSErrorException { if (StringUtils.isEmpty(id)) { throw new CSErrorException(97000, "contxtId cannot be empty"); } diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextHistoryRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextHistoryRestfulApi.java index 0239e2effc..22aecb11f9 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextHistoryRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextHistoryRestfulApi.java @@ -46,7 +46,7 @@ public class ContextHistoryRestfulApi implements CsRestfulParent { private CsScheduler csScheduler; @RequestMapping(path = "createHistory",method = RequestMethod.POST) - public Message createHistory(HttpServletRequest req,@RequestBody JsonNode json) throws InterruptedException, CSErrorException { + public Message createHistory(HttpServletRequest req) throws InterruptedException, CSErrorException { ContextHistory history = new PersistenceContextHistory(); history.setSource("server1:prot1"); history.setContextType(ContextType.METADATA); @@ -65,7 +65,7 @@ public Message createHistory(HttpServletRequest req,@RequestBody JsonNode json) } @RequestMapping(path = "removeHistory",method = RequestMethod.POST) - public Message removeHistory( HttpServletRequest req, @RequestBody JsonNode json) throws InterruptedException, CSErrorException { + public Message removeHistory( HttpServletRequest req) throws InterruptedException, CSErrorException { ContextHistory history = new PersistenceContextHistory(); history.setSource("server1:prot1"); ContextID contextID = new PersistenceContextID(); @@ -83,7 +83,7 @@ public Message removeHistory( HttpServletRequest req, @RequestBody JsonNode json @RequestMapping(path = "getHistories",method = RequestMethod.GET) - public Message getHistories( HttpServletRequest req, @RequestBody JsonNode json) throws InterruptedException, CSErrorException { + public Message getHistories( HttpServletRequest req) throws InterruptedException, CSErrorException { ContextID contextID = new PersistenceContextID(); contextID.setContextId("84716"); if (StringUtils.isEmpty(contextID.getContextId())) { @@ -94,7 +94,7 @@ public Message getHistories( HttpServletRequest req, @RequestBody JsonNode json) } @RequestMapping(path = "getHistory",method = RequestMethod.GET) - public Message getHistory( HttpServletRequest req, @RequestBody JsonNode json) throws InterruptedException, CSErrorException { + public Message getHistory( HttpServletRequest req) throws InterruptedException, CSErrorException { //ContextID contextID, String source String source = "server1:prot1"; ContextID contextID = new PersistenceContextID(); @@ -111,7 +111,7 @@ public Message getHistory( HttpServletRequest req, @RequestBody JsonNode json) t } @RequestMapping(path = "searchHistory",method = RequestMethod.GET) - public Message searchHistory( HttpServletRequest req, @RequestBody JsonNode json) throws InterruptedException, CSErrorException { + public Message searchHistory( HttpServletRequest req) throws InterruptedException, CSErrorException { //ContextID contextID, String[] keywords ContextID contextID = new PersistenceContextID(); contextID.setContextId("84716"); diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextIDRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextIDRestfulApi.java index 4dba58930a..9fdc9de3ac 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextIDRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextIDRestfulApi.java @@ -45,7 +45,7 @@ public class ContextIDRestfulApi implements CsRestfulParent { private CsScheduler csScheduler; @RequestMapping(path = "createContextID",method = RequestMethod.POST) - public Message createContextID(HttpServletRequest req, @RequestBody JsonNode json) throws InterruptedException { + public Message createContextID(HttpServletRequest req) throws InterruptedException { //contextID是client传过来的序列化的id PersistenceContextID contextID = new PersistenceContextID(); contextID.setUser("neiljianliu"); @@ -68,7 +68,7 @@ public Message getContextID( HttpServletRequest req, @RequestParam(value="contex } @RequestMapping(path = "updateContextID",method = RequestMethod.POST) - public Message updateContextID( HttpServletRequest req, @RequestBody JsonNode json) throws InterruptedException, CSErrorException { + public Message updateContextID( HttpServletRequest req) throws InterruptedException, CSErrorException { PersistenceContextID contextID = new PersistenceContextID(); contextID.setUser("johnnwang"); contextID.setExpireType(ExpireType.NEVER); @@ -86,7 +86,7 @@ public Message updateContextID( HttpServletRequest req, @RequestBody JsonNode js } @RequestMapping(path = "resetContextID",method = RequestMethod.POST) - public Message resetContextID( HttpServletRequest req, @RequestBody JsonNode json) throws InterruptedException, CSErrorException { + public Message resetContextID( HttpServletRequest req) throws InterruptedException, CSErrorException { String id = null; if (StringUtils.isEmpty(id)) { throw new CSErrorException(97000, "contxtId cannot be empty"); diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextListenerRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextListenerRestfulApi.java index 333b272380..5448f9a451 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextListenerRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextListenerRestfulApi.java @@ -43,7 +43,7 @@ public class ContextListenerRestfulApi implements CsRestfulParent { private CsScheduler csScheduler; @RequestMapping(path = "onBindIDListener",method = RequestMethod.POST) - public Message onBindIDListener(HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException { + public Message onBindIDListener(HttpServletRequest req) throws InterruptedException { //ContextIDListener listener ContextIDListener listener = null; ContextID contextID = null; @@ -52,7 +52,7 @@ public Message onBindIDListener(HttpServletRequest req,@RequestBody JsonNode jso } @RequestMapping(path = "onBindKeyListener",method = RequestMethod.POST) - public Message onBindKeyListener( HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException { + public Message onBindKeyListener( HttpServletRequest req) throws InterruptedException { ContextKeyListener listener = null; ContextID contextID = null; ContextKey contextKey = null; diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextRestfulApi.java index 5668335ceb..1a1d14aba9 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextRestfulApi.java +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/test/java/com/webank/wedatasphere/linkis/cs/server/ContextRestfulApi.java @@ -70,7 +70,7 @@ public Message createContext(HttpServletRequest request) throws Exception{ @RequestMapping(path = "getContextValue",method = RequestMethod.POST) - public Message getContextValue( HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException { + public Message getContextValue( HttpServletRequest req) throws InterruptedException { //ContextID contextID, ContextKey contextKey ContextID contextID = new PersistenceContextID(); contextID.setContextId("84716"); @@ -117,7 +117,7 @@ public Message searchContextValueByCondition( HttpServletRequest req, @RequestBo @RequestMapping(path = "setValueByKey",method = RequestMethod.POST) - public Message setValueByKey( HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException { + public Message setValueByKey( HttpServletRequest req) throws InterruptedException, CSErrorException { /*JSONSerializer jsonSerializer = new JSONSerializer(); PersistenceContextID contextID = new PersistenceContextID(); //// TODO: 2020/2/26 手动修改contextid @@ -140,7 +140,7 @@ public Message setValueByKey( HttpServletRequest req,@RequestBody JsonNode jsonN } @RequestMapping(path = "setValue",method = RequestMethod.POST) - public Message setValue( HttpServletRequest req, @RequestBody JsonNode jsonNode) throws InterruptedException, CSErrorException { + public Message setValue( HttpServletRequest req) throws InterruptedException, CSErrorException { /*JSONSerializer jsonSerializer = new JSONSerializer(); PersistenceContextID contextID = new PersistenceContextID(); //// TODO: 2020/2/26 手动修改contextid @@ -167,7 +167,7 @@ public Message setValue( HttpServletRequest req, @RequestBody JsonNode jsonNode) } @RequestMapping(path = "resetValue",method = RequestMethod.POST) - public Message resetValue( HttpServletRequest req, @RequestBody JsonNode jsonNode) throws InterruptedException { + public Message resetValue( HttpServletRequest req) throws InterruptedException { ContextID contextID = null; ContextKey contextKey = null; HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.RESET, contextID, contextKey); @@ -175,7 +175,7 @@ public Message resetValue( HttpServletRequest req, @RequestBody JsonNode jsonNod } @RequestMapping(path = "removeValue",method = RequestMethod.POST) - public Message removeValue( HttpServletRequest req,@RequestBody JsonNode jsonNode) throws InterruptedException { + public Message removeValue( HttpServletRequest req) throws InterruptedException { ContextID contextID = new PersistenceContextID(); contextID.setContextId("84716"); ContextKey contextKey = new PersistenceContextKey(); @@ -185,7 +185,7 @@ public Message removeValue( HttpServletRequest req,@RequestBody JsonNode jsonNod } @RequestMapping(path = "removeAllValue",method = RequestMethod.POST) - public Message removeAllValue( HttpServletRequest req, @RequestBody JsonNode jsonNode) throws InterruptedException { + public Message removeAllValue( HttpServletRequest req) throws InterruptedException { ContextID contextID = new PersistenceContextID(); contextID.setContextId("84716"); HttpAnswerJob answerJob = submitRestJob(req, ServiceMethod.REMOVEALL, contextID); diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/FsRestfulApi.java b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/FsRestfulApi.java index f66ef2dd4b..00ac4f5ebd 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/FsRestfulApi.java +++ b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/FsRestfulApi.java @@ -25,7 +25,7 @@ import com.webank.wedatasphere.linkis.filesystem.exception.WorkspaceExceptionManager; import com.webank.wedatasphere.linkis.filesystem.service.FsService; import com.webank.wedatasphere.linkis.filesystem.util.WorkspaceUtil; -import com.webank.wedatasphere.linkis.filesystem.validator.PathValidator$; +import com.webank.wedatasphere.linkis.filesystem.validator.SpringPathValidator$; import com.webank.wedatasphere.linkis.server.Message; import com.webank.wedatasphere.linkis.server.security.SecurityFilter; import com.webank.wedatasphere.linkis.storage.csv.CSVFsWriter; @@ -42,9 +42,6 @@ import org.apache.commons.math3.util.Pair; import org.apache.http.Consts; import com.fasterxml.jackson.databind.JsonNode; -import org.glassfish.jersey.media.multipart.FormDataBodyPart; -import org.glassfish.jersey.media.multipart.FormDataContentDisposition; -import org.glassfish.jersey.media.multipart.FormDataMultiPart; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -59,6 +56,7 @@ import java.nio.file.Files; import java.nio.file.Paths; import java.util.*; +import org.springframework.web.multipart.MultipartFile; import static com.webank.wedatasphere.linkis.filesystem.conf.WorkSpaceConfiguration.*; import static com.webank.wedatasphere.linkis.filesystem.constant.WorkSpaceConstants.*; @@ -141,8 +139,8 @@ public Message rename(HttpServletRequest req,@RequestBody JsonNode json) throws String userName = SecurityFilter.getLoginUsername(req); if (FILESYSTEM_PATH_CHECK_TRIGGER.getValue()) { LOGGER.info(String.format("path check trigger is open,now check the path,oldDest:%s,newDest:%s", oldDest, newDest)); - PathValidator$.MODULE$.validate(oldDest, userName); - PathValidator$.MODULE$.validate(newDest, userName); + SpringPathValidator$.MODULE$.validate(oldDest, userName); + SpringPathValidator$.MODULE$.validate(newDest, userName); } if (StringUtils.isEmpty(oldDest)) { throw WorkspaceExceptionManager.createException(80004, oldDest); @@ -164,22 +162,20 @@ public Message rename(HttpServletRequest req,@RequestBody JsonNode json) throws @RequestMapping(path = "/upload",method = RequestMethod.POST) public Message upload(HttpServletRequest req, - @RequestParam("path") String path, - FormDataMultiPart form) throws IOException, WorkSpaceException { + @RequestParam("path") String path, + @RequestParam("file") List files) throws IOException, WorkSpaceException { String userName = SecurityFilter.getLoginUsername(req); if (StringUtils.isEmpty(path)) { throw WorkspaceExceptionManager.createException(80004, path); } FsPath fsPath = new FsPath(path); FileSystem fileSystem = fsService.getFileSystem(userName, fsPath); - List files = form.getFields("file"); - for (FormDataBodyPart p : files) { - FormDataContentDisposition fileDetail = p.getFormDataContentDisposition(); - String fileName = new String(fileDetail.getFileName().getBytes(Consts.ISO_8859_1), Consts.UTF_8); + for (MultipartFile p : files) { + String fileName = new String(p.getOriginalFilename().getBytes(Consts.ISO_8859_1), Consts.UTF_8); FsPath fsPathNew = new FsPath(fsPath.getPath() + "/" + fileName); WorkspaceUtil.fileAndDirNameSpecialCharCheck(fsPathNew.getPath()); fileSystem.createNewFile(fsPathNew); - try (InputStream is = p.getValueAs(InputStream.class); + try (InputStream is = p.getInputStream(); OutputStream outputStream = fileSystem.write(fsPathNew, true)) { IOUtils.copy(is, outputStream); } @@ -585,7 +581,9 @@ public Message formate(HttpServletRequest req, } @RequestMapping(path = "/openLog",method = RequestMethod.GET) - public Message openLog(HttpServletRequest req, @RequestParam(value="path",required=false) String path, @RequestParam(value="proxyUser",required=false) String proxyUser) throws IOException, WorkSpaceException { + public Message openLog(HttpServletRequest req, + @RequestParam(value="path",required=false) String path, + @RequestParam(value="proxyUser",required=false) String proxyUser) throws IOException, WorkSpaceException { String userName = SecurityFilter.getLoginUsername(req); if (StringUtils.isEmpty(path)) { throw WorkspaceExceptionManager.createException(80004, path); diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/PathValidator.scala b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/PathValidator.scala index 317f9e6c45..fc65bda170 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/PathValidator.scala +++ b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/PathValidator.scala @@ -1,126 +1,126 @@ -/* - * Copyright 2019 WeBank - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.webank.wedatasphere.linkis.filesystem.validator - -import java.io.File - -import com.webank.wedatasphere.linkis.common.utils.Logging -import com.webank.wedatasphere.linkis.filesystem.conf.WorkSpaceConfiguration._ -import com.webank.wedatasphere.linkis.filesystem.exception.WorkSpaceException -import com.webank.wedatasphere.linkis.filesystem.util.WorkspaceUtil -import com.webank.wedatasphere.linkis.server -import com.webank.wedatasphere.linkis.server.Message -import com.webank.wedatasphere.linkis.server.security.SecurityFilter -import com.webank.wedatasphere.linkis.storage.utils.StorageUtils -import javax.servlet.http.HttpServletRequest -import javax.ws.rs.core.Response -import org.aspectj.lang.ProceedingJoinPoint -import org.aspectj.lang.annotation.{Around, Aspect, Pointcut} -import org.aspectj.lang.reflect.MethodSignature -import org.codehaus.jackson.JsonNode -import org.springframework.stereotype.Component -import org.springframework.util.StringUtils - -@Aspect -@Component -class PathValidator extends Logging { - - @Pointcut("@annotation(javax.ws.rs.Path) && within(com.webank.wedatasphere.linkis.filesystem.restful.api.*)") - def restfulResponseCatch(): Unit = {} - - def getPath(args: Array[Object], paramNames: Array[String]): String = { - var path: String = null - var index: Int = paramNames.indexOf("path") - if (index != -1) { - path = args(index).asInstanceOf[String] - } else { - index = paramNames.indexOf("json") - if (index != -1) { - args(index) match { - case j: JsonNode if j.get("path") != null => path = j.get("path").getTextValue - case m: java.util.Map[String, Object] if m.get("path") != null => path = m.get("path").asInstanceOf[String] - case _ => - } - } - } - path - } - - def getUserName(args: Array[Object], paramNames: Array[String]): String = { - var username: String = null - paramNames.indexOf("req") match { - case -1 => - case index: Int => { - val proxyUser = paramNames.indexOf("proxyUser") - if (proxyUser == -1 || StringUtils.isEmpty(args(proxyUser))) { - username = SecurityFilter.getLoginUsername(args(index).asInstanceOf[HttpServletRequest]) - } else { - //增加proxyuser的判断 - username = args(proxyUser).toString - } - } - } - username - } - - def checkPath(path: String, username: String) = { - //校验path的逻辑 - val userLocalRootPath: String = WorkspaceUtil.suffixTuning(LOCAL_USER_ROOT_PATH.getValue) + - username - var userHdfsRootPath: String = WorkspaceUtil.suffixTuning(HDFS_USER_ROOT_PATH_PREFIX.getValue) + - username + HDFS_USER_ROOT_PATH_SUFFIX.getValue - if (!(path.contains(StorageUtils.FILE_SCHEMA)) && !(path.contains(StorageUtils.HDFS_SCHEMA))) { - throw new WorkSpaceException(80025, "the path should contain schema") - } - userHdfsRootPath = StringUtils.trimTrailingCharacter(userHdfsRootPath, File.separatorChar) - if (path.contains("../")) { - throw new WorkSpaceException(80026, "Relative path not allowed") - } - if (!(path.contains(userLocalRootPath)) && !(path.contains(userHdfsRootPath))) { - throw new WorkSpaceException(80027, "The path needs to be within the user's own workspace path") - } - } - - def validate(args: Array[Object], paramNames: Array[String]) = { - //获取path:String,json:JsonNode,json:Map中的path 参数 - val path: String = getPath(args, paramNames) - val username: String = getUserName(args, paramNames) - if (!StringUtils.isEmpty(path) && !StringUtils.isEmpty(username)) { - logger.info(String.format("user:%s,path:%s", username, path)) - checkPath(path, username) - } - } - - @Around("restfulResponseCatch()") - def dealResponseRestful(proceedingJoinPoint: ProceedingJoinPoint): Object = { - val response: Response = server.catchIt { - val signature = proceedingJoinPoint.getSignature.asInstanceOf[MethodSignature] - logger.info("enter the path validator,the method is {}", signature.getName) - if (FILESYSTEM_PATH_CHECK_TRIGGER.getValue) { - logger.info("path check trigger is open,now check the path") - validate(proceedingJoinPoint.getArgs, signature.getParameterNames) - } - Message.ok() - } - if (response.getStatus != 200) response else proceedingJoinPoint.proceed() - } -} - -object PathValidator { - val validator = new PathValidator() - - def validate(path: String, username: String): Unit = { - validator.checkPath(path, username) - } -} +///* +// * Copyright 2019 WeBank +// * Licensed under the Apache License, Version 2.0 (the "License"); +// * you may not use this file except in compliance with the License. +// * You may obtain a copy of the License at +// * http://www.apache.org/licenses/LICENSE-2.0 +// * Unless required by applicable law or agreed to in writing, software +// * distributed under the License is distributed on an "AS IS" BASIS, +// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// * See the License for the specific language governing permissions and +// * limitations under the License. +// */ +// +//package com.webank.wedatasphere.linkis.filesystem.validator +// +//import java.io.File +// +//import com.webank.wedatasphere.linkis.common.utils.Logging +//import com.webank.wedatasphere.linkis.filesystem.conf.WorkSpaceConfiguration._ +//import com.webank.wedatasphere.linkis.filesystem.exception.WorkSpaceException +//import com.webank.wedatasphere.linkis.filesystem.util.WorkspaceUtil +//import com.webank.wedatasphere.linkis.server +//import com.webank.wedatasphere.linkis.server.Message +//import com.webank.wedatasphere.linkis.server.security.SecurityFilter +//import com.webank.wedatasphere.linkis.storage.utils.StorageUtils +//import javax.servlet.http.HttpServletRequest +//import javax.ws.rs.core.Response +//import org.aspectj.lang.ProceedingJoinPoint +//import org.aspectj.lang.annotation.{Around, Aspect, Pointcut} +//import org.aspectj.lang.reflect.MethodSignature +//import org.codehaus.jackson.JsonNode +//import org.springframework.stereotype.Component +//import org.springframework.util.StringUtils +// +//@Aspect +//@Component +//class PathValidator extends Logging { +// +// @Pointcut("@annotation(javax.ws.rs.Path) && within(com.webank.wedatasphere.linkis.filesystem.restful.api.*)") +// def restfulResponseCatch(): Unit = {} +// +// def getPath(args: Array[Object], paramNames: Array[String]): String = { +// var path: String = null +// var index: Int = paramNames.indexOf("path") +// if (index != -1) { +// path = args(index).asInstanceOf[String] +// } else { +// index = paramNames.indexOf("json") +// if (index != -1) { +// args(index) match { +// case j: JsonNode if j.get("path") != null => path = j.get("path").getTextValue +// case m: java.util.Map[String, Object] if m.get("path") != null => path = m.get("path").asInstanceOf[String] +// case _ => +// } +// } +// } +// path +// } +// +// def getUserName(args: Array[Object], paramNames: Array[String]): String = { +// var username: String = null +// paramNames.indexOf("req") match { +// case -1 => +// case index: Int => { +// val proxyUser = paramNames.indexOf("proxyUser") +// if (proxyUser == -1 || StringUtils.isEmpty(args(proxyUser))) { +// username = SecurityFilter.getLoginUsername(args(index).asInstanceOf[HttpServletRequest]) +// } else { +// //增加proxyuser的判断 +// username = args(proxyUser).toString +// } +// } +// } +// username +// } +// +// def checkPath(path: String, username: String) = { +// //校验path的逻辑 +// val userLocalRootPath: String = WorkspaceUtil.suffixTuning(LOCAL_USER_ROOT_PATH.getValue) + +// username +// var userHdfsRootPath: String = WorkspaceUtil.suffixTuning(HDFS_USER_ROOT_PATH_PREFIX.getValue) + +// username + HDFS_USER_ROOT_PATH_SUFFIX.getValue +// if (!(path.contains(StorageUtils.FILE_SCHEMA)) && !(path.contains(StorageUtils.HDFS_SCHEMA))) { +// throw new WorkSpaceException(80025, "the path should contain schema") +// } +// userHdfsRootPath = StringUtils.trimTrailingCharacter(userHdfsRootPath, File.separatorChar) +// if (path.contains("../")) { +// throw new WorkSpaceException(80026, "Relative path not allowed") +// } +// if (!(path.contains(userLocalRootPath)) && !(path.contains(userHdfsRootPath))) { +// throw new WorkSpaceException(80027, "The path needs to be within the user's own workspace path") +// } +// } +// +// def validate(args: Array[Object], paramNames: Array[String]) = { +// //获取path:String,json:JsonNode,json:Map中的path 参数 +// val path: String = getPath(args, paramNames) +// val username: String = getUserName(args, paramNames) +// if (!StringUtils.isEmpty(path) && !StringUtils.isEmpty(username)) { +// logger.info(String.format("user:%s,path:%s", username, path)) +// checkPath(path, username) +// } +// } +// +// @Around("restfulResponseCatch()") +// def dealResponseRestful(proceedingJoinPoint: ProceedingJoinPoint): Object = { +// val response: Response = server.catchIt { +// val signature = proceedingJoinPoint.getSignature.asInstanceOf[MethodSignature] +// logger.info("enter the path validator,the method is {}", signature.getName) +// if (FILESYSTEM_PATH_CHECK_TRIGGER.getValue) { +// logger.info("path check trigger is open,now check the path") +// validate(proceedingJoinPoint.getArgs, signature.getParameterNames) +// } +// Message.ok() +// } +// if (response.getStatus != 200) response else proceedingJoinPoint.proceed() +// } +//} +// +//object PathValidator { +// val validator = new PathValidator() +// +// def validate(path: String, username: String): Unit = { +// validator.checkPath(path, username) +// } +//} diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/SpringPathValidator.scala b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/SpringPathValidator.scala index 3f82fb9b07..3ad170d241 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/SpringPathValidator.scala +++ b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/SpringPathValidator.scala @@ -113,7 +113,7 @@ class SpringPathValidator extends Logging { } Message.ok() } - if ( messageToHttpStatus(resp)!= 200) resp else proceedingJoinPoint.proceed() + if (Message.messageToHttpStatus(resp)!= 200) resp else proceedingJoinPoint.proceed() } def getCurrentHttpResponse: HttpServletResponse = { @@ -124,15 +124,6 @@ class SpringPathValidator extends Logging { } null } - def messageToHttpStatus(message: Message): Int = message.getStatus match { - case -1 => 401 - case 0 => 200 - case 1 => 400 - case 2 => 412 - case 3 => 403 - case 4 => 206 - } - } object SpringPathValidator { diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-service/src/main/java/com/webank/wedatasphere/linkis/udf/api/UDFApi.java b/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-service/src/main/java/com/webank/wedatasphere/linkis/udf/api/UDFApi.java index 659069e12e..989a56767d 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-service/src/main/java/com/webank/wedatasphere/linkis/udf/api/UDFApi.java +++ b/linkis-public-enhancements/linkis-publicservice/linkis-udf/linkis-udf-service/src/main/java/com/webank/wedatasphere/linkis/udf/api/UDFApi.java @@ -121,7 +121,7 @@ private void fetchUdfInfoRecursively(List allInfo, UDFTree udfTree, Str } @RequestMapping(path = "list",method = RequestMethod.POST) - public Message listUDF(HttpServletRequest req, Map json){ + public Message listUDF(HttpServletRequest req,@RequestBody Map json){ Message message = null; try { String userName = SecurityFilter.getLoginUsername(req); @@ -192,7 +192,8 @@ public Message deleteUDF(HttpServletRequest req,@PathVariable("id") Long id){ @RequestMapping(path = "isload",method = RequestMethod.GET) public Message isLoad(HttpServletRequest req, - @RequestParam(value="udfId",required=false) Long udfId,@RequestParam(value="isLoad",required=false) Boolean isLoad){ + @RequestParam(value="udfId",required=false) Long udfId, + @RequestParam(value="isLoad",required=false) Boolean isLoad){ String userName = SecurityFilter.getLoginUsername(req); Message message = null; try { @@ -210,7 +211,7 @@ public Message isLoad(HttpServletRequest req, } @RequestMapping(path = "/tree/add",method = RequestMethod.POST) - public Message addTree(HttpServletRequest req, UDFTree udfTree){ + public Message addTree(HttpServletRequest req,@RequestBody UDFTree udfTree){ String userName = SecurityFilter.getLoginUsername(req); Message message = null; try { @@ -229,7 +230,7 @@ public Message addTree(HttpServletRequest req, UDFTree udfTree){ } @RequestMapping(path = "/tree/update",method = RequestMethod.POST) - public Message updateTree(HttpServletRequest req, UDFTree udfTree){ + public Message updateTree(HttpServletRequest req,@RequestBody UDFTree udfTree){ String userName = SecurityFilter.getLoginUsername(req); Message message = null; try { @@ -261,7 +262,7 @@ public Message deleteTree(HttpServletRequest req,@PathVariable("id") Long id){ } @RequestMapping(path = "/authenticate",method = RequestMethod.POST) - public Message Authenticate(HttpServletRequest req,@RequestBody JsonNode json){ + public Message Authenticate(HttpServletRequest req){ Message message = null; try { String userName = SecurityFilter.getLoginUsername(req); @@ -301,7 +302,7 @@ public Message setExpire(HttpServletRequest req,@RequestBody JsonNode json){ } Long shareUDFId=udfService.getAllShareUDFInfoIdByUDFId(userName,udfName); if(shareUDFId != null){ - if(shareUDFId == udfId){ + if(shareUDFId.equals(udfId)){ throw new UDFException("请操作该共享函数对应的个人函数。"); } udfService.setSharedUDFInfoExpire(shareUDFId); From 18044b972dff2eb941f470a66f60b385caa9b08f Mon Sep 17 00:00:00 2001 From: casionxia Date: Thu, 30 Sep 2021 13:35:39 +0800 Subject: [PATCH 25/29] remove unused dependency --- linkis-commons/linkis-module/pom.xml | 220 +++++++++--------- linkis-commons/linkis-storage/pom.xml | 10 +- .../linkis-application-manager/pom.xml | 10 +- .../linkis-spring-cloud-gateway/pom.xml | 21 +- 4 files changed, 141 insertions(+), 120 deletions(-) diff --git a/linkis-commons/linkis-module/pom.xml b/linkis-commons/linkis-module/pom.xml index 4054626d86..69263eb783 100644 --- a/linkis-commons/linkis-module/pom.xml +++ b/linkis-commons/linkis-module/pom.xml @@ -61,10 +61,11 @@ spring-cloud-starter-netflix-eureka-client ${spring.eureka.version} - - jsr311-api - javax.ws.rs - + + + + + spring-boot-autoconfigure org.springframework.boot @@ -307,11 +308,18 @@ 5.1.49 + + + + + + - org.glassfish.jersey.bundles - jaxrs-ri - 2.21 + javax.validation + validation-api + 2.0.1.Final + cglib cglib @@ -338,108 +346,108 @@ ${jetty.version} - - org.glassfish.jersey.ext - jersey-spring3 - ${jersey.servlet.version} - - - org.springframework - spring - - - org.springframework - spring-core - - - org.springframework - spring-web - - - org.springframework - spring-beans - - - org.springframework - spring-context - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - com.sun.jersey - jersey-server - 1.19.1 - - - jsr311-api - javax.ws.rs - - - - - com.sun.jersey - jersey-servlet - 1.19.1 - - - org.glassfish.jersey.containers - jersey-container-servlet - ${jersey.servlet.version} - - - org.glassfish.jersey.containers - jersey-container-servlet-core - ${jersey.servlet.version} - - - javax.ws.rs-api - javax.ws.rs - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - org.glassfish.jersey.media - jersey-media-json-jackson - ${jersey.version} - - - jackson-core - com.fasterxml.jackson.core - - - jackson-databind - com.fasterxml.jackson.core - - - - - org.glassfish.jersey.media - jersey-media-multipart - ${jersey.version} - - - org.glassfish.jersey.ext - jersey-entity-filtering - ${jersey.version} - - - com.sun.jersey - jersey-json - - - jsr311-api - javax.ws.rs - - - jersey-core - com.sun.jersey - - - 1.19 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + com.fasterxml.jackson.core diff --git a/linkis-commons/linkis-storage/pom.xml b/linkis-commons/linkis-storage/pom.xml index 610d3ceabf..f958c5bbcf 100644 --- a/linkis-commons/linkis-storage/pom.xml +++ b/linkis-commons/linkis-storage/pom.xml @@ -58,11 +58,11 @@ cglib 2.2.2 - - net.sourceforge.javacsv - javacsv - 2.0 - + + + + + com.monitorjbl xlsx-streamer diff --git a/linkis-computation-governance/linkis-manager/linkis-application-manager/pom.xml b/linkis-computation-governance/linkis-manager/linkis-application-manager/pom.xml index 88f009548c..8cc986daf8 100644 --- a/linkis-computation-governance/linkis-manager/linkis-application-manager/pom.xml +++ b/linkis-computation-governance/linkis-manager/linkis-application-manager/pom.xml @@ -123,11 +123,11 @@ compile - - com.github.dozermapper - dozer-core - 6.5.0 - + + + + + diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/pom.xml b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/pom.xml index d4064e8b84..e87df90c51 100644 --- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/pom.xml +++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/pom.xml @@ -54,10 +54,10 @@ spring-cloud-starter-gateway ${spring.cloud.version} - - hibernate-validator - org.hibernate.validator - + + + + spring-boot-starter-logging org.springframework.boot @@ -96,10 +96,23 @@ + + + + + + + org.springframework.boot spring-boot-starter ${spring.boot.version} + + + spring-boot-starter-logging + org.springframework.boot + + From de1df7ab3208a1f1653b1fb70c8a9dd1f1221835 Mon Sep 17 00:00:00 2001 From: casionxia Date: Fri, 8 Oct 2021 20:00:09 +0800 Subject: [PATCH 26/29] remove unused dependency --- linkis-commons/linkis-module/pom.xml | 114 +++++++++--------- .../linkis-spring-cloud-gateway/pom.xml | 13 -- 2 files changed, 55 insertions(+), 72 deletions(-) diff --git a/linkis-commons/linkis-module/pom.xml b/linkis-commons/linkis-module/pom.xml index 69263eb783..539b4cec4a 100644 --- a/linkis-commons/linkis-module/pom.xml +++ b/linkis-commons/linkis-module/pom.xml @@ -61,11 +61,10 @@ spring-cloud-starter-netflix-eureka-client ${spring.eureka.version} - - - - - + + jsr311-api + javax.ws.rs + spring-boot-autoconfigure org.springframework.boot @@ -308,18 +307,11 @@ 5.1.49 - - - - - - javax.validation validation-api 2.0.1.Final - cglib cglib @@ -375,38 +367,42 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + com.sun.jersey + jersey-server + 1.19.1 + + + jsr311-api + javax.ws.rs + + + javax.validation + validation-api + + + + + com.sun.jersey + jersey-servlet + 1.19.1 + + + org.glassfish.jersey.containers + jersey-container-servlet + ${jersey.servlet.version} + + + org.glassfish.jersey.containers + jersey-container-servlet-core + ${jersey.servlet.version} + + + javax.ws.rs-api + javax.ws.rs + + + @@ -433,21 +429,21 @@ - - - - - - - - - - - - - - - + + com.sun.jersey + jersey-json + + + jsr311-api + javax.ws.rs + + + jersey-core + com.sun.jersey + + + 1.19 + com.fasterxml.jackson.core diff --git a/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/pom.xml b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/pom.xml index e87df90c51..d32b67b49c 100644 --- a/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/pom.xml +++ b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/pom.xml @@ -96,23 +96,10 @@ - - - - - - - org.springframework.boot spring-boot-starter ${spring.boot.version} - - - spring-boot-starter-logging - org.springframework.boot - - From 7dd8abc1472ad6e746bbcd822a09931adda9b807 Mon Sep 17 00:00:00 2001 From: casionone Date: Wed, 13 Oct 2021 16:20:39 +0800 Subject: [PATCH 27/29] Parameter optimization & remove useless comments --- .../common/conf/DWCArgumentsParser.scala | 6 - linkis-commons/linkis-module/pom.xml | 54 ---- .../linkis/DataWorkCloudApplication.java | 4 +- .../server/restful/RestfulApplication.java | 50 ---- .../linkis/server/BDPJettyServerHelper.scala | 15 - .../server/conf/ServerConfiguration.scala | 1 - .../server/utils/LinkisMainHelper.scala | 5 +- .../LinkisClientApplicationTest.java | 2 +- .../hook/CallbackEngineConnHook.scala | 2 +- .../entrance/restful/EntranceRestfulApi.java | 7 +- .../restful/EntranceRestfulRemote.scala | 126 +++++---- .../linkis-application-manager/pom.xml | 7 - .../linkis-cs-listener/pom.xml | 4 +- .../filesystem/restful/api/FsRestfulApi.java | 6 +- .../filesystem/validator/PathValidator.scala | 263 +++++++++--------- .../validator/SpringPathValidator.scala | 137 --------- 16 files changed, 215 insertions(+), 474 deletions(-) delete mode 100644 linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/server/restful/RestfulApplication.java delete mode 100644 linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/SpringPathValidator.scala diff --git a/linkis-commons/linkis-common/src/main/scala/com/webank/wedatasphere/linkis/common/conf/DWCArgumentsParser.scala b/linkis-commons/linkis-common/src/main/scala/com/webank/wedatasphere/linkis/common/conf/DWCArgumentsParser.scala index 08adfbbc04..c6e4f61a01 100644 --- a/linkis-commons/linkis-common/src/main/scala/com/webank/wedatasphere/linkis/common/conf/DWCArgumentsParser.scala +++ b/linkis-commons/linkis-common/src/main/scala/com/webank/wedatasphere/linkis/common/conf/DWCArgumentsParser.scala @@ -25,7 +25,6 @@ import scala.collection.{JavaConversions, mutable} object DWCArgumentsParser { protected val DWC_CONF = "--engineconn-conf" protected val SPRING_CONF = "--spring-conf" - private val SPRING_STAR = "spring." private var dwcOptionMap = Map.empty[String, String] private[linkis] def setDWCOptionMap(dwcOptionMap: Map[String, String]) = this.dwcOptionMap = dwcOptionMap @@ -75,11 +74,6 @@ object DWCArgumentsParser { val options = ArrayBuffer[String]() springOptionMap.foreach { case (key, value) => if (StringUtils.isNotEmpty(key) && StringUtils.isNotEmpty(value)) { - var realKey=key -// if(key.startsWith(SPRING_STAR+SPRING_STAR)){ -// realKey = key.substring(SPRING_STAR.length) -// } -// options += ("--" + realKey + "=" + value) options += ("--" + key + "=" + value) } } diff --git a/linkis-commons/linkis-module/pom.xml b/linkis-commons/linkis-module/pom.xml index 539b4cec4a..9ebecbd84f 100644 --- a/linkis-commons/linkis-module/pom.xml +++ b/linkis-commons/linkis-module/pom.xml @@ -338,35 +338,6 @@ ${jetty.version} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - com.sun.jersey jersey-server @@ -404,31 +375,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - com.sun.jersey jersey-json diff --git a/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/DataWorkCloudApplication.java b/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/DataWorkCloudApplication.java index b21085436c..6afc72ed63 100644 --- a/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/DataWorkCloudApplication.java +++ b/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/DataWorkCloudApplication.java @@ -80,7 +80,6 @@ public static ApplicationContext getApplicationContext() { public static void main(String[] args) throws ReflectiveOperationException { - //RuntimeDelegate.setInstance(new org.glassfish.jersey.internal.RuntimeDelegateImpl()); final SpringApplication application = new SpringApplication(DataWorkCloudApplication.class); application.addListeners(new ApplicationListener(){ public void onApplicationEvent(ApplicationPreparedEvent applicationPreparedEvent) { @@ -183,7 +182,7 @@ protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { //todo confirm @Bean - public ObjectMapper get() { + public ObjectMapper defaultObjectMapper() { ObjectMapper objectMapper = new ObjectMapper() .registerModule(new JavaTimeModule()) .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, true); @@ -204,7 +203,6 @@ public void customize(Server server) { filterHolder.setInitParameter("encoding", Configuration.BDP_ENCODING().getValue()); filterHolder.setInitParameter("forceEncoding", "true"); webApp.addFilter(filterHolder, "/*", EnumSet.allOf(DispatcherType.class)); - // BDPJettyServerHelper.setupRestApiContextHandler(webApp); //set servletHolder for spring restful api BDPJettyServerHelper.setupSpringRestApiContextHandler(webApp); diff --git a/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/server/restful/RestfulApplication.java b/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/server/restful/RestfulApplication.java deleted file mode 100644 index 512c329665..0000000000 --- a/linkis-commons/linkis-module/src/main/java/com/webank/wedatasphere/linkis/server/restful/RestfulApplication.java +++ /dev/null @@ -1,50 +0,0 @@ -///* -// * Copyright 2019 WeBank -// * -// * Licensed under the Apache License, Version 2.0 (the "License"); -// * you may not use this file except in compliance with the License. -// * You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ -// -//package com.webank.wedatasphere.linkis.server.restful; -// -//import com.webank.wedatasphere.linkis.server.conf.ServerConfiguration; -//import org.apache.commons.lang.StringUtils; -//import org.apache.commons.logging.Log; -//import org.apache.commons.logging.LogFactory; -//import org.codehaus.jackson.jaxrs.JacksonJsonProvider; -//import org.glassfish.jersey.jackson.JacksonFeature; -//import org.glassfish.jersey.media.multipart.MultiPartFeature; -//import org.glassfish.jersey.server.ResourceConfig; -// -// -//public class RestfulApplication extends ResourceConfig { -// -// private static final Log logger = LogFactory.getLog(RestfulApplication.class); -// -// public RestfulApplication() throws ClassNotFoundException { -// register(JacksonFeature.class); -// register(JacksonJsonProvider.class); -// register(MultiPartFeature.class); -// String registerClasses = ServerConfiguration.BDP_SERVER_RESTFUL_REGISTER_CLASSES().acquireNew(); -// if(StringUtils.isNotBlank(registerClasses)) { -// for(String clazz : registerClasses.split(",")) { -// logger.info("register " + clazz); -// register(Class.forName(clazz, true, Thread.currentThread().getContextClassLoader())); -// } -// } -// String packages = ServerConfiguration.BDP_SERVER_RESTFUL_SCAN_PACKAGES().acquireNew(); -// if(StringUtils.isNotBlank(packages)) { -// logger.info("packages " + packages); -// packages(packages.split(",")); -// } -// } -//} diff --git a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/BDPJettyServerHelper.scala b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/BDPJettyServerHelper.scala index f9e8dff192..7cc0700738 100644 --- a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/BDPJettyServerHelper.scala +++ b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/BDPJettyServerHelper.scala @@ -66,21 +66,6 @@ private[linkis] object BDPJettyServerHelper extends Logging { private def getSecurityFilter(): Class[Filter] = Class.forName(BDP_SERVER_SECURITY_FILTER.getValue).asInstanceOf[Class[Filter]] -// def setupRestApiContextHandler(webApp: ServletContextHandler) { -// val servletHolder = new ServletHolder(classOf[ServletContainer]) -// servletHolder.setInitParameter("javax.ws.rs.Application", classOf[RestfulApplication].getName) -// servletHolder.setName("restful") -// servletHolder.setForcedPath("restful") -// webApp.setSessionHandler(new SessionHandler) -// val p = "/api/rest_xx/" -// val restfulPath = if(p.endsWith("/*")) p -// else if(p.endsWith("/")) p + "*" -// else p + "/*" -// webApp.addServlet(servletHolder, restfulPath) -// val filterHolder = new FilterHolder(getSecurityFilter()) -// webApp.addFilter(filterHolder, restfulPath, EnumSet.allOf(classOf[DispatcherType])) - // } - def setupSpringRestApiContextHandler(webApp: ServletContextHandler) { val context = new AnnotationConfigWebApplicationContext //val CONFIG_LOCATION = "com.webank.wedatasphere.linkis.manager.am" diff --git a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/conf/ServerConfiguration.scala b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/conf/ServerConfiguration.scala index 5400381eef..c773dcb4a0 100644 --- a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/conf/ServerConfiguration.scala +++ b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/conf/ServerConfiguration.scala @@ -75,7 +75,6 @@ object ServerConfiguration extends Logging{ val BDP_SERVER_SERVER_CONTEXT_PATH = CommonVars("wds.linkis.server.context.path", "/") val BDP_SERVER_RESTFUL_URI = CommonVars("wds.linkis.server.restful.uri", "/api/rest_j/" + BDP_SERVER_VERSION) - // val BDP_SERVER_SPRING_RESTFUL_URI = CommonVars("wds.linkis.server.restful.uri", "/api/rest_s/" + BDP_SERVER_VERSION) val BDP_SERVER_USER_URI = CommonVars("wds.linkis.server.user.restful.uri", "/api/rest_j/" + BDP_SERVER_VERSION + "/user") val BDP_SERVER_RESTFUL_LOGIN_URI = CommonVars("wds.linkis.server.user.restful.login.uri", new File(BDP_SERVER_USER_URI.getValue, "login").getPath) val BDP_SERVER_SECURITY_SSL_URI = CommonVars("wds.linkis.server.user.security.ssl.uri", new File(BDP_SERVER_USER_URI.getValue, "publicKey").getPath) diff --git a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/utils/LinkisMainHelper.scala b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/utils/LinkisMainHelper.scala index 0fc62da364..625be55be8 100644 --- a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/utils/LinkisMainHelper.scala +++ b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/utils/LinkisMainHelper.scala @@ -17,6 +17,8 @@ package com.webank.wedatasphere.linkis.server.utils import com.webank.wedatasphere.linkis.common.conf.CommonVars +import com.webank.wedatasphere.linkis.server.conf.ServerConfiguration + import scala.collection.JavaConverters._ object LinkisMainHelper { @@ -42,7 +44,8 @@ object LinkisMainHelper { } def getExtraSpringOptions(profilesName: String): Array[String] = { - s"--spring.profiles.active=$profilesName" +: CommonVars.properties.asScala.filter { case (k, v) => k != null && k.startsWith(SPRING_STAR)} + val servletPath=ServerConfiguration.BDP_SERVER_RESTFUL_URI.getValue + s"--spring.profiles.active=$profilesName"+:s"--spring.mvc.servlet.path=$servletPath" +: CommonVars.properties.asScala.filter { case (k, v) => k != null && k.startsWith(SPRING_STAR)} .map { case (k, v) => val realKey = k.substring(SPRING_STAR.length) s"--$realKey=$v" diff --git a/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/java/com/webank/wedatasphere/linkis/cli/application/LinkisClientApplicationTest.java b/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/java/com/webank/wedatasphere/linkis/cli/application/LinkisClientApplicationTest.java index 2dc004e9b1..5a65e3fe05 100644 --- a/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/java/com/webank/wedatasphere/linkis/cli/application/LinkisClientApplicationTest.java +++ b/linkis-computation-governance/linkis-client/linkis-cli/linkis-cli-application/src/test/java/com/webank/wedatasphere/linkis/cli/application/LinkisClientApplicationTest.java @@ -46,7 +46,7 @@ public void before() throws Exception { }; cmdStr = new String[]{ - "--gatewayUrl", "http://172.21.8.149:9001", + "--gatewayUrl", "http://127.0.0.1:9001", "--authStg", "token", "--authKey", "Validation-Code", "--authVal", "BML-AUTH", diff --git a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/callback-service/src/main/scala/com/webank/wedatasphere/linkis/engineconn/callback/hook/CallbackEngineConnHook.scala b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/callback-service/src/main/scala/com/webank/wedatasphere/linkis/engineconn/callback/hook/CallbackEngineConnHook.scala index 7c6a57f04a..0da5ac249c 100644 --- a/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/callback-service/src/main/scala/com/webank/wedatasphere/linkis/engineconn/callback/hook/CallbackEngineConnHook.scala +++ b/linkis-computation-governance/linkis-engineconn/linkis-engineconn-executor/callback-service/src/main/scala/com/webank/wedatasphere/linkis/engineconn/callback/hook/CallbackEngineConnHook.scala @@ -50,7 +50,7 @@ class CallbackEngineConnHook extends EngineConnHook with Logging { // 加载spring类 val map = new mutable.HashMap[String, String]() val newMap = map.++(parser.getSpringConfMap) - newMap.put("spring.mvc.servlet.path", "/api/rest_j/v1") + newMap.put("spring.mvc.servlet.path", ServerConfiguration.BDP_SERVER_RESTFUL_URI.getValue) DataWorkCloudApplication.main(DWCArgumentsParser.formatSpringOptions(newMap.toMap)) val engineConnPidCallBack = new EngineConnPidCallback(engineCreationContext.getEMInstance) diff --git a/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java b/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java index 5e2794fb2c..012910d657 100644 --- a/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java +++ b/linkis-computation-governance/linkis-entrance/src/main/java/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulApi.java @@ -49,7 +49,7 @@ */ @RestController @RequestMapping(path = "/entrance") -public class EntranceRestfulApi{ +public class EntranceRestfulApi implements EntranceRestfulRemote { private EntranceServer entranceServer; @@ -367,9 +367,10 @@ public Message killJobs(HttpServletRequest req,@RequestBody JsonNode jsonNode, @ return Message.ok("停止任务成功").data("messages", messages); } - + + //todo confirm long or Long @RequestMapping(path = "/{id}/kill",method = RequestMethod.GET) - public Message kill(@PathVariable("id") String id, @RequestParam(value = "taskID",required = false) Long taskID) { + public Message kill(@PathVariable("id") String id, @RequestParam(value = "taskID",required = false) long taskID) { String realId = ZuulEntranceUtils.parseExecID(id)[3]; //通过jobid获取job,可能会由于job找不到而导致有looparray的报错,一旦报错的话,就可以将该任务直接置为Cancenlled Option job = Option.apply(null); diff --git a/linkis-computation-governance/linkis-entrance/src/main/scala/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulRemote.scala b/linkis-computation-governance/linkis-entrance/src/main/scala/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulRemote.scala index 74c73b1ebb..7b94ef438b 100644 --- a/linkis-computation-governance/linkis-entrance/src/main/scala/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulRemote.scala +++ b/linkis-computation-governance/linkis-entrance/src/main/scala/com/webank/wedatasphere/linkis/entrance/restful/EntranceRestfulRemote.scala @@ -1,64 +1,62 @@ -///* -// * Copyright 2019 WeBank -// * -// * Licensed under the Apache License, Version 2.0 (the "License"); -// * you may not use this file except in compliance with the License. -// * You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ -// -//package com.webank.wedatasphere.linkis.entrance.restful -// -//import java.util -// -//import com.fasterxml.jackson.databind.JsonNode -//import javax.servlet.http.HttpServletRequest -//import javax.ws.rs.QueryParam -//import javax.ws.rs.core.{Context, Response} -//import org.springframework.web.bind.annotation.{PathVariable, RequestBody, RequestMapping, RequestMethod} -// -// -//trait EntranceRestfulRemote { -// -// @RequestMapping(value = Array("/entrance/execute"), method = Array(RequestMethod.POST)) -// def execute(@Context req: HttpServletRequest, @RequestBody json: util.Map[String, Any]): Response -// -// @RequestMapping(value = Array("/entrance/submit"), method = Array(RequestMethod.POST)) -// def submit(@Context req: HttpServletRequest, @RequestBody json: util.Map[String, Any]): Response -// -// // @RequestMapping(value = Array("/api/entrance/{id}"), method = Array(RequestMethod.GET)) -//// def get(@PathVariable("id") id: String): Response -// -// @RequestMapping(value = Array("/entrance/{id}/status"), method = Array(RequestMethod.GET)) -// def status(@PathVariable("id") id: String, @QueryParam("taskID") taskID:String): Response -// -// -// @RequestMapping(value = Array("/entrance/{id}/progress"), method = Array(RequestMethod.POST)) -// def progress(@PathVariable("id") id: String): Response -// -// //TODO The resultSet interface is provided here, you need to think about it again, temporarily remove it.(resultSet这个接口是否在这里提供,还需再思考一下,先暂时去掉) -//// @RequestMapping(value = Array("/api/entrance/{id}/resultSet"), method = Array(RequestMethod.POST)) -//// def resultSet(@PathVariable("id") id: String): Response -// -// @RequestMapping(value = Array("/entrance/{id}/log"), method = Array(RequestMethod.POST)) -// def log(@Context req: HttpServletRequest, @PathVariable("id") id: String): Response -// -// @RequestMapping(value = Array("/entrance/{id}/killJobs"), method = Array(RequestMethod.POST)) -// def killJobs(@Context req: HttpServletRequest, @RequestBody jsonNode: JsonNode, @PathVariable("id") id: String): Response -// -// @RequestMapping(value = Array("/entrance/{id}/kill"), method = Array(RequestMethod.POST)) -// def kill(@PathVariable("id") id: String, @QueryParam("taskID") taskID:Long): Response -// -// @RequestMapping(value = Array("/entrance/{id}/pause"), method = Array(RequestMethod.POST)) -// def pause(@PathVariable("id") id: String): Response -// -// -// -//} \ No newline at end of file +/* + * Copyright 2019 WeBank + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.webank.wedatasphere.linkis.entrance.restful + +import java.util + +import com.fasterxml.jackson.databind.JsonNode +import com.webank.wedatasphere.linkis.server.Message +import javax.servlet.http.HttpServletRequest +import org.springframework.web.bind.annotation.{PathVariable, RequestBody, RequestMapping, RequestMethod, RequestParam} + + +trait EntranceRestfulRemote { + + @RequestMapping(value = Array("/entrance/execute"), method = Array(RequestMethod.POST)) + def execute(req: HttpServletRequest, @RequestBody json: util.Map[String, Any]): Message + + @RequestMapping(value = Array("/entrance/submit"), method = Array(RequestMethod.POST)) + def submit(req: HttpServletRequest, @RequestBody json: util.Map[String, Any]): Message + + // @RequestMapping(value = Array("/api/entrance/{id}"), method = Array(RequestMethod.GET)) +// def get(@PathVariable("id") id: String): Response + + @RequestMapping(value = Array("/entrance/{id}/status"), method = Array(RequestMethod.GET)) + def status(@PathVariable("id") id: String, @RequestParam(value="taskID",required = false) taskID:String): Message + + @RequestMapping(value = Array("/entrance/{id}/progress"), method = Array(RequestMethod.POST)) + def progress(@PathVariable("id") id: String): Message + + //TODO The resultSet interface is provided here, you need to think about it again, temporarily remove it.(resultSet这个接口是否在这里提供,还需再思考一下,先暂时去掉) +// @RequestMapping(value = Array("/api/entrance/{id}/resultSet"), method = Array(RequestMethod.POST)) +// def resultSet(@PathVariable("id") id: String): Message + + @RequestMapping(value = Array("/entrance/{id}/log"), method = Array(RequestMethod.POST)) + def log(req: HttpServletRequest, @PathVariable("id") id: String): Message + + @RequestMapping(value = Array("/entrance/{id}/killJobs"), method = Array(RequestMethod.POST)) + def killJobs(req: HttpServletRequest, @RequestBody jsonNode: JsonNode, @PathVariable("id") id: String): Message + + @RequestMapping(value = Array("/entrance/{id}/kill"), method = Array(RequestMethod.POST)) + def kill(@PathVariable("id") id: String, @RequestParam("taskID") taskID:scala.Long): Message + + @RequestMapping(value = Array("/entrance/{id}/pause"), method = Array(RequestMethod.POST)) + def pause(@PathVariable("id") id: String): Message + + + +} \ No newline at end of file diff --git a/linkis-computation-governance/linkis-manager/linkis-application-manager/pom.xml b/linkis-computation-governance/linkis-manager/linkis-application-manager/pom.xml index 8cc986daf8..0d20ff18d0 100644 --- a/linkis-computation-governance/linkis-manager/linkis-application-manager/pom.xml +++ b/linkis-computation-governance/linkis-manager/linkis-application-manager/pom.xml @@ -122,13 +122,6 @@ ${linkis.version} compile - - - - - - - diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-listener/pom.xml b/linkis-public-enhancements/linkis-context-service/linkis-cs-listener/pom.xml index 14045b8f0f..ce06fc8473 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-listener/pom.xml +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-listener/pom.xml @@ -7,7 +7,7 @@ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.n ~ See the License for the specific language governing permissions and ~ limitations under the License. --> @@ -35,7 +35,7 @@ com.webank.wedatasphere.linkis linkis-cs-common - 1.0.3 + ${linkis.version} junit diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/FsRestfulApi.java b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/FsRestfulApi.java index 97dcb3f6fa..94eb0b5162 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/FsRestfulApi.java +++ b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/com/webank/wedatasphere/linkis/filesystem/restful/api/FsRestfulApi.java @@ -26,7 +26,7 @@ import com.webank.wedatasphere.linkis.filesystem.exception.WorkspaceExceptionManager; import com.webank.wedatasphere.linkis.filesystem.service.FsService; import com.webank.wedatasphere.linkis.filesystem.util.WorkspaceUtil; -import com.webank.wedatasphere.linkis.filesystem.validator.SpringPathValidator$; +import com.webank.wedatasphere.linkis.filesystem.validator.PathValidator$; import com.webank.wedatasphere.linkis.server.Message; import com.webank.wedatasphere.linkis.server.security.SecurityFilter; import com.webank.wedatasphere.linkis.storage.csv.CSVFsWriter; @@ -178,8 +178,8 @@ public Message rename(HttpServletRequest req,@RequestBody JsonNode json) throws String userName = SecurityFilter.getLoginUsername(req); if (FILESYSTEM_PATH_CHECK_TRIGGER.getValue()) { LOGGER.info(String.format("path check trigger is open,now check the path,oldDest:%s,newDest:%s", oldDest, newDest)); - SpringPathValidator$.MODULE$.validate(oldDest, userName); - SpringPathValidator$.MODULE$.validate(newDest, userName); + PathValidator$.MODULE$.validate(oldDest, userName); + PathValidator$.MODULE$.validate(newDest, userName); } if (!checkIsUsersDirectory(newDest,userName)) { throw WorkspaceExceptionManager.createException(80010, newDest); diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/PathValidator.scala b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/PathValidator.scala index fc65bda170..be3769b1cd 100644 --- a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/PathValidator.scala +++ b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/PathValidator.scala @@ -1,126 +1,137 @@ -///* -// * Copyright 2019 WeBank -// * Licensed under the Apache License, Version 2.0 (the "License"); -// * you may not use this file except in compliance with the License. -// * You may obtain a copy of the License at -// * http://www.apache.org/licenses/LICENSE-2.0 -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ -// -//package com.webank.wedatasphere.linkis.filesystem.validator -// -//import java.io.File -// -//import com.webank.wedatasphere.linkis.common.utils.Logging -//import com.webank.wedatasphere.linkis.filesystem.conf.WorkSpaceConfiguration._ -//import com.webank.wedatasphere.linkis.filesystem.exception.WorkSpaceException -//import com.webank.wedatasphere.linkis.filesystem.util.WorkspaceUtil -//import com.webank.wedatasphere.linkis.server -//import com.webank.wedatasphere.linkis.server.Message -//import com.webank.wedatasphere.linkis.server.security.SecurityFilter -//import com.webank.wedatasphere.linkis.storage.utils.StorageUtils -//import javax.servlet.http.HttpServletRequest -//import javax.ws.rs.core.Response -//import org.aspectj.lang.ProceedingJoinPoint -//import org.aspectj.lang.annotation.{Around, Aspect, Pointcut} -//import org.aspectj.lang.reflect.MethodSignature -//import org.codehaus.jackson.JsonNode -//import org.springframework.stereotype.Component -//import org.springframework.util.StringUtils -// -//@Aspect -//@Component -//class PathValidator extends Logging { -// -// @Pointcut("@annotation(javax.ws.rs.Path) && within(com.webank.wedatasphere.linkis.filesystem.restful.api.*)") -// def restfulResponseCatch(): Unit = {} -// -// def getPath(args: Array[Object], paramNames: Array[String]): String = { -// var path: String = null -// var index: Int = paramNames.indexOf("path") -// if (index != -1) { -// path = args(index).asInstanceOf[String] -// } else { -// index = paramNames.indexOf("json") -// if (index != -1) { -// args(index) match { -// case j: JsonNode if j.get("path") != null => path = j.get("path").getTextValue -// case m: java.util.Map[String, Object] if m.get("path") != null => path = m.get("path").asInstanceOf[String] -// case _ => -// } -// } -// } -// path -// } -// -// def getUserName(args: Array[Object], paramNames: Array[String]): String = { -// var username: String = null -// paramNames.indexOf("req") match { -// case -1 => -// case index: Int => { -// val proxyUser = paramNames.indexOf("proxyUser") -// if (proxyUser == -1 || StringUtils.isEmpty(args(proxyUser))) { -// username = SecurityFilter.getLoginUsername(args(index).asInstanceOf[HttpServletRequest]) -// } else { -// //增加proxyuser的判断 -// username = args(proxyUser).toString -// } -// } -// } -// username -// } -// -// def checkPath(path: String, username: String) = { -// //校验path的逻辑 -// val userLocalRootPath: String = WorkspaceUtil.suffixTuning(LOCAL_USER_ROOT_PATH.getValue) + -// username -// var userHdfsRootPath: String = WorkspaceUtil.suffixTuning(HDFS_USER_ROOT_PATH_PREFIX.getValue) + -// username + HDFS_USER_ROOT_PATH_SUFFIX.getValue -// if (!(path.contains(StorageUtils.FILE_SCHEMA)) && !(path.contains(StorageUtils.HDFS_SCHEMA))) { -// throw new WorkSpaceException(80025, "the path should contain schema") -// } -// userHdfsRootPath = StringUtils.trimTrailingCharacter(userHdfsRootPath, File.separatorChar) -// if (path.contains("../")) { -// throw new WorkSpaceException(80026, "Relative path not allowed") -// } -// if (!(path.contains(userLocalRootPath)) && !(path.contains(userHdfsRootPath))) { -// throw new WorkSpaceException(80027, "The path needs to be within the user's own workspace path") -// } -// } -// -// def validate(args: Array[Object], paramNames: Array[String]) = { -// //获取path:String,json:JsonNode,json:Map中的path 参数 -// val path: String = getPath(args, paramNames) -// val username: String = getUserName(args, paramNames) -// if (!StringUtils.isEmpty(path) && !StringUtils.isEmpty(username)) { -// logger.info(String.format("user:%s,path:%s", username, path)) -// checkPath(path, username) -// } -// } -// -// @Around("restfulResponseCatch()") -// def dealResponseRestful(proceedingJoinPoint: ProceedingJoinPoint): Object = { -// val response: Response = server.catchIt { -// val signature = proceedingJoinPoint.getSignature.asInstanceOf[MethodSignature] -// logger.info("enter the path validator,the method is {}", signature.getName) -// if (FILESYSTEM_PATH_CHECK_TRIGGER.getValue) { -// logger.info("path check trigger is open,now check the path") -// validate(proceedingJoinPoint.getArgs, signature.getParameterNames) -// } -// Message.ok() -// } -// if (response.getStatus != 200) response else proceedingJoinPoint.proceed() -// } -//} -// -//object PathValidator { -// val validator = new PathValidator() -// -// def validate(path: String, username: String): Unit = { -// validator.checkPath(path, username) -// } -//} +/* + * Copyright 2019 WeBank + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.webank.wedatasphere.linkis.filesystem.validator + +import java.io.File + +import com.fasterxml.jackson.databind.JsonNode +import com.webank.wedatasphere.linkis.common.utils.Logging +import com.webank.wedatasphere.linkis.filesystem.conf.WorkSpaceConfiguration._ +import com.webank.wedatasphere.linkis.filesystem.exception.WorkSpaceException +import com.webank.wedatasphere.linkis.filesystem.util.WorkspaceUtil +import com.webank.wedatasphere.linkis.server +import com.webank.wedatasphere.linkis.server.{Message, catchIt} +import com.webank.wedatasphere.linkis.server.security.SecurityFilter +import com.webank.wedatasphere.linkis.storage.utils.StorageUtils +import javax.servlet.http.{HttpServletRequest, HttpServletResponse} +import org.aspectj.lang.ProceedingJoinPoint +import org.aspectj.lang.annotation.{Around, Aspect, Pointcut} +import org.aspectj.lang.reflect.MethodSignature +import org.springframework.stereotype.Component +import org.springframework.util.StringUtils +import org.springframework.web.context.request.{RequestContextHolder, ServletRequestAttributes} + +@Aspect +@Component +class PathValidator extends Logging { + + @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping) && within(com.webank.wedatasphere.linkis.filesystem.restful.api.*)") + def restfulResponseCatch1(): Unit = {} + + def getPath(args: Array[Object], paramNames: Array[String]): String = { + var path: String = null + var index: Int = paramNames.indexOf("path") + if (index != -1) { + path = args(index).asInstanceOf[String] + } else { + index = paramNames.indexOf("json") + if (index != -1) { + args(index) match { + case j: JsonNode if j.get("path") != null => path = j.get("path").textValue() + case m: java.util.Map[String, Object] if m.get("path") != null => path = m.get("path").asInstanceOf[String] + case _ => + } + } + } + path + } + + def getUserName(args: Array[Object], paramNames: Array[String]): String = { + var username: String = null + paramNames.indexOf("req") match { + case -1 => + case index: Int => { + val proxyUser = paramNames.indexOf("proxyUser") + if (proxyUser == -1 || StringUtils.isEmpty(args(proxyUser))) { + username = SecurityFilter.getLoginUsername(args(index).asInstanceOf[HttpServletRequest]) + } else { + //增加proxyuser的判断 + username = args(proxyUser).toString + } + } + } + username + } + + def checkPath(path: String, username: String) = { + //校验path的逻辑 + val userLocalRootPath: String = WorkspaceUtil.suffixTuning(LOCAL_USER_ROOT_PATH.getValue) + + username + var userHdfsRootPath: String = WorkspaceUtil.suffixTuning(HDFS_USER_ROOT_PATH_PREFIX.getValue) + + username + HDFS_USER_ROOT_PATH_SUFFIX.getValue + if (!(path.contains(StorageUtils.FILE_SCHEMA)) && !(path.contains(StorageUtils.HDFS_SCHEMA))) { + throw new WorkSpaceException(80025, "the path should contain schema") + } + userHdfsRootPath = StringUtils.trimTrailingCharacter(userHdfsRootPath, File.separatorChar) + if (path.contains("../")) { + throw new WorkSpaceException(80026, "Relative path not allowed") + } + if (!(path.contains(userLocalRootPath)) && !(path.contains(userHdfsRootPath))) { + throw new WorkSpaceException(80027, "The path needs to be within the user's own workspace path") + } + } + + def validate(args: Array[Object], paramNames: Array[String]) = { + //获取path:String,json:JsonNode,json:Map中的path 参数 + val path: String = getPath(args, paramNames) + val username: String = getUserName(args, paramNames) + if (!StringUtils.isEmpty(path) && !StringUtils.isEmpty(username)) { + logger.info(String.format("user:%s,path:%s", username, path)) + checkPath(path, username) + } + } + + @Around("restfulResponseCatch1()") + def dealResponseRestful(proceedingJoinPoint: ProceedingJoinPoint): Object = { + val resp: Message = server.catchIt { + val signature = proceedingJoinPoint.getSignature.asInstanceOf[MethodSignature] + logger.info("enter the path validator,the method is {}", signature.getName) + if (FILESYSTEM_PATH_CHECK_TRIGGER.getValue) { + logger.info("path check trigger is open,now check the path") + validate(proceedingJoinPoint.getArgs, signature.getParameterNames) + } + Message.ok() + } + if (Message.messageToHttpStatus(resp)!= 200) resp else proceedingJoinPoint.proceed() + } + + def getCurrentHttpResponse: HttpServletResponse = { + val requestAttributes = RequestContextHolder.getRequestAttributes + if (requestAttributes.isInstanceOf[ServletRequestAttributes]) { + val response = requestAttributes.asInstanceOf[ServletRequestAttributes].getResponse + return response + } + null + } +} + +object PathValidator { + val validator = new PathValidator() + + def validate(path: String, username: String): Unit = { + validator.checkPath(path, username) + } +} + + diff --git a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/SpringPathValidator.scala b/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/SpringPathValidator.scala deleted file mode 100644 index 3ad170d241..0000000000 --- a/linkis-public-enhancements/linkis-publicservice/linkis-script-dev/linkis-storage-script-dev-server/src/main/scala/com/webank/wedatasphere/linkis/filesystem/validator/SpringPathValidator.scala +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright 2019 WeBank - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.webank.wedatasphere.linkis.filesystem.validator - -import java.io.File - -import com.fasterxml.jackson.databind.JsonNode -import com.webank.wedatasphere.linkis.common.utils.Logging -import com.webank.wedatasphere.linkis.filesystem.conf.WorkSpaceConfiguration._ -import com.webank.wedatasphere.linkis.filesystem.exception.WorkSpaceException -import com.webank.wedatasphere.linkis.filesystem.util.WorkspaceUtil -import com.webank.wedatasphere.linkis.server -import com.webank.wedatasphere.linkis.server.{Message, catchIt} -import com.webank.wedatasphere.linkis.server.security.SecurityFilter -import com.webank.wedatasphere.linkis.storage.utils.StorageUtils -import javax.servlet.http.{HttpServletRequest, HttpServletResponse} -import org.aspectj.lang.ProceedingJoinPoint -import org.aspectj.lang.annotation.{Around, Aspect, Pointcut} -import org.aspectj.lang.reflect.MethodSignature -import org.springframework.stereotype.Component -import org.springframework.util.StringUtils -import org.springframework.web.context.request.{RequestContextHolder, ServletRequestAttributes} - -@Aspect -@Component -class SpringPathValidator extends Logging { - - @Pointcut("@annotation(org.springframework.web.bind.annotation.RequestMapping) && within(com.webank.wedatasphere.linkis.filesystem.restful.api.*)") - def restfulResponseCatch1(): Unit = {} - - def getPath(args: Array[Object], paramNames: Array[String]): String = { - var path: String = null - var index: Int = paramNames.indexOf("path") - if (index != -1) { - path = args(index).asInstanceOf[String] - } else { - index = paramNames.indexOf("json") - if (index != -1) { - args(index) match { - case j: JsonNode if j.get("path") != null => path = j.get("path").textValue() - case m: java.util.Map[String, Object] if m.get("path") != null => path = m.get("path").asInstanceOf[String] - case _ => - } - } - } - path - } - - def getUserName(args: Array[Object], paramNames: Array[String]): String = { - var username: String = null - paramNames.indexOf("req") match { - case -1 => - case index: Int => { - val proxyUser = paramNames.indexOf("proxyUser") - if (proxyUser == -1 || StringUtils.isEmpty(args(proxyUser))) { - username = SecurityFilter.getLoginUsername(args(index).asInstanceOf[HttpServletRequest]) - } else { - //增加proxyuser的判断 - username = args(proxyUser).toString - } - } - } - username - } - - def checkPath(path: String, username: String) = { - //校验path的逻辑 - val userLocalRootPath: String = WorkspaceUtil.suffixTuning(LOCAL_USER_ROOT_PATH.getValue) + - username - var userHdfsRootPath: String = WorkspaceUtil.suffixTuning(HDFS_USER_ROOT_PATH_PREFIX.getValue) + - username + HDFS_USER_ROOT_PATH_SUFFIX.getValue - if (!(path.contains(StorageUtils.FILE_SCHEMA)) && !(path.contains(StorageUtils.HDFS_SCHEMA))) { - throw new WorkSpaceException(80025, "the path should contain schema") - } - userHdfsRootPath = StringUtils.trimTrailingCharacter(userHdfsRootPath, File.separatorChar) - if (path.contains("../")) { - throw new WorkSpaceException(80026, "Relative path not allowed") - } - if (!(path.contains(userLocalRootPath)) && !(path.contains(userHdfsRootPath))) { - throw new WorkSpaceException(80027, "The path needs to be within the user's own workspace path") - } - } - - def validate(args: Array[Object], paramNames: Array[String]) = { - //获取path:String,json:JsonNode,json:Map中的path 参数 - val path: String = getPath(args, paramNames) - val username: String = getUserName(args, paramNames) - if (!StringUtils.isEmpty(path) && !StringUtils.isEmpty(username)) { - logger.info(String.format("user:%s,path:%s", username, path)) - checkPath(path, username) - } - } - - @Around("restfulResponseCatch1()") - def dealResponseRestful(proceedingJoinPoint: ProceedingJoinPoint): Object = { - val resp: Message = server.catchIt { - val signature = proceedingJoinPoint.getSignature.asInstanceOf[MethodSignature] - logger.info("enter the path validator,the method is {}", signature.getName) - if (FILESYSTEM_PATH_CHECK_TRIGGER.getValue) { - logger.info("path check trigger is open,now check the path") - validate(proceedingJoinPoint.getArgs, signature.getParameterNames) - } - Message.ok() - } - if (Message.messageToHttpStatus(resp)!= 200) resp else proceedingJoinPoint.proceed() - } - - def getCurrentHttpResponse: HttpServletResponse = { - val requestAttributes = RequestContextHolder.getRequestAttributes - if (requestAttributes.isInstanceOf[ServletRequestAttributes]) { - val response = requestAttributes.asInstanceOf[ServletRequestAttributes].getResponse - return response - } - null - } -} - -object SpringPathValidator { - val validator = new SpringPathValidator() - - def validate(path: String, username: String): Unit = { - validator.checkPath(path, username) - } -} - - From b4271de723757c1daf9f95e8265f84c2d1d11a9c Mon Sep 17 00:00:00 2001 From: casionone Date: Wed, 13 Oct 2021 16:41:11 +0800 Subject: [PATCH 28/29] add LICENSE & CONTRIBUTING --- CONTRIBUTING.md | 180 +++++++++++++++++++++++ Contributing_CN.md => CONTRIBUTING_CN.md | 0 DISCLAIMER-WIP | 18 +-- LICENSE | 100 +++++++++++++ NOTICE | 30 +++- 5 files changed, 317 insertions(+), 11 deletions(-) create mode 100644 CONTRIBUTING.md rename Contributing_CN.md => CONTRIBUTING_CN.md (100%) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..14ebe18166 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,180 @@ +# Contributing + +| **Version Management Information Form** | | +| ----------- | --------------------------------- | +| Current version | Version 1.1, May 2021 | +| Current version release date | May 6, 2021 | +| Revision Information | 1. Add Issue submission guidelines and modify some descriptions | + +Thank you very much for contributing to the Linkis project! Before participating in the contribution, please read the following guidelines carefully. + +## 1. Contribution category + +### 1.1 Bug feedback and repair + +We recommend that whether it is a bug feedback or a fix, an issue is first created to describe the bug's status in detail, so that the community can find and review the problem and code through the issue record. Bug feedback Issues usually need to include **complete description of the bug information** and **reproducible scenarios** so that the community can quickly locate the cause of the bug and fix it. All open issues that contain the `#bug` tag need to be fixed. + +### 1.2 Functional communication, implementation, refactoring + +In the communication process, a detailed description of the details, mechanisms and usage scenarios of the new function (or refactoring) can promote it to be implemented better and faster (including test cases and codes, and CI/CD related work). **If you plan to implement a major feature (or refactoring), be sure to communicate with the core development team through Issue or other means** so that everyone can promote it in the most efficient way. Issues opened with the label of `#feature` are all new features that need to be implemented, and issues opened with the label of `#enhancement` are all features that need to be improved and refactored. + +### 1.3 Issue Q&A + +Helping to answer the usage questions in the Issue is a very valuable way to contribute to the Linkis community; there will always be new users in the community that will keep coming in. While helping new users, you can also show your expertise. + +### 1.4 Documentation improvements + +The Linkis document is located at [Linkis-Doc](https://github.com/WeBankFinTech/Linkis-Doc), and the supplement of the document is also crucial to the development of Linkis. + +### 1.5 Other +Including participating in and helping to organize community exchanges, community operation activities, etc., and other activities that can help the Linkis project and the community. + +--- + +## 2. Contribution process + +### 2.1 Branch structure + +The Linkis source code may produce some temporary branches, but the only ones that are really meaningful are the following three branches: + +- master: The source code of the last stable release, and occasionally hotfix submissions; +- release-*: stable release version;* +- *dev-*: main development branch; +- feature-*: Development branches for some larger new features that need to be jointly developed by the community + +Please note: The dev branch of major features will be named with corresponding naming instructions in addition to the version number, such as: dev-0.10.0-flink, which refers to the flink feature development branch of 0.10.0. + +### 2.2 Development Guidelines + +Linkis front-end and back-end code share the same code base, but they are separated in development. Before starting the development, please fork the Linkis project to your Github Repositories. When developing, please develop based on the Linkis code base in your Github Repositories. + +We recommend cloning the dev-* branch for development, so that the possibility of merge conflicts when submitting a PR to the main Linkis project will be much smaller + +```bash +git clone https://github.com/yourname/Linkis.git --branch dev-* +``` + +#### 2.2.1 Backend + +The user configuration is in the project root directory /config/, the project startup script and the upgrade patch script are in the project root directory /bin/, the back-end code and core configuration are in the server/ directory, and the log is in the project root directory /log/. Note: The project root directory referred to here refers to the directory configured by the environment variable LINKIS_HOME, and environment variables need to be configured during IDE development. For example, Idea's priority regarding environment variable loading: Configured in `Run/Debug Configurations` `Environment variables` —> System environment variables cached by IDE. + +##### 2.2.1.1 Directory structure + +1. Script + +``` +├── bin # script directory + ├── install.sh # One-click deployment script + ├── start-all.sh # One-click start script + └── stop-all.sh # One-click stop script +``` + +2. Configuration + +``` +├── config # User configuration directory + ├── config.sh # One-click deployment configuration file + ├── db.sh # One-click deployment database configuration +``` + +3. Code directory structure + + For details, see [Linkis Code Directory Structure](https://github.com/WeBankFinTech/Linkis/wiki/Linkis%E6%BA%90%E7%A0%81%E5%B1%82%E7%BA%A7%E7 %BB%93%E6%9E%84%E8%AF%A6%E8%A7%A3) + +4. Log directory + +``` +├── logs # log root directory +``` + +##### 2.2.1.2 Environment Variables + + Configure system environment variable or IDE environment variable LINKIS_HOME, it is recommended to use IDE environment variable first. + +##### 2.2.1.3 Database + +1. Create the Linkis system database by yourself; +2. Modify the corresponding information of the database in conf/db.sh and execute bin/install.sh or directly import db/linkis_*.sql on the database client. + +##### 2.2.1.4 Configuration file + + Modify the `application.yml` file in the resources/ directory of each microservice to configure related properties. + +##### 2.2.1.5 Packaging + +1. To open a complete release package, you need to modify the relevant version information in /assembly/src/main/assembly/assembly.xml in the root directory, and then execute: `mvn clean package` in the root directory; +2. Open the package of each module and execute `mvn clean package` directly in the module directory. + +### 2.3 Issue submission guidelines +- If you still don’t know how to initiate a PR to an open source project, please refer to [About issues](https://docs.github.com/en/github/managing-your-work-on-github/about-issues) +- Issue name, which should briefly describe your problem or suggestion in one sentence; for the international promotion of the project, please write the issue in English or both Chinese and English. +- For each Issue, please bring at least two labels, component and type, such as component=Computation Governance/EngineConn, type=Improvement. Reference: [issue #590](https://github.com/WeBankFinTech/Linkis/issues/ 590) + +### 2.3 Pull Request(PR) Submission Guidelines + +- If you still don’t know how to initiate a PR to an open source project, please refer to [About pull requests](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull -requests) + Whether it is a bug fix or a new feature development, please submit a PR to the dev-* branch. +- PR and submission name follow the principle of `(): `, for details, please refer to Ruan Yifeng's [Commit message and Change log writing guide](http://www.ruanyifeng.com/blog/ 2016/01/commit_message_change_log.html) this article. +- If the PR contains new features, the document update should be included in this PR. +- If this PR is not ready to merge, please add [WIP] prefix to the head of the name (WIP = work-in-progress). +- All submissions to dev-* branches need to go through at least one review before they can be merged + +### 2.4 Review Standard + +Before contributing code, you can find out what kind of submissions are popular in Review. Simply put, if a submission can bring as many gains as possible and as few side effects or risks as possible, the higher the probability of it being merged, the faster the review will be. Submissions with high risk and low value are almost impossible to merge, and may be rejected Review. + +#### 2.4.1 Gain + +- Fix the main cause of the bug +- Add or fix a function or problem that a large number of users urgently need +- Simple and effective +- Easy to test, with test cases +- Reduce complexity and amount of code +- Issues that have been discussed by the community and identified for improvement + +#### 2.4.2 Side effects and risks + +- Only fix the surface phenomenon of the bug +- Introduce new features with high complexity +- Add complexity to meet niche needs +- Change stable existing API or semantics +- Cause other functions to not operate normally +- Add a lot of dependencies +- Change the dependency version at will +- Submit a large number of codes or changes at once + +#### 2.4.3 Reviewer notes + +- Please use a constructive tone to write comments +- If you need to make changes by the submitter, please clearly state all the content that needs to be modified to complete the Pull Request +- If a PR is found to have brought new problems after the merger, the Reviewer needs to contact the PR author and communicate to solve the problem; if the PR author cannot be contacted, the Reviewer needs to restore the PR + +--- + +## Three, advanced contribution + +### 3.1 About Committers (Collaborators) + +#### 3.1.1 How to become Committer + +If you have submitted a valuable PR to Linkis and have been merged, or contributed continuously for more than half a year, and have led the release of at least one version, you can find a PMC of the Linkis project through the official WeChat group, if he is willing to nominate you as a committer , And are willing to state your contribution to all PMC and Committer, then a vote will be initiated next; PMC and other Committers will vote together to decide whether to allow you to join, if you get enough votes, you will become Committer of the Linkis project . + +#### 3.1.2 Committer rights + +- You can join the official developer WeChat group to participate in discussions and formulate Linkis development plans +- Can manage Issues, including closing and adding tags +- Can create and manage project branches, except for master and dev-* branches +- You can review the PR submitted to the dev-* branch +- Can apply to become a Committee member + +### 3.2 About Committee + +#### 3.2.1 How to become a Committee member + +If you are the Committer of the Linkis project, and all your contributions have been approved by other Committee members, you can apply to become a member of the Linkis Committee, and other Committee members will vote together to decide whether to allow you to join. If you pass unanimously, you will Become a member of the Linkis Committee. + +#### 3.2.2 Rights of Committee members + +- You can merge PRs submitted by other Committers and contributors to the dev-** branch +- Participate in determining the roadmap and development direction of the Linkis project +- Can participate in the new version release \ No newline at end of file diff --git a/Contributing_CN.md b/CONTRIBUTING_CN.md similarity index 100% rename from Contributing_CN.md rename to CONTRIBUTING_CN.md diff --git a/DISCLAIMER-WIP b/DISCLAIMER-WIP index 4fb31110d8..9677b47fed 100644 --- a/DISCLAIMER-WIP +++ b/DISCLAIMER-WIP @@ -1,10 +1,8 @@ Apache Linkis is an effort undergoing incubation at The Apache Software Foundation (ASF), -sponsored by the Apache Incubator PMC. - -Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, -communications, and decision-making process have stabilized in a manner consistent with other successful ASF projects. - -While incubation status is not necessarily a reflection of the completeness or stability of the code, +sponsored by the Apache Incubator PMC.Incubation is required of all newly accepted projects +until a further review indicates that the infrastructure,communications, and decision-making +process have stabilized in a manner consistent with other successful ASF projects.While +incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF. Some of the incubating project’s releases may not be fully compliant with ASF policy. @@ -13,7 +11,7 @@ What follows is a list of issues the project is currently aware of (this list is 1- Releases may have incomplete licensing conditions - -If you are planning to incorporate this work into your product/project, -please be aware that you will need to conduct a thorough licensing review to determine the overall implications of including this work. -For the current status of this project through the Apache Incubator, visit: https://incubator.apache.org/projects/linkis.html \ No newline at end of file +If you are planning to incorporate this work into your product/project,please be aware that +you will need to conduct a thorough licensing review to determine the overall implications of +including this work.For the current status of this project through the Apache Incubator, +visit: https://incubator.apache.org/projects/linkis.html \ No newline at end of file diff --git a/LICENSE b/LICENSE index 261eeb9e9f..779bb4c12b 100644 --- a/LICENSE +++ b/LICENSE @@ -199,3 +199,103 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + + +============================================================================ + APACHE LINKIS SUBCOMPONENTS: + + The Apache Linkis project contains subcomponents with separate copyright + notices and license terms. Your use of the source code for the these + subcomponents is subject to the terms and conditions of the following + licenses. + +======================================================================== +Third party Apache 2.0 licenses +======================================================================== + +The following components are provided under the Apache 2.0 License. + + (Apache License, Version 2.0) Apache Commons Codec (commons-codec:commons-codec:1.10 - http://commons.apache.org/proper/commons-codec/) + (Apache License, Version 2.0) Apache Commons Collections (commons-collections:commons-collections:3.2.2 - http://commons.apache.org/collections/) + (Apache License, Version 2.0) Apache Commons Lang (org.apache.commons:commons-lang3:3.4 - http://commons.apache.org/proper/commons-lang/) + (Apache License, Version 2.0) Apache Commons Text (org.apache.commons:commons-text:1.6 - http://commons.apache.org/proper/commons-text) + (Apache License, Version 2.0) Apache Hadoop Auth (org.apache.hadoop:hadoop-auth:2.7.2 - no url defined) + (Apache License, Version 2.0) Apache Hadoop Client (org.apache.hadoop:hadoop-client:2.7.2 - no url defined) + (Apache License, Version 2.0) Apache Hadoop HDFS (org.apache.hadoop:hadoop-hdfs:2.7.2 - no url defined) + (Apache License, Version 2.0) Apache Thrift (org.apache.thrift:libthrift:0.9.3 - http://thrift.apache.org) + (Apache License, Version 2.0) Bean Validation API (javax.validation:validation-api:2.0.1.Final - http://beanvalidation.org) + (Apache License, Version 2.0) Caffeine cache (com.github.ben-manes.caffeine:caffeine:2.8.4 - https://github.com/ben-manes/caffeine) + (Apache License, Version 2.0) Commons DBCP (commons-dbcp:commons-dbcp:1.4 - http://commons.apache.org/dbcp/) + (Apache License, Version 2.0) Commons IO (commons-io:commons-io:2.4 - http://commons.apache.org/io/) + (Apache License, Version 2.0) Commons Lang (commons-lang:commons-lang:2.6 - http://commons.apache.org/lang/) + (Apache License, Version 2.0) Commons Net (commons-net:commons-net:3.1 - http://commons.apache.org/net/) + (Apache License, Version 2.0) druid (com.alibaba:druid:0.2.9 - https://github.com/AlibabaTech/druid) + (Apache License, Version 2.0) hadoop-yarn-client (org.apache.hadoop:hadoop-yarn-client:2.7.2 - no url defined) + (Apache License, Version 2.0) Hive Common (org.apache.hive:hive-common:2.3.3 - http://hive.apache.org/hive-common) + (Apache License, Version 2.0) Hive JDBC (org.apache.hive:hive-jdbc:1.2.1 - http://hive.apache.org/hive-jdbc) + (Apache License, Version 2.0) Hive Query Language (org.apache.hive:hive-exec:2.3.3 - http://hive.apache.org/hive-exec) + (Apache License, Version 2.0) jackson-module-scala (com.fasterxml.jackson.module:jackson-module-scala_2.11:2.11.3 - http://wiki.fasterxml.com/JacksonModuleScala) + (Apache License, Version 2.0) jsp-ap(jsp-api-2.1 6.1.14 - https://mvnrepository.com/artifact/org.mortbay.jetty/jsp-api-2.1/6.1.14) + (Apache License, Version 2.0) mybatis-plus (com.baomidou:mybatis-plus-boot-starter:3.4.1 - https://github.com/baomidou/mybatis-plus) + (Apache License, Version 2.0) protostuff :: core (io.protostuff:protostuff-core:1.6.2 - https://protostuff.github.io/protostuff-core) + (Apache License, Version 2.0) protostuff :: runtime (io.protostuff:protostuff-runtime:1.6.2 - https://protostuff.github.io/protostuff-runtime) + (Apache License, Version 2.0) Reactive Streams Netty driver (io.projectreactor.netty:reactor-netty:0.9.7.RELEASE - https://github.com/reactor/reactor-netty) + (Apache License, Version 2.0) Spark Project Core (org.apache.spark:spark-core_2.11:2.4.3 - http://spark.apache.org/) + (Apache License, Version 2.0) Spark Project Hive (org.apache.spark:spark-hive_2.11:2.4.3 - http://spark.apache.org/) + (Apache License, Version 2.0) Spark Project REPL (org.apache.spark:spark-repl_2.11:2.4.3 - http://spark.apache.org/) + (Apache License, Version 2.0) Spark Project SQL (org.apache.spark:spark-sql_2.11:2.4.3 - http://spark.apache.org/) + (Apache License, Version 2.0) Spring Boot Actuator AutoConfigure (org.springframework.boot:spring-boot-actuator-autoconfigure:2.2.1.RELEASE - https://projects.spring.io/spring-boot/#/spring-boot-parent/spring-boot-actuator-autoconfigure) + (Apache License, Version 2.0) spring-boot (org.springframework.boot:spring-boot:2.3.2.RELEASE - https://spring.io/projects/spring-boot) + (Apache License, Version 2.0) spring-boot-starter-actuator (org.springframework.boot:spring-boot-starter-actuator:2.3.2.RELEASE - https://spring.io/projects/spring-boot) + (Apache License, Version 2.0) spring-boot-starter-aop (org.springframework.boot:spring-boot-starter-aop:2.3.2.RELEASE - https://spring.io/projects/spring-boot) + (Apache License, Version 2.0) spring-boot-starter-jetty (org.springframework.boot:spring-boot-starter-jetty:2.3.2.RELEASE - https://spring.io/projects/spring-boot) + (Apache License, Version 2.0) spring-boot-starter-reactor-netty (org.springframework.boot:spring-boot-starter-reactor-netty:2.3.2.RELEASE - https://spring.io/projects/spring-boot) + (Apache License, Version 2.0) spring-boot-starter-web (org.springframework.boot:spring-boot-starter-web:2.3.2.RELEASE - https://spring.io/projects/spring-boot) + (Apache License, Version 2.0) Spring Cloud Config Client (org.springframework.cloud:spring-cloud-config-client:2.2.1.RELEASE - https://spring.io) + (Apache License, Version 2.0) Spring Cloud Context (org.springframework.cloud:spring-cloud-context:2.2.1.RELEASE - https://projects.spring.io/spring-cloud/spring-cloud-context/) + (Apache License, Version 2.0) Spring Cloud Gateway Core (org.springframework.cloud:spring-cloud-gateway-core:2.2.1.RELEASE - https://spring.io/spring-cloud/spring-cloud-gateway/spring-cloud-gateway-core) + (Apache License, Version 2.0) spring-cloud-starter-config (org.springframework.cloud:spring-cloud-starter-config:2.2.1.RELEASE - https://projects.spring.io/spring-cloud) + (Apache License, Version 2.0) spring-cloud-starter-gateway (org.springframework.cloud:spring-cloud-starter-gateway:2.2.1.RELEASE - https://projects.spring.io/spring-cloud) + (Apache License, Version 2.0) Spring Cloud Starter Netflix Eureka Client (org.springframework.cloud:spring-cloud-starter-netflix-eureka-client:2.2.1.RELEASE - https://projects.spring.io/spring-cloud) + (Apache License, Version 2.0) Spring Cloud Starter Netflix Eureka Server (org.springframework.cloud:spring-cloud-starter-netflix-eureka-server:2.2.1.RELEASE - https://projects.spring.io/spring-cloud) + (Apache License, Version 2.0) Spring Cloud Starter OpenFeign (org.springframework.cloud:spring-cloud-starter-openfeign:2.2.1.RELEASE - https://projects.spring.io/spring-cloud) + (Apache License, Version 2.0) Spring JDBC (org.springframework:spring-jdbc:5.2.12.RELEASE - https://github.com/spring-projects/spring-framework) + (Apache License, Version 2.0) spring-security-crypto (org.springframework.security:spring-security-crypto:5.3.6.RELEASE - https://spring.io/spring-security) + (Apache License, Version 2.0) Spring TestContext Framework (org.springframework:spring-test:5.2.12.RELEASE - https://github.com/spring-projects/spring-framework) + (Apache License, Version 2.0) Spring Transaction (org.springframework:spring-tx:5.2.12.RELEASE - https://github.com/spring-projects/spring-framework) + (Apache License, Version 2.0) Streaming Excel reader (com.monitorjbl:xlsx-streamer:1.2.1 - https://github.com/monitorjbl/excel-streaming-reader) + (Apache Software License - Version 2.0) (Eclipse Public License - Version 1.0) Jetty :: Server Core (org.eclipse.jetty:jetty-server:9.4.20.v20190813 - http://www.eclipse.org/jetty) + (Apache Software License - Version 2.0) (Eclipse Public License - Version 1.0) Jetty :: Webapp Application Support (org.eclipse.jetty:jetty-webapp:9.4.20.v20190813 - http://www.eclipse.org/jetty) + (Apache Software License - Version 2.0) (Eclipse Public License - Version 1.0) Jetty :: Websocket :: Client (org.eclipse.jetty.websocket:websocket-client:9.4.20.v20190813 - http://www.eclipse.org/jetty/websocket-client) + (Apache Software License - Version 2.0) (Eclipse Public License - Version 1.0) Jetty :: Websocket :: Server (org.eclipse.jetty.websocket:websocket-server:9.4.20.v20190813 - http://www.eclipse.org/jetty/websocket-server) + (Apache Software License - Version 2.0) (Eclipse Public License - Version 1.0) Jetty :: Websocket :: Servlet Interface (org.eclipse.jetty.websocket:websocket-servlet:9.4.20.v20190813 - http://www.eclipse.org/jetty/websocket-servlet) + +======================================================================== +Third party CDDL licenses +======================================================================== + +The following components are provided under the CDDL License. + + (CDDL 1.1) (GPL2 w/ CPE) jersey-json (com.sun.jersey:jersey-json:1.19 - https://jersey.java.net/jersey-json/) + (CDDL 1.1) (GPL2 w/ CPE) jersey-server (com.sun.jersey:jersey-server:1.19.1 - https://jersey.java.net/jersey-server/) + (CDDL 1.1) (GPL2 w/ CPE) jersey-servlet (com.sun.jersey:jersey-servlet:1.19.1 - https://jersey.java.net/jersey-servlet/) + (CDDL+GPL License) jersey-container-servlet-core (org.glassfish.jersey.containers:jersey-container-servlet-core:2.23.1 - https://jersey.java.net/project/jersey-container-servlet-core/) + (CDDL+GPL License) jersey-container-servlet (org.glassfish.jersey.containers:jersey-container-servlet:2.23.1 - https://jersey.java.net/project/jersey-container-servlet/) + +======================================================================== +Third party BSD licenses +======================================================================== + +The following components are provided under the BSD License. + + (The 3-Clause BSD License) Py4J (net.sf.py4j:py4j:0.10.4 - http://nexus.sonatype.org/oss-repository-hosting.html/py4j) + +======================================================================== +Third party MIT licenses +======================================================================== + +The following components are provided under the MIT License. + (The MIT License (MIT)) pagehelper 5 (com.github.pagehelper:pagehelper:5.1.4 - https://github.com/pagehelper/Mybatis-PageHelper) + (The MIT License) Mockito (org.mockito:mockito-all:2.0.2-beta - http://www.mockito.org) + (The MIT License) SLF4J API Module (org.slf4j:slf4j-api:1.7.30 - http://www.slf4j.org) diff --git a/NOTICE b/NOTICE index d3bedd032b..162e003e14 100644 --- a/NOTICE +++ b/NOTICE @@ -2,4 +2,32 @@ Apache Linkis (incubating) Copyright 2021 The Apache Software Foundation This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file +The Apache Software Foundation (http://www.apache.org/). + +The initial codebase was donated to the ASF by WeBank, copyright 2015-2020. + +======================================================================== + +Jetty NOTICE + +======================================================================== +============================================================== + Jetty Web Container + Copyright 1995-2018 Mort Bay Consulting Pty Ltd. +============================================================== + +The Jetty Web Container is Copyright Mort Bay Consulting Pty Ltd +unless otherwise noted. + +Jetty is dual licensed under both + + * The Apache 2.0 License + http://www.apache.org/licenses/LICENSE-2.0.html + + and + + * The Eclipse Public 1.0 License + http://www.eclipse.org/legal/epl-v10.html + +Jetty may be distributed under either license. + From 336cb7f1e5793b9275610f899e7782a06c6f4ef4 Mon Sep 17 00:00:00 2001 From: casionone Date: Wed, 13 Oct 2021 18:53:18 +0800 Subject: [PATCH 29/29] remove unused configuration properties&java file --- .../server/restful/RestfulCatchAOP.scala | 50 ------------------- .../rpc/conf/RPCReceiveRestfulCondition.scala | 4 -- .../computation/client/FlinkOnceJobTest.java | 5 -- .../resources/linkis-engineconn.properties | 7 +-- .../resources/linkis-engineconn.properties | 6 +-- .../resources/linkis-engineconn.properties | 4 -- .../resources/linkis-engineconn.properties | 5 -- .../resources/linkis-engineconn.properties | 5 -- .../resources/linkis-engineconn.properties | 5 -- .../resources/linkis-engineconn.properties | 4 -- .../resources/linkis-engineconn.properties | 6 +-- .../linkis-cs-listener/pom.xml | 2 +- .../cs/server/restful/HelloRestfulApi.java | 36 ------------- 13 files changed, 4 insertions(+), 135 deletions(-) delete mode 100644 linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/restful/RestfulCatchAOP.scala delete mode 100644 linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/HelloRestfulApi.java diff --git a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/restful/RestfulCatchAOP.scala b/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/restful/RestfulCatchAOP.scala deleted file mode 100644 index c55c5a4994..0000000000 --- a/linkis-commons/linkis-module/src/main/scala/com/webank/wedatasphere/linkis/server/restful/RestfulCatchAOP.scala +++ /dev/null @@ -1,50 +0,0 @@ -///* -// * Copyright 2019 WeBank -// * -// * Licensed under the Apache License, Version 2.0 (the "License"); -// * you may not use this file except in compliance with the License. -// * You may obtain a copy of the License at -// * -// * http://www.apache.org/licenses/LICENSE-2.0 -// * -// * Unless required by applicable law or agreed to in writing, software -// * distributed under the License is distributed on an "AS IS" BASIS, -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// * See the License for the specific language governing permissions and -// * limitations under the License. -// */ -// -//package com.webank.wedatasphere.linkis.server.restful -// -//import com.webank.wedatasphere.linkis.common.utils.Logging -//import com.webank.wedatasphere.linkis.server.{Message, catchIt} -//import javax.ws.rs.core.Response -//import org.aspectj.lang.ProceedingJoinPoint -//import org.aspectj.lang.annotation.{Around, Aspect, Pointcut} -//import org.springframework.stereotype.Component -// -// -//@Aspect -//@Component -//class RestfulCatchAOP extends Logging { -// -// @Pointcut("@annotation(javax.ws.rs.Path) && execution(public com.webank.wedatasphere.linkis.server.Message *(..))") -// def restfulMessageCatch() : Unit = {} -// -// @Around("restfulMessageCatch()") -// def dealMessageRestful(proceedingJoinPoint: ProceedingJoinPoint): Object = catchIt { -// proceedingJoinPoint.proceed().asInstanceOf[Message] -// } -// -// @Pointcut("@annotation(javax.ws.rs.Path) && execution(public javax.ws.rs.core.Response *(..)))") -// def restfulResponseCatch() : Unit = {} -// -// @Around("restfulResponseCatch()") -// def dealResponseRestful(proceedingJoinPoint: ProceedingJoinPoint): Object = { -// val resp: Response = catchIt { -// return proceedingJoinPoint.proceed() -// } -// resp -// } -// -//} diff --git a/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/conf/RPCReceiveRestfulCondition.scala b/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/conf/RPCReceiveRestfulCondition.scala index 72b1a3aab0..b85d491c1f 100644 --- a/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/conf/RPCReceiveRestfulCondition.scala +++ b/linkis-commons/linkis-rpc/src/main/scala/com/webank/wedatasphere/linkis/rpc/conf/RPCReceiveRestfulCondition.scala @@ -4,10 +4,6 @@ import com.webank.wedatasphere.linkis.common.conf.CommonVars import org.springframework.context.annotation.{Condition, ConditionContext} import org.springframework.core.`type`.AnnotatedTypeMetadata -/** - * @author casionxia - * @Date 2021/9/26 - */ class RPCReceiveRestfulCondition extends Condition{ val condition = CommonVars("wds.linkis.rpc.default.recevie.enable",false).getValue override def matches(conditionContext: ConditionContext, annotatedTypeMetadata: AnnotatedTypeMetadata): Boolean = { diff --git a/linkis-computation-governance/linkis-client/linkis-computation-client/src/test/java/com/webank/wedatasphere/linkis/computation/client/FlinkOnceJobTest.java b/linkis-computation-governance/linkis-client/linkis-computation-client/src/test/java/com/webank/wedatasphere/linkis/computation/client/FlinkOnceJobTest.java index d094c6398d..74e4e2b4d8 100644 --- a/linkis-computation-governance/linkis-client/linkis-computation-client/src/test/java/com/webank/wedatasphere/linkis/computation/client/FlinkOnceJobTest.java +++ b/linkis-computation-governance/linkis-client/linkis-computation-client/src/test/java/com/webank/wedatasphere/linkis/computation/client/FlinkOnceJobTest.java @@ -21,11 +21,6 @@ import com.webank.wedatasphere.linkis.computation.client.once.simple.SubmittableSimpleOnceJob; import com.webank.wedatasphere.linkis.computation.client.utils.LabelKeyUtils; -/** - * @author enjoyyin - * @date 2021-08-25 - * @since 0.5.0 - */ public class FlinkOnceJobTest { public static void main(String[] args) { // TODO First, set the right gateway url. diff --git a/linkis-engineconn-plugins/engineconn-plugins/flink/src/main/resources/linkis-engineconn.properties b/linkis-engineconn-plugins/engineconn-plugins/flink/src/main/resources/linkis-engineconn.properties index abdb9f01d9..cfced42c34 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/flink/src/main/resources/linkis-engineconn.properties +++ b/linkis-engineconn-plugins/engineconn-plugins/flink/src/main/resources/linkis-engineconn.properties @@ -26,9 +26,4 @@ wds.linkis.engineconn.plugin.default.class=com.webank.wedatasphere.linkis.engine wds.linkis.engine.connector.hooks=com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ComputationEngineConnHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.JarUdfEngineHook -wds.linkis.engineconn.executor.manager.class=com.webank.wedatasphere.linkis.engineconnplugin.flink.executormanager.FlinkExecutorManager - - -spring.spring.mvc.servlet.path=/api/rest_j/v1 -spring.spring.servlet.multipart.max-file-size=200MB -spring.spring.servlet.multipart.max-request-size=200MB \ No newline at end of file +wds.linkis.engineconn.executor.manager.class=com.webank.wedatasphere.linkis.engineconnplugin.flink.executormanager.FlinkExecutorManager \ No newline at end of file diff --git a/linkis-engineconn-plugins/engineconn-plugins/hive/src/main/resources/linkis-engineconn.properties b/linkis-engineconn-plugins/engineconn-plugins/hive/src/main/resources/linkis-engineconn.properties index b598ffe412..7b06ef9c36 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/hive/src/main/resources/linkis-engineconn.properties +++ b/linkis-engineconn-plugins/engineconn-plugins/hive/src/main/resources/linkis-engineconn.properties @@ -26,8 +26,4 @@ wds.linkis.engineconn.plugin.default.class=com.webank.wedatasphere.linkis.engine wds.linkis.bdp.hive.init.sql.enable=true -wds.linkis.engine.connector.hooks=com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ComputationEngineConnHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.JarUdfEngineHook - -spring.spring.mvc.servlet.path=/api/rest_j/v1 -spring.spring.servlet.multipart.max-file-size=200MB -spring.spring.servlet.multipart.max-request-size=200MB \ No newline at end of file +wds.linkis.engine.connector.hooks=com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ComputationEngineConnHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.JarUdfEngineHook \ No newline at end of file diff --git a/linkis-engineconn-plugins/engineconn-plugins/io_file/src/main/resources/linkis-engineconn.properties b/linkis-engineconn-plugins/engineconn-plugins/io_file/src/main/resources/linkis-engineconn.properties index e56de10410..d75ad47916 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/io_file/src/main/resources/linkis-engineconn.properties +++ b/linkis-engineconn-plugins/engineconn-plugins/io_file/src/main/resources/linkis-engineconn.properties @@ -31,7 +31,3 @@ wds.linkis.engineconn.support.parallelism=true wds.linkis.engineconn.max.free.time=0 wds.linkis.engine.push.log.enable=false - -spring.spring.mvc.servlet.path=/api/rest_j/v1 -spring.spring.servlet.multipart.max-file-size=200MB -spring.spring.servlet.multipart.max-request-size=200MB diff --git a/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/resources/linkis-engineconn.properties b/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/resources/linkis-engineconn.properties index 7c4fb88884..93e0616294 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/resources/linkis-engineconn.properties +++ b/linkis-engineconn-plugins/engineconn-plugins/jdbc/src/main/resources/linkis-engineconn.properties @@ -26,8 +26,3 @@ wds.linkis.engineconn.plugin.default.class=com.webank.wedatasphere.linkis.manage #wds.linkis.engine.io.opts=" -Dfile.encoding=UTF-8 -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=49100 " wds.linkis.engineconn.support.parallelism=true - -spring.spring.mvc.servlet.path=/api/rest_j/v1 -spring.spring.servlet.multipart.max-file-size=200MB -spring.spring.servlet.multipart.max-request-size=200MB - diff --git a/linkis-engineconn-plugins/engineconn-plugins/pipeline/src/main/resources/linkis-engineconn.properties b/linkis-engineconn-plugins/engineconn-plugins/pipeline/src/main/resources/linkis-engineconn.properties index 9a0f9a1882..52ccf19efa 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/pipeline/src/main/resources/linkis-engineconn.properties +++ b/linkis-engineconn-plugins/engineconn-plugins/pipeline/src/main/resources/linkis-engineconn.properties @@ -26,8 +26,3 @@ wds.linkis.engineconn.debug.enable=true wds.linkis.engineconn.plugin.default.class=com.webank.wedatasphere.linkis.manager.engineplugin.pipeline.PipelineEngineConnPlugin wds.linkis.engineconn.max.free.time=5m - - -spring.spring.mvc.servlet.path=/api/rest_j/v1 -spring.spring.servlet.multipart.max-file-size=200MB -spring.spring.servlet.multipart.max-request-size=200MB diff --git a/linkis-engineconn-plugins/engineconn-plugins/python/src/main/resources/linkis-engineconn.properties b/linkis-engineconn-plugins/engineconn-plugins/python/src/main/resources/linkis-engineconn.properties index 5a43136b16..fc200e4423 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/python/src/main/resources/linkis-engineconn.properties +++ b/linkis-engineconn-plugins/engineconn-plugins/python/src/main/resources/linkis-engineconn.properties @@ -26,8 +26,3 @@ wds.linkis.engineconn.debug.enable=true wds.linkis.engineconn.plugin.default.class=com.webank.wedatasphere.linkis.manager.engineplugin.python.PythonEngineConnPlugin wds.linkis.engine.connector.hooks=com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ComputationEngineConnHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.PyFunctionEngineHook - - -spring.spring.mvc.servlet.path=/api/rest_j/v1 -spring.spring.servlet.multipart.max-file-size=200MB -spring.spring.servlet.multipart.max-request-size=200MB diff --git a/linkis-engineconn-plugins/engineconn-plugins/shell/src/main/resources/linkis-engineconn.properties b/linkis-engineconn-plugins/engineconn-plugins/shell/src/main/resources/linkis-engineconn.properties index 158701637d..4b8cdf1b0f 100755 --- a/linkis-engineconn-plugins/engineconn-plugins/shell/src/main/resources/linkis-engineconn.properties +++ b/linkis-engineconn-plugins/engineconn-plugins/shell/src/main/resources/linkis-engineconn.properties @@ -17,7 +17,3 @@ wds.linkis.server.version=v1 wds.linkis.engineconn.plugin.default.class=com.webank.wedatasphere.linkis.manager.engineplugin.shell.ShellEngineConnPlugin - -spring.spring.mvc.servlet.path=/api/rest_j/v1 -spring.spring.servlet.multipart.max-file-size=200MB -spring.spring.servlet.multipart.max-request-size=200MB diff --git a/linkis-engineconn-plugins/engineconn-plugins/spark/src/main/resources/linkis-engineconn.properties b/linkis-engineconn-plugins/engineconn-plugins/spark/src/main/resources/linkis-engineconn.properties index 82d3d9daf1..e950588a38 100644 --- a/linkis-engineconn-plugins/engineconn-plugins/spark/src/main/resources/linkis-engineconn.properties +++ b/linkis-engineconn-plugins/engineconn-plugins/spark/src/main/resources/linkis-engineconn.properties @@ -26,8 +26,4 @@ wds.linkis.engineconn.debug.enable=true wds.linkis.engineconn.plugin.default.class=com.webank.wedatasphere.linkis.engineplugin.spark.SparkEngineConnPlugin -wds.linkis.engine.connector.hooks=com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ComputationEngineConnHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.PyUdfEngineHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ScalaUdfEngineHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.JarUdfEngineHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.PyFunctionEngineHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ScalaFunctionEngineHook - -spring.spring.mvc.servlet.path=/api/rest_j/v1 -spring.spring.servlet.multipart.max-file-size=200MB -spring.spring.servlet.multipart.max-request-size=200MB \ No newline at end of file +wds.linkis.engine.connector.hooks=com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ComputationEngineConnHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.PyUdfEngineHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ScalaUdfEngineHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.JarUdfEngineHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.PyFunctionEngineHook,com.webank.wedatasphere.linkis.engineconn.computation.executor.hook.ScalaFunctionEngineHook \ No newline at end of file diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-listener/pom.xml b/linkis-public-enhancements/linkis-context-service/linkis-cs-listener/pom.xml index ce06fc8473..7036de12e1 100644 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-listener/pom.xml +++ b/linkis-public-enhancements/linkis-context-service/linkis-cs-listener/pom.xml @@ -7,7 +7,7 @@ ~ http://www.apache.org/licenses/LICENSE-2.0 ~ Unless required by applicable law or agreed to in writing, software ~ distributed under the License is distributed on an "AS IS" BASIS, - ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.n + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ~ See the License for the specific language governing permissions and ~ limitations under the License. --> diff --git a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/HelloRestfulApi.java b/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/HelloRestfulApi.java deleted file mode 100644 index eedb629f77..0000000000 --- a/linkis-public-enhancements/linkis-context-service/linkis-cs-server/src/main/java/com/webank/wedatasphere/linkis/cs/server/restful/HelloRestfulApi.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2019 WeBank - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.webank.wedatasphere.linkis.cs.server.restful; - -import com.webank.wedatasphere.linkis.server.Message; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; - - -@RestController -@RequestMapping(path = "/contextservice") -public class HelloRestfulApi { - - - @RequestMapping(path = "hello",method = RequestMethod.GET) - public Message getContextID(HttpServletRequest req, String id) throws InterruptedException { - return Message.ok(); - } -}