use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.
the class UserProfileManager method deleteProfile.
@Override
@CacheEvict(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'UserProfile_'.concat(#username)")
public void deleteProfile(String username) throws ApsSystemException {
try {
IUserProfile profileToDelete = this.getProfile(username);
if (null == profileToDelete) {
return;
}
this.getProfileDAO().deleteEntity(username);
this.notifyProfileChanging(profileToDelete, ProfileChangedEvent.REMOVE_OPERATION_CODE);
} catch (Throwable t) {
logger.error("Error deleting user profile {}", username, t);
throw new ApsSystemException("Error deleting user profile", t);
}
}
use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.
the class ApiUserProfileInterface method getUserProfile.
public JAXBUserProfile getUserProfile(Properties properties) throws ApiException, Throwable {
JAXBUserProfile jaxbUserProfile = null;
try {
String username = properties.getProperty("username");
IUserProfile userProfile = this.getUserProfileManager().getProfile(username);
if (null == userProfile) {
throw new ApiException(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR, "Profile of user '" + username + "' does not exist", Response.Status.CONFLICT);
}
jaxbUserProfile = new JAXBUserProfile(userProfile, null);
} catch (ApiException ae) {
throw ae;
} catch (Throwable t) {
_logger.error("Error extracting user profile", t);
// ApsSystemUtils.logThrowable(t, this, "getUserProfile");
throw new ApsSystemException("Error extracting user profile", t);
}
return jaxbUserProfile;
}
use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.
the class ApiUserProfileInterface method addUserProfile.
public StringApiResponse addUserProfile(JAXBUserProfile jaxbUserProfile) throws Throwable {
StringApiResponse response = new StringApiResponse();
try {
String username = jaxbUserProfile.getId();
if (null != this.getUserProfileManager().getProfile(username)) {
throw new ApiException(IApiErrorCodes.API_PARAMETER_VALIDATION_ERROR, "Profile of user '" + username + "' already exist", Response.Status.CONFLICT);
}
IApsEntity profilePrototype = this.getUserProfileManager().getEntityPrototype(jaxbUserProfile.getTypeCode());
if (null == profilePrototype) {
throw new ApiException(IApiErrorCodes.API_VALIDATION_ERROR, "User Profile type with code '" + jaxbUserProfile.getTypeCode() + "' does not exist", Response.Status.CONFLICT);
}
IUserProfile userProfile = (IUserProfile) jaxbUserProfile.buildEntity(profilePrototype, null);
List<ApiError> errors = this.validate(userProfile);
if (errors.size() > 0) {
response.addErrors(errors);
response.setResult(IResponseBuilder.FAILURE, null);
return response;
}
this.getUserProfileManager().addProfile(username, userProfile);
response.setResult(IResponseBuilder.SUCCESS, null);
} catch (ApiException ae) {
response.addErrors(ae.getErrors());
response.setResult(IResponseBuilder.FAILURE, null);
} catch (Throwable t) {
_logger.error("Error adding user profile", t);
// ApsSystemUtils.logThrowable(t, this, "addUserProfile");
throw new ApsSystemException("Error adding user profile", t);
}
return response;
}
use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.
the class JAXBUserProfile method buildEntity.
@Override
public IApsEntity buildEntity(IApsEntity prototype, ICategoryManager categoryManager) {
IUserProfile profile = (IUserProfile) super.buildEntity(prototype, categoryManager);
// this.valorizeTextAttribute(profile.getFirstNameAttributeName(), this.getFirstname(), profile);
// this.valorizeTextAttribute(profile.getSurnameAttributeName(), this.getSurname(), profile);
this.valorizeTextAttribute(profile.getMailAttributeName(), this.getMail(), profile);
return profile;
}
use of org.entando.entando.aps.system.services.userprofile.model.IUserProfile in project entando-core by entando.
the class SocialActivityStreamManager method getActionLikeRecords.
@Override
@CachePut(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'ActivityStreamLikeRecords_id_'.concat(#id)")
@CacheableInfo(groups = "'ActivityStreamLikeRecords_cacheGroup'")
public List<ActivityStreamLikeInfo> getActionLikeRecords(int id) throws ApsSystemException {
List<ActivityStreamLikeInfo> infos = null;
try {
infos = this.getSocialActivityStreamDAO().getActionLikeRecords(id);
if (null != infos) {
for (int i = 0; i < infos.size(); i++) {
ActivityStreamLikeInfo asli = infos.get(i);
String username = asli.getUsername();
IUserProfile profile = this.getUserProfileManager().getProfile(username);
String displayName = (null != profile) ? profile.getDisplayName() : username;
asli.setDisplayName(displayName);
}
}
} catch (Throwable t) {
_logger.error("Error extracting activity stream like records", t);
throw new ApsSystemException("Error extracting activity stream like records", t);
}
return infos;
}
Aggregations