publishSyncError(eControlArea, errors);
return;
}
// Get two configured BasicPerson objects from AppConfig.
BasicPerson currentBasicPerson = null;
BasicPerson newBasicPerson = null;
try {
currentBasicPerson = (BasicPerson)getAppConfig().getObject("BasicPerson");
newBasicPerson = (BasicPerson)getAppConfig().getObject("BasicPerson");
}
catch (EnterpriseConfigurationObjectException ecoe) {
// An error occurred getting an object from AppConfig. Log it and
// publish a sync error message.
Error error = new Error();
error.setType("application");
error.setErrorNumber("OpenEAI-3001");
error.setErrorDescription("An error occurred getting an object from " +
"AppConfig. the exception is: " + ecoe.getMessage());
errors = new ArrayList();
errors.add(error);
publishSyncError(eControlArea, errors, ecoe);
return;
}
// Handle a BasicPerson.Update-Sync
if (messageAction.equalsIgnoreCase("Update")) {
// Get the baseline state of the BasicPerson and build a BasicPerson
// object.
Element eBaselinePerson = inDoc.getRootElement().getChild("DataArea")
.getChild("BaselineData").getChild("BasicPerson");
try {
currentBasicPerson.buildObjectFromInput(eBaselinePerson);
}
catch (EnterpriseLayoutException ele) {
// An error occurred building the BasicPerson object from the
// BasicPerson element contained in the BaselineData element of the
// message. Log it and publish a sync error message.
Error error = new Error();
error.setType("system");
error.setErrorNumber("DirectoryServiceGateway-1001");
error.setErrorDescription("An error occurred building the BasicPerson "
+ "object from the BasicPerson element contained in the " +
"BaselineData element of the message. The exception is: " +
ele.getMessage());
errors = new ArrayList();
errors.add(error);
publishSyncError(eControlArea, errors, ele);
return;
}
// Get the new state of the BasicPerson and build a BasicPerson
// object.
Element eNewPerson = inDoc.getRootElement().getChild("DataArea")
.getChild("NewData").getChild("BasicPerson");
try {
newBasicPerson.buildObjectFromInput(eNewPerson);
}
catch (EnterpriseLayoutException ele) {
// An error occurred building the BasicPerson object from thw
// BasicPerson element contained in the NewData element of
// the message. Log it and publish a sync error message.
Error error = new Error();
error.setType("system");
error.setErrorNumber("DirectoryServiceGateway-1002");
error.setErrorDescription("An error occurred building the " +
"BasicPerson object from the BasicPerson element contained in " +
"the NewData element of the message. The exception is: " +
ele.getMessage());
errors = new ArrayList();
errors.add(error);
publishSyncError(eControlArea, errors, ele);
return;
}
// Determine whether the user exists in the portal database.
String instId = currentBasicPerson.getInstitutionalId();
PortalPerson portalPerson = null;
try { portalPerson = retrievePortalPerson(instId); }
catch (CommandException ce) {
// An error occurred querying the portal database to determine whether
// the user exists. Log it, publish a error message, and return.
String errMsg = "An error occurred querying the portal database to " +
"determine whether the user exists.";
logger.debug("[PasswordSyncCommand.execute] " + errMsg);
Error error = new Error();
error.setType("system");
error.setErrorNumber("UportalGateway-2001");
error.setErrorDescription(errMsg);
errors = new ArrayList();
errors.add(error);
publishSyncError(eControlArea, errors, ce);
return;
}
// If there are no matching entries and the publishErrorsForMissingEntries
// property is true, publish a error message indicating that the user does
// not exist. Otherwise, log the fact that the user does not exist and
// return.
if (portalPerson == null) {
if (getPublishErrorsForMissingEntries() == true) {
// --- Publish the sync error.
Error error = new Error();
error.setType("application");
error.setErrorNumber("UportalGateway-1005");
error.setErrorDescription("No user with user ID " + instId +
" exists in the portal. Cannot reset the password for this user.");
logger.fatal("[BasicPersonSyncCommand.execute] " +
error.getErrorDescription());
errors = new ArrayList();
errors.add(error);
publishSyncError(eControlArea, errors);
return;
}
else {
// --- Just log it.
logger.info("[BasicPersonSyncCommand.execute] No user with user ID " +
instId + " exists in the portal. Cannot reset the password for " +
"this user.");
return;
}
}
// Otherwise, the user already exists in the portal, so determine if their
// name and e-mail have changed and, if so, update them.
else {
// Get the new first name, last name, and e-mail address.
String newFirstName = newBasicPerson.getName().getFirstName();
String newLastName = newBasicPerson.getName().getLastName();
String email;
List emailAddresses = newBasicPerson.getEmail();
ListIterator li = emailAddresses.listIterator();
switch (emailAddresses.size()) {
// If there are no e-mail addresses in the list, set the value of the
// e-mail address to null.