use of cn.edu.zju.acm.onlinejudge.bean.UserProfile in project zoj by licheng.
the class AddUserRoleAction method execute.
/**
* AddUserRoleAction.
*
* @param mapping
* action mapping
* @param form
* action form
* @param request
* http servlet request
* @param response
* http servlet response
*
* @return action forward instance
*
* @throws Exception
* any errors happened
*/
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, ContextAdapter context) throws Exception {
// check admin
ActionForward forward = this.checkAdmin(mapping, context);
if (forward != null) {
return forward;
}
long userId = Utility.parseLong(String.valueOf(context.getRequest().getParameter("userId")));
long roleId = Utility.parseLong(String.valueOf(context.getRequest().getParameter("roleId")));
UserProfile user = UserManager.getInstance().getUserProfile(userId);
if (user == null) {
return this.handleSuccess(mapping, context, "failure");
}
PersistenceManager.getInstance().getAuthorizationPersistence().addUserRole(userId, roleId);
return this.handleSuccess(mapping, context, "success", "?userId=" + userId);
}
use of cn.edu.zju.acm.onlinejudge.bean.UserProfile in project zoj by licheng.
the class SubmissionPersistenceImplTest method newUserProfile.
/**
* Creates a new user profile.
* @param id the id
* @return a new user profile instance
*/
private UserProfile newUserProfile(long id) {
UserProfile profile = new UserProfile();
profile.setId(id);
profile.setHandle("myHandle" + id);
profile.setPassword("myPassword");
profile.setEmail("myEmail" + id);
profile.setRegDate(new Date());
profile.setFirstName("myFirstName");
profile.setLastName("myLastName");
profile.setAddressLine1("myAddressLine1");
profile.setAddressLine2("myAddressLine2");
profile.setCity("myCity");
profile.setState("myState");
profile.setCountry(new Country(1, "foo"));
profile.setZipCode("myZipCode");
profile.setPhoneNumber("myPhoneNumber");
profile.setBirthDate(new Date(0));
profile.setGender('M');
profile.setSchool("mySchool");
profile.setMajor("myMajor");
profile.setGraduateStudent(true);
profile.setGraduationYear(2005);
profile.setStudentNumber("myStudentNumber");
profile.setConfirmed(false);
return profile;
}
use of cn.edu.zju.acm.onlinejudge.bean.UserProfile in project zoj by licheng.
the class UserManager method getUserProfile.
public UserProfile getUserProfile(long userId) throws PersistenceException {
Object key = new Long(userId);
synchronized (this.userCache) {
UserProfile user = this.userCache.get(key);
if (user == null) {
UserPersistence userPersistence = PersistenceManager.getInstance().getUserPersistence();
user = userPersistence.getUserProfile(userId);
this.userCache.put(key, user);
}
return user;
}
}
use of cn.edu.zju.acm.onlinejudge.bean.UserProfile in project zoj by licheng.
the class UserPersistenceImplTest method testCreateUserProfile.
/**
* Tests createUserProfile method
* @throws Exception to JUnit
*/
public void testCreateUserProfile() throws Exception {
persistence.createUserProfile(profile, 1);
UserProfile profile1 = persistence.getUserProfile(profile.getId());
checkUserProfile(profile, profile1);
}
use of cn.edu.zju.acm.onlinejudge.bean.UserProfile in project zoj by licheng.
the class UserPersistenceImplTest method testGetUserProfileByHandle.
/**
* Tests getUserProfileByHandle method
* @throws Exception to JUnit
*/
public void testGetUserProfileByHandle() throws Exception {
persistence.createUserProfile(profile, 1);
UserProfile profile1 = persistence.getUserProfileByHandle(profile.getHandle());
checkUserProfile(profile, profile1);
}
Aggregations