public boolean preValidateRelationships(final ContentSpec contentSpec) {
        boolean error = false;

        // Create the map of unique ids to spec topics
        final Map<String, List<ITopicNode>> specTopicMap = ContentSpecUtilities.getIdTopicNodeMap(contentSpec);

        final Map<SpecNodeWithRelationships, List<Relationship>> relationships = contentSpec.getRelationships();
        for (final Entry<SpecNodeWithRelationships, List<Relationship>> relationshipEntry : relationships.entrySet()) {
            final SpecNodeWithRelationships specNode = relationshipEntry.getKey();

            // Check if the app should be shutdown
            if (isShuttingDown.get()) {
                shutdown.set(true);
                return false;
            }

            for (final Relationship relationship : relationshipEntry.getValue()) {
                // Check if the app should be shutdown
                if (isShuttingDown.get()) {
                    shutdown.set(true);
                    return false;
                }

                final String relatedId = relationship.getSecondaryRelationshipId();
                // The relationship points to a target so it must be a level or topic
                if (relationship instanceof TargetRelationship) {
                    final SpecNode node = ((TargetRelationship) relationship).getSecondaryRelationship();
                    if (node instanceof SpecTopic) {
                        final SpecTopic targetTopic = (SpecTopic) node;
                        if (!validateRelationshipToTopic(relationship, specNode, relatedId, targetTopic, specTopicMap)) {
                            error = true;
                        }
                    } else if (node instanceof Level) {
                        final Level targetLevel = (Level) node;
                        if (!validateRelationshipToLevel(relationship, specNode, targetLevel)) {
                            error = true;
                        }
                    }
                } else if (relationship instanceof TopicRelationship) {
                    final SpecTopic relatedTopic = ((TopicRelationship) relationship).getSecondaryRelationship();
                    if (!validateRelationshipToTopic(relationship, specNode, relatedId, relatedTopic, specTopicMap)) {
                        error = true;
                    }
                }
            }
        }
        return !error;
    }
public boolean preValidateRelationships ( final ContentSpec contentSpec ) { boolean error = false ; final Map < String , List < ITopicNode > > specTopicMap = ContentSpecUtilities . getIdTopicNodeMap ( contentSpec ) ; final Map < SpecNodeWithRelationships , List < Relationship > > relationships = contentSpec . getRelationships ( ) ; for ( final Entry < SpecNodeWithRelationships , List < Relationship > > relationshipEntry : relationships . entrySet ( ) ) { final SpecNodeWithRelationships specNode = relationshipEntry . getKey ( ) ; if ( isShuttingDown . get ( ) ) { shutdown . set ( true ) ; return false ; } for ( final Relationship relationship : relationshipEntry . getValue ( ) ) { if ( isShuttingDown . get ( ) ) { shutdown . set ( true ) ; return false ; } final String relatedId = relationship . getSecondaryRelationshipId ( ) ; if ( relationship instanceof TargetRelationship ) { final SpecNode node = ( ( TargetRelationship ) relationship ) . getSecondaryRelationship ( ) ; if ( node instanceof SpecTopic ) { final SpecTopic targetTopic = ( SpecTopic ) node ; if ( ! validateRelationshipToTopic ( relationship , specNode , relatedId , targetTopic , specTopicMap ) ) { error = true ; } } else if ( node instanceof Level ) { final Level targetLevel = ( Level ) node ; if ( ! validateRelationshipToLevel ( relationship , specNode , targetLevel ) ) { error = true ; } } } else if ( relationship instanceof TopicRelationship ) { final SpecTopic relatedTopic = ( ( TopicRelationship ) relationship ) . getSecondaryRelationship ( ) ; if ( ! validateRelationshipToTopic ( relationship , specNode , relatedId , relatedTopic , specTopicMap ) ) { error = true ; } } } } return ! error ; }
Validate a set of relationships created when parsing.

@param contentSpec The content spec to be validated.
@return True if the relationships are valid, otherwise false.