Search in sources :

Example 11 with DataVO

use of org.mx.rest.vo.DataVO in project main by JohnPeng739.

the class TopologyManageResource method killTopology.

/**
 * 杀死集群中的计算拓扑
 *
 * @param userCode   操作用户代码
 * @param topologyId 拓扑关键字ID
 * @return 操作成功后的拓扑对象
 */
@Path("topology/kill")
@GET
public DataVO<TopologyVO> killTopology(@QueryParam("userCode") String userCode, @QueryParam("topologyId") String topologyId) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        Topology topology = topologyManageService.kill(topologyId);
        TopologyVO topologyVO = new TopologyVO();
        TopologyVO.transform(topology, topologyVO);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(topologyVO);
    } catch (UserInterfaceErrorException ex) {
        return new DataVO<>(ex);
    }
}
Also used : PaginationDataVO(org.mx.rest.vo.PaginationDataVO) DataVO(org.mx.rest.vo.DataVO) UserInterfaceErrorException(com.ds.retl.exception.UserInterfaceErrorException) Topology(com.ds.retl.dal.entity.Topology) TopologyVO(com.ds.retl.rest.vo.topology.TopologyVO)

Example 12 with DataVO

use of org.mx.rest.vo.DataVO in project main by JohnPeng739.

the class TopologyManageResource method getTopology.

/**
 * 根据拓扑数据库ID获取拓扑信息
 *
 * @param topologyId 关键字ID,不是集群中的ID
 * @return 拓扑值对象
 */
@Path("topology")
@GET
public DataVO<TopologyVO> getTopology(@QueryParam("topologyId") String topologyId) {
    try {
        Topology topology = accessor.getById(topologyId, Topology.class);
        TopologyVO vo = new TopologyVO();
        TopologyVO.transform(topology, vo);
        return new DataVO<>(vo);
    } catch (EntityAccessException ex) {
        if (logger.isErrorEnabled()) {
            logger.error(ex);
        }
        return new DataVO<>(new UserInterfaceErrorException(UserInterfaceErrors.DB_OPERATE_FAIL));
    }
}
Also used : PaginationDataVO(org.mx.rest.vo.PaginationDataVO) DataVO(org.mx.rest.vo.DataVO) UserInterfaceErrorException(com.ds.retl.exception.UserInterfaceErrorException) EntityAccessException(org.mx.dal.exception.EntityAccessException) Topology(com.ds.retl.dal.entity.Topology) TopologyVO(com.ds.retl.rest.vo.topology.TopologyVO)

Example 13 with DataVO

use of org.mx.rest.vo.DataVO in project main by JohnPeng739.

the class UserManageResource method login.

/**
 * 登入系统
 *
 * @param login 用户认证值对象
 * @return 登录成功返回登录用户信息对象,否则返回错误信息。
 */
@Path("login")
@POST
public DataVO<UserVO> login(AuthenticateVO login) {
    if (login == null) {
        return new DataVO<>();
    }
    sessionDataStore.setCurrentUserCode(login.getUser());
    try {
        User user = userManageService.login(login.getUser(), login.getPassword());
        UserVO userVO = new UserVO();
        UserVO.transform(user, userVO);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(userVO);
    } catch (UserInterfaceErrorException ex) {
        return new DataVO<>(ex);
    }
}
Also used : User(com.ds.retl.dal.entity.User) UserVO(com.ds.retl.rest.vo.user.UserVO) PaginationDataVO(org.mx.rest.vo.PaginationDataVO) DataVO(org.mx.rest.vo.DataVO) UserInterfaceErrorException(com.ds.retl.exception.UserInterfaceErrorException)

Example 14 with DataVO

use of org.mx.rest.vo.DataVO in project main by JohnPeng739.

the class UserManageResource method getUser.

/**
 * 获取指定用户代码的用户信息
 *
 * @param userCode 用户代码
 * @return 用户信息对象
 */
@Path("users/{userCode}")
@GET
public DataVO<UserVO> getUser(@PathParam("userCode") String userCode) {
    try {
        User user = accessor.getByCode(userCode, User.class);
        if (user == null) {
            return new DataVO<>(new UserInterfaceErrorException(UserInterfaceErrors.USER_NOT_FOUND));
        }
        UserVO userVO = new UserVO();
        UserVO.transform(user, userVO);
        return new DataVO<>(userVO);
    } catch (EntityAccessException ex) {
        if (logger.isErrorEnabled()) {
            logger.error(ex);
        }
        return new DataVO<>(new UserInterfaceErrorException(UserInterfaceErrors.DB_OPERATE_FAIL));
    }
}
Also used : User(com.ds.retl.dal.entity.User) UserVO(com.ds.retl.rest.vo.user.UserVO) PaginationDataVO(org.mx.rest.vo.PaginationDataVO) DataVO(org.mx.rest.vo.DataVO) UserInterfaceErrorException(com.ds.retl.exception.UserInterfaceErrorException) EntityAccessException(org.mx.dal.exception.EntityAccessException)

Aggregations

DataVO (org.mx.rest.vo.DataVO)14 PaginationDataVO (org.mx.rest.vo.PaginationDataVO)13 UserInterfaceErrorException (com.ds.retl.exception.UserInterfaceErrorException)12 Topology (com.ds.retl.dal.entity.Topology)5 TopologyVO (com.ds.retl.rest.vo.topology.TopologyVO)5 JSONObject (com.alibaba.fastjson.JSONObject)3 User (com.ds.retl.dal.entity.User)3 UserVO (com.ds.retl.rest.vo.user.UserVO)3 ServerInfoVO (com.ds.retl.rest.vo.server.ServerInfoVO)2 ArrayList (java.util.ArrayList)2 EntityAccessException (org.mx.dal.exception.EntityAccessException)2 JSONArray (com.alibaba.fastjson.JSONArray)1 JmsManager (com.ds.retl.jms.JmsManager)1 LabelValueVO (com.ds.retl.rest.vo.LabelValueVO)1 ServicesStatusVO (com.ds.retl.rest.vo.server.ServicesStatusVO)1 RetlStatisticVO (com.ds.retl.rest.vo.statistic.RetlStatisticVO)1 SupportedVO (com.ds.retl.rest.vo.topology.SupportedVO)1 TopologyRealStatusVO (com.ds.retl.rest.vo.topology.TopologyRealStatusVO)1 ServerManageService (com.ds.retl.service.ServerManageService)1 TypeValidateFunc (com.ds.retl.validate.TypeValidateFunc)1