Program: 89455
Project: 89455
Buggy source:
/** 
 * @see org.alfresco.module.org_alfresco_module_rm.model.BaseTypeBehaviour#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef,boolean)
 */
@Behaviour(kind=BehaviourKind.ASSOCIATION,notificationFrequency=NotificationFrequency.TRANSACTION_COMMIT) public void onCreateChildAssociation(final ChildAssociationRef childAssocRef,boolean isNewNode){
  AuthenticationUtil.runAsSystem(new RunAsWork<Void>(){
    @Override public Void doWork() throws Exception {
      final NodeRef child=childAssocRef.getChildRef();
      if (nodeService.exists(child) == true) {
        QName childType=nodeService.getType(child);
        if (dictionaryService.isSubClass(childType,ContentModel.TYPE_FOLDER) == true) {
          if (dictionaryService.isSubClass(childType,ContentModel.TYPE_SYSTEM_FOLDER) == true) {
            nodeService.addAspect(child,ASPECT_FILE_PLAN_COMPONENT,null);
          }
 else {
            if (nodeService.hasAspect(child,ASPECT_FILE_PLAN_COMPONENT) == false) {
              nodeService.setType(child,TYPE_RECORD_FOLDER);
            }
            setIdenifierProperty(child);
          }
        }
 else {
          NodeRef parentRef=childAssocRef.getParentRef();
          QName parentType=nodeService.getType(parentRef);
          boolean isContentSubType=dictionaryService.isSubClass(childType,ContentModel.TYPE_CONTENT);
          boolean isUnfiledRecordContainerChild=parentType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER_CHILD);
          if (isContentSubType == true && isUnfiledRecordContainerChild == true) {
            if (nodeService.hasAspect(child,ASPECT_FILE_PLAN_COMPONENT) == false) {
              nodeService.addAspect(child,ASPECT_FILE_PLAN_COMPONENT,null);
            }
            if (nodeService.hasAspect(child,ASPECT_RECORD) == false) {
              recordService.makeRecord(child);
            }
          }
        }
      }
      return null;
    }
  }
);
}

Fixed version (ground truth):
/** 
 * @see org.alfresco.module.org_alfresco_module_rm.model.BaseTypeBehaviour#onCreateChildAssociation(org.alfresco.service.cmr.repository.ChildAssociationRef,boolean)
 */
@Behaviour(kind=BehaviourKind.ASSOCIATION,notificationFrequency=NotificationFrequency.TRANSACTION_COMMIT) public void onCreateChildAssociation(final ChildAssociationRef childAssocRef,boolean isNewNode){
  AuthenticationUtil.runAsSystem(new RunAsWork<Void>(){
    @Override public Void doWork() throws Exception {
      final NodeRef child=childAssocRef.getChildRef();
      if (nodeService.exists(child) == true) {
        QName childType=nodeService.getType(child);
        if (dictionaryService.isSubClass(childType,ContentModel.TYPE_FOLDER) == true) {
          if (dictionaryService.isSubClass(childType,ContentModel.TYPE_SYSTEM_FOLDER) == true) {
            nodeService.addAspect(child,ASPECT_FILE_PLAN_COMPONENT,null);
          }
 else {
            if (nodeService.hasAspect(child,ASPECT_FILE_PLAN_COMPONENT) == false) {
              nodeService.setType(child,TYPE_RECORD_FOLDER);
            }
            setIdenifierProperty(child);
          }
        }
 else {
          NodeRef parentRef=childAssocRef.getParentRef();
          QName parentType=nodeService.getType(parentRef);
          boolean isContentSubType=dictionaryService.isSubClass(childType,ContentModel.TYPE_CONTENT);
          boolean isUnfiledRecordContainer=parentType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER);
          boolean isUnfiledRecordContainerChild=parentType.equals(RecordsManagementModel.TYPE_UNFILED_RECORD_CONTAINER_CHILD);
          if (isContentSubType && (isUnfiledRecordContainer || isUnfiledRecordContainerChild)) {
            if (nodeService.hasAspect(child,ASPECT_FILE_PLAN_COMPONENT) == false) {
              nodeService.addAspect(child,ASPECT_FILE_PLAN_COMPONENT,null);
            }
            if (nodeService.hasAspect(child,ASPECT_RECORD) == false) {
              recordService.makeRecord(child);
            }
          }
        }
      }
      return null;
    }
  }
);
}