public AssetItem next() { return new AssetItem(rulesRepository, it.nextNode()); }
public AssetItem next() { return new AssetItem(rulesRepository, it.nextNode()); }
public AssetItem next() { return new AssetItem(this.rulesRepository, (Version) versionIterator.next()); }
public AssetItem next() { return new AssetItem(this.rulesRepository, (Version) versionIterator.next()); }
/** * Load a specific asset by name. */ public AssetItem loadAsset(String name) { try { Node content = getVersionContentNode(); return new AssetItem( this.rulesRepository, content.getNode(ASSET_FOLDER_NAME).getNode(name)); } catch (RepositoryException e) { throw new RulesRepositoryException(e); } }
/** * Load a specific asset by name. */ public AssetItem loadAsset(String name) { try { Node content = getVersionContentNode(); return new AssetItem( this.rulesRepository, content.getNode(ASSET_FOLDER_NAME).getNode(name)); } catch (RepositoryException e) { throw new RulesRepositoryException(e); } }
public VersionableItem getPrecedingVersion() throws RulesRepositoryException { try { Node precedingVersionNode = this.getPrecedingVersionNode(); if ( precedingVersionNode != null ) { return new AssetItem( this.rulesRepository, precedingVersionNode ); } else { return null; } } catch ( Exception e ) { log.error( "Caught exception", e ); throw new RulesRepositoryException( e ); } }
public VersionableItem getSucceedingVersion() throws RulesRepositoryException { try { Node succeedingVersionNode = this.getSucceedingVersionNode(); if ( succeedingVersionNode != null ) { return new AssetItem( this.rulesRepository, succeedingVersionNode ); } else { return null; } } catch ( Exception e ) { log.error( "Caught exception", e ); throw new RulesRepositoryException( e ); } }
public VersionableItem getPrecedingVersion() throws RulesRepositoryException { try { Node precedingVersionNode = this.getPrecedingVersionNode(); if ( precedingVersionNode != null ) { return new AssetItem( this.rulesRepository, precedingVersionNode ); } else { return null; } } catch ( Exception e ) { log.error( "Caught exception", e ); throw new RulesRepositoryException( e ); } }
public VersionableItem getSucceedingVersion() throws RulesRepositoryException { try { Node succeedingVersionNode = this.getSucceedingVersionNode(); if ( succeedingVersionNode != null ) { return new AssetItem( this.rulesRepository, succeedingVersionNode ); } else { return null; } } catch ( Exception e ) { log.error( "Caught exception", e ); throw new RulesRepositoryException( e ); } }
/** * Loads an asset by its UUID (generally the fastest way to load something). */ public AssetItem loadAssetByUUID(String uuid) { try { Node moduleNode = this.session.getNodeByIdentifier(uuid); return new AssetItem(this, moduleNode); } catch (ItemNotFoundException e) { log.warn(e.getMessage(), e); throw new RulesRepositoryException("That item does not exist."); } catch (RepositoryException e) { log.error("Unable to load an asset by UUID.", e); throw new RulesRepositoryException(e); } }
/** * Loads an asset by its UUID (generally the fastest way to load something). */ public AssetItem loadAssetByUUID(String uuid) { try { Node moduleNode = this.session.getNodeByIdentifier(uuid); return new AssetItem(this, moduleNode); } catch (ItemNotFoundException e) { log.warn(e.getMessage(), e); throw new RulesRepositoryException("That item does not exist."); } catch (RepositoryException e) { log.error("Unable to load an asset by UUID.", e); throw new RulesRepositoryException(e); } }
} else if (moduleNode.getPrimaryNodeType().getName() .equals(AssetItem.ASSET_NODE_TYPE_NAME)) { return new AssetItem(this, moduleNode);
return new AssetItem(this.rulesRepository, assetNode); } catch (RepositoryException e) {
return new AssetItem(this.rulesRepository, assetNode); } catch (RepositoryException e) {
} else if (moduleNode.getPrimaryNodeType().getName() .equals(AssetItem.ASSET_NODE_TYPE_NAME)) { return new AssetItem(this, moduleNode);
if (isNotSnapshot(parentNode) && parentNode.getPrimaryNodeType().getName().equals(AssetItem.ASSET_NODE_TYPE_NAME)) { if (seekArchivedAsset || !parentNode.getProperty(AssetItem.CONTENT_PROPERTY_ARCHIVE_FLAG).getBoolean()) { AssetItem ai = new AssetItem(this, parentNode); if (filter == null || filter.accept(ai,
@Test public void testAssetItemFilterAndAccepts() { AssetItemFilter filter = new AssetItemFilter(null); assertTrue( filter.accept( new AssetItem(), "action" ) ); }
@Test public void testAssetItemCreation() throws Exception { Calendar now = Calendar.getInstance(); Thread.sleep(500); //MN: need this sleep to get the correct date AssetItem ruleItem1 = getDefaultPackage().addAsset("testRuleItem", "test content"); assertNotNull(ruleItem1); assertNotNull(ruleItem1.getNode()); assertEquals("testRuleItem", ruleItem1.getName()); assertNotNull(ruleItem1.getCreatedDate()); assertTrue(now.before( ruleItem1.getCreatedDate() )); String packName = getDefaultPackage().getName(); assertEquals(packName, ruleItem1.getModuleName()); assertNotNull(ruleItem1.getUUID()); //try constructing with node of wrong type try { ModuleItem pitem = getRepo().loadDefaultModule(); new AssetItem(getRepo(), pitem.getNode()); fail("Exception not thrown for node of wrong type"); } catch(RulesRepositoryException e) { assertNotNull(e.getMessage()); } catch(Exception e) { fail("Caught unexpected exception: " + 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); } }