package org.gcube.portlets.gcubeckan.gcubeckandatacatalog.server.thread; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue; import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg; import com.liferay.portal.kernel.log.Log; import com.liferay.portal.kernel.log.LogFactoryUtil; /** * Add the user to the other organizations present in the local instance of ckan. * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) */ public class AddUserToOrganizationThread extends Thread { private static final Log logger = LogFactoryUtil.getLog(AddUserToOrganizationThread.class); private DataCatalogue instance; private String username; private Map orgAndCapacity; /** * @param instance * @param username * @param orgAndCapacity */ public AddUserToOrganizationThread(DataCatalogue instance, String username, Map orgAndCapacity) { super(); this.instance = instance; this.username = username; this.orgAndCapacity = orgAndCapacity; } @Override public void run() { logger.debug("Thread for role association started. Organizations and roles are in the map: " + orgAndCapacity); Set> entrySet = orgAndCapacity.entrySet(); for (Entry entry : entrySet) { if(instance.getOrganizationByName(entry.getKey()) != null) instance.checkRoleIntoOrganization(username, entry.getKey(), RolesCkanGroupOrOrg.convertFromCapacity(entry.getValue())); } logger.debug("Thread for role association ended"); } }