public void overWriteAssetData ( RepositoryResourceImpl fromResource , boolean includeAttachmentInfo ) throws RepositoryResourceValidationException { // Make sure we are dealing with the same type....this // should never happen if ( ! fromResource . getClass ( ) . getName ( ) . equals ( getClass ( ) . getName ( ) ) ) { throw new RepositoryResourceValidationException ( "Expected class of type " + getClass ( ) . getName ( ) + " but was " + fromResource . getClass ( ) . getName ( ) , this . getId ( ) ) ; } // copy the stuff into target fromResource . copyFieldsFrom ( this , includeAttachmentInfo ) ; // Now use target _asset = fromResource . _asset ; }
This method copies the fields from this that we care about to the fromResource . Then we set our asset to point to the one in fromResource . In effect this means we get all the details from the fromResource and override fields we care about and store the merged result in our asset .