use of org.jaffa.applications.jaffa.modules.admin.domain.UserRole 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.applications.jaffa.modules.admin.domain.UserRole in project jaffa-framework by jaffa-projects.
the class UserMaintenanceTx method deleteRelatedObjects.
// .//GEN-END:_addRelatedDtosToRetrieveOut_2_be
// .//GEN-BEGIN:_deleteRelatedObjects_1_be
/**
* Delete the related domain objects if the 'Cascading' constraint is specified. Throw an exception in case 'Restricted' constraint is specified.
*/
private void deleteRelatedObjects(UOW uow, UserMaintenanceDeleteInDto input, User user) throws FrameworkException, ApplicationExceptions {
ApplicationExceptions appExps = null;
// .//GEN-BEGIN:_deleteRelatedObjects_UserRole_1_be
if (user.getUserName() != null) {
Criteria criteria = new Criteria();
criteria.setTable(UserRoleMeta.getName());
criteria.addCriteria(UserRoleMeta.USER_NAME, user.getUserName());
criteria.setLocking(Criteria.LOCKING_PARANOID);
// .//GEN-END:_deleteRelatedObjects_UserRole_1_be
// Add custom code to set the criteria before the query //GEN-FIRST:_deleteRelatedObjects_UserRole_1
// .//GEN-LAST:_deleteRelatedObjects_UserRole_1
// .//GEN-BEGIN:_deleteRelatedObjects_UserRole_4_be
Iterator itr = uow.query(criteria).iterator();
while (itr.hasNext()) {
UserRole userRole = (UserRole) itr.next();
if (log.isDebugEnabled())
log.debug("Deleting the related object " + userRole);
uow.delete(userRole);
}
// .//GEN-END:_deleteRelatedObjects_UserRole_4_be
// .//GEN-BEGIN:_deleteRelatedObjects_UserRole_6_be
}
// .//GEN-BEGIN:_deleteRelatedObjects_2_be
if (appExps != null)
throw appExps;
}
use of org.jaffa.applications.jaffa.modules.admin.domain.UserRole in project jaffa-framework by jaffa-projects.
the class User method newUserRoleObject.
/**
* Creates a new UserRole object and initializes the related fields.
* This will uncache the related UserRole objects.
* @throws ValidationException if an invalid value is passed.
* @throws FrameworkException Indicates some system error
* @return the related UserRole object with the initialized related fields.
*/
public UserRole newUserRoleObject() throws ValidationException, FrameworkException {
m_userRoleCollection = null;
UserRole userRole = new UserRole();
userRole.setUserName(getUserName());
// .//GEN-BEGIN:userRoleArray_3_be
return userRole;
}
Aggregations