use of org.jaffa.applications.jaffa.modules.admin.components.usermaintenance.tx.exceptions.UserMaintenanceException in project jaffa-framework by jaffa-projects.
the class UserMaintenanceTx method performUserRoleValidations.
private void performUserRoleValidations(String[] userRole, User domain) throws ApplicationExceptions {
ApplicationExceptions appExps = null;
boolean foundExcludedRole = false;
Roles root = PolicyCache.getRoles();
if (root != null) {
List roleObjects = root.getRole();
if (roleObjects != null) {
for (Iterator it = roleObjects.iterator(); it.hasNext(); ) {
Role role = (Role) it.next();
if (Arrays.binarySearch(userRole, role.getName()) >= 0) {
List includes = role.getInclude();
if (includes != null) {
for (Iterator it2 = includes.iterator(); it2.hasNext(); ) {
Include includedObject = (Include) it2.next();
String includeName = includedObject.getName();
if (Arrays.binarySearch(userRole, includeName) < 0) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(new UserMaintenanceException(UserMaintenanceException.PROP_INCLUDED_ROLE_MISSING, role.getName(), includeName));
}
}
}
List excludes = role.getExclude();
if (excludes != null && !foundExcludedRole) {
for (Iterator it2 = excludes.iterator(); it2.hasNext(); ) {
Exclude excludedObject = (Exclude) it2.next();
String excludeName = excludedObject.getName();
if (Arrays.binarySearch(userRole, excludeName) >= 0) {
if (appExps == null)
appExps = new ApplicationExceptions();
appExps.add(new UserMaintenanceException(UserMaintenanceException.PROP_EXCLUDED_ROLE_PRESENT, role.getName(), excludeName));
foundExcludedRole = true;
}
}
}
}
}
}
}
if (appExps != null && appExps.size() > 0)
throw appExps;
}
use of org.jaffa.applications.jaffa.modules.admin.components.usermaintenance.tx.exceptions.UserMaintenanceException in project jaffa-framework by jaffa-projects.
the class UserMaintenanceTx method preprocess.
// .//GEN-END:_updateDomain_3_be
// .//GEN-BEGIN:_preprocessDelete_1_be
/**
* Preprocess the input for the delete method.
*/
private void preprocess(UOW uow, UserMaintenanceDeleteInDto input) throws FrameworkException, ApplicationExceptions {
// ensure that the user has access to the business function - Jaffa.Admin.User.Maintenance
if (!hasMaintenanceAccess()) {
String str = "Delete aborted. User has no access to the Business Function: 'Jaffa.Admin.User.Maintenance'";
log.error(str);
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add(new UserMaintenanceException(UserMaintenanceException.PROP_NO_MAINT_ACCESS));
throw appExps;
}
// .//GEN-LAST:_preprocessDelete_1
// .//GEN-BEGIN:_preprocessDelete_2_be
}
use of org.jaffa.applications.jaffa.modules.admin.components.usermaintenance.tx.exceptions.UserMaintenanceException in project jaffa-framework by jaffa-projects.
the class UserMaintenanceTx method preprocess.
// .//GEN-END:_delete_1_be
// .//GEN-BEGIN:_preprocessCreate_1_be
/**
* Preprocess the input for the create method.
*/
private void preprocess(UOW uow, UserMaintenanceCreateInDto input) throws FrameworkException, ApplicationExceptions {
// ensure that the user has access to the business function - Jaffa.Admin.User.Maintenance
if (!hasMaintenanceAccess()) {
String str = "Create aborted. User has no access to the Business Function: 'Jaffa.Admin.User.Maintenance'";
log.error(str);
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add(new UserMaintenanceException(UserMaintenanceException.PROP_NO_MAINT_ACCESS));
throw appExps;
}
// .//GEN-LAST:_preprocessCreate_1
// .//GEN-BEGIN:_preprocessCreate_2_be
}
use of org.jaffa.applications.jaffa.modules.admin.components.usermaintenance.tx.exceptions.UserMaintenanceException in project jaffa-framework by jaffa-projects.
the class UserMaintenanceTx method preprocess.
// .//GEN-END:_buildRetrieveOutDto_3_be
// .//GEN-BEGIN:_preprocessUpdate_1_be
/**
* Preprocess the input for the update method.
*/
private void preprocess(UOW uow, UserMaintenanceUpdateInDto input) throws FrameworkException, ApplicationExceptions {
// .//GEN-END:_preprocessUpdate_1_be
// Add custom code //GEN-FIRST:_preprocessUpdate_1
// determine the user access levels
boolean selfUpdateAccess;
boolean maintenanceAccess = hasMaintenanceAccess();
if (maintenanceAccess) {
// maintenanceAccess implies selfUpdateAccess
selfUpdateAccess = true;
} else {
selfUpdateAccess = hasSelfUpdateAccess();
}
if (!maintenanceAccess && !selfUpdateAccess) {
String str = "Update aborted. User has no access to either of the Business Functions: 'Jaffa.Admin.User.Maintenance' & 'Jaffa.Admin.User.SelfUpdate'";
log.error(str);
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add(new UserMaintenanceException(UserMaintenanceException.PROP_NO_ACCESS));
throw appExps;
} else if (!maintenanceAccess && selfUpdateAccess) {
if (!input.getHeaderDto().getUserId().equals(input.getUserName())) {
String str = "Update aborted. User has no privilege to update someone else's profile";
log.error(str);
ApplicationExceptions appExps = new ApplicationExceptions();
appExps.add(new UserMaintenanceException(UserMaintenanceException.PROP_CANNOT_UPDATE_OTHERS_PROFILE));
throw appExps;
}
}
// .//GEN-LAST:_preprocessUpdate_1
// .//GEN-BEGIN:_preprocessUpdate_2_be
}
Aggregations