private boolean assetHasHistory(AssetItem asset) { AssetHistoryIterator it = asset.getHistory(); while ( it.hasNext() ) { VersionableItem historical = (VersionableItem) it.next(); long versionNumber = historical.getVersionNumber(); if ( versionNumber != 0) { //Version 0 is not a real version. It is the root version return true; } } return false; } /**
private boolean assetHasHistory(AssetItem asset) { AssetHistoryIterator it = asset.getHistory(); while ( it.hasNext() ) { VersionableItem historical = (VersionableItem) it.next(); long versionNumber = historical.getVersionNumber(); if ( versionNumber != 0) { //Version 0 is not a real version. It is the root version return true; } } return false; } /**
/** * This will save the content (if it hasn't been already) and * then check it in to create a new version. * It will also set the last modified property. */ public void checkin(String comment) { checkIsUpdateable(); checkInAssetIfNecessary(false); try { this.node.setProperty( LAST_MODIFIED_PROPERTY_NAME, Calendar.getInstance() ); this.node.setProperty( CHECKIN_COMMENT, comment ); this.node.setProperty( LAST_CONTRIBUTOR_PROPERTY_NAME, this.node.getSession().getUserID() ); long nextVersion = getVersionNumber() + 1; this.node.setProperty( VERSION_NUMBER_PROPERTY_NAME, nextVersion ); this.node.getSession().save(); getVersionManager(this.node).checkin(this.node.getPath()); if (StorageEventManager.hasSaveEvent()) { if (this instanceof AssetItem) { StorageEventManager.getSaveEvent().onAssetCheckin((AssetItem) this); } } StorageEventManager.doCheckinEvents(this); } catch ( RepositoryException e ) { throw new RulesRepositoryException( "Unable to checkin.", e ); } }
/** * This will save the content (if it hasn't been already) and * then check it in to create a new version. * It will also set the last modified property. */ public void checkin(String comment) { checkIsUpdateable(); checkInAssetIfNecessary(false); try { this.node.setProperty( LAST_MODIFIED_PROPERTY_NAME, Calendar.getInstance() ); this.node.setProperty( CHECKIN_COMMENT, comment ); this.node.setProperty( LAST_CONTRIBUTOR_PROPERTY_NAME, this.node.getSession().getUserID() ); long nextVersion = getVersionNumber() + 1; this.node.setProperty( VERSION_NUMBER_PROPERTY_NAME, nextVersion ); this.node.getSession().save(); getVersionManager(this.node).checkin(this.node.getPath()); if (StorageEventManager.hasSaveEvent()) { if (this instanceof AssetItem) { StorageEventManager.getSaveEvent().onAssetCheckin((AssetItem) this); } } StorageEventManager.doCheckinEvents(this); } catch ( RepositoryException e ) { throw new RulesRepositoryException( "Unable to checkin.", e ); } }