public void changeTextExtractorField ( MappedAttributeDefinition defn , ModelNode newValue , String extractorName ) throws RepositoryException , OperationFailedException { ModeShapeEngine engine = getEngine ( ) ; String repositoryName = repositoryName ( ) ; // Get a snapshot of the current configuration ... RepositoryConfiguration config = engine . getRepositoryConfiguration ( repositoryName ) ; // Now start to make changes ... Editor editor = config . edit ( ) ; // Find the array of sequencer documents ... List < String > pathToContainer = defn . getPathToContainerOfField ( ) ; EditableDocument textExtracting = editor . getOrCreateDocument ( pathToContainer . get ( 1 ) ) ; EditableDocument extractors = textExtracting . getOrCreateDocument ( pathToContainer . get ( 2 ) ) ; // The container should be an array ... for ( String configuredExtractorName : extractors . keySet ( ) ) { // Look for the entry with a name that matches our extractor name ... if ( extractorName . equals ( configuredExtractorName ) ) { // All these entries should be nested documents ... EditableDocument extractor = ( EditableDocument ) extractors . get ( configuredExtractorName ) ; // Change the field ... String fieldName = defn . getFieldName ( ) ; // Get the raw value from the model node ... Object rawValue = defn . getTypedValue ( newValue ) ; // And update the field ... extractor . set ( fieldName , rawValue ) ; break ; } } Changes changes = editor . getChanges ( ) ; engine . update ( repositoryName , changes ) ; }
Immediately change and apply the specified extractor field in the current repository configuration to the new value .