The export was stuck due to #19348, now the getGroupUsers does not stall
This commit is contained in:
parent
c937ad8931
commit
cbc1a5a360
|
@ -0,0 +1,22 @@
|
||||||
|
Changelog for "ldap-export-servlet"
|
||||||
|
|
||||||
|
|
||||||
|
## [v1.2.1] [r4.23.0] - 2020-05-29
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- This release fixes a potential bug in the export of the users to LDAP. See Incident #19348
|
||||||
|
|
||||||
|
## [v1.2.0] [r unknown] - 2016-09-12
|
||||||
|
### New Features
|
||||||
|
- Feature #4999: LDAP Export script to export SSH public key
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- Bug fix for #4916: LDAP Export fails if user surname is empty
|
||||||
|
|
||||||
|
## [v1.2.0] [r unknown] - 2016-07-04
|
||||||
|
### New Features
|
||||||
|
- Updated to use Liferay 6.2 API
|
||||||
|
|
||||||
|
## [v1.0.0] [r unknown] - 2015-12-11
|
||||||
|
|
||||||
|
- First Release
|
2
pom.xml
2
pom.xml
|
@ -11,7 +11,7 @@
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>org.gcube.portal</groupId>
|
||||||
<artifactId>ldap-export-servlet</artifactId>
|
<artifactId>ldap-export-servlet</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>war</packaging>
|
||||||
<version>1.2.0-SNAPSHOT</version>
|
<version>1.2.1-SNAPSHOT</version>
|
||||||
<name>ldap-export-servlet Maven Webapp</name>
|
<name>ldap-export-servlet Maven Webapp</name>
|
||||||
<description>This component read periodically exports users and their groups in LDAP</description>
|
<description>This component read periodically exports users and their groups in LDAP</description>
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Reference in New Issue