// Path: src/main/java/com/liferay/support/tools/common/ParamContext.java
// public abstract class ParamContext {
// 
// 	protected ThemeDisplay themeDisplay;
// 	protected ServiceContext serviceContext;
// 
// 	public ThemeDisplay getThemeDisplay() {
// 		return themeDisplay;
// 	}
// 
// 	public void setThemeDisplay(ThemeDisplay themeDisplay) {
// 		this.themeDisplay = themeDisplay;
// 	}
// 
// 	public ServiceContext getServiceContext() {
// 		return serviceContext;
// 	}
// 
// 	public void setServiceContext(ServiceContext serviceContext) {
// 		this.serviceContext = serviceContext;
// 	}
// 
// }
// 
// Path: src/main/java/com/liferay/support/tools/utils/CommonUtil.java
// @Component(immediate = true, service = CommonUtil.class)
// public class CommonUtil {
// 
// 	/**
// 	 * Page Command Pairs
// 	 * 
// 	 * @return jsp file name corresponding to the command.
// 	 */
// 	public Map<String, String> getPageFromMode() {
// 		return LDFPortletKeys.renderJSPs;
// 	}
// 
// 	/**
// 	 * Convert 
// 	 * @param source
// 	 * @return
// 	 */
// 	static public String[] convertToStringArray(String source) {
// 		if(source.length() == 0) {
// 			return new String[0];
// 		}
// 		
// 		return source.split(",",0);
// 	}
// 	
// 	/**
// 	 * Convert string array to long array
// 	 * 
// 	 * @param source String array of ids
// 	 * @return long array of ids
// 	 */
// 	static public long[] convertStringToLongArray(String[] source) {
// 		if (Validator.isNull(source) || source.length <= 0) {
// 			return null;
// 		}
// 
// 		return Arrays.stream(source).distinct().mapToLong(Long::parseLong).toArray();
// 	}
// 
// 	/**
// 	 * Filter roles
// 	 * 
// 	 * Depending on role types, the processes to apply roles are different. This
// 	 * method filter either Organization / Site roles or Regular roles.
// 	 * 
// 	 * @param roleIds role ids. This can be mix of reguler / organization / site roles.
// 	 * @return Filtered roleids in each array.
// 	 * @throws PortalException
// 	 */
// 	public Map<Integer, List<Role>> filterRoles(long[] roleIds) throws PortalException {
// 
// 		if (Validator.isNull(roleIds) || roleIds.length == 0) {
// 			return new ConcurrentHashMap<Integer, List<Role>>();
// 		}
// 
// 		List<Role> roles = _roleLocalService.getRoles(roleIds);
// 		return roles.stream().collect(Collectors.groupingBy(Role::getType));
// 	}
// 
// 
// 	/**
// 	 * Create Faker
// 	 * 
// 	 * @param locale Language to create Faker object based on.
// 	 * @return Faker object.
// 	 */
// 	public Faker createFaker(String locale) {
// 		// For generating dummy user name
// 		Faker faker = new Faker(new Locale(Locale.ENGLISH.toLanguageTag()));
// 
// 		try {
// 			Faker fakerTmp = new Faker(new Locale(locale));
// 			faker = fakerTmp;
// 		} catch (Exception e) {
// 			e.printStackTrace();
// 		}
// 
// 		return faker;
// 	}
// 	
// 	@Reference
// 	private RoleLocalService _roleLocalService;
// 	
// 	private static final Log _log = LogFactoryUtil.getLog(CommonUtil.class);			
// }


import com.liferay.announcements.kernel.model.AnnouncementsDelivery;
import com.liferay.announcements.kernel.model.AnnouncementsEntryConstants;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.model.Group;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextFactory;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portlet.announcements.model.impl.AnnouncementsDeliveryImpl;
import com.liferay.support.tools.common.ParamContext;
import com.liferay.support.tools.utils.CommonUtil;
import java.util.ArrayList;
import java.util.List;
import javax.portlet.ActionRequest;

package com.liferay.support.tools.user;




public class UserContext extends ParamContext {

	public UserContext(ActionRequest actionRequest)
		throws PortalException {

		// Fetch data
		numberOfusers = ParamUtil.getLong(actionRequest, "numberOfusers", 0);
		baseScreenName =
			ParamUtil.getString(actionRequest, "baseScreenName", "");
		baseDomain =
			ParamUtil.getString(actionRequest, "baseDomain", "liferay.com");
		male = ParamUtil.getBoolean(actionRequest, "male", true);
		fakerEnable = ParamUtil.getBoolean(actionRequest, "fakerEnable", false);
		password = ParamUtil.getString(actionRequest, "password", "test");
		locale = ParamUtil.getString(actionRequest, "locale", "en");
		autoUserPreLogin =
			ParamUtil.getBoolean(actionRequest, "autoUserPreLogin", false);

		// Organization
		String[] organizations =
			ParamUtil.getStringValues(actionRequest, "organizations", null);
// Path: src/main/java/com/liferay/support/tools/common/ParamContext.java
// public abstract class ParamContext {
// 
// 	protected ThemeDisplay themeDisplay;
// 	protected ServiceContext serviceContext;
// 
// 	public ThemeDisplay getThemeDisplay() {
// 		return themeDisplay;
// 	}
// 
// 	public void setThemeDisplay(ThemeDisplay themeDisplay) {
// 		this.themeDisplay = themeDisplay;
// 	}
// 
// 	public ServiceContext getServiceContext() {
// 		return serviceContext;
// 	}
// 
// 	public void setServiceContext(ServiceContext serviceContext) {
// 		this.serviceContext = serviceContext;
// 	}
// 
// }
// 
// Path: src/main/java/com/liferay/support/tools/utils/CommonUtil.java
// @Component(immediate = true, service = CommonUtil.class)
// public class CommonUtil {
// 
// 	/**
// 	 * Page Command Pairs
// 	 * 
// 	 * @return jsp file name corresponding to the command.
// 	 */
// 	public Map<String, String> getPageFromMode() {
// 		return LDFPortletKeys.renderJSPs;
// 	}
// 
// 	/**
// 	 * Convert 
// 	 * @param source
// 	 * @return
// 	 */
// 	static public String[] convertToStringArray(String source) {
// 		if(source.length() == 0) {
// 			return new String[0];
// 		}
// 		
// 		return source.split(",",0);
// 	}
// 	
// 	/**
// 	 * Convert string array to long array
// 	 * 
// 	 * @param source String array of ids
// 	 * @return long array of ids
// 	 */
// 	static public long[] convertStringToLongArray(String[] source) {
// 		if (Validator.isNull(source) || source.length <= 0) {
// 			return null;
// 		}
// 
// 		return Arrays.stream(source).distinct().mapToLong(Long::parseLong).toArray();
// 	}
// 
// 	/**
// 	 * Filter roles
// 	 * 
// 	 * Depending on role types, the processes to apply roles are different. This
// 	 * method filter either Organization / Site roles or Regular roles.
// 	 * 
// 	 * @param roleIds role ids. This can be mix of reguler / organization / site roles.
// 	 * @return Filtered roleids in each array.
// 	 * @throws PortalException
// 	 */
// 	public Map<Integer, List<Role>> filterRoles(long[] roleIds) throws PortalException {
// 
// 		if (Validator.isNull(roleIds) || roleIds.length == 0) {
// 			return new ConcurrentHashMap<Integer, List<Role>>();
// 		}
// 
// 		List<Role> roles = _roleLocalService.getRoles(roleIds);
// 		return roles.stream().collect(Collectors.groupingBy(Role::getType));
// 	}
// 
// 
// 	/**
// 	 * Create Faker
// 	 * 
// 	 * @param locale Language to create Faker object based on.
// 	 * @return Faker object.
// 	 */
// 	public Faker createFaker(String locale) {
// 		// For generating dummy user name
// 		Faker faker = new Faker(new Locale(Locale.ENGLISH.toLanguageTag()));
// 
// 		try {
// 			Faker fakerTmp = new Faker(new Locale(locale));
// 			faker = fakerTmp;
// 		} catch (Exception e) {
// 			e.printStackTrace();
// 		}
// 
// 		return faker;
// 	}
// 	
// 	@Reference
// 	private RoleLocalService _roleLocalService;
// 	
// 	private static final Log _log = LogFactoryUtil.getLog(CommonUtil.class);			
// }


// Path: src/main/java/com/liferay/support/tools/user/UserContext.java
import com.liferay.announcements.kernel.model.AnnouncementsDelivery;
import com.liferay.announcements.kernel.model.AnnouncementsEntryConstants;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.model.Group;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextFactory;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portlet.announcements.model.impl.AnnouncementsDeliveryImpl;
import com.liferay.support.tools.common.ParamContext;
import com.liferay.support.tools.utils.CommonUtil;
import java.util.ArrayList;
import java.util.List;
import javax.portlet.ActionRequest;


package com.liferay.support.tools.user;




public class UserContext extends ParamContext {

	public UserContext(ActionRequest actionRequest)
		throws PortalException {

		// Fetch data
		numberOfusers = ParamUtil.getLong(actionRequest, "numberOfusers", 0);
		baseScreenName =
			ParamUtil.getString(actionRequest, "baseScreenName", "");
		baseDomain =
			ParamUtil.getString(actionRequest, "baseDomain", "liferay.com");
		male = ParamUtil.getBoolean(actionRequest, "male", true);
		fakerEnable = ParamUtil.getBoolean(actionRequest, "fakerEnable", false);
		password = ParamUtil.getString(actionRequest, "password", "test");
		locale = ParamUtil.getString(actionRequest, "locale", "en");
		autoUserPreLogin =
			ParamUtil.getBoolean(actionRequest, "autoUserPreLogin", false);

		// Organization
		String[] organizations =
			ParamUtil.getStringValues(actionRequest, "organizations", null);
		organizationIds = CommonUtil.convertStringToLongArray(organizations);