Skip to content

Commit

Permalink
don't sync sym_node_security changes if the registration_enabled or i…
Browse files Browse the repository at this point in the history
…nitial_load_enabled flags are changing
  • Loading branch information
chenson42 committed Nov 21, 2011
1 parent 72985b4 commit 01d2f4c
Showing 1 changed file with 35 additions and 6 deletions.
Expand Up @@ -25,9 +25,11 @@
import java.util.Map;
import java.util.Set;

import org.apache.commons.lang.StringUtils;
import org.jumpmind.symmetric.common.ParameterConstants;
import org.jumpmind.symmetric.common.TableConstants;
import org.jumpmind.symmetric.common.logging.LogFactory;
import org.jumpmind.symmetric.model.DataEventType;
import org.jumpmind.symmetric.model.DataMetaData;
import org.jumpmind.symmetric.model.NetworkedNode;
import org.jumpmind.symmetric.model.Node;
Expand Down Expand Up @@ -79,6 +81,10 @@ public Set<String> routeToNodes(IRouterContext routingContext,
// goes to.
if (tableMatches(dataMetaData, TableConstants.SYM_NODE)
|| tableMatches(dataMetaData, TableConstants.SYM_NODE_SECURITY)) {

if (didNodeSecurityChangeForNodeInitialization(dataMetaData)) {
return null;
}

String nodeIdInQuestion = columnValues.get("NODE_ID");
List<NodeGroupLink> nodeGroupLinks = getNodeGroupLinksFromContext(routingContext);
Expand All @@ -103,12 +109,16 @@ public Set<String> routeToNodes(IRouterContext routingContext,
}
}

if (tableMatches(dataMetaData, TableConstants.SYM_TRIGGER)
|| tableMatches(dataMetaData, TableConstants.SYM_TRIGGER_ROUTER)
|| tableMatches(dataMetaData, TableConstants.SYM_ROUTER)
|| tableMatches(dataMetaData, TableConstants.SYM_NODE_GROUP_LINK)) {
routingContext.getContextCache().put(CTX_KEY_RESYNC_NEEDED, Boolean.TRUE);
}
if (StringUtils.isBlank(dataMetaData.getData().getSourceNodeId())
&& (tableMatches(dataMetaData, TableConstants.SYM_TRIGGER)
|| tableMatches(dataMetaData,
TableConstants.SYM_TRIGGER_ROUTER)
|| tableMatches(dataMetaData,
TableConstants.SYM_ROUTER) || tableMatches(
dataMetaData, TableConstants.SYM_NODE_GROUP_LINK))) {
routingContext.getContextCache().put(CTX_KEY_RESYNC_NEEDED,
Boolean.TRUE);
}

if (tableMatches(dataMetaData, TableConstants.SYM_CHANNEL)) {
routingContext.getContextCache().put(CTX_KEY_FLUSH_CHANNELS_NEEDED, Boolean.TRUE);
Expand All @@ -122,6 +132,25 @@ public Set<String> routeToNodes(IRouterContext routingContext,

return nodeIds;
}

/**
* Check to see if the change was due to registration or initial load is being enabled or disabled. If
* so, then don't propagate the change.
*/
protected boolean didNodeSecurityChangeForNodeInitialization(DataMetaData dataMetaData) {
if (tableMatches(dataMetaData, TableConstants.SYM_NODE_SECURITY) && dataMetaData.getData().getEventType() == DataEventType.UPDATE) {
Map<String,String> oldData = getOldDataAsString("", dataMetaData);
Map<String,String> newData = getNewDataAsString("", dataMetaData);
if (newData.get("REGISTRATION_ENABLED") != null &&
!newData.get("REGISTRATION_ENABLED").equals(oldData.get("REGISTRATION_ENABLED"))) {
return true;
} else if (newData.get("INITIAL_LOAD_ENABLED") != null &&
!newData.get("INITIAL_LOAD_ENABLED").equals(oldData.get("INITIAL_LOAD_ENABLED"))) {
return true;
}
}
return false;
}

protected Node findIdentity() {
return nodeService.findIdentity();
Expand Down

0 comments on commit 01d2f4c

Please sign in to comment.