use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class UserProfileManager method getProfile.
@Override
@CachePut(value = ICacheInfoManager.DEFAULT_CACHE_NAME, key = "'UserProfile_'.concat(#username)")
@CacheableInfo(groups = "'UserProfileTypes_cacheGroup'")
public IUserProfile getProfile(String username) throws ApsSystemException {
IUserProfile profile = null;
try {
UserProfileRecord profileVO = (UserProfileRecord) this.getProfileDAO().loadEntityRecord(username);
if (profileVO != null) {
profile = (IUserProfile) this.createEntityFromXml(profileVO.getTypeCode(), profileVO.getXml());
profile.setPublicProfile(profileVO.isPublicProfile());
}
} catch (Throwable t) {
logger.error("Error loading profile. user: {} ", username, t);
throw new ApsSystemException("Error loading profile", t);
}
return profile;
}
use of com.agiletec.aps.system.exception.ApsSystemException in project entando-core by entando.
the class UserProfileManager method addProfile.
@Override
public void addProfile(String username, IUserProfile profile) throws ApsSystemException {
try {
profile.setId(username);
this.getProfileDAO().addEntity(profile);
this.notifyProfileChanging(profile, ProfileChangedEvent.INSERT_OPERATION_CODE);
} catch (Throwable t) {
logger.error("Error saving profile - user: {}", username, t);
throw new ApsSystemException("Error saving profile", t);
}
}
use of com.agiletec.aps.system.exception.ApsSystemException 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 com.agiletec.aps.system.exception.ApsSystemException 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 com.agiletec.aps.system.exception.ApsSystemException 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;
}
Aggregations