Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[#8979] Remove unnecessary ResponseEntity #9010

Merged
merged 2 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.apache.thrift.TBase;
import org.apache.thrift.TException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand All @@ -59,7 +58,7 @@ public AgentCommandController(ConfigProperties webProperties, AgentService agent
}

@GetMapping(value = "/activeThreadDump")
public ResponseEntity<CodeResult> getActiveThreadDump(@RequestParam(value = "applicationName") String applicationName,
public CodeResult getActiveThreadDump(@RequestParam(value = "applicationName") String applicationName,
@RequestParam(value = "agentId") String agentId,
@RequestParam(value = "limit", required = false, defaultValue = "-1") int limit,
@RequestParam(value = "threadName", required = false) List<String> threadNameList,
Expand Down Expand Up @@ -155,7 +154,7 @@ public String getVersion() {
}

@GetMapping(value = "/activeThreadLightDump")
public ResponseEntity<CodeResult> getActiveThreadLightDump(@RequestParam(value = "applicationName") String applicationName,
public CodeResult getActiveThreadLightDump(@RequestParam(value = "applicationName") String applicationName,
@RequestParam(value = "agentId") String agentId,
@RequestParam(value = "limit", required = false, defaultValue = "-1") int limit,
@RequestParam(value = "threadName", required = false) List<String> threadNameList,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.navercorp.pinpoint.web.vo.AgentDownloadInfo;
import com.navercorp.pinpoint.web.vo.AgentInstallationInfo;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;
Expand All @@ -22,7 +21,7 @@ public AgentDownloadController(AgentDownLoadService agentDownLoadService) {
}

@RequestMapping(value = "/getAgentInstallationInfo")
public ResponseEntity<CodeResult> getAgentDownloadUrl() {
public CodeResult getAgentDownloadUrl() {
AgentDownloadInfo latestStableAgentDownloadInfo = agentDownLoadService.getLatestStableAgentDownloadInfo();
if (latestStableAgentDownloadInfo != null) {
return CodeResult.ok(new AgentInstallationInfo(latestStableAgentDownloadInfo));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import com.navercorp.pinpoint.common.server.util.time.Range;
import com.navercorp.pinpoint.web.vo.timeline.inspector.InspectorTimeline;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand Down Expand Up @@ -177,7 +176,7 @@ public InspectorTimeline getAgentStatusTimeline(
}

@RequestMapping(value = "/isAvailableAgentId")
public ResponseEntity<CodeResult> isAvailableAgentId(@RequestParam("agentId") String agentId) {
public CodeResult isAvailableAgentId(@RequestParam("agentId") String agentId) {
final IdValidateUtils.CheckResult result = IdValidateUtils.checkId(agentId, PinpointConstants.AGENT_ID_MAX_LEN);
if (result == IdValidateUtils.CheckResult.FAIL_LENGTH) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "length range is 1 ~ 24");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down Expand Up @@ -76,16 +75,16 @@ private boolean isRuleDataValidForPost(Rule rule) {
}

@PostMapping()
public ResponseEntity<Response> insertRule(@RequestBody Rule rule) {
public Response insertRule(@RequestBody Rule rule) {
if (!isRuleDataValidForPost(rule)) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "there is not applicationId/checkerName/userGroupId/threashold to insert alarm rule");
}
String ruleId = alarmService.insertRule(rule);
return ResponseEntity.ok(getAlarmResponse("SUCCESS", ruleId));
return getAlarmResponse("SUCCESS", ruleId);
}

@DeleteMapping()
public ResponseEntity<Response> deleteRule(@RequestBody Rule rule) {
public Response deleteRule(@RequestBody Rule rule) {
if (StringUtils.isEmpty(rule.getRuleId())) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "there is not ruleId to delete alarm rule");
}
Expand All @@ -105,7 +104,7 @@ public Object getRule(@RequestParam(value=USER_GROUP_ID, required=false) String
}

@PutMapping()
public ResponseEntity<Response> updateRule(@RequestBody Rule rule) {
public Response updateRule(@RequestBody Rule rule) {
if (StringUtils.isEmpty(rule.getRuleId()) || StringUtils.isEmpty(rule.getApplicationId()) || StringUtils.isEmpty(rule.getCheckerName()) || StringUtils.isEmpty(rule.getUserGroupId())) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "there is not ruleId/userGroupId/applicationid/checkerName to update alarm rule");
}
Expand All @@ -114,7 +113,7 @@ public ResponseEntity<Response> updateRule(@RequestBody Rule rule) {
}

@PostMapping(value = "/includeWebhooks")
public ResponseEntity<Response> insertRuleWithWebhooks(@RequestBody RuleWithWebhooks ruleWithWebhooks) {
public Response insertRuleWithWebhooks(@RequestBody RuleWithWebhooks ruleWithWebhooks) {
Rule rule = ruleWithWebhooks.getRule();
if (!isRuleDataValidForPost(rule)) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "there is not applicationId/checkerName/userGroupId/threashold to insert alarm rule");
Expand All @@ -123,11 +122,11 @@ public ResponseEntity<Response> insertRuleWithWebhooks(@RequestBody RuleWithWebh
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "webhook should be enabled to bind webhook to an alarm");
}
String ruleId = alarmService.insertRuleWithWebhooks(rule, ruleWithWebhooks.getWebhookIds());
return ResponseEntity.ok(getAlarmResponse("SUCCESS", ruleId));
return getAlarmResponse("SUCCESS", ruleId);
}

@PutMapping(value = "/includeWebhooks")
public ResponseEntity<Response> updateRuleWithWebhooks(@RequestBody RuleWithWebhooks ruleWithWebhooks) {
public Response updateRuleWithWebhooks(@RequestBody RuleWithWebhooks ruleWithWebhooks) {
Rule rule = ruleWithWebhooks.getRule();
if (StringUtils.isEmpty(rule.getRuleId()) || StringUtils.isEmpty(rule.getApplicationId()) || StringUtils.isEmpty(rule.getCheckerName()) || StringUtils.isEmpty(rule.getUserGroupId())) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "there is not ruleId/userGroupId/applicationid/checkerName to update alarm rule");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
Expand Down Expand Up @@ -58,7 +56,7 @@ public UserController(UserService userService) {
}

@PostMapping()
public ResponseEntity<Response> insertUser(@RequestBody User user) {
public Response insertUser(@RequestBody User user) {
if (!ValueValidator.validateUser(user)) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "User information validation failed to creating user information.");
}
Expand All @@ -67,7 +65,7 @@ public ResponseEntity<Response> insertUser(@RequestBody User user) {
}

@DeleteMapping()
public ResponseEntity<Response> deletetUser(@RequestBody User user) {
public Response deletetUser(@RequestBody User user) {
if (StringUtils.isEmpty(user.getUserId())) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "there is not userId in params to delete user");
}
Expand Down Expand Up @@ -95,7 +93,7 @@ public List<User> getUser(@RequestParam(value = "userId", required = false) Stri
}

@PutMapping()
public ResponseEntity<Response> updateUser(@RequestBody User user) {
public Response updateUser(@RequestBody User user) {
if (!ValueValidator.validateUser(user)) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "User information validation failed to creating user infomation.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
Expand Down Expand Up @@ -59,22 +58,22 @@ public UserGroupController(UserGroupService userGroupService) {
}

@PostMapping()
public ResponseEntity<Response> createUserGroup(@RequestBody UserGroup userGroup) {
public Response createUserGroup(@RequestBody UserGroup userGroup) {
if (!ValueValidator.validateUserGroupId(userGroup.getId())) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "usergroupId pattern is invalid to create user group");
}

try {
String userGroupNumber = userGroupService.createUserGroup(userGroup);
return ResponseEntity.ok(new CreateUserGroupResponse("SUCCESS", userGroupNumber));
return new CreateUserGroupResponse("SUCCESS", userGroupNumber);
} catch (PinpointUserGroupException e) {
logger.error(e.getMessage(), e);
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, e.getMessage());
}
}

@DeleteMapping()
public ResponseEntity<Response> deleteUserGroup(@RequestBody UserGroup userGroup) {
public Response deleteUserGroup(@RequestBody UserGroup userGroup) {
if (StringUtils.isEmpty(userGroup.getId())) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "there is id of userGroup in params to delete user group");
}
Expand All @@ -99,7 +98,7 @@ public List<UserGroup> getUserGroup(@RequestParam(value = USER_ID, required = fa
}

@PostMapping(value = "/member")
public ResponseEntity<Response> insertUserGroupMember(@RequestBody UserGroupMemberParam userGroupMember) {
public Response insertUserGroupMember(@RequestBody UserGroupMemberParam userGroupMember) {
if (StringUtils.isEmpty(userGroupMember.getMemberId()) || StringUtils.isEmpty(userGroupMember.getUserGroupId())) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "there is not userGroupId or memberId in params to insert user group member");
}
Expand All @@ -108,7 +107,7 @@ public ResponseEntity<Response> insertUserGroupMember(@RequestBody UserGroupMemb
}

@DeleteMapping(value = "/member")
public ResponseEntity<Response> deleteUserGroupMember(@RequestBody UserGroupMemberParam userGroupMember) {
public Response deleteUserGroupMember(@RequestBody UserGroupMemberParam userGroupMember) {
if (StringUtils.isEmpty(userGroupMember.getUserGroupId()) || StringUtils.isEmpty(userGroupMember.getMemberId())) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "there is not userGroupId or memberId in params to delete user group member");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.navercorp.pinpoint.web.vo.AgentCountStatistics;
import com.navercorp.pinpoint.common.server.util.time.Range;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -47,12 +46,12 @@ public AgentStatisticsController(AgentStatisticsService agentStatisticsService)
}

@GetMapping(value = "/insertAgentCount", params = {"agentCount"})
public ResponseEntity<Response> insertAgentCount(@RequestParam("agentCount") int agentCount) {
public Response insertAgentCount(@RequestParam("agentCount") int agentCount) {
return insertAgentCount(agentCount, new Date().getTime());
}

@GetMapping(value = "/insertAgentCount", params = {"agentCount", "timestamp"})
public ResponseEntity<Response> insertAgentCount(@RequestParam("agentCount") int agentCount, @RequestParam("timestamp") long timestamp) {
public Response insertAgentCount(@RequestParam("agentCount") int agentCount, @RequestParam("timestamp") long timestamp) {
if (timestamp < 0) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "negative timestamp.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.navercorp.pinpoint.web.vo.ApplicationAgentHostList;
import com.navercorp.pinpoint.web.response.CodeResult;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand Down Expand Up @@ -63,7 +62,7 @@ public ApplicationAgentHostList getApplicationHostInfo (
}

@RequestMapping(value = "/isAvailableApplicationName")
public ResponseEntity<CodeResult> isAvailableApplicationName(@RequestParam("applicationName") String applicationName) {
public CodeResult isAvailableApplicationName(@RequestParam("applicationName") String applicationName) {
final IdValidateUtils.CheckResult result = IdValidateUtils.checkId(applicationName, PinpointConstants.APPLICATION_NAME_MAX_LEN);
if (result == IdValidateUtils.CheckResult.FAIL_LENGTH) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "length range is 1 ~ 24");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand All @@ -53,7 +52,7 @@ public CommandController(AgentService agentService) {
}

@GetMapping(value = "/echo")
public ResponseEntity<CodeResult> echo(@RequestParam("applicationName") String applicationName, @RequestParam("agentId") String agentId,
public CodeResult echo(@RequestParam("applicationName") String applicationName, @RequestParam("agentId") String agentId,
@RequestParam("startTimeStamp") long startTimeStamp, @RequestParam("message") String message) throws TException {

AgentInfo agentInfo = agentService.getAgentInfo(applicationName, agentId, startTimeStamp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException;
Expand All @@ -36,7 +35,7 @@ public WebhookController(WebhookService webhookService) {
}

@PostMapping()
public ResponseEntity<Response> insertWebhook(@RequestBody Webhook webhook) {
public Response insertWebhook(@RequestBody Webhook webhook) {
if (!webhookEnable) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "webhook function is disabled");
}
Expand All @@ -46,11 +45,11 @@ public ResponseEntity<Response> insertWebhook(@RequestBody Webhook webhook) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "there should be url, applicationId/serviceName to insert webhook");
}
String webhookId = webhookService.insertWebhook(webhook);
return ResponseEntity.ok(new WebhookResponse("SUCCESS", webhookId));
return new WebhookResponse("SUCCESS", webhookId);
}

@DeleteMapping()
public ResponseEntity<Response> deleteWebhook(@RequestBody Webhook webhook) {
public Response deleteWebhook(@RequestBody Webhook webhook) {
if (!webhookEnable) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "webhook function is disabled");
}
Expand Down Expand Up @@ -86,7 +85,7 @@ public List<Webhook> getWebhook(@RequestParam(value=APPLICATION_ID, required=fal
}

@PutMapping()
public ResponseEntity<Response> updateWebhook(@RequestBody Webhook webhook) {
public Response updateWebhook(@RequestBody Webhook webhook) {
if (!webhookEnable) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "webhook function is disabled");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.apache.logging.log4j.LogManager;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException;
Expand All @@ -36,7 +35,7 @@ public WebhookSendInfoController(WebhookService webhookService, WebhookSendInfoS


@PostMapping()
public ResponseEntity<Response> insertWebhookSendInfo(@RequestBody WebhookSendInfo webhookSendInfo) {
public Response insertWebhookSendInfo(@RequestBody WebhookSendInfo webhookSendInfo) {
if (!webhookEnable) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "webhook function is disabled");
}
Expand All @@ -45,11 +44,11 @@ public ResponseEntity<Response> insertWebhookSendInfo(@RequestBody WebhookSendIn
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "there should be ruleId and webhookIdto insert webhookSendInfo");
}
String webhookSendInfoId = webhookSendInfoService.insertWebhookSendInfo(webhookSendInfo);
return ResponseEntity.ok(new WebhookSendInfoResponse("SUCCESS", webhookSendInfoId));
return new WebhookSendInfoResponse("SUCCESS", webhookSendInfoId);
}

@DeleteMapping()
public ResponseEntity<Response> deleteWebhookSendInfo(@RequestBody WebhookSendInfo webhookSendInfo) {
public Response deleteWebhookSendInfo(@RequestBody WebhookSendInfo webhookSendInfo) {
if (!webhookEnable) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "webhook function is disabled");
}
Expand Down Expand Up @@ -80,7 +79,7 @@ public Object getWebhookSendInfo(@RequestParam(value=WEBHOOK_ID, required=false)
}

@PutMapping()
public ResponseEntity<Response> updateWebhookSendInfo(@RequestBody WebhookSendInfo webhookSendInfo) {
public Response updateWebhookSendInfo(@RequestBody WebhookSendInfo webhookSendInfo) {
if (!webhookEnable) {
throw new ResponseStatusException(HttpStatus.INTERNAL_SERVER_ERROR, "webhook function is disabled");
}
Expand Down
Loading