Search in sources :

Example 66 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project plumdo-work by wengwh.

the class TaskIdentityResource method createIdentityLink.

@RequestMapping(value = "/task/{taskId}/identity", method = RequestMethod.POST, name = "任务候选人创建")
@ResponseStatus(value = HttpStatus.OK)
public void createIdentityLink(@PathVariable("taskId") String taskId, @RequestBody TaskIdentityRequest taskIdentityRequest) {
    Task task = getTaskFromRequest(taskId, false);
    validateIdentityLinkArguments(taskIdentityRequest.getIdentityId(), taskIdentityRequest.getType());
    if (TaskIdentityRequest.AUTHORIZE_GROUP.equals(taskIdentityRequest.getType())) {
        taskService.addGroupIdentityLink(task.getId(), taskIdentityRequest.getIdentityId(), IdentityLinkType.CANDIDATE);
    } else if (TaskIdentityRequest.AUTHORIZE_USER.equals(taskIdentityRequest.getType())) {
        taskService.addUserIdentityLink(task.getId(), taskIdentityRequest.getIdentityId(), IdentityLinkType.CANDIDATE);
    }
}
Also used : Task(org.flowable.engine.task.Task) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 67 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project ORCID-Source by ORCID.

the class PasswordResetController method sendReactivation.

@RequestMapping(value = "/sendReactivation.json", method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
public void sendReactivation(@RequestParam("email") String email) {
    OrcidProfile orcidProfile = orcidProfileCacheManager.retrieve(emailManager.findOrcidIdByEmail(email));
    notificationManager.sendReactivationEmail(email, orcidProfile);
}
Also used : OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 68 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.

the class CompleteDataSetRegistrationController method deleteCompleteDataSetRegistration.

// -------------------------------------------------------------------------
// DELETE
// -------------------------------------------------------------------------
@ApiVersion({ DhisApiVersion.ALL, DhisApiVersion.DEFAULT })
@RequestMapping(method = RequestMethod.DELETE)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void deleteCompleteDataSetRegistration(@RequestParam Set<String> ds, @RequestParam String pe, @RequestParam String ou, @RequestParam(required = false) String cc, @RequestParam(required = false) String cp, @RequestParam(required = false) boolean multiOu, HttpServletResponse response) throws WebMessageException {
    Set<DataSet> dataSets = new HashSet<>(manager.getByUid(DataSet.class, ds));
    if (dataSets.size() != ds.size()) {
        throw new WebMessageException(WebMessageUtils.conflict("Illegal data set identifier in this list: " + ds));
    }
    Period period = PeriodType.getPeriodFromIsoString(pe);
    if (period == null) {
        throw new WebMessageException(WebMessageUtils.conflict("Illegal period identifier: " + pe));
    }
    OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit(ou);
    if (organisationUnit == null) {
        throw new WebMessageException(WebMessageUtils.conflict("Illegal organisation unit identifier: " + ou));
    }
    DataElementCategoryOptionCombo attributeOptionCombo = inputUtils.getAttributeOptionCombo(cc, cp, false);
    if (attributeOptionCombo == null) {
        return;
    }
    // ---------------------------------------------------------------------
    // Check locked status
    // ---------------------------------------------------------------------
    List<String> lockedDataSets = new ArrayList<>();
    for (DataSet dataSet : dataSets) {
        if (dataSetService.isLocked(dataSet, period, organisationUnit, attributeOptionCombo, null, multiOu)) {
            lockedDataSets.add(dataSet.getUid());
        }
    }
    if (lockedDataSets.size() != 0) {
        throw new WebMessageException(WebMessageUtils.conflict("Locked Data set(s) : " + StringUtils.join(lockedDataSets, ", ")));
    }
    // ---------------------------------------------------------------------
    // Un-register as completed data set
    // ---------------------------------------------------------------------
    Set<OrganisationUnit> orgUnits = new HashSet<>();
    orgUnits.add(organisationUnit);
    if (multiOu) {
        orgUnits.addAll(organisationUnit.getChildren());
    }
    unRegisterCompleteDataSet(dataSets, period, orgUnits, attributeOptionCombo);
}
Also used : OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataSet(org.hisp.dhis.dataset.DataSet) WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) ArrayList(java.util.ArrayList) Period(org.hisp.dhis.period.Period) DataElementCategoryOptionCombo(org.hisp.dhis.dataelement.DataElementCategoryOptionCombo) HashSet(java.util.HashSet) DhisApiVersion(org.hisp.dhis.common.DhisApiVersion) ApiVersion(org.hisp.dhis.webapi.mvc.annotation.ApiVersion) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 69 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.

the class DataApprovalController method acceptApprovalMultiple.

@PreAuthorize("hasRole('ALL') or hasRole('F_ACCEPT_DATA_LOWER_LEVELS')")
@RequestMapping(value = MULTIPLE_ACCEPTANCES_RESOURCE_PATH, method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void acceptApprovalMultiple(@RequestBody DataApprovalStateRequests dataApprovalStateRequests, HttpServletResponse response) throws WebMessageException {
    List<DataApproval> dataApprovalList = new ArrayList<>();
    for (DataApprovalStateRequest approvalStateRequest : dataApprovalStateRequests) {
        DataApprovalWorkflow workflow = getAndValidateWorkflow(approvalStateRequest.getDs(), null);
        Period period = getAndValidatePeriod(approvalStateRequest.getPe());
        OrganisationUnit organisationUnit = getAndValidateOrgUnit(approvalStateRequest.getOu());
        DataApprovalLevel dataApprovalLevel = getAndValidateApprovalLevel(organisationUnit);
        User user = approvalStateRequest.getAb() == null ? currentUserService.getCurrentUser() : userService.getUserCredentialsByUsername(approvalStateRequest.getAb()).getUserInfo();
        Date approvalDate = (approvalStateRequest.getAd() == null) ? new Date() : approvalStateRequest.getAd();
        dataApprovalList.addAll(getApprovalsAsList(dataApprovalLevel, workflow, period, organisationUnit, false, approvalDate, user));
    }
    dataApprovalService.acceptData(dataApprovalList);
}
Also used : DataApproval(org.hisp.dhis.dataapproval.DataApproval) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataApprovalLevel(org.hisp.dhis.dataapproval.DataApprovalLevel) User(org.hisp.dhis.user.User) DataApprovalStateRequest(org.hisp.dhis.dataapproval.DataApprovalStateRequest) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) Period(org.hisp.dhis.period.Period) DataApprovalWorkflow(org.hisp.dhis.dataapproval.DataApprovalWorkflow) Date(java.util.Date) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 70 with ResponseStatus

use of org.springframework.web.bind.annotation.ResponseStatus in project dhis2-core by dhis2.

the class DataApprovalController method saveApprovalMultiple.

@PreAuthorize("hasRole('ALL') or hasRole('F_APPROVE_DATA') or hasRole('F_APPROVE_DATA_LOWER_LEVELS')")
@RequestMapping(value = MULTIPLE_SAVE_RESOURCE_PATH, method = RequestMethod.POST)
@ResponseStatus(HttpStatus.NO_CONTENT)
public void saveApprovalMultiple(@RequestBody DataApprovalStateRequests dataApprovalStateRequests, HttpServletResponse response) throws WebMessageException {
    List<DataApproval> dataApprovalList = new ArrayList<>();
    for (DataApprovalStateRequest approvalStateRequest : dataApprovalStateRequests) {
        DataApprovalWorkflow workflow = getAndValidateWorkflow(approvalStateRequest.getDs(), null);
        Period period = getAndValidatePeriod(approvalStateRequest.getPe());
        OrganisationUnit organisationUnit = getAndValidateOrgUnit(approvalStateRequest.getOu());
        DataApprovalLevel dataApprovalLevel = getAndValidateApprovalLevel(organisationUnit);
        User user = approvalStateRequest.getAb() == null ? currentUserService.getCurrentUser() : userService.getUserCredentialsByUsername(approvalStateRequest.getAb()).getUserInfo();
        Date approvalDate = approvalStateRequest.getAd() == null ? new Date() : approvalStateRequest.getAd();
        dataApprovalList.addAll(getApprovalsAsList(dataApprovalLevel, workflow, period, organisationUnit, false, approvalDate, user));
    }
    dataApprovalService.approveData(dataApprovalList);
}
Also used : DataApproval(org.hisp.dhis.dataapproval.DataApproval) OrganisationUnit(org.hisp.dhis.organisationunit.OrganisationUnit) DataApprovalLevel(org.hisp.dhis.dataapproval.DataApprovalLevel) User(org.hisp.dhis.user.User) DataApprovalStateRequest(org.hisp.dhis.dataapproval.DataApprovalStateRequest) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) Period(org.hisp.dhis.period.Period) DataApprovalWorkflow(org.hisp.dhis.dataapproval.DataApprovalWorkflow) Date(java.util.Date) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)149 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)118 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)36 ApiOperation (io.swagger.annotations.ApiOperation)31 WebMessageException (org.hisp.dhis.dxf2.webmessage.WebMessageException)26 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)19 GetMapping (org.springframework.web.bind.annotation.GetMapping)18 ApiResponses (io.swagger.annotations.ApiResponses)14 User (org.hisp.dhis.user.User)14 Transactional (org.springframework.transaction.annotation.Transactional)14 Date (java.util.Date)13 Configuration (org.hisp.dhis.configuration.Configuration)12 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)12 Period (org.hisp.dhis.period.Period)11 ArrayList (java.util.ArrayList)10 QualifiedName (com.netflix.metacat.common.QualifiedName)9 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)9 ApiImplicitParam (io.swagger.annotations.ApiImplicitParam)9 Calendar (java.util.Calendar)9 Task (org.flowable.engine.task.Task)8