Search in sources :

Example 1 with AccreditVO

use of org.mx.comps.rbac.rest.vo.AccreditVO in project main by JohnPeng739.

the class AccreditManageResource method deleteAccredit.

@Path("accredits/{id}")
@DELETE
public DataVO<AccreditVO> deleteAccredit(@QueryParam("userCode") String userCode, @PathParam("id") String id) {
    if (StringUtils.isBlank(userCode) || StringUtils.isBlank(id)) {
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_ILLEGAL_PARAM));
    }
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        Accredit accredit = accreditManageService.closeAccredit(id);
        AccreditVO vo = AccreditVO.transform(accredit, true);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Delete accredit fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Accredit(org.mx.comps.rbac.dal.entity.Accredit) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) AccreditVO(org.mx.comps.rbac.rest.vo.AccreditVO) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException)

Example 2 with AccreditVO

use of org.mx.comps.rbac.rest.vo.AccreditVO in project main by JohnPeng739.

the class AccreditManageResource method newAccredit.

@Path("accredits/new")
@POST
public DataVO<AccreditVO> newAccredit(@QueryParam("userCode") String userCode, AccreditInfoVO accreditInfoVO) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        Accredit accredit = accreditManageService.accredit(accreditInfoVO.getAccreditInfo());
        AccreditVO vo = AccreditVO.transform(accredit, true);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Create accredit fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Accredit(org.mx.comps.rbac.dal.entity.Accredit) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) AccreditVO(org.mx.comps.rbac.rest.vo.AccreditVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException)

Example 3 with AccreditVO

use of org.mx.comps.rbac.rest.vo.AccreditVO in project main by JohnPeng739.

the class AccreditManageResource method accredits.

@Path("accredits")
@POST
public PaginationDataVO<List<AccreditVO>> accredits(Pagination pagination) {
    if (pagination == null) {
        pagination = new Pagination();
    }
    try {
        List<Accredit> accredits = accessor.list(pagination, Accredit.class);
        List<AccreditVO> list = AccreditVO.transform(accredits);
        return new PaginationDataVO<>(pagination, list);
    } catch (UserInterfaceException ex) {
        return new PaginationDataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("List accredits fail.", ex);
        }
        return new PaginationDataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Pagination(org.mx.dal.Pagination) Accredit(org.mx.comps.rbac.dal.entity.Accredit) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) AccreditVO(org.mx.comps.rbac.rest.vo.AccreditVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException)

Example 4 with AccreditVO

use of org.mx.comps.rbac.rest.vo.AccreditVO in project main by JohnPeng739.

the class AccreditManageResource method getAccredit.

@Path("accredits/{id}")
@GET
public DataVO<AccreditVO> getAccredit(@PathParam("id") String id) {
    if (StringUtils.isBlank(id)) {
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_ILLEGAL_PARAM));
    }
    try {
        Accredit accredit = accessor.getById(id, Accredit.class);
        AccreditVO vo = AccreditVO.transform(accredit, true);
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Get accredit fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Accredit(org.mx.comps.rbac.dal.entity.Accredit) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) AccreditVO(org.mx.comps.rbac.rest.vo.AccreditVO) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException)

Aggregations

Accredit (org.mx.comps.rbac.dal.entity.Accredit)4 AccreditVO (org.mx.comps.rbac.rest.vo.AccreditVO)4 UserInterfaceException (org.mx.error.UserInterfaceException)4 UserInterfaceSystemErrorException (org.mx.error.UserInterfaceSystemErrorException)4 PaginationDataVO (org.mx.service.rest.vo.PaginationDataVO)4 DataVO (org.mx.service.rest.vo.DataVO)3 Pagination (org.mx.dal.Pagination)1