blob: fcd1593c625cac52e6049dd0f246a8bfb551085d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
package com.p4square.grow.ccb;
import com.p4square.ccbapi.model.IndividualProfile;
import org.restlet.security.User;
/**
* CCBUser is an adapter between a CCB IndividualProfile and a Restlet User.
*
* Note: CCBUser prefixes the user's identifier with "CCB-". This is done to
* ensure the identifier does not collide with identifiers from other
* systems.
*/
public class CCBUser extends User {
private final IndividualProfile mProfile;
/**
* Wrap an IndividualProfile inside a User object.
*
* @param profile The CCB IndividualProfile for the user.
*/
public CCBUser(final IndividualProfile profile) {
mProfile = profile;
// The identifier is set to the syncId if present, otherwise the CCB Id is used with the prefix CCB-.
final int syncId = mProfile.getSyncId();
if (syncId > 0) {
setIdentifier(String.valueOf(syncId));
} else {
setIdentifier("CCB-" + mProfile.getId());
}
setFirstName(mProfile.getFirstName());
setLastName(mProfile.getLastName());
setEmail(mProfile.getEmail());
}
/**
* @return The IndividualProfile of the user.
*/
public IndividualProfile getProfile() {
return mProfile;
}
}
|