public <C> C loadSettingValue(Setting<C> setting) { String v = null; // TODO SystemProperties.getComponentProperty(setting.getComponent().getName(), // setting.getName()); if (v != null) { return setting.getDataType().cast(v, null, null); } return null; }
@SuppressWarnings("unchecked") @Override public <C> C getSettingValue(Setting<C> setting, Parameters parameters) { boolean useSession = parameters != null && parameters.get(USE_REQ); if (useSession) { HttpServletRequest req = parameters.get(Parameter.REQUEST); if (req != null) { Object v = req.getSession(true).getAttribute(getKey(setting)); if (v != null) { return setting.getDataType().cast(v, null, null); } } } if (settingValues.containsKey(setting)) { return (C) settingValues.get(setting); } else { C settingValue = loadSettingValue(setting); if (settingValue != null) { settingValues.put(setting, settingValue); return settingValue; } return setting.getDataType().getDefaultValue(); } }
/* * Add a new record to the Organization table, * creates an admin account when SA creates a new consulting company * @param OrganizationCode (based on Company Name) * @param OrganizationName (based on Company Description) * @param FKCompanyID * @param NameSequence * @param PKUser * @param nomRater * @throws SQLException * @throws Exception * @author: Mark Oei * @since v.1.3.12.63 09 Mar 2010 */ public boolean addOrganisationByCons( String OrganizationCode, String OrganizationName, int FKCompanyID, int NameSequence, int PKUser, String nomRater) throws SQLException, Exception { Connection con = null; Statement st = null; boolean bIsAdded = false; String sql = "INSERT INTO tblOrganization (OrganizationCode, OrganizationName, FKCompanyID, NameSequence, NominationModule)"; sql = sql + " VALUES ('" + OrganizationCode + "', '" + OrganizationName + "', " + FKCompanyID + ", " + NameSequence + ", '" + Boolean.parseBoolean(nomRater) + "')"; try { con = ConnectionBean.getConnection(); st = con.createStatement(); int iSuccess = st.executeUpdate(sql); System.out.println(iSuccess); if (iSuccess != 0) bIsAdded = true; } catch (Exception E) { System.err.println("Organization.java - AddRecord - " + E); } finally { ConnectionBean.closeStmt(st); // Close statement ConnectionBean.close(con); // Close connection } System.out.println("1. Add Organization"); // add default under the organization. String defaultName = "NA"; int FKOrganization = checkOrgExist(OrganizationCode, OrganizationName, FKCompanyID); // Change to disable print statement. Used for debugging only // Mark Oei 19 Mar 2010 // System.out.println("testing " + FKOrganization); System.out.println("2. Check Organization Exist"); if (FKOrganization != 0) { // Add Division div.addRecord(defaultName, FKOrganization, PKUser); System.out.println("3. Add Division"); // Add Department dept.addRecord(defaultName, FKOrganization, PKUser); System.out.println("4. Add Department"); // Add Group G.addRecord(defaultName, FKOrganization, PKUser); System.out.println("5. Add Group"); // Check whether exists int FKDivision = div.checkDivExist(defaultName, FKOrganization); int FKDepartment = dept.checkDeptExist(defaultName, FKOrganization); int FKGroup = G.checkGroupExist(defaultName, FKOrganization); // Create links dept.linkDepartment(FKDivision, FKDepartment); G.linkGroup(FKDepartment, FKGroup); // Establish new admin account and password Date timeStamp = new java.util.Date(); SimpleDateFormat dFormat = new SimpleDateFormat("ddMMyyHHmmss"); String temp = dFormat.format(timeStamp); String loginName = OrganizationCode + "admin"; String password = OrganizationCode + temp; int userType = 6; // Insert record into database U.addRecord( FKDepartment, FKDivision, userType, "Admin", "Admin", loginName, "NA", "NA", FKGroup, password, 1, FKCompanyID, FKOrganization, "NA", PKUser); System.out.println("6. Add User"); int userExist = U.checkUserExist( FKDepartment, FKDivision, userType, "Admin", "Admin", loginName, "NA", "NA", FKGroup, password, 1, FKCompanyID, FKOrganization); System.out.println( "FKDivision = " + FKDivision + ", FKDepartment = " + FKDepartment + ", FKGroup = " + FKGroup + " and User Exist = " + userExist); if (userExist != 0) { try { U.insertRelation(userExist, userExist, 0); } catch (SQLException SE) { System.out.println(SE.getMessage()); } // Send email notification String content = template.ForgotPass_temp(loginName, password); String email = "*****@*****.**"; // Edited By Roger 13 June 2008 Email.sendMail( server.getAdminEmail(), email, "New Admin Assignment for " + OrganizationName, content, FKOrganization); } System.out.println("8. Add User Relation"); } sDetail = detail.getUserDetail(PKUser); ev.addRecord("Insert", itemName, OrganizationName, sDetail[2], sDetail[11], sDetail[10]); return bIsAdded; } // End Method for addOrganisationByCons
protected String getKey(Setting<?> setting) { return "org.mmbase.framework." + setting.getComponent().getName() + "." + setting.getName(); }