Skip to content

Commit

Permalink
changed signature for onModification so that we get information about…
Browse files Browse the repository at this point in the history
… the modifications.

this is used to determine if minification is triggered by a modification
  • Loading branch information
vigorouscoding committed Aug 26, 2016
1 parent 8207481 commit 52fa03f
Show file tree
Hide file tree
Showing 35 changed files with 303 additions and 209 deletions.
6 changes: 4 additions & 2 deletions structr-core/src/main/java/org/structr/core/GraphObject.java
Expand Up @@ -30,6 +30,7 @@
import org.structr.common.error.FrameworkException;
import org.structr.core.entity.AbstractNode;
import org.structr.core.entity.AbstractRelationship;
import org.structr.core.graph.ModificationQueue;
import org.structr.core.graph.NodeInterface;
import org.structr.core.graph.RelationshipInterface;
import org.structr.core.property.BooleanProperty;
Expand Down Expand Up @@ -201,7 +202,7 @@ public interface GraphObject {
*/
public void unlockReadOnlyPropertiesOnce();


public boolean isValid(ErrorBuffer errorBuffer);


Expand All @@ -224,10 +225,11 @@ public interface GraphObject {
*
* @param securityContext the context in which the modification takes place
* @param errorBuffer the error buffer to put error tokens into
* @param modificationQueue the modification queue that triggered this call to onModification
* @return true if the transaction can go on, false if an error occurred
* @throws FrameworkException
*/
public boolean onModification(final SecurityContext securityContext, final ErrorBuffer errorBuffer) throws FrameworkException;
public boolean onModification(final SecurityContext securityContext, final ErrorBuffer errorBuffer, final ModificationQueue modificationQueue) throws FrameworkException;

/**
* Called when an entity of this type is deleted. This method can cause the underlying
Expand Down
Expand Up @@ -27,13 +27,14 @@
import org.structr.api.graph.PropertyContainer;
import org.structr.cmis.CMISInfo;
import org.structr.common.PermissionResolutionMask;
import org.structr.core.property.PropertyKey;
import org.structr.core.property.PropertyMap;
import org.structr.common.SecurityContext;
import org.structr.common.error.ErrorBuffer;
import org.structr.common.error.FrameworkException;
import org.structr.core.graph.ModificationQueue;
import org.structr.core.graph.NodeInterface;
import org.structr.core.graph.RelationshipInterface;
import org.structr.core.property.PropertyKey;
import org.structr.core.property.PropertyMap;
import org.structr.core.script.Scripting;
import org.structr.schema.action.ActionContext;

Expand Down Expand Up @@ -114,7 +115,7 @@ public boolean onCreation(final SecurityContext securityContext, final ErrorBuff
}

@Override
public boolean onModification(final SecurityContext securityContext, final ErrorBuffer errorBuffer) throws FrameworkException {
public boolean onModification(final SecurityContext securityContext, final ErrorBuffer errorBuffer, final ModificationQueue modificationQueue) throws FrameworkException {
return true;
}

Expand Down
Expand Up @@ -42,15 +42,16 @@
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import org.structr.api.DatabaseService;
import org.structr.api.graph.Direction;
import org.structr.api.index.Index;
import org.structr.api.NativeResult;
import org.structr.api.Predicate;
import org.structr.api.graph.Direction;
import org.structr.api.graph.Node;
import org.structr.api.graph.Path;
import org.structr.api.Predicate;
import org.structr.api.graph.PropertyContainer;
import org.structr.api.graph.Relationship;
import org.structr.api.graph.RelationshipType;
import org.structr.api.index.Index;
import org.structr.api.util.FixedSizeCache;
import org.structr.cmis.CMISInfo;
import org.structr.cmis.common.CMISExtensionsData;
import org.structr.cmis.common.StructrItemActions;
Expand All @@ -62,7 +63,6 @@
import org.structr.cmis.info.CMISSecondaryInfo;
import org.structr.common.AccessControllable;
import org.structr.common.AccessPathCache;
import org.structr.api.util.FixedSizeCache;
import org.structr.common.GraphObjectComparator;
import org.structr.common.IdSorter;
import org.structr.common.Permission;
Expand All @@ -79,12 +79,13 @@
import org.structr.common.error.ReadOnlyPropertyToken;
import org.structr.core.GraphObject;
import org.structr.core.IterableAdapter;
import org.structr.core.entity.relationship.Ownership;
import org.structr.core.Services;
import org.structr.core.app.App;
import org.structr.core.app.StructrApp;
import org.structr.core.converter.PropertyConverter;
import org.structr.core.entity.relationship.Ownership;
import org.structr.core.entity.relationship.PrincipalOwnsNode;
import org.structr.core.graph.ModificationQueue;
import org.structr.core.graph.NodeInterface;
import org.structr.core.graph.NodeRelationshipStatisticsCommand;
import org.structr.core.graph.NodeService;
Expand Down Expand Up @@ -383,11 +384,11 @@ public long getId() {

@Override
public String getUuid() {

if (cachedUuid == null) {
cachedUuid = getProperty(GraphObject.id);
}

return cachedUuid;
}

Expand Down Expand Up @@ -1245,7 +1246,7 @@ public boolean onCreation(SecurityContext securityContext, ErrorBuffer errorBuff
}

@Override
public boolean onModification(SecurityContext securityContext, ErrorBuffer errorBuffer) throws FrameworkException {
public boolean onModification(SecurityContext securityContext, ErrorBuffer errorBuffer, final ModificationQueue modificationQueue) throws FrameworkException {
return true;
}

Expand Down Expand Up @@ -1508,7 +1509,7 @@ public void indexPassiveProperties() {
public static void clearRelationshipTemplateInstanceCache() {
relationshipTemplateInstanceCache.clear();
}

public static <A extends NodeInterface, B extends NodeInterface, R extends Relation<A, B, ?, ?>> R getRelationshipForType(final Class<R> type) {

R instance = (R) relationshipTemplateInstanceCache.get(type.getName());
Expand Down
Expand Up @@ -30,13 +30,13 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.chemistry.opencmis.commons.enums.PropertyType;
import org.structr.api.Predicate;
import org.structr.api.graph.Direction;
import org.structr.api.index.Index;
import org.structr.api.graph.Node;
import org.structr.api.Predicate;
import org.structr.api.graph.PropertyContainer;
import org.structr.api.graph.Relationship;
import org.structr.api.graph.RelationshipType;
import org.structr.api.index.Index;
import org.structr.cmis.CMISInfo;
import org.structr.common.GraphObjectComparator;
import org.structr.common.PermissionResolutionMask;
Expand All @@ -55,6 +55,7 @@
import org.structr.core.app.App;
import org.structr.core.app.StructrApp;
import org.structr.core.converter.PropertyConverter;
import org.structr.core.graph.ModificationQueue;
import org.structr.core.graph.NodeFactory;
import org.structr.core.graph.NodeInterface;
import org.structr.core.graph.NodeService;
Expand Down Expand Up @@ -106,7 +107,7 @@ public abstract class AbstractRelationship<S extends NodeInterface, T extends No
public boolean internalSystemPropertiesUnlocked = false;

private boolean readOnlyPropertiesUnlocked = false;

private String cachedEndNodeId = null;
private String cachedStartNodeId = null;

Expand Down Expand Up @@ -188,7 +189,7 @@ public void unlockSystemPropertiesOnce() {
this.internalSystemPropertiesUnlocked = true;
unlockReadOnlyPropertiesOnce();
}

@Override
public void unlockReadOnlyPropertiesOnce() {
this.readOnlyPropertiesUnlocked = true;
Expand Down Expand Up @@ -508,7 +509,7 @@ public boolean onCreation(SecurityContext securityContext, ErrorBuffer errorBuff
}

@Override
public boolean onModification(SecurityContext securityContext, ErrorBuffer errorBuffer) throws FrameworkException {
public boolean onModification(SecurityContext securityContext, ErrorBuffer errorBuffer, final ModificationQueue modificationQueue) throws FrameworkException {
return isValid(errorBuffer);
}

Expand Down Expand Up @@ -598,7 +599,7 @@ public <T> Object setProperty(final PropertyKey<T> key, final T value) throws Fr
}

return key.setProperty(securityContext, this, value);

} finally {

// unconditionally lock read-only properties after every write (attempt) to avoid security problems
Expand Down
Expand Up @@ -32,6 +32,7 @@
import org.structr.core.entity.relationship.SchemaNodeMethod;
import org.structr.core.entity.relationship.SchemaNodeProperty;
import org.structr.core.entity.relationship.SchemaNodeView;
import org.structr.core.graph.ModificationQueue;
import org.structr.core.graph.NodeAttribute;
import static org.structr.core.graph.NodeInterface.name;
import org.structr.core.graph.TransactionCommand;
Expand Down Expand Up @@ -99,9 +100,9 @@ public boolean onCreation(SecurityContext securityContext, ErrorBuffer errorBuff
}

@Override
public boolean onModification(SecurityContext securityContext, ErrorBuffer errorBuffer) throws FrameworkException {
public boolean onModification(SecurityContext securityContext, ErrorBuffer errorBuffer, final ModificationQueue modificationQueue) throws FrameworkException {

if (super.onModification(securityContext, errorBuffer)) {
if (super.onModification(securityContext, errorBuffer, modificationQueue)) {

// register transaction post processing that recreates the schema information
TransactionCommand.postProcess("createDefaultProperties", new CreateBuiltInSchemaEntities(this));
Expand Down
Expand Up @@ -23,15 +23,16 @@
import java.util.Set;
import java.util.TreeSet;
import java.util.function.Function;
import org.structr.api.util.Iterables;
import org.structr.api.graph.Node;
import org.structr.api.util.FixedSizeCache;
import org.structr.core.property.PropertyMap;
import org.structr.api.util.Iterables;
import org.structr.common.SecurityContext;
import org.structr.common.error.ErrorBuffer;
import org.structr.common.error.FrameworkException;
import org.structr.core.graph.ModificationQueue;
import org.structr.core.property.GenericProperty;
import org.structr.core.property.PropertyKey;
import org.structr.core.property.PropertyMap;

//~--- classes ----------------------------------------------------------------

Expand Down Expand Up @@ -66,7 +67,7 @@ public boolean onCreation(SecurityContext securityContext, ErrorBuffer errorBuff
}

@Override
public boolean onModification(SecurityContext securityContext, ErrorBuffer errorBuffer) throws FrameworkException {
public boolean onModification(SecurityContext securityContext, ErrorBuffer errorBuffer, final ModificationQueue modificationQueue) throws FrameworkException {
return true;
}

Expand Down
Expand Up @@ -25,15 +25,16 @@
import java.util.Map;
import java.util.Set;
import org.structr.api.graph.Relationship;
import org.structr.core.property.PropertyKey;
import org.structr.core.property.PropertyMap;
import org.structr.common.PropertyView;
import org.structr.common.SecurityContext;
import org.structr.common.View;
import org.structr.common.error.ErrorBuffer;
import org.structr.common.error.FrameworkException;
import org.structr.core.app.StructrApp;
import org.structr.core.graph.ModificationQueue;
import org.structr.core.graph.NodeInterface;
import org.structr.core.property.PropertyKey;
import org.structr.core.property.PropertyMap;
import org.structr.core.property.SourceId;
import org.structr.core.property.TargetId;

Expand Down Expand Up @@ -87,7 +88,7 @@ public boolean onCreation(SecurityContext securityContext, ErrorBuffer errorBuff
}

@Override
public boolean onModification(SecurityContext securityContext, ErrorBuffer errorBuffer) throws FrameworkException {
public boolean onModification(SecurityContext securityContext, ErrorBuffer errorBuffer, final ModificationQueue modificationQueue) throws FrameworkException {
return true;
}

Expand Down
Expand Up @@ -18,16 +18,17 @@
*/
package org.structr.core.entity;

import org.structr.core.property.Property;
import org.structr.common.PropertyView;
import org.structr.common.SecurityContext;
import org.structr.common.View;
import org.structr.common.error.ErrorBuffer;
import org.structr.common.error.FrameworkException;
import org.structr.core.entity.relationship.NodeHasLocation;
import org.structr.core.graph.ModificationQueue;
import org.structr.core.graph.NodeInterface;
import org.structr.core.graph.RelationshipInterface;
import org.structr.core.property.DoubleProperty;
import org.structr.core.property.Property;

//~--- classes ----------------------------------------------------------------

Expand Down Expand Up @@ -56,7 +57,7 @@ public boolean onCreation(SecurityContext securityContext, ErrorBuffer errorBuff
}

@Override
public boolean onModification(SecurityContext securityContext, ErrorBuffer errorBuffer) throws FrameworkException {
public boolean onModification(SecurityContext securityContext, ErrorBuffer errorBuffer, final ModificationQueue modificationQueue) throws FrameworkException {
return isValid(errorBuffer);
}

Expand Down

0 comments on commit 52fa03f

Please sign in to comment.