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
unknown | language
stringclasses 5
values | commit_datetime
unknown | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,702 | [Improvement] [APIServer] When update the existing alarm plug-in instance, the api should use POST instead of GET |
When update the existing alarm plug-in instance, the front-end and back-end interaction should use POST method instead of GET.
 | https://github.com/apache/dolphinscheduler/issues/5702 | https://github.com/apache/dolphinscheduler/pull/5703 | b31ba7e18b89885c37c2129bf9b4816001f09e51 | 2d71930837092c52dc63a76941b19051ae38cc2e | "2021-06-26T14:53:59Z" | java | "2021-06-27T10:58:22Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AlertPluginInstanceController.java | }
/**
* getAlertPluginInstance
*
* @param loginUser login user
* @param id alert plugin instance id
* @return result
*/
@ApiOperation(value = "get", notes = "GET_ALERT_PLUGIN_INSTANCE_NOTES")
@PostMapping(value = "/get")
@ResponseStatus(HttpStatus.OK)
@ApiException(GET_ALERT_PLUGIN_INSTANCE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result getAlertPluginInstance(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "id") int id) {
Map<String, Object> result = alertPluginInstanceService.get(loginUser, id);
return returnDataList(result);
}
/**
* getAlertPluginInstance
*
* @param loginUser login user
* @return result
*/
@ApiOperation(value = "/queryAll", notes = "QUERY_ALL_ALERT_PLUGIN_INSTANCE_NOTES")
@PostMapping(value = "/queryAll")
@ResponseStatus(HttpStatus.OK)
@ApiException(QUERY_ALL_ALERT_PLUGIN_INSTANCE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result getAlertPluginInstance(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,702 | [Improvement] [APIServer] When update the existing alarm plug-in instance, the api should use POST instead of GET |
When update the existing alarm plug-in instance, the front-end and back-end interaction should use POST method instead of GET.
 | https://github.com/apache/dolphinscheduler/issues/5702 | https://github.com/apache/dolphinscheduler/pull/5703 | b31ba7e18b89885c37c2129bf9b4816001f09e51 | 2d71930837092c52dc63a76941b19051ae38cc2e | "2021-06-26T14:53:59Z" | java | "2021-06-27T10:58:22Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AlertPluginInstanceController.java | Map<String, Object> result = alertPluginInstanceService.queryAll();
return returnDataList(result);
}
/**
* check alert group exist
*
* @param loginUser login user
* @param alertInstanceName alert instance name
* @return check result code
*/
@ApiOperation(value = "verifyAlertInstanceName", notes = "VERIFY_ALERT_INSTANCE_NAME_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "groupName", value = "GROUP_NAME", required = true, dataType = "String"),
})
@GetMapping(value = "/verify-alert-instance-name")
@ResponseStatus(HttpStatus.OK)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result verifyGroupName(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "alertInstanceName") String alertInstanceName) {
boolean exist = alertPluginInstanceService.checkExistPluginInstanceName(alertInstanceName);
Result result = new Result();
if (exist) {
logger.error("alert plugin instance {} has exist, can't create again.", alertInstanceName);
result.setCode(Status.PLUGIN_INSTANCE_ALREADY_EXIT.getCode());
result.setMsg(Status.PLUGIN_INSTANCE_ALREADY_EXIT.getMsg());
} else {
result.setCode(Status.SUCCESS.getCode());
result.setMsg(Status.SUCCESS.getMsg());
}
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,702 | [Improvement] [APIServer] When update the existing alarm plug-in instance, the api should use POST instead of GET |
When update the existing alarm plug-in instance, the front-end and back-end interaction should use POST method instead of GET.
 | https://github.com/apache/dolphinscheduler/issues/5702 | https://github.com/apache/dolphinscheduler/pull/5703 | b31ba7e18b89885c37c2129bf9b4816001f09e51 | 2d71930837092c52dc63a76941b19051ae38cc2e | "2021-06-26T14:53:59Z" | java | "2021-06-27T10:58:22Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AlertPluginInstanceController.java | }
/**
* paging query alert plugin instance group list
*
* @param loginUser login user
* @param pageNo page number
* @param pageSize page size
* @return alert plugin instance list page
*/
@ApiOperation(value = "queryAlertPluginInstanceListPaging", notes = "QUERY_ALERT_PLUGIN_INSTANCE_LIST_PAGING_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "1"),
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "20")
})
@GetMapping(value = "/list-paging")
@ResponseStatus(HttpStatus.OK)
@ApiException(LIST_PAGING_ALERT_PLUGIN_INSTANCE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result listPaging(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) {
Map<String, Object> result = checkPageParams(pageNo, pageSize);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return returnDataListPaging(result);
}
result = alertPluginInstanceService.queryPluginPage(pageNo, pageSize);
return returnDataListPaging(result);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,710 | [Improvement][ALERT-LOG] The usage of Preconditions.checkState in Guava is wrong |
The usage of Preconditions.checkState in Guava is wrong, the placeholder should use the form of %s instead of {}
like this: [DolphinPluginLoader.java#L107](https://github.com/apache/dolphinscheduler/blob/3d8d1ebe67cc3331ff5fda649675b5c61a04df5f/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginLoader.java#L107)
```java
private void loadPlugin(URLClassLoader pluginClassLoader) {
ServiceLoader<DolphinSchedulerPlugin> serviceLoader = ServiceLoader.load(DolphinSchedulerPlugin.class, pluginClassLoader);
List<DolphinSchedulerPlugin> plugins = ImmutableList.copyOf(serviceLoader);
Preconditions.checkState(!plugins.isEmpty(), "No service providers the plugin {}",DolphinSchedulerPlugin.class.getName());
for (DolphinSchedulerPlugin plugin : plugins) {
logger.info("Installing {}", plugin.getClass().getName());
for (AbstractDolphinPluginManager dolphinPluginManager : dolphinPluginManagerList) {
dolphinPluginManager.installPlugin(plugin);
}
}
}
```
we can reproduce this like this simple sample:
```java
public class Test {
public static void main(String[] args) {
String word = "letters";
checkState(word.isEmpty(), "Alert Plugin {} is not null", word);
}
}
```
the result is:
**Alert Plugin {} is not null [letters]**
but we actually want to show the message like this:
**Alert Plugin letters is not null** | https://github.com/apache/dolphinscheduler/issues/5710 | https://github.com/apache/dolphinscheduler/pull/5711 | 3d8d1ebe67cc3331ff5fda649675b5c61a04df5f | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | "2021-06-28T16:34:24Z" | java | "2021-06-28T17:03:52Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/plugin/AlertPluginManager.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 |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,710 | [Improvement][ALERT-LOG] The usage of Preconditions.checkState in Guava is wrong |
The usage of Preconditions.checkState in Guava is wrong, the placeholder should use the form of %s instead of {}
like this: [DolphinPluginLoader.java#L107](https://github.com/apache/dolphinscheduler/blob/3d8d1ebe67cc3331ff5fda649675b5c61a04df5f/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginLoader.java#L107)
```java
private void loadPlugin(URLClassLoader pluginClassLoader) {
ServiceLoader<DolphinSchedulerPlugin> serviceLoader = ServiceLoader.load(DolphinSchedulerPlugin.class, pluginClassLoader);
List<DolphinSchedulerPlugin> plugins = ImmutableList.copyOf(serviceLoader);
Preconditions.checkState(!plugins.isEmpty(), "No service providers the plugin {}",DolphinSchedulerPlugin.class.getName());
for (DolphinSchedulerPlugin plugin : plugins) {
logger.info("Installing {}", plugin.getClass().getName());
for (AbstractDolphinPluginManager dolphinPluginManager : dolphinPluginManagerList) {
dolphinPluginManager.installPlugin(plugin);
}
}
}
```
we can reproduce this like this simple sample:
```java
public class Test {
public static void main(String[] args) {
String word = "letters";
checkState(word.isEmpty(), "Alert Plugin {} is not null", word);
}
}
```
the result is:
**Alert Plugin {} is not null [letters]**
but we actually want to show the message like this:
**Alert Plugin letters is not null** | https://github.com/apache/dolphinscheduler/issues/5710 | https://github.com/apache/dolphinscheduler/pull/5711 | 3d8d1ebe67cc3331ff5fda649675b5c61a04df5f | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | "2021-06-28T16:34:24Z" | java | "2021-06-28T17:03:52Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/plugin/AlertPluginManager.java | * 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.alert.plugin;
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;
import static com.google.common.base.Preconditions.checkState;
import org.apache.dolphinscheduler.common.enums.PluginType;
import org.apache.dolphinscheduler.spi.plugin.AbstractDolphinPluginManager;
import org.apache.dolphinscheduler.dao.DaoFactory;
import org.apache.dolphinscheduler.dao.PluginDao;
import org.apache.dolphinscheduler.dao.entity.PluginDefine;
import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin;
import org.apache.dolphinscheduler.spi.alert.AlertChannel;
import org.apache.dolphinscheduler.spi.alert.AlertChannelFactory;
import org.apache.dolphinscheduler.spi.classloader.ThreadContextClassLoader;
import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer;
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* load the configured alert plugin and manager them
*/
public class AlertPluginManager extends AbstractDolphinPluginManager { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,710 | [Improvement][ALERT-LOG] The usage of Preconditions.checkState in Guava is wrong |
The usage of Preconditions.checkState in Guava is wrong, the placeholder should use the form of %s instead of {}
like this: [DolphinPluginLoader.java#L107](https://github.com/apache/dolphinscheduler/blob/3d8d1ebe67cc3331ff5fda649675b5c61a04df5f/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginLoader.java#L107)
```java
private void loadPlugin(URLClassLoader pluginClassLoader) {
ServiceLoader<DolphinSchedulerPlugin> serviceLoader = ServiceLoader.load(DolphinSchedulerPlugin.class, pluginClassLoader);
List<DolphinSchedulerPlugin> plugins = ImmutableList.copyOf(serviceLoader);
Preconditions.checkState(!plugins.isEmpty(), "No service providers the plugin {}",DolphinSchedulerPlugin.class.getName());
for (DolphinSchedulerPlugin plugin : plugins) {
logger.info("Installing {}", plugin.getClass().getName());
for (AbstractDolphinPluginManager dolphinPluginManager : dolphinPluginManagerList) {
dolphinPluginManager.installPlugin(plugin);
}
}
}
```
we can reproduce this like this simple sample:
```java
public class Test {
public static void main(String[] args) {
String word = "letters";
checkState(word.isEmpty(), "Alert Plugin {} is not null", word);
}
}
```
the result is:
**Alert Plugin {} is not null [letters]**
but we actually want to show the message like this:
**Alert Plugin letters is not null** | https://github.com/apache/dolphinscheduler/issues/5710 | https://github.com/apache/dolphinscheduler/pull/5711 | 3d8d1ebe67cc3331ff5fda649675b5c61a04df5f | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | "2021-06-28T16:34:24Z" | java | "2021-06-28T17:03:52Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/plugin/AlertPluginManager.java | private static final Logger logger = LoggerFactory.getLogger(AlertPluginManager.class);
private final Map<String, AlertChannelFactory> alertChannelFactoryMap = new ConcurrentHashMap<>();
private final Map<String, AlertChannel> alertChannelMap = new ConcurrentHashMap<>();
/**
* k->pluginDefineId v->pluginDefineName
*/
private final Map<Integer, String> pluginDefineMap = new HashMap<>();
private PluginDao pluginDao = DaoFactory.getDaoInstance(PluginDao.class);
private void addAlertChannelFactory(AlertChannelFactory alertChannelFactory) {
requireNonNull(alertChannelFactory, "alertChannelFactory is null");
if (alertChannelFactoryMap.putIfAbsent(alertChannelFactory.getName(), alertChannelFactory) != null) {
throw new IllegalArgumentException(format("Alert Plugin '%s' is already registered", alertChannelFactory.getName()));
}
try {
loadAlertChannel(alertChannelFactory.getName());
} catch (Exception e) {
throw new IllegalArgumentException(format("Alert Plugin '%s' is can not load .", alertChannelFactory.getName()));
}
}
private void loadAlertChannel(String name) {
requireNonNull(name, "name is null");
AlertChannelFactory alertChannelFactory = alertChannelFactoryMap.get(name);
checkState(alertChannelFactory != null, "Alert Plugin {} is not registered", name); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,710 | [Improvement][ALERT-LOG] The usage of Preconditions.checkState in Guava is wrong |
The usage of Preconditions.checkState in Guava is wrong, the placeholder should use the form of %s instead of {}
like this: [DolphinPluginLoader.java#L107](https://github.com/apache/dolphinscheduler/blob/3d8d1ebe67cc3331ff5fda649675b5c61a04df5f/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginLoader.java#L107)
```java
private void loadPlugin(URLClassLoader pluginClassLoader) {
ServiceLoader<DolphinSchedulerPlugin> serviceLoader = ServiceLoader.load(DolphinSchedulerPlugin.class, pluginClassLoader);
List<DolphinSchedulerPlugin> plugins = ImmutableList.copyOf(serviceLoader);
Preconditions.checkState(!plugins.isEmpty(), "No service providers the plugin {}",DolphinSchedulerPlugin.class.getName());
for (DolphinSchedulerPlugin plugin : plugins) {
logger.info("Installing {}", plugin.getClass().getName());
for (AbstractDolphinPluginManager dolphinPluginManager : dolphinPluginManagerList) {
dolphinPluginManager.installPlugin(plugin);
}
}
}
```
we can reproduce this like this simple sample:
```java
public class Test {
public static void main(String[] args) {
String word = "letters";
checkState(word.isEmpty(), "Alert Plugin {} is not null", word);
}
}
```
the result is:
**Alert Plugin {} is not null [letters]**
but we actually want to show the message like this:
**Alert Plugin letters is not null** | https://github.com/apache/dolphinscheduler/issues/5710 | https://github.com/apache/dolphinscheduler/pull/5711 | 3d8d1ebe67cc3331ff5fda649675b5c61a04df5f | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | "2021-06-28T16:34:24Z" | java | "2021-06-28T17:03:52Z" | dolphinscheduler-alert/src/main/java/org/apache/dolphinscheduler/alert/plugin/AlertPluginManager.java | try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(alertChannelFactory.getClass().getClassLoader())) {
AlertChannel alertChannel = alertChannelFactory.create();
this.alertChannelMap.put(name, alertChannel);
}
logger.info("-- Loaded Alert Plugin {} --", name);
}
Map<String, AlertChannelFactory> getAlertChannelFactoryMap() {
return alertChannelFactoryMap;
}
public Map<String, AlertChannel> getAlertChannelMap() {
return alertChannelMap;
}
public String getPluginNameById(int id) {
return pluginDefineMap.get(id);
}
@Override
public void installPlugin(DolphinSchedulerPlugin dolphinSchedulerPlugin) {
for (AlertChannelFactory alertChannelFactory : dolphinSchedulerPlugin.getAlertChannelFactorys()) {
logger.info("Registering Alert Plugin '{}'", alertChannelFactory.getName());
this.addAlertChannelFactory(alertChannelFactory);
List<PluginParams> params = alertChannelFactory.getParams();
String nameEn = alertChannelFactory.getName();
String paramsJson = PluginParamsTransfer.transferParamsToJson(params);
PluginDefine pluginDefine = new PluginDefine(nameEn, PluginType.ALERT.getDesc(), paramsJson);
int id = pluginDao.addOrUpdatePluginDefine(pluginDefine);
pluginDefineMap.put(id, pluginDefine.getPluginName());
}
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,710 | [Improvement][ALERT-LOG] The usage of Preconditions.checkState in Guava is wrong |
The usage of Preconditions.checkState in Guava is wrong, the placeholder should use the form of %s instead of {}
like this: [DolphinPluginLoader.java#L107](https://github.com/apache/dolphinscheduler/blob/3d8d1ebe67cc3331ff5fda649675b5c61a04df5f/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginLoader.java#L107)
```java
private void loadPlugin(URLClassLoader pluginClassLoader) {
ServiceLoader<DolphinSchedulerPlugin> serviceLoader = ServiceLoader.load(DolphinSchedulerPlugin.class, pluginClassLoader);
List<DolphinSchedulerPlugin> plugins = ImmutableList.copyOf(serviceLoader);
Preconditions.checkState(!plugins.isEmpty(), "No service providers the plugin {}",DolphinSchedulerPlugin.class.getName());
for (DolphinSchedulerPlugin plugin : plugins) {
logger.info("Installing {}", plugin.getClass().getName());
for (AbstractDolphinPluginManager dolphinPluginManager : dolphinPluginManagerList) {
dolphinPluginManager.installPlugin(plugin);
}
}
}
```
we can reproduce this like this simple sample:
```java
public class Test {
public static void main(String[] args) {
String word = "letters";
checkState(word.isEmpty(), "Alert Plugin {} is not null", word);
}
}
```
the result is:
**Alert Plugin {} is not null [letters]**
but we actually want to show the message like this:
**Alert Plugin letters is not null** | https://github.com/apache/dolphinscheduler/issues/5710 | https://github.com/apache/dolphinscheduler/pull/5711 | 3d8d1ebe67cc3331ff5fda649675b5c61a04df5f | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | "2021-06-28T16:34:24Z" | java | "2021-06-28T17:03:52Z" | dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginLoader.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.
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,710 | [Improvement][ALERT-LOG] The usage of Preconditions.checkState in Guava is wrong |
The usage of Preconditions.checkState in Guava is wrong, the placeholder should use the form of %s instead of {}
like this: [DolphinPluginLoader.java#L107](https://github.com/apache/dolphinscheduler/blob/3d8d1ebe67cc3331ff5fda649675b5c61a04df5f/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginLoader.java#L107)
```java
private void loadPlugin(URLClassLoader pluginClassLoader) {
ServiceLoader<DolphinSchedulerPlugin> serviceLoader = ServiceLoader.load(DolphinSchedulerPlugin.class, pluginClassLoader);
List<DolphinSchedulerPlugin> plugins = ImmutableList.copyOf(serviceLoader);
Preconditions.checkState(!plugins.isEmpty(), "No service providers the plugin {}",DolphinSchedulerPlugin.class.getName());
for (DolphinSchedulerPlugin plugin : plugins) {
logger.info("Installing {}", plugin.getClass().getName());
for (AbstractDolphinPluginManager dolphinPluginManager : dolphinPluginManagerList) {
dolphinPluginManager.installPlugin(plugin);
}
}
}
```
we can reproduce this like this simple sample:
```java
public class Test {
public static void main(String[] args) {
String word = "letters";
checkState(word.isEmpty(), "Alert Plugin {} is not null", word);
}
}
```
the result is:
**Alert Plugin {} is not null [letters]**
but we actually want to show the message like this:
**Alert Plugin letters is not null** | https://github.com/apache/dolphinscheduler/issues/5710 | https://github.com/apache/dolphinscheduler/pull/5711 | 3d8d1ebe67cc3331ff5fda649675b5c61a04df5f | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | "2021-06-28T16:34:24Z" | java | "2021-06-28T17:03:52Z" | dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginLoader.java | package org.apache.dolphinscheduler.spi.plugin;
import static java.lang.String.format;
import static java.util.Objects.requireNonNull;
import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin;
import org.apache.dolphinscheduler.spi.classloader.ThreadContextClassLoader;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.ServiceLoader;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonatype.aether.artifact.Artifact;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Ordering;
import io.airlift.resolver.ArtifactResolver;
/**
* Plugin Loader
* Load Plugin from pom when development and run server in IDE
* Load Plugin from the plugin directory when running on the server
*/
public class DolphinPluginLoader {
private static final Logger logger = LoggerFactory.getLogger(DolphinPluginLoader.class);
/**
* All third-party jar packages used in the classes which in spi package need to be add |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,710 | [Improvement][ALERT-LOG] The usage of Preconditions.checkState in Guava is wrong |
The usage of Preconditions.checkState in Guava is wrong, the placeholder should use the form of %s instead of {}
like this: [DolphinPluginLoader.java#L107](https://github.com/apache/dolphinscheduler/blob/3d8d1ebe67cc3331ff5fda649675b5c61a04df5f/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginLoader.java#L107)
```java
private void loadPlugin(URLClassLoader pluginClassLoader) {
ServiceLoader<DolphinSchedulerPlugin> serviceLoader = ServiceLoader.load(DolphinSchedulerPlugin.class, pluginClassLoader);
List<DolphinSchedulerPlugin> plugins = ImmutableList.copyOf(serviceLoader);
Preconditions.checkState(!plugins.isEmpty(), "No service providers the plugin {}",DolphinSchedulerPlugin.class.getName());
for (DolphinSchedulerPlugin plugin : plugins) {
logger.info("Installing {}", plugin.getClass().getName());
for (AbstractDolphinPluginManager dolphinPluginManager : dolphinPluginManagerList) {
dolphinPluginManager.installPlugin(plugin);
}
}
}
```
we can reproduce this like this simple sample:
```java
public class Test {
public static void main(String[] args) {
String word = "letters";
checkState(word.isEmpty(), "Alert Plugin {} is not null", word);
}
}
```
the result is:
**Alert Plugin {} is not null [letters]**
but we actually want to show the message like this:
**Alert Plugin letters is not null** | https://github.com/apache/dolphinscheduler/issues/5710 | https://github.com/apache/dolphinscheduler/pull/5711 | 3d8d1ebe67cc3331ff5fda649675b5c61a04df5f | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | "2021-06-28T16:34:24Z" | java | "2021-06-28T17:03:52Z" | dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginLoader.java | */
private static final ImmutableList<String> DOLPHIN_SPI_PACKAGES = ImmutableList.<String>builder()
.add("org.apache.dolphinscheduler.spi.")
.add("com.fasterxml.jackson.")
.build();
private final File installedPluginsDir;
private final List<String> configPlugins;
private ArtifactResolver resolver = null;
private final List<AbstractDolphinPluginManager> dolphinPluginManagerList;
public DolphinPluginLoader(DolphinPluginManagerConfig config, List<AbstractDolphinPluginManager> dolphinPluginManagerList) {
installedPluginsDir = config.getInstalledPluginsDir();
if (config.getPlugins() == null) {
this.configPlugins = ImmutableList.of();
} else {
this.configPlugins = ImmutableList.copyOf(config.getPlugins());
}
this.dolphinPluginManagerList = requireNonNull(dolphinPluginManagerList, "dolphinPluginManagerList is null");
if (configPlugins != null && configPlugins.size() > 0) {
this.resolver = new ArtifactResolver(config.getMavenLocalRepository(), config.getMavenRemoteRepository());
}
}
public void loadPlugins()
throws Exception {
for (File file : listPluginDirs(installedPluginsDir)) {
if (file.isDirectory()) {
loadPlugin(file.getAbsolutePath());
}
}
for (String plugin : configPlugins) {
loadPlugin(plugin); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,710 | [Improvement][ALERT-LOG] The usage of Preconditions.checkState in Guava is wrong |
The usage of Preconditions.checkState in Guava is wrong, the placeholder should use the form of %s instead of {}
like this: [DolphinPluginLoader.java#L107](https://github.com/apache/dolphinscheduler/blob/3d8d1ebe67cc3331ff5fda649675b5c61a04df5f/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginLoader.java#L107)
```java
private void loadPlugin(URLClassLoader pluginClassLoader) {
ServiceLoader<DolphinSchedulerPlugin> serviceLoader = ServiceLoader.load(DolphinSchedulerPlugin.class, pluginClassLoader);
List<DolphinSchedulerPlugin> plugins = ImmutableList.copyOf(serviceLoader);
Preconditions.checkState(!plugins.isEmpty(), "No service providers the plugin {}",DolphinSchedulerPlugin.class.getName());
for (DolphinSchedulerPlugin plugin : plugins) {
logger.info("Installing {}", plugin.getClass().getName());
for (AbstractDolphinPluginManager dolphinPluginManager : dolphinPluginManagerList) {
dolphinPluginManager.installPlugin(plugin);
}
}
}
```
we can reproduce this like this simple sample:
```java
public class Test {
public static void main(String[] args) {
String word = "letters";
checkState(word.isEmpty(), "Alert Plugin {} is not null", word);
}
}
```
the result is:
**Alert Plugin {} is not null [letters]**
but we actually want to show the message like this:
**Alert Plugin letters is not null** | https://github.com/apache/dolphinscheduler/issues/5710 | https://github.com/apache/dolphinscheduler/pull/5711 | 3d8d1ebe67cc3331ff5fda649675b5c61a04df5f | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | "2021-06-28T16:34:24Z" | java | "2021-06-28T17:03:52Z" | dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginLoader.java | }
}
private void loadPlugin(String plugin)
throws Exception {
logger.info("-- Loading plugin {} --", plugin);
URLClassLoader pluginClassLoader = buildPluginClassLoader(plugin);
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(pluginClassLoader)) {
loadPlugin(pluginClassLoader);
}
logger.info("-- Finished loading plugin {} --", plugin);
}
private void loadPlugin(URLClassLoader pluginClassLoader) {
ServiceLoader<DolphinSchedulerPlugin> serviceLoader = ServiceLoader.load(DolphinSchedulerPlugin.class, pluginClassLoader);
List<DolphinSchedulerPlugin> plugins = ImmutableList.copyOf(serviceLoader);
Preconditions.checkState(!plugins.isEmpty(), "No service providers the plugin {}", DolphinSchedulerPlugin.class.getName());
for (DolphinSchedulerPlugin plugin : plugins) {
logger.info("Installing {}", plugin.getClass().getName());
for (AbstractDolphinPluginManager dolphinPluginManager : dolphinPluginManagerList) {
dolphinPluginManager.installPlugin(plugin);
}
}
}
private URLClassLoader buildPluginClassLoader(String plugin)
throws Exception {
File file = new File(plugin);
if (!file.isDirectory() && (file.getName().equals("pom.xml") || file.getName().endsWith(".pom"))) {
return buildPluginClassLoaderFromPom(file);
}
if (file.isDirectory()) {
return buildPluginClassLoaderFromDirectory(file); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,710 | [Improvement][ALERT-LOG] The usage of Preconditions.checkState in Guava is wrong |
The usage of Preconditions.checkState in Guava is wrong, the placeholder should use the form of %s instead of {}
like this: [DolphinPluginLoader.java#L107](https://github.com/apache/dolphinscheduler/blob/3d8d1ebe67cc3331ff5fda649675b5c61a04df5f/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginLoader.java#L107)
```java
private void loadPlugin(URLClassLoader pluginClassLoader) {
ServiceLoader<DolphinSchedulerPlugin> serviceLoader = ServiceLoader.load(DolphinSchedulerPlugin.class, pluginClassLoader);
List<DolphinSchedulerPlugin> plugins = ImmutableList.copyOf(serviceLoader);
Preconditions.checkState(!plugins.isEmpty(), "No service providers the plugin {}",DolphinSchedulerPlugin.class.getName());
for (DolphinSchedulerPlugin plugin : plugins) {
logger.info("Installing {}", plugin.getClass().getName());
for (AbstractDolphinPluginManager dolphinPluginManager : dolphinPluginManagerList) {
dolphinPluginManager.installPlugin(plugin);
}
}
}
```
we can reproduce this like this simple sample:
```java
public class Test {
public static void main(String[] args) {
String word = "letters";
checkState(word.isEmpty(), "Alert Plugin {} is not null", word);
}
}
```
the result is:
**Alert Plugin {} is not null [letters]**
but we actually want to show the message like this:
**Alert Plugin letters is not null** | https://github.com/apache/dolphinscheduler/issues/5710 | https://github.com/apache/dolphinscheduler/pull/5711 | 3d8d1ebe67cc3331ff5fda649675b5c61a04df5f | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | "2021-06-28T16:34:24Z" | java | "2021-06-28T17:03:52Z" | dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginLoader.java | } else {
throw new IllegalArgumentException(format("plugin must be a pom file or directory %s .", plugin));
}
}
private URLClassLoader buildPluginClassLoaderFromPom(File pomFile)
throws Exception {
List<Artifact> artifacts = resolver.resolvePom(pomFile);
URLClassLoader classLoader = createClassLoader(artifacts, pomFile.getPath());
Artifact artifact = artifacts.get(0);
Set<String> plugins = DolphinPluginDiscovery.discoverPluginsFromArtifact(artifact, classLoader);
if (!plugins.isEmpty()) {
DolphinPluginDiscovery.writePluginServices(plugins, artifact.getFile());
}
return classLoader;
}
private URLClassLoader buildPluginClassLoaderFromDirectory(File dir)
throws Exception {
logger.info("Classpath for {}:", dir.getName());
List<URL> urls = new ArrayList<>();
for (File file : listPluginDirs(dir)) {
logger.info(" {}", file);
urls.add(file.toURI().toURL());
}
return createClassLoader(urls);
}
private URLClassLoader createClassLoader(List<Artifact> artifacts, String name)
throws IOException {
logger.info("Classpath for {}:", name);
List<URL> urls = new ArrayList<>();
for (Artifact artifact : sortArtifacts(artifacts)) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,710 | [Improvement][ALERT-LOG] The usage of Preconditions.checkState in Guava is wrong |
The usage of Preconditions.checkState in Guava is wrong, the placeholder should use the form of %s instead of {}
like this: [DolphinPluginLoader.java#L107](https://github.com/apache/dolphinscheduler/blob/3d8d1ebe67cc3331ff5fda649675b5c61a04df5f/dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginLoader.java#L107)
```java
private void loadPlugin(URLClassLoader pluginClassLoader) {
ServiceLoader<DolphinSchedulerPlugin> serviceLoader = ServiceLoader.load(DolphinSchedulerPlugin.class, pluginClassLoader);
List<DolphinSchedulerPlugin> plugins = ImmutableList.copyOf(serviceLoader);
Preconditions.checkState(!plugins.isEmpty(), "No service providers the plugin {}",DolphinSchedulerPlugin.class.getName());
for (DolphinSchedulerPlugin plugin : plugins) {
logger.info("Installing {}", plugin.getClass().getName());
for (AbstractDolphinPluginManager dolphinPluginManager : dolphinPluginManagerList) {
dolphinPluginManager.installPlugin(plugin);
}
}
}
```
we can reproduce this like this simple sample:
```java
public class Test {
public static void main(String[] args) {
String word = "letters";
checkState(word.isEmpty(), "Alert Plugin {} is not null", word);
}
}
```
the result is:
**Alert Plugin {} is not null [letters]**
but we actually want to show the message like this:
**Alert Plugin letters is not null** | https://github.com/apache/dolphinscheduler/issues/5710 | https://github.com/apache/dolphinscheduler/pull/5711 | 3d8d1ebe67cc3331ff5fda649675b5c61a04df5f | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | "2021-06-28T16:34:24Z" | java | "2021-06-28T17:03:52Z" | dolphinscheduler-spi/src/main/java/org/apache/dolphinscheduler/spi/plugin/DolphinPluginLoader.java | if (artifact.getFile() == null) {
throw new RuntimeException("Could not resolve artifact: " + artifact);
}
File file = artifact.getFile().getCanonicalFile();
logger.info(" {}", file);
urls.add(file.toURI().toURL());
}
return createClassLoader(urls);
}
private URLClassLoader createClassLoader(List<URL> urls) {
ClassLoader parent = getClass().getClassLoader();
return new DolphinPluginClassLoader(urls, parent, DOLPHIN_SPI_PACKAGES);
}
private static List<File> listPluginDirs(File installedPluginsDir) {
if (installedPluginsDir != null && installedPluginsDir.isDirectory()) {
File[] files = installedPluginsDir.listFiles();
if (files != null) {
Arrays.sort(files);
return ImmutableList.copyOf(files);
}
}
return ImmutableList.of();
}
private static List<Artifact> sortArtifacts(List<Artifact> artifacts) {
List<Artifact> list = new ArrayList<>(artifacts);
list.sort(Ordering.natural().nullsLast().onResultOf(Artifact::getFile));
return list;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.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 org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ServiceException;
import org.apache.dolphinscheduler.api.service.UsersService;
import org.apache.dolphinscheduler.api.utils.CheckUtils;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.Flag;
import org.apache.dolphinscheduler.common.enums.ResourceType;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.utils.CollectionUtils; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | import org.apache.dolphinscheduler.common.utils.EncryptionUtils;
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.AlertGroup;
import org.apache.dolphinscheduler.dao.entity.DatasourceUser;
import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.ProjectUser;
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.UDFUser;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper;
import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper;
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
import org.apache.dolphinscheduler.dao.mapper.ProjectUserMapper;
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.UDFUserMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* users service impl
*/
@Service
public class UsersServiceImpl extends BaseServiceImpl implements UsersService {
private static final Logger logger = LoggerFactory.getLogger(UsersServiceImpl.class);
@Autowired
private UserMapper userMapper;
@Autowired
private TenantMapper tenantMapper;
@Autowired
private ProjectUserMapper projectUserMapper;
@Autowired
private ResourceUserMapper resourceUserMapper;
@Autowired
private ResourceMapper resourceMapper;
@Autowired
private DataSourceUserMapper datasourceUserMapper;
@Autowired |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | private UDFUserMapper udfUserMapper;
@Autowired
private AlertGroupMapper alertGroupMapper;
@Autowired
private ProcessDefinitionMapper processDefinitionMapper;
@Autowired
private ProjectMapper projectMapper;
/**
* create user, only system admin have permission
*
* @param loginUser login user
* @param userName user name
* @param userPassword user password
* @param email email
* @param tenantId tenant id
* @param phone phone
* @param queue queue
* @return create result code
* @throws Exception exception
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Map<String, Object> createUser(User loginUser,
String userName,
String userPassword,
String email,
int tenantId,
String phone,
String queue,
int state) throws IOException { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | Map<String, Object> result = new HashMap<>();
String msg = this.checkUserParams(userName, userPassword, email, phone);
if (!StringUtils.isEmpty(msg)) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, msg);
return result;
}
if (!isAdmin(loginUser)) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
if (!checkTenantExists(tenantId)) {
putMsg(result, Status.TENANT_NOT_EXIST);
return result;
}
User user = createUser(userName, userPassword, email, tenantId, phone, queue, state);
Tenant tenant = tenantMapper.queryById(tenantId);
if (PropertyUtils.getResUploadStartupState()) {
if (!HadoopUtils.getInstance().exists(HadoopUtils.getHdfsTenantDir(tenant.getTenantCode()))) {
createTenantDirIfNotExists(tenant.getTenantCode());
}
String userPath = HadoopUtils.getHdfsUserDir(tenant.getTenantCode(), user.getId());
HadoopUtils.getInstance().mkdir(userPath);
}
putMsg(result, Status.SUCCESS);
return result;
}
@Override |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | @Transactional(rollbackFor = RuntimeException.class)
public User createUser(String userName,
String userPassword,
String email,
int tenantId,
String phone,
String queue,
int state) {
User user = new User();
Date now = new Date();
user.setUserName(userName);
user.setUserPassword(EncryptionUtils.getMd5(userPassword));
user.setEmail(email);
user.setTenantId(tenantId);
user.setPhone(phone);
user.setState(state);
user.setUserType(UserType.GENERAL_USER);
user.setCreateTime(now);
user.setUpdateTime(now);
if (StringUtils.isEmpty(queue)) {
queue = "";
}
user.setQueue(queue);
userMapper.insert(user);
return user;
}
/***
* create User for ldap login |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | */
@Override
@Transactional(rollbackFor = Exception.class)
public User createUser(UserType userType, String userId, String email) {
User user = new User();
Date now = new Date();
user.setUserName(userId);
user.setEmail(email);
user.setUserType(userType);
user.setCreateTime(now);
user.setUpdateTime(now);
user.setQueue("");
userMapper.insert(user);
return user;
}
/**
* get user by user name
*
* @param userName user name
* @return exist user or null
*/
@Override
public User getUserByUserName(String userName) {
return userMapper.queryByUserNameAccurately(userName);
}
/**
* query user by id
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | * @param id id
* @return user info
*/
@Override
public User queryUser(int id) {
return userMapper.selectById(id);
}
@Override
public List<User> queryUser(List<Integer> ids) {
if (CollectionUtils.isEmpty(ids)) {
return new ArrayList<>();
}
return userMapper.selectByIds(ids);
}
/**
* query user
*
* @param name name
* @return user info
*/
@Override
public User queryUser(String name) {
return userMapper.queryByUserNameAccurately(name);
}
/**
* query user
*
* @param name name
* @param password password
* @return user info |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | */
@Override
public User queryUser(String name, String password) {
String md5 = EncryptionUtils.getMd5(password);
return userMapper.queryUserByNamePassword(name, md5);
}
/**
* get user id by user name
*
* @param name user name
* @return if name empty 0, user not exists -1, user exist user id
*/
@Override
public int getUserIdByName(String name) {
int executorId = 0;
if (StringUtils.isNotEmpty(name)) {
User executor = queryUser(name);
if (null != executor) {
executorId = executor.getId();
} else {
executorId = -1;
}
}
return executorId;
}
/**
* query user list
*
* @param loginUser login user |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | * @param pageNo page number
* @param searchVal search avlue
* @param pageSize page size
* @return user list page
*/
@Override
public Map<String, Object> queryUserList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
Map<String, Object> result = new HashMap<>();
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
return result;
}
Page<User> page = new Page<>(pageNo, pageSize);
IPage<User> scheduleList = userMapper.queryUserPaging(page, searchVal);
PageInfo<User> pageInfo = new PageInfo<>(pageNo, pageSize);
pageInfo.setTotalCount((int) scheduleList.getTotal());
pageInfo.setLists(scheduleList.getRecords());
result.put(Constants.DATA_LIST, pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* updateProcessInstance user
*
*
* @param loginUser
* @param userId user id
* @param userName user name
* @param userPassword user password
* @param email email
* @param tenantId tennat id |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | * @param phone phone
* @param queue queue
* @return update result code
* @throws Exception exception
*/
@Override
public Map<String, Object> updateUser(User loginUser, int userId,
String userName,
String userPassword,
String email,
int tenantId,
String phone,
String queue,
int state) throws IOException {
Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false);
if (check(result, !hasPerm(loginUser, userId), Status.USER_NO_OPERATION_PERM)) {
return result;
}
User user = userMapper.selectById(userId);
if (user == null) {
putMsg(result, Status.USER_NOT_EXIST, userId);
return result;
}
if (StringUtils.isNotEmpty(userName)) {
if (!CheckUtils.checkUserName(userName)) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName);
return result;
}
User tempUser = userMapper.queryByUserNameAccurately(userName); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | if (tempUser != null && tempUser.getId() != userId) {
putMsg(result, Status.USER_NAME_EXIST);
return result;
}
user.setUserName(userName);
}
if (StringUtils.isNotEmpty(userPassword)) {
if (!CheckUtils.checkPassword(userPassword)) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userPassword);
return result;
}
user.setUserPassword(EncryptionUtils.getMd5(userPassword));
}
if (StringUtils.isNotEmpty(email)) {
if (!CheckUtils.checkEmail(email)) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, email);
return result;
}
user.setEmail(email);
}
if (StringUtils.isNotEmpty(phone) && !CheckUtils.checkPhone(phone)) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, phone);
return result;
}
user.setPhone(phone);
user.setQueue(queue);
user.setState(state);
Date now = new Date();
user.setUpdateTime(now); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | if (user.getTenantId() != tenantId) {
Tenant oldTenant = tenantMapper.queryById(user.getTenantId());
Tenant newTenant = tenantMapper.queryById(tenantId);
if (newTenant != null) {
if (PropertyUtils.getResUploadStartupState() && oldTenant != null) {
String newTenantCode = newTenant.getTenantCode();
String oldResourcePath = HadoopUtils.getHdfsResDir(oldTenant.getTenantCode());
String oldUdfsPath = HadoopUtils.getHdfsUdfDir(oldTenant.getTenantCode());
if (HadoopUtils.getInstance().exists(oldResourcePath)) {
String newResourcePath = HadoopUtils.getHdfsResDir(newTenantCode);
String newUdfsPath = HadoopUtils.getHdfsUdfDir(newTenantCode);
List<Resource> fileResourcesList = resourceMapper.queryResourceList(
null, userId, ResourceType.FILE.ordinal());
if (CollectionUtils.isNotEmpty(fileResourcesList)) {
ResourceTreeVisitor resourceTreeVisitor = new ResourceTreeVisitor(fileResourcesList);
ResourceComponent resourceComponent = resourceTreeVisitor.visit();
copyResourceFiles(resourceComponent, oldResourcePath, newResourcePath);
}
List<Resource> udfResourceList = resourceMapper.queryResourceList(
null, userId, ResourceType.UDF.ordinal());
if (CollectionUtils.isNotEmpty(udfResourceList)) {
ResourceTreeVisitor resourceTreeVisitor = new ResourceTreeVisitor(udfResourceList);
ResourceComponent resourceComponent = resourceTreeVisitor.visit();
copyResourceFiles(resourceComponent, oldUdfsPath, newUdfsPath);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | String oldUserPath = HadoopUtils.getHdfsUserDir(oldTenant.getTenantCode(), userId);
HadoopUtils.getInstance().delete(oldUserPath, true);
} else {
createTenantDirIfNotExists(oldTenant.getTenantCode());
}
if (HadoopUtils.getInstance().exists(HadoopUtils.getHdfsTenantDir(newTenant.getTenantCode()))) {
String newUserPath = HadoopUtils.getHdfsUserDir(newTenant.getTenantCode(), user.getId());
HadoopUtils.getInstance().mkdir(newUserPath);
} else {
createTenantDirIfNotExists(newTenant.getTenantCode());
}
}
}
user.setTenantId(tenantId);
}
userMapper.updateById(user);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* delete user
*
* @param loginUser login user
* @param id user id
* @return delete result code |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | * @throws Exception exception when operate hdfs
*/
@Override
public Map<String, Object> deleteUserById(User loginUser, int id) throws IOException {
Map<String, Object> result = new HashMap<>();
if (!isAdmin(loginUser)) {
putMsg(result, Status.USER_NO_OPERATION_PERM, id);
return result;
}
User tempUser = userMapper.selectById(id);
if (tempUser == null) {
putMsg(result, Status.USER_NOT_EXIST, id);
return result;
}
List<Project> projects = projectMapper.queryProjectCreatedByUser(id);
if (CollectionUtils.isNotEmpty(projects)) {
String projectNames = projects.stream().map(Project::getName).collect(Collectors.joining(","));
putMsg(result, Status.TRANSFORM_PROJECT_OWNERSHIP, projectNames);
return result;
}
User user = userMapper.queryTenantCodeByUserId(id);
if (user != null) {
if (PropertyUtils.getResUploadStartupState()) {
String userPath = HadoopUtils.getHdfsUserDir(user.getTenantCode(), id);
if (HadoopUtils.getInstance().exists(userPath)) {
HadoopUtils.getInstance().delete(userPath, true); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | }
}
}
userMapper.deleteById(id);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* grant project
*
* @param loginUser login user
* @param userId user id
* @param projectIds project id array
* @return grant result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> grantProject(User loginUser, int userId, String projectIds) {
Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false);
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
return result;
}
User tempUser = userMapper.selectById(userId);
if (tempUser == null) {
putMsg(result, Status.USER_NOT_EXIST, userId);
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | if (check(result, StringUtils.isEmpty(projectIds), Status.SUCCESS)) {
projectUserMapper.deleteProjectRelation(0, userId);
return result;
}
String[] projectIdArr = projectIds.split(",");
for (String projectId : projectIdArr) {
Date now = new Date();
ProjectUser projectUser = new ProjectUser();
projectUser.setUserId(userId);
projectUser.setProjectId(Integer.parseInt(projectId));
projectUser.setPerm(7);
projectUser.setCreateTime(now);
projectUser.setUpdateTime(now);
projectUserMapper.insert(projectUser);
}
putMsg(result, Status.SUCCESS);
return result;
}
/**
* grant resource
*
* @param loginUser login user
* @param userId user id
* @param resourceIds resource id array
* @return grant result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> grantResources(User loginUser, int userId, String resourceIds) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | Map<String, Object> result = new HashMap<>();
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
return result;
}
User user = userMapper.selectById(userId);
if (user == null) {
putMsg(result, Status.USER_NOT_EXIST, userId);
return result;
}
Set<Integer> needAuthorizeResIds = new HashSet<>();
if (StringUtils.isNotBlank(resourceIds)) {
String[] resourceFullIdArr = resourceIds.split(",");
for (String resourceFullId : resourceFullIdArr) {
String[] resourceIdArr = resourceFullId.split("-");
for (int i = 0; i <= resourceIdArr.length - 1; i++) {
int resourceIdValue = Integer.parseInt(resourceIdArr[i]);
needAuthorizeResIds.add(resourceIdValue);
}
}
}
List<Integer> resIds = resourceUserMapper.queryResourcesIdListByUserIdAndPerm(userId, Constants.AUTHORIZE_WRITABLE_PERM);
List<Resource> oldAuthorizedRes = CollectionUtils.isEmpty(resIds) ? new ArrayList<>() : resourceMapper.queryResourceListById(resIds);
Set<Integer> oldAuthorizedResIds = oldAuthorizedRes.stream().map(Resource::getId).collect(Collectors.toSet());
oldAuthorizedResIds.removeAll(needAuthorizeResIds);
if (CollectionUtils.isNotEmpty(oldAuthorizedResIds)) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | List<Map<String, Object>> list = processDefinitionMapper.listResourcesByUser(userId);
Map<Integer, Set<Long>> resourceProcessMap = ResourceProcessDefinitionUtils.getResourceProcessDefinitionMap(list);
Set<Integer> resourceIdSet = resourceProcessMap.keySet();
resourceIdSet.retainAll(oldAuthorizedResIds);
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;
}
}
resourceUserMapper.deleteResourceUser(userId, 0);
if (check(result, StringUtils.isEmpty(resourceIds), Status.SUCCESS)) {
return result;
}
for (int resourceIdValue : needAuthorizeResIds) {
Resource resource = resourceMapper.selectById(resourceIdValue);
if (resource == null) {
putMsg(result, Status.RESOURCE_NOT_EXIST);
return result;
}
Date now = new Date();
ResourcesUser resourcesUser = new ResourcesUser();
resourcesUser.setUserId(userId);
resourcesUser.setResourcesId(resourceIdValue);
if (resource.isDirectory()) {
resourcesUser.setPerm(Constants.AUTHORIZE_READABLE_PERM); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | } else {
resourcesUser.setPerm(Constants.AUTHORIZE_WRITABLE_PERM);
}
resourcesUser.setCreateTime(now);
resourcesUser.setUpdateTime(now);
resourceUserMapper.insert(resourcesUser);
}
putMsg(result, Status.SUCCESS);
return result;
}
/**
* grant udf function
*
* @param loginUser login user
* @param userId user id
* @param udfIds udf id array
* @return grant result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> grantUDFFunction(User loginUser, int userId, String udfIds) {
Map<String, Object> result = new HashMap<>();
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
return result;
}
User user = userMapper.selectById(userId);
if (user == null) {
putMsg(result, Status.USER_NOT_EXIST, userId);
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | }
udfUserMapper.deleteByUserId(userId);
if (check(result, StringUtils.isEmpty(udfIds), Status.SUCCESS)) {
return result;
}
String[] resourcesIdArr = udfIds.split(",");
for (String udfId : resourcesIdArr) {
Date now = new Date();
UDFUser udfUser = new UDFUser();
udfUser.setUserId(userId);
udfUser.setUdfId(Integer.parseInt(udfId));
udfUser.setPerm(7);
udfUser.setCreateTime(now);
udfUser.setUpdateTime(now);
udfUserMapper.insert(udfUser);
}
putMsg(result, Status.SUCCESS);
return result;
}
/**
* grant datasource
*
* @param loginUser login user
* @param userId user id
* @param datasourceIds data source id array
* @return grant result code
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> grantDataSource(User loginUser, int userId, String datasourceIds) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false);
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
return result;
}
User user = userMapper.selectById(userId);
if (user == null) {
putMsg(result, Status.USER_NOT_EXIST, userId);
return result;
}
datasourceUserMapper.deleteByUserId(userId);
if (check(result, StringUtils.isEmpty(datasourceIds), Status.SUCCESS)) {
return result;
}
String[] datasourceIdArr = datasourceIds.split(",");
for (String datasourceId : datasourceIdArr) {
Date now = new Date();
DatasourceUser datasourceUser = new DatasourceUser();
datasourceUser.setUserId(userId);
datasourceUser.setDatasourceId(Integer.parseInt(datasourceId));
datasourceUser.setPerm(7);
datasourceUser.setCreateTime(now);
datasourceUser.setUpdateTime(now);
datasourceUserMapper.insert(datasourceUser);
}
putMsg(result, Status.SUCCESS);
return result;
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | * query user info
*
* @param loginUser login user
* @return user info
*/
@Override
public Map<String, Object> getUserInfo(User loginUser) {
Map<String, Object> result = new HashMap<>();
User user = null;
if (loginUser.getUserType() == UserType.ADMIN_USER) {
user = loginUser;
} else {
user = userMapper.queryDetailsById(loginUser.getId());
List<AlertGroup> alertGroups = alertGroupMapper.queryByUserId(loginUser.getId());
StringBuilder sb = new StringBuilder();
if (alertGroups != null && !alertGroups.isEmpty()) {
for (int i = 0; i < alertGroups.size() - 1; i++) {
sb.append(alertGroups.get(i).getGroupName() + ",");
}
sb.append(alertGroups.get(alertGroups.size() - 1));
user.setAlertGroup(sb.toString());
}
}
result.put(Constants.DATA_LIST, user);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query user list
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | * @param loginUser login user
* @return user list
*/
@Override
public Map<String, Object> queryAllGeneralUsers(User loginUser) {
Map<String, Object> result = new HashMap<>();
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
return result;
}
List<User> userList = userMapper.queryAllGeneralUser();
result.put(Constants.DATA_LIST, userList);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query user list
*
* @param loginUser login user
* @return user list
*/
@Override
public Map<String, Object> queryUserList(User loginUser) {
Map<String, Object> result = new HashMap<>();
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
return result;
}
List<User> userList = userMapper.selectList(null);
result.put(Constants.DATA_LIST, userList); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | putMsg(result, Status.SUCCESS);
return result;
}
/**
* verify user name exists
*
* @param userName user name
* @return true if user name not exists, otherwise return false
*/
@Override
public Result<Object> verifyUserName(String userName) {
Result<Object> result = new Result<>();
User user = userMapper.queryByUserNameAccurately(userName);
if (user != null) {
putMsg(result, Status.USER_NAME_EXIST);
} else {
putMsg(result, Status.SUCCESS);
}
return result;
}
/**
* unauthorized user
*
* @param loginUser login user
* @param alertgroupId alert group id
* @return unauthorize result code
*/
@Override
public Map<String, Object> unauthorizedUser(User loginUser, Integer alertgroupId) {
Map<String, Object> result = new HashMap<>(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
return result;
}
List<User> userList = userMapper.selectList(null);
List<User> resultUsers = new ArrayList<>();
Set<User> userSet = null;
if (userList != null && !userList.isEmpty()) {
userSet = new HashSet<>(userList);
List<User> authedUserList = userMapper.queryUserListByAlertGroupId(alertgroupId);
Set<User> authedUserSet = null;
if (authedUserList != null && !authedUserList.isEmpty()) {
authedUserSet = new HashSet<>(authedUserList);
userSet.removeAll(authedUserSet);
}
resultUsers = new ArrayList<>(userSet);
}
result.put(Constants.DATA_LIST, resultUsers);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* authorized user
*
* @param loginUser login user
* @param alertgroupId alert group id
* @return authorized result code
*/
@Override
public Map<String, Object> authorizedUser(User loginUser, Integer alertgroupId) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | Map<String, Object> result = new HashMap<>();
if (check(result, !isAdmin(loginUser), Status.USER_NO_OPERATION_PERM)) {
return result;
}
List<User> userList = userMapper.queryUserListByAlertGroupId(alertgroupId);
result.put(Constants.DATA_LIST, userList);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* @param tenantId tenant id
* @return true if tenant exists, otherwise return false
*/
private boolean checkTenantExists(int tenantId) {
return tenantMapper.queryById(tenantId) != null;
}
/**
* @return if check failed return the field, otherwise return null
*/
private String checkUserParams(String userName, String password, String email, String phone) {
String msg = null;
if (!CheckUtils.checkUserName(userName)) {
msg = userName;
} else if (!CheckUtils.checkPassword(password)) {
msg = password;
} else if (!CheckUtils.checkEmail(email)) {
msg = email;
} else if (!CheckUtils.checkPhone(phone)) {
msg = phone; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | }
return msg;
}
/**
* copy resource files
*
* @param resourceComponent resource component
* @param srcBasePath src base path
* @param dstBasePath dst base path
* @throws IOException io exception
*/
private void copyResourceFiles(ResourceComponent resourceComponent, String srcBasePath, String dstBasePath) throws IOException {
List<ResourceComponent> components = resourceComponent.getChildren();
if (CollectionUtils.isNotEmpty(components)) {
for (ResourceComponent component : components) {
if (!HadoopUtils.getInstance().exists(String.format("%s/%s", srcBasePath, component.getFullName()))) {
logger.error("resource file: {} not exist,copy error", component.getFullName());
throw new ServiceException(Status.RESOURCE_NOT_EXIST);
}
if (!component.isDirctory()) {
HadoopUtils.getInstance().copy(String.format("%s/%s", srcBasePath, component.getFullName()), String.format("%s/%s", dstBasePath, component.getFullName()), false, true);
continue;
}
if (CollectionUtils.isEmpty(component.getChildren())) {
if (!HadoopUtils.getInstance().exists(String.format("%s/%s", dstBasePath, component.getFullName()))) {
HadoopUtils.getInstance().mkdir(String.format("%s/%s", dstBasePath, component.getFullName()));
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | } else {
copyResourceFiles(component, srcBasePath, dstBasePath);
}
}
}
}
/**
* registry user, default state is 0, default tenant_id is 1, no phone, no queue
*
* @param userName user name
* @param userPassword user password
* @param repeatPassword repeat password
* @param email email
* @return registry result code
* @throws Exception exception
*/
@Override
@Transactional(rollbackFor = RuntimeException.class)
public Map<String, Object> registerUser(String userName, String userPassword, String repeatPassword, String email) {
Map<String, Object> result = new HashMap<>();
String msg = this.checkUserParams(userName, userPassword, email, "");
if (!StringUtils.isEmpty(msg)) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, msg);
return result;
}
if (!userPassword.equals(repeatPassword)) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, "two passwords are not same");
return result;
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | User user = createUser(userName, userPassword, email, 1, "", "", Flag.NO.ordinal());
putMsg(result, Status.SUCCESS);
result.put(Constants.DATA_LIST, user);
return result;
}
/**
* activate user, only system admin have permission, change user state code 0 to 1
*
* @param loginUser login user
* @param userName user name
* @return create result code
*/
@Override
public Map<String, Object> activateUser(User loginUser, String userName) {
Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false);
if (!isAdmin(loginUser)) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
if (!CheckUtils.checkUserName(userName)) {
putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName);
return result;
}
User user = userMapper.queryByUserNameAccurately(userName);
if (user == null) {
putMsg(result, Status.USER_NOT_EXIST, userName);
return result;
}
if (user.getState() != Flag.NO.ordinal()) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | putMsg(result, Status.REQUEST_PARAMS_NOT_VALID_ERROR, userName);
return result;
}
user.setState(Flag.YES.ordinal());
Date now = new Date();
user.setUpdateTime(now);
userMapper.updateById(user);
User responseUser = userMapper.queryByUserNameAccurately(userName);
putMsg(result, Status.SUCCESS);
result.put(Constants.DATA_LIST, responseUser);
return result;
}
/**
* activate user, only system admin have permission, change users state code 0 to 1
*
* @param loginUser login user
* @param userNames user name
* @return create result code
*/
@Override
public Map<String, Object> batchActivateUser(User loginUser, List<String> userNames) {
Map<String, Object> result = new HashMap<>();
if (!isAdmin(loginUser)) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
int totalSuccess = 0;
List<String> successUserNames = new ArrayList<>();
Map<String, Object> successRes = new HashMap<>();
int totalFailed = 0; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/UsersServiceImpl.java | List<Map<String, String>> failedInfo = new ArrayList<>();
Map<String, Object> failedRes = new HashMap<>();
for (String userName : userNames) {
Map<String, Object> tmpResult = activateUser(loginUser, userName);
if (tmpResult.get(Constants.STATUS) != Status.SUCCESS) {
totalFailed++;
Map<String, String> failedBody = new HashMap<>();
failedBody.put("userName", userName);
Status status = (Status) tmpResult.get(Constants.STATUS);
String errorMessage = MessageFormat.format(status.getMsg(), userName);
failedBody.put("msg", errorMessage);
failedInfo.add(failedBody);
} else {
totalSuccess++;
successUserNames.add(userName);
}
}
successRes.put("sum", totalSuccess);
successRes.put("userName", successUserNames);
failedRes.put("sum", totalFailed);
failedRes.put("info", failedInfo);
Map<String, Object> res = new HashMap<>();
res.put("success", successRes);
res.put("failed", failedRes);
putMsg(result, Status.SUCCESS);
result.put(Constants.DATA_LIST, res);
return result;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.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;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.when;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.impl.UsersServiceImpl;
import org.apache.dolphinscheduler.api.utils.PageInfo; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ResourceType;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
import org.apache.dolphinscheduler.common.utils.EncryptionUtils;
import org.apache.dolphinscheduler.dao.entity.AlertGroup;
import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.Resource;
import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper;
import org.apache.dolphinscheduler.dao.mapper.DataSourceUserMapper;
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
import org.apache.dolphinscheduler.dao.mapper.ProjectUserMapper;
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.UDFUserMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.junit.After;
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; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
/**
* users service test
*/
@RunWith(MockitoJUnitRunner.class)
public class UsersServiceTest {
private static final Logger logger = LoggerFactory.getLogger(UsersServiceTest.class);
@InjectMocks
private UsersServiceImpl usersService;
@Mock
private UserMapper userMapper;
@Mock
private TenantMapper tenantMapper;
@Mock
private ResourceMapper resourceMapper;
@Mock
private AlertGroupMapper alertGroupMapper;
@Mock
private DataSourceUserMapper datasourceUserMapper;
@Mock
private ProjectUserMapper projectUserMapper;
@Mock
private ResourceUserMapper resourceUserMapper;
@Mock |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | private UDFUserMapper udfUserMapper;
@Mock
private ProjectMapper projectMapper;
private String queueName = "UsersServiceTestQueue";
@Before
public void before() {
}
@After
public void after() {
}
@Test
public void testCreateUserForLdap() {
String userName = "user1";
String email = "[email protected]";
User user = usersService.createUser(UserType.ADMIN_USER, userName, email);
Assert.assertNotNull(user);
}
@Test
public void testCreateUser() {
User user = new User();
user.setUserType(UserType.ADMIN_USER);
String userName = "userTest0001~";
String userPassword = "userTest";
String email = "[email protected]";
int tenantId = Integer.MAX_VALUE;
String phone = "13456432345";
int state = 1;
try {
Map<String, Object> result = usersService.createUser(user, userName, userPassword, email, tenantId, phone, queueName, state); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | logger.info(result.toString());
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS));
userName = "userTest0001";
userPassword = "userTest000111111111111111";
result = usersService.createUser(user, userName, userPassword, email, tenantId, phone, queueName, state);
logger.info(result.toString());
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS));
userPassword = "userTest0001";
email = "1q.com";
result = usersService.createUser(user, userName, userPassword, email, tenantId, phone, queueName, state);
logger.info(result.toString());
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS));
email = "[email protected]";
phone = "2233";
result = usersService.createUser(user, userName, userPassword, email, tenantId, phone, queueName, state);
logger.info(result.toString());
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS));
phone = "13456432345";
result = usersService.createUser(user, userName, userPassword, email, tenantId, phone, queueName, state);
logger.info(result.toString());
Assert.assertEquals(Status.TENANT_NOT_EXIST, result.get(Constants.STATUS));
Mockito.when(tenantMapper.queryById(1)).thenReturn(getTenant());
result = usersService.createUser(user, userName, userPassword, email, 1, phone, queueName, state);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | } catch (Exception e) {
logger.error(Status.CREATE_USER_ERROR.getMsg(), e);
Assert.assertTrue(false);
}
}
@Test
public void testQueryUser() {
String userName = "userTest0001";
String userPassword = "userTest0001";
when(userMapper.queryUserByNamePassword(userName, EncryptionUtils.getMd5(userPassword))).thenReturn(getGeneralUser());
User queryUser = usersService.queryUser(userName, userPassword);
logger.info(queryUser.toString());
Assert.assertTrue(queryUser != null);
}
@Test
public void testSelectByIds() {
List<Integer> ids = new ArrayList<>();
List<User> users = usersService.queryUser(ids);
Assert.assertTrue(users.isEmpty());
ids.add(1);
List<User> userList = new ArrayList<>();
userList.add(new User());
when(userMapper.selectByIds(ids)).thenReturn(userList);
List<User> userList1 = usersService.queryUser(ids);
Assert.assertFalse(userList1.isEmpty());
}
@Test
public void testGetUserIdByName() {
User user = new User();
user.setId(1); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | user.setUserType(UserType.ADMIN_USER);
user.setUserName("test_user");
int userId = usersService.getUserIdByName("");
Assert.assertEquals(0, userId);
when(usersService.queryUser(user.getUserName())).thenReturn(null);
int userNotExistId = usersService.getUserIdByName(user.getUserName());
Assert.assertEquals(-1, userNotExistId);
when(usersService.queryUser(user.getUserName())).thenReturn(user);
int userExistId = usersService.getUserIdByName(user.getUserName());
Assert.assertEquals(user.getId(), userExistId);
}
@Test
public void testQueryUserList() {
User user = new User();
Map<String, Object> result = usersService.queryUserList(user);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
user.setUserType(UserType.ADMIN_USER);
when(userMapper.selectList(null)).thenReturn(getUserList());
result = usersService.queryUserList(user);
List<User> userList = (List<User>) result.get(Constants.DATA_LIST);
Assert.assertTrue(userList.size() > 0);
}
@Test
public void testQueryUserListPage() { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | User user = new User();
IPage<User> page = new Page<>(1, 10);
page.setRecords(getUserList());
when(userMapper.queryUserPaging(any(Page.class), eq("userTest"))).thenReturn(page);
Map<String, Object> result = usersService.queryUserList(user, "userTest", 1, 10);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
user.setUserType(UserType.ADMIN_USER);
result = usersService.queryUserList(user, "userTest", 1, 10);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
PageInfo<User> pageInfo = (PageInfo<User>) result.get(Constants.DATA_LIST);
Assert.assertTrue(pageInfo.getLists().size() > 0);
}
@Test
public void testUpdateUser() {
String userName = "userTest0001";
String userPassword = "userTest0001";
try {
Map<String, Object> result = usersService.updateUser(getLoginUser(), 0,userName,userPassword,"[email protected]",1,"13457864543","queue", 1);
Assert.assertEquals(Status.USER_NOT_EXIST, result.get(Constants.STATUS));
logger.info(result.toString());
when(userMapper.selectById(1)).thenReturn(getUser());
result = usersService.updateUser(getLoginUser(), 1,userName,userPassword,"[email protected]",1,"13457864543","queue", 1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
} catch (Exception e) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | logger.error("update user error", e);
Assert.assertTrue(false);
}
}
@Test
public void testDeleteUserById() {
User loginUser = new User();
try {
when(userMapper.queryTenantCodeByUserId(1)).thenReturn(getUser());
when(userMapper.selectById(1)).thenReturn(getUser());
Map<String, Object> result = usersService.deleteUserById(loginUser, 3);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
loginUser.setUserType(UserType.ADMIN_USER);
result = usersService.deleteUserById(loginUser, 3);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NOT_EXIST, result.get(Constants.STATUS));
Mockito.when(projectMapper.queryProjectCreatedByUser(1)).thenReturn(Lists.newArrayList(new Project()));
result = usersService.deleteUserById(loginUser, 1);
Assert.assertEquals(Status.TRANSFORM_PROJECT_OWNERSHIP, result.get(Constants.STATUS));
Mockito.when(projectMapper.queryProjectCreatedByUser(1)).thenReturn(null);
result = usersService.deleteUserById(loginUser, 1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
} catch (Exception e) {
logger.error("delete user error", e); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | Assert.assertTrue(false);
}
}
@Test
public void testGrantProject() {
when(userMapper.selectById(1)).thenReturn(getUser());
User loginUser = new User();
String projectIds = "100000,120000";
Map<String, Object> result = usersService.grantProject(loginUser, 1, projectIds);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
loginUser.setUserType(UserType.ADMIN_USER);
result = usersService.grantProject(loginUser, 2, projectIds);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NOT_EXIST, result.get(Constants.STATUS));
result = usersService.grantProject(loginUser, 1, projectIds);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}
@Test
public void testGrantResources() {
String resourceIds = "100000,120000";
when(userMapper.selectById(1)).thenReturn(getUser());
User loginUser = new User();
Map<String, Object> result = usersService.grantResources(loginUser, 1, resourceIds);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | loginUser.setUserType(UserType.ADMIN_USER);
result = usersService.grantResources(loginUser, 2, resourceIds);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NOT_EXIST, result.get(Constants.STATUS));
when(resourceMapper.selectById(Mockito.anyInt())).thenReturn(getResource());
when(resourceUserMapper.deleteResourceUser(1, 0)).thenReturn(1);
result = usersService.grantResources(loginUser, 1, resourceIds);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}
@Test
public void testGrantUDFFunction() {
String udfIds = "100000,120000";
when(userMapper.selectById(1)).thenReturn(getUser());
User loginUser = new User();
Map<String, Object> result = usersService.grantUDFFunction(loginUser, 1, udfIds);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
loginUser.setUserType(UserType.ADMIN_USER);
result = usersService.grantUDFFunction(loginUser, 2, udfIds);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NOT_EXIST, result.get(Constants.STATUS));
when(udfUserMapper.deleteByUserId(1)).thenReturn(1);
result = usersService.grantUDFFunction(loginUser, 1, udfIds);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | @Test
public void testGrantDataSource() {
String datasourceIds = "100000,120000";
when(userMapper.selectById(1)).thenReturn(getUser());
User loginUser = new User();
Map<String, Object> result = usersService.grantDataSource(loginUser, 1, datasourceIds);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
loginUser.setUserType(UserType.ADMIN_USER);
result = usersService.grantDataSource(loginUser, 2, datasourceIds);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NOT_EXIST, result.get(Constants.STATUS));
when(datasourceUserMapper.deleteByUserId(Mockito.anyInt())).thenReturn(1);
result = usersService.grantDataSource(loginUser, 1, datasourceIds);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}
private User getLoginUser(){
User loginUser = new User();
loginUser.setId(1);
loginUser.setUserType(UserType.ADMIN_USER);
return loginUser;
}
@Test
public void getUserInfo() {
User loginUser = new User();
loginUser.setUserName("admin");
loginUser.setUserType(UserType.ADMIN_USER); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | Map<String, Object> result = usersService.getUserInfo(loginUser);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
User tempUser = (User) result.get(Constants.DATA_LIST);
Assert.assertEquals("admin", tempUser.getUserName());
loginUser.setUserType(null);
loginUser.setId(1);
when(userMapper.queryDetailsById(1)).thenReturn(getGeneralUser());
when(alertGroupMapper.queryByUserId(1)).thenReturn(getAlertGroups());
result = usersService.getUserInfo(loginUser);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
tempUser = (User) result.get(Constants.DATA_LIST);
Assert.assertEquals("userTest0001", tempUser.getUserName());
}
@Test
public void testQueryAllGeneralUsers() {
User loginUser = new User();
Map<String, Object> result = usersService.queryAllGeneralUsers(loginUser);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
loginUser.setUserType(UserType.ADMIN_USER);
when(userMapper.queryAllGeneralUser()).thenReturn(getUserList());
result = usersService.queryAllGeneralUsers(loginUser); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<User> userList = (List<User>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(userList));
}
@Test
public void testVerifyUserName() {
Result result = usersService.verifyUserName("admin89899");
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS.getMsg(), result.getMsg());
when(userMapper.queryByUserNameAccurately("userTest0001")).thenReturn(getUser());
result = usersService.verifyUserName("userTest0001");
logger.info(result.toString());
Assert.assertEquals(Status.USER_NAME_EXIST.getMsg(), result.getMsg());
}
@Test
public void testUnauthorizedUser() {
User loginUser = new User();
when(userMapper.selectList(null)).thenReturn(getUserList());
when(userMapper.queryUserListByAlertGroupId(2)).thenReturn(getUserList());
Map<String, Object> result = usersService.unauthorizedUser(loginUser, 2);
logger.info(result.toString());
loginUser.setUserType(UserType.ADMIN_USER);
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
result = usersService.unauthorizedUser(loginUser, 2);
logger.info(result.toString()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}
@Test
public void testAuthorizedUser() {
User loginUser = new User();
when(userMapper.queryUserListByAlertGroupId(2)).thenReturn(getUserList());
Map<String, Object> result = usersService.authorizedUser(loginUser, 2);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
loginUser.setUserType(UserType.ADMIN_USER);
result = usersService.authorizedUser(loginUser, 2);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
List<User> userList = (List<User>) result.get(Constants.DATA_LIST);
logger.info(result.toString());
Assert.assertTrue(CollectionUtils.isNotEmpty(userList));
}
@Test
public void testRegisterUser() {
String userName = "userTest0002~";
String userPassword = "userTest";
String repeatPassword = "userTest";
String email = "[email protected]";
try {
Map<String, Object> result = usersService.registerUser(userName, userPassword, repeatPassword, email);
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS));
userName = "userTest0002";
userPassword = "userTest000111111111111111"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | result = usersService.registerUser(userName, userPassword, repeatPassword, email);
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS));
userPassword = "userTest0002";
email = "1q.com";
result = usersService.registerUser(userName, userPassword, repeatPassword, email);
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS));
email = "[email protected]";
repeatPassword = "userPassword";
result = usersService.registerUser(userName, userPassword, repeatPassword, email);
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS));
repeatPassword = "userTest0002";
result = usersService.registerUser(userName, userPassword, repeatPassword, email);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
} catch (Exception e) {
Assert.assertTrue(false);
}
}
@Test
public void testActivateUser() {
User user = new User();
user.setUserType(UserType.GENERAL_USER);
String userName = "userTest0002~";
try {
Map<String, Object> result = usersService.activateUser(user, userName);
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | user.setUserType(UserType.ADMIN_USER);
result = usersService.activateUser(user, userName);
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS));
userName = "userTest10013";
result = usersService.activateUser(user, userName);
Assert.assertEquals(Status.USER_NOT_EXIST, result.get(Constants.STATUS));
userName = "userTest0001";
when(userMapper.queryByUserNameAccurately(userName)).thenReturn(getUser());
result = usersService.activateUser(user, userName);
Assert.assertEquals(Status.REQUEST_PARAMS_NOT_VALID_ERROR, result.get(Constants.STATUS));
when(userMapper.queryByUserNameAccurately(userName)).thenReturn(getDisabledUser());
result = usersService.activateUser(user, userName);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
} catch (Exception e) {
Assert.assertTrue(false);
}
}
@Test
public void testBatchActivateUser() {
User user = new User();
user.setUserType(UserType.GENERAL_USER);
List<String> userNames = new ArrayList<>();
userNames.add("userTest0001");
userNames.add("userTest0002");
userNames.add("userTest0003~");
userNames.add("userTest0004"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | try {
Map<String, Object> result = usersService.batchActivateUser(user, userNames);
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
user.setUserType(UserType.ADMIN_USER);
when(userMapper.queryByUserNameAccurately("userTest0001")).thenReturn(getUser());
when(userMapper.queryByUserNameAccurately("userTest0002")).thenReturn(getDisabledUser());
result = usersService.batchActivateUser(user, userNames);
Map<String, Object> responseData = (Map<String, Object>) result.get(Constants.DATA_LIST);
Map<String, Object> successData = (Map<String, Object>) responseData.get("success");
int totalSuccess = (Integer) successData.get("sum");
Map<String, Object> failedData = (Map<String, Object>) responseData.get("failed");
int totalFailed = (Integer) failedData.get("sum");
Assert.assertEquals(1, totalSuccess);
Assert.assertEquals(3, totalFailed);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
} catch (Exception e) {
Assert.assertTrue(false);
}
}
/**
* get disabled user
*/
private User getDisabledUser() {
User user = new User();
user.setUserType(UserType.GENERAL_USER);
user.setUserName("userTest0001");
user.setUserPassword("userTest0001");
user.setState(0); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | return user;
}
/**
* get user
*/
private User getGeneralUser() {
User user = new User();
user.setUserType(UserType.GENERAL_USER);
user.setUserName("userTest0001");
user.setUserPassword("userTest0001");
return user;
}
private List<User> getUserList() {
List<User> userList = new ArrayList<>();
userList.add(getGeneralUser());
return userList;
}
/**
* get user
*/
private User getUser() {
User user = new User();
user.setUserType(UserType.ADMIN_USER);
user.setUserName("userTest0001");
user.setUserPassword("userTest0001");
user.setState(1);
return user;
}
/**
* get tenant |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UsersServiceTest.java | *
* @return tenant
*/
private Tenant getTenant() {
Tenant tenant = new Tenant();
tenant.setId(1);
return tenant;
}
/**
* get resource
*
* @return resource
*/
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 List<AlertGroup> getAlertGroups() {
List<AlertGroup> alertGroups = new ArrayList<>();
AlertGroup alertGroup = new AlertGroup();
alertGroups.add(alertGroup);
return alertGroups;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapper.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.AccessToken;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
/**
* accesstoken mapper interface
*/
public interface AccessTokenMapper extends BaseMapper<AccessToken> { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapper.java | /**
* access token page
* @param page page
* @param userName userName
* @param userId userId
* @return access token Ipage
*/
IPage<AccessToken> selectAccessTokenPage(Page page,
@Param("userName") String userName,
@Param("userId") int userId
);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapperTest.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. |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapperTest.java | */
package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.dao.entity.AccessToken;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dolphinscheduler.dao.entity.User;
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 javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.*;
/**
* AccessToken mapper test
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
@Rollback |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapperTest.java | public class AccessTokenMapperTest {
@Autowired
AccessTokenMapper accessTokenMapper;
@Autowired
UserMapper userMapper;
/**
* test insert
*
* @throws Exception
*/
@Test
public void testInsert() throws Exception {
Integer userId = 1;
AccessToken accessToken = createAccessToken(userId);
assertThat(accessToken.getId(), greaterThan(0));
}
/**
* test select by id
*
* @throws Exception
*/
@Test
public void testSelectById() throws Exception {
Integer userId = 1;
AccessToken accessToken = createAccessToken(userId);
AccessToken resultAccessToken = accessTokenMapper.selectById(accessToken.getId());
assertEquals(accessToken, resultAccessToken);
}
/**
* test hashCode method |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapperTest.java | *
* @throws Exception
*/
@Test
public void testHashCodeMethod() throws Exception {
Integer userId = 1;
AccessToken accessToken = createAccessToken(userId);
AccessToken resultAccessToken = accessTokenMapper.selectById(accessToken.getId());
boolean flag = accessToken.equals(resultAccessToken);
assertTrue(flag);
}
/**
* test equals method
*
* @throws Exception
*/
@Test
public void testEqualsMethod() throws Exception {
Integer userId = 1;
AccessToken accessToken = createAccessToken(userId);
int result = accessToken.hashCode();
assertNotNull(result);
}
/**
* test page
*/
@Test
public void testSelectAccessTokenPage() throws Exception {
Integer count = 4;
String userName = "zhangsan"; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapperTest.java | Integer offset = 2;
Integer size = 2;
Map<Integer, AccessToken> accessTokenMap = createAccessTokens(count, userName);
Page page = new Page(offset, size);
IPage<AccessToken> accessTokenPage = accessTokenMapper.selectAccessTokenPage(page, userName, 0);
assertEquals(Integer.valueOf(accessTokenPage.getRecords().size()), size);
for (AccessToken accessToken : accessTokenPage.getRecords()) {
AccessToken resultAccessToken = accessTokenMap.get(accessToken.getId());
assertEquals(accessToken, resultAccessToken);
}
}
/**
* test update
*/
@Test
public void testUpdate() throws Exception {
Integer userId = 1;
AccessToken accessToken = createAccessToken(userId);
accessToken.setToken("56789");
accessToken.setExpireTime(DateUtils.getCurrentDate());
accessToken.setUpdateTime(DateUtils.getCurrentDate());
int status = accessTokenMapper.updateById(accessToken);
if (status != 1) {
Assert.fail("update access token fail");
}
AccessToken resultAccessToken = accessTokenMapper.selectById(accessToken.getId());
assertEquals(accessToken, resultAccessToken);
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapperTest.java | * test delete
*/
@Test
public void testDelete() throws Exception {
Integer userId = 1;
AccessToken accessToken = createAccessToken(userId);
int status = accessTokenMapper.deleteById(accessToken.getId());
if (status != 1) {
Assert.fail("delete access token data fail");
}
AccessToken resultAccessToken =
accessTokenMapper.selectById(accessToken.getId());
assertNull(resultAccessToken);
}
/**
* create accessTokens
*
* @param count create accessToken count
* @param userName username
* @return accessToken map
* @throws Exception
*/
private Map<Integer, AccessToken> createAccessTokens(
Integer count, String userName) throws Exception {
User user = createUser(userName);
Map<Integer, AccessToken> accessTokenMap = new HashMap<>();
for (int i = 1; i <= count; i++) {
AccessToken accessToken = createAccessToken(user.getId(), userName);
accessTokenMap.put(accessToken.getId(), accessToken);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapperTest.java | return accessTokenMap;
}
/**
* create user
*
* @param userName userName
* @return user
* @throws Exception
*/
private User createUser(String userName) throws Exception {
User user = new User();
user.setUserName(userName);
user.setUserPassword("123");
user.setUserType(UserType.GENERAL_USER);
user.setEmail("[email protected]");
user.setPhone("13102557272");
user.setTenantId(1);
user.setCreateTime(DateUtils.getCurrentDate());
user.setUpdateTime(DateUtils.getCurrentDate());
user.setQueue("default");
int status = userMapper.insert(user);
if (status != 1) {
Assert.fail("insert user data error");
}
return user;
}
/**
* create access token
*
* @param userId userId |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,701 | [Bug][UI][DAO]When deleting a user, the accessToken associated with the user should also be deleted | When deleting a user, the accessToken associated with the user should be also deleted
1. create a normal user

2. add an accesstoken associated with the user created in the step 1.

3. delete the user created in the step 1, then have a look at the accessToken:

**Which version of Dolphin Scheduler:**
1.3.7-release
| https://github.com/apache/dolphinscheduler/issues/5701 | https://github.com/apache/dolphinscheduler/pull/5697 | 239cfe5027b558abe1f17b1e7dd38504f10ab3e0 | 8d7d3a816672c196cf827055ce0221efcac68b55 | "2021-06-26T13:17:23Z" | java | "2021-06-28T17:27:39Z" | dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AccessTokenMapperTest.java | * @param userName userName
* @return accessToken
* @throws Exception
*/
private AccessToken createAccessToken(Integer userId, String userName) throws Exception {
AccessToken accessToken = new AccessToken();
accessToken.setUserName(userName);
accessToken.setUserId(userId);
accessToken.setToken(String.valueOf(ThreadLocalRandom.current().nextLong()));
accessToken.setCreateTime(DateUtils.getCurrentDate());
accessToken.setUpdateTime(DateUtils.getCurrentDate());
accessToken.setExpireTime(DateUtils.getCurrentDate());
int status = accessTokenMapper.insert(accessToken);
if (status != 1) {
Assert.fail("insert data error");
}
return accessToken;
}
/**
* create access token
*
* @param userId userId
* @return accessToken
* @throws Exception
*/
private AccessToken createAccessToken(Integer userId) throws Exception {
return createAccessToken(userId, null);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,714 | [Improvement][Plugin] When updating the existing alarm instance, the `creation time` should't be updated. | When updating the existing alarm instance, it would cause the `creation time` to be always same with the `modification time`
+ when create a new alam instance, `creation time` and `update time` is same, it's right.

+ when I try to update the existing alarm instance, after updating success, the 'creation time' changes, it's wrong:

| https://github.com/apache/dolphinscheduler/issues/5714 | https://github.com/apache/dolphinscheduler/pull/5715 | 2ba569acd028c00c22f4853de7c58251ac72816c | cf99df3de00ef63ee96b7ab00427c7385c42720a | "2021-06-29T11:45:35Z" | java | "2021-07-04T15:46:47Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.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 org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.AlertPluginInstanceService;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.vo.AlertPluginInstanceVO;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.utils.BooleanUtils;
import org.apache.dolphinscheduler.common.utils.CollectionUtils;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance;
import org.apache.dolphinscheduler.dao.entity.PluginDefine; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,714 | [Improvement][Plugin] When updating the existing alarm instance, the `creation time` should't be updated. | When updating the existing alarm instance, it would cause the `creation time` to be always same with the `modification time`
+ when create a new alam instance, `creation time` and `update time` is same, it's right.

+ when I try to update the existing alarm instance, after updating success, the 'creation time' changes, it's wrong:

| https://github.com/apache/dolphinscheduler/issues/5714 | https://github.com/apache/dolphinscheduler/pull/5715 | 2ba569acd028c00c22f4853de7c58251ac72816c | cf99df3de00ef63ee96b7ab00427c7385c42720a | "2021-06-29T11:45:35Z" | java | "2021-07-04T15:46:47Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java | import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper;
import org.apache.dolphinscheduler.dao.mapper.AlertPluginInstanceMapper;
import org.apache.dolphinscheduler.dao.mapper.PluginDefineMapper;
import org.apache.dolphinscheduler.spi.params.PluginParamsTransfer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* alert plugin instance service impl
*/
@Service
@Lazy
public class AlertPluginInstanceServiceImpl extends BaseServiceImpl implements AlertPluginInstanceService {
@Autowired
private AlertPluginInstanceMapper alertPluginInstanceMapper;
@Autowired
private PluginDefineMapper pluginDefineMapper;
@Autowired
private AlertGroupMapper alertGroupMapper; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,714 | [Improvement][Plugin] When updating the existing alarm instance, the `creation time` should't be updated. | When updating the existing alarm instance, it would cause the `creation time` to be always same with the `modification time`
+ when create a new alam instance, `creation time` and `update time` is same, it's right.

+ when I try to update the existing alarm instance, after updating success, the 'creation time' changes, it's wrong:

| https://github.com/apache/dolphinscheduler/issues/5714 | https://github.com/apache/dolphinscheduler/pull/5715 | 2ba569acd028c00c22f4853de7c58251ac72816c | cf99df3de00ef63ee96b7ab00427c7385c42720a | "2021-06-29T11:45:35Z" | java | "2021-07-04T15:46:47Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java | /**
* creat alert plugin instance
*
* @param loginUser login user
* @param pluginDefineId plugin define id
* @param instanceName instance name
* @param pluginInstanceParams plugin instance params
*/
@Override
public Map<String, Object> create(User loginUser, int pluginDefineId, String instanceName, String pluginInstanceParams) {
AlertPluginInstance alertPluginInstance = new AlertPluginInstance();
String paramsMapJson = parsePluginParamsMap(pluginInstanceParams);
alertPluginInstance.setPluginInstanceParams(paramsMapJson);
alertPluginInstance.setInstanceName(instanceName);
alertPluginInstance.setPluginDefineId(pluginDefineId);
Map<String, Object> result = new HashMap<>();
if (BooleanUtils.isTrue(alertPluginInstanceMapper.existInstanceName(alertPluginInstance.getInstanceName()))) {
putMsg(result, Status.PLUGIN_INSTANCE_ALREADY_EXIT);
return result;
}
int i = alertPluginInstanceMapper.insert(alertPluginInstance);
if (i > 0) {
putMsg(result, Status.SUCCESS);
return result;
}
putMsg(result, Status.SAVE_ERROR);
return result;
}
/**
* update alert plugin instance |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,714 | [Improvement][Plugin] When updating the existing alarm instance, the `creation time` should't be updated. | When updating the existing alarm instance, it would cause the `creation time` to be always same with the `modification time`
+ when create a new alam instance, `creation time` and `update time` is same, it's right.

+ when I try to update the existing alarm instance, after updating success, the 'creation time' changes, it's wrong:

| https://github.com/apache/dolphinscheduler/issues/5714 | https://github.com/apache/dolphinscheduler/pull/5715 | 2ba569acd028c00c22f4853de7c58251ac72816c | cf99df3de00ef63ee96b7ab00427c7385c42720a | "2021-06-29T11:45:35Z" | java | "2021-07-04T15:46:47Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java | *
* @param loginUser login user
* @param pluginInstanceId plugin instance id
* @param instanceName instance name
* @param pluginInstanceParams plugin instance params
*/
@Override
public Map<String, Object> update(User loginUser, int pluginInstanceId, String instanceName, String pluginInstanceParams) {
AlertPluginInstance alertPluginInstance = new AlertPluginInstance();
String paramsMapJson = parsePluginParamsMap(pluginInstanceParams);
alertPluginInstance.setPluginInstanceParams(paramsMapJson);
alertPluginInstance.setInstanceName(instanceName);
alertPluginInstance.setId(pluginInstanceId);
Map<String, Object> result = new HashMap<>();
int i = alertPluginInstanceMapper.updateById(alertPluginInstance);
if (i > 0) {
putMsg(result, Status.SUCCESS);
return result;
}
putMsg(result, Status.SAVE_ERROR);
return result;
}
/**
* delete alert plugin instance
*
* @param loginUser login user
* @param id id
* @return result
*/
@Override |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,714 | [Improvement][Plugin] When updating the existing alarm instance, the `creation time` should't be updated. | When updating the existing alarm instance, it would cause the `creation time` to be always same with the `modification time`
+ when create a new alam instance, `creation time` and `update time` is same, it's right.

+ when I try to update the existing alarm instance, after updating success, the 'creation time' changes, it's wrong:

| https://github.com/apache/dolphinscheduler/issues/5714 | https://github.com/apache/dolphinscheduler/pull/5715 | 2ba569acd028c00c22f4853de7c58251ac72816c | cf99df3de00ef63ee96b7ab00427c7385c42720a | "2021-06-29T11:45:35Z" | java | "2021-07-04T15:46:47Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java | public Map<String, Object> delete(User loginUser, int id) {
Map<String, Object> result = new HashMap<>();
boolean hasAssociatedAlertGroup = checkHasAssociatedAlertGroup(String.valueOf(id));
if (hasAssociatedAlertGroup) {
putMsg(result, Status.DELETE_ALERT_PLUGIN_INSTANCE_ERROR_HAS_ALERT_GROUP_ASSOCIATED);
return result;
}
int i = alertPluginInstanceMapper.deleteById(id);
if (i > 0) {
putMsg(result, Status.SUCCESS);
}
return result;
}
/**
* get alert plugin instance
*
* @param loginUser login user
* @param id get id
* @return alert plugin
*/
@Override
public Map<String, Object> get(User loginUser, int id) {
Map<String, Object> result = new HashMap<>();
AlertPluginInstance alertPluginInstance = alertPluginInstanceMapper.selectById(id);
if (null != alertPluginInstance) {
putMsg(result, Status.SUCCESS);
result.put(Constants.DATA_LIST, alertPluginInstance);
}
return result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,714 | [Improvement][Plugin] When updating the existing alarm instance, the `creation time` should't be updated. | When updating the existing alarm instance, it would cause the `creation time` to be always same with the `modification time`
+ when create a new alam instance, `creation time` and `update time` is same, it's right.

+ when I try to update the existing alarm instance, after updating success, the 'creation time' changes, it's wrong:

| https://github.com/apache/dolphinscheduler/issues/5714 | https://github.com/apache/dolphinscheduler/pull/5715 | 2ba569acd028c00c22f4853de7c58251ac72816c | cf99df3de00ef63ee96b7ab00427c7385c42720a | "2021-06-29T11:45:35Z" | java | "2021-07-04T15:46:47Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java | }
@Override
public Map<String, Object> queryAll() {
Map<String, Object> result = new HashMap<>();
List<AlertPluginInstance> alertPluginInstances = alertPluginInstanceMapper.queryAllAlertPluginInstanceList();
List<AlertPluginInstanceVO> alertPluginInstanceVOS = buildPluginInstanceVOList(alertPluginInstances);
if (null != alertPluginInstances) {
putMsg(result, Status.SUCCESS);
result.put(Constants.DATA_LIST, alertPluginInstanceVOS);
}
return result;
}
@Override
public boolean checkExistPluginInstanceName(String pluginInstanceName) {
return BooleanUtils.isTrue(alertPluginInstanceMapper.existInstanceName(pluginInstanceName));
}
@Override
public Map<String, Object> queryPluginPage(int pageIndex, int pageSize) {
IPage<AlertPluginInstance> pluginInstanceIPage = new Page<>(pageIndex, pageSize);
pluginInstanceIPage = alertPluginInstanceMapper.selectPage(pluginInstanceIPage, null);
PageInfo<AlertPluginInstanceVO> pageInfo = new PageInfo<>(pageIndex, pageSize);
pageInfo.setTotalCount((int) pluginInstanceIPage.getTotal());
pageInfo.setLists(buildPluginInstanceVOList(pluginInstanceIPage.getRecords()));
Map<String, Object> result = new HashMap<>();
result.put(Constants.DATA_LIST, pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
private List<AlertPluginInstanceVO> buildPluginInstanceVOList(List<AlertPluginInstance> alertPluginInstances) {
if (CollectionUtils.isEmpty(alertPluginInstances)) { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,714 | [Improvement][Plugin] When updating the existing alarm instance, the `creation time` should't be updated. | When updating the existing alarm instance, it would cause the `creation time` to be always same with the `modification time`
+ when create a new alam instance, `creation time` and `update time` is same, it's right.

+ when I try to update the existing alarm instance, after updating success, the 'creation time' changes, it's wrong:

| https://github.com/apache/dolphinscheduler/issues/5714 | https://github.com/apache/dolphinscheduler/pull/5715 | 2ba569acd028c00c22f4853de7c58251ac72816c | cf99df3de00ef63ee96b7ab00427c7385c42720a | "2021-06-29T11:45:35Z" | java | "2021-07-04T15:46:47Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java | return null;
}
List<PluginDefine> pluginDefineList = pluginDefineMapper.queryAllPluginDefineList();
if (CollectionUtils.isEmpty(pluginDefineList)) {
return null;
}
Map<Integer, PluginDefine> pluginDefineMap = pluginDefineList.stream().collect(Collectors.toMap(PluginDefine::getId, Function.identity()));
List<AlertPluginInstanceVO> alertPluginInstanceVOS = new ArrayList<>();
alertPluginInstances.forEach(alertPluginInstance -> {
AlertPluginInstanceVO alertPluginInstanceVO = new AlertPluginInstanceVO();
alertPluginInstanceVO.setCreateTime(alertPluginInstance.getCreateTime());
alertPluginInstanceVO.setUpdateTime(alertPluginInstance.getUpdateTime());
alertPluginInstanceVO.setPluginDefineId(alertPluginInstance.getPluginDefineId());
alertPluginInstanceVO.setInstanceName(alertPluginInstance.getInstanceName());
alertPluginInstanceVO.setId(alertPluginInstance.getId());
PluginDefine pluginDefine = pluginDefineMap.get(alertPluginInstance.getPluginDefineId());
if (null == pluginDefine) {
return;
}
alertPluginInstanceVO.setAlertPluginName(pluginDefine.getPluginName());
String pluginParamsMapString = alertPluginInstance.getPluginInstanceParams();
String uiPluginParams = parseToPluginUiParams(pluginParamsMapString, pluginDefine.getPluginParams());
alertPluginInstanceVO.setPluginInstanceParams(uiPluginParams);
alertPluginInstanceVOS.add(alertPluginInstanceVO);
});
return alertPluginInstanceVOS;
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,714 | [Improvement][Plugin] When updating the existing alarm instance, the `creation time` should't be updated. | When updating the existing alarm instance, it would cause the `creation time` to be always same with the `modification time`
+ when create a new alam instance, `creation time` and `update time` is same, it's right.

+ when I try to update the existing alarm instance, after updating success, the 'creation time' changes, it's wrong:

| https://github.com/apache/dolphinscheduler/issues/5714 | https://github.com/apache/dolphinscheduler/pull/5715 | 2ba569acd028c00c22f4853de7c58251ac72816c | cf99df3de00ef63ee96b7ab00427c7385c42720a | "2021-06-29T11:45:35Z" | java | "2021-07-04T15:46:47Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AlertPluginInstanceServiceImpl.java | * Get the parameters actually needed by the plugin
*
* @param pluginParams Complete parameters(include ui)
* @return k, v(json string)
*/
private String parsePluginParamsMap(String pluginParams) {
Map<String, String> paramsMap = PluginParamsTransfer.getPluginParamsMap(pluginParams);
return JSONUtils.toJsonString(paramsMap);
}
/**
* parse To Plugin Ui Params
*
* @param pluginParamsMapString k-v data
* @param pluginUiParams Complete parameters(include ui)
* @return Complete parameters list(include ui)
*/
private String parseToPluginUiParams(String pluginParamsMapString, String pluginUiParams) {
List<Map<String, Object>> pluginParamsList = PluginParamsTransfer.generatePluginParams(pluginParamsMapString, pluginUiParams);
return JSONUtils.toJsonString(pluginParamsList);
}
private boolean checkHasAssociatedAlertGroup(String id) {
List<String> idsList = alertGroupMapper.queryInstanceIdsList();
if (CollectionUtils.isEmpty(idsList)) {
return false;
}
Optional<String> first = idsList.stream().filter(k -> null != k && Arrays.asList(k.split(",")).contains(id)).findFirst();
return first.isPresent();
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,714 | [Improvement][Plugin] When updating the existing alarm instance, the `creation time` should't be updated. | When updating the existing alarm instance, it would cause the `creation time` to be always same with the `modification time`
+ when create a new alam instance, `creation time` and `update time` is same, it's right.

+ when I try to update the existing alarm instance, after updating success, the 'creation time' changes, it's wrong:

| https://github.com/apache/dolphinscheduler/issues/5714 | https://github.com/apache/dolphinscheduler/pull/5715 | 2ba569acd028c00c22f4853de7c58251ac72816c | cf99df3de00ef63ee96b7ab00427c7385c42720a | "2021-06-29T11:45:35Z" | java | "2021-07-04T15:46:47Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AlertPluginInstance.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.entity;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
/**
* t_ds_alert_plugin_instance
*/
@TableName("t_ds_alert_plugin_instance") |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,714 | [Improvement][Plugin] When updating the existing alarm instance, the `creation time` should't be updated. | When updating the existing alarm instance, it would cause the `creation time` to be always same with the `modification time`
+ when create a new alam instance, `creation time` and `update time` is same, it's right.

+ when I try to update the existing alarm instance, after updating success, the 'creation time' changes, it's wrong:

| https://github.com/apache/dolphinscheduler/issues/5714 | https://github.com/apache/dolphinscheduler/pull/5715 | 2ba569acd028c00c22f4853de7c58251ac72816c | cf99df3de00ef63ee96b7ab00427c7385c42720a | "2021-06-29T11:45:35Z" | java | "2021-07-04T15:46:47Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AlertPluginInstance.java | public class AlertPluginInstance {
/**
* id
*/
@TableId(value = "id", type = IdType.AUTO)
private int id;
/**
* plugin_define_id
*/
@TableField(value = "plugin_define_id", updateStrategy = FieldStrategy.NEVER)
private int pluginDefineId;
/**
* alert plugin instance name
*/
@TableField("instance_name")
private String instanceName;
/**
* plugin_instance_params
*/
@TableField("plugin_instance_params") |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,714 | [Improvement][Plugin] When updating the existing alarm instance, the `creation time` should't be updated. | When updating the existing alarm instance, it would cause the `creation time` to be always same with the `modification time`
+ when create a new alam instance, `creation time` and `update time` is same, it's right.

+ when I try to update the existing alarm instance, after updating success, the 'creation time' changes, it's wrong:

| https://github.com/apache/dolphinscheduler/issues/5714 | https://github.com/apache/dolphinscheduler/pull/5715 | 2ba569acd028c00c22f4853de7c58251ac72816c | cf99df3de00ef63ee96b7ab00427c7385c42720a | "2021-06-29T11:45:35Z" | java | "2021-07-04T15:46:47Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AlertPluginInstance.java | private String pluginInstanceParams;
/**
* create_time
*/
@TableField("create_time")
private Date createTime;
/**
* update_time
*/
@TableField("update_time")
private Date updateTime;
public AlertPluginInstance() {
this.createTime = new Date();
this.updateTime = new Date();
}
public AlertPluginInstance(int pluginDefineId, String pluginInstanceParams, String instanceName) {
this.pluginDefineId = pluginDefineId;
this.pluginInstanceParams = pluginInstanceParams;
this.createTime = new Date();
this.updateTime = new Date();
this.instanceName = instanceName;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getPluginDefineId() {
return pluginDefineId; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,714 | [Improvement][Plugin] When updating the existing alarm instance, the `creation time` should't be updated. | When updating the existing alarm instance, it would cause the `creation time` to be always same with the `modification time`
+ when create a new alam instance, `creation time` and `update time` is same, it's right.

+ when I try to update the existing alarm instance, after updating success, the 'creation time' changes, it's wrong:

| https://github.com/apache/dolphinscheduler/issues/5714 | https://github.com/apache/dolphinscheduler/pull/5715 | 2ba569acd028c00c22f4853de7c58251ac72816c | cf99df3de00ef63ee96b7ab00427c7385c42720a | "2021-06-29T11:45:35Z" | java | "2021-07-04T15:46:47Z" | dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AlertPluginInstance.java | }
public void setPluginDefineId(int pluginDefineId) {
this.pluginDefineId = pluginDefineId;
}
public String getPluginInstanceParams() {
return pluginInstanceParams;
}
public void setPluginInstanceParams(String pluginInstanceParams) {
this.pluginInstanceParams = pluginInstanceParams;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getInstanceName() {
return instanceName;
}
public void setInstanceName(String instanceName) {
this.instanceName = instanceName;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.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.controller;
import static org.apache.dolphinscheduler.api.enums.Status.CREATE_SCHEDULE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.DELETE_SCHEDULE_CRON_BY_ID_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.OFFLINE_SCHEDULE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.PREVIEW_SCHEDULE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.PUBLISH_SCHEDULE_ONLINE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_SCHEDULE_LIST_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_SCHEDULE_LIST_PAGING_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_SCHEDULE_ERROR;
import static org.apache.dolphinscheduler.common.Constants.SESSION_USER;
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ApiException; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | import org.apache.dolphinscheduler.api.service.SchedulerService;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.utils.ParameterUtils;
import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import springfox.documentation.annotations.ApiIgnore;
/**
* scheduler controller
*/
@Api(tags = "SCHEDULER_TAG") |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | @RestController
@RequestMapping("/projects/{projectCode}/schedule")
public class SchedulerController extends BaseController {
public static final String DEFAULT_WARNING_TYPE = "NONE";
public static final String DEFAULT_NOTIFY_GROUP_ID = "1";
public static final String DEFAULT_FAILURE_POLICY = "CONTINUE";
public static final String DEFAULT_PROCESS_INSTANCE_PRIORITY = "MEDIUM";
@Autowired
private SchedulerService schedulerService;
/**
* create schedule
*
* @param loginUser login user
* @param projectCode project code
* @param processDefinitionCode process definition code
* @param schedule scheduler
* @param warningType warning type
* @param warningGroupId warning group id
* @param failureStrategy failure strategy
* @param processInstancePriority process instance priority
* @param workerGroup worker group
* @return create result code |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | */
@ApiOperation(value = "createSchedule", notes = "CREATE_SCHEDULE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "processDefinitionCode", value = "PROCESS_DEFINITION_CODE", required = true, dataType = "Long", example = "100"),
@ApiImplicitParam(name = "schedule", value = "SCHEDULE", dataType = "String",
example = "{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','timezoneId':'America/Phoenix','crontab':'0 0 3/6 * * ? *'}"),
@ApiImplicitParam(name = "warningType", value = "WARNING_TYPE", type = "WarningType"),
@ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "failureStrategy", value = "FAILURE_STRATEGY", type = "FailureStrategy"),
@ApiImplicitParam(name = "workerGroupId", value = "WORKER_GROUP_ID", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", type = "Priority"),
})
@PostMapping("/create")
@ResponseStatus(HttpStatus.CREATED)
@ApiException(CREATE_SCHEDULE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result createSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectCode", value = "PROJECT_CODE", required = true) @PathVariable long projectCode,
@RequestParam(value = "processDefinitionCode") long processDefinitionCode,
@RequestParam(value = "schedule") String schedule,
@RequestParam(value = "warningType", required = false, defaultValue = DEFAULT_WARNING_TYPE) WarningType warningType,
@RequestParam(value = "warningGroupId", required = false, defaultValue = DEFAULT_NOTIFY_GROUP_ID) int warningGroupId,
@RequestParam(value = "failureStrategy", required = false, defaultValue = DEFAULT_FAILURE_POLICY) FailureStrategy failureStrategy,
@RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup,
@RequestParam(value = "processInstancePriority", required = false, defaultValue = DEFAULT_PROCESS_INSTANCE_PRIORITY) Priority processInstancePriority) {
Map<String, Object> result = schedulerService.insertSchedule(loginUser, projectCode, processDefinitionCode, schedule,
warningType, warningGroupId, failureStrategy, processInstancePriority, workerGroup);
return returnDataList(result);
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | * updateProcessInstance schedule
*
* @param loginUser login user
* @param projectName project name
* @param id scheduler id
* @param schedule scheduler
* @param warningType warning type
* @param warningGroupId warning group id
* @param failureStrategy failure strategy
* @param workerGroup worker group
* @param processInstancePriority process instance priority
* @return update result code
*/
@ApiOperation(value = "updateSchedule", notes = "UPDATE_SCHEDULE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100"),
@ApiImplicitParam(name = "schedule", value = "SCHEDULE", dataType = "String", example = "{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','crontab':'0 0 3/6 * * ? *'}"),
@ApiImplicitParam(name = "warningType", value = "WARNING_TYPE", type = "WarningType"),
@ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "failureStrategy", value = "FAILURE_STRATEGY", type = "FailureStrategy"),
@ApiImplicitParam(name = "workerGroupId", value = "WORKER_GROUP_ID", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", type = "Priority"),
})
@PostMapping("/update")
@ApiException(UPDATE_SCHEDULE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result updateSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
@RequestParam(value = "id") Integer id,
@RequestParam(value = "schedule") String schedule, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | @RequestParam(value = "warningType", required = false, defaultValue = DEFAULT_WARNING_TYPE) WarningType warningType,
@RequestParam(value = "warningGroupId", required = false) int warningGroupId,
@RequestParam(value = "failureStrategy", required = false, defaultValue = "END") FailureStrategy failureStrategy,
@RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup,
@RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority) {
Map<String, Object> result = schedulerService.updateSchedule(loginUser, projectName, id, schedule,
warningType, warningGroupId, failureStrategy, null, processInstancePriority, workerGroup);
return returnDataList(result);
}
/**
* publish schedule setScheduleState
*
* @param loginUser login user
* @param projectName project name
* @param id scheduler id
* @return publish result code
*/
@ApiOperation(value = "online", notes = "ONLINE_SCHEDULE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100")
})
@PostMapping("/online")
@ApiException(PUBLISH_SCHEDULE_ONLINE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result online(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
@RequestParam("id") Integer id) {
Map<String, Object> result = schedulerService.setScheduleState(loginUser, projectName, id, ReleaseState.ONLINE);
return returnDataList(result);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | /**
* offline schedule
*
* @param loginUser login user
* @param projectName project name
* @param id schedule id
* @return operation result code
*/
@ApiOperation(value = "offline", notes = "OFFLINE_SCHEDULE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100")
})
@PostMapping("/offline")
@ApiException(OFFLINE_SCHEDULE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result offline(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
@RequestParam("id") Integer id) {
Map<String, Object> result = schedulerService.setScheduleState(loginUser, projectName, id, ReleaseState.OFFLINE);
return returnDataList(result);
}
/**
* query schedule list paging
*
* @param loginUser login user
* @param projectName project name
* @param processDefinitionId process definition id
* @param pageNo page number
* @param pageSize page size
* @param searchVal search value |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | * @return schedule list page
*/
@ApiOperation(value = "queryScheduleListPaging", notes = "QUERY_SCHEDULE_LIST_PAGING_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100"),
@ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", type = "String"),
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", dataType = "Int", example = "100"),
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", dataType = "Int", example = "100")
})
@GetMapping("/list-paging")
@ApiException(QUERY_SCHEDULE_LIST_PAGING_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result queryScheduleListPaging(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
@RequestParam Integer processDefinitionId,
@RequestParam(value = "searchVal", required = false) String searchVal,
@RequestParam("pageNo") Integer pageNo,
@RequestParam("pageSize") Integer pageSize) {
Map<String, Object> result = checkPageParams(pageNo, pageSize);
if (result.get(Constants.STATUS) != Status.SUCCESS) {
return returnDataListPaging(result);
}
searchVal = ParameterUtils.handleEscapes(searchVal);
result = schedulerService.querySchedule(loginUser, projectName, processDefinitionId, searchVal, pageNo, pageSize);
return returnDataListPaging(result);
}
/**
* delete schedule by id
*
* @param loginUser login user |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | * @param projectName project name
* @param scheduleId scheule id
* @return delete result code
*/
@ApiOperation(value = "deleteScheduleById", notes = "OFFLINE_SCHEDULE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "scheduleId", value = "SCHEDULE_ID", required = true, dataType = "Int", example = "100")
})
@GetMapping(value = "/delete")
@ResponseStatus(HttpStatus.OK)
@ApiException(DELETE_SCHEDULE_CRON_BY_ID_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result deleteScheduleById(@RequestAttribute(value = SESSION_USER) User loginUser,
@PathVariable String projectName,
@RequestParam("scheduleId") Integer scheduleId
) {
Map<String, Object> result = schedulerService.deleteScheduleById(loginUser, projectName, scheduleId);
return returnDataList(result);
}
/**
* query schedule list
*
* @param loginUser login user
* @param projectName project name
* @return schedule list
*/
@ApiOperation(value = "queryScheduleList", notes = "QUERY_SCHEDULE_LIST_NOTES")
@PostMapping("/list")
@ApiException(QUERY_SCHEDULE_LIST_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser") |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/SchedulerController.java | public Result queryScheduleList(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName) {
Map<String, Object> result = schedulerService.queryScheduleList(loginUser, projectName);
return returnDataList(result);
}
/**
* preview schedule
*
* @param loginUser login user
* @param projectName project name
* @param schedule schedule expression
* @return the next five fire time
*/
@ApiOperation(value = "previewSchedule", notes = "PREVIEW_SCHEDULE_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "schedule", value = "SCHEDULE", dataType = "String", example = "{'startTime':'2019-06-10 00:00:00','endTime':'2019-06-13 00:00:00','crontab':'0 0 3/6 * * ? *'}"),
})
@PostMapping("/preview")
@ResponseStatus(HttpStatus.CREATED)
@ApiException(PREVIEW_SCHEDULE_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result previewSchedule(@ApiIgnore @RequestAttribute(value = SESSION_USER) User loginUser,
@ApiParam(name = "projectName", value = "PROJECT_NAME", required = true) @PathVariable String projectName,
@RequestParam(value = "schedule") String schedule
) {
Map<String, Object> result = schedulerService.previewSchedule(loginUser, projectName, schedule);
return returnDataList(result);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.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;
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Map;
/**
* scheduler service
*/
public interface SchedulerService { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java | /**
* save schedule
*
* @param loginUser login user
* @param projectCode project code
* @param processDefineCode process definition code
* @param schedule scheduler
* @param warningType warning type
* @param warningGroupId warning group id
* @param failureStrategy failure strategy
* @param processInstancePriority process instance priority
* @param workerGroup worker group
* @return create result code
*/
Map<String, Object> insertSchedule(User loginUser,
long projectCode,
long processDefineCode,
String schedule,
WarningType warningType, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 5,511 | [Feature][JsonSplit-api]schedule update interface | from #5498
remove the request parameter workerGroupId,including the front end and controller interface | https://github.com/apache/dolphinscheduler/issues/5511 | https://github.com/apache/dolphinscheduler/pull/5761 | d382a7ba8c454b41944958c6e42692843a765234 | cfa22d7c89bcd8e35b8a286b39b67b9b36b3b4dc | "2021-05-18T13:58:16Z" | java | "2021-07-07T10:15:19Z" | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java | int warningGroupId,
FailureStrategy failureStrategy,
Priority processInstancePriority,
String workerGroup);
/**
* updateProcessInstance schedule
*
* @param loginUser login user
* @param projectName project name
* @param id scheduler id
* @param scheduleExpression scheduler
* @param warningType warning type
* @param warningGroupId warning group id
* @param failureStrategy failure strategy
* @param workerGroup worker group
* @param processInstancePriority process instance priority
* @param scheduleStatus schedule status
* @return update result code
*/
Map<String, Object> updateSchedule(User loginUser,
String projectName,
Integer id,
String scheduleExpression,
WarningType warningType,
int warningGroupId,
FailureStrategy failureStrategy,
ReleaseState scheduleStatus,
Priority processInstancePriority,
String workerGroup);
/** |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.