use of org.structr.common.error.NullArgumentToken in project structr by structr.
the class AbstractNode method setPropertyInternal.
private <T> Object setPropertyInternal(final PropertyKey<T> key, final T value) throws FrameworkException {
if (key == null) {
logger.error("Tried to set property with null key (action was denied)");
throw new FrameworkException(422, "Tried to set property with null key (action was denied)", new NullArgumentToken(getClass().getSimpleName(), base));
}
try {
// check for system properties
if (key.isSystemInternal() && !internalSystemPropertiesUnlocked) {
throw new FrameworkException(422, "Property " + key.jsonName() + " is an internal system property", new InternalSystemPropertyToken(getClass().getSimpleName(), key));
}
// check for read-only properties
if ((key.isReadOnly() || key.isWriteOnce()) && !readOnlyPropertiesUnlocked && !securityContext.isSuperUser()) {
throw new FrameworkException(422, "Property " + key.jsonName() + " is read-only", new ReadOnlyPropertyToken(getClass().getSimpleName(), key));
}
return key.setProperty(securityContext, this, value);
} finally {
// unconditionally lock read-only properties after every write (attempt) to avoid security problems
// since we made "unlock_readonly_properties_once" available through scripting
internalSystemPropertiesUnlocked = false;
readOnlyPropertiesUnlocked = false;
}
}
use of org.structr.common.error.NullArgumentToken in project structr by structr.
the class AbstractRelationship method setProperty.
@Override
public final <T> Object setProperty(final PropertyKey<T> key, final T value) throws FrameworkException {
if (key == null) {
logger.error("Tried to set property with null key (action was denied)");
throw new FrameworkException(422, "Tried to set property with null key (action was denied)", new NullArgumentToken(getClass().getSimpleName(), base));
}
try {
if (dbRelationship != null && dbRelationship.hasProperty(key.dbName())) {
// check for system properties
if (key.isSystemInternal() && !internalSystemPropertiesUnlocked) {
throw new FrameworkException(422, "Property " + key.jsonName() + " is an internal system property", new InternalSystemPropertyToken(getClass().getSimpleName(), key));
}
// check for read-only properties
if ((key.isReadOnly() || key.isWriteOnce()) && !readOnlyPropertiesUnlocked && !securityContext.isSuperUser()) {
throw new FrameworkException(422, "Property " + key.jsonName() + " is read-only", new ReadOnlyPropertyToken(getClass().getSimpleName(), key));
}
}
return key.setProperty(securityContext, this, value);
} finally {
// unconditionally lock read-only properties after every write (attempt) to avoid security problems
// since we made "unlock_readonly_properties_once" available through scripting
internalSystemPropertiesUnlocked = false;
readOnlyPropertiesUnlocked = false;
}
}
Aggregations