001
014
015 package com.liferay.portlet;
016
017 import com.liferay.portal.kernel.log.Log;
018 import com.liferay.portal.kernel.log.LogFactoryUtil;
019 import com.liferay.portal.kernel.util.Randomizer;
020
021 import java.util.Map;
022
023
033 public class DefaultCustomUserAttributes implements CustomUserAttributes {
034
035 public String getValue(String name, Map<String, String> userInfo) {
036 if (name == null) {
037 return null;
038 }
039
040 if (_log.isDebugEnabled()) {
041 String companyId = userInfo.get(UserAttributes.LIFERAY_COMPANY_ID);
042 String userId = userInfo.get(UserAttributes.LIFERAY_USER_ID);
043
044 _log.debug("Company id " + companyId);
045 _log.debug("User id " + userId);
046 }
047
048 if (name.equals("user.name.random")) {
049 String[] names = new String[] {"Aaa", "Bbb", "Ccc"};
050
051 return names[Randomizer.getInstance().nextInt(3)];
052 }
053 else {
054 return null;
055 }
056 }
057
058 public Object clone() {
059 return new DefaultCustomUserAttributes();
060 }
061
062 private static Log _log = LogFactoryUtil.getLog(
063 DefaultCustomUserAttributes.class);
064
065 }