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;
}
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;
}
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);
}
}
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);
}
}
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;
}
Aggregations