Search in sources :

Example 1 with PrivilegeVO

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

the class PrivilegeManageResource method savePrivilege.

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

Example 2 with PrivilegeVO

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

the class PrivilegeManageResource method privileges.

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

Example 3 with PrivilegeVO

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

the class PrivilegeManageResource method savePrivilegeInfo.

private DataVO<PrivilegeVO> savePrivilegeInfo(PrivilegeVO privilegeVO) {
    try {
        Privilege privilege = EntityFactory.createEntity(Privilege.class);
        PrivilegeVO.transform(privilegeVO, privilege);
        privilege = accessor.save(privilege);
        PrivilegeVO vo = PrivilegeVO.transform(privilege, true);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(vo);
    } catch (UserInterfaceException ex) {
        return new DataVO<>(ex);
    } catch (Exception ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Save privilege fail.", ex);
        }
        return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
    }
}
Also used : DataVO(org.mx.service.rest.vo.DataVO) PaginationDataVO(org.mx.service.rest.vo.PaginationDataVO) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException) PrivilegeVO(org.mx.comps.rbac.rest.vo.PrivilegeVO) Privilege(org.mx.comps.rbac.dal.entity.Privilege) UserInterfaceException(org.mx.error.UserInterfaceException) UserInterfaceSystemErrorException(org.mx.error.UserInterfaceSystemErrorException)

Example 4 with PrivilegeVO

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

the class PrivilegeManageResource method getPrivilege.

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

Aggregations

Privilege (org.mx.comps.rbac.dal.entity.Privilege)4 PrivilegeVO (org.mx.comps.rbac.rest.vo.PrivilegeVO)4 UserInterfaceException (org.mx.error.UserInterfaceException)4 UserInterfaceSystemErrorException (org.mx.error.UserInterfaceSystemErrorException)4 PaginationDataVO (org.mx.service.rest.vo.PaginationDataVO)4 AuthenticateAround (org.mx.comps.jwt.AuthenticateAround)3 DataVO (org.mx.service.rest.vo.DataVO)3 Pagination (org.mx.dal.Pagination)1