Search in sources :

Example 6 with IUserProfile

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);
    }
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) CacheEvict(org.springframework.cache.annotation.CacheEvict)

Example 7 with IUserProfile

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;
}
Also used : JAXBUserProfile(org.entando.entando.aps.system.services.userprofile.api.model.JAXBUserProfile) IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 8 with IUserProfile

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;
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) IApsEntity(com.agiletec.aps.system.common.entity.model.IApsEntity) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ApiError(org.entando.entando.aps.system.services.api.model.ApiError) StringApiResponse(org.entando.entando.aps.system.services.api.model.StringApiResponse) ApiException(org.entando.entando.aps.system.services.api.model.ApiException)

Example 9 with IUserProfile

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;
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile)

Example 10 with IUserProfile

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;
}
Also used : IUserProfile(org.entando.entando.aps.system.services.userprofile.model.IUserProfile) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ActivityStreamLikeInfo(org.entando.entando.apsadmin.system.services.activitystream.model.ActivityStreamLikeInfo) CacheableInfo(org.entando.entando.aps.system.services.cache.CacheableInfo) CachePut(org.springframework.cache.annotation.CachePut)

Aggregations

IUserProfile (org.entando.entando.aps.system.services.userprofile.model.IUserProfile)42 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)10 UserDetails (com.agiletec.aps.system.services.user.UserDetails)7 MonoTextAttribute (com.agiletec.aps.system.common.entity.model.attribute.MonoTextAttribute)5 ApiException (org.entando.entando.aps.system.services.api.model.ApiException)5 IApsEntity (com.agiletec.aps.system.common.entity.model.IApsEntity)3 AbstractUser (com.agiletec.aps.system.services.user.AbstractUser)3 Date (java.util.Date)3 StringApiResponse (org.entando.entando.aps.system.services.api.model.StringApiResponse)3 CacheableInfo (org.entando.entando.aps.system.services.cache.CacheableInfo)3 CachePut (org.springframework.cache.annotation.CachePut)3 DateAttribute (com.agiletec.aps.system.common.entity.model.attribute.DateAttribute)2 ActionSupport (com.opensymphony.xwork2.ActionSupport)2 ArrayList (java.util.ArrayList)2 ApiError (org.entando.entando.aps.system.services.api.model.ApiError)2 Test (org.junit.Test)2 IEntityTypesConfigurer (com.agiletec.aps.system.common.entity.IEntityTypesConfigurer)1 BaseFilterUtils (com.agiletec.aps.system.common.entity.helper.BaseFilterUtils)1 EntitySearchFilter (com.agiletec.aps.system.common.entity.model.EntitySearchFilter)1 ITextAttribute (com.agiletec.aps.system.common.entity.model.attribute.ITextAttribute)1