Search in sources :

Example 31 with UserInterfaceErrorException

use of com.ds.retl.exception.UserInterfaceErrorException in project main by JohnPeng739.

the class ServerManageResource method saveServerInfo.

@Path("server")
@POST
public DataVO<ServerInfoVO> saveServerInfo(@QueryParam("userCode") String userCode, String info) {
    sessionDataStore.setCurrentUserCode(userCode);
    try {
        JSONObject json = serverManageService.saveServerInfo(info);
        sessionDataStore.removeCurrentUserCode();
        return new DataVO<>(new ServerInfoVO(json));
    } catch (UserInterfaceErrorException ex) {
        return new DataVO<>(ex);
    }
}
Also used : JSONObject(com.alibaba.fastjson.JSONObject) PaginationDataVO(org.mx.rest.vo.PaginationDataVO) DataVO(org.mx.rest.vo.DataVO) ServerInfoVO(com.ds.retl.rest.vo.server.ServerInfoVO) UserInterfaceErrorException(com.ds.retl.exception.UserInterfaceErrorException)

Example 32 with UserInterfaceErrorException

use of com.ds.retl.exception.UserInterfaceErrorException 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 33 with UserInterfaceErrorException

use of com.ds.retl.exception.UserInterfaceErrorException 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 34 with UserInterfaceErrorException

use of com.ds.retl.exception.UserInterfaceErrorException 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 35 with UserInterfaceErrorException

use of com.ds.retl.exception.UserInterfaceErrorException 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

UserInterfaceErrorException (com.ds.retl.exception.UserInterfaceErrorException)35 JSONObject (com.alibaba.fastjson.JSONObject)17 EntityAccessException (org.mx.dal.exception.EntityAccessException)15 PaginationDataVO (org.mx.rest.vo.PaginationDataVO)13 DataVO (org.mx.rest.vo.DataVO)12 Topology (com.ds.retl.dal.entity.Topology)8 User (com.ds.retl.dal.entity.User)7 Transactional (org.springframework.transaction.annotation.Transactional)6 TopologyVO (com.ds.retl.rest.vo.topology.TopologyVO)5 ServerInfoVO (com.ds.retl.rest.vo.server.ServerInfoVO)3 UserVO (com.ds.retl.rest.vo.user.UserVO)3 IOException (java.io.IOException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 EntityInstantiationException (org.mx.dal.exception.EntityInstantiationException)3 RestInvokeException (org.mx.rest.client.RestInvokeException)3 JSONArray (com.alibaba.fastjson.JSONArray)2 ConfigJson (com.ds.retl.dal.entity.ConfigJson)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 PrintStream (java.io.PrintStream)2