use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.
the class SocialActivityStreamManager method getActionCommentRecords.
@Override
@CachePut(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'ActivityStreamCommentRecords_id_'.concat(#id)")
@CacheableInfo(groups = "'ActivityStreamCommentRecords_cacheGroup'")
public List<ActivityStreamComment> getActionCommentRecords(int id) throws ApsSystemException {
List<ActivityStreamComment> infos = null;
try {
infos = this.getSocialActivityStreamDAO().getActionCommentRecords(id);
if (null != infos) {
for (int i = 0; i < infos.size(); i++) {
ActivityStreamComment comment = infos.get(i);
String username = comment.getUsername();
IUserProfile profile = this.getUserProfileManager().getProfile(username);
String displayName = (null != profile) ? profile.getDisplayName() : username;
comment.setDisplayName(displayName);
}
}
} catch (Throwable t) {
_logger.error("Error extracting activity stream like records for stream with id {}", id, t);
throw new ApsSystemException("Error extracting activity stream like records", t);
}
return infos;
}
use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.
the class UserAction method checkUserProfile.
private boolean checkUserProfile(String username, String profileTypeCode) throws ApsSystemException {
try {
IUserProfile userProfile = this.getUserProfileManager().getProfile(username);
if (null == userProfile) {
userProfile = (null != profileTypeCode) ? this.getUserProfileManager().getProfileType(profileTypeCode) : null;
if (null == userProfile) {
userProfile = this.getUserProfileManager().getDefaultProfileType();
}
if (null != userProfile) {
userProfile.setId(username);
this.getUserProfileManager().addProfile(username, userProfile);
return true;
}
} else {
return true;
}
} catch (Throwable t) {
_logger.error("Error adding default profile for user {}", username, t);
throw new ApsSystemException("Error adding default profile for user " + username, t);
}
return false;
}
use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.
the class UserProfileAction method edit.
@Override
public String edit() {
String username = this.getUsername();
try {
String checkUsernameResult = this.checkUsername(username, false);
if (null != checkUsernameResult)
return checkUsernameResult;
IUserProfile userProfile = (IUserProfile) this.getUserProfileManager().getProfile(username);
if (null == userProfile) {
List<IApsEntity> userProfileTypes = new ArrayList<IApsEntity>();
userProfileTypes.addAll(this.getUserProfileManager().getEntityPrototypes().values());
if (userProfileTypes.isEmpty()) {
throw new RuntimeException("Unexpected error - no one user profile types");
} else if (userProfileTypes.size() == 1) {
userProfile = (IUserProfile) userProfileTypes.get(0);
userProfile.setId(username);
} else {
return "chooseType";
}
}
this.getRequest().getSession().setAttribute(USERPROFILE_ON_SESSION, userProfile);
} catch (Throwable t) {
_logger.error("error in edit", t);
return FAILURE;
}
return SUCCESS;
}
use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.
the class TestCurrentUserProfileAction method testEditProfile_1.
public void testEditProfile_1() throws Throwable {
this.setUserOnSession(USERNAME_FOR_TEST);
this.initAction("/do/currentuser/profile", "edit");
String result = this.executeAction();
assertEquals("currentUserWithoutProfile", result);
IUserProfile currentUserProfile = (IUserProfile) this.getRequest().getSession().getAttribute(ICurrentUserProfileAction.SESSION_PARAM_NAME_CURRENT_PROFILE);
assertNull(currentUserProfile);
}
use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.
the class TestUserProfileAction method testEditProfile_1.
public void testEditProfile_1() throws Throwable {
this.setUserOnSession("admin");
this.initAction("/do/userprofile", "edit");
this.addParameter("username", USERNAME_FOR_TEST);
String result = this.executeAction();
assertEquals(Action.SUCCESS, result);
IUserProfile currentUserProfile = (IUserProfile) this.getRequest().getSession().getAttribute(UserProfileAction.USERPROFILE_ON_SESSION);
assertNotNull(currentUserProfile);
assertEquals(USERNAME_FOR_TEST, currentUserProfile.getUsername());
}
Aggregations