protected boolean sharingEnabled() { return forceAcl() || (SharingUtils.isSupported(clazz) && !(currentUserService.getCurrentUser() == null || CollectionUtils.containsAny( currentUserService.getCurrentUser().getUserCredentials().getAllAuthorities(), SharingUtils.SHARING_OVERRIDE_AUTHORITIES))); }
protected boolean isDeleteAllowed(T object) { if (IdentifiableObject.class.isInstance(object)) { IdentifiableObject idObject = (IdentifiableObject) object; if (SharingUtils.isSupported(clazz)) { return SharingUtils.canDelete(currentUserService.getCurrentUser(), idObject); } } return true; }
@Override public int save(T object) { if (!Interpretation.class.isAssignableFrom(clazz) && currentUserService.getCurrentUser() != null && SharingUtils.isSupported(clazz)) { BaseIdentifiableObject identifiableObject = (BaseIdentifiableObject) object; // TODO we might want to allow setting sharing props on save, but for now we null them out identifiableObject.setPublicAccess(null); identifiableObject.setUserGroupAccesses(new HashSet<UserGroupAccess>()); if (identifiableObject.getUser() == null) { identifiableObject.setUser(currentUserService.getCurrentUser()); } if (SharingUtils.canCreatePublic(currentUserService.getCurrentUser(), identifiableObject)) { if (SharingUtils.defaultPublic(clazz)) { String build = AccessStringHelper.newInstance() .enable(AccessStringHelper.Permission.READ) .enable(AccessStringHelper.Permission.WRITE) .build(); identifiableObject.setPublicAccess(build); } else { String build = AccessStringHelper.newInstance().build(); identifiableObject.setPublicAccess(build); } } else if (SharingUtils.canCreatePrivate( currentUserService.getCurrentUser(), identifiableObject)) { identifiableObject.setPublicAccess(AccessStringHelper.newInstance().build()); } else { AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_CREATE_DENIED); throw new CreateAccessDeniedException(object.toString()); } } AuditLogUtil.infoWrapper( log, currentUserService.getCurrentUsername(), object, AuditLogUtil.ACTION_CREATE); return (Integer) sessionFactory.getCurrentSession().save(object); }