Search in sources :

Example 6 with Group

use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.

the class BaseDataObjectDispenser method getBaseRenderizationInfo.

public DataObjectRenderizationInfo getBaseRenderizationInfo(PublicDataTypeAuthorizationInfo authInfo, String dataObjectId, long modelId, String langCode, UserDetails currentUser, RequestContext reqCtx, boolean cacheable) {
    DataObjectRenderizationInfo renderInfo = null;
    try {
        List<Group> userGroups = (null != currentUser) ? this.getAuthorizationManager().getUserGroups(currentUser) : new ArrayList<Group>();
        if (authInfo.isUserAllowed(userGroups)) {
            DataObject dataObjectToRender = this.getDataObjectManager().loadDataObject(dataObjectId, true, cacheable);
            renderInfo = this.getBaseRenderizationInfo(dataObjectToRender, modelId, langCode, reqCtx);
        }
    } catch (Throwable t) {
        _logger.error("Error while rendering DataObject {}", dataObjectId, t);
        return null;
    }
    return renderInfo;
}
Also used : Group(com.agiletec.aps.system.services.group.Group) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject)

Example 7 with Group

use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.

the class BaseDataObjectDispenser method getRenderizationInfo.

protected DataObjectRenderizationInfo getRenderizationInfo(PublicDataTypeAuthorizationInfo authInfo, String dataObjectId, long modelId, String langCode, RequestContext reqCtx, boolean cacheable) {
    DataObjectRenderizationInfo renderInfo = null;
    try {
        UserDetails currentUser = (null != reqCtx) ? (UserDetails) reqCtx.getRequest().getSession().getAttribute(SystemConstants.SESSIONPARAM_CURRENT_USER) : null;
        List<Group> userGroups = (null != currentUser) ? this.getAuthorizationManager().getUserGroups(currentUser) : new ArrayList<Group>();
        if (authInfo.isUserAllowed(userGroups)) {
            renderInfo = this.getBaseRenderizationInfo(authInfo, dataObjectId, modelId, langCode, currentUser, reqCtx, cacheable);
            if (null == renderInfo) {
                return null;
            }
        } else {
            String renderedDataObject = "Current user '" + currentUser.getUsername() + "' can't view this DataObject";
            DataObject dataObjectToRender = this.getDataObjectManager().loadDataObject(dataObjectId, true, cacheable);
            renderInfo = new DataObjectRenderizationInfo(dataObjectToRender, renderedDataObject, modelId, langCode, null);
            renderInfo.setRenderedDataobject(renderedDataObject);
            return renderInfo;
        }
    } catch (Throwable t) {
        _logger.error("Error while rendering dataObject {}", dataObjectId, t);
        return null;
    }
    return renderInfo;
}
Also used : Group(com.agiletec.aps.system.services.group.Group) UserDetails(com.agiletec.aps.system.services.user.UserDetails) DataObject(org.entando.entando.aps.system.services.dataobject.model.DataObject)

Example 8 with Group

use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.

the class GroupService method addGroup.

@Override
public GroupDto addGroup(GroupRequest groupRequest) {
    try {
        Group group = this.createGroup(groupRequest);
        this.getGroupManager().addGroup(group);
        return this.getDtoBuilder().convert(group);
    } catch (ApsSystemException e) {
        logger.error("Error adding group", e);
        throw new RestServerError("error add group", e);
    }
}
Also used : Group(com.agiletec.aps.system.services.group.Group) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException)

Example 9 with Group

use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.

the class GroupService method removeGroup.

@Override
public void removeGroup(String groupName) {
    try {
        Group group = this.getGroupManager().getGroup(groupName);
        BeanPropertyBindingResult validationResult = this.checkGroupForDelete(group);
        if (validationResult.hasErrors()) {
            throw new ValidationConflictException(validationResult);
        }
        if (null != group) {
            this.getGroupManager().removeGroup(group);
        }
    } catch (ApsSystemException e) {
        logger.error("Error in delete group {}", groupName, e);
        throw new RestServerError("error in delete group", e);
    }
}
Also used : Group(com.agiletec.aps.system.services.group.Group) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) RestServerError(org.entando.entando.aps.system.exception.RestServerError) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) ValidationConflictException(org.entando.entando.web.common.exceptions.ValidationConflictException)

Example 10 with Group

use of com.agiletec.aps.system.services.group.Group in project entando-core by entando.

the class GroupService method createGroup.

protected Group createGroup(GroupRequest groupRequest) {
    Group group = new Group();
    group.setName(groupRequest.getCode());
    group.setDescription(groupRequest.getName());
    return group;
}
Also used : Group(com.agiletec.aps.system.services.group.Group)

Aggregations

Group (com.agiletec.aps.system.services.group.Group)68 UserDetails (com.agiletec.aps.system.services.user.UserDetails)15 Role (com.agiletec.aps.system.services.role.Role)13 ArrayList (java.util.ArrayList)13 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)7 BeanComparator (org.apache.commons.beanutils.BeanComparator)5 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)4 HashSet (java.util.HashSet)4 RestRourceNotFoundException (org.entando.entando.aps.system.exception.RestRourceNotFoundException)4 RestServerError (org.entando.entando.aps.system.exception.RestServerError)4 IGroupManager (com.agiletec.aps.system.services.group.IGroupManager)3 DataObject (org.entando.entando.aps.system.services.dataobject.model.DataObject)3 AttributeRole (com.agiletec.aps.system.common.entity.model.attribute.AttributeRole)2 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)2 Authorization (com.agiletec.aps.system.services.authorization.Authorization)2 IAuthorizationManager (com.agiletec.aps.system.services.authorization.IAuthorizationManager)2 ExtendedResourceAction (com.agiletec.plugins.jacms.apsadmin.content.attribute.action.resource.ExtendedResourceAction)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2