status
stringclasses 1
value | repo_name
stringclasses 31
values | repo_url
stringclasses 31
values | issue_id
int64 1
104k
| title
stringlengths 4
233
| body
stringlengths 0
186k
⌀ | issue_url
stringlengths 38
56
| pull_url
stringlengths 37
54
| before_fix_sha
stringlengths 40
40
| after_fix_sha
stringlengths 40
40
| report_datetime
timestamp[us, tz=UTC] | language
stringclasses 5
values | commit_datetime
timestamp[us, tz=UTC] | updated_file
stringlengths 7
188
| chunk_content
stringlengths 1
1.03M
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.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.AccessTokenService;
import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.EncryptionUtils;
import org.apache.dolphinscheduler.dao.entity.AccessToken;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* access token service impl
*/
@Service
public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTokenService {
private static final Logger logger = LoggerFactory.getLogger(AccessTokenServiceImpl.class);
@Autowired
private AccessTokenMapper accessTokenMapper;
/**
* query access token list
*
* @param loginUser login user
* @param searchVal search value
* @param pageNo page number |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | * @param pageSize page size
* @return token list for page number and page size
*/
@Override
public Result queryAccessTokenList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
Result result = new Result();
PageInfo<AccessToken> pageInfo = new PageInfo<>(pageNo, pageSize);
Page<AccessToken> page = new Page<>(pageNo, pageSize);
int userId = loginUser.getId();
if (loginUser.getUserType() == UserType.ADMIN_USER) {
userId = 0;
}
IPage<AccessToken> accessTokenList = accessTokenMapper.selectAccessTokenPage(page, searchVal, userId);
pageInfo.setTotal((int) accessTokenList.getTotal());
pageInfo.setTotalList(accessTokenList.getRecords());
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query access token for specified user
*
* @param loginUser login user
* @param userId user id
* @return token list for specified user
*/
@Override
public Map<String, Object> queryAccessTokenByUser(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | if (isNotAdmin(loginUser, result)) {
return result;
}
List<AccessToken> accessTokenList = this.accessTokenMapper.queryAccessTokenByUser(userId);
result.put(Constants.DATA_LIST, accessTokenList);
this.putMsg(result, Status.SUCCESS);
return result;
}
/**
* create token
*
* @param userId token for user
* @param expireTime token expire time
* @param token token string
* @return create result code
*/
@SuppressWarnings("checkstyle:WhitespaceAround")
@Override
public Map<String, Object> createToken(User loginUser, int userId, String expireTime, String token) {
Map<String, Object> result = new HashMap<>();
if (!hasPerm(loginUser,userId)) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
if (userId <= 0) {
throw new IllegalArgumentException("User id should not less than or equals to 0.");
}
AccessToken accessToken = new AccessToken(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | accessToken.setUserId(userId);
accessToken.setExpireTime(DateUtils.stringToDate(expireTime));
accessToken.setToken(token);
accessToken.setCreateTime(new Date());
accessToken.setUpdateTime(new Date());
int insert = accessTokenMapper.insert(accessToken);
if (insert > 0) {
result.put(Constants.DATA_LIST, accessToken);
putMsg(result, Status.SUCCESS);
} else {
putMsg(result, Status.CREATE_ACCESS_TOKEN_ERROR);
}
return result;
}
/**
* generate token
*
* @param userId token for user
* @param expireTime token expire time
* @return token string
*/
@Override
public Map<String, Object> generateToken(User loginUser, int userId, String expireTime) {
Map<String, Object> result = new HashMap<>();
if (!hasPerm(loginUser,userId)) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
String token = EncryptionUtils.getMd5(userId + expireTime + System.currentTimeMillis()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | result.put(Constants.DATA_LIST, token);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* delete access token
*
* @param loginUser login user
* @param id token id
* @return delete result code
*/
@Override
public Map<String, Object> delAccessTokenById(User loginUser, int id) {
Map<String, Object> result = new HashMap<>();
AccessToken accessToken = accessTokenMapper.selectById(id);
if (accessToken == null) {
logger.error("access token not exist, access token id {}", id);
putMsg(result, Status.ACCESS_TOKEN_NOT_EXIST);
return result;
}
if (!hasPerm(loginUser,accessToken.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
accessTokenMapper.deleteById(id);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* update token by id |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | *
* @param id token id
* @param userId token for user
* @param expireTime token expire time
* @param token token string
* @return update result code
*/
@Override
public Map<String, Object> updateToken(User loginUser, int id, int userId, String expireTime, String token) {
Map<String, Object> result = new HashMap<>();
if (!hasPerm(loginUser,userId)) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
AccessToken accessToken = accessTokenMapper.selectById(id);
if (accessToken == null) {
logger.error("access token not exist, access token id {}", id);
putMsg(result, Status.ACCESS_TOKEN_NOT_EXIST);
return result;
}
accessToken.setUserId(userId);
accessToken.setExpireTime(DateUtils.stringToDate(expireTime));
accessToken.setToken(token);
accessToken.setUpdateTime(new Date());
accessTokenMapper.updateById(accessToken);
putMsg(result, Status.SUCCESS);
return result;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.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.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.utils.Result; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java | import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
/**
* access token controller test
*/
public class AccessTokenControllerTest extends AbstractControllerTest {
private static final Logger logger = LoggerFactory.getLogger(AccessTokenControllerTest.class);
@Test
public void testCreateToken() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "4");
paramsMap.add("expireTime", "2019-12-18 00:00:00");
paramsMap.add("token", "607f5aeaaa2093dbdff5d5522ce00510");
MvcResult mvcResult = mockMvc.perform(post("/access-tokens")
.header("sessionId", sessionId)
.params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java | @Test
public void testExceptionHandler() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "-1");
paramsMap.add("expireTime", "2019-12-18 00:00:00");
paramsMap.add("token", "507f5aeaaa2093dbdff5d5522ce00510");
MvcResult mvcResult = mockMvc.perform(post("/access-tokens")
.header("sessionId", sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.CREATE_ACCESS_TOKEN_ERROR.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testGenerateToken() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "4");
paramsMap.add("expireTime", "2019-12-28 00:00:00");
MvcResult mvcResult = mockMvc.perform(post("/access-tokens/generate")
.header("sessionId", sessionId)
.params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java | }
@Test
public void testQueryAccessTokenList() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("pageNo", "1");
paramsMap.add("pageSize", "20");
paramsMap.add("searchVal", "");
MvcResult mvcResult = mockMvc.perform(get("/access-tokens")
.header("sessionId", sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testQueryAccessTokenByUser() throws Exception {
MvcResult mvcResult = this.mockMvc
.perform(get("/access-tokens/user/1")
.header("sessionId", this.sessionId))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java | public void testDelAccessTokenById() throws Exception {
testCreateToken();
MvcResult mvcResult = mockMvc.perform(delete("/access-tokens/1")
.header("sessionId", sessionId))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testUpdateToken() throws Exception {
testCreateToken();
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "4");
paramsMap.add("expireTime", "2019-12-20 00:00:00");
paramsMap.add("token", "cxctoken123update");
MvcResult mvcResult = mockMvc.perform(put("/access-tokens/1")
.header("sessionId", sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.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; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java | import org.apache.dolphinscheduler.api.service.impl.AccessTokenServiceImpl;
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.UserType;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.dao.entity.AccessToken;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.assertj.core.util.Lists;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
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;
/**
* access token service test
*/
@RunWith(MockitoJUnitRunner.class) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java | public class AccessTokenServiceTest {
private static final Logger logger = LoggerFactory.getLogger(AccessTokenServiceTest.class);
@InjectMocks
private AccessTokenServiceImpl accessTokenService;
@Mock
private AccessTokenMapper accessTokenMapper;
@Test
@SuppressWarnings("unchecked")
public void testQueryAccessTokenList() {
IPage<AccessToken> tokenPage = new Page<>();
tokenPage.setRecords(getList());
tokenPage.setTotal(1L);
when(accessTokenMapper.selectAccessTokenPage(any(Page.class), eq("zhangsan"), eq(0))).thenReturn(tokenPage);
User user = new User();
Result result = accessTokenService.queryAccessTokenList(user, "zhangsan", 1, 10);
PageInfo<AccessToken> pageInfo = (PageInfo<AccessToken>) result.getData();
logger.info(result.toString());
Assert.assertTrue(pageInfo.getTotal() > 0);
}
@Test
public void testQueryAccessTokenByUser() {
List<AccessToken> accessTokenList = Lists.newArrayList(this.getEntity());
Mockito.when(this.accessTokenMapper.queryAccessTokenByUser(1)).thenReturn(accessTokenList);
User user = this.getLoginUser(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java | user.setUserType(UserType.GENERAL_USER);
Map<String, Object> result = this.accessTokenService.queryAccessTokenByUser(user, 1);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
user.setUserType(UserType.ADMIN_USER);
result = this.accessTokenService.queryAccessTokenByUser(user, 1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}
@Test
public void testCreateToken() {
when(accessTokenMapper.insert(any(AccessToken.class))).thenReturn(2);
Map<String, Object> result = accessTokenService.createToken(getLoginUser(), 1, getDate(), "AccessTokenServiceTest");
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}
@Test
public void testGenerateToken() {
Map<String, Object> result = accessTokenService.generateToken(getLoginUser(), Integer.MAX_VALUE,getDate());
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
String token = (String) result.get(Constants.DATA_LIST);
Assert.assertNotNull(token);
}
@Test
public void testDelAccessTokenById() {
when(accessTokenMapper.selectById(1)).thenReturn(getEntity());
User userLogin = new User(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java | Map<String, Object> result = accessTokenService.delAccessTokenById(userLogin, 0);
logger.info(result.toString());
Assert.assertEquals(Status.ACCESS_TOKEN_NOT_EXIST, result.get(Constants.STATUS));
result = accessTokenService.delAccessTokenById(userLogin, 1);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
userLogin.setId(1);
userLogin.setUserType(UserType.ADMIN_USER);
result = accessTokenService.delAccessTokenById(userLogin, 1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}
@Test
public void testUpdateToken() {
when(accessTokenMapper.selectById(1)).thenReturn(getEntity());
Map<String, Object> result = accessTokenService.updateToken(getLoginUser(), 1,Integer.MAX_VALUE,getDate(),"token");
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
result = accessTokenService.updateToken(getLoginUser(), 2,Integer.MAX_VALUE,getDate(),"token");
logger.info(result.toString());
Assert.assertEquals(Status.ACCESS_TOKEN_NOT_EXIST, result.get(Constants.STATUS));
}
private User getLoginUser() {
User loginUser = new User();
loginUser.setId(1);
loginUser.setUserType(UserType.ADMIN_USER);
return loginUser; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,401 | [Feature][dolphinscheduler-api] Built GenerateToken into the CreateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If CreateToken does not explicitly specify a Token, then GenerateToken is built into the CreateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7401 | https://github.com/apache/dolphinscheduler/pull/7404 | 1f1edb2f23d5a93b2d80f5caf521ea43a81bc374 | 14343864bf5b840cc297365463300896dcb1ef96 | 2021-12-14T08:18:27Z | java | 2021-12-14T09:54:35Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java | }
/**
* create entity
*/
private AccessToken getEntity() {
AccessToken accessToken = new AccessToken();
accessToken.setId(1);
accessToken.setUserId(1);
accessToken.setToken("AccessTokenServiceTest");
Date date = DateUtils.add(new Date(), Calendar.DAY_OF_MONTH, 30);
accessToken.setExpireTime(date);
return accessToken;
}
/**
* entity list
*/
private List<AccessToken> getList() {
List<AccessToken> list = new ArrayList<>();
list.add(getEntity());
return list;
}
/**
* get dateStr
*/
private String getDate() {
Date date = DateUtils.add(new Date(), Calendar.DAY_OF_MONTH, 30);
return DateUtils.dateToString(date);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.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.QUERY_ACCESSTOKEN_BY_USER_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.CREATE_ACCESS_TOKEN_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.DELETE_ACCESS_TOKEN_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.GENERATE_TOKEN_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ACCESSTOKEN_LIST_PAGING_ERROR; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java | import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_ACCESS_TOKEN_ERROR;
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.AccessTokenService;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
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.DeleteMapping;
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.PutMapping;
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 springfox.documentation.annotations.ApiIgnore;
/**
* access token controller
*/
@Api(tags = "ACCESS_TOKEN_TAG") |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java | @RestController
@RequestMapping("/access-tokens")
public class AccessTokenController extends BaseController {
@Autowired
private AccessTokenService accessTokenService;
/**
* create token
*
* @param loginUser login user
* @param userId token for user id
* @param expireTime expire time for the token
* @param token token string (if it is absent, it will be automatically generated)
* @return create result state code
*/
@ApiOperation(value = "createToken", notes = "CREATE_TOKEN_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType = "Int"),
@ApiImplicitParam(name = "expireTime", value = "EXPIRE_TIME", required = true, dataType = "String", example = "2021-12-31 00:00:00"),
@ApiImplicitParam(name = "token", value = "TOKEN", required = false, dataType = "String", example = "xxxx")
})
@PostMapping()
@ResponseStatus(HttpStatus.CREATED)
@ApiException(CREATE_ACCESS_TOKEN_ERROR) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java | @AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result createToken(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "userId") int userId,
@RequestParam(value = "expireTime") String expireTime,
@RequestParam(value = "token", required = false) String token) {
Map<String, Object> result = accessTokenService.createToken(loginUser, userId, expireTime, token);
return returnDataList(result);
}
/**
* generate token string
*
* @param loginUser login user
* @param userId token for user
* @param expireTime expire time
* @return token string
*/
@ApiIgnore
@PostMapping(value = "/generate")
@ResponseStatus(HttpStatus.CREATED)
@ApiException(GENERATE_TOKEN_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result generateToken(@RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "userId") int userId,
@RequestParam(value = "expireTime") String expireTime) {
Map<String, Object> result = accessTokenService.generateToken(loginUser, userId, expireTime);
return returnDataList(result);
}
/**
* query access token list paging
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java | * @param loginUser login user
* @param pageNo page number
* @param searchVal search value
* @param pageSize page size
* @return token list of page number and page size
*/
@ApiOperation(value = "queryAccessTokenList", notes = "QUERY_ACCESS_TOKEN_LIST_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", dataType = "String"),
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", required = true, dataType = "Int", example = "1"),
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", required = true, dataType = "Int", example = "20")
})
@GetMapping()
@ResponseStatus(HttpStatus.OK)
@ApiException(QUERY_ACCESSTOKEN_LIST_PAGING_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result queryAccessTokenList(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("pageNo") Integer pageNo,
@RequestParam(value = "searchVal", required = false) String searchVal,
@RequestParam("pageSize") Integer pageSize) {
Result result = checkPageParams(pageNo, pageSize);
if (!result.checkResult()) {
return result;
}
searchVal = ParameterUtils.handleEscapes(searchVal);
result = accessTokenService.queryAccessTokenList(loginUser, searchVal, pageNo, pageSize);
return result;
}
/**
* query access token for specified user |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java | *
* @param loginUser login user
* @param userId user id
* @return token list for specified user
*/
@ApiOperation(value = "queryAccessTokenByUser", notes = "QUERY_ACCESS_TOKEN_BY_USER_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "USER_ID", dataType = "Int")
})
@GetMapping(value = "/user/{userId}")
@ResponseStatus(HttpStatus.OK)
@ApiException(QUERY_ACCESSTOKEN_BY_USER_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result queryAccessTokenByUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@PathVariable("userId") Integer userId) {
Map<String, Object> result = this.accessTokenService.queryAccessTokenByUser(loginUser, userId);
return this.returnDataList(result);
}
/**
* delete access token by id
*
* @param loginUser login user
* @param id token id
* @return delete result code
*/
@ApiIgnore
@DeleteMapping(value = "/{id}")
@ResponseStatus(HttpStatus.OK)
@ApiException(DELETE_ACCESS_TOKEN_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser") |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java | public Result delAccessTokenById(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@PathVariable(value = "id") int id) {
Map<String, Object> result = accessTokenService.delAccessTokenById(loginUser, id);
return returnDataList(result);
}
/**
* update token
*
* @param loginUser login user
* @param id token id
* @param userId token for user
* @param expireTime token expire time
* @param token token string
* @return update result code
*/
@ApiIgnore
@PutMapping(value = "/{id}")
@ResponseStatus(HttpStatus.OK)
@ApiException(UPDATE_ACCESS_TOKEN_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result updateToken(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@PathVariable(value = "id") int id,
@RequestParam(value = "userId") int userId,
@RequestParam(value = "expireTime") String expireTime,
@RequestParam(value = "token") String token) {
Map<String, Object> result = accessTokenService.updateToken(loginUser, id, userId, expireTime, token);
return returnDataList(result);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AccessTokenService.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.api.utils.Result;
import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Map;
/**
* access token service
*/
public interface AccessTokenService { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AccessTokenService.java | /**
* query access token list
*
* @param loginUser login user
* @param searchVal search value
* @param pageNo page number
* @param pageSize page size
* @return token list for page number and page size
*/
Result queryAccessTokenList(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
/**
* query access token for specified user
*
* @param loginUser login user
* @param userId user id
* @return token list for specified user
*/
Map<String, Object> queryAccessTokenByUser(User loginUser, Integer userId);
/**
* create token
*
* @param userId token for user
* @param expireTime token expire time
* @param token token string (if it is absent, it will be automatically generated)
* @return create result code |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AccessTokenService.java | */
Map<String, Object> createToken(User loginUser, int userId, String expireTime, String token);
/**
* generate token
*
* @param userId token for user
* @param expireTime token expire time
* @return token string
*/
Map<String, Object> generateToken(User loginUser, int userId, String expireTime);
/**
* delete access token
*
* @param loginUser login user
* @param id token id
* @return delete result code
*/
Map<String, Object> delAccessTokenById(User loginUser, int id);
/**
* update token by id
*
* @param id token id
* @param userId token for user
* @param expireTime token expire time
* @param token token string
* @return update result code
*/
Map<String, Object> updateToken(User loginUser, int id, int userId, String expireTime, String token);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.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.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.AccessTokenService;
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.UserType;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.EncryptionUtils;
import org.apache.dolphinscheduler.dao.entity.AccessToken;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* access token service impl
*/
@Service
public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTokenService {
private static final Logger logger = LoggerFactory.getLogger(AccessTokenServiceImpl.class);
@Autowired
private AccessTokenMapper accessTokenMapper;
/**
* query access token list
*
* @param loginUser login user
* @param searchVal search value
* @param pageNo page number
* @param pageSize page size
* @return token list for page number and page size
*/
@Override
public Result queryAccessTokenList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
Result result = new Result(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | PageInfo<AccessToken> pageInfo = new PageInfo<>(pageNo, pageSize);
Page<AccessToken> page = new Page<>(pageNo, pageSize);
int userId = loginUser.getId();
if (loginUser.getUserType() == UserType.ADMIN_USER) {
userId = 0;
}
IPage<AccessToken> accessTokenList = accessTokenMapper.selectAccessTokenPage(page, searchVal, userId);
pageInfo.setTotal((int) accessTokenList.getTotal());
pageInfo.setTotalList(accessTokenList.getRecords());
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query access token for specified user
*
* @param loginUser login user
* @param userId user id
* @return token list for specified user
*/
@Override
public Map<String, Object> queryAccessTokenByUser(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false);
if (isNotAdmin(loginUser, result)) {
return result;
}
List<AccessToken> accessTokenList = this.accessTokenMapper.queryAccessTokenByUser(userId); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | result.put(Constants.DATA_LIST, accessTokenList);
this.putMsg(result, Status.SUCCESS);
return result;
}
/**
* create token
*
* @param userId token for user
* @param expireTime token expire time
* @param token token string (if it is absent, it will be automatically generated)
* @return create result code
*/
@SuppressWarnings("checkstyle:WhitespaceAround")
@Override
public Map<String, Object> createToken(User loginUser, int userId, String expireTime, String token) {
Map<String, Object> result = new HashMap<>();
if (!hasPerm(loginUser,userId)) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
if (userId <= 0) {
throw new IllegalArgumentException("User id should not less than or equals to 0.");
}
if (StringUtils.isBlank(token)) {
token = EncryptionUtils.getMd5(userId + expireTime + System.currentTimeMillis());
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | AccessToken accessToken = new AccessToken();
accessToken.setUserId(userId);
accessToken.setExpireTime(DateUtils.stringToDate(expireTime));
accessToken.setToken(token);
accessToken.setCreateTime(new Date());
accessToken.setUpdateTime(new Date());
int insert = accessTokenMapper.insert(accessToken);
if (insert > 0) {
result.put(Constants.DATA_LIST, accessToken);
putMsg(result, Status.SUCCESS);
} else {
putMsg(result, Status.CREATE_ACCESS_TOKEN_ERROR);
}
return result;
}
/**
* generate token
*
* @param userId token for user
* @param expireTime token expire time
* @return token string
*/
@Override
public Map<String, Object> generateToken(User loginUser, int userId, String expireTime) {
Map<String, Object> result = new HashMap<>();
if (!hasPerm(loginUser,userId)) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
String token = EncryptionUtils.getMd5(userId + expireTime + System.currentTimeMillis()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | result.put(Constants.DATA_LIST, token);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* delete access token
*
* @param loginUser login user
* @param id token id
* @return delete result code
*/
@Override
public Map<String, Object> delAccessTokenById(User loginUser, int id) {
Map<String, Object> result = new HashMap<>();
AccessToken accessToken = accessTokenMapper.selectById(id);
if (accessToken == null) {
logger.error("access token not exist, access token id {}", id);
putMsg(result, Status.ACCESS_TOKEN_NOT_EXIST);
return result;
}
if (!hasPerm(loginUser,accessToken.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
accessTokenMapper.deleteById(id);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* update token by id |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | *
* @param id token id
* @param userId token for user
* @param expireTime token expire time
* @param token token string
* @return update result code
*/
@Override
public Map<String, Object> updateToken(User loginUser, int id, int userId, String expireTime, String token) {
Map<String, Object> result = new HashMap<>();
if (!hasPerm(loginUser,userId)) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
AccessToken accessToken = accessTokenMapper.selectById(id);
if (accessToken == null) {
logger.error("access token not exist, access token id {}", id);
putMsg(result, Status.ACCESS_TOKEN_NOT_EXIST);
return result;
}
accessToken.setUserId(userId);
accessToken.setExpireTime(DateUtils.stringToDate(expireTime));
accessToken.setToken(token);
accessToken.setUpdateTime(new Date());
accessTokenMapper.updateById(accessToken);
putMsg(result, Status.SUCCESS);
return result;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.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, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java | * 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.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
/**
* access token controller test
*/
public class AccessTokenControllerTest extends AbstractControllerTest {
private static final Logger logger = LoggerFactory.getLogger(AccessTokenControllerTest.class);
@Test
public void testCreateToken() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java | paramsMap.add("userId", "4");
paramsMap.add("expireTime", "2019-12-18 00:00:00");
paramsMap.add("token", "607f5aeaaa2093dbdff5d5522ce00510");
MvcResult mvcResult = mockMvc.perform(post("/access-tokens")
.header("sessionId", sessionId)
.params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testCreateTokenWhenTokenAbsent() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "4");
paramsMap.add("expireTime", "2019-12-18 00:00:00");
paramsMap.add("token", null);
MvcResult mvcResult = this.mockMvc
.perform(post("/access-tokens")
.header("sessionId", this.sessionId)
.params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java | @Test
public void testExceptionHandler() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "-1");
paramsMap.add("expireTime", "2019-12-18 00:00:00");
paramsMap.add("token", "507f5aeaaa2093dbdff5d5522ce00510");
MvcResult mvcResult = mockMvc.perform(post("/access-tokens")
.header("sessionId", sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.CREATE_ACCESS_TOKEN_ERROR.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testGenerateToken() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "4");
paramsMap.add("expireTime", "2019-12-28 00:00:00");
MvcResult mvcResult = mockMvc.perform(post("/access-tokens/generate")
.header("sessionId", sessionId)
.params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java | }
@Test
public void testQueryAccessTokenList() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("pageNo", "1");
paramsMap.add("pageSize", "20");
paramsMap.add("searchVal", "");
MvcResult mvcResult = mockMvc.perform(get("/access-tokens")
.header("sessionId", sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testQueryAccessTokenByUser() throws Exception {
MvcResult mvcResult = this.mockMvc
.perform(get("/access-tokens/user/1")
.header("sessionId", this.sessionId))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java | public void testDelAccessTokenById() throws Exception {
testCreateToken();
MvcResult mvcResult = mockMvc.perform(delete("/access-tokens/1")
.header("sessionId", sessionId))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testUpdateToken() throws Exception {
testCreateToken();
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "4");
paramsMap.add("expireTime", "2019-12-20 00:00:00");
paramsMap.add("token", "cxctoken123update");
MvcResult mvcResult = mockMvc.perform(put("/access-tokens/1")
.header("sessionId", sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.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; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java | import org.apache.dolphinscheduler.api.service.impl.AccessTokenServiceImpl;
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.UserType;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.dao.entity.AccessToken;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.assertj.core.util.Lists;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
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;
/**
* access token service test
*/
@RunWith(MockitoJUnitRunner.class) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java | public class AccessTokenServiceTest {
private static final Logger logger = LoggerFactory.getLogger(AccessTokenServiceTest.class);
@InjectMocks
private AccessTokenServiceImpl accessTokenService;
@Mock
private AccessTokenMapper accessTokenMapper;
@Test
@SuppressWarnings("unchecked")
public void testQueryAccessTokenList() {
IPage<AccessToken> tokenPage = new Page<>();
tokenPage.setRecords(getList());
tokenPage.setTotal(1L);
when(accessTokenMapper.selectAccessTokenPage(any(Page.class), eq("zhangsan"), eq(0))).thenReturn(tokenPage);
User user = new User();
Result result = accessTokenService.queryAccessTokenList(user, "zhangsan", 1, 10);
PageInfo<AccessToken> pageInfo = (PageInfo<AccessToken>) result.getData();
logger.info(result.toString());
Assert.assertTrue(pageInfo.getTotal() > 0);
}
@Test
public void testQueryAccessTokenByUser() {
List<AccessToken> accessTokenList = Lists.newArrayList(this.getEntity());
Mockito.when(this.accessTokenMapper.queryAccessTokenByUser(1)).thenReturn(accessTokenList);
User user = this.getLoginUser();
user.setUserType(UserType.GENERAL_USER);
Map<String, Object> result = this.accessTokenService.queryAccessTokenByUser(user, 1);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS)); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java | user.setUserType(UserType.ADMIN_USER);
result = this.accessTokenService.queryAccessTokenByUser(user, 1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}
@Test
public void testCreateToken() {
when(accessTokenMapper.insert(any(AccessToken.class))).thenReturn(2);
Map<String, Object> result = accessTokenService.createToken(getLoginUser(), 1, getDate(), "AccessTokenServiceTest");
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
result = this.accessTokenService.createToken(getLoginUser(), 1, getDate(), null);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}
@Test
public void testGenerateToken() {
Map<String, Object> result = accessTokenService.generateToken(getLoginUser(), Integer.MAX_VALUE,getDate());
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
String token = (String) result.get(Constants.DATA_LIST);
Assert.assertNotNull(token);
}
@Test
public void testDelAccessTokenById() {
when(accessTokenMapper.selectById(1)).thenReturn(getEntity());
User userLogin = new User(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java | Map<String, Object> result = accessTokenService.delAccessTokenById(userLogin, 0);
logger.info(result.toString());
Assert.assertEquals(Status.ACCESS_TOKEN_NOT_EXIST, result.get(Constants.STATUS));
result = accessTokenService.delAccessTokenById(userLogin, 1);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
userLogin.setId(1);
userLogin.setUserType(UserType.ADMIN_USER);
result = accessTokenService.delAccessTokenById(userLogin, 1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}
@Test
public void testUpdateToken() {
when(accessTokenMapper.selectById(1)).thenReturn(getEntity());
Map<String, Object> result = accessTokenService.updateToken(getLoginUser(), 1,Integer.MAX_VALUE,getDate(),"token");
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
result = accessTokenService.updateToken(getLoginUser(), 2,Integer.MAX_VALUE,getDate(),"token");
logger.info(result.toString());
Assert.assertEquals(Status.ACCESS_TOKEN_NOT_EXIST, result.get(Constants.STATUS));
}
private User getLoginUser() {
User loginUser = new User();
loginUser.setId(1);
loginUser.setUserType(UserType.ADMIN_USER);
return loginUser; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,408 | [Feature][dolphinscheduler-api] Built GenerateToken into the UpdateToken API | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
If UpdateToken does not explicitly specify a Token, then GenerateToken is built into the UpdateToken interface, otherwise the current behavior remains unchanged, which is beneficial to reduce the count of network request interactions
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7408 | https://github.com/apache/dolphinscheduler/pull/7411 | 4988004150e3c8c264c0be027535bbcfdfd05d7c | 6b5c3934490027c57e8e8651d02d696060b290f5 | 2021-12-14T10:16:21Z | java | 2021-12-15T02:39:43Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java | }
/**
* create entity
*/
private AccessToken getEntity() {
AccessToken accessToken = new AccessToken();
accessToken.setId(1);
accessToken.setUserId(1);
accessToken.setToken("AccessTokenServiceTest");
Date date = DateUtils.add(new Date(), Calendar.DAY_OF_MONTH, 30);
accessToken.setExpireTime(date);
return accessToken;
}
/**
* entity list
*/
private List<AccessToken> getList() {
List<AccessToken> list = new ArrayList<>();
list.add(getEntity());
return list;
}
/**
* get dateStr
*/
private String getDate() {
Date date = DateUtils.add(new Date(), Calendar.DAY_OF_MONTH, 30);
return DateUtils.dateToString(date);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.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.QUERY_ACCESSTOKEN_BY_USER_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.CREATE_ACCESS_TOKEN_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.DELETE_ACCESS_TOKEN_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.GENERATE_TOKEN_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ACCESSTOKEN_LIST_PAGING_ERROR; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java | import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_ACCESS_TOKEN_ERROR;
import org.apache.dolphinscheduler.api.aspect.AccessLogAnnotation;
import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.AccessTokenService;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants;
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.DeleteMapping;
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.PutMapping;
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 springfox.documentation.annotations.ApiIgnore;
/**
* access token controller
*/
@Api(tags = "ACCESS_TOKEN_TAG") |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java | @RestController
@RequestMapping("/access-tokens")
public class AccessTokenController extends BaseController {
@Autowired
private AccessTokenService accessTokenService;
/**
* create token
*
* @param loginUser login user
* @param userId token for user id
* @param expireTime expire time for the token
* @param token token string (if it is absent, it will be automatically generated)
* @return create result state code
*/
@ApiOperation(value = "createToken", notes = "CREATE_TOKEN_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType = "Int"),
@ApiImplicitParam(name = "expireTime", value = "EXPIRE_TIME", required = true, dataType = "String", example = "2021-12-31 00:00:00"),
@ApiImplicitParam(name = "token", value = "TOKEN", required = false, dataType = "String", example = "xxxx")
})
@PostMapping()
@ResponseStatus(HttpStatus.CREATED)
@ApiException(CREATE_ACCESS_TOKEN_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result createToken(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "userId") int userId,
@RequestParam(value = "expireTime") String expireTime,
@RequestParam(value = "token", required = false) String token) {
Map<String, Object> result = accessTokenService.createToken(loginUser, userId, expireTime, token); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java | return returnDataList(result);
}
/**
* generate token string
*
* @param loginUser login user
* @param userId token for user
* @param expireTime expire time
* @return token string
*/
@ApiIgnore
@PostMapping(value = "/generate")
@ResponseStatus(HttpStatus.CREATED)
@ApiException(GENERATE_TOKEN_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result generateToken(@RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "userId") int userId,
@RequestParam(value = "expireTime") String expireTime) {
Map<String, Object> result = accessTokenService.generateToken(loginUser, userId, expireTime);
return returnDataList(result);
}
/**
* query access token list paging
*
* @param loginUser login user
* @param pageNo page number
* @param searchVal search value
* @param pageSize page size
* @return token list of page number and page size
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java | @ApiOperation(value = "queryAccessTokenList", notes = "QUERY_ACCESS_TOKEN_LIST_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "searchVal", value = "SEARCH_VAL", dataType = "String"),
@ApiImplicitParam(name = "pageNo", value = "PAGE_NO", required = true, dataType = "Int", example = "1"),
@ApiImplicitParam(name = "pageSize", value = "PAGE_SIZE", required = true, dataType = "Int", example = "20")
})
@GetMapping()
@ResponseStatus(HttpStatus.OK)
@ApiException(QUERY_ACCESSTOKEN_LIST_PAGING_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result queryAccessTokenList(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam("pageNo") Integer pageNo,
@RequestParam(value = "searchVal", required = false) String searchVal,
@RequestParam("pageSize") Integer pageSize) {
Result result = checkPageParams(pageNo, pageSize);
if (!result.checkResult()) {
return result;
}
searchVal = ParameterUtils.handleEscapes(searchVal);
result = accessTokenService.queryAccessTokenList(loginUser, searchVal, pageNo, pageSize);
return result;
}
/**
* query access token for specified user
*
* @param loginUser login user
* @param userId user id
* @return token list for specified user
*/
@ApiOperation(value = "queryAccessTokenByUser", notes = "QUERY_ACCESS_TOKEN_BY_USER_NOTES") |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java | @ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "USER_ID", dataType = "Int")
})
@GetMapping(value = "/user/{userId}")
@ResponseStatus(HttpStatus.OK)
@ApiException(QUERY_ACCESSTOKEN_BY_USER_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result queryAccessTokenByUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@PathVariable("userId") Integer userId) {
Map<String, Object> result = this.accessTokenService.queryAccessTokenByUser(loginUser, userId);
return this.returnDataList(result);
}
/**
* delete access token by id
*
* @param loginUser login user
* @param id token id
* @return delete result code
*/
@ApiIgnore
@DeleteMapping(value = "/{id}")
@ResponseStatus(HttpStatus.OK)
@ApiException(DELETE_ACCESS_TOKEN_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result delAccessTokenById(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@PathVariable(value = "id") int id) {
Map<String, Object> result = accessTokenService.delAccessTokenById(loginUser, id);
return returnDataList(result);
}
/** |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AccessTokenController.java | * update token
*
* @param loginUser login user
* @param id token id
* @param userId token for user
* @param expireTime token expire time
* @param token token string (if it is absent, it will be automatically generated)
* @return update result code
*/
@ApiOperation(value = "updateToken", notes = "UPDATE_TOKEN_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "TOKEN_ID", required = true, dataType = "Int"),
@ApiImplicitParam(name = "userId", value = "USER_ID", required = true, dataType = "Int"),
@ApiImplicitParam(name = "expireTime", value = "EXPIRE_TIME", required = true, dataType = "String", example = "2021-12-31 00:00:00"),
@ApiImplicitParam(name = "token", value = "TOKEN", required = false, dataType = "String", example = "xxxx")
})
@PutMapping(value = "/{id}")
@ResponseStatus(HttpStatus.OK)
@ApiException(UPDATE_ACCESS_TOKEN_ERROR)
@AccessLogAnnotation(ignoreRequestArgs = "loginUser")
public Result updateToken(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@PathVariable(value = "id") int id,
@RequestParam(value = "userId") int userId,
@RequestParam(value = "expireTime") String expireTime,
@RequestParam(value = "token", required = false) String token) {
Map<String, Object> result = accessTokenService.updateToken(loginUser, id, userId, expireTime, token);
return returnDataList(result);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AccessTokenService.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.api.utils.Result;
import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Map;
/**
* access token service
*/
public interface AccessTokenService { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AccessTokenService.java | /**
* query access token list
*
* @param loginUser login user
* @param searchVal search value
* @param pageNo page number
* @param pageSize page size
* @return token list for page number and page size
*/
Result queryAccessTokenList(User loginUser, String searchVal, Integer pageNo, Integer pageSize);
/**
* query access token for specified user
*
* @param loginUser login user
* @param userId user id
* @return token list for specified user
*/
Map<String, Object> queryAccessTokenByUser(User loginUser, Integer userId);
/**
* create token
*
* @param userId token for user
* @param expireTime token expire time
* @param token token string (if it is absent, it will be automatically generated)
* @return create result code |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AccessTokenService.java | */
Map<String, Object> createToken(User loginUser, int userId, String expireTime, String token);
/**
* generate token
*
* @param userId token for user
* @param expireTime token expire time
* @return token string
*/
Map<String, Object> generateToken(User loginUser, int userId, String expireTime);
/**
* delete access token
*
* @param loginUser login user
* @param id token id
* @return delete result code
*/
Map<String, Object> delAccessTokenById(User loginUser, int id);
/**
* update token by id
*
* @param id token id
* @param userId token for user
* @param expireTime token expire time
* @param token token string (if it is absent, it will be automatically generated)
* @return update result code
*/
Map<String, Object> updateToken(User loginUser, int id, int userId, String expireTime, String token);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.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. |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | * See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service.impl;
import org.apache.commons.lang3.StringUtils;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.AccessTokenService;
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.UserType;
import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.common.utils.EncryptionUtils;
import org.apache.dolphinscheduler.dao.entity.AccessToken;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* access token service impl
*/
@Service |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | public class AccessTokenServiceImpl extends BaseServiceImpl implements AccessTokenService {
private static final Logger logger = LoggerFactory.getLogger(AccessTokenServiceImpl.class);
@Autowired
private AccessTokenMapper accessTokenMapper;
/**
* query access token list
*
* @param loginUser login user
* @param searchVal search value
* @param pageNo page number
* @param pageSize page size
* @return token list for page number and page size
*/
@Override
public Result queryAccessTokenList(User loginUser, String searchVal, Integer pageNo, Integer pageSize) {
Result result = new Result();
PageInfo<AccessToken> pageInfo = new PageInfo<>(pageNo, pageSize);
Page<AccessToken> page = new Page<>(pageNo, pageSize);
int userId = loginUser.getId();
if (loginUser.getUserType() == UserType.ADMIN_USER) {
userId = 0;
}
IPage<AccessToken> accessTokenList = accessTokenMapper.selectAccessTokenPage(page, searchVal, userId); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | pageInfo.setTotal((int) accessTokenList.getTotal());
pageInfo.setTotalList(accessTokenList.getRecords());
result.setData(pageInfo);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* query access token for specified user
*
* @param loginUser login user
* @param userId user id
* @return token list for specified user
*/
@Override
public Map<String, Object> queryAccessTokenByUser(User loginUser, Integer userId) {
Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false);
if (isNotAdmin(loginUser, result)) {
return result;
}
List<AccessToken> accessTokenList = this.accessTokenMapper.queryAccessTokenByUser(userId);
result.put(Constants.DATA_LIST, accessTokenList);
this.putMsg(result, Status.SUCCESS);
return result;
}
/**
* create token
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | * @param userId token for user
* @param expireTime token expire time
* @param token token string (if it is absent, it will be automatically generated)
* @return create result code
*/
@SuppressWarnings("checkstyle:WhitespaceAround")
@Override
public Map<String, Object> createToken(User loginUser, int userId, String expireTime, String token) {
Map<String, Object> result = new HashMap<>();
if (!hasPerm(loginUser,userId)) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
if (userId <= 0) {
throw new IllegalArgumentException("User id should not less than or equals to 0.");
}
if (StringUtils.isBlank(token)) {
token = EncryptionUtils.getMd5(userId + expireTime + System.currentTimeMillis());
}
AccessToken accessToken = new AccessToken();
accessToken.setUserId(userId);
accessToken.setExpireTime(DateUtils.stringToDate(expireTime));
accessToken.setToken(token);
accessToken.setCreateTime(new Date());
accessToken.setUpdateTime(new Date());
int insert = accessTokenMapper.insert(accessToken); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | if (insert > 0) {
result.put(Constants.DATA_LIST, accessToken);
putMsg(result, Status.SUCCESS);
} else {
putMsg(result, Status.CREATE_ACCESS_TOKEN_ERROR);
}
return result;
}
/**
* generate token
*
* @param userId token for user
* @param expireTime token expire time
* @return token string
*/
@Override
public Map<String, Object> generateToken(User loginUser, int userId, String expireTime) {
Map<String, Object> result = new HashMap<>();
if (!hasPerm(loginUser,userId)) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
String token = EncryptionUtils.getMd5(userId + expireTime + System.currentTimeMillis());
result.put(Constants.DATA_LIST, token);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* delete access token
* |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | * @param loginUser login user
* @param id token id
* @return delete result code
*/
@Override
public Map<String, Object> delAccessTokenById(User loginUser, int id) {
Map<String, Object> result = new HashMap<>();
AccessToken accessToken = accessTokenMapper.selectById(id);
if (accessToken == null) {
logger.error("access token not exist, access token id {}", id);
putMsg(result, Status.ACCESS_TOKEN_NOT_EXIST);
return result;
}
if (!hasPerm(loginUser,accessToken.getUserId())) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
accessTokenMapper.deleteById(id);
putMsg(result, Status.SUCCESS);
return result;
}
/**
* update token by id
*
* @param id token id
* @param userId token for user
* @param expireTime token expire time
* @param token token string (if it is absent, it will be automatically generated)
* @return update result code
*/ |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/AccessTokenServiceImpl.java | @Override
public Map<String, Object> updateToken(User loginUser, int id, int userId, String expireTime, String token) {
Map<String, Object> result = new HashMap<>();
if (!hasPerm(loginUser,userId)) {
putMsg(result, Status.USER_NO_OPERATION_PERM);
return result;
}
AccessToken accessToken = accessTokenMapper.selectById(id);
if (accessToken == null) {
logger.error("access token not exist, access token id {}", id);
putMsg(result, Status.ACCESS_TOKEN_NOT_EXIST);
return result;
}
if (StringUtils.isBlank(token)) {
token = EncryptionUtils.getMd5(userId + expireTime + System.currentTimeMillis());
}
accessToken.setUserId(userId);
accessToken.setExpireTime(DateUtils.stringToDate(expireTime));
accessToken.setToken(token);
accessToken.setUpdateTime(new Date());
accessTokenMapper.updateById(accessToken);
putMsg(result, Status.SUCCESS);
return result;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.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.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java | import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MvcResult;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
/**
* access token controller test
*/
public class AccessTokenControllerTest extends AbstractControllerTest {
private static final Logger logger = LoggerFactory.getLogger(AccessTokenControllerTest.class);
@Test
public void testCreateToken() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "4");
paramsMap.add("expireTime", "2019-12-18 00:00:00");
paramsMap.add("token", "607f5aeaaa2093dbdff5d5522ce00510");
MvcResult mvcResult = mockMvc.perform(post("/access-tokens")
.header("sessionId", sessionId)
.params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testCreateTokenIfAbsent() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "4");
paramsMap.add("expireTime", "2019-12-18 00:00:00"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java | paramsMap.add("token", null);
MvcResult mvcResult = this.mockMvc
.perform(post("/access-tokens")
.header("sessionId", this.sessionId)
.params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testExceptionHandler() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "-1");
paramsMap.add("expireTime", "2019-12-18 00:00:00");
paramsMap.add("token", "507f5aeaaa2093dbdff5d5522ce00510");
MvcResult mvcResult = mockMvc.perform(post("/access-tokens")
.header("sessionId", sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.CREATE_ACCESS_TOKEN_ERROR.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testGenerateToken() throws Exception { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java | MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "4");
paramsMap.add("expireTime", "2019-12-28 00:00:00");
MvcResult mvcResult = mockMvc.perform(post("/access-tokens/generate")
.header("sessionId", sessionId)
.params(paramsMap))
.andExpect(status().isCreated())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testQueryAccessTokenList() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("pageNo", "1");
paramsMap.add("pageSize", "20");
paramsMap.add("searchVal", "");
MvcResult mvcResult = mockMvc.perform(get("/access-tokens")
.header("sessionId", sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java | public void testQueryAccessTokenByUser() throws Exception {
MvcResult mvcResult = this.mockMvc
.perform(get("/access-tokens/user/1")
.header("sessionId", this.sessionId))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testDelAccessTokenById() throws Exception {
testCreateToken();
MvcResult mvcResult = mockMvc.perform(delete("/access-tokens/1")
.header("sessionId", sessionId))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testUpdateToken() throws Exception {
testCreateToken();
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "4");
paramsMap.add("expireTime", "2019-12-20 00:00:00");
paramsMap.add("token", "cxctoken123update"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AccessTokenControllerTest.java | MvcResult mvcResult = mockMvc.perform(put("/access-tokens/1")
.header("sessionId", sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
@Test
public void testUpdateTokenIfAbsent() throws Exception {
this.testCreateTokenIfAbsent();
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("userId", "4");
paramsMap.add("expireTime", "2019-12-20 00:00:00");
paramsMap.add("token", null);
MvcResult mvcResult = this.mockMvc
.perform(put("/access-tokens/2")
.header("sessionId", this.sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.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.AccessTokenServiceImpl;
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.UserType; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java | import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.dao.entity.AccessToken;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.AccessTokenMapper;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
import org.assertj.core.util.Lists;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
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;
/**
* access token service test
*/
@RunWith(MockitoJUnitRunner.class)
public class AccessTokenServiceTest {
private static final Logger logger = LoggerFactory.getLogger(AccessTokenServiceTest.class);
@InjectMocks
private AccessTokenServiceImpl accessTokenService;
@Mock |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java | private AccessTokenMapper accessTokenMapper;
@Test
@SuppressWarnings("unchecked")
public void testQueryAccessTokenList() {
IPage<AccessToken> tokenPage = new Page<>();
tokenPage.setRecords(getList());
tokenPage.setTotal(1L);
when(accessTokenMapper.selectAccessTokenPage(any(Page.class), eq("zhangsan"), eq(0))).thenReturn(tokenPage);
User user = new User();
Result result = accessTokenService.queryAccessTokenList(user, "zhangsan", 1, 10);
PageInfo<AccessToken> pageInfo = (PageInfo<AccessToken>) result.getData();
logger.info(result.toString());
Assert.assertTrue(pageInfo.getTotal() > 0);
}
@Test
public void testQueryAccessTokenByUser() {
List<AccessToken> accessTokenList = Lists.newArrayList(this.getEntity());
Mockito.when(this.accessTokenMapper.queryAccessTokenByUser(1)).thenReturn(accessTokenList);
User user = this.getLoginUser();
user.setUserType(UserType.GENERAL_USER);
Map<String, Object> result = this.accessTokenService.queryAccessTokenByUser(user, 1);
logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
user.setUserType(UserType.ADMIN_USER);
result = this.accessTokenService.queryAccessTokenByUser(user, 1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java | @Test
public void testCreateToken() {
when(accessTokenMapper.insert(any(AccessToken.class))).thenReturn(2);
Map<String, Object> result = accessTokenService.createToken(getLoginUser(), 1, getDate(), "AccessTokenServiceTest");
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
result = this.accessTokenService.createToken(getLoginUser(), 1, getDate(), null);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}
@Test
public void testGenerateToken() {
Map<String, Object> result = accessTokenService.generateToken(getLoginUser(), Integer.MAX_VALUE,getDate());
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
String token = (String) result.get(Constants.DATA_LIST);
Assert.assertNotNull(token);
}
@Test
public void testDelAccessTokenById() {
when(accessTokenMapper.selectById(1)).thenReturn(getEntity());
User userLogin = new User();
Map<String, Object> result = accessTokenService.delAccessTokenById(userLogin, 0);
logger.info(result.toString());
Assert.assertEquals(Status.ACCESS_TOKEN_NOT_EXIST, result.get(Constants.STATUS));
result = accessTokenService.delAccessTokenById(userLogin, 1); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java | logger.info(result.toString());
Assert.assertEquals(Status.USER_NO_OPERATION_PERM, result.get(Constants.STATUS));
userLogin.setId(1);
userLogin.setUserType(UserType.ADMIN_USER);
result = accessTokenService.delAccessTokenById(userLogin, 1);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}
@Test
public void testUpdateToken() {
when(accessTokenMapper.selectById(1)).thenReturn(getEntity());
Map<String, Object> result = accessTokenService.updateToken(getLoginUser(), 1,Integer.MAX_VALUE,getDate(),"token");
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
result = accessTokenService.updateToken(getLoginUser(), 1, Integer.MAX_VALUE,getDate(),null);
logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
result = accessTokenService.updateToken(getLoginUser(), 2,Integer.MAX_VALUE,getDate(),"token");
logger.info(result.toString());
Assert.assertEquals(Status.ACCESS_TOKEN_NOT_EXIST, result.get(Constants.STATUS));
}
private User getLoginUser() {
User loginUser = new User();
loginUser.setId(1);
loginUser.setUserType(UserType.ADMIN_USER);
return loginUser; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,418 | [Feature][dolphinscheduler-api] Return domain object after UpdateXxx success | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Return domain object after UpdateXxx success
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7418 | https://github.com/apache/dolphinscheduler/pull/7420 | bc995752d6b52f2f94bf17ea806c60f8d63b7342 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | 2021-12-15T03:16:23Z | java | 2021-12-15T05:40:07Z | dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AccessTokenServiceTest.java | }
/**
* create entity
*/
private AccessToken getEntity() {
AccessToken accessToken = new AccessToken();
accessToken.setId(1);
accessToken.setUserId(1);
accessToken.setToken("AccessTokenServiceTest");
Date date = DateUtils.add(new Date(), Calendar.DAY_OF_MONTH, 30);
accessToken.setExpireTime(date);
return accessToken;
}
/**
* entity list
*/
private List<AccessToken> getList() {
List<AccessToken> list = new ArrayList<>();
list.add(getEntity());
return list;
}
/**
* get dateStr
*/
private String getDate() {
Date date = DateUtils.add(new Date(), Calendar.DAY_OF_MONTH, 30);
return DateUtils.dateToString(date);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,392 | [Bug] [DataSource] Add hive datasource failed | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened

Update Kerberos environment failed when add new hive datasource.
### What you expected to happen
add new hive datasource success.
### How to reproduce
add new hive datasource.
### Anything else
It's a bug in 2.0.1-release.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7392 | https://github.com/apache/dolphinscheduler/pull/7393 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | a17a8d777a3d4d2eda2409b1917ad5ddd3123969 | 2021-12-14T04:33:02Z | java | 2021-12-15T09:36:05Z | dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.plugin.datasource.hive;
import static org.apache.dolphinscheduler.spi.task.TaskConstants.JAVA_SECURITY_KRB5_CONF;
import static org.apache.dolphinscheduler.spi.task.TaskConstants.JAVA_SECURITY_KRB5_CONF_PATH; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,392 | [Bug] [DataSource] Add hive datasource failed | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened

Update Kerberos environment failed when add new hive datasource.
### What you expected to happen
add new hive datasource success.
### How to reproduce
add new hive datasource.
### Anything else
It's a bug in 2.0.1-release.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7392 | https://github.com/apache/dolphinscheduler/pull/7393 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | a17a8d777a3d4d2eda2409b1917ad5ddd3123969 | 2021-12-14T04:33:02Z | java | 2021-12-15T09:36:05Z | dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java | import org.apache.dolphinscheduler.plugin.datasource.api.client.CommonDataSourceClient;
import org.apache.dolphinscheduler.plugin.datasource.api.provider.JDBCDataSourceProvider;
import org.apache.dolphinscheduler.plugin.datasource.utils.CommonUtil;
import org.apache.dolphinscheduler.spi.datasource.BaseConnectionParam;
import org.apache.dolphinscheduler.spi.enums.DbType;
import org.apache.dolphinscheduler.spi.utils.Constants;
import org.apache.dolphinscheduler.spi.utils.PropertyUtils;
import org.apache.dolphinscheduler.spi.utils.StringUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.security.UserGroupInformation;
import java.io.IOException;
import java.lang.reflect.Field;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.zaxxer.hikari.HikariDataSource;
import sun.security.krb5.Config;
public class HiveDataSourceClient extends CommonDataSourceClient {
private static final Logger logger = LoggerFactory.getLogger(HiveDataSourceClient.class);
private ScheduledExecutorService kerberosRenewalService;
private Configuration hadoopConf;
protected HikariDataSource oneSessionDataSource;
private UserGroupInformation ugi;
public HiveDataSourceClient(BaseConnectionParam baseConnectionParam, DbType dbType) {
super(baseConnectionParam, dbType);
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,392 | [Bug] [DataSource] Add hive datasource failed | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened

Update Kerberos environment failed when add new hive datasource.
### What you expected to happen
add new hive datasource success.
### How to reproduce
add new hive datasource.
### Anything else
It's a bug in 2.0.1-release.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7392 | https://github.com/apache/dolphinscheduler/pull/7393 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | a17a8d777a3d4d2eda2409b1917ad5ddd3123969 | 2021-12-14T04:33:02Z | java | 2021-12-15T09:36:05Z | dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java | @Override
protected void preInit() {
logger.info("PreInit in {}", getClass().getName());
this.kerberosRenewalService = Executors.newSingleThreadScheduledExecutor();
}
@Override
protected void initClient(BaseConnectionParam baseConnectionParam, DbType dbType) {
logger.info("Create Configuration for hive configuration.");
this.hadoopConf = createHadoopConf();
logger.info("Create Configuration success.");
logger.info("Create UserGroupInformation.");
this.ugi = createUserGroupInformation(baseConnectionParam.getUser());
logger.info("Create ugi success.");
super.initClient(baseConnectionParam, dbType);
this.oneSessionDataSource = JDBCDataSourceProvider.createOneSessionJdbcDataSource(baseConnectionParam);
logger.info("Init {} success.", getClass().getName());
}
@Override
protected void checkEnv(BaseConnectionParam baseConnectionParam) {
super.checkEnv(baseConnectionParam);
checkKerberosEnv();
}
private void checkKerberosEnv() {
String krb5File = PropertyUtils.getString(JAVA_SECURITY_KRB5_CONF_PATH);
if (StringUtils.isNotBlank(krb5File)) {
System.setProperty(JAVA_SECURITY_KRB5_CONF, krb5File);
try {
Config.refresh();
Class<?> kerberosName = Class.forName("org.apache.hadoop.security.authentication.util.KerberosName");
Field field = kerberosName.getDeclaredField("defaultRealm"); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,392 | [Bug] [DataSource] Add hive datasource failed | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened

Update Kerberos environment failed when add new hive datasource.
### What you expected to happen
add new hive datasource success.
### How to reproduce
add new hive datasource.
### Anything else
It's a bug in 2.0.1-release.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7392 | https://github.com/apache/dolphinscheduler/pull/7393 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | a17a8d777a3d4d2eda2409b1917ad5ddd3123969 | 2021-12-14T04:33:02Z | java | 2021-12-15T09:36:05Z | dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java | field.setAccessible(true);
field.set(null, Config.getInstance().getDefaultRealm());
} catch (Exception e) {
throw new RuntimeException("Update Kerberos environment failed.", e);
}
}
}
private UserGroupInformation createUserGroupInformation(String username) {
String krb5File = PropertyUtils.getString(Constants.JAVA_SECURITY_KRB5_CONF_PATH);
String keytab = PropertyUtils.getString(Constants.LOGIN_USER_KEY_TAB_PATH);
String principal = PropertyUtils.getString(Constants.LOGIN_USER_KEY_TAB_USERNAME);
try {
UserGroupInformation ugi = CommonUtil.createUGI(getHadoopConf(), principal, keytab, krb5File, username);
try {
Field isKeytabField = ugi.getClass().getDeclaredField("isKeytab");
isKeytabField.setAccessible(true);
isKeytabField.set(ugi, true);
} catch (NoSuchFieldException | IllegalAccessException e) {
logger.warn(e.getMessage());
}
kerberosRenewalService.scheduleWithFixedDelay(() -> {
try {
ugi.checkTGTAndReloginFromKeytab();
} catch (IOException e) {
logger.error("Check TGT and Renewal from Keytab error", e);
}
}, 5, 5, TimeUnit.MINUTES);
return ugi;
} catch (IOException e) {
throw new RuntimeException("createUserGroupInformation fail. ", e); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,392 | [Bug] [DataSource] Add hive datasource failed | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar issues.
### What happened

Update Kerberos environment failed when add new hive datasource.
### What you expected to happen
add new hive datasource success.
### How to reproduce
add new hive datasource.
### Anything else
It's a bug in 2.0.1-release.
### Version
dev
### Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7392 | https://github.com/apache/dolphinscheduler/pull/7393 | 801e6dd6bb721ee2d9f35528673865483957fcd3 | a17a8d777a3d4d2eda2409b1917ad5ddd3123969 | 2021-12-14T04:33:02Z | java | 2021-12-15T09:36:05Z | dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-hive/src/main/java/org/apache/dolphinscheduler/plugin/datasource/hive/HiveDataSourceClient.java | }
}
protected Configuration createHadoopConf() {
Configuration hadoopConf = new Configuration();
hadoopConf.setBoolean("ipc.client.fallback-to-simple-auth-allowed", true);
return hadoopConf;
}
protected Configuration getHadoopConf() {
return this.hadoopConf;
}
@Override
public Connection getConnection() {
try {
return oneSessionDataSource.getConnection();
} catch (SQLException e) {
logger.error("get oneSessionDataSource Connection fail SQLException: {}", e.getMessage(), e);
return null;
}
}
@Override
public void close() {
super.close();
logger.info("close HiveDataSourceClient.");
kerberosRenewalService.shutdown();
this.ugi = null;
this.oneSessionDataSource.close();
this.oneSessionDataSource = null;
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,926 | [Feature][Python] Add workflow as code task type dependent | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Add python api task type dependent. sub task in #6407. we should cover all parameter from UI side and make it suitable for python.
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6926 | https://github.com/apache/dolphinscheduler/pull/7405 | 676a952bcbeba1790b03954915ec352cd920b6d1 | 6f93ebf3ba66a2e99e56e1844243dfc75d43556c | 2021-11-19T07:04:43Z | java | 2021-12-16T01:58:50Z | dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.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 |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,926 | [Feature][Python] Add workflow as code task type dependent | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Add python api task type dependent. sub task in #6407. we should cover all parameter from UI side and make it suitable for python.
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6926 | https://github.com/apache/dolphinscheduler/pull/7405 | 676a952bcbeba1790b03954915ec352cd920b6d1 | 6f93ebf3ba66a2e99e56e1844243dfc75d43556c | 2021-11-19T07:04:43Z | java | 2021-12-16T01:58:50Z | dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java | *
* 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.server;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.service.ExecutorService;
import org.apache.dolphinscheduler.api.service.ProcessDefinitionService;
import org.apache.dolphinscheduler.api.service.ProjectService;
import org.apache.dolphinscheduler.api.service.QueueService;
import org.apache.dolphinscheduler.api.service.SchedulerService;
import org.apache.dolphinscheduler.api.service.TaskDefinitionService;
import org.apache.dolphinscheduler.api.service.TenantService;
import org.apache.dolphinscheduler.api.service.UsersService;
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.ProcessExecutionTypeEnum;
import org.apache.dolphinscheduler.common.enums.ReleaseState;
import org.apache.dolphinscheduler.common.enums.RunMode;
import org.apache.dolphinscheduler.common.enums.TaskDependType;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.utils.CodeGenerateUtils; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,926 | [Feature][Python] Add workflow as code task type dependent | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Add python api task type dependent. sub task in #6407. we should cover all parameter from UI side and make it suitable for python.
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6926 | https://github.com/apache/dolphinscheduler/pull/7405 | 676a952bcbeba1790b03954915ec352cd920b6d1 | 6f93ebf3ba66a2e99e56e1844243dfc75d43556c | 2021-11-19T07:04:43Z | java | 2021-12-16T01:58:50Z | dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java | import org.apache.dolphinscheduler.dao.entity.DataSource;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
import org.apache.dolphinscheduler.dao.entity.Project;
import org.apache.dolphinscheduler.dao.entity.Queue;
import org.apache.dolphinscheduler.dao.entity.Schedule;
import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper;
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper;
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper;
import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper;
import org.apache.dolphinscheduler.dao.mapper.TaskDefinitionMapper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import py4j.GatewayServer;
@ComponentScan(value = "org.apache.dolphinscheduler")
public class PythonGatewayServer extends SpringBootServletInitializer {
private static final Logger LOGGER = LoggerFactory.getLogger(PythonGatewayServer.class);
private static final WarningType DEFAULT_WARNING_TYPE = WarningType.NONE;
private static final int DEFAULT_WARNING_GROUP_ID = 0; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,926 | [Feature][Python] Add workflow as code task type dependent | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Add python api task type dependent. sub task in #6407. we should cover all parameter from UI side and make it suitable for python.
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6926 | https://github.com/apache/dolphinscheduler/pull/7405 | 676a952bcbeba1790b03954915ec352cd920b6d1 | 6f93ebf3ba66a2e99e56e1844243dfc75d43556c | 2021-11-19T07:04:43Z | java | 2021-12-16T01:58:50Z | dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java | private static final FailureStrategy DEFAULT_FAILURE_STRATEGY = FailureStrategy.CONTINUE;
private static final Priority DEFAULT_PRIORITY = Priority.MEDIUM;
private static final Long DEFAULT_ENVIRONMENT_CODE = -1L;
private static final TaskDependType DEFAULT_TASK_DEPEND_TYPE = TaskDependType.TASK_POST;
private static final RunMode DEFAULT_RUN_MODE = RunMode.RUN_MODE_SERIAL;
private static final int DEFAULT_DRY_RUN = 0;
@Autowired
private ProcessDefinitionMapper processDefinitionMapper;
@Autowired
private ProjectService projectService;
@Autowired
private TenantService tenantService;
@Autowired
private ExecutorService executorService;
@Autowired
private ProcessDefinitionService processDefinitionService;
@Autowired
private TaskDefinitionService taskDefinitionService;
@Autowired
private UsersService usersService;
@Autowired
private QueueService queueService;
@Autowired
private ProjectMapper projectMapper;
@Autowired
private TaskDefinitionMapper taskDefinitionMapper;
@Autowired
private SchedulerService schedulerService;
@Autowired
private ScheduleMapper scheduleMapper; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,926 | [Feature][Python] Add workflow as code task type dependent | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Add python api task type dependent. sub task in #6407. we should cover all parameter from UI side and make it suitable for python.
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6926 | https://github.com/apache/dolphinscheduler/pull/7405 | 676a952bcbeba1790b03954915ec352cd920b6d1 | 6f93ebf3ba66a2e99e56e1844243dfc75d43556c | 2021-11-19T07:04:43Z | java | 2021-12-16T01:58:50Z | dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java | @Autowired
private DataSourceMapper dataSourceMapper;
private final User dummyAdminUser = new User() {
{
setId(Integer.MAX_VALUE);
setUserName("dummyUser");
setUserType(UserType.ADMIN_USER);
}
};
private final Queue queuePythonGateway = new Queue() {
{
setId(Integer.MAX_VALUE);
setQueueName("queuePythonGateway");
}
};
public String ping() {
return "PONG";
}
public Map<String, Object> genTaskCodeList(Integer genNum) {
return taskDefinitionService.genTaskCodeList(genNum);
}
public Map<String, Long> getCodeAndVersion(String projectName, String taskName) throws CodeGenerateUtils.CodeGenerateException {
Project project = projectMapper.queryByName(projectName);
Map<String, Long> result = new HashMap<>();
if (project == null) {
result.put("code", CodeGenerateUtils.getInstance().genCode()); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,926 | [Feature][Python] Add workflow as code task type dependent | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Add python api task type dependent. sub task in #6407. we should cover all parameter from UI side and make it suitable for python.
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6926 | https://github.com/apache/dolphinscheduler/pull/7405 | 676a952bcbeba1790b03954915ec352cd920b6d1 | 6f93ebf3ba66a2e99e56e1844243dfc75d43556c | 2021-11-19T07:04:43Z | java | 2021-12-16T01:58:50Z | dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java | result.put("version", 0L);
return result;
}
TaskDefinition taskDefinition = taskDefinitionMapper.queryByName(project.getCode(), taskName);
if (taskDefinition == null) {
result.put("code", CodeGenerateUtils.getInstance().genCode());
result.put("version", 0L);
} else {
result.put("code", taskDefinition.getCode());
result.put("version", (long) taskDefinition.getVersion());
}
return result;
}
/**
* create or update process definition.
* If process definition do not exists in Project=`projectCode` would create a new one
* If process definition already exists in Project=`projectCode` would update it
*
* @param userName user name who create or update process definition
* @param projectName project name which process definition belongs to
* @param name process definition name
* @param description description
* @param globalParams global params
* @param schedule schedule for process definition, will not set schedule if null,
* and if would always fresh exists schedule if not null
* @param locations locations json object about all tasks
* @param timeout timeout for process definition working, if running time longer than timeout,
* task will mark as fail
* @param workerGroup run task in which worker group
* @param tenantCode tenantCode |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,926 | [Feature][Python] Add workflow as code task type dependent | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Add python api task type dependent. sub task in #6407. we should cover all parameter from UI side and make it suitable for python.
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6926 | https://github.com/apache/dolphinscheduler/pull/7405 | 676a952bcbeba1790b03954915ec352cd920b6d1 | 6f93ebf3ba66a2e99e56e1844243dfc75d43556c | 2021-11-19T07:04:43Z | java | 2021-12-16T01:58:50Z | dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java | * @param taskRelationJson relation json for nodes
* @param taskDefinitionJson taskDefinitionJson
* @return create result code
*/
public Long createOrUpdateProcessDefinition(String userName,
String projectName,
String name,
String description,
String globalParams,
String schedule,
String locations,
int timeout,
String workerGroup,
String tenantCode,
String taskRelationJson,
String taskDefinitionJson,
ProcessExecutionTypeEnum executionType) {
User user = usersService.queryUser(userName);
Project project = (Project) projectService.queryByName(user, projectName).get(Constants.DATA_LIST);
long projectCode = project.getCode();
ProcessDefinition processDefinition = getProcessDefinition(user, projectCode, name);
long processDefinitionCode;
if (processDefinition != null) {
processDefinitionCode = processDefinition.getCode();
processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinitionCode, ReleaseState.OFFLINE);
Map<String, Object> result = processDefinitionService.updateProcessDefinition(user, projectCode, name, processDefinitionCode, description, globalParams,
locations, timeout, tenantCode, taskRelationJson, taskDefinitionJson, executionType);
} else { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,926 | [Feature][Python] Add workflow as code task type dependent | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Add python api task type dependent. sub task in #6407. we should cover all parameter from UI side and make it suitable for python.
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6926 | https://github.com/apache/dolphinscheduler/pull/7405 | 676a952bcbeba1790b03954915ec352cd920b6d1 | 6f93ebf3ba66a2e99e56e1844243dfc75d43556c | 2021-11-19T07:04:43Z | java | 2021-12-16T01:58:50Z | dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java | Map<String, Object> result = processDefinitionService.createProcessDefinition(user, projectCode, name, description, globalParams,
locations, timeout, tenantCode, taskRelationJson, taskDefinitionJson, executionType);
processDefinition = (ProcessDefinition) result.get(Constants.DATA_LIST);
processDefinitionCode = processDefinition.getCode();
}
if (schedule != null) {
createOrUpdateSchedule(user, projectCode, processDefinitionCode, schedule, workerGroup);
}
processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinitionCode, ReleaseState.ONLINE);
return processDefinitionCode;
}
/**
* get process definition
* @param user user who create or update schedule
* @param projectCode project which process definition belongs to
* @param processDefinitionName process definition name
*/
private ProcessDefinition getProcessDefinition(User user, long projectCode, String processDefinitionName) {
Map<String, Object> verifyProcessDefinitionExists = processDefinitionService.verifyProcessDefinitionName(user, projectCode, processDefinitionName);
Status verifyStatus = (Status) verifyProcessDefinitionExists.get(Constants.STATUS);
ProcessDefinition processDefinition = null;
if (verifyStatus == Status.PROCESS_DEFINITION_NAME_EXIST) {
processDefinition = processDefinitionMapper.queryByDefineName(projectCode, processDefinitionName);
} else if (verifyStatus != Status.SUCCESS) {
String msg = "Verify process definition exists status is invalid, neither SUCCESS or PROCESS_DEFINITION_NAME_EXIST.";
LOGGER.error(msg);
throw new RuntimeException(msg);
}
return processDefinition; |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,926 | [Feature][Python] Add workflow as code task type dependent | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Add python api task type dependent. sub task in #6407. we should cover all parameter from UI side and make it suitable for python.
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6926 | https://github.com/apache/dolphinscheduler/pull/7405 | 676a952bcbeba1790b03954915ec352cd920b6d1 | 6f93ebf3ba66a2e99e56e1844243dfc75d43556c | 2021-11-19T07:04:43Z | java | 2021-12-16T01:58:50Z | dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java | }
/**
* create or update process definition schedule.
* It would always use latest schedule define in workflow-as-code, and set schedule online when
* it's not null
*
* @param user user who create or update schedule
* @param projectCode project which process definition belongs to
* @param processDefinitionCode process definition code
* @param schedule schedule expression
* @param workerGroup work group
*/
private void createOrUpdateSchedule(User user,
long projectCode,
long processDefinitionCode,
String schedule,
String workerGroup) {
Schedule scheduleObj = scheduleMapper.queryByProcessDefinitionCode(processDefinitionCode);
int scheduleId;
if (scheduleObj == null) {
processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinitionCode, ReleaseState.ONLINE);
Map<String, Object> result = schedulerService.insertSchedule(user, projectCode, processDefinitionCode, schedule, DEFAULT_WARNING_TYPE,
DEFAULT_WARNING_GROUP_ID, DEFAULT_FAILURE_STRATEGY, DEFAULT_PRIORITY, workerGroup, DEFAULT_ENVIRONMENT_CODE);
scheduleId = (int) result.get("scheduleId");
} else {
scheduleId = scheduleObj.getId();
processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinitionCode, ReleaseState.OFFLINE);
schedulerService.updateSchedule(user, projectCode, scheduleId, schedule, DEFAULT_WARNING_TYPE,
DEFAULT_WARNING_GROUP_ID, DEFAULT_FAILURE_STRATEGY, DEFAULT_PRIORITY, workerGroup, DEFAULT_ENVIRONMENT_CODE); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,926 | [Feature][Python] Add workflow as code task type dependent | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Add python api task type dependent. sub task in #6407. we should cover all parameter from UI side and make it suitable for python.
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6926 | https://github.com/apache/dolphinscheduler/pull/7405 | 676a952bcbeba1790b03954915ec352cd920b6d1 | 6f93ebf3ba66a2e99e56e1844243dfc75d43556c | 2021-11-19T07:04:43Z | java | 2021-12-16T01:58:50Z | dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java | }
schedulerService.setScheduleState(user, projectCode, scheduleId, ReleaseState.ONLINE);
}
public void execProcessInstance(String userName,
String projectName,
String processDefinitionName,
String cronTime,
String workerGroup,
Integer timeout
) {
User user = usersService.queryUser(userName);
Project project = projectMapper.queryByName(projectName);
ProcessDefinition processDefinition = processDefinitionMapper.queryByDefineName(project.getCode(), processDefinitionName);
processDefinitionService.releaseProcessDefinition(user, project.getCode(), processDefinition.getCode(), ReleaseState.ONLINE);
executorService.execProcessInstance(user,
project.getCode(),
processDefinition.getCode(),
cronTime,
null,
DEFAULT_FAILURE_STRATEGY,
null,
DEFAULT_TASK_DEPEND_TYPE,
DEFAULT_WARNING_TYPE,
DEFAULT_WARNING_GROUP_ID,
DEFAULT_RUN_MODE,
DEFAULT_PRIORITY,
workerGroup,
DEFAULT_ENVIRONMENT_CODE,
timeout, |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,926 | [Feature][Python] Add workflow as code task type dependent | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Add python api task type dependent. sub task in #6407. we should cover all parameter from UI side and make it suitable for python.
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6926 | https://github.com/apache/dolphinscheduler/pull/7405 | 676a952bcbeba1790b03954915ec352cd920b6d1 | 6f93ebf3ba66a2e99e56e1844243dfc75d43556c | 2021-11-19T07:04:43Z | java | 2021-12-16T01:58:50Z | dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java | null,
null,
DEFAULT_DRY_RUN
);
}
public Map<String, Object> createProject(String userName, String name, String desc) {
User user = usersService.queryUser(userName);
return projectService.createProject(user, name, desc);
}
public Map<String, Object> createQueue(String name, String queueName) {
Result<Object> verifyQueueExists = queueService.verifyQueue(name, queueName);
if (verifyQueueExists.getCode() == 0) {
return queueService.createQueue(dummyAdminUser, name, queueName);
} else {
Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, Status.SUCCESS);
result.put(Constants.MSG, Status.SUCCESS.getMsg());
return result;
}
}
public Map<String, Object> createTenant(String tenantCode, String desc, String queueName) throws Exception {
if (tenantService.checkTenantExists(tenantCode)) {
Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, Status.SUCCESS);
result.put(Constants.MSG, Status.SUCCESS.getMsg());
return result;
} else { |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,926 | [Feature][Python] Add workflow as code task type dependent | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Add python api task type dependent. sub task in #6407. we should cover all parameter from UI side and make it suitable for python.
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6926 | https://github.com/apache/dolphinscheduler/pull/7405 | 676a952bcbeba1790b03954915ec352cd920b6d1 | 6f93ebf3ba66a2e99e56e1844243dfc75d43556c | 2021-11-19T07:04:43Z | java | 2021-12-16T01:58:50Z | dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java | Result<Object> verifyQueueExists = queueService.verifyQueue(queueName, queueName);
if (verifyQueueExists.getCode() == 0) {
queueService.createQueue(dummyAdminUser, queueName, queueName);
}
Map<String, Object> result = queueService.queryQueueName(queueName);
List<Queue> queueList = (List<Queue>) result.get(Constants.DATA_LIST);
Queue queue = queueList.get(0);
return tenantService.createTenant(dummyAdminUser, tenantCode, queue.getId(), desc);
}
}
public void createUser(String userName,
String userPassword,
String email,
String phone,
String tenantCode,
String queue,
int state) {
User user = usersService.queryUser(userName);
if (Objects.isNull(user)) {
Map<String, Object> tenantResult = tenantService.queryByTenantCode(tenantCode);
Tenant tenant = (Tenant) tenantResult.get(Constants.DATA_LIST);
usersService.createUser(userName, userPassword, email, tenant.getId(), phone, queue, state);
}
}
/**
* Get datasource by given datasource name. It return map contain datasource id, type, name.
* Useful in Python API create sql task which need datasource information.
*
* @param datasourceName user who create or update schedule |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,926 | [Feature][Python] Add workflow as code task type dependent | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Add python api task type dependent. sub task in #6407. we should cover all parameter from UI side and make it suitable for python.
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6926 | https://github.com/apache/dolphinscheduler/pull/7405 | 676a952bcbeba1790b03954915ec352cd920b6d1 | 6f93ebf3ba66a2e99e56e1844243dfc75d43556c | 2021-11-19T07:04:43Z | java | 2021-12-16T01:58:50Z | dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java | */
public Map<String, Object> getDatasourceInfo(String datasourceName) {
Map<String, Object> result = new HashMap<>();
List<DataSource> dataSourceList = dataSourceMapper.queryDataSourceByName(datasourceName);
if (dataSourceList.size() > 1) {
String msg = String.format("Get more than one datasource by name %s", datasourceName);
logger.error(msg);
throw new IllegalArgumentException(msg);
} else if (dataSourceList.size() == 0) {
String msg = String.format("Can not find any datasource by name %s", datasourceName);
logger.error(msg);
throw new IllegalArgumentException(msg);
} else {
DataSource dataSource = dataSourceList.get(0);
result.put("id", dataSource.getId());
result.put("type", dataSource.getType().name());
result.put("name", dataSource.getName());
}
return result;
}
/**
* Get processDefinition by given processDefinitionName name. It return map contain processDefinition id, name, code.
* Useful in Python API create subProcess task which need processDefinition information.
*
* @param userName user who create or update schedule
* @param projectName project name which process definition belongs to
* @param processDefinitionName process definition name
*/
public Map<String, Object> getProcessDefinitionInfo(String userName, String projectName, String processDefinitionName) {
Map<String, Object> result = new HashMap<>(); |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 6,926 | [Feature][Python] Add workflow as code task type dependent | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
Add python api task type dependent. sub task in #6407. we should cover all parameter from UI side and make it suitable for python.
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [ ] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/6926 | https://github.com/apache/dolphinscheduler/pull/7405 | 676a952bcbeba1790b03954915ec352cd920b6d1 | 6f93ebf3ba66a2e99e56e1844243dfc75d43556c | 2021-11-19T07:04:43Z | java | 2021-12-16T01:58:50Z | dolphinscheduler-python/src/main/java/org/apache/dolphinscheduler/server/PythonGatewayServer.java | User user = usersService.queryUser(userName);
Project project = (Project) projectService.queryByName(user, projectName).get(Constants.DATA_LIST);
long projectCode = project.getCode();
ProcessDefinition processDefinition = getProcessDefinition(user, projectCode, processDefinitionName);
if (processDefinition != null) {
processDefinitionService.releaseProcessDefinition(user, projectCode, processDefinition.getCode(), ReleaseState.ONLINE);
result.put("id", processDefinition.getId());
result.put("name", processDefinition.getName());
result.put("code", processDefinition.getCode());
} else {
String msg = String.format("Can not find valid process definition by name %s", processDefinitionName);
logger.error(msg);
throw new IllegalArgumentException(msg);
}
return result;
}
@PostConstruct
public void run() {
GatewayServer server = new GatewayServer(this);
GatewayServer.turnLoggingOn();
server.start();
}
public static void main(String[] args) {
SpringApplication.run(PythonGatewayServer.class, args);
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,460 | [Feature][Alert] Wechat alert support send to group chat | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
We only support sending to apps right now in 2.0.1-release. https://work.weixin.qq.com/api/doc/90000/90135/90236
We should add support send to appchat .And add a switch button in UI. https://work.weixin.qq.com/api/doc/90000/90135/90248
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7460 | https://github.com/apache/dolphinscheduler/pull/7465 | fc162826d91576da2649f5acfd6f11bcff58c5d7 | 86b476a1601872d1e47c3e9ca5ee4c18cbea92d3 | 2021-12-17T04:05:54Z | java | 2021-12-18T02:26:16Z | dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertChannelFactory.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.plugin.alert.wechat;
import org.apache.dolphinscheduler.alert.api.AlertChannel;
import org.apache.dolphinscheduler.alert.api.AlertChannelFactory;
import org.apache.dolphinscheduler.alert.api.AlertConstants;
import org.apache.dolphinscheduler.alert.api.ShowType;
import org.apache.dolphinscheduler.spi.params.base.ParamsOptions;
import org.apache.dolphinscheduler.spi.params.base.PluginParams;
import org.apache.dolphinscheduler.spi.params.base.Validate;
import org.apache.dolphinscheduler.spi.params.input.InputParam;
import org.apache.dolphinscheduler.spi.params.radio.RadioParam;
import java.util.Arrays;
import java.util.List;
import com.google.auto.service.AutoService;
@AutoService(AlertChannelFactory.class) |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,460 | [Feature][Alert] Wechat alert support send to group chat | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
We only support sending to apps right now in 2.0.1-release. https://work.weixin.qq.com/api/doc/90000/90135/90236
We should add support send to appchat .And add a switch button in UI. https://work.weixin.qq.com/api/doc/90000/90135/90248
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7460 | https://github.com/apache/dolphinscheduler/pull/7465 | fc162826d91576da2649f5acfd6f11bcff58c5d7 | 86b476a1601872d1e47c3e9ca5ee4c18cbea92d3 | 2021-12-17T04:05:54Z | java | 2021-12-18T02:26:16Z | dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertChannelFactory.java | public final class WeChatAlertChannelFactory implements AlertChannelFactory {
@Override
public String name() {
return "WeChat";
}
@Override
public List<PluginParams> params() {
InputParam corpIdParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_CORP_ID, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_CORP_ID)
.setPlaceholder("please input corp id ")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam secretParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_SECRET, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_SECRET)
.setPlaceholder("please input secret ")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam usersParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_USERS, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_USERS)
.setPlaceholder("please input users ") |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,460 | [Feature][Alert] Wechat alert support send to group chat | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
We only support sending to apps right now in 2.0.1-release. https://work.weixin.qq.com/api/doc/90000/90135/90236
We should add support send to appchat .And add a switch button in UI. https://work.weixin.qq.com/api/doc/90000/90135/90248
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7460 | https://github.com/apache/dolphinscheduler/pull/7465 | fc162826d91576da2649f5acfd6f11bcff58c5d7 | 86b476a1601872d1e47c3e9ca5ee4c18cbea92d3 | 2021-12-17T04:05:54Z | java | 2021-12-18T02:26:16Z | dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertChannelFactory.java | .addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam userSendMsgParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_USER_SEND_MSG, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_USER_SEND_MSG)
.setPlaceholder("please input corp id ")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
InputParam agentIdParam = InputParam.newBuilder(WeChatAlertParamsConstants.NAME_ENTERPRISE_WE_CHAT_AGENT_ID, WeChatAlertParamsConstants.ENTERPRISE_WE_CHAT_AGENT_ID)
.setPlaceholder("please input agent id ")
.addValidate(Validate.newBuilder()
.setRequired(true)
.build())
.build();
RadioParam showType = RadioParam.newBuilder(AlertConstants.NAME_SHOW_TYPE, AlertConstants.SHOW_TYPE)
.addParamsOptions(new ParamsOptions(ShowType.TABLE.getDescp(), ShowType.TABLE.getDescp(), false))
.addParamsOptions(new ParamsOptions(ShowType.TEXT.getDescp(), ShowType.TEXT.getDescp(), false))
.setValue(ShowType.TABLE.getDescp())
.addValidate(Validate.newBuilder().setRequired(true).build())
.build();
return Arrays.asList(corpIdParam, secretParam, usersParam, userSendMsgParam, agentIdParam, showType);
}
@Override
public AlertChannel create() {
return new WeChatAlertChannel();
}
} |
closed | apache/dolphinscheduler | https://github.com/apache/dolphinscheduler | 7,460 | [Feature][Alert] Wechat alert support send to group chat | ### Search before asking
- [X] I had searched in the [issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and found no similar feature requirement.
### Description
We only support sending to apps right now in 2.0.1-release. https://work.weixin.qq.com/api/doc/90000/90135/90236
We should add support send to appchat .And add a switch button in UI. https://work.weixin.qq.com/api/doc/90000/90135/90248
### Use case
_No response_
### Related issues
_No response_
### Are you willing to submit a PR?
- [X] Yes I am willing to submit a PR!
### Code of Conduct
- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)
| https://github.com/apache/dolphinscheduler/issues/7460 | https://github.com/apache/dolphinscheduler/pull/7465 | fc162826d91576da2649f5acfd6f11bcff58c5d7 | 86b476a1601872d1e47c3e9ca5ee4c18cbea92d3 | 2021-12-17T04:05:54Z | java | 2021-12-18T02:26:16Z | dolphinscheduler-alert/dolphinscheduler-alert-plugins/dolphinscheduler-alert-wechat/src/main/java/org/apache/dolphinscheduler/plugin/alert/wechat/WeChatAlertConstants.java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.plugin.alert.wechat;
public final class WeChatAlertConstants {
static final String MARKDOWN_QUOTE = ">";
static final String MARKDOWN_ENTER = "\n";
static final String CHARSET = "UTF-8";
static final String WE_CHAT_PUSH_URL = "https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token={token}";
static final String WE_CHAT_TOKEN_URL = "https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid={corpId}&corpsecret={secret}";
private WeChatAlertConstants() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.