void checkout ( AbstractJcrNode node ) throws LockException , RepositoryException { checkVersionable ( node ) ; // Check this separately since it throws a different type of exception if ( node . isLocked ( ) && ! node . holdsLock ( ) ) { throw new LockException ( JcrI18n . lockTokenNotHeld . text ( node . getPath ( ) ) ) ; } if ( ! node . hasProperty ( JcrLexicon . BASE_VERSION ) ) { // This happens when we've added mix:versionable, but not saved it to create the base // version (and the rest of the version storage graph). See MODE-704. return ; } // Checking out an already checked-out node is supposed to return silently if ( node . getProperty ( JcrLexicon . IS_CHECKED_OUT ) . getBoolean ( ) ) { return ; } // Create a session that we'll used to change the node ... SessionCache versionSession = session . spawnSessionCache ( false ) ; MutableCachedNode versionable = versionSession . mutable ( node . key ( ) ) ; NodeKey baseVersionKey = node . getBaseVersion ( ) . key ( ) ; PropertyFactory props = propertyFactory ( ) ; Reference baseVersionRef = session . referenceFactory ( ) . create ( baseVersionKey , true ) ; versionable . setProperty ( versionSession , props . create ( JcrLexicon . PREDECESSORS , new Object [ ] { baseVersionRef } ) ) ; versionable . setProperty ( versionSession , props . create ( JcrLexicon . IS_CHECKED_OUT , Boolean . TRUE ) ) ; versionSession . save ( ) ; }
Checks out the given node updating version - related properties on the node as needed .