public ModuleItem next() { if (this.next == null) { this.hasNext(); } this.current = this.next; this.next = null; if (this.current == null) { throw new NoSuchElementException("No more elements to return"); } return new ModuleItem(this.repository, (Node) this.current); }
public ModuleItem next() { if (this.next == null) { this.hasNext(); } this.current = this.next; this.next = null; if (this.current == null) { throw new NoSuchElementException("No more elements to return"); } return new ModuleItem(this.repository, (Node) this.current); }
public ModuleItem next() { return new ModuleItem(this.rulesRepository, (Version) versionIterator.next()); }
public ModuleItem next() { return new ModuleItem(this.rulesRepository, (Version) versionIterator.next()); }
public ModuleItem loadModuleSnapshot(String moduleName, String snapshotName) { try { Node n = this.getAreaNode(MODULE_SNAPSHOT_AREA).getNode(moduleName).getNode(snapshotName); return new ModuleItem(this, n); } catch (RepositoryException e) { log.error(e.getMessage(), e); throw new RulesRepositoryException(e); } }
public ModuleItem loadModuleSnapshot(String moduleName, String snapshotName) { try { Node n = this.getAreaNode(MODULE_SNAPSHOT_AREA).getNode(moduleName).getNode(snapshotName); return new ModuleItem(this, n); } catch (RepositoryException e) { log.error(e.getMessage(), e); throw new RulesRepositoryException(e); } }
@Override public ModuleItem getPrecedingVersion() throws RulesRepositoryException { try { Node precedingVersionNode = this.getPrecedingVersionNode(); if (precedingVersionNode != null) { return new ModuleItem(this.rulesRepository, precedingVersionNode); } else { return null; } } catch (Exception e) { log.error("Caught exception", e); throw new RulesRepositoryException(e); } }
@Override public ModuleItem getSucceedingVersion() throws RulesRepositoryException { try { Node succeedingVersionNode = this.getSucceedingVersionNode(); if (succeedingVersionNode != null) { return new ModuleItem(this.rulesRepository, succeedingVersionNode); } else { return null; } } catch (Exception e) { log.error("Caught exception", e); throw new RulesRepositoryException(e); } }
@Override public ModuleItem getPrecedingVersion() throws RulesRepositoryException { try { Node precedingVersionNode = this.getPrecedingVersionNode(); if (precedingVersionNode != null) { return new ModuleItem(this.rulesRepository, precedingVersionNode); } else { return null; } } catch (Exception e) { log.error("Caught exception", e); throw new RulesRepositoryException(e); } }
@Override public ModuleItem getSucceedingVersion() throws RulesRepositoryException { try { Node succeedingVersionNode = this.getSucceedingVersionNode(); if (succeedingVersionNode != null) { return new ModuleItem(this.rulesRepository, succeedingVersionNode); } else { return null; } } catch (Exception e) { log.error("Caught exception", e); throw new RulesRepositoryException(e); } }
/** * Similar to above. Loads a ModuleItem for the specified uuid. * * @param uuid the uuid of the module to load * @return a ModuleItem object * @throws RulesRepositoryException */ public ModuleItem loadModuleByUUID(String uuid) throws RulesRepositoryException { try { Node moduleNode = this.session.getNodeByIdentifier(uuid); return new ModuleItem(this, moduleNode); } catch (Exception e) { log.error("Unable to load a module by UUID. ", e); if (e instanceof RuntimeException) { throw (RuntimeException) e; } else { throw new RulesRepositoryException("Unable to load a module. ", e); } } }
/** * Similar to above. Loads a ModuleItem for the specified uuid. * * @param uuid the uuid of the module to load * @return a ModuleItem object * @throws RulesRepositoryException */ public ModuleItem loadModuleByUUID(String uuid) throws RulesRepositoryException { try { Node moduleNode = this.session.getNodeByIdentifier(uuid); return new ModuleItem(this, moduleNode); } catch (Exception e) { log.error("Unable to load a module by UUID. ", e); if (e instanceof RuntimeException) { throw (RuntimeException) e; } else { throw new RulesRepositoryException("Unable to load a module. ", e); } } }
/** * Loads a Module for the specified module name. Will throw an * exception if the specified module does not exist. * * @param name the name of the module to load * @return a ModuleItem object */ public ModuleItem loadModule(String name) throws RulesRepositoryException { try { Node folderNode = this.getAreaNode(MODULE_AREA); Node moduleNode = folderNode.getNode(name); return new ModuleItem(this, moduleNode); } catch (RepositoryException e) { //the Global package should always exist. In case it is not (eg, when //an old db was imported to repo), we create it. if (GLOBAL_AREA.equals(name)) { log.info("Creating Global area as it does not exist yet."); return createModule(GLOBAL_AREA, "the global area that holds sharable assets"); } else { log.error("Unable to load a module. ", e); throw new RulesRepositoryException( "Unable to load a module. ", e); } } }
/** * Loads a Module for the specified module name. Will throw an * exception if the specified module does not exist. * * @param name the name of the module to load * @return a ModuleItem object */ public ModuleItem loadModule(String name) throws RulesRepositoryException { try { Node folderNode = this.getAreaNode(MODULE_AREA); Node moduleNode = folderNode.getNode(name); return new ModuleItem(this, moduleNode); } catch (RepositoryException e) { //the Global package should always exist. In case it is not (eg, when //an old db was imported to repo), we create it. if (GLOBAL_AREA.equals(name)) { log.info("Creating Global area as it does not exist yet."); return createModule(GLOBAL_AREA, "the global area that holds sharable assets"); } else { log.error("Unable to load a module. ", e); throw new RulesRepositoryException( "Unable to load a module. ", e); } } }
false); return new ModuleItem(this.rulesRepository, ruleSubPackageNode);
@Test public void testSortHistoryByVersionNumber() { ModuleItem item = new ModuleItem(); List l = new ArrayList(); AssetItem i1 = new MockAssetItem(42); AssetItem i2 = new MockAssetItem(1); l.add( i2 ); l.add( i1 ); assertEquals(i2, l.iterator().next()); item.sortHistoryByVersionNumber( l ); assertEquals(i1, l.iterator().next()); }
if (moduleNode.getPrimaryNodeType().getName() .equals(ModuleItem.MODULE_TYPE_NAME)) { return new ModuleItem(this, moduleNode); } else if (moduleNode.getPrimaryNodeType().getName()
/** * This will get the module an asset item belongs to. */ public ModuleItem getModule() { try { if ( this.isHistoricalVersion() ) { return this.rulesRepository.loadModule( this.getModuleName() ); } return new ModuleItem( this.rulesRepository, this.node.getParent().getParent() ); } catch ( RepositoryException e ) { throw new RulesRepositoryException( e ); } }
/** * This will get the module an asset item belongs to. */ public ModuleItem getModule() { try { if ( this.isHistoricalVersion() ) { return this.rulesRepository.loadModule( this.getModuleName() ); } return new ModuleItem( this.rulesRepository, this.node.getParent().getParent() ); } catch ( RepositoryException e ) { throw new RulesRepositoryException( e ); } }
@Test public void testPackageInstanceWrongNodeType() throws Exception { ModuleItem pack = getRepo().loadDefaultModule(); AssetItem rule = pack.addAsset( "packageInstanceWrongNodeType", "" ); try { new ModuleItem(this.getRepo(), rule.getNode()); fail("Can't create a package from a rule node."); } catch (RulesRepositoryException e) { assertNotNull(e.getMessage()); } }