1 // license-header java merge-point
2 //
3 // Generated by SessionBeanImpl.vsl in andromda-ejb3-cartridge on 08/05/2014 14:24:56.
4 // Modify as necessary. If deleted it will be regenerated.
5 //
6 package org.andromda.timetracker.service;
7
8 import java.util.Collection;
9 import org.andromda.timetracker.domain.User;
10 import org.andromda.timetracker.domain.UserDao;
11 import org.andromda.timetracker.domain.UserDaoException;
12 import org.andromda.timetracker.vo.UserDetailsVO;
13 import org.andromda.timetracker.vo.UserVO;
14
15 /**
16 * @see UserServiceBase
17 *
18 * Remember to manually configure the local business interface this bean implements if originally you only
19 * defined the remote business interface. However, this change is automatically reflected in the ejb-jar.xml.
20 *
21 * Do not specify the javax.ejb.Stateless annotation
22 * Instead, the session bean is defined in the ejb-jar.xml descriptor.
23 */
24 // Uncomment to enable webservices for UserServiceBean
25 // @javax.jws.WebService(endpointInterface = "org.andromda.timetracker.service.UserServiceWSInterface", serviceName = "UserService")
26 public class UserServiceBean
27 extends UserServiceBase
28 implements UserServiceRemote
29 {
30 // --------------- Constructors ---------------
31
32 /**
33 * Default constructor extending base class default constructor
34 */
35 public UserServiceBean()
36 {
37 super();
38 }
39
40 // -------- Business Methods Impl --------------
41
42 /**
43 * @see UserServiceBase#getAllUsers()
44 */
45 @Override
46 protected UserVO[] handleGetAllUsers()
47 throws Exception
48 {
49 Collection userVOs = this.getUserDao().loadAll(UserDao.TRANSFORM_USERVO);
50 return (UserVO[])userVOs.toArray(new UserVO[0]);
51 }
52
53 /**
54 * @see UserServiceBase#registerUser(UserDetailsVO)
55 */
56 @Override
57 protected UserDetailsVO handleRegisterUser(UserDetailsVO userDetailVO)
58 throws Exception
59 {
60 User user = this.getUserDao().userDetailsVOToEntity(userDetailVO);
61 user = this.getUserDao().create(user);
62 return this.getUserDao().toUserDetailsVO(user);
63 }
64
65 /**
66 * @see UserServiceBase#getAllUsers()
67 */
68 @Override
69 protected UserVO handleGetUser(String username) throws Exception
70 {
71 try
72 {
73 User user = this.getUserDao().findByUsername(username);
74 return getUserDao().toUserVO(user);
75 }
76 catch (UserDaoException ex)
77 {
78 throw new UserDoesNotExistException("User does not exist " + username);
79 }
80 }
81
82 /**
83 * @see UserServiceBase#removeUser(UserVO)
84 */
85 @Override
86 protected void handleRemoveUser(UserVO userVO)
87 throws Exception
88 {
89 getUserDao().remove(userVO.getId());
90 }
91
92
93 // -------- Lifecycle Callback Implementation --------------
94
95 }