/** * This will create a child category under this one */ public CategoryItem addCategory(String name, String description) { try { String nodePath = NodeUtils.makeJSR170ComplaintName(name); Node child = this.node.addNode(nodePath, CategoryItem.TAG_NODE_TYPE_NAME); this.rulesRepository.getSession().save(); return new CategoryItem(this.rulesRepository, child); } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else { throw new RulesRepositoryException(e); } } }
/** * This will copy the module to the snapshot area. Creating a copy for * deployment, etc. */ public void createModuleSnapshot(String moduleName, String snapshotName) { log.debug("Creating snapshot for [" + moduleName + "] called [" + snapshotName + "]"); try { Node snaps = this.getAreaNode(MODULE_SNAPSHOT_AREA); String nodePath = NodeUtils.makeJSR170ComplaintName(moduleName); if (!snaps.hasNode(nodePath)) { snaps.addNode(nodePath, "nt:folder"); save(); } String newName = snaps.getNode(nodePath).getPath() + "/" + snapshotName; Node moduleNode = this.getAreaNode(MODULE_AREA).getNode(moduleName); long start = System.currentTimeMillis(); this.session.getWorkspace().copy(moduleNode.getPath(), newName); log.debug("Time taken for snap: " + (System.currentTimeMillis() - start)); } catch (RepositoryException e) { log.error("Unable to create snapshot", e); throw new RulesRepositoryException(e); } }
/** * This will copy the module to the snapshot area. Creating a copy for * deployment, etc. */ public void createModuleSnapshot(String moduleName, String snapshotName) { log.debug("Creating snapshot for [" + moduleName + "] called [" + snapshotName + "]"); try { Node snaps = this.getAreaNode(MODULE_SNAPSHOT_AREA); String nodePath = NodeUtils.makeJSR170ComplaintName(moduleName); if (!snaps.hasNode(nodePath)) { snaps.addNode(nodePath, "nt:folder"); save(); } String newName = snaps.getNode(nodePath).getPath() + "/" + snapshotName; Node moduleNode = this.getAreaNode(MODULE_AREA).getNode(moduleName); long start = System.currentTimeMillis(); this.session.getWorkspace().copy(moduleNode.getPath(), newName); log.debug("Time taken for snap: " + (System.currentTimeMillis() - start)); } catch (RepositoryException e) { log.error("Unable to create snapshot", e); throw new RulesRepositoryException(e); } }
/** * This will create a child category under this one */ public CategoryItem addCategory(String name, String description) { try { String nodePath = NodeUtils.makeJSR170ComplaintName(name); Node child = this.node.addNode(nodePath, CategoryItem.TAG_NODE_TYPE_NAME); this.rulesRepository.getSession().save(); return new CategoryItem(this.rulesRepository, child); } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } else { throw new RulesRepositoryException(e); } } }
/** * Create a status node of the given name. */ public StateItem createState(String name) { try { Node folderNode = this.getAreaNode(STATE_AREA); String nodePath = NodeUtils.makeJSR170ComplaintName(name); Node stateNode = RulesRepository.addNodeIfNew(folderNode, nodePath, StateItem.STATE_NODE_TYPE_NAME); log.debug("Created the status [" + name + "] at [" + nodePath + "]"); return new StateItem(this, stateNode); } catch (Exception e) { log.error(e.getMessage(), e); throw new RulesRepositoryException(e); } }
/** * Create a status node of the given name. */ public StateItem createState(String name) { try { Node folderNode = this.getAreaNode(STATE_AREA); String nodePath = NodeUtils.makeJSR170ComplaintName(name); Node stateNode = RulesRepository.addNodeIfNew(folderNode, nodePath, StateItem.STATE_NODE_TYPE_NAME); log.debug("Created the status [" + name + "] at [" + nodePath + "]"); return new StateItem(this, stateNode); } catch (Exception e) { log.error(e.getMessage(), e); throw new RulesRepositoryException(e); } }
/** * Gets a StateItem for the specified state name. If a node for the * specified state does not yet exist, one is first created. * * @param name the name of the state to get * @return a StateItem object encapsulating the retrieved node * @throws RulesRepositoryException */ public StateItem getState(String name) throws RulesRepositoryException { try { Node folderNode = this.getAreaNode(STATE_AREA); String nodePath = NodeUtils.makeJSR170ComplaintName(name); if (!folderNode.hasNode(nodePath)) { throw new RulesRepositoryException("The state called [" + name + "] does not exist."); } Node stateNode = folderNode.getNode(nodePath); // RulesRepository.addNodeIfNew(folderNode, name, StateItem.STATE_NODE_TYPE_NAME); return new StateItem(this, stateNode); } catch (Exception e) { log.error(e.getMessage(), e); throw new RulesRepositoryException(e); } }
String assetPath = NodeUtils.makeJSR170ComplaintName(subModuleName); Node ruleSubPackageNode = subModulesNode.addNode(assetPath, ModuleItem.MODULE_TYPE_NAME);
/** * Gets a StateItem for the specified state name. If a node for the * specified state does not yet exist, one is first created. * * @param name the name of the state to get * @return a StateItem object encapsulating the retrieved node * @throws RulesRepositoryException */ public StateItem getState(String name) throws RulesRepositoryException { try { Node folderNode = this.getAreaNode(STATE_AREA); String nodePath = NodeUtils.makeJSR170ComplaintName(name); if (!folderNode.hasNode(nodePath)) { throw new RulesRepositoryException("The state called [" + name + "] does not exist."); } Node stateNode = folderNode.getNode(nodePath); // RulesRepository.addNodeIfNew(folderNode, name, StateItem.STATE_NODE_TYPE_NAME); return new StateItem(this, stateNode); } catch (Exception e) { log.error(e.getMessage(), e); throw new RulesRepositoryException(e); } }
String assetPath = NodeUtils.makeJSR170ComplaintName(subModuleName); Node ruleSubPackageNode = subModulesNode.addNode(assetPath, ModuleItem.MODULE_TYPE_NAME);
assetName = assetName.trim(); Node assetsFolder = this.node.getNode(ASSET_FOLDER_NAME); String assetPath = NodeUtils.makeJSR170ComplaintName(assetName); assetNode = assetsFolder.addNode(assetPath, AssetItem.ASSET_NODE_TYPE_NAME);
assetName = assetName.trim(); Node assetsFolder = this.node.getNode(ASSET_FOLDER_NAME); String assetPath = NodeUtils.makeJSR170ComplaintName(assetName); assetNode = assetsFolder.addNode(assetPath, AssetItem.ASSET_NODE_TYPE_NAME);
String nodePath = NodeUtils.makeJSR170ComplaintName(name); Node moduleNode = folderNode.addNode(nodePath, ModuleItem.MODULE_TYPE_NAME);
String nodePath = NodeUtils.makeJSR170ComplaintName(name); Node moduleNode = folderNode.addNode(nodePath, ModuleItem.MODULE_TYPE_NAME);
@Test public void testNodePathConversion5() { final String assetName = "one]two"; final String pathName = NodeUtils.makeJSR170ComplaintName( assetName ); assertEquals( "one_two", pathName ); }
@Test public void testNodePathConversion7() { final String assetName = "one\"two"; final String pathName = NodeUtils.makeJSR170ComplaintName( assetName ); assertEquals( "one_two", pathName ); }
@Test public void testNodePathConversion3() { final String assetName = "one*two"; final String pathName = NodeUtils.makeJSR170ComplaintName( assetName ); assertEquals( "one_two", pathName ); }
@Test public void testNodePathConversion2() { final String assetName = "one:two"; final String pathName = NodeUtils.makeJSR170ComplaintName( assetName ); assertEquals( "one_two", pathName ); }
@Test public void testNodePathConversion6() { final String assetName = "one'two"; final String pathName = NodeUtils.makeJSR170ComplaintName( assetName ); assertEquals( "one_two", pathName ); }
@Test public void testNodePathConversion1() { final String assetName = "one/two"; final String pathName = NodeUtils.makeJSR170ComplaintName( assetName ); assertEquals( "one_two", pathName ); }