01: /*
02: * $Id: GetUserImpl.java,v 1.3 2007/09/18 11:27:16 agoubard Exp $
03: */
04: package com.mycompany.rest.api;
05:
06: /**
07: * Implementation of the <code>GetUser</code> function.
08: *
09: * <p>Description: Get the information related to a new user.
10: *
11: * @version $Revision: 1.3 $ $Date: 2007/09/18 11:27:16 $
12: * @author <a href="mailto:anthony.goubard@japplis.com">Anthony Goubard</a>
13: */
14: public final class GetUserImpl extends GetUser {
15:
16: /**
17: * Constructs a new <code>GetUserImpl</code> instance.
18: *
19: * @param api
20: * the API to which this function belongs, guaranteed to be not
21: * <code>null</code>.
22: */
23: public GetUserImpl(APIImpl api) {
24: super (api);
25: }
26:
27: /**
28: * Calls this function. If the function fails, it may throw any kind of
29: * exception. All exceptions will be handled by the caller.
30: *
31: * @param request
32: * the request, never <code>null</code>.
33: *
34: * @return
35: * the result of the function call, should never be <code>null</code>.
36: *
37: * @throws Throwable
38: * if anything went wrong.
39: */
40: public Result call(Request request) throws Throwable {
41: SuccessfulResult result = new SuccessfulResult();
42: String[] name = _users.getUser(request.getAccountNumber());
43: if (name == null) {
44: return new AccountNotFoundResult();
45: }
46: result.setFirstName(name[0]);
47: result.setLastName(name[1]);
48: return result;
49: }
50: }
|