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