Skip to content

Commit

Permalink
getWorkspaceStr
Browse files Browse the repository at this point in the history
  • Loading branch information
xlinliu committed Dec 10, 2024
1 parent 01c6e6f commit 53d02ed
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -341,15 +341,8 @@ public Message getAllWorkspaces() {
*/
@RequestMapping(path = "getWorkSpaceStr", method = RequestMethod.GET)
public Message getWorkSpaceStr(@RequestParam(name = "workspaceName") String workspaceName) {
String username = SecurityFilter.getLoginUsername(httpServletRequest);
DSSWorkspace workspaceEntity;
try {
workspaceEntity = dssWorkspaceService.getWorkspacesByName(workspaceName, username);
} catch (DSSErrorException e) {
LOGGER.error("User {} get workspace {} failed.", username, workspaceName, e);
return Message.error(e);
}
Workspace workspace = SSOHelper.setAndGetWorkspace(httpServletRequest, httpServletResponse, workspaceEntity.getId(), workspaceName);
int workspaceId = dssWorkspaceService.getWorkspaceId(workspaceName);
Workspace workspace = SSOHelper.setAndGetWorkspace(httpServletRequest, httpServletResponse, workspaceId, workspaceName);
return Message.ok("succeed.").data("workspaceStr", DSSCommonUtils.COMMON_GSON.toJson(workspace));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ List<DSSWorkspaceUserVO> getWorkspaceUsers(String workspaceId, String department

String getWorkspaceName(Long workspaceId);

int getWorkspaceId(String workspaceName);

/**
* 工作空间管理员权限判断(is_admin=1的用户才拥有工作空间操作权限)
* @param userName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.webank.wedatasphere.dss.appconn.manager.utils.AppInstanceConstants;
import com.webank.wedatasphere.dss.common.StaffInfoGetter;
import com.webank.wedatasphere.dss.common.exception.DSSErrorException;
import com.webank.wedatasphere.dss.common.exception.DSSRuntimeException;
import com.webank.wedatasphere.dss.common.label.EnvDSSLabel;
import com.webank.wedatasphere.dss.framework.admin.conf.AdminConf;
import com.webank.wedatasphere.dss.framework.admin.service.DssAdminUserService;
Expand Down Expand Up @@ -485,6 +486,14 @@ public DSSWorkspaceHomepageSettingVO getWorkspaceHomepageSettings(int workspaceI
public String getWorkspaceName(Long workspaceId) {
return dssWorkspaceMapper.getWorkspaceNameById(workspaceId);
}
@Override
public int getWorkspaceId(String workspaceName) {
Integer workspaceId= dssWorkspaceMapper.getWorkspaceIdByName(workspaceName);
if (workspaceId == null || workspaceId < 0) {
throw new DSSRuntimeException("workspace is not exist.workspaceName:" + workspaceName);
}
return workspaceId;
}

@Override
public boolean checkAdmin(String userName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,23 @@ public Message status(HttpServletRequest req, @PathVariable("id") String id, @Re
logger.error("Got {} task for taskID : {}", size, realTaskID);
message = Message.error("Got " + size + " task for taskId : " + realTaskID);
} else {
String status = taskList.get(0).getStatus();
message.data("status", status).data("execID", id);
WorkflowQueryTask task = taskList.get(0);
String status = task.getStatus();
String logPath = task.getLogPath();
message.data("status", status).data("execID", id).data("logPath",logPath);
}
message.setMethod("/api/entrance/" + id + "/status");
return message;
}
if (job.isDefined()) {
long realTaskID = Long.parseLong(taskID);
WorkflowQueryTask queryTask = new WorkflowQueryTask();
queryTask.setTaskID(realTaskID);
List<WorkflowQueryTask> taskList = taskMapper.selectTask(queryTask);
String logPath = taskList.isEmpty() ? null : taskList.get(taskList.size() - 1).getLogPath();
message = Message.ok();
message.setMethod("/api/entrance/" + id + "/status");
message.data("status", job.get().getState().toString()).data("execID", id);
message.data("status", job.get().getState().toString()).data("execID", id).data("logPath",logPath);
} else {
message = Message.error("ID The corresponding job is empty and cannot obtain the corresponding task status.(ID 对应的job为空,不能获取相应的任务状态)");
}
Expand Down

0 comments on commit 53d02ed

Please sign in to comment.