private boolean performAction ( Progress progress , int progressCount , IndexAction indexAction ) { requireNonNull ( indexAction ) ; String entityTypeId = indexAction . getEntityTypeId ( ) ; updateIndexActionStatus ( indexAction , IndexActionMetadata . IndexStatus . STARTED ) ; try { if ( dataService . hasEntityType ( entityTypeId ) ) { EntityType entityType = dataService . getEntityType ( entityTypeId ) ; if ( indexAction . getEntityId ( ) != null ) { progress . progress ( progressCount , format ( "Indexing {0}.{1}" , entityType . getId ( ) , indexAction . getEntityId ( ) ) ) ; rebuildIndexOneEntity ( entityTypeId , indexAction . getEntityId ( ) ) ; } else { progress . progress ( progressCount , format ( "Indexing {0}" , entityType . getId ( ) ) ) ; final Repository < Entity > repository = dataService . getRepository ( entityType . getId ( ) ) ; indexService . rebuildIndex ( repository ) ; } } else { EntityType entityType = getEntityType ( indexAction ) ; if ( indexService . hasIndex ( entityType ) ) { progress . progress ( progressCount , format ( "Dropping entityType with id: {0}" , entityType . getId ( ) ) ) ; indexService . deleteIndex ( entityType ) ; } else { // Index Job is finished, here we concluded that we don't have enough info to continue the // index job progress . progress ( progressCount , format ( "Skip index entity {0}.{1}" , entityType . getId ( ) , indexAction . getEntityId ( ) ) ) ; } } updateIndexActionStatus ( indexAction , IndexActionMetadata . IndexStatus . FINISHED ) ; return true ; } catch ( Exception ex ) { LOG . error ( "Index job failed" , ex ) ; updateIndexActionStatus ( indexAction , IndexActionMetadata . IndexStatus . FAILED ) ; return false ; } }
Performs a single IndexAction