notesConnectorSession.getConnector().getGoogleConnectorName(),
id.toString());
// Get the GSA client.
NotesConnector connector = notesConnectorSession.getConnector();
GsaClient client = null;
try {
client = getGsaClient(connector);
} catch (AuthenticationException e) {
return false;
}
// Delete any existing ACL rules for this database.
if (!deletePolicyAcl(client, urlPattern)) {
return false;
}
boolean hasUsers = (permitUsers != null && permitUsers.size() > 0);
boolean hasGroups = (permitGroups != null && permitGroups.size() > 0);
// If there are no allowed users or groups, we're done.
if (!(hasUsers || hasGroups)) {
if (LOGGER.isLoggable(Level.FINER)) {
LOGGER.logp(Level.FINER, CLASS_NAME, METHOD,
"No new users/groups for " + urlPattern);
}
return true;
}
// Build and add new ACL.
StringBuilder acl = new StringBuilder();
// Add groups. getGsaGroups handles URL-encoding.
if (hasGroups) {
permitGroups = GsaUtil.getGsaGroups(permitGroups,
notesConnectorSession.getGsaGroupPrefix());
for (String group : permitGroups) {
acl.append("group:").append(group).append(" ");
}
}
// Resolve the Notes names to the PVIs and add users.
if (hasUsers) {
permitUsers = notesConnectorSession.getUserGroupManager()
.mapNotesNamesToGsaNames(notesSession, permitUsers, false);
for (String user : permitUsers) {
acl.append("user:").append(user).append(" ");
}
}
// If the acl is empty, pvi lookup must have failed for all users.
if (acl.length() == 0) {
LOGGER.logp(Level.WARNING, CLASS_NAME, METHOD,
"No ACL to send for url pattern: " + urlPattern);
return false;
}
// Send ACL to GSA.
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.logp(Level.FINE, CLASS_NAME, METHOD,
"Sending ACL for url pattern: " + urlPattern + " with values "
+ acl.toString());
}
try {
GsaEntry entry = new GsaEntry();
entry.addGsaContent(Terms.PROPERTY_URL_PATTERN, urlPattern);
entry.addGsaContent(Terms.PROPERTY_POLICY_ACL, acl.toString());
client.insertEntry(Terms.FEED_POLICY_ACLS, entry);
LOGGER.logp(Level.FINER, CLASS_NAME, METHOD, "Sent ACL");
} catch (AuthenticationException e) {
LOGGER.logp(Level.WARNING, CLASS_NAME, METHOD, e.toString());
return false;
} catch (ServiceException e) {