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 @Override
036 public Object clone() {
037 return new DefaultCustomUserAttributes();
038 }
039
040 public String getValue(String name, Map<String, String> userInfo) {
041 if (name == null) {
042 return null;
043 }
044
045 if (_log.isDebugEnabled()) {
046 String companyId = userInfo.get(UserAttributes.LIFERAY_COMPANY_ID);
047 String userId = userInfo.get(UserAttributes.LIFERAY_USER_ID);
048
049 _log.debug("Company id " + companyId);
050 _log.debug("User id " + userId);
051 }
052
053 if (name.equals("user.name.random")) {
054 String[] names = new String[] {"Aaa", "Bbb", "Ccc"};
055
056 return names[Randomizer.getInstance().nextInt(3)];
057 }
058 else {
059 return null;
060 }
061 }
062
063 private static Log _log = LogFactoryUtil.getLog(
064 DefaultCustomUserAttributes.class);
065
066 }