|
|
@ -24,10 +24,7 @@ import org.apache.dolphinscheduler.api.utils.PageInfo; |
|
|
|
import org.apache.dolphinscheduler.api.utils.Result; |
|
|
|
import org.apache.dolphinscheduler.api.utils.Result; |
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
import org.apache.dolphinscheduler.common.Constants; |
|
|
|
import org.apache.dolphinscheduler.common.enums.ResourceType; |
|
|
|
import org.apache.dolphinscheduler.common.enums.ResourceType; |
|
|
|
import org.apache.dolphinscheduler.common.utils.FileUtils; |
|
|
|
import org.apache.dolphinscheduler.common.utils.*; |
|
|
|
import org.apache.dolphinscheduler.common.utils.HadoopUtils; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.utils.PropertyUtils; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.common.utils.StringUtils; |
|
|
|
|
|
|
|
import org.apache.dolphinscheduler.dao.entity.Resource; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Resource; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Tenant; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.Tenant; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.UdfFunc; |
|
|
|
import org.apache.dolphinscheduler.dao.entity.UdfFunc; |
|
|
@ -141,7 +138,7 @@ public class ResourcesService extends BaseService { |
|
|
|
|
|
|
|
|
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
putMsg(result, Status.SUCCESS); |
|
|
|
Map<Object, Object> dataMap = new BeanMap(resource); |
|
|
|
Map<Object, Object> dataMap = new BeanMap(resource); |
|
|
|
Map<String, Object> resultMap = new HashMap<String, Object>(); |
|
|
|
Map<String, Object> resultMap = new HashMap<>(); |
|
|
|
for (Map.Entry<Object, Object> entry: dataMap.entrySet()) { |
|
|
|
for (Map.Entry<Object, Object> entry: dataMap.entrySet()) { |
|
|
|
if (!"class".equalsIgnoreCase(entry.getKey().toString())) { |
|
|
|
if (!"class".equalsIgnoreCase(entry.getKey().toString())) { |
|
|
|
resultMap.put(entry.getKey().toString(), entry.getValue()); |
|
|
|
resultMap.put(entry.getKey().toString(), entry.getValue()); |
|
|
@ -171,12 +168,8 @@ public class ResourcesService extends BaseService { |
|
|
|
* @return true if resource exists |
|
|
|
* @return true if resource exists |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private boolean checkResourceExists(String alias, int userId, int type ){ |
|
|
|
private boolean checkResourceExists(String alias, int userId, int type ){ |
|
|
|
|
|
|
|
|
|
|
|
List<Resource> resources = resourcesMapper.queryResourceList(alias, userId, type); |
|
|
|
List<Resource> resources = resourcesMapper.queryResourceList(alias, userId, type); |
|
|
|
if (resources != null && resources.size() > 0) { |
|
|
|
return CollectionUtils.isNotEmpty(resources); |
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -237,7 +230,7 @@ public class ResourcesService extends BaseService { |
|
|
|
|
|
|
|
|
|
|
|
//get the file suffix
|
|
|
|
//get the file suffix
|
|
|
|
String originResourceName = resource.getAlias(); |
|
|
|
String originResourceName = resource.getAlias(); |
|
|
|
String suffix = originResourceName.substring(originResourceName.lastIndexOf(".")); |
|
|
|
String suffix = originResourceName.substring(originResourceName.lastIndexOf('.')); |
|
|
|
|
|
|
|
|
|
|
|
//if the name without suffix then add it ,else use the origin name
|
|
|
|
//if the name without suffix then add it ,else use the origin name
|
|
|
|
String nameWithSuffix = name; |
|
|
|
String nameWithSuffix = name; |
|
|
@ -746,8 +739,7 @@ public class ResourcesService extends BaseService { |
|
|
|
logger.info("resource hdfs path is {} ", hdfsFileName); |
|
|
|
logger.info("resource hdfs path is {} ", hdfsFileName); |
|
|
|
|
|
|
|
|
|
|
|
HadoopUtils.getInstance().copyHdfsToLocal(hdfsFileName, localFileName, false, true); |
|
|
|
HadoopUtils.getInstance().copyHdfsToLocal(hdfsFileName, localFileName, false, true); |
|
|
|
org.springframework.core.io.Resource file = org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(localFileName); |
|
|
|
return org.apache.dolphinscheduler.api.utils.FileUtils.file2Resource(localFileName); |
|
|
|
return file; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -766,7 +758,7 @@ public class ResourcesService extends BaseService { |
|
|
|
} |
|
|
|
} |
|
|
|
List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId); |
|
|
|
List<Resource> resourceList = resourcesMapper.queryResourceExceptUserId(userId); |
|
|
|
List<Object> list ; |
|
|
|
List<Object> list ; |
|
|
|
if (resourceList != null && resourceList.size() > 0) { |
|
|
|
if (CollectionUtils.isNotEmpty(resourceList)) { |
|
|
|
Set<Resource> resourceSet = new HashSet<>(resourceList); |
|
|
|
Set<Resource> resourceSet = new HashSet<>(resourceList); |
|
|
|
List<Resource> authedResourceList = resourcesMapper.queryAuthorizedResourceList(userId); |
|
|
|
List<Resource> authedResourceList = resourcesMapper.queryAuthorizedResourceList(userId); |
|
|
|
|
|
|
|
|
|
|
@ -801,7 +793,7 @@ public class ResourcesService extends BaseService { |
|
|
|
List<UdfFunc> udfFuncList = udfFunctionMapper.queryUdfFuncExceptUserId(userId); |
|
|
|
List<UdfFunc> udfFuncList = udfFunctionMapper.queryUdfFuncExceptUserId(userId); |
|
|
|
List<UdfFunc> resultList = new ArrayList<>(); |
|
|
|
List<UdfFunc> resultList = new ArrayList<>(); |
|
|
|
Set<UdfFunc> udfFuncSet = null; |
|
|
|
Set<UdfFunc> udfFuncSet = null; |
|
|
|
if (udfFuncList != null && udfFuncList.size() > 0) { |
|
|
|
if (CollectionUtils.isNotEmpty(udfFuncList)) { |
|
|
|
udfFuncSet = new HashSet<>(udfFuncList); |
|
|
|
udfFuncSet = new HashSet<>(udfFuncList); |
|
|
|
|
|
|
|
|
|
|
|
List<UdfFunc> authedUDFFuncList = udfFunctionMapper.queryAuthedUdfFunc(userId); |
|
|
|
List<UdfFunc> authedUDFFuncList = udfFunctionMapper.queryAuthedUdfFunc(userId); |
|
|
@ -897,10 +889,9 @@ public class ResourcesService extends BaseService { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private void getAuthorizedResourceList(Set<?> resourceSet, List<?> authedResourceList) { |
|
|
|
private void getAuthorizedResourceList(Set<?> resourceSet, List<?> authedResourceList) { |
|
|
|
Set<?> authedResourceSet = null; |
|
|
|
Set<?> authedResourceSet = null; |
|
|
|
if (authedResourceList != null && authedResourceList.size() > 0) { |
|
|
|
if (CollectionUtils.isNotEmpty(authedResourceList)) { |
|
|
|
authedResourceSet = new HashSet<>(authedResourceList); |
|
|
|
authedResourceSet = new HashSet<>(authedResourceList); |
|
|
|
resourceSet.removeAll(authedResourceSet); |
|
|
|
resourceSet.removeAll(authedResourceSet); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|