|
|
@ -22,16 +22,17 @@ import org.gcube.vomanagement.usermanagement.GroupManager;
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
|
|
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
|
|
|
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
|
|
|
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.liferay.portal.kernel.cache.CacheRegistryUtil;
|
|
|
|
import com.liferay.portal.kernel.cache.CacheRegistryUtil;
|
|
|
|
import com.liferay.portal.kernel.exception.SystemException;
|
|
|
|
import com.liferay.portal.kernel.exception.SystemException;
|
|
|
|
|
|
|
|
import com.liferay.portal.kernel.log.Log;
|
|
|
|
|
|
|
|
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
|
|
|
import com.liferay.portal.model.User;
|
|
|
|
import com.liferay.portal.model.User;
|
|
|
|
import com.liferay.portal.service.UserLocalServiceUtil;
|
|
|
|
import com.liferay.portal.service.UserLocalServiceUtil;
|
|
|
|
|
|
|
|
|
|
|
|
public class LDAPSync implements Runnable {
|
|
|
|
public class LDAPSync implements Runnable {
|
|
|
|
private static final Logger _log = LoggerFactory.getLogger(LDAPSync.class);
|
|
|
|
|
|
|
|
|
|
|
|
private static Log _log = LogFactoryUtil.getLog(LDAPSync.class);
|
|
|
|
|
|
|
|
|
|
|
|
private static final String LDAP_ORG_FILTER = "(objectClass=organizationalUnit)";
|
|
|
|
private static final String LDAP_ORG_FILTER = "(objectClass=organizationalUnit)";
|
|
|
|
private static final String LDAP_GROUP_FILTER = "(objectClass=posixGroup)";
|
|
|
|
private static final String LDAP_GROUP_FILTER = "(objectClass=posixGroup)";
|
|
|
@ -82,7 +83,7 @@ public class LDAPSync implements Runnable {
|
|
|
|
List<User> users = null;
|
|
|
|
List<User> users = null;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
users = getAllLiferayUsers();
|
|
|
|
users = getAllLiferayUsers();
|
|
|
|
_log.debug("\n***Read " + users.size() + " from LR DB\n");
|
|
|
|
_log.info("***Read " + users.size() + " from LR DB\n");
|
|
|
|
} catch (Exception e1) {
|
|
|
|
} catch (Exception e1) {
|
|
|
|
e1.printStackTrace();
|
|
|
|
e1.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -185,7 +186,13 @@ public class LDAPSync implements Runnable {
|
|
|
|
* @throws SystemException
|
|
|
|
* @throws SystemException
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void updateUsersInGroup(DirContext ctx, String vreSubCtx, GCubeGroup vre) throws NamingException, SystemException {
|
|
|
|
private void updateUsersInGroup(DirContext ctx, String vreSubCtx, GCubeGroup vre) throws NamingException, SystemException {
|
|
|
|
List<User> users = UserLocalServiceUtil.getGroupUsers(vre.getGroupId());
|
|
|
|
_log.debug("updateUsersInGroup: " + vre.getGroupName() );
|
|
|
|
|
|
|
|
List<User> users = new ArrayList<>();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
users = UserLocalServiceUtil.getGroupUsers(vre.getGroupId());
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
_log.error("Could not retrieve members of vre: " + vre.getGroupName() + " having groupid: "+vre.getGroupId(), e);
|
|
|
|
|
|
|
|
}
|
|
|
|
for (User userObj : users) {
|
|
|
|
for (User userObj : users) {
|
|
|
|
String user = userObj.getScreenName();
|
|
|
|
String user = userObj.getScreenName();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|