status
stringclasses
1 value
repo_name
stringclasses
31 values
repo_url
stringclasses
31 values
issue_id
int64
1
104k
title
stringlengths
4
233
body
stringlengths
0
186k
issue_url
stringlengths
38
56
pull_url
stringlengths
37
54
before_fix_sha
stringlengths
40
40
after_fix_sha
stringlengths
40
40
report_datetime
timestamp[us, tz=UTC]
language
stringclasses
5 values
commit_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
7
188
chunk_content
stringlengths
1
1.03M
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,638
[Bug] [MasterServer] task state no change when failover worker
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version: 2.0-alpha The task state is always running when I stop the worker. I try to debug in failoverWorker and found the judge conditions error. ### What you expected to happen After stop the worker, the task will change state and no always running. ### How to reproduce run a long time task and stop the worker. ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6638
https://github.com/apache/dolphinscheduler/pull/6639
8850baff07cc5174a57a0560cbeeb1a3368a4dca
ae0b18f3a3284357f7533c015086cd65f27caca5
2021-10-29T10:43:07Z
java
2021-10-31T13:12:55Z
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java
/** * registry */ public void registry() { String address = NetUtils.getAddr(masterConfig.getListenPort()); localNodePath = getMasterPath(); int masterHeartbeatInterval = masterConfig.getMasterHeartbeatInterval(); HeartBeatTask heartBeatTask = new HeartBeatTask(startupTime, masterConfig.getMasterMaxCpuloadAvg(), masterConfig.getMasterReservedMemory(), Sets.newHashSet(getMasterPath()), Constants.MASTER_TYPE, registryClient); registryClient.persistEphemeral(localNodePath, heartBeatTask.getHeartBeatInfo()); registryClient.addConnectionStateListener(new MasterRegistryConnectStateListener()); this.heartBeatExecutor.scheduleAtFixedRate(heartBeatTask, masterHeartbeatInterval, masterHeartbeatInterval, TimeUnit.SECONDS); logger.info("master node : {} registry to ZK successfully with heartBeatInterval : {}s", address, masterHeartbeatInterval); } class MasterRegistryConnectStateListener implements RegistryConnectListener { @Override public void notify(RegistryConnectState newState) { if (RegistryConnectState.RECONNECTED == newState) { registryClient.persistEphemeral(localNodePath, ""); } if (RegistryConnectState.SUSPENDED == newState) { registryClient.persistEphemeral(localNodePath, ""); } } } /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,638
[Bug] [MasterServer] task state no change when failover worker
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version: 2.0-alpha The task state is always running when I stop the worker. I try to debug in failoverWorker and found the judge conditions error. ### What you expected to happen After stop the worker, the task will change state and no always running. ### How to reproduce run a long time task and stop the worker. ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6638
https://github.com/apache/dolphinscheduler/pull/6639
8850baff07cc5174a57a0560cbeeb1a3368a4dca
ae0b18f3a3284357f7533c015086cd65f27caca5
2021-10-29T10:43:07Z
java
2021-10-31T13:12:55Z
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/registry/MasterRegistryClient.java
* remove registry info */ public void unRegistry() { try { String address = getLocalAddress(); String localNodePath = getMasterPath(); registryClient.remove(localNodePath); logger.info("master node : {} unRegistry to register center.", address); heartBeatExecutor.shutdown(); logger.info("heartbeat executor shutdown"); registryClient.close(); } catch (Exception e) { logger.error("remove registry path exception ", e); } } /** * get master path */ public String getMasterPath() { String address = getLocalAddress(); return REGISTRY_DOLPHINSCHEDULER_MASTERS + "/" + address; } /** * get local address */ private String getLocalAddress() { return NetUtils.getAddr(masterConfig.getListenPort()); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 org.apache.dolphinscheduler.api.service.impl; import static org.apache.dolphinscheduler.common.Constants.ALIAS; import static org.apache.dolphinscheduler.common.Constants.CONTENT; import static org.apache.dolphinscheduler.common.Constants.JAR; import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent; import org.apache.dolphinscheduler.api.dto.resources.filter.ResourceFilter; import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor; import org.apache.dolphinscheduler.api.dto.resources.visitor.Visitor;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; import org.apache.dolphinscheduler.api.service.ResourcesService; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.RegexUtils; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.enums.ProgramType; import org.apache.dolphinscheduler.spi.enums.ResourceType; import org.apache.dolphinscheduler.common.utils.CollectionUtils; import org.apache.dolphinscheduler.common.utils.FileUtils; import org.apache.dolphinscheduler.common.utils.HadoopUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.PropertyUtils; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.ResourcesUser; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.UdfFunc; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils; import org.apache.commons.beanutils.BeanMap; import org.apache.commons.lang.StringUtils; import java.io.IOException; import java.text.MessageFormat;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.regex.Matcher; import java.util.stream.Collectors; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DuplicateKeyException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fasterxml.jackson.databind.SerializationFeature; /** * resources service impl */ @Service public class ResourcesServiceImpl extends BaseServiceImpl implements ResourcesService { private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceImpl.class); @Autowired private ResourceMapper resourcesMapper; @Autowired
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
private UdfFuncMapper udfFunctionMapper; @Autowired private TenantMapper tenantMapper; @Autowired private UserMapper userMapper; @Autowired private ResourceUserMapper resourceUserMapper; @Autowired private ProcessDefinitionMapper processDefinitionMapper; /** * create directory * * @param loginUser login user * @param name alias * @param description description * @param type type * @param pid parent id * @param currentDir current directory * @return create directory result */ @Override @Transactional(rollbackFor = Exception.class) public Result<Object> createDirectory(User loginUser, String name, String description, ResourceType type, int pid, String currentDir) { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } String fullName = currentDir.equals("/") ? String.format("%s%s",currentDir,name) : String.format("%s/%s",currentDir,name); result = verifyResource(loginUser, type, fullName, pid); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } if (checkResourceExists(fullName, 0, type.ordinal())) { logger.error("resource directory {} has exist, can't recreate", fullName); putMsg(result, Status.RESOURCE_EXIST); return result; } Date now = new Date(); Resource resource = new Resource(pid,name,fullName,true,description,name,loginUser.getId(),type,0,now,now); try { resourcesMapper.insert(resource); putMsg(result, Status.SUCCESS); Map<Object, Object> dataMap = new BeanMap(resource); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry: dataMap.entrySet()) { if (!"class".equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue()); } } result.setData(resultMap); } catch (DuplicateKeyException e) { logger.error("resource directory {} has exist, can't recreate", fullName); putMsg(result, Status.RESOURCE_EXIST); return result; } catch (Exception e) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
logger.error("resource already exists, can't recreate ", e); throw new ServiceException("resource already exists, can't recreate"); } createDirectory(loginUser,fullName,type,result); return result; } /** * create resource * * @param loginUser login user * @param name alias * @param desc description * @param file file * @param type type * @param pid parent id * @param currentDir current directory * @return create result code */ @Override @Transactional(rollbackFor = Exception.class) public Result<Object> createResource(User loginUser, String name, String desc, ResourceType type, MultipartFile file, int pid, String currentDir) { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } result = verifyPid(loginUser, pid); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } result = verifyFile(name, type, file); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } String fullName = currentDir.equals("/") ? String.format("%s%s",currentDir,name) : String.format("%s/%s",currentDir,name); if (checkResourceExists(fullName, 0, type.ordinal())) { logger.error("resource {} has exist, can't recreate", RegexUtils.escapeNRT(name)); putMsg(result, Status.RESOURCE_EXIST); return result; } Date now = new Date(); Resource resource = new Resource(pid,name,fullName,false,desc,file.getOriginalFilename(),loginUser.getId(),type,file.getSize(),now,now); try { resourcesMapper.insert(resource); putMsg(result, Status.SUCCESS); Map<Object, Object> dataMap = new BeanMap(resource); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry: dataMap.entrySet()) { if (!"class".equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue()); } } result.setData(resultMap);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} catch (Exception e) { logger.error("resource already exists, can't recreate ", e); throw new ServiceException("resource already exists, can't recreate"); } if (!upload(loginUser, fullName, file, type)) { logger.error("upload resource: {} file: {} failed.", RegexUtils.escapeNRT(name), RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.HDFS_OPERATION_ERROR); throw new ServiceException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename())); } return result; } /** * check resource is exists * * @param fullName fullName * @param userId user id * @param type type * @return true if resource exists */ private boolean checkResourceExists(String fullName, int userId, int type) { Boolean existResource = resourcesMapper.existResource(fullName, userId, type); return existResource == Boolean.TRUE; } /** * update resource * @param loginUser login user * @param resourceId resource id * @param name name * @param desc description
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @param type resource type * @param file resource file * @return update result code */ @Override @Transactional(rollbackFor = Exception.class) public Result<Object> updateResource(User loginUser, int resourceId, String name, String desc, ResourceType type, MultipartFile file) { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } if (!hasPerm(loginUser, resource.getUserId())) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } if (file == null && name.equals(resource.getAlias()) && desc.equals(resource.getDescription())) { putMsg(result, Status.SUCCESS); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
String originFullName = resource.getFullName(); String originResourceName = resource.getAlias(); String fullName = String.format("%s%s",originFullName.substring(0,originFullName.lastIndexOf("/") + 1),name); if (!originResourceName.equals(name) && checkResourceExists(fullName, 0, type.ordinal())) { logger.error("resource {} already exists, can't recreate", name); putMsg(result, Status.RESOURCE_EXIST); return result; } result = verifyFile(name, type, file); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } String tenantCode = getTenantCode(resource.getUserId(),result); if (StringUtils.isEmpty(tenantCode)) { return result; } String originHdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(),tenantCode,originFullName); try { if (!HadoopUtils.getInstance().exists(originHdfsFileName)) { logger.error("{} not exist", originHdfsFileName); putMsg(result,Status.RESOURCE_NOT_EXIST); return result; } } catch (IOException e) { logger.error(e.getMessage(),e); throw new ServiceException(Status.HDFS_OPERATION_ERROR); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (!resource.isDirectory()) { String originSuffix = FileUtils.suffix(originFullName); String suffix = FileUtils.suffix(fullName); boolean suffixIsChanged = false; if (StringUtils.isBlank(suffix) && StringUtils.isNotBlank(originSuffix)) { suffixIsChanged = true; } if (StringUtils.isNotBlank(suffix) && !suffix.equals(originSuffix)) { suffixIsChanged = true; } if (suffixIsChanged) { Map<String, Object> columnMap = new HashMap<>(); columnMap.put("resources_id", resourceId); List<ResourcesUser> resourcesUsers = resourceUserMapper.selectByMap(columnMap); if (CollectionUtils.isNotEmpty(resourcesUsers)) { List<Integer> userIds = resourcesUsers.stream().map(ResourcesUser::getUserId).collect(Collectors.toList()); List<User> users = userMapper.selectBatchIds(userIds); String userNames = users.stream().map(User::getUserName).collect(Collectors.toList()).toString(); logger.error("resource is authorized to user {},suffix not allowed to be modified", userNames); putMsg(result,Status.RESOURCE_IS_AUTHORIZED,userNames); return result; } } } Date now = new Date(); resource.setAlias(name);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
resource.setFileName(name); resource.setFullName(fullName); resource.setDescription(desc); resource.setUpdateTime(now); if (file != null) { resource.setSize(file.getSize()); } try { resourcesMapper.updateById(resource); if (resource.isDirectory()) { List<Integer> childrenResource = listAllChildren(resource,false); if (CollectionUtils.isNotEmpty(childrenResource)) { String matcherFullName = Matcher.quoteReplacement(fullName); List<Resource> childResourceList; Integer[] childResIdArray = childrenResource.toArray(new Integer[childrenResource.size()]); List<Resource> resourceList = resourcesMapper.listResourceByIds(childResIdArray); childResourceList = resourceList.stream().map(t -> { t.setFullName(t.getFullName().replaceFirst(originFullName, matcherFullName)); t.setUpdateTime(now); return t; }).collect(Collectors.toList()); resourcesMapper.batchUpdateResource(childResourceList); if (ResourceType.UDF.equals(resource.getType())) { List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(childResIdArray); if (CollectionUtils.isNotEmpty(udfFuncs)) { udfFuncs = udfFuncs.stream().map(t -> { t.setResourceName(t.getResourceName().replaceFirst(originFullName, matcherFullName)); t.setUpdateTime(now); return t; }).collect(Collectors.toList());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
udfFunctionMapper.batchUpdateUdfFunc(udfFuncs); } } } } else if (ResourceType.UDF.equals(resource.getType())) { List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(new Integer[]{resourceId}); if (CollectionUtils.isNotEmpty(udfFuncs)) { udfFuncs = udfFuncs.stream().map(t -> { t.setResourceName(fullName); t.setUpdateTime(now); return t; }).collect(Collectors.toList()); udfFunctionMapper.batchUpdateUdfFunc(udfFuncs); } } putMsg(result, Status.SUCCESS); Map<Object, Object> dataMap = new BeanMap(resource); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry: dataMap.entrySet()) { if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue()); } } result.setData(resultMap); } catch (Exception e) { logger.error(Status.UPDATE_RESOURCE_ERROR.getMsg(), e); throw new ServiceException(Status.UPDATE_RESOURCE_ERROR); } if (originResourceName.equals(name) && file == null) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } if (file != null) { if (!upload(loginUser, fullName, file, type)) { logger.error("upload resource: {} file: {} failed.", name, RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.HDFS_OPERATION_ERROR); throw new ServiceException(String.format("upload resource: %s file: %s failed.", name, file.getOriginalFilename())); } if (!fullName.equals(originFullName)) { try { HadoopUtils.getInstance().delete(originHdfsFileName,false); } catch (IOException e) { logger.error(e.getMessage(),e); throw new ServiceException(String.format("delete resource: %s failed.", originFullName)); } } return result; } String destHdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(),tenantCode,fullName); try { logger.info("start hdfs copy {} -> {}", originHdfsFileName, destHdfsFileName); HadoopUtils.getInstance().copy(originHdfsFileName, destHdfsFileName, true, true); } catch (Exception e) { logger.error(MessageFormat.format("hdfs copy {0} -> {1} fail", originHdfsFileName, destHdfsFileName), e); putMsg(result,Status.HDFS_COPY_FAIL); throw new ServiceException(Status.HDFS_COPY_FAIL); } return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} private Result<Object> verifyFile(String name, ResourceType type, MultipartFile file) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (file != null) { if (file.isEmpty()) { logger.error("file is empty: {}", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_FILE_IS_EMPTY); return result; } String fileSuffix = FileUtils.suffix(file.getOriginalFilename()); String nameSuffix = FileUtils.suffix(name); if (!(StringUtils.isNotEmpty(fileSuffix) && fileSuffix.equalsIgnoreCase(nameSuffix))) { logger.error("rename file suffix and original suffix must be consistent: {}", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_SUFFIX_FORBID_CHANGE); return result; } if (Constants.UDF.equals(type.name()) && !JAR.equalsIgnoreCase(fileSuffix)) { logger.error(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg()); putMsg(result, Status.UDF_RESOURCE_SUFFIX_NOT_JAR); return result; } if (file.getSize() > Constants.MAX_FILE_SIZE) { logger.error("file size is too large: {}", RegexUtils.escapeNRT(file.getOriginalFilename())); putMsg(result, Status.RESOURCE_SIZE_EXCEED_LIMIT);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } } return result; } /** * query resources list paging * * @param loginUser login user * @param type resource type * @param searchVal search value * @param pageNo page number * @param pageSize page size * @return resource list page */ @Override public Result queryResourceListPaging(User loginUser, int directoryId, ResourceType type, String searchVal, Integer pageNo, Integer pageSize) { Result result = new Result(); Page<Resource> page = new Page<>(pageNo, pageSize); int userId = loginUser.getId(); if (isAdmin(loginUser)) { userId = 0; } if (directoryId != -1) { Resource directory = resourcesMapper.selectById(directoryId); if (directory == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
List<Integer> resourcesIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, 0); IPage<Resource> resourceIPage = resourcesMapper.queryResourcePaging(page, userId, directoryId, type.ordinal(), searchVal,resourcesIds); PageInfo<Resource> pageInfo = new PageInfo<>(pageNo, pageSize); pageInfo.setTotal((int)resourceIPage.getTotal()); pageInfo.setTotalList(resourceIPage.getRecords()); result.setData(pageInfo); putMsg(result,Status.SUCCESS); return result; } /** * create directory * @param loginUser login user * @param fullName full name * @param type resource type * @param result Result */ private void createDirectory(User loginUser,String fullName,ResourceType type,Result<Object> result) { String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); String directoryName = HadoopUtils.getHdfsFileName(type,tenantCode,fullName); String resourceRootPath = HadoopUtils.getHdfsDir(type,tenantCode); try { if (!HadoopUtils.getInstance().exists(resourceRootPath)) { createTenantDirIfNotExists(tenantCode); } if (!HadoopUtils.getInstance().mkdir(directoryName)) { logger.error("create resource directory {} of hdfs failed",directoryName); putMsg(result,Status.HDFS_OPERATION_ERROR); throw new ServiceException(String.format("create resource directory: %s failed.", directoryName)); } } catch (Exception e) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
logger.error("create resource directory {} of hdfs failed",directoryName); putMsg(result,Status.HDFS_OPERATION_ERROR); throw new ServiceException(String.format("create resource directory: %s failed.", directoryName)); } } /** * upload file to hdfs * * @param loginUser login user * @param fullName full name * @param file file */ private boolean upload(User loginUser, String fullName, MultipartFile file, ResourceType type) { String fileSuffix = FileUtils.suffix(file.getOriginalFilename()); String nameSuffix = FileUtils.suffix(fullName); if (!(StringUtils.isNotEmpty(fileSuffix) && fileSuffix.equalsIgnoreCase(nameSuffix))) { return false; } String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); String localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString()); String hdfsFilename = HadoopUtils.getHdfsFileName(type,tenantCode,fullName); String resourcePath = HadoopUtils.getHdfsDir(type,tenantCode); try { if (!HadoopUtils.getInstance().exists(resourcePath)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
createTenantDirIfNotExists(tenantCode); } org.apache.dolphinscheduler.api.utils.FileUtils.copyFile(file, localFilename); HadoopUtils.getInstance().copyLocalToHdfs(localFilename, hdfsFilename, true, true); } catch (Exception e) { try { FileUtils.deleteFile(localFilename); } catch (IOException ex) { logger.error("delete local tmp file:{} error", localFilename, ex); } logger.error(e.getMessage(), e); return false; } return true; } /** * query resource list * * @param loginUser login user * @param type resource type * @return resource list */ @Override public Map<String, Object> queryResourceList(User loginUser, ResourceType type) { Map<String, Object> result = new HashMap<>(); List<Resource> allResourceList = queryAuthoredResourceList(loginUser, type); Visitor resourceTreeVisitor = new ResourceTreeVisitor(allResourceList); result.put(Constants.DATA_LIST, resourceTreeVisitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} /** * query resource list by program type * * @param loginUser login user * @param type resource type * @return resource list */ @Override public Map<String, Object> queryResourceByProgramType(User loginUser, ResourceType type, ProgramType programType) { Map<String, Object> result = new HashMap<>(); List<Resource> allResourceList = queryAuthoredResourceList(loginUser, type); String suffix = ".jar"; if (programType != null) { switch (programType) { case JAVA: case SCALA: break; case PYTHON: suffix = ".py"; break; default: } } List<Resource> resources = new ResourceFilter(suffix, new ArrayList<>(allResourceList)).filter(); Visitor resourceTreeVisitor = new ResourceTreeVisitor(resources); result.put(Constants.DATA_LIST, resourceTreeVisitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
/** * delete resource * * @param loginUser login user * @param resourceId resource id * @return delete result code * @throws IOException exception */ @Override @Transactional(rollbackFor = Exception.class) public Result<Object> delete(User loginUser, int resourceId) throws IOException { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } if (!hasPerm(loginUser, resource.getUserId())) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } String tenantCode = getTenantCode(resource.getUserId(),result); if (StringUtils.isEmpty(tenantCode)) { return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
List<Map<String, Object>> list = processDefinitionMapper.listResources(); Map<Integer, Set<Long>> resourceProcessMap = ResourceProcessDefinitionUtils.getResourceProcessDefinitionMap(list); Set<Integer> resourceIdSet = resourceProcessMap.keySet(); List<Integer> allChildren = listAllChildren(resource,true); Integer[] needDeleteResourceIdArray = allChildren.toArray(new Integer[allChildren.size()]); if (resource.getType() == (ResourceType.UDF)) { List<UdfFunc> udfFuncs = udfFunctionMapper.listUdfByResourceId(needDeleteResourceIdArray); if (CollectionUtils.isNotEmpty(udfFuncs)) { logger.error("can't be deleted,because it is bound by UDF functions:{}", udfFuncs); putMsg(result,Status.UDF_RESOURCE_IS_BOUND,udfFuncs.get(0).getFuncName()); return result; } } if (resourceIdSet.contains(resource.getPid())) { logger.error("can't be deleted,because it is used of process definition"); putMsg(result, Status.RESOURCE_IS_USED); return result; } resourceIdSet.retainAll(allChildren); if (CollectionUtils.isNotEmpty(resourceIdSet)) { logger.error("can't be deleted,because it is used of process definition"); for (Integer resId : resourceIdSet) { logger.error("resource id:{} is used of process definition {}",resId,resourceProcessMap.get(resId)); } putMsg(result, Status.RESOURCE_IS_USED); return result; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
String hdfsFilename = HadoopUtils.getHdfsFileName(resource.getType(), tenantCode, resource.getFullName()); resourcesMapper.deleteIds(needDeleteResourceIdArray); resourceUserMapper.deleteResourceUserArray(0, needDeleteResourceIdArray); HadoopUtils.getInstance().delete(hdfsFilename, true); putMsg(result, Status.SUCCESS); return result; } /** * verify resource by name and type * @param loginUser login user * @param fullName resource full name * @param type resource type * @return true if the resource name not exists, otherwise return false */ @Override public Result<Object> verifyResourceName(String fullName, ResourceType type, User loginUser) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (checkResourceExists(fullName, 0, type.ordinal())) { logger.error("resource type:{} name:{} has exist, can't create again.", type, RegexUtils.escapeNRT(fullName)); putMsg(result, Status.RESOURCE_EXIST); } else { Tenant tenant = tenantMapper.queryById(loginUser.getTenantId()); if (tenant != null) { String tenantCode = tenant.getTenantCode(); try { String hdfsFilename = HadoopUtils.getHdfsFileName(type,tenantCode,fullName);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (HadoopUtils.getInstance().exists(hdfsFilename)) { logger.error("resource type:{} name:{} has exist in hdfs {}, can't create again.", type, RegexUtils.escapeNRT(fullName), hdfsFilename); putMsg(result, Status.RESOURCE_FILE_EXIST,hdfsFilename); } } catch (Exception e) { logger.error(e.getMessage(),e); putMsg(result,Status.HDFS_OPERATION_ERROR); } } else { putMsg(result,Status.TENANT_NOT_EXIST); } } return result; } /** * verify resource by full name or pid and type * @param fullName resource full name * @param id resource id * @param type resource type * @return true if the resource full name or pid not exists, otherwise return false */ @Override public Result<Object> queryResource(String fullName, Integer id, ResourceType type) { Result<Object> result = new Result<>(); if (StringUtils.isBlank(fullName) && id == null) { putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR); return result; } if (StringUtils.isNotBlank(fullName)) { List<Resource> resourceList = resourcesMapper.queryResource(fullName,type.ordinal());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (CollectionUtils.isEmpty(resourceList)) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } putMsg(result, Status.SUCCESS); result.setData(resourceList.get(0)); } else { Resource resource = resourcesMapper.selectById(id); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } Resource parentResource = resourcesMapper.selectById(resource.getPid()); if (parentResource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } putMsg(result, Status.SUCCESS); result.setData(parentResource); } return result; } /** * view resource file online * * @param resourceId resource id * @param skipLineNum skip line number * @param limit limit * @return resource content */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
@Override public Result<Object> readResource(int resourceId, int skipLineNum, int limit) { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } String nameSuffix = FileUtils.suffix(resource.getAlias()); String resourceViewSuffixs = FileUtils.getResourceViewSuffixs(); if (StringUtils.isNotEmpty(resourceViewSuffixs)) { List<String> strList = Arrays.asList(resourceViewSuffixs.split(",")); if (!strList.contains(nameSuffix)) { logger.error("resource suffix {} not support view, resource id {}", nameSuffix, resourceId); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } String tenantCode = getTenantCode(resource.getUserId(),result); if (StringUtils.isEmpty(tenantCode)) { return result; } String hdfsFileName = HadoopUtils.getHdfsResourceFileName(tenantCode, resource.getFullName()); logger.info("resource hdfs path is {}", hdfsFileName);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
try { if (HadoopUtils.getInstance().exists(hdfsFileName)) { List<String> content = HadoopUtils.getInstance().catFile(hdfsFileName, skipLineNum, limit); putMsg(result, Status.SUCCESS); Map<String, Object> map = new HashMap<>(); map.put(ALIAS, resource.getAlias()); map.put(CONTENT, String.join("\n", content)); result.setData(map); } else { logger.error("read file {} not exist in hdfs", hdfsFileName); putMsg(result, Status.RESOURCE_FILE_NOT_EXIST,hdfsFileName); } } catch (Exception e) { logger.error("Resource {} read failed", hdfsFileName, e); putMsg(result, Status.HDFS_OPERATION_ERROR); } return result; } /** * create resource file online * * @param loginUser login user * @param type resource type * @param fileName file name * @param fileSuffix file suffix * @param desc description * @param content content * @param pid pid * @param currentDir current directory * @return create result code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
*/ @Override @Transactional(rollbackFor = Exception.class) public Result<Object> onlineCreateResource(User loginUser, ResourceType type, String fileName, String fileSuffix, String desc, String content,int pid,String currentDir) { Result<Object> result = checkResourceUploadStartupState(); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } String nameSuffix = fileSuffix.trim(); String resourceViewSuffixs = FileUtils.getResourceViewSuffixs(); if (StringUtils.isNotEmpty(resourceViewSuffixs)) { List<String> strList = Arrays.asList(resourceViewSuffixs.split(",")); if (!strList.contains(nameSuffix)) { logger.error("resource suffix {} not support create", nameSuffix); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } String name = fileName.trim() + "." + nameSuffix; String fullName = currentDir.equals("/") ? String.format("%s%s",currentDir,name) : String.format("%s/%s",currentDir,name); result = verifyResource(loginUser, type, fullName, pid); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Date now = new Date(); Resource resource = new Resource(pid,name,fullName,false,desc,name,loginUser.getId(),type,content.getBytes().length,now,now); resourcesMapper.insert(resource); putMsg(result, Status.SUCCESS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
Map<Object, Object> dataMap = new BeanMap(resource); Map<String, Object> resultMap = new HashMap<>(); for (Map.Entry<Object, Object> entry: dataMap.entrySet()) { if (!Constants.CLASS.equalsIgnoreCase(entry.getKey().toString())) { resultMap.put(entry.getKey().toString(), entry.getValue()); } } result.setData(resultMap); String tenantCode = tenantMapper.queryById(loginUser.getTenantId()).getTenantCode(); result = uploadContentToHdfs(fullName, tenantCode, content); if (!result.getCode().equals(Status.SUCCESS.getCode())) { throw new ServiceException(result.getMsg()); } return result; } private Result<Object> checkResourceUploadStartupState() { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (!PropertyUtils.getResUploadStartupState()) { logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState()); putMsg(result, Status.HDFS_NOT_STARTUP); return result; } return result; } private Result<Object> verifyResource(User loginUser, ResourceType type, String fullName, int pid) { Result<Object> result = verifyResourceName(fullName, type, loginUser); if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} return verifyPid(loginUser, pid); } private Result<Object> verifyPid(User loginUser, int pid) { Result<Object> result = new Result<>(); putMsg(result, Status.SUCCESS); if (pid != -1) { Resource parentResource = resourcesMapper.selectById(pid); if (parentResource == null) { putMsg(result, Status.PARENT_RESOURCE_NOT_EXIST); return result; } if (!hasPerm(loginUser, parentResource.getUserId())) { putMsg(result, Status.USER_NO_OPERATION_PERM); return result; } } return result; } /** * updateProcessInstance resource * * @param resourceId resource id * @param content content * @return update result cod */ @Override @Transactional(rollbackFor = Exception.class) public Result<Object> updateResourceContent(int resourceId, String content) { Result<Object> result = checkResourceUploadStartupState();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (!result.getCode().equals(Status.SUCCESS.getCode())) { return result; } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { logger.error("read file not exist, resource id {}", resourceId); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } String nameSuffix = FileUtils.suffix(resource.getAlias()); String resourceViewSuffixs = FileUtils.getResourceViewSuffixs(); if (StringUtils.isNotEmpty(resourceViewSuffixs)) { List<String> strList = Arrays.asList(resourceViewSuffixs.split(",")); if (!strList.contains(nameSuffix)) { logger.error("resource suffix {} not support updateProcessInstance, resource id {}", nameSuffix, resourceId); putMsg(result, Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW); return result; } } String tenantCode = getTenantCode(resource.getUserId(),result); if (StringUtils.isEmpty(tenantCode)) { return result; } resource.setSize(content.getBytes().length); resource.setUpdateTime(new Date()); resourcesMapper.updateById(resource); result = uploadContentToHdfs(resource.getFullName(), tenantCode, content); if (!result.getCode().equals(Status.SUCCESS.getCode())) { throw new ServiceException(result.getMsg());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} return result; } /** * @param resourceName resource name * @param tenantCode tenant code * @param content content * @return result */ private Result<Object> uploadContentToHdfs(String resourceName, String tenantCode, String content) { Result<Object> result = new Result<>(); String localFilename = ""; String hdfsFileName = ""; try { localFilename = FileUtils.getUploadFilename(tenantCode, UUID.randomUUID().toString()); if (!FileUtils.writeContent2File(content, localFilename)) { logger.error("file {} fail, content is {}", localFilename, RegexUtils.escapeNRT(content)); putMsg(result, Status.RESOURCE_NOT_EXIST); return result; } hdfsFileName = HadoopUtils.getHdfsResourceFileName(tenantCode, resourceName); String resourcePath = HadoopUtils.getHdfsResDir(tenantCode); logger.info("resource hdfs path is {}, resource dir is {}", hdfsFileName, resourcePath); HadoopUtils hadoopUtils = HadoopUtils.getInstance(); if (!hadoopUtils.exists(resourcePath)) { createTenantDirIfNotExists(tenantCode); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
if (hadoopUtils.exists(hdfsFileName)) { hadoopUtils.delete(hdfsFileName, false); } hadoopUtils.copyLocalToHdfs(localFilename, hdfsFileName, true, true); } catch (Exception e) { logger.error(e.getMessage(), e); result.setCode(Status.HDFS_OPERATION_ERROR.getCode()); result.setMsg(String.format("copy %s to hdfs %s fail", localFilename, hdfsFileName)); return result; } putMsg(result, Status.SUCCESS); return result; } /** * download file * * @param resourceId resource id * @return resource content * @throws IOException exception */ @Override public org.springframework.core.io.Resource downloadResource(int resourceId) throws IOException { if (!PropertyUtils.getResUploadStartupState()) { logger.error("resource upload startup state: {}", PropertyUtils.getResUploadStartupState()); throw new ServiceException("hdfs not startup"); } Resource resource = resourcesMapper.selectById(resourceId); if (resource == null) { logger.error("download file not exist, resource id {}", resourceId);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return null; } if (resource.isDirectory()) { logger.error("resource id {} is directory,can't download it", resourceId); throw new ServiceException("can't download directory"); } int userId = resource.getUserId(); User user = userMapper.selectById(userId); if (user == null) { logger.error("user id {} not exists", userId); throw new ServiceException(String.format("resource owner id %d not exist",userId)); } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant id {} not exists", user.getTenantId()); throw new ServiceException(String.format("The tenant id %d of resource owner not exist",user.getTenantId())); } String tenantCode = tenant.getTenantCode(); String hdfsFileName = HadoopUtils.getHdfsFileName(resource.getType(), tenantCode, resource.getFullName()); String localFileName = FileUtils.getDownloadFilename(resource.getAlias()); logger.info("resource hdfs path is {}, download local filename is {}", hdfsFileName, localFileName); HadoopUtils.getInstance().copyHdfsToLocal(hdfsFileName, localFileName, false, true); return org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(localFileName); } /** * list all file * * @param loginUser login user * @param userId user id * @return unauthorized result code
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
*/ @Override public Map<String, Object> authorizeResourceTree(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { return result; } List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId); List<ResourceComponent> list; if (CollectionUtils.isNotEmpty(resourceList)) { Visitor visitor = new ResourceTreeVisitor(resourceList); list = visitor.visit().getChildren(); } else { list = new ArrayList<>(0); } result.put(Constants.DATA_LIST, list); putMsg(result, Status.SUCCESS); return result; } /** * unauthorized file * * @param loginUser login user * @param userId user id * @return unauthorized result code */ @Override public Map<String, Object> unauthorizedFile(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId); List<Resource> list; if (resourceList != null && !resourceList.isEmpty()) { Set<Resource> resourceSet = new HashSet<>(resourceList); List<Resource> authedResourceList = queryResourceList(userId, Constants.AUTHORIZE_WRITABLE_PERM); getAuthorizedResourceList(resourceSet, authedResourceList); list = new ArrayList<>(resourceSet); } else { list = new ArrayList<>(0); } Visitor visitor = new ResourceTreeVisitor(list); result.put(Constants.DATA_LIST, visitor.visit().getChildren()); putMsg(result, Status.SUCCESS); return result; } /** * unauthorized udf function * * @param loginUser login user * @param userId user id * @return unauthorized result code */ @Override public Map<String, Object> unauthorizedUDFFunction(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { return result;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
} List<UdfFunc> udfFuncList = udfFunctionMapper.queryUdfFuncExceptUserId(userId); List<UdfFunc> resultList = new ArrayList<>(); Set<UdfFunc> udfFuncSet; if (CollectionUtils.isNotEmpty(udfFuncList)) { udfFuncSet = new HashSet<>(udfFuncList); List<UdfFunc> authedUDFFuncList = udfFunctionMapper.queryAuthedUdfFunc(userId); getAuthorizedResourceList(udfFuncSet, authedUDFFuncList); resultList = new ArrayList<>(udfFuncSet); } result.put(Constants.DATA_LIST, resultList); putMsg(result, Status.SUCCESS); return result; } /** * authorized udf function * * @param loginUser login user * @param userId user id * @return authorized result code */ @Override public Map<String, Object> authorizedUDFFunction(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { return result; } List<UdfFunc> udfFuncs = udfFunctionMapper.queryAuthedUdfFunc(userId); result.put(Constants.DATA_LIST, udfFuncs); putMsg(result, Status.SUCCESS);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
return result; } /** * authorized file * * @param loginUser login user * @param userId user id * @return authorized result */ @Override public Map<String, Object> authorizedFile(User loginUser, Integer userId) { Map<String, Object> result = new HashMap<>(); if (isNotAdmin(loginUser, result)) { return result; } List<Resource> authedResources = queryResourceList(userId, Constants.AUTHORIZE_WRITABLE_PERM); Visitor visitor = new ResourceTreeVisitor(authedResources); String visit = JSONUtils.toJsonString(visitor.visit(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); logger.info(visit); String jsonTreeStr = JSONUtils.toJsonString(visitor.visit().getChildren(), SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS); logger.info(jsonTreeStr); result.put(Constants.DATA_LIST, visitor.visit().getChildren()); putMsg(result,Status.SUCCESS); return result; } /** * get authorized resource list * * @param resourceSet resource set * @param authedResourceList authorized resource list
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
*/ private void getAuthorizedResourceList(Set<?> resourceSet, List<?> authedResourceList) { Set<?> authedResourceSet; if (CollectionUtils.isNotEmpty(authedResourceList)) { authedResourceSet = new HashSet<>(authedResourceList); resourceSet.removeAll(authedResourceSet); } } /** * get tenantCode by UserId * * @param userId user id * @param result return result * @return tenant code */ private String getTenantCode(int userId,Result<Object> result) { User user = userMapper.selectById(userId); if (user == null) { logger.error("user {} not exists", userId); putMsg(result, Status.USER_NOT_EXIST,userId); return null; } Tenant tenant = tenantMapper.queryById(user.getTenantId()); if (tenant == null) { logger.error("tenant not exists"); putMsg(result, Status.TENANT_NOT_EXIST); return null; } return tenant.getTenantCode(); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
/** * list all children id * @param resource resource * @param containSelf whether add self to children list * @return all children id */ List<Integer> listAllChildren(Resource resource,boolean containSelf) { List<Integer> childList = new ArrayList<>(); if (resource.getId() != -1 && containSelf) { childList.add(resource.getId()); } if (resource.isDirectory()) { listAllChildren(resource.getId(),childList); } return childList; } /** * list all children id * @param resourceId resource id * @param childList child list */ void listAllChildren(int resourceId,List<Integer> childList) { List<Integer> children = resourcesMapper.listChildren(resourceId); for (int childId : children) { childList.add(childId); listAllChildren(childId, childList); } } /** * query authored resource list (own and authorized)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ResourcesServiceImpl.java
* @param loginUser login user * @param type ResourceType * @return all authored resource list */ private List<Resource> queryAuthoredResourceList(User loginUser, ResourceType type) { List<Resource> relationResources; int userId = loginUser.getId(); if (isAdmin(loginUser)) { userId = 0; relationResources = new ArrayList<>(); } else { relationResources = queryResourceList(userId, 0); } List<Resource> ownResourceList = resourcesMapper.queryResourceListAuthored(userId, type.ordinal()); ownResourceList.addAll(relationResources); return ownResourceList; } /** * query resource list by userId and perm * @param userId userId * @param perm perm * @return resource list */ private List<Resource> queryResourceList(Integer userId, int perm) { List<Integer> resIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, perm); return CollectionUtils.isEmpty(resIds) ? new ArrayList<>() : resourcesMapper.queryResourceListById(resIds); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
* (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 org.apache.dolphinscheduler.api.service; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.service.impl.ResourcesServiceImpl; import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.spi.enums.ResourceType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.utils.CollectionUtils; import org.apache.dolphinscheduler.common.utils.FileUtils; import org.apache.dolphinscheduler.common.utils.HadoopUtils; import org.apache.dolphinscheduler.common.utils.PropertyUtils; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.UdfFunc; import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceMapper; import org.apache.dolphinscheduler.dao.mapper.ResourceUserMapper;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.Mock; import org.mockito.Mockito; import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PowerMockIgnore; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.mock.web.MockMultipartFile; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; /** * resources service test */ @RunWith(PowerMockRunner.class) @PowerMockIgnore({"sun.security.*", "javax.net.*"}) @PrepareForTest({HadoopUtils.class, PropertyUtils.class, FileUtils.class, org.apache.dolphinscheduler.api.utils.FileUtils.class})
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
public class ResourcesServiceTest { private static final Logger logger = LoggerFactory.getLogger(ResourcesServiceTest.class); @InjectMocks private ResourcesServiceImpl resourcesService; @Mock private ResourceMapper resourcesMapper; @Mock private TenantMapper tenantMapper; @Mock private HadoopUtils hadoopUtils; @Mock private UserMapper userMapper; @Mock private UdfFuncMapper udfFunctionMapper; @Mock private ProcessDefinitionMapper processDefinitionMapper; @Mock private ResourceUserMapper resourceUserMapper; @Before public void setUp() { PowerMockito.mockStatic(HadoopUtils.class); PowerMockito.mockStatic(FileUtils.class); PowerMockito.mockStatic(org.apache.dolphinscheduler.api.utils.FileUtils.class); try { PowerMockito.whenNew(HadoopUtils.class).withNoArguments().thenReturn(hadoopUtils); } catch (Exception e) { e.printStackTrace(); } PowerMockito.when(HadoopUtils.getInstance()).thenReturn(hadoopUtils);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
PowerMockito.mockStatic(PropertyUtils.class); } @Test public void testCreateResource() { PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); User user = new User(); Result result = resourcesService.createResource(user, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, null, -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(), result.getMsg()); MockMultipartFile mockMultipartFile = new MockMultipartFile("test.pdf", "".getBytes()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); result = resourcesService.createResource(user, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, mockMultipartFile, -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_FILE_IS_EMPTY.getMsg(), result.getMsg()); mockMultipartFile = new MockMultipartFile("test.pdf", "test.pdf", "pdf", "test".getBytes()); PowerMockito.when(FileUtils.suffix("test.pdf")).thenReturn("pdf"); PowerMockito.when(FileUtils.suffix("ResourcesServiceTest.jar")).thenReturn("jar"); result = resourcesService.createResource(user, "ResourcesServiceTest.jar", "ResourcesServiceTest", ResourceType.FILE, mockMultipartFile, -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_SUFFIX_FORBID_CHANGE.getMsg(), result.getMsg()); mockMultipartFile = new MockMultipartFile("ResourcesServiceTest.pdf", "ResourcesServiceTest.pdf", "pdf", "test".getBytes()); PowerMockito.when(FileUtils.suffix("ResourcesServiceTest.pdf")).thenReturn("pdf"); result = resourcesService.createResource(user, "ResourcesServiceTest.pdf", "ResourcesServiceTest", ResourceType.UDF, mockMultipartFile, -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.UDF_RESOURCE_SUFFIX_NOT_JAR.getMsg(), result.getMsg()); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
@Test public void testCreateDirecotry() { PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); User user = new User(); Result result = resourcesService.createDirectory(user, "directoryTest", "directory test", ResourceType.FILE, -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(), result.getMsg()); user.setId(1); user.setTenantId(1); Mockito.when(userMapper.selectById(1)).thenReturn(getUser()); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); Mockito.when(resourcesMapper.selectById(Mockito.anyInt())).thenReturn(null); result = resourcesService.createDirectory(user, "directoryTest", "directory test", ResourceType.FILE, 1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.PARENT_RESOURCE_NOT_EXIST.getMsg(), result.getMsg()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); Mockito.when(resourcesMapper.existResource("/directoryTest", 0, 0)).thenReturn(true); result = resourcesService.createDirectory(user, "directoryTest", "directory test", ResourceType.FILE, -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_EXIST.getMsg(), result.getMsg()); } @Test public void testUpdateResource() { PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); User user = new User();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
Result result = resourcesService.updateResource(user, 1, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, null); logger.info(result.toString()); Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(), result.getMsg()); Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); result = resourcesService.updateResource(user, 0, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, null); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg()); result = resourcesService.updateResource(user, 1, "ResourcesServiceTest", "ResourcesServiceTest", ResourceType.FILE, null); logger.info(result.toString()); Assert.assertEquals(Status.USER_NO_OPERATION_PERM.getMsg(), result.getMsg()); user.setId(1); Mockito.when(userMapper.selectById(1)).thenReturn(getUser()); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); PowerMockito.when(HadoopUtils.getHdfsFileName(Mockito.any(), Mockito.any(), Mockito.anyString())).thenReturn("test1"); try { Mockito.when(HadoopUtils.getInstance().exists(Mockito.any())).thenReturn(false); } catch (IOException e) { logger.error(e.getMessage(), e); } result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.UDF, null); Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg()); user.setId(1); Mockito.when(userMapper.queryDetailsById(1)).thenReturn(getUser()); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); try {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
Mockito.when(HadoopUtils.getInstance().exists(Mockito.any())).thenReturn(true); } catch (IOException e) { logger.error(e.getMessage(), e); } result = resourcesService.updateResource(user, 1, "ResourcesServiceTest.jar", "ResourcesServiceTest", ResourceType.FILE, null); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg()); Mockito.when(resourcesMapper.existResource("/ResourcesServiceTest1.jar", 0, 0)).thenReturn(true); result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.FILE, null); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_EXIST.getMsg(), result.getMsg()); Mockito.when(userMapper.selectById(Mockito.anyInt())).thenReturn(null); result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.UDF, null); logger.info(result.toString()); Assert.assertTrue(Status.USER_NOT_EXIST.getCode() == result.getCode()); Mockito.when(userMapper.selectById(1)).thenReturn(getUser()); Mockito.when(tenantMapper.queryById(Mockito.anyInt())).thenReturn(null); result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest", ResourceType.UDF, null); logger.info(result.toString()); Assert.assertEquals(Status.TENANT_NOT_EXIST.getMsg(), result.getMsg()); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); PowerMockito.when(HadoopUtils.getHdfsResourceFileName(Mockito.any(), Mockito.any())).thenReturn("test"); try { PowerMockito.when(HadoopUtils.getInstance().copy(Mockito.anyString(), Mockito.anyString(), true, true)).thenReturn(true); } catch (Exception e) { logger.error(e.getMessage(), e);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
} result = resourcesService.updateResource(user, 1, "ResourcesServiceTest1.jar", "ResourcesServiceTest1.jar", ResourceType.UDF, null); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg()); } @Test public void testQueryResourceListPaging() { User loginUser = new User(); loginUser.setUserType(UserType.ADMIN_USER); IPage<Resource> resourcePage = new Page<>(1, 10); resourcePage.setTotal(1); resourcePage.setRecords(getResourceList()); Mockito.when(resourcesMapper.queryResourcePaging(Mockito.any(Page.class), Mockito.eq(0), Mockito.eq(-1), Mockito.eq(0), Mockito.eq("test"), Mockito.any())).thenReturn(resourcePage); Result result = resourcesService.queryResourceListPaging(loginUser, -1, ResourceType.FILE, "test", 1, 10); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getCode(), (int)result.getCode()); PageInfo pageInfo = (PageInfo) result.getData(); Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getTotalList())); } @Test public void testQueryResourceList() { User loginUser = new User(); loginUser.setId(0); loginUser.setUserType(UserType.ADMIN_USER); Mockito.when(resourcesMapper.queryResourceListAuthored(0, 0)).thenReturn(getResourceList()); Map<String, Object> result = resourcesService.queryResourceList(loginUser, ResourceType.FILE); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); List<Resource> resourceList = (List<Resource>) result.get(Constants.DATA_LIST);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
Assert.assertTrue(CollectionUtils.isNotEmpty(resourceList)); } @Test public void testDelete() { User loginUser = new User(); loginUser.setId(0); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); try { Result result = resourcesService.delete(loginUser, 1); logger.info(result.toString()); Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(), result.getMsg()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource()); result = resourcesService.delete(loginUser, 2); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg()); result = resourcesService.delete(loginUser, 2); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg()); loginUser.setUserType(UserType.ADMIN_USER); loginUser.setTenantId(2); Mockito.when(userMapper.selectById(Mockito.anyInt())).thenReturn(loginUser); result = resourcesService.delete(loginUser, 1); logger.info(result.toString()); Assert.assertEquals(Status.TENANT_NOT_EXIST.getMsg(), result.getMsg());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
loginUser.setTenantId(1); Mockito.when(hadoopUtils.delete(Mockito.anyString(), Mockito.anyBoolean())).thenReturn(true); Mockito.when(processDefinitionMapper.listResources()).thenReturn(getResources()); Mockito.when(resourcesMapper.deleteIds(Mockito.any())).thenReturn(1); Mockito.when(resourceUserMapper.deleteResourceUserArray(Mockito.anyInt(), Mockito.any())).thenReturn(1); result = resourcesService.delete(loginUser, 1); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg()); } catch (Exception e) { logger.error("delete error", e); Assert.assertTrue(false); } } @Test public void testVerifyResourceName() { User user = new User(); user.setId(1); Mockito.when(resourcesMapper.existResource("/ResourcesServiceTest.jar", 0, 0)).thenReturn(true); Result result = resourcesService.verifyResourceName("/ResourcesServiceTest.jar", ResourceType.FILE, user); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_EXIST.getMsg(), result.getMsg()); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); String unExistFullName = "/test.jar"; try { Mockito.when(hadoopUtils.exists(unExistFullName)).thenReturn(false); } catch (IOException e) { logger.error("hadoop error", e); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
result = resourcesService.verifyResourceName("/test.jar", ResourceType.FILE, user); logger.info(result.toString()); Assert.assertEquals(Status.TENANT_NOT_EXIST.getMsg(), result.getMsg()); user.setTenantId(1); try { Mockito.when(hadoopUtils.exists("test")).thenReturn(true); } catch (IOException e) { logger.error("hadoop error", e); } PowerMockito.when(HadoopUtils.getHdfsResourceFileName("123", "test1")).thenReturn("test"); result = resourcesService.verifyResourceName("/ResourcesServiceTest.jar", ResourceType.FILE, user); logger.info(result.toString()); Assert.assertTrue(Status.RESOURCE_EXIST.getCode() == result.getCode()); result = resourcesService.verifyResourceName("test2", ResourceType.FILE, user); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg()); } @Test public void testReadResource() { PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); Result result = resourcesService.readResource(1, 1, 10); logger.info(result.toString()); Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(), result.getMsg()); Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); result = resourcesService.readResource(2, 1, 10);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg()); PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("class"); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); result = resourcesService.readResource(1, 1, 10); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg()); PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("jar"); PowerMockito.when(FileUtils.suffix("ResourcesServiceTest.jar")).thenReturn("jar"); result = resourcesService.readResource(1, 1, 10); logger.info(result.toString()); Assert.assertTrue(Status.USER_NOT_EXIST.getCode() == result.getCode()); Mockito.when(userMapper.selectById(1)).thenReturn(getUser()); result = resourcesService.readResource(1, 1, 10); logger.info(result.toString()); Assert.assertEquals(Status.TENANT_NOT_EXIST.getMsg(), result.getMsg()); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); try { Mockito.when(hadoopUtils.exists(Mockito.anyString())).thenReturn(false); } catch (IOException e) { logger.error("hadoop error", e); } result = resourcesService.readResource(1, 1, 10); logger.info(result.toString()); Assert.assertTrue(Status.RESOURCE_FILE_NOT_EXIST.getCode() == result.getCode());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
try { Mockito.when(hadoopUtils.exists(null)).thenReturn(true); Mockito.when(hadoopUtils.catFile(null, 1, 10)).thenReturn(getContent()); } catch (IOException e) { logger.error("hadoop error", e); } result = resourcesService.readResource(1, 1, 10); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg()); } @Test public void testOnlineCreateResource() { PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); PowerMockito.when(HadoopUtils.getHdfsResDir("hdfsdDir")).thenReturn("hdfsDir"); PowerMockito.when(HadoopUtils.getHdfsUdfDir("udfDir")).thenReturn("udfDir"); User user = getUser(); Result result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(), result.getMsg()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("class"); result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg()); try { PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("jar"); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/"); } catch (RuntimeException ex) { logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), ex.getMessage()); } Mockito.when(FileUtils.getUploadFilename(Mockito.anyString(), Mockito.anyString())).thenReturn("test"); PowerMockito.when(FileUtils.writeContent2File(Mockito.anyString(), Mockito.anyString())).thenReturn(true); result = resourcesService.onlineCreateResource(user, ResourceType.FILE, "test", "jar", "desc", "content", -1, "/"); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg()); } @Test public void testUpdateResourceContent() { User loginUser = new User(); loginUser.setId(0); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); Result result = resourcesService.updateResourceContent(1, "content"); logger.info(result.toString()); Assert.assertEquals(Status.HDFS_NOT_STARTUP.getMsg(), result.getMsg()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource()); result = resourcesService.updateResourceContent(2, "content"); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_NOT_EXIST.getMsg(), result.getMsg()); PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("class");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
result = resourcesService.updateResourceContent(1, "content"); logger.info(result.toString()); Assert.assertEquals(Status.RESOURCE_SUFFIX_NOT_SUPPORT_VIEW.getMsg(), result.getMsg()); PowerMockito.when(FileUtils.getResourceViewSuffixs()).thenReturn("jar"); PowerMockito.when(FileUtils.suffix("ResourcesServiceTest.jar")).thenReturn("jar"); result = resourcesService.updateResourceContent(1, "content"); logger.info(result.toString()); Assert.assertTrue(Status.USER_NOT_EXIST.getCode() == result.getCode()); Mockito.when(userMapper.selectById(1)).thenReturn(getUser()); result = resourcesService.updateResourceContent(1, "content"); logger.info(result.toString()); Assert.assertTrue(Status.TENANT_NOT_EXIST.getCode() == result.getCode()); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); Mockito.when(FileUtils.getUploadFilename(Mockito.anyString(), Mockito.anyString())).thenReturn("test"); PowerMockito.when(FileUtils.writeContent2File(Mockito.anyString(), Mockito.anyString())).thenReturn(true); result = resourcesService.updateResourceContent(1, "content"); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg()); } @Test public void testDownloadResource() { PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(true); Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant()); Mockito.when(userMapper.selectById(1)).thenReturn(getUser()); org.springframework.core.io.Resource resourceMock = Mockito.mock(org.springframework.core.io.Resource.class); try {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
org.springframework.core.io.Resource resource = resourcesService.downloadResource(1); Assert.assertNull(resource); Mockito.when(resourcesMapper.selectById(1)).thenReturn(getResource()); PowerMockito.when(org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(Mockito.any())).thenReturn(resourceMock); resource = resourcesService.downloadResource(1); Assert.assertNotNull(resource); } catch (Exception e) { logger.error("DownloadResource error", e); Assert.assertTrue(false); } } @Test public void testUnauthorizedFile() { User user = getUser(); Map<String, Object> result = resourcesService.unauthorizedFile(user, 1); logger.info(result.toString()); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); user.setUserType(UserType.ADMIN_USER); Mockito.when(resourcesMapper.queryResourceExceptUserId(1)).thenReturn(getResourceList()); result = resourcesService.unauthorizedFile(user, 1); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST); Assert.assertTrue(CollectionUtils.isNotEmpty(resources)); } @Test public void testUnauthorizedUDFFunction() { User user = getUser();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
Map<String, Object> result = resourcesService.unauthorizedUDFFunction(user, 1); logger.info(result.toString()); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); user.setUserType(UserType.ADMIN_USER); Mockito.when(udfFunctionMapper.queryUdfFuncExceptUserId(1)).thenReturn(getUdfFuncList()); result = resourcesService.unauthorizedUDFFunction(user, 1); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); List<UdfFunc> udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST); Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs)); } @Test public void testAuthorizedUDFFunction() { User user = getUser(); Map<String, Object> result = resourcesService.authorizedUDFFunction(user, 1); logger.info(result.toString()); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); user.setUserType(UserType.ADMIN_USER); Mockito.when(udfFunctionMapper.queryAuthedUdfFunc(1)).thenReturn(getUdfFuncList()); result = resourcesService.authorizedUDFFunction(user, 1); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); List<UdfFunc> udfFuncs = (List<UdfFunc>) result.get(Constants.DATA_LIST); Assert.assertTrue(CollectionUtils.isNotEmpty(udfFuncs)); } @Test
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
public void testAuthorizedFile() { User user = getUser(); Map<String, Object> result = resourcesService.authorizedFile(user, 1); logger.info(result.toString()); Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); user.setUserType(UserType.ADMIN_USER); List<Integer> resIds = new ArrayList<>(); resIds.add(1); Mockito.when(resourceUserMapper.queryResourcesIdListByUserIdAndPerm(Mockito.anyInt(), Mockito.anyInt())).thenReturn(resIds); Mockito.when(resourcesMapper.queryResourceListById(Mockito.any())).thenReturn(getResourceList()); result = resourcesService.authorizedFile(user, 1); logger.info(result.toString()); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); List<Resource> resources = (List<Resource>) result.get(Constants.DATA_LIST); Assert.assertTrue(CollectionUtils.isNotEmpty(resources)); } @Test public void testCatFile() { PowerMockito.when(PropertyUtils.getResUploadStartupState()).thenReturn(false); try { Mockito.when(hadoopUtils.exists(null)).thenReturn(true); Mockito.when(hadoopUtils.catFile(null, 1, 10)).thenReturn(getContent()); List<String> list = hadoopUtils.catFile(null, 1, 10); Assert.assertNotNull(list); } catch (IOException e) { logger.error("hadoop error", e); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
} private List<Resource> getResourceList() { List<Resource> resources = new ArrayList<>(); resources.add(getResource()); return resources; } private Tenant getTenant() { Tenant tenant = new Tenant(); tenant.setTenantCode("123"); return tenant; } private Resource getResource() { Resource resource = new Resource(); resource.setPid(-1); resource.setUserId(1); resource.setDescription("ResourcesServiceTest.jar"); resource.setAlias("ResourcesServiceTest.jar"); resource.setFullName("/ResourcesServiceTest.jar"); resource.setType(ResourceType.FILE); return resource; } private Resource getUdfResource() { Resource resource = new Resource(); resource.setUserId(1); resource.setDescription("udfTest"); resource.setAlias("udfTest.jar"); resource.setFullName("/udfTest.jar"); resource.setType(ResourceType.UDF); return resource; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ResourcesServiceTest.java
private UdfFunc getUdfFunc() { UdfFunc udfFunc = new UdfFunc(); udfFunc.setId(1); return udfFunc; } private List<UdfFunc> getUdfFuncList() { List<UdfFunc> udfFuncs = new ArrayList<>(); udfFuncs.add(getUdfFunc()); return udfFuncs; } private User getUser() { User user = new User(); user.setId(1); user.setTenantId(1); return user; } private List<String> getContent() { List<String> contentList = new ArrayList<>(); contentList.add("test"); return contentList; } private List<Map<String, Object>> getResources() { List<Map<String, Object>> resources = new ArrayList<>(); Map<String, Object> resource = new HashMap<>(); resource.put("id", 1); resource.put("resource_ids", "1"); resources.add(resource); return resources; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapper.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 org.apache.dolphinscheduler.dao.mapper; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.ibatis.annotations.Param; import java.util.List; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; /** * resource mapper interface */ public interface ResourceMapper extends BaseMapper<Resource> {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapper.java
/** * query resource list * @param fullName full name * @param userId userId * @param type type * @return resource list */ List<Resource> queryResourceList(@Param("fullName") String fullName, @Param("userId") int userId, @Param("type") int type); /** * query resource list * @param userId userId * @param type type * @return resource list
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapper.java
*/ List<Resource> queryResourceListAuthored(@Param("userId") int userId, @Param("type") int type); /** * resource page * @param page page * @param userId userId * @param id id * @param type type * @param searchVal searchVal * @param resIds resIds * @return resource page */ IPage<Resource> queryResourcePaging(IPage<Resource> page, @Param("userId") int userId, @Param("id") int id, @Param("type") int type, @Param("searchVal") String searchVal, @Param("resIds") List<Integer> resIds); /** * query resource except userId * @param userId userId * @return resource list */ List<Resource> queryResourceExceptUserId(@Param("userId") int userId); /** * list authorized resource * @param userId userId * @param resNames resNames * @param <T> T
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapper.java
* @return resource list */ <T> List<Resource> listAuthorizedResource(@Param("userId") int userId, @Param("resNames") T[] resNames); /** * list resources by id * @param resIds resIds * @return resource list */ List<Resource> queryResourceListById(@Param("resIds") List<Integer> resIds); /** * list authorized resource * @param userId userId * @param resIds resIds * @param <T> T * @return resource list */ <T> List<Resource> listAuthorizedResourceById(@Param("userId") int userId,@Param("resIds")T[] resIds); /** * delete resource by id array * @param resIds resource id array * @return delete num */ int deleteIds(@Param("resIds")Integer[] resIds); /** * list children * @param direcotyId directory id * @return resource id array */ List<Integer> listChildren(@Param("direcotyId") int direcotyId); /**
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapper.java
* query resource by full name or pid * @param fullName full name * @param type resource type * @return resource */ List<Resource> queryResource(@Param("fullName") String fullName,@Param("type") int type); /** * list resource by id array * @param resIds resource id array * @return resource list */ List<Resource> listResourceByIds(@Param("resIds")Integer[] resIds); /** * update resource * @param resourceList resource list * @return update num */ int batchUpdateResource(@Param("resourceList") List<Resource> resourceList); /** * check resource exist * @param fullName full name * @param userId userId * @param type type * @return true if exist else return null */ Boolean existResource(@Param("fullName") String fullName, @Param("userId") int userId, @Param("type") int type); }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapperTest.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapperTest.java
* limitations under the License. */ package org.apache.dolphinscheduler.dao.mapper; import static java.util.stream.Collectors.toList; import static org.hamcrest.Matchers.greaterThan; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.spi.enums.ResourceType; import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.utils.CollectionUtils; import org.apache.dolphinscheduler.dao.entity.Resource; import org.apache.dolphinscheduler.dao.entity.ResourcesUser; import org.apache.dolphinscheduler.dao.entity.Tenant; import org.apache.dolphinscheduler.dao.entity.User; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.annotation.Rollback; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.transaction.annotation.Transactional; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @RunWith(SpringRunner.class)
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapperTest.java
@SpringBootTest @Transactional @Rollback(true) public class ResourceMapperTest { @Autowired ResourceMapper resourceMapper; @Autowired ResourceUserMapper resourceUserMapper; @Autowired TenantMapper tenantMapper; @Autowired UserMapper userMapper; /** * insert * * @return Resource */ private Resource insertOne() { Resource resource = new Resource(); resource.setAlias("ut-resource"); resource.setFullName("/ut-resource"); resource.setPid(-1); resource.setDirectory(false);
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapperTest.java
resource.setType(ResourceType.FILE); resource.setUserId(111); int status = resourceMapper.insert(resource); if (status != 1) { Assert.fail("insert data error"); } return resource; } /** * create resource by user * * @param user user * @return Resource */ private Resource createResource(User user, boolean isDirectory, ResourceType resourceType, int pid, String alias, String fullName) { Resource resource = new Resource(); resource.setDirectory(isDirectory); resource.setType(resourceType); resource.setAlias(alias); resource.setFullName(fullName); resource.setUserId(user.getId()); int status = resourceMapper.insert(resource); if (status != 1) { Assert.fail("insert data error"); } return resource; } /** * create resource by user
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapperTest.java
* * @param user user * @return Resource */ private Resource createResource(User user) { String alias = String.format("ut-resource-%s", user.getUserName()); String fullName = String.format("/%s", alias); Resource resource = createResource(user, false, ResourceType.FILE, -1, alias, fullName); return resource; } /** * create user * * @return User */ private User createGeneralUser(String userName) { User user = new User(); user.setUserName(userName); user.setUserPassword("1"); user.setEmail("[email protected]"); user.setUserType(UserType.GENERAL_USER); user.setCreateTime(new Date()); user.setTenantId(1); user.setUpdateTime(new Date()); int status = userMapper.insert(user); if (status != 1) { Assert.fail("insert data error"); } return user;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapperTest.java
} /** * create resource user * * @return ResourcesUser */ private ResourcesUser createResourcesUser(Resource resource, User user) { ResourcesUser resourcesUser = new ResourcesUser(); resourcesUser.setCreateTime(new Date()); resourcesUser.setUpdateTime(new Date()); resourcesUser.setUserId(user.getId()); resourcesUser.setResourcesId(resource.getId()); resourcesUser.setPerm(7); resourceUserMapper.insert(resourcesUser); return resourcesUser; } @Test public void testInsert() { Resource resource = insertOne(); assertNotNull(resource.getId()); assertThat(resource.getId(), greaterThan(0)); } /** * test update */ @Test public void testUpdate() { Resource resource = insertOne();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapperTest.java
resource.setCreateTime(new Date()); int update = resourceMapper.updateById(resource); Assert.assertEquals(1, update); } /** * test delete */ @Test public void testDelete() { Resource resourceMap = insertOne(); int delete = resourceMapper.deleteById(resourceMap.getId()); Assert.assertEquals(1, delete); } /** * test query */ @Test public void testQuery() { Resource resource = insertOne(); List<Resource> resources = resourceMapper.selectList(null); Assert.assertNotEquals(resources.size(), 0); } /** * test query resource list */ @Test public void testQueryResourceList() { Resource resource = insertOne();
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapperTest.java
String alias = ""; int userId = resource.getUserId(); int type = resource.getType().ordinal(); List<Resource> resources = resourceMapper.queryResourceList( alias, userId, type ); Assert.assertNotEquals(resources.size(), 0); } /** * test page */ @Test public void testQueryResourcePaging() { Resource resource = insertOne(); ResourcesUser resourcesUser = new ResourcesUser(); resourcesUser.setResourcesId(resource.getId()); resourcesUser.setUserId(1110); resourceUserMapper.insert(resourcesUser); Page<Resource> page = new Page(1, 3); IPage<Resource> resourceIPage = resourceMapper.queryResourcePaging( page, 0, -1, resource.getType().ordinal(), "", new ArrayList<>() ); IPage<Resource> resourceIPage1 = resourceMapper.queryResourcePaging(
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapperTest.java
page, 1110, -1, resource.getType().ordinal(), "", null ); Assert.assertEquals(resourceIPage.getTotal(), 0); Assert.assertEquals(resourceIPage1.getTotal(), 0); } /** * test authed resource list */ @Test public void testQueryResourceListAuthored() { Resource resource = insertOne(); List<Integer> resIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(resource.getUserId(), Constants.AUTHORIZE_WRITABLE_PERM); List<Resource> resources = CollectionUtils.isEmpty(resIds) ? new ArrayList<>() : resourceMapper.queryResourceListById(resIds); ResourcesUser resourcesUser = new ResourcesUser(); resourcesUser.setResourcesId(resource.getId()); resourcesUser.setUserId(1110); resourcesUser.setPerm(Constants.AUTHORIZE_WRITABLE_PERM); resourceUserMapper.insert(resourcesUser); List<Integer> resIds1 = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(1110, Constants.AUTHORIZE_WRITABLE_PERM); List<Resource> resources1 = CollectionUtils.isEmpty(resIds1) ? new ArrayList<>() : resourceMapper.queryResourceListById(resIds1); Assert.assertEquals(0, resources.size()); Assert.assertNotEquals(0, resources1.size()); } /** * test authed resource list
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapperTest.java
*/ @Test public void testQueryAuthorizedResourceList() { Resource resource = insertOne(); List<Integer> resIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(resource.getUserId(), Constants.AUTHORIZE_WRITABLE_PERM); List<Resource> resources = CollectionUtils.isEmpty(resIds) ? new ArrayList<>() : resourceMapper.queryResourceListById(resIds); resourceMapper.deleteById(resource.getId()); Assert.assertEquals(0, resources.size()); } /** * test query resource expect userId */ @Test public void testQueryResourceExceptUserId() { Resource resource = insertOne(); List<Resource> resources = resourceMapper.queryResourceExceptUserId( 11111 ); Assert.assertNotEquals(resources.size(), 0); } /** * test query tenant code by resource name */ @Test public void testQueryTenantCodeByResourceName() { Tenant tenant = new Tenant(); tenant.setTenantCode("ut tenant code for resource"); int tenantInsertStatus = tenantMapper.insert(tenant); if (tenantInsertStatus != 1) { Assert.fail("insert tenant data error");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapperTest.java
} User user = new User(); user.setTenantId(tenant.getId()); user.setUserName("ut user"); int userInsertStatus = userMapper.insert(user); if (userInsertStatus != 1) { Assert.fail("insert user data error"); } Resource resource = insertOne(); resource.setUserId(user.getId()); int userUpdateStatus = resourceMapper.updateById(resource); if (userUpdateStatus != 1) { Assert.fail("update user data error"); } List<Resource> resourceList = resourceMapper.queryResource(resource.getFullName(), ResourceType.FILE.ordinal()); int resourceUserId = resourceList.get(0).getUserId(); User resourceUser = userMapper.selectById(resourceUserId); Tenant resourceTenant = tenantMapper.selectById(resourceUser.getTenantId()); Assert.assertEquals("ut tenant code for resource", resourceTenant.getTenantCode()); } @Test public void testListAuthorizedResource() { User generalUser1 = createGeneralUser("user1"); User generalUser2 = createGeneralUser("user2"); Resource resource = createResource(generalUser2); Resource unauthorizedResource = createResource(generalUser1); String[] resNames = new String[]{resource.getFullName(), unauthorizedResource.getFullName()};
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapperTest.java
List<Resource> resources = resourceMapper.listAuthorizedResource(generalUser2.getId(), resNames); Assert.assertEquals(generalUser2.getId(), resource.getUserId()); Assert.assertFalse(resources.stream().map(t -> t.getFullName()).collect(toList()).containsAll(Arrays.asList(resNames))); createResourcesUser(unauthorizedResource, generalUser2); List<Resource> authorizedResources = resourceMapper.listAuthorizedResource(generalUser2.getId(), resNames); Assert.assertTrue(authorizedResources.stream().map(t -> t.getFullName()).collect(toList()).containsAll(Arrays.asList(resNames))); } @Test public void deleteIdsTest() { User generalUser1 = createGeneralUser("user1"); User generalUser = createGeneralUser("user"); Resource resource = createResource(generalUser); Resource resource1 = createResource(generalUser1); List<Integer> resourceList = new ArrayList<>(); resourceList.add(resource.getId()); resourceList.add(resource1.getId()); int result = resourceMapper.deleteIds(resourceList.toArray(new Integer[resourceList.size()])); Assert.assertEquals(result, 2); } @Test public void queryResourceListAuthoredTest() { User generalUser1 = createGeneralUser("user1"); User generalUser2 = createGeneralUser("user2"); Resource resource = createResource(generalUser1); createResourcesUser(resource, generalUser2); List<Resource> resourceList = resourceMapper.queryResourceListAuthored(generalUser2.getId(), ResourceType.FILE.ordinal());
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,408
[Feature][API] the private function 'checkResourceExists' should remove the userId condition
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description the private function 'checkResourceExists' should remove the userId condition; If we want to check the resouce exists or not, we should not user the userId condition. Because the resource was created by user, it's userId was the user who created it. If we user the userID '0', It won't take effect. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6408
https://github.com/apache/dolphinscheduler/pull/6409
86c85114b23317b9f791e091101fa6289e9d6b7c
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
2021-09-29T04:44:58Z
java
2021-10-31T13:26:48Z
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ResourceMapperTest.java
Assert.assertNotNull(resourceList); resourceList = resourceMapper.queryResourceListAuthored(generalUser2.getId(), ResourceType.FILE.ordinal()); Assert.assertFalse(resourceList.contains(resource)); } @Test public void batchUpdateResourceTest() { User generalUser1 = createGeneralUser("user1"); Resource resource = createResource(generalUser1); resource.setFullName(String.format("%s-update", resource.getFullName())); resource.setUpdateTime(new Date()); List<Resource> resourceList = new ArrayList<>(); resourceList.add(resource); int result = resourceMapper.batchUpdateResource(resourceList); if (result != resourceList.size()) { Assert.fail("batch update resource data error"); } } @Test public void existResourceTest() { String fullName = "/ut-resource"; int userId = 111; int type = ResourceType.FILE.getCode(); Assert.assertNull(resourceMapper.existResource(fullName, userId, type)); insertOne(); Assert.assertTrue(resourceMapper.existResource(fullName, userId, type)); } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,653
[Bug] [Server] Netty client create too many channel and make busy network
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version: dev When after the stress test, I found the busy network between master and worker, but no any log. And then I dump the network package and found many heartbeat report. ![c5c20ffb4c6220c43924557b0478fd5](https://user-images.githubusercontent.com/11962619/139615061-c16f141f-e8a3-412c-9364-7f3418ccc5a9.png) I try to run the test method, which use netty client to send many commands, and the channel created number is equal to the commands number. When debug, I found that the key of map to manage channels is Host, a Object without override hashcode and equals. ### What you expected to happen Netty client create less channel. ### How to reproduce Run the test method, which use netty client to send many commands. ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6653
https://github.com/apache/dolphinscheduler/pull/6654
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
daca3baf6662b9bcf3de856722ece79aad753773
2021-11-01T02:55:40Z
java
2021-11-01T04:18:39Z
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/utils/Host.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 org.apache.dolphinscheduler.remote.utils; import static org.apache.dolphinscheduler.common.Constants.COLON; import java.io.Serializable; /** * server address */ public class Host implements Serializable { /** * address */ private String address;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,653
[Bug] [Server] Netty client create too many channel and make busy network
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version: dev When after the stress test, I found the busy network between master and worker, but no any log. And then I dump the network package and found many heartbeat report. ![c5c20ffb4c6220c43924557b0478fd5](https://user-images.githubusercontent.com/11962619/139615061-c16f141f-e8a3-412c-9364-7f3418ccc5a9.png) I try to run the test method, which use netty client to send many commands, and the channel created number is equal to the commands number. When debug, I found that the key of map to manage channels is Host, a Object without override hashcode and equals. ### What you expected to happen Netty client create less channel. ### How to reproduce Run the test method, which use netty client to send many commands. ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6653
https://github.com/apache/dolphinscheduler/pull/6654
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
daca3baf6662b9bcf3de856722ece79aad753773
2021-11-01T02:55:40Z
java
2021-11-01T04:18:39Z
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/utils/Host.java
/** * ip */ private String ip; /** * port */ private int port; public Host() { } public Host(String ip, int port) { this.ip = ip; this.port = port; this.address = ip + COLON + port; } public Host(String address) { String[] parts = splitAddress(address); this.ip = parts[0]; this.port = Integer.parseInt(parts[1]); this.address = address; } public String getAddress() { return address; } public void setAddress(String address) { String[] parts = splitAddress(address); this.ip = parts[0]; this.port = Integer.parseInt(parts[1]); this.address = address; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,653
[Bug] [Server] Netty client create too many channel and make busy network
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version: dev When after the stress test, I found the busy network between master and worker, but no any log. And then I dump the network package and found many heartbeat report. ![c5c20ffb4c6220c43924557b0478fd5](https://user-images.githubusercontent.com/11962619/139615061-c16f141f-e8a3-412c-9364-7f3418ccc5a9.png) I try to run the test method, which use netty client to send many commands, and the channel created number is equal to the commands number. When debug, I found that the key of map to manage channels is Host, a Object without override hashcode and equals. ### What you expected to happen Netty client create less channel. ### How to reproduce Run the test method, which use netty client to send many commands. ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6653
https://github.com/apache/dolphinscheduler/pull/6654
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
daca3baf6662b9bcf3de856722ece79aad753773
2021-11-01T02:55:40Z
java
2021-11-01T04:18:39Z
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/utils/Host.java
public String getIp() { return ip; } public void setIp(String ip) { this.ip = ip; this.address = ip + COLON + port; } public int getPort() { return port; } public void setPort(int port) { this.port = port; this.address = ip + COLON + port; } /** * address convert host * * @param address address * @return host */ public static Host of(String address) { String[] parts = splitAddress(address); return new Host(parts[0], Integer.parseInt(parts[1])); } /** * address convert host * * @param address address * @return host */
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,653
[Bug] [Server] Netty client create too many channel and make busy network
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened version: dev When after the stress test, I found the busy network between master and worker, but no any log. And then I dump the network package and found many heartbeat report. ![c5c20ffb4c6220c43924557b0478fd5](https://user-images.githubusercontent.com/11962619/139615061-c16f141f-e8a3-412c-9364-7f3418ccc5a9.png) I try to run the test method, which use netty client to send many commands, and the channel created number is equal to the commands number. When debug, I found that the key of map to manage channels is Host, a Object without override hashcode and equals. ### What you expected to happen Netty client create less channel. ### How to reproduce Run the test method, which use netty client to send many commands. ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6653
https://github.com/apache/dolphinscheduler/pull/6654
3a8b80971ba4b23b8e919ad04e074bd273c40c9a
daca3baf6662b9bcf3de856722ece79aad753773
2021-11-01T02:55:40Z
java
2021-11-01T04:18:39Z
dolphinscheduler-remote/src/main/java/org/apache/dolphinscheduler/remote/utils/Host.java
public static String[] splitAddress(String address) { if (address == null) { throw new IllegalArgumentException("Host : address is null."); } String[] parts = address.split(COLON); if (parts.length != 2) { throw new IllegalArgumentException(String.format("Host : %s illegal.", address)); } return parts; } /** * whether old version * * @param address address * @return old version is true , otherwise is false */ public static Boolean isOldVersion(String address) { String[] parts = address.split(COLON); return parts.length != 2; } @Override public String toString() { return "Host{" + "address='" + address + '\'' + ", ip='" + ip + '\'' + ", port=" + port + '}'; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,625
[Bug] [Standalone Server] Standalone server load plugin from fixed maven loacl repository path
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev 开发分支 When use standalone server, the DolphinPluginManager looks for plugin dependencies from local maven repository. but the local maven repository is a fixed value in `DolphinPluginManagerConfig.java` who's value is `${user.home}/.m2/repository`. 当使用本地单机开发时,插件加载器会从本地Maven仓库加载插件,但是本地仓库的值是在代码中写死的: `${user.home}/.m2/repository`. ![图片](https://user-images.githubusercontent.com/23203149/139200190-9267993e-6df7-4b5c-a443-4aad86cf5a78.png) In my developement envirionment, I set the maven local repository path (localRepository) to `D:\\repository` in `${user.home}/.m2/settings.xml`. 在我的开发环境中,我在Maven的配置文件`${user.home}/.m2/settings.xml`中设置了本地仓库(localRepository)的地址 ![Local Maven Repository Settings](https://user-images.githubusercontent.com/23203149/139199519-7c7705a3-5d3d-4931-93ce-e2d1affc137f.png) so that the plugin manager could not load plugin correctly 因此,插件加载器无法正确加载插件 ### What you expected to happen * we should load from settings.xml firstly 1. load from `${user.home}/.m2/settings.xml` 2. if `${user.home}/.m2/settings.xml` not exists, load from `${MAVEN_HOME}/conf/settings.xml` * if settings.xml not exists or the node `localRepository` not exists in settings.xml, use default value ### How to reproduce * set local repository into another path in ide * start standalone server ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6625
https://github.com/apache/dolphinscheduler/pull/6626
f5d8356dc310ab942039834ceff6af1cf1f9f83c
61a8726ccc42a2adba8cdc859e3c3271099fdade
2021-10-28T06:34:54Z
java
2021-11-03T10:46:25Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginManagerConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 org.apache.dolphinscheduler.spi.plugin; import static java.lang.String.format; import static java.util.Objects.requireNonNull; import java.io.File; import java.util.List; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; /** * Dolphin Scheduler Plugin Manager Config */ public class DolphinPluginManagerConfig {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,625
[Bug] [Standalone Server] Standalone server load plugin from fixed maven loacl repository path
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev 开发分支 When use standalone server, the DolphinPluginManager looks for plugin dependencies from local maven repository. but the local maven repository is a fixed value in `DolphinPluginManagerConfig.java` who's value is `${user.home}/.m2/repository`. 当使用本地单机开发时,插件加载器会从本地Maven仓库加载插件,但是本地仓库的值是在代码中写死的: `${user.home}/.m2/repository`. ![图片](https://user-images.githubusercontent.com/23203149/139200190-9267993e-6df7-4b5c-a443-4aad86cf5a78.png) In my developement envirionment, I set the maven local repository path (localRepository) to `D:\\repository` in `${user.home}/.m2/settings.xml`. 在我的开发环境中,我在Maven的配置文件`${user.home}/.m2/settings.xml`中设置了本地仓库(localRepository)的地址 ![Local Maven Repository Settings](https://user-images.githubusercontent.com/23203149/139199519-7c7705a3-5d3d-4931-93ce-e2d1affc137f.png) so that the plugin manager could not load plugin correctly 因此,插件加载器无法正确加载插件 ### What you expected to happen * we should load from settings.xml firstly 1. load from `${user.home}/.m2/settings.xml` 2. if `${user.home}/.m2/settings.xml` not exists, load from `${MAVEN_HOME}/conf/settings.xml` * if settings.xml not exists or the node `localRepository` not exists in settings.xml, use default value ### How to reproduce * set local repository into another path in ide * start standalone server ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6625
https://github.com/apache/dolphinscheduler/pull/6626
f5d8356dc310ab942039834ceff6af1cf1f9f83c
61a8726ccc42a2adba8cdc859e3c3271099fdade
2021-10-28T06:34:54Z
java
2021-11-03T10:46:25Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginManagerConfig.java
/** * The dir of the Alert Plugin in. * When AlertServer is running on the server, it will load the Alert Plugin from this directory. */ private File installedPluginsDir; /** * The plugin should be load. * The installedPluginsDir is empty when we development and run server in IDEA. Then we can config which plugin should be load by param name alert.plugin.binding in the alert.properties file */ private List<String> plugins; /** * Development, When AlertServer is running on IDE, AlertPluginLoad can load Alert Plugin from local Repository. */ private String mavenLocalRepository = System.getProperty("user.home") + "/.m2/repository"; private List<String> mavenRemoteRepository = ImmutableList.of("http://repo1.maven.org/maven2/");
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,625
[Bug] [Standalone Server] Standalone server load plugin from fixed maven loacl repository path
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev 开发分支 When use standalone server, the DolphinPluginManager looks for plugin dependencies from local maven repository. but the local maven repository is a fixed value in `DolphinPluginManagerConfig.java` who's value is `${user.home}/.m2/repository`. 当使用本地单机开发时,插件加载器会从本地Maven仓库加载插件,但是本地仓库的值是在代码中写死的: `${user.home}/.m2/repository`. ![图片](https://user-images.githubusercontent.com/23203149/139200190-9267993e-6df7-4b5c-a443-4aad86cf5a78.png) In my developement envirionment, I set the maven local repository path (localRepository) to `D:\\repository` in `${user.home}/.m2/settings.xml`. 在我的开发环境中,我在Maven的配置文件`${user.home}/.m2/settings.xml`中设置了本地仓库(localRepository)的地址 ![Local Maven Repository Settings](https://user-images.githubusercontent.com/23203149/139199519-7c7705a3-5d3d-4931-93ce-e2d1affc137f.png) so that the plugin manager could not load plugin correctly 因此,插件加载器无法正确加载插件 ### What you expected to happen * we should load from settings.xml firstly 1. load from `${user.home}/.m2/settings.xml` 2. if `${user.home}/.m2/settings.xml` not exists, load from `${MAVEN_HOME}/conf/settings.xml` * if settings.xml not exists or the node `localRepository` not exists in settings.xml, use default value ### How to reproduce * set local repository into another path in ide * start standalone server ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6625
https://github.com/apache/dolphinscheduler/pull/6626
f5d8356dc310ab942039834ceff6af1cf1f9f83c
61a8726ccc42a2adba8cdc859e3c3271099fdade
2021-10-28T06:34:54Z
java
2021-11-03T10:46:25Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginManagerConfig.java
File getInstalledPluginsDir() { return installedPluginsDir; } /** * @param pluginDir plugin directory */ public void setInstalledPluginsDir(String pluginDir) { requireNonNull(pluginDir, "pluginDir can not be null"); File pluginDirFile = new File(pluginDir); if (!pluginDirFile.exists()) { throw new IllegalArgumentException(format("plugin dir not exists ! %s", pluginDirFile.getPath())); } this.installedPluginsDir = pluginDirFile; } public List<String> getPlugins() { return plugins; } public DolphinPluginManagerConfig setPlugins(List<String> plugins) { this.plugins = plugins; return this; } /** * When development and run server in IDE, this method can set plugins in alert.properties . * Then when you start AlertServer in IDE, the plugin can be load. * eg: * file: alert.properties * alert.plugin=\ * ../dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/pom.xml, \ * ../dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/pom.xml *
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,625
[Bug] [Standalone Server] Standalone server load plugin from fixed maven loacl repository path
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened branch: dev 开发分支 When use standalone server, the DolphinPluginManager looks for plugin dependencies from local maven repository. but the local maven repository is a fixed value in `DolphinPluginManagerConfig.java` who's value is `${user.home}/.m2/repository`. 当使用本地单机开发时,插件加载器会从本地Maven仓库加载插件,但是本地仓库的值是在代码中写死的: `${user.home}/.m2/repository`. ![图片](https://user-images.githubusercontent.com/23203149/139200190-9267993e-6df7-4b5c-a443-4aad86cf5a78.png) In my developement envirionment, I set the maven local repository path (localRepository) to `D:\\repository` in `${user.home}/.m2/settings.xml`. 在我的开发环境中,我在Maven的配置文件`${user.home}/.m2/settings.xml`中设置了本地仓库(localRepository)的地址 ![Local Maven Repository Settings](https://user-images.githubusercontent.com/23203149/139199519-7c7705a3-5d3d-4931-93ce-e2d1affc137f.png) so that the plugin manager could not load plugin correctly 因此,插件加载器无法正确加载插件 ### What you expected to happen * we should load from settings.xml firstly 1. load from `${user.home}/.m2/settings.xml` 2. if `${user.home}/.m2/settings.xml` not exists, load from `${MAVEN_HOME}/conf/settings.xml` * if settings.xml not exists or the node `localRepository` not exists in settings.xml, use default value ### How to reproduce * set local repository into another path in ide * start standalone server ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6625
https://github.com/apache/dolphinscheduler/pull/6626
f5d8356dc310ab942039834ceff6af1cf1f9f83c
61a8726ccc42a2adba8cdc859e3c3271099fdade
2021-10-28T06:34:54Z
java
2021-11-03T10:46:25Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginManagerConfig.java
* @param plugins plugins * @return DolphinPluginManagerConfig */ public DolphinPluginManagerConfig setPlugins(String plugins) { if (plugins == null) { this.plugins = null; } else { this.plugins = ImmutableList.copyOf(Splitter.on(',').omitEmptyStrings().trimResults().split(plugins)); } return this; } String getMavenLocalRepository() { return mavenLocalRepository; } public void setMavenLocalRepository(String mavenLocalRepository) { this.mavenLocalRepository = mavenLocalRepository; } List<String> getMavenRemoteRepository() { return mavenRemoteRepository; } public DolphinPluginManagerConfig setMavenRemoteRepository(List<String> mavenRemoteRepository) { this.mavenRemoteRepository = mavenRemoteRepository; return this; } public DolphinPluginManagerConfig setMavenRemoteRepository(String mavenRemoteRepository) { this.mavenRemoteRepository = ImmutableList.copyOf(Splitter.on(',').omitEmptyStrings().trimResults().split(mavenRemoteRepository)); return this; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,689
[Bug] [Standalone Server] DolphinPluginManagerConfig get maven sttings does not check file exists
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened i created a pr #6626 to fix #6625, but if forget to check if `the settings.xml` in the code. I feel very sorry about this~ if `~/.m2/settings.xml` or `${MAVEN_HOME}/conf/settings.xml` does not exists, will cause FileNotFound exception ### What you expected to happen check file exists ### How to reproduce * remove ~/.m2/settings.xml and the start the server ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6689
https://github.com/apache/dolphinscheduler/pull/6691
66fbcae9ddd6c0ca925c24ef01345fc793d85586
71047db39ea97373411a674ab0f3efe647f28a9d
2021-11-04T02:18:15Z
java
2021-11-04T12:17:53Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginManagerConfig.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,689
[Bug] [Standalone Server] DolphinPluginManagerConfig get maven sttings does not check file exists
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened i created a pr #6626 to fix #6625, but if forget to check if `the settings.xml` in the code. I feel very sorry about this~ if `~/.m2/settings.xml` or `${MAVEN_HOME}/conf/settings.xml` does not exists, will cause FileNotFound exception ### What you expected to happen check file exists ### How to reproduce * remove ~/.m2/settings.xml and the start the server ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6689
https://github.com/apache/dolphinscheduler/pull/6691
66fbcae9ddd6c0ca925c24ef01345fc793d85586
71047db39ea97373411a674ab0f3efe647f28a9d
2021-11-04T02:18:15Z
java
2021-11-04T12:17:53Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginManagerConfig.java
* * 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 org.apache.dolphinscheduler.spi.plugin; import static java.lang.String.format; import static java.util.Objects.requireNonNull; import org.apache.dolphinscheduler.spi.utils.StringUtils; import java.io.File; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; import javax.xml.XMLConstants; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import com.google.common.base.Splitter; import com.google.common.collect.ImmutableList; /** * Dolphin Scheduler Plugin Manager Config */ public class DolphinPluginManagerConfig {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,689
[Bug] [Standalone Server] DolphinPluginManagerConfig get maven sttings does not check file exists
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened i created a pr #6626 to fix #6625, but if forget to check if `the settings.xml` in the code. I feel very sorry about this~ if `~/.m2/settings.xml` or `${MAVEN_HOME}/conf/settings.xml` does not exists, will cause FileNotFound exception ### What you expected to happen check file exists ### How to reproduce * remove ~/.m2/settings.xml and the start the server ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6689
https://github.com/apache/dolphinscheduler/pull/6691
66fbcae9ddd6c0ca925c24ef01345fc793d85586
71047db39ea97373411a674ab0f3efe647f28a9d
2021-11-04T02:18:15Z
java
2021-11-04T12:17:53Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginManagerConfig.java
private static final Logger logger = LoggerFactory.getLogger(DolphinPluginManagerConfig.class); /** * The dir of the Alert Plugin in. * When AlertServer is running on the server, it will load the Alert Plugin from this directory. */ private File installedPluginsDir; /** * The plugin should be load. * The installedPluginsDir is empty when we development and run server in IDEA. Then we can config which plugin should be load by param name alert.plugin.binding in the alert.properties file */ private List<String> plugins; /** * Development, When AlertServer is running on IDE, AlertPluginLoad can load Alert Plugin from local Repository. */ private final String defaultLocalRepository = System.getProperty("user.home") + "/.m2/repository"; private String mavenLocalRepository = getMavenLocalRepositoryOrDefault(defaultLocalRepository); private List<String> mavenRemoteRepository = ImmutableList.of("http://repo1.maven.org/maven2/"); File getInstalledPluginsDir() { return installedPluginsDir; } /** * @param pluginDir plugin directory */ public void setInstalledPluginsDir(String pluginDir) { requireNonNull(pluginDir, "pluginDir can not be null"); File pluginDirFile = new File(pluginDir); if (!pluginDirFile.exists()) { throw new IllegalArgumentException(format("plugin dir not exists ! %s", pluginDirFile.getPath()));
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,689
[Bug] [Standalone Server] DolphinPluginManagerConfig get maven sttings does not check file exists
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened i created a pr #6626 to fix #6625, but if forget to check if `the settings.xml` in the code. I feel very sorry about this~ if `~/.m2/settings.xml` or `${MAVEN_HOME}/conf/settings.xml` does not exists, will cause FileNotFound exception ### What you expected to happen check file exists ### How to reproduce * remove ~/.m2/settings.xml and the start the server ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6689
https://github.com/apache/dolphinscheduler/pull/6691
66fbcae9ddd6c0ca925c24ef01345fc793d85586
71047db39ea97373411a674ab0f3efe647f28a9d
2021-11-04T02:18:15Z
java
2021-11-04T12:17:53Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginManagerConfig.java
} this.installedPluginsDir = pluginDirFile; } public List<String> getPlugins() { return plugins; } public DolphinPluginManagerConfig setPlugins(List<String> plugins) { this.plugins = plugins; return this; } /** * When development and run server in IDE, this method can set plugins in alert.properties . * Then when you start AlertServer in IDE, the plugin can be load. * eg: * file: alert.properties * alert.plugin=\ * ../dolphinscheduler-alert-plugin/dolphinscheduler-alert-email/pom.xml, \ * ../dolphinscheduler-alert-plugin/dolphinscheduler-alert-wechat/pom.xml * * @param plugins plugins * @return DolphinPluginManagerConfig */ public DolphinPluginManagerConfig setPlugins(String plugins) { if (plugins == null) { this.plugins = null; } else { this.plugins = ImmutableList.copyOf(Splitter.on(',').omitEmptyStrings().trimResults().split(plugins)); } return this; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,689
[Bug] [Standalone Server] DolphinPluginManagerConfig get maven sttings does not check file exists
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened i created a pr #6626 to fix #6625, but if forget to check if `the settings.xml` in the code. I feel very sorry about this~ if `~/.m2/settings.xml` or `${MAVEN_HOME}/conf/settings.xml` does not exists, will cause FileNotFound exception ### What you expected to happen check file exists ### How to reproduce * remove ~/.m2/settings.xml and the start the server ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6689
https://github.com/apache/dolphinscheduler/pull/6691
66fbcae9ddd6c0ca925c24ef01345fc793d85586
71047db39ea97373411a674ab0f3efe647f28a9d
2021-11-04T02:18:15Z
java
2021-11-04T12:17:53Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginManagerConfig.java
String getMavenLocalRepository() { return mavenLocalRepository; } public void setMavenLocalRepository(String mavenLocalRepository) { this.mavenLocalRepository = mavenLocalRepository; } List<String> getMavenRemoteRepository() { return mavenRemoteRepository; } /** * Get local repository from maven settings.xml if available. * <p> * if System environment does not exists settings.xml, return the default value. * </p> * * @param defaultRepository default repository path. * @return local repository path. */ private String getMavenLocalRepositoryOrDefault(String defaultRepository) { Path settingsXmlPath = getMavenSettingsXmlFromUserHome(); if (settingsXmlPath == null) { logger.info("User home does not exists maven settings.xml"); settingsXmlPath = getMavenSettingsXmlFromEvn(); } if (settingsXmlPath == null) { logger.info("Maven home does not exists maven settings.xml, use default"); return defaultRepository;
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,689
[Bug] [Standalone Server] DolphinPluginManagerConfig get maven sttings does not check file exists
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened i created a pr #6626 to fix #6625, but if forget to check if `the settings.xml` in the code. I feel very sorry about this~ if `~/.m2/settings.xml` or `${MAVEN_HOME}/conf/settings.xml` does not exists, will cause FileNotFound exception ### What you expected to happen check file exists ### How to reproduce * remove ~/.m2/settings.xml and the start the server ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6689
https://github.com/apache/dolphinscheduler/pull/6691
66fbcae9ddd6c0ca925c24ef01345fc793d85586
71047db39ea97373411a674ab0f3efe647f28a9d
2021-11-04T02:18:15Z
java
2021-11-04T12:17:53Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginManagerConfig.java
} DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder; try { try { factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true); factory.setFeature("http://xml.org/sax/features/external-general-entities", false); factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false); factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, ""); factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, ""); } catch (Exception e) { logger.warn("Error at parse settings.xml, setting security features: {}", e.getLocalizedMessage()); } documentBuilder = factory.newDocumentBuilder(); Document document = documentBuilder.parse(settingsXmlPath.toFile()); String localRepositoryNodeTag = "localRepository"; NodeList nodeList = document.getElementsByTagName(localRepositoryNodeTag); int length = nodeList.getLength(); if (length <= 0) { logger.info("File {} does not contains node named {}", settingsXmlPath, localRepositoryNodeTag); return defaultRepository; } for (int i = 0; i < length; i++) { Node node = nodeList.item(i); String content = node.getTextContent(); if (StringUtils.isNotEmpty(content) && StringUtils.isNotBlank(content)) {
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,689
[Bug] [Standalone Server] DolphinPluginManagerConfig get maven sttings does not check file exists
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened i created a pr #6626 to fix #6625, but if forget to check if `the settings.xml` in the code. I feel very sorry about this~ if `~/.m2/settings.xml` or `${MAVEN_HOME}/conf/settings.xml` does not exists, will cause FileNotFound exception ### What you expected to happen check file exists ### How to reproduce * remove ~/.m2/settings.xml and the start the server ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6689
https://github.com/apache/dolphinscheduler/pull/6691
66fbcae9ddd6c0ca925c24ef01345fc793d85586
71047db39ea97373411a674ab0f3efe647f28a9d
2021-11-04T02:18:15Z
java
2021-11-04T12:17:53Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginManagerConfig.java
Path localRepositoryPath = Paths.get(content); if (Files.exists(localRepositoryPath)) { logger.info("Got local repository path {}", content); return content; } } } return defaultRepository; } catch (Exception e) { logger.error(e.getLocalizedMessage(), e); return defaultRepository; } } /** * Get maven settings.xml file path from "${user.home}/.m2" * <p> * if "${user.home}/.m2/settings.xml" does not exist, * null will be returned * </p> * * @return settings.xml file path, could be null */ private Path getMavenSettingsXmlFromUserHome() { String userHome = System.getProperty("user.home"); Path settingsXmlPath = null; if (!StringUtils.isEmpty(userHome)) { settingsXmlPath = Paths.get(userHome, ".m2", "settings.xml").toAbsolutePath(); } return settingsXmlPath; }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,689
[Bug] [Standalone Server] DolphinPluginManagerConfig get maven sttings does not check file exists
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues. ### What happened i created a pr #6626 to fix #6625, but if forget to check if `the settings.xml` in the code. I feel very sorry about this~ if `~/.m2/settings.xml` or `${MAVEN_HOME}/conf/settings.xml` does not exists, will cause FileNotFound exception ### What you expected to happen check file exists ### How to reproduce * remove ~/.m2/settings.xml and the start the server ### Anything else _No response_ ### Are you willing to submit PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6689
https://github.com/apache/dolphinscheduler/pull/6691
66fbcae9ddd6c0ca925c24ef01345fc793d85586
71047db39ea97373411a674ab0f3efe647f28a9d
2021-11-04T02:18:15Z
java
2021-11-04T12:17:53Z
dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginManagerConfig.java
/** * Get maven settings.xml file path from "${MAVEN_HOME}/conf" * <p> * if "${MAVEN_HOME}/conf/settings.xml" does not exist, * null will be returned * </p> * * @return settings.xml file path, could be null */ private Path getMavenSettingsXmlFromEvn() { String mavenHome = System.getenv("MAVEN_HOME"); Path settingsXmlPath = null; if (mavenHome == null) { mavenHome = System.getenv("M2_HOME"); } if (mavenHome != null) { settingsXmlPath = Paths.get(mavenHome, "conf", "settings.xml").toAbsolutePath(); } return settingsXmlPath; } public DolphinPluginManagerConfig setMavenRemoteRepository(List<String> mavenRemoteRepository) { this.mavenRemoteRepository = mavenRemoteRepository; return this; } public DolphinPluginManagerConfig setMavenRemoteRepository(String mavenRemoteRepository) { this.mavenRemoteRepository = ImmutableList.copyOf(Splitter.on(',').omitEmptyStrings().trimResults().split(mavenRemoteRepository)); return this; } }
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,660
[Improvement][Server] Change the registry session timeout
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Now the default registry timeout is 1s, which is short for zk, and it will be reset a negotiated timeout by zk server, because `zk.minSessionTimeout = 2 * tickTimeout` and `zk.maxSessionTimeout = 20 * tickTimeout`. I think the default session timeout param should be improved to control by client better, not only for zk. Now the defaule hearbeat interval is 10s, So maybe the registry session timeout should set to 30s. BTW, `Curator.DEFAULT_SESSION_TIMEOUT_MS = 60 * 1000` and `Curator.DEFAULT_CONNECTION_TIMEOUT_MS = 15 * 1000`. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6660
https://github.com/apache/dolphinscheduler/pull/6663
1165afbdd17cf072c434020376d653b5f411fdd6
1ebab356f3e431237524537a6fedd26590ff24ce
2021-11-02T04:21:49Z
java
2021-11-04T14:31:13Z
dolphinscheduler-registry-plugin/dolphinscheduler-registry-zookeeper/src/main/java/org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperConfiguration.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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 org.apache.dolphinscheduler.plugin.registry.zookeeper; import java.util.function.Function; public enum ZookeeperConfiguration { NAME_SPACE("namespace", "dolphinscheduler", value -> value),
closed
apache/dolphinscheduler
https://github.com/apache/dolphinscheduler
6,660
[Improvement][Server] Change the registry session timeout
### Search before asking - [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement. ### Description Now the default registry timeout is 1s, which is short for zk, and it will be reset a negotiated timeout by zk server, because `zk.minSessionTimeout = 2 * tickTimeout` and `zk.maxSessionTimeout = 20 * tickTimeout`. I think the default session timeout param should be improved to control by client better, not only for zk. Now the defaule hearbeat interval is 10s, So maybe the registry session timeout should set to 30s. BTW, `Curator.DEFAULT_SESSION_TIMEOUT_MS = 60 * 1000` and `Curator.DEFAULT_CONNECTION_TIMEOUT_MS = 15 * 1000`. ### Use case _No response_ ### Related issues _No response_ ### Are you willing to submit a PR? - [X] Yes I am willing to submit a PR! ### Code of Conduct - [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
https://github.com/apache/dolphinscheduler/issues/6660
https://github.com/apache/dolphinscheduler/pull/6663
1165afbdd17cf072c434020376d653b5f411fdd6
1ebab356f3e431237524537a6fedd26590ff24ce
2021-11-02T04:21:49Z
java
2021-11-04T14:31:13Z
dolphinscheduler-registry-plugin/dolphinscheduler-registry-zookeeper/src/main/java/org/apache/dolphinscheduler/plugin/registry/zookeeper/ZookeeperConfiguration.java
SERVERS("servers", null, value -> value), /** * Initial amount of time to wait between retries */ BASE_SLEEP_TIME("base.sleep.time.ms", 60, Integer::valueOf), MAX_SLEEP_TIME("max.sleep.ms", 300, Integer::valueOf), DIGEST("digest", null, value -> value), MAX_RETRIES("max.retries", 5, Integer::valueOf), SESSION_TIMEOUT_MS("session.timeout.ms", 1000, Integer::valueOf), CONNECTION_TIMEOUT_MS("connection.timeout.ms", 1000, Integer::valueOf), BLOCK_UNTIL_CONNECTED_WAIT_MS("block.until.connected.wait", 600, Integer::valueOf), ; private final String name; public String getName() { return name; } private final Object defaultValue; private final Function<String, Object> converter; <T> ZookeeperConfiguration(String name, T defaultValue, Function<String, T> converter) { this.name = name; this.defaultValue = defaultValue; this.converter = (Function<String, Object>) converter; } public <T> T getParameterValue(String param) { Object value = param != null ? converter.apply(param) : defaultValue; return (T) value; } }