1
14
15 package com.liferay.portlet;
16
17 import com.liferay.portal.kernel.log.Log;
18 import com.liferay.portal.kernel.log.LogFactoryUtil;
19 import com.liferay.portal.kernel.util.Randomizer;
20
21 import java.util.Map;
22
23
35 public class CustomUserAttributes implements Cloneable {
36
37 public String getValue(String name, Map<String, String> userInfo) {
38 if (name == null) {
39 return null;
40 }
41
42 if (_log.isDebugEnabled()) {
43 String companyId = userInfo.get(UserAttributes.LIFERAY_COMPANY_ID);
44 String userId = userInfo.get(UserAttributes.LIFERAY_USER_ID);
45
46 _log.debug("Company id " + companyId);
47 _log.debug("User id " + userId);
48 }
49
50 if (name.equals("user.name.random")) {
51 String[] names = new String[] {"Aaa", "Bbb", "Ccc"};
52
53 return names[Randomizer.getInstance().nextInt(3)];
54 }
55 else {
56 return null;
57 }
58 }
59
60 public Object clone() {
61 return new CustomUserAttributes();
62 }
63
64 private static Log _log = LogFactoryUtil.getLog(CustomUserAttributes.class);
65
66 }