public AssetHistoryIterator(RulesRepository rulesRepository, Node head) { this.head = head; this.rulesRepository = rulesRepository; try { this.versionIterator = VersionableItem.getVersionManager(head).getVersionHistory(head.getPath()).getAllVersions(); } catch ( RepositoryException e ) { throw new RulesRepositoryException( e ); } }
public ModuleHistoryIterator(RulesRepository rulesRepository, Node head) { this.head = head; this.rulesRepository = rulesRepository; try { this.versionIterator = VersionableItem.getVersionManager(head).getVersionHistory(head.getPath()).getAllVersions(); } catch ( RepositoryException e ) { throw new RulesRepositoryException( e ); } }
public ModuleHistoryIterator(RulesRepository rulesRepository, Node head) { this.head = head; this.rulesRepository = rulesRepository; try { this.versionIterator = VersionableItem.getVersionManager(head).getVersionHistory(head.getPath()).getAllVersions(); } catch ( RepositoryException e ) { throw new RulesRepositoryException( e ); } }
public AssetHistoryIterator(RulesRepository rulesRepository, Node head) { this.head = head; this.rulesRepository = rulesRepository; try { this.versionIterator = VersionableItem.getVersionManager(head).getVersionHistory(head.getPath()).getAllVersions(); } catch ( RepositoryException e ) { throw new RulesRepositoryException( e ); } }
getVersionManager(targetNode).checkout(targetNode.getPath()); } catch ( UnsupportedRepositoryOperationException e ) { String message = "";
versionNode = this.node; } else { versionNode = getVersionManager(this.node).getBaseVersion(this.node.getPath());
getVersionManager(targetNode).checkout(targetNode.getPath()); } catch ( UnsupportedRepositoryOperationException e ) { String message = "";
versionNode = this.node; } else { versionNode = getVersionManager(this.node).getBaseVersion(this.node.getPath());
/** * 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 ); } }
@Test public void testUpdateContent() throws Exception { AssetItem ruleItem1 = getDefaultPackage().addAsset("testUpdateContent", "test description"); assertFalse(ruleItem1.getCreator().equals( "" )); ruleItem1.updateContent( "test content" ); ruleItem1.checkin( "yeah" ); assertFalse(ruleItem1.getLastContributor().equals( "" )); ruleItem1.updateContent( "new rule content"); assertEquals("new rule content", ruleItem1.getContent()); assertTrue(ruleItem1.getNode().getSession().hasPendingChanges()); ruleItem1.checkin( "yeah !" ); assertFalse(ruleItem1.getNode().getSession().hasPendingChanges()); assertEquals("yeah !", ruleItem1.getCheckinComment()); AssetItem prev = (AssetItem) ruleItem1.getPrecedingVersion(); assertEquals("test content", prev.getContent()); assertFalse("yeah !".equals(prev.getCheckinComment())); assertEquals(prev, ruleItem1.getPrecedingVersion()); ruleItem1 = getDefaultPackage().loadAsset( "testUpdateContent" ); VersionIterator it = VersionableItem.getVersionManager(ruleItem1.getNode()).getVersionHistory(ruleItem1.getNode().getPath()).getAllVersions(); // and this shows using a version iterator. // perhaps migrate to using this rather then next/prev methods. //this way, we can skip. assertTrue(it.hasNext()); while (it.hasNext()) { Version n = it.nextVersion(); AssetItem item = new AssetItem(ruleItem1.getRulesRepository(), n); assertNotNull(item); } }