better exceptions management

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/social-mail-servlet@117444 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2015-07-23 09:42:59 +00:00
parent ff629c7c2f
commit 43206e6229
2 changed files with 19 additions and 8 deletions

View File

@ -1,5 +1,6 @@
package org.gcube.portal.ldapexport;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
@ -73,7 +74,10 @@ public class LDAPSync implements Runnable {
_log.error("Something went Wrong during LDAP Sync");
e.printStackTrace();
}
if (! users.isEmpty())
_log.info("LDAP Sync Completed OK!");
else
_log.warn("LDAP Sync cycle skipped this time");
}
@ -89,7 +93,7 @@ public class LDAPSync implements Runnable {
try {
answer = ctx.search(getSubContext(username), filter, ctls);
} catch (NamingException e) {
_log.info("user: " + username + " not found checkIfLDAPUserExists returning false");
_log.info("user: " + username + " not found in LDAP, trying to export it");
return false;
}
return answer.hasMoreElements();
@ -139,11 +143,18 @@ public class LDAPSync implements Runnable {
}
}
private List<User> getAllLiferayUsers() throws SystemException, PortalException {
private List<User> getAllLiferayUsers() {
String infraName = PortalContext.getConfiguration().getInfrastructureName();
_log.debug("Reading users belonging to: /" + infraName);
Organization rootInfra = OrganizationLocalServiceUtil.getOrganization(OrganizationsUtil.getCompany().getCompanyId(), infraName);
return UserLocalServiceUtil.getOrganizationUsers(rootInfra.getOrganizationId());
List<User> toReturn = new ArrayList<User>();
Organization rootInfra;
try {
rootInfra = OrganizationLocalServiceUtil.getOrganization(OrganizationsUtil.getCompany().getCompanyId(), infraName);
toReturn = UserLocalServiceUtil.getOrganizationUsers(rootInfra.getOrganizationId());
} catch (PortalException | SystemException e) {
_log.error("Error during LDAP Sync, could not retrieve users from LR DB: " + e.getMessage());
}
return toReturn;
}
}

View File

@ -155,7 +155,7 @@ public class PeriodicTask implements Runnable {
String feedId = extractFeedId(message);
String commentText = extractText(portalName, feedId, message);
_log.info("Extracted id: " + feedId + " text=" + commentText);
String escapedCommentText = Utils.escapeHtmlAndTransformUrl(commentText);
Address[] froms = message.getFrom();