use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class CommentController method get.
@ApiOperation(value = "Get topic with all comments")
@RequestMapping(value = "/api/v1/comments/{topicId}", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = RequestMethod.GET)
public JsonResult<CommentTopicDTO> get(@PathVariable("topicId") Long topicId) throws NotExistException {
final CommentTopic topic = commentService.getTopic(topicId);
JsonResult<CommentTopicDTO> result = new JsonResult<>(NO_ERROR);
result.setResult(conversionService.convert(topic, CommentTopicDTO.class));
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseExpertFinderController method list.
@ApiOperation("Get expert list")
@RequestMapping(value = "/api/v1/user-management/users", method = GET)
public JsonResult<ExpertListSearchResultDTO> list(@ModelAttribute SearchExpertListDTO searchDTO) throws IOException, SolrServerException, NoSuchFieldException {
JsonResult result = new JsonResult<ExpertListSearchResultDTO>(NO_ERROR);
SolrQuery solrQuery = conversionService.convert(searchDTO, SolrQuery.class);
SearchResult searchResult = userService.search(solrQuery);
result.setResult(this.conversionService.convert(searchResult, ExpertListSearchResultDTO.class));
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseUserController method changePassword.
@ApiOperation("Change user password")
@RequestMapping(value = "/api/v1/user-management/users/changepassword", method = POST)
public JsonResult changePassword(@RequestBody @Valid ChangePasswordDTO changePasswordDTO, Principal principal) throws ValidationException, PasswordValidationException {
JsonResult result;
U loggedUser = userService.getByEmail(principal.getName());
try {
userService.updatePassword(loggedUser, changePasswordDTO.getOldPassword(), changePasswordDTO.getNewPassword());
result = new JsonResult<>(NO_ERROR);
} catch (ValidationException ex) {
result = new JsonResult<>(VALIDATION_ERROR);
result.setErrorMessage(ex.getMessage());
}
return result;
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseUserController method unlinkUserToDataNode.
@ApiOperation("Unlink User to DataNode")
@RequestMapping(value = "/api/v1/user-management/datanodes/{datanodeId}/users", method = RequestMethod.DELETE)
public JsonResult unlinkUserToDataNode(@PathVariable("datanodeId") Long datanodeId, @RequestBody CommonLinkUserToDataNodeDTO linkUserToDataNode) throws NotExistException {
final DN datanode = Optional.ofNullable(baseDataNodeService.getById(datanodeId)).orElseThrow(() -> new NotExistException(String.format(DATA_NODE_NOT_FOUND_EXCEPTION, datanodeId), DataNode.class));
final U user = userService.getByUsernameInAnyTenant(linkUserToDataNode.getUserName());
baseDataNodeService.unlinkUserToDataNode(datanode, user);
return new JsonResult(NO_ERROR);
}
use of com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.NO_ERROR in project ArachneCentralAPI by OHDSI.
the class BaseUserController method invitationAccept.
private JsonResult<UserProfileDTO> invitationAccept(InvitationActionDTO invitationActionDTO, U user) throws NotExistException, AlreadyExistException, IOException {
checkIfUserExists(user);
final Boolean invitationAccepted = invitationActionDTO.getAccepted();
final Long invitationId = invitationActionDTO.getId();
switch(invitationActionDTO.getType()) {
case InvitationType.COLLABORATOR:
{
userService.processInvitation(user, invitationId, invitationAccepted, invitationActionDTO.getComment());
break;
}
case InvitationType.DATA_OWNER:
{
studyService.processDataSourceInvitation(user, invitationId, invitationAccepted, invitationActionDTO.getComment());
break;
}
case InvitationType.UNLOCK_ANALYSIS:
{
analysisService.processAnalysisUnlockRequest(user, invitationId, invitationAccepted);
break;
}
case InvitationType.APPROVE_EXECUTE_SUBMISSION:
submissionService.approveSubmission(invitationId, invitationAccepted, invitationActionDTO.getComment(), user);
break;
case InvitationType.APPROVE_PUBLISH_SUBMISSION:
ApproveDTO dto = new ApproveDTO(invitationId, invitationAccepted, Boolean.TRUE, invitationActionDTO.getComment());
submissionService.approveSubmissionResult(invitationId, dto, user);
break;
default:
{
throw new IllegalArgumentException();
}
}
return new JsonResult<>(NO_ERROR, conversionService.convert(userService.getByIdInAnyTenantAndInitializeCollections(user.getId()), UserProfileDTO.class));
}
Aggregations