public void changeField ( MappedAttributeDefinition defn , ModelNode newValue ) 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 Document containing the field ... EditableDocument fieldContainer = editor ; for ( String fieldName : defn . getPathToContainerOfField ( ) ) { fieldContainer = editor . getOrCreateDocument ( fieldName ) ; } // Get the raw value from the model node ... Object rawValue = defn . getTypedValue ( newValue ) ; // Change the field ... String fieldName = defn . getFieldName ( ) ; fieldContainer . set ( fieldName , rawValue ) ; // Apply the changes to the current configuration ... Changes changes = editor . getChanges ( ) ; engine . update ( repositoryName , changes ) ; }
Immediately change and apply the specified field in the current repository configuration to the new value .