/** * Check if adding or updating a relation is allowed. * * @param resourceIdentifiers The persistent resources that are being added */ protected void checkSharePermission(Set<PersistentResource> resourceIdentifiers) { if (resourceIdentifiers == null) { return; } final Set<PersistentResource> newResources = getRequestScope().getNewPersistentResources(); for (PersistentResource persistentResource : resourceIdentifiers) { if (!newResources.contains(persistentResource) && !lineage.getRecord(persistentResource.getType()).contains(persistentResource)) { checkPermission(SharePermission.class, persistentResource); } } }
/** * Queue the @*Update triggers iff this is not a newly created object (otherwise we run @*Create) */ private void triggerUpdate(String fieldName, Object original, Object value) { ChangeSpec changeSpec = new ChangeSpec(this, fieldName, original, value); boolean isNewlyCreated = requestScope.getNewPersistentResources().contains(this); CRUDEvent.CRUDAction action = isNewlyCreated ? CRUDEvent.CRUDAction.CREATE : CRUDEvent.CRUDAction.UPDATE; requestScope.publishLifecycleEvent(this, fieldName, action, Optional.of(changeSpec)); requestScope.publishLifecycleEvent(this, action); auditField(new ChangeSpec(this, fieldName, original, value)); }
/** * Sets value. * @param fieldName the field name * @param newValue the new value */ protected void setValueChecked(String fieldName, Object newValue) { Object existingValue = getValueUnchecked(fieldName); ChangeSpec spec = new ChangeSpec(this, fieldName, existingValue, newValue); boolean isNewlyCreated = requestScope.getNewPersistentResources().contains(this); // TODO: Need to refactor this logic. For creates this is properly converted in the executor. This logic // should be explicitly encapsulated here, not there. checkFieldAwareDeferPermissions(UpdatePermission.class, fieldName, newValue, existingValue); setValue(fieldName, newValue); }
/** * Check if adding or updating a relation is allowed. * * @param resourceIdentifiers The persistent resources that are being added */ protected void checkSharePermission(Set<PersistentResource> resourceIdentifiers) { if (resourceIdentifiers == null) { return; } final Set<PersistentResource> newResources = getRequestScope().getNewPersistentResources(); for (PersistentResource persistentResource : resourceIdentifiers) { if (!newResources.contains(persistentResource) && !lineage.getRecord(persistentResource.getType()).contains(persistentResource)) { checkPermission(SharePermission.class, persistentResource); } } }
/** * Sets value. * @param fieldName the field name * @param newValue the new value */ protected void setValueChecked(String fieldName, Object newValue) { Object existingValue = getValueUnchecked(fieldName); ChangeSpec spec = new ChangeSpec(this, fieldName, existingValue, newValue); boolean isNewlyCreated = requestScope.getNewPersistentResources().contains(this); // TODO: Need to refactor this logic. For creates this is properly converted in the executor. This logic // should be explicitly encapsulated here, not there. checkFieldAwareDeferPermissions(UpdatePermission.class, fieldName, newValue, existingValue); setValue(fieldName, newValue); }
/** * Queue the @*Update triggers iff this is not a newly created object (otherwise we run @*Create) */ private void triggerUpdate(String fieldName, Object original, Object value) { ChangeSpec changeSpec = new ChangeSpec(this, fieldName, original, value); boolean isNewlyCreated = requestScope.getNewPersistentResources().contains(this); CRUDEvent.CRUDAction action = isNewlyCreated ? CRUDEvent.CRUDAction.CREATE : CRUDEvent.CRUDAction.UPDATE; requestScope.publishLifecycleEvent(this, fieldName, action, Optional.of(changeSpec)); requestScope.publishLifecycleEvent(this, action); auditField(new ChangeSpec(this, fieldName, original, value)); }
newResources = requestScope.getNewPersistentResources().stream() .filter(resource -> typeAlias.equals(resource.getType()) && ids.contains(resource.getUUID().orElse("")))
newResources = requestScope.getNewPersistentResources().stream() .filter(resource -> typeAlias.equals(resource.getType()) && ids.contains(resource.getUUID().orElse("")))
if (requestScope.getNewPersistentResources().contains(resource)) { return executeUserChecksDeferInline(expressionAnnotation, expression);
newResources = requestScope.getNewPersistentResources().stream() .filter(resource -> typeAlias.equals(resource.getType()) && ids.contains(resource.getUUID().orElse("")))
if (requestScope.getNewPersistentResources().contains(resource)) { return executeUserChecksDeferInline(expressionAnnotation, expression);
newResources = requestScope.getNewPersistentResources().stream() .filter(resource -> typeAlias.equals(resource.getType()) && ids.contains(resource.getUUID().orElse("")))
if (requestScope.getNewPersistentResources().contains(resource)) { return executeUserChecksDeferInline(annotationClass, expression);
if (requestScope.getNewPersistentResources().contains(resource)) { return executeUserChecksDeferInline(annotationClass, expression);
requestScope.getNewPersistentResources().add(newResource); checkPermission(CreatePermission.class, newResource);
requestScope.getNewPersistentResources().add(newResource); checkPermission(CreatePermission.class, newResource);