NodeChange implements

        BeforeDeleteNodePolicy, OnAddAspectPolicy, OnCreateNodePolicy, OnMoveNodePolicy,
        OnRemoveAspectPolicy, OnUpdatePropertiesPolicy,

        OnContentReadPolicy, OnContentUpdatePolicy,

        OnCreateVersionPolicy,

        OnCopyCompletePolicy,
        
        OnCheckOut, OnCheckIn, OnCancelCheckOut { public Map<String, Serializable> getAuditData(boolean subAction) { Map<String, Serializable> auditMap = new HashMap<String, Serializable>( 2 * (1 + 1 + 1 + 3 + 3 + 3 + (fromProperties != null ? fromProperties.size() + toProperties.size() + 4 : 0) + (addedAspects != null ? addedAspects.size() : 0) + (deletedAspects != null ? deletedAspects.size() : 0) + (versionProperties != null ? versionProperties.size()+1 : 0) + getSubAuditDataSize())); if (!subAction) { setAction(getDerivedAction()); } auditMap.put(ACTION, action); if (!subAction) { auditMap.put(USER, AuthenticationUtil.getFullyAuthenticatedUser()); addSubActionsToAuditMap(auditMap); auditMap.put(NODE, nodeInfo.getNodeRef()); auditMap.put(PATH, nodeInfo.getPrefixPath()); auditMap.put(TYPE, nodeInfo.getPrefixType()); } if (copyFrom != null) { auditMap.put(buildPath(COPY, FROM, NODE), copyFrom.getNodeRef()); auditMap.put(buildPath(COPY, FROM, PATH), copyFrom.getPrefixPath()); auditMap.put(buildPath(COPY, FROM, TYPE), copyFrom.getPrefixType()); } if (moveFrom != null) { auditMap.put(buildPath(MOVE, FROM, NODE), moveFrom.getNodeRef()); auditMap.put(buildPath(MOVE, FROM, PATH), moveFrom.getPrefixPath()); auditMap.put(buildPath(MOVE, FROM, TYPE), moveFrom.getPrefixType()); } if (fromProperties != null) { addPropertyChangesToAuditMap(auditMap, subAction); } if (addedAspects != null && !addedAspects.isEmpty()) { addAspectChangesToAuditMap(auditMap, ADD, addedAspects, subAction); } if (deletedAspects != null && !deletedAspects.isEmpty()) { addAspectChangesToAuditMap(auditMap, DELETE, deletedAspects, subAction); } if (versionProperties != null && !versionProperties.isEmpty()) { addVersionPropertiesToAuditMap(auditMap, versionProperties, subAction); } addSubActionAuditMapsToAuditMap(auditMap); return auditMap; } NodeChange(NodeInfoFactory nodeInfoFactory, NamespaceService namespaceService, NodeRef nodeRef); String getDerivedAction(); boolean isTemporaryNode(); NodeChange setAuditSubActions(boolean auditSubActions); @Override void beforeDeleteNode(NodeRef nodeRef); @Override void onCreateNode(ChildAssociationRef childAssocRef); @Override void onMoveNode(ChildAssociationRef fromChildAssocRef, ChildAssociationRef toChildAssocRef); @Override void onUpdateProperties(NodeRef nodeRef,
            Map<QName, Serializable> fromProperties, Map<QName, Serializable> toProperties); @Override void onRemoveAspect(NodeRef nodeRef, QName aspect); @Override void onAddAspect(NodeRef nodeRef, QName aspect); @Override void onContentUpdate(NodeRef nodeRef, boolean newContent); @Override void onContentRead(NodeRef nodeRef); @Override void onCreateVersion(QName classRef, NodeRef nodeRef,
            Map<String, Serializable> versionProperties, PolicyScope nodeDetails); void onCopyComplete(QName classRef, NodeRef sourceNodeRef, NodeRef targetNodeRef,
            boolean copyToNewNode, Map<NodeRef, NodeRef> copyMap); void onCheckOut(NodeRef workingCopy); void onCheckIn(NodeRef nodeRef); void onCancelCheckOut(NodeRef nodeRef); Map<String, Serializable> getAuditData(boolean subAction); static final String SUB_ACTION; static Collection<String> SUMMARY_KEYS; static final String SUB_ACTION_PREFIX; }
@Test public final void testGetAuditDataTrueSubAction() { callCreateNode(); Map<String, Serializable> auditMap = nodeChange.getAuditData(true); assertEquals("Should NOT be derived", "createNode", auditMap.get("action")); assertFalse("'user' should not exist in a subAction", auditMap.keySet().contains("user")); assertFalse("'sub-actions' should not exist in a subAction", auditMap.keySet().contains("sub-actions")); assertFalse("'node' should not exist in a subAction", auditMap.keySet().contains("node")); assertFalse("'path' should not exist in a subAction", auditMap.keySet().contains("path")); assertFalse("'type' should not exist in a subAction", auditMap.keySet().contains("type")); }
@Test public final void testGetAuditDataFalseTopLevelAction() { callCreateNode(); Map<String, Serializable> auditMap = nodeChange.getAuditData(false); assertEquals("Should be derived", "CREATE", auditMap.get("action")); assertTrue("'user' should exist if not a subAction", auditMap.keySet().contains("user")); assertTrue("'sub-actions' should exist if not a subAction", auditMap.keySet().contains("sub-actions")); assertTrue("'node' should exist if not a subAction", auditMap.keySet().contains("node")); assertTrue("'path' should exist if not a subAction", auditMap.keySet().contains("path")); assertTrue("'type' should exist if not a subAction", auditMap.keySet().contains("type")); }