Search in sources :

Example 1 with RoleVO

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

the class RoleManageResource method saveRole.

@Path("roles/new")
@POST
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<RoleVO> saveRole(@QueryParam("userCode") String userCode, RoleInfoVO roleInfoVO) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        roleInfoVO.setId(null);
        Role role = roleManageService.saveRole(roleInfoVO.getRoleInfo());
        RoleVO vo = RoleVO.transform(role, true);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Save role fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Role(org.mx.comps.rbac.dal.entity.Role) RoleVO(org.mx.comps.rbac.rest.vo.RoleVO) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Example 2 with RoleVO

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

the class RoleManageResource method roles.

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

Example 3 with RoleVO

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

the class RoleManageResource method getRole.

@Path("roles/{id}")
@GET
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<RoleVO> getRole(@PathParam("id") String id) {
    try {
        Role role = accessor.getById(id, Role.class);
        RoleVO vo = RoleVO.transform(role, true);
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Get role fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Role(org.mx.comps.rbac.dal.entity.Role) RoleVO(org.mx.comps.rbac.rest.vo.RoleVO) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Example 4 with RoleVO

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

the class RoleManageResource method deleteRole.

@Path("roles/{id}")
@DELETE
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<RoleVO> deleteRole(@QueryParam("userCode") String userCode, @PathParam("id") String id) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        Role role = accessor.remove(id, Role.class);
        RoleVO vo = RoleVO.transform(role, true);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Delete role fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : Role(org.mx.comps.rbac.dal.entity.Role) RoleVO(org.mx.comps.rbac.rest.vo.RoleVO) DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) AuthenticateAround(org.mx.comps.jwt.AuthenticateAround)

Aggregations

AuthenticateAround (org.mx.comps.jwt.AuthenticateAround)4 Role (org.mx.comps.rbac.dal.entity.Role)4 RoleVO (org.mx.comps.rbac.rest.vo.RoleVO)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