/** * returns the name of the snapshot, if this module is really a snapshot. * If it is not, it will just return the name of the module, so use wisely * ! */ public String getSnapshotName() { try { return this.node.getName(); } catch (RepositoryException e) { throw new RulesRepositoryException(e); } }
@Test public void testDuplicatePackageName() throws Exception { ModuleItem pack = getRepo().createModule( "dupePackageTest", "testing for dupe" ); assertNotNull(pack.getName()); try { getRepo().createModule( "dupePackageTest", "this should fail" ); fail("Should not be able to add a package of the same name."); } catch (RulesRepositoryException e) { assertNotNull(e.getMessage()); } }
@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()); } }
protected String getPath() { try { return this.node.getPath(); } catch ( RepositoryException e ) { throw new RulesRepositoryException( e ); } } }
@Test public void testLoadRulePackageItem() { ModuleItem rulePackageItem = getRepo().createModule("testLoadRuleRuleItem", "desc"); rulePackageItem = getRepo().loadModule("testLoadRuleRuleItem"); assertNotNull(rulePackageItem); assertEquals("testLoadRuleRuleItem", rulePackageItem.getName()); assertEquals("desc", rulePackageItem.getDescription()); assertEquals(ModuleItem.MODULE_FORMAT, rulePackageItem.getFormat()); // try loading rule package that was not created try { rulePackageItem = getRepo().loadModule("anotherRuleRuleItem"); fail("Exception not thrown loading rule package that was not created."); } catch (RulesRepositoryException e) { // that is OK! assertNotNull(e.getMessage()); } }
protected String getPath() { try { return this.node.getPath(); } catch ( RepositoryException e ) { throw new RulesRepositoryException( e ); } } }
/** * returns the name of the snapshot, if this module is really a snapshot. * If it is not, it will just return the name of the module, so use wisely * ! */ public String getSnapshotName() { try { return this.node.getName(); } catch (RepositoryException e) { throw new RulesRepositoryException(e); } }
private boolean containsDoNotInstallSampleNode() throws RepositoryException { Node rootNode = this.session.getRootNode().getNode(RULES_REPOSITORY_NAME); try { return rootNode.hasNode(DO_NOT_INSTALL_SAMPLE_NODE); } catch (RepositoryException e) { throw new RulesRepositoryException(e); } }
private boolean containsDoNotInstallSampleNode() throws RepositoryException { Node rootNode = this.session.getRootNode().getNode(RULES_REPOSITORY_NAME); try { return rootNode.hasNode(DO_NOT_INSTALL_SAMPLE_NODE); } catch (RepositoryException e) { throw new RulesRepositoryException(e); } }
/** * gets the name of this item (unless overridden in a subclass, this just returns the * name of the node that this Item encapsulates. * * @return the name of the node that this item encapsultes * @throws RulesRepositoryException */ public String getName() throws RulesRepositoryException { try { return this.node.getName(); } catch(Exception e) { log.error("Caught exception: " + e); throw new RulesRepositoryException(e); } }
/** * Construct a validate JCR Node path name per JSR-170 from an asset name. * Only the following characters are valid: char ::= nonspace | ' ' nonspace * ::= (* Any Unicode character except: '/', ':', '[', ']', '*', ''', '"', * '|' or any whitespace character *). Invalid characters are replaced with * an underscore ("_"). * * @param assetName * @return a JSR-170 complaint path */ public static String makeJSR170ComplaintName(String assetName) { if ( assetName == null || assetName.length() == 0 ) { throw new RulesRepositoryException( "An Asset's name cannot be null or empty." ); } assetName = assetName.replaceAll( "[/:/*\\[\\]'\"|]", "_" ); return assetName; }
/** * This returns true if the repository contains the specified module name. */ public boolean containsModule(String name) { Node folderNode = this.getAreaNode(MODULE_AREA); try { return folderNode.hasNode(name); } catch (RepositoryException e) { throw new RulesRepositoryException(e); } }
/** * This returns true if the repository contains the specified module name. */ public boolean containsModule(String name) { Node folderNode = this.getAreaNode(MODULE_AREA); try { return folderNode.hasNode(name); } catch (RepositoryException e) { throw new RulesRepositoryException(e); } }
/** * Returns true if this module contains an asset of the given name. */ public boolean containsAsset(String name) { Node content; try { content = getVersionContentNode(); return content.getNode(ASSET_FOLDER_NAME).hasNode(name); } catch (RepositoryException e) { throw new RulesRepositoryException(e); } }
public VersionableItem archiveItem(boolean data) { checkout(); try { this.node.setProperty(CONTENT_PROPERTY_ARCHIVE_FLAG, data); return this; } catch (RepositoryException e) { log.error("Unable to update this VersionableItem binary archive flag"); throw new RulesRepositoryException(e); } }
/** * This returns the date/time on which the asset was "ORIGINALLY CREATED". * Kinda handy if you want to know how old something is. */ public Calendar getCreatedDate() { Property prop; try { prop = this.node.getProperty( "jcr:created" ); return prop.getDate(); } catch ( RepositoryException e ) { throw new RulesRepositoryException( e ); } }
/** * Use the given userName to select the node. */ public UserInfo(RulesRepository repo, String userName) throws RulesRepositoryException { try { init(repo, userName); } catch (RepositoryException e) { log.error("Unable to init UserInfo", e); throw new RulesRepositoryException(e); } }
/** * Returns true if this module contains an asset of the given name. */ public boolean containsAsset(String name) { Node content; try { content = getVersionContentNode(); return content.getNode(ASSET_FOLDER_NAME).hasNode(name); } catch (RepositoryException e) { throw new RulesRepositoryException(e); } }
public VersionableItem archiveItem(boolean data) { checkout(); try { this.node.setProperty(CONTENT_PROPERTY_ARCHIVE_FLAG, data); return this; } catch (RepositoryException e) { log.error("Unable to update this VersionableItem binary archive flag"); throw new RulesRepositoryException(e); } }
/** * Use the given userName to select the node. */ public UserInfo(RulesRepository repo, String userName) throws RulesRepositoryException { try { init(repo, userName); } catch (RepositoryException e) { log.error("Unable to init UserInfo", e); throw new RulesRepositoryException(e); } }