|
|
|
@ -21,21 +21,25 @@ import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
import com.liferay.portal.kernel.cache.CacheRegistryUtil;
|
|
|
|
|
import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
|
|
|
|
|
import com.liferay.portal.kernel.exception.PortalException;
|
|
|
|
|
import com.liferay.portal.kernel.exception.SystemException;
|
|
|
|
|
import com.liferay.portal.model.Organization;
|
|
|
|
|
import com.liferay.portal.model.User;
|
|
|
|
|
import com.liferay.portal.service.OrganizationLocalServiceUtil;
|
|
|
|
|
import com.liferay.portal.service.UserLocalServiceUtil;
|
|
|
|
|
import com.liferay.portal.service.UserServiceUtil;
|
|
|
|
|
|
|
|
|
|
public class LDAPSync implements Runnable {
|
|
|
|
|
private static final Logger _log = LoggerFactory.getLogger(LDAPSync.class);
|
|
|
|
|
//TODO_ Move it to Runtime Resource
|
|
|
|
|
//TODO Move it to Runtime Resource
|
|
|
|
|
private static final String ldapUrl = "ldap://ldap-liferay.d4science.org";
|
|
|
|
|
private static final String filter = "(objectClass=inetOrgPerson)";
|
|
|
|
|
|
|
|
|
|
private static final String ldapPrincipal = "";
|
|
|
|
|
private static final String ldapPwd = "";
|
|
|
|
|
private static final String ldapPrincipal = "cn=admin,dc=d4science,dc=org";
|
|
|
|
|
private static final String ldapPwd = "poiwefhaewfkhj";
|
|
|
|
|
// private static final String ldapPrincipal = "";
|
|
|
|
|
// private static final String ldapPwd = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public LDAPSync() {
|
|
|
|
@ -49,7 +53,7 @@ public class LDAPSync implements Runnable {
|
|
|
|
|
List<User> users = null;
|
|
|
|
|
try {
|
|
|
|
|
users = getAllLiferayUsers();
|
|
|
|
|
_log.debug("Read " + users.size() + " from LR DB");
|
|
|
|
|
_log.debug("\n\n\n ******** Read " + users.size() + " from LR DB\n\n");
|
|
|
|
|
} catch (Exception e1) {
|
|
|
|
|
e1.printStackTrace();
|
|
|
|
|
}
|
|
|
|
@ -147,11 +151,12 @@ public class LDAPSync implements Runnable {
|
|
|
|
|
|
|
|
|
|
private List<User> getAllLiferayUsers() {
|
|
|
|
|
String infraName = PortalContext.getConfiguration().getInfrastructureName();
|
|
|
|
|
_log.info("Reading users belonging to: /" + infraName);
|
|
|
|
|
_log.info("TRY Reading non chached users belonging to: /" + infraName);
|
|
|
|
|
|
|
|
|
|
List<User> toReturn = new ArrayList<User>();
|
|
|
|
|
Organization rootInfra;
|
|
|
|
|
try {
|
|
|
|
|
CacheRegistryUtil.clear();
|
|
|
|
|
rootInfra = OrganizationLocalServiceUtil.getOrganization(OrganizationsUtil.getCompany().getCompanyId(), infraName);
|
|
|
|
|
toReturn = UserLocalServiceUtil.getOrganizationUsers(rootInfra.getOrganizationId());
|
|
|
|
|
} catch (PortalException | SystemException e) {
|
|
|
|
|