001: /**
002: * ChainBuilder ESB
003: * Visual Enterprise Integration
004: *
005: * Copyright (C) 2006 Bostech Corporation
006: *
007: * This program is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License as published by the
009: * Free Software Foundation; either version 2 of the License, or (at your option)
010: * any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
014: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
015: * for more details.
016: *
017: * You should have received a copy of the GNU General Public License along with
018: * this program; if not, write to the Free Software Foundation, Inc.,
019: * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020: *
021: * SecurityOperationsImpl
022: * LPS
023: * Oct 29, 2007
024: */package com.bostechcorp.cbesb.console.server;
025:
026: import java.util.List;
027: import java.util.Vector;
028:
029: import com.bostechcorp.cbesb.common.i18n.CoreMessageConstants;
030: import com.bostechcorp.cbesb.common.i18n.Messages;
031: import com.bostechcorp.cbesb.common.util.runtimedb.ConsoleUserDB;
032: import com.bostechcorp.cbesb.common.util.runtimedb.vo.ConsoleUserVO;
033: import com.bostechcorp.cbesb.console.common.ConsoleUserInfo;
034: import com.bostechcorp.cbesb.console.common.ServerSideException;
035: import com.bostechcorp.cbesb.console.rpc.SecurityOperations;
036:
037: /**
038: * @author LPS
039: *
040: */
041: public class SecurityOperationsImpl extends ConsoleRemoteServiceServlet
042: implements SecurityOperations {
043:
044: private static final long serialVersionUID = -1094367799218319247L;
045:
046: /* (non-Javadoc)
047: * @see com.bostechcorp.cbesb.console.rpc.SecurityOperations#getUserList()
048: */
049: public List getUserList() throws ServerSideException {
050:
051: List l;
052: List<ConsoleUserInfo> userInfoList = new Vector<ConsoleUserInfo>();
053: try {
054: l = ConsoleUserDB.getUserList();
055:
056: for (int i = 0; i < l.size(); i++) {
057: userInfoList.add(convert((ConsoleUserVO) l.get(i)));
058: }
059: } catch (Exception e) {
060: throw new ServerSideException((Messages
061: .get(CoreMessageConstants.FAILED_GET_USER_LIST)), e);
062: }
063: return userInfoList;
064: }
065:
066: /* (non-Javadoc)
067: * @see com.bostechcorp.cbesb.console.rpc.SecurityOperations#add(com.bostechcorp.cbesb.common.util.runtimedb.vo.ConsoleUserVO)
068: */
069: public boolean add(ConsoleUserInfo user) throws ServerSideException {
070:
071: try {
072:
073: ConsoleUserDB.add(convert(user));
074: } catch (Exception e) {
075: throw new ServerSideException((Messages
076: .get(CoreMessageConstants.FAILED_ADD_USER)), e);
077: }
078: return true;
079: }
080:
081: /* (non-Javadoc)
082: * @see com.bostechcorp.cbesb.console.rpc.SecurityOperations#delete(com.bostechcorp.cbesb.common.util.runtimedb.vo.ConsoleUserVO)
083: */
084: public boolean delete(ConsoleUserInfo user)
085: throws ServerSideException {
086:
087: try {
088: ConsoleUserDB.delete(convert(user));
089: } catch (Exception e) {
090: throw new ServerSideException((Messages
091: .get(CoreMessageConstants.FAILED_DELETE_USER)), e);
092: }
093: return true;
094: }
095:
096: /* (non-Javadoc)
097: * @see com.bostechcorp.cbesb.console.rpc.SecurityOperations#getUserByNickname(java.lang.String)
098: *
099: */
100: public ConsoleUserInfo getUserByNickname(String nickname)
101: throws ServerSideException {
102:
103: try {
104:
105: return convert(ConsoleUserDB.getUserByNickname(nickname));
106: } catch (Exception e) {
107: throw new ServerSideException((Messages
108: .get(CoreMessageConstants.FAILED_GET_USER))
109: + nickname, e);
110: }
111: }
112:
113: /* (non-Javadoc)
114: * @see com.bostechcorp.cbesb.console.rpc.SecurityOperations#update(com.bostechcorp.cbesb.console.rpc.ConsoleUserVO)
115: */
116: public boolean update(ConsoleUserInfo user)
117: throws ServerSideException {
118:
119: try {
120: ConsoleUserDB.update(convert(user));
121: } catch (Exception e) {
122: throw new ServerSideException((Messages
123: .get(CoreMessageConstants.FAILED_UPDATE_USER))
124: + user.getLogin(), e);
125: }
126: return true;
127: }
128:
129: static ConsoleUserInfo convert(ConsoleUserVO vo) {
130: ConsoleUserInfo userInfo = new ConsoleUserInfo();
131: userInfo.setUserId(vo.getUserId());
132: userInfo.setPassword(vo.getPassword());
133: userInfo.setName(vo.getName());
134: userInfo.setEmail(vo.getEmail());
135: userInfo.setLogin(vo.getLogin());
136: userInfo.setNotes(vo.getNotes());
137: userInfo.setTimeout(vo.getTimeout());
138: userInfo.setType(vo.getType());
139: userInfo.setLastUpdated(vo.getLastUpdated());
140:
141: return userInfo;
142: }
143:
144: static ConsoleUserVO convert(ConsoleUserInfo userInfo) {
145: ConsoleUserVO vo = new ConsoleUserVO();
146: vo.setUserId(userInfo.getUserId());
147: vo.setName(userInfo.getName());
148: vo.setPassword(userInfo.getPassword());
149: vo.setEmail(userInfo.getEmail());
150: vo.setLastUpdated(userInfo.getLastUpdated());
151: vo.setLogin(userInfo.getLogin());
152: vo.setNotes(userInfo.getNotes());
153: vo.setTimeout(userInfo.getTimeout());
154: vo.setType(userInfo.getType());
155:
156: return vo;
157: }
158: }
|