private boolean validateExistingTopicTags ( final ITopicNode topicNode , final BaseTopicWrapper < ? > topic ) { // Ignore validating revision topics if ( topicNode . getRevision ( ) != null ) { return true ; } boolean valid = true ; final List < String > tagNames = topicNode . getTags ( true ) ; if ( ! tagNames . isEmpty ( ) ) { final Set < TagWrapper > tags = new HashSet < TagWrapper > ( ) ; for ( final String tagName : tagNames ) { // Check if the app should be shutdown if ( isShuttingDown . get ( ) ) { shutdown . set ( true ) ; return false ; } // Get the tag from the database TagWrapper tag = null ; try { tag = tagProvider . getTagByName ( tagName ) ; } catch ( NotFoundException e ) { } // Check that it exists if ( tag != null ) { tags . add ( tag ) ; } } // Add all the existing tags if ( topic . getTags ( ) != null ) { tags . addAll ( topic . getTags ( ) . getItems ( ) ) ; } // Check that the mutex value entered is correct final Map < Integer , List < TagWrapper > > mapping = EntityUtilities . getCategoryMappingFromTagList ( tags ) ; for ( final Entry < Integer , List < TagWrapper > > catEntry : mapping . entrySet ( ) ) { final CategoryWrapper cat = categoryProvider . getCategory ( catEntry . getKey ( ) ) ; final List < TagWrapper > catTags = catEntry . getValue ( ) ; // Check if the app should be shutdown if ( isShuttingDown . get ( ) ) { shutdown . set ( true ) ; return false ; } // Check that only one tag has been set if the category is mutually exclusive if ( cat . isMutuallyExclusive ( ) && catTags . size ( ) > 1 ) { log . error ( String . format ( ProcessorConstants . ERROR_TOPIC_TOO_MANY_CATS_MSG , topicNode . getLineNumber ( ) , cat . getName ( ) , topicNode . getText ( ) ) ) ; valid = false ; } } } return valid ; }
Checks that adding tags to existing topic won t cause problems