ucUATransactUser

Purpose

This display is used on the user account administration screen. It is called after all other modifications to the database are complete for UserAccountsDisplay.

Applies To

User Account Display

Signature

public boolean ucUATransactUser(
                       String mode, 
                       FormParameters fp,
                       SecurityUser su,
                       HttpServletRequest request,
                       HttpServletResponse response,
                       Connection dbconn,
                       SesameSession session) throws Exception {
       return true;
   }

Notes

Errors should be communicated to the user by setting the ALERT attribute in the current session.

Example

public boolean ucUATransactUser(String mode,
                                    FormParameters fp,
                                    SecurityUser su,
                                    HttpServletRequest request,
                                    HttpServletResponse response,
                                    Connection dbconn,
                                    SesameSession session) throws Exception {
        // Don't perform transaction if the area/role form parameter doesn't exist
        // (in case of non-admin user editing account settings)
        if (! fp.containsKey("p_area_role") )
            return true;

        // Create new area/role list based on form parameters list
        String[] areaRoles = fp.getArray("p_area_role");
        ArrayList areaRoleList = new ArrayList();

        for (int i = 0; i |"
            int lastIndex = value.lastIndexOf('|');
            String roleId = value.substring(lastIndex + 1);

            if (!roleId.equals("{NULL}")) // ignore none values
                areaRoleList.add(value);
        }

        // Get the id of the user account
        String userId = su.getId();
        String updateUserId = session.getUserId();
        String message = null;

        // Update the database with the area/role mappings
        try {
            if (mode.equals("doAdd"))
                UserAreaRole.addMultiple(dbconn, userId, areaRoleList, updateUserId);
            else
                UserAreaRole.editMultiple(dbconn, userId, areaRoleList, updateUserId);
        }
        catch (Exception e) {
            message = "Error updating Area/Role Mapping.  Please see logged error.";
            Z.log.writeToLog(Z.log.ERROR, "ucUATransactUser Exception");
            ErrorWriter.write(e, ErrorWriter.LOGERR);
        }

        dbconn.commit();

        // Communicate error to user
        if (message != null) {
            session.setAttribute("ALERT", "\n");
            return false;
        }
        return true;
    }