Search in sources :

Example 11 with NO_ERROR

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;
}
Also used : CommentTopicDTO(com.odysseusinc.arachne.portal.api.v1.dto.CommentTopicDTO) CommentTopic(com.odysseusinc.arachne.portal.model.CommentTopic) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 12 with NO_ERROR

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;
}
Also used : ExpertListSearchResultDTO(com.odysseusinc.arachne.portal.api.v1.dto.ExpertListSearchResultDTO) SearchResult(com.odysseusinc.arachne.portal.service.impl.solr.SearchResult) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) SolrQuery(org.apache.solr.client.solrj.SolrQuery) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with 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 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;
}
Also used : PasswordValidationException(com.odysseusinc.arachne.portal.exception.PasswordValidationException) ValidationException(com.odysseusinc.arachne.portal.exception.ValidationException) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with 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 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);
}
Also used : DataNode(com.odysseusinc.arachne.portal.model.DataNode) NotExistException(com.odysseusinc.arachne.portal.exception.NotExistException) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 15 with 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));
}
Also used : UserProfileDTO(com.odysseusinc.arachne.portal.api.v1.dto.UserProfileDTO) ApproveDTO(com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO) JsonResult(com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)

Aggregations

RequestMapping (org.springframework.web.bind.annotation.RequestMapping)34 JsonResult (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult)33 ApiOperation (io.swagger.annotations.ApiOperation)31 IUser (com.odysseusinc.arachne.portal.model.IUser)18 GET (org.springframework.web.bind.annotation.RequestMethod.GET)10 POST (org.springframework.web.bind.annotation.RequestMethod.POST)10 PUT (org.springframework.web.bind.annotation.RequestMethod.PUT)10 NotExistException (com.odysseusinc.arachne.portal.exception.NotExistException)6 FileDTO (com.odysseusinc.arachne.portal.api.v1.dto.FileDTO)5 SubmissionFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionFileDTO)5 UploadFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.UploadFileDTO)5 AnalysisFile (com.odysseusinc.arachne.portal.model.AnalysisFile)5 PERMISSION_DENIED (com.odysseusinc.arachne.commons.api.v1.dto.util.JsonResult.ErrorCode.PERMISSION_DENIED)4 ApproveDTO (com.odysseusinc.arachne.portal.api.v1.dto.ApproveDTO)4 ResultFileDTO (com.odysseusinc.arachne.portal.api.v1.dto.ResultFileDTO)4 SubmissionInsightDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionInsightDTO)4 SubmissionStatusHistoryElementDTO (com.odysseusinc.arachne.portal.api.v1.dto.SubmissionStatusHistoryElementDTO)4 ValidationException (com.odysseusinc.arachne.portal.exception.ValidationException)4 DataNode (com.odysseusinc.arachne.portal.model.DataNode)4 Submission (com.odysseusinc.arachne.portal.model.Submission)4