use of org.jaffa.datatypes.ValidationException in project jaffa-framework by jaffa-projects.
the class UserMaintenanceTx method updateDomain.
// .//GEN-END:_loadUpdate_3_be
// .//GEN-BEGIN:_updateDomain_1_be
/**
* Update the domain object and add it to the UOW.
*/
private void updateDomain(UOW uow, UserMaintenanceUpdateInDto input, User domain, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
ApplicationExceptions appExps = null;
// .//GEN-BEGIN:_updateDomain_2_be
try {
domain.updateFirstName(input.getFirstName());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateLastName(input.getLastName());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateStatus(input.getStatus());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateEMailAddress(input.getEMailAddress());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateSecurityQuestion(input.getSecurityQuestion());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateSecurityAnswer(input.getSecurityAnswer());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
if (!fromPrevalidate)
domain.updateLastUpdatedOn(new DateTime());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
if (!fromPrevalidate && input.getHeaderDto() != null && input.getHeaderDto().getUserId() != null)
domain.updateLastUpdatedBy(input.getHeaderDto().getUserId());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
// Add custom code //GEN-FIRST:_updateDomain_2
try {
if (input.getPassword1() != null)
domain.updatePassword(input.getPassword1());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
String[] userRole = null;
if (appExps == null || appExps.size() == 0) {
// Build an array of roles
userRole = new String[input.getUserRoleCount()];
UserRoleDto[] userRoleDtos = input.getUserRole();
for (int i = 0; i < userRoleDtos.length; i++) userRole[i] = userRoleDtos[i].getRoleName();
Arrays.sort(userRole);
performUserRoleValidations(userRole, domain);
}
if (!fromPrevalidate) {
// These keep track of whats added and removed
Collection rolesAdded = new ArrayList();
Collection rolesRemoved = new ArrayList();
Collection processed = new ArrayList();
if (appExps == null || appExps.size() == 0) {
// Roles can be updated only if the user has access to the maintenance function
if (hasMaintenanceAccess()) {
// Get the current roles
Criteria crit = new Criteria();
crit.setTable(UserRoleMeta.getName());
crit.addCriteria(UserRoleMeta.USER_NAME, input.getUserName());
Collection currRoles = uow.query(crit);
// if in database, add to the processed list
for (Iterator it = currRoles.iterator(); it.hasNext(); ) {
UserRole ur = (UserRole) it.next();
if (Arrays.binarySearch(userRole, ur.getRoleName()) >= 0) {
processed.add(ur.getRoleName());
if (log.isDebugEnabled())
log.debug("Keeping Role - " + ur.getRoleName());
} else {
rolesRemoved.add(ur.getRoleName());
uow.delete(ur);
if (log.isDebugEnabled())
log.debug("Deleting Role - " + ur.getRoleName());
}
}
// Now add the new ones
for (int i = 0; i < userRole.length; i++) {
String rolename = userRole[i];
if (!processed.contains(rolename)) {
try {
UserRole ur = new UserRole();
ur.updateRoleName(rolename);
ur.updateUserName(input.getUserName());
rolesAdded.add(ur.getRoleName());
uow.add(ur);
if (log.isDebugEnabled())
log.debug("Adding Role - " + ur.getRoleName());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
}
}
}
}
}
if (input.getNotifyUser().booleanValue()) {
try {
EmailerBean email = new EmailerBean();
String[] to = new String[] { domain.getEMailAddress() };
StringBuffer body = new StringBuffer();
if ((oldPassword != null && !oldPassword.equals(domain.getPassword())) || (oldStatus != null && !oldStatus.equals(domain.getStatus()))) {
body.append("Your UserName is " + domain.getUserName());
if (oldPassword != null && !oldPassword.equals(domain.getPassword()))
body.append(" and your password is " + domain.getPassword() + ".");
if (oldStatus != null && !oldStatus.equals(domain.getStatus()))
body.append("Your account is currently " + domain.getStatus() + ".");
email.sendMail(to, "Account Information", body.toString());
}
} catch (javax.mail.MessagingException e) {
e.printStackTrace();
}
}
/* try {
UserRequest userRequest = UserRequest.findByPK(uow , new Long(input.getRequestId()));
userRequest.setStatus("S");
uow.update(userRequest);
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
*/
if (appExps != null && appExps.size() > 0)
throw appExps;
// .//GEN-BEGIN:_updateDomain_3_be
if (appExps != null && appExps.size() > 0)
throw appExps;
}
use of org.jaffa.datatypes.ValidationException in project jaffa-framework by jaffa-projects.
the class UserMaintenanceTx method createDomain.
// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
* Create the domain object.
*/
private User createDomain(UOW uow, UserMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
User domain = new User();
ApplicationExceptions appExps = null;
// Add custom code //GEN-FIRST:_createDomain_1
try {
if (input.getPassword1() != null)
domain.updatePassword(input.getPassword1());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
// .//GEN-BEGIN:_createDomain_2_be
try {
domain.updateUserName(input.getUserName());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateFirstName(input.getFirstName());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateLastName(input.getLastName());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateStatus(input.getStatus());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateEMailAddress(input.getEMailAddress());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateSecurityQuestion(input.getSecurityQuestion());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateSecurityAnswer(input.getSecurityAnswer());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
if (!fromPrevalidate)
domain.updateCreatedOn(new DateTime());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
if (!fromPrevalidate && input.getHeaderDto() != null && input.getHeaderDto().getUserId() != null)
domain.updateCreatedBy(input.getHeaderDto().getUserId());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
// .//GEN-BEGIN:_createDomain_3_be
if (appExps != null && appExps.size() > 0)
throw appExps;
return domain;
}
use of org.jaffa.datatypes.ValidationException in project jaffa-framework by jaffa-projects.
the class UserMaintenanceTx method postCreate.
// .//GEN-END:_createDomain_3_be
// .//GEN-BEGIN:_postCreate_1_be
/**
* This method is invoked after the domain object has been created.
*/
private User postCreate(UOW uow, UserMaintenanceCreateInDto input, User domain, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
// .//GEN-END:_postCreate_1_be
// Add custom code //GEN-FIRST:_postCreate_1
ApplicationExceptions appExps = null;
String[] userRole = null;
// Build an array of roles
userRole = new String[input.getUserRoleCount()];
UserRoleDto[] userRoleDtos = input.getUserRole();
for (int i = 0; i < userRoleDtos.length; i++) userRole[i] = userRoleDtos[i].getRoleName();
Arrays.sort(userRole);
performUserRoleValidations(userRole, domain);
if (!fromPrevalidate) {
// add the the roles
for (int i = 0; i < userRole.length; i++) {
try {
UserRole ur = new UserRole();
ur.updateRoleName(userRole[i]);
ur.updateUserName(input.getUserName());
uow.add(ur);
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
}
}
if (input.getNotifyUser().booleanValue()) {
try {
EmailerBean email = new EmailerBean();
String[] to = new String[] { domain.getEMailAddress() };
String body = "Your UserName is " + domain.getUserName() + " and your password is " + domain.getPassword() + ". Your account is currently " + domain.getStatus() + ".";
email.sendMail(to, "Account Information", body);
} catch (javax.mail.MessagingException e) {
e.printStackTrace();
}
}
if (input.getRequestId() != null && input.getRequestId().length() > 0) {
try {
UserRequest userRequest = UserRequest.findByPK(uow, new Long(input.getRequestId()));
userRequest.setStatus("S");
uow.update(userRequest);
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
}
if (appExps != null && appExps.size() > 0)
throw appExps;
// .//GEN-BEGIN:_postCreate_2_be
return domain;
}
use of org.jaffa.datatypes.ValidationException in project jaffa-framework by jaffa-projects.
the class FormGroupMaintenanceTx method updateDomain.
// .//GEN-END:_loadUpdate_3_be
// .//GEN-BEGIN:_updateDomain_1_be
/**
* Update the domain object and add it to the UOW.
*/
private void updateDomain(UOW uow, FormGroupMaintenanceUpdateInDto input, FormGroup domain, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
ApplicationExceptions appExps = null;
// .//GEN-BEGIN:_updateDomain_2_be
try {
domain.updateDescription(input.getDescription());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateFormType(input.getFormType());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
// .//GEN-END:_updateDomain_2_be
// Add custom code//GEN-FIRST:_updateDomain_2
// creating the FormUsage entries.
createFormUsageEntry(uow, input, fromPrevalidate);
// .//GEN-BEGIN:_updateDomain_3_be
if (appExps != null && appExps.size() > 0)
throw appExps;
}
use of org.jaffa.datatypes.ValidationException in project jaffa-framework by jaffa-projects.
the class OutputCommandMaintenanceTx method createDomain.
// .//GEN-END:_duplicateCheck_4_be
// .//GEN-BEGIN:_createDomain_1_be
/**
* Create the domain object.
*/
private OutputCommand createDomain(UOW uow, OutputCommandMaintenanceCreateInDto input, boolean fromPrevalidate) throws FrameworkException, ApplicationExceptions {
OutputCommand domain = new OutputCommand();
ApplicationExceptions appExps = null;
// .//GEN-BEGIN:_createDomain_2_be
try {
domain.updateOutputCommandId(input.getOutputCommandId());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateSequenceNo(input.getSequenceNo());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateOsPattern(input.getOsPattern());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateCommandLine(input.getCommandLine());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
try {
domain.updateOutputType(input.getOutputType());
} catch (ValidationException e) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(e);
}
// Add custom code//GEN-FIRST:_createDomain_2
if (!fromPrevalidate)
domain.adjustSequenceNoBeforeAdd(uow);
// .//GEN-BEGIN:_createDomain_3_be
if (appExps != null && appExps.size() > 0)
throw appExps;
return domain;
}
Aggregations