public List<InboxEntry> readEntries(String fileName, String propertyName) throws RulesRepositoryException { try { Val property = getProperty(fileName, propertyName); if (!(property.value == null || property.value.equals(""))) { return (List<InboxEntry>) getXStream().fromXML(property.value); } else { return new ArrayList<InboxEntry>(); } } catch (RepositoryException e) { log.error("Unable to readEntries", 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); } }
public void writeEntries(String fileName, String boxName, List<InboxEntry> entries) throws RulesRepositoryException { try { String entry = getXStream().toXML(entries); setProperty(fileName, boxName, new UserInfo.Val(entry)); } catch (RepositoryException e) { log.error("Unable to writeEntries", e); throw new RulesRepositoryException(e); } }
UserInfo info = new UserInfo(repo); info.setProperty("inbox", "something", new UserInfo.Val("boo")); info.save(); info.setProperty("inbox", "something", new UserInfo.Val("boo")); info.save(); assertEquals("boo", info.getProperty("inbox", "something").value); info.setProperty("inbox", "something", new UserInfo.Val("boo2")); assertEquals("boo2", info.getProperty("inbox", "something").value); info.setProperty("inbox", "another", new UserInfo.Val("boo")); assertEquals("boo", info.getProperty("inbox", "another").value); info = new UserInfo(repo); info.init(repo, "wankle"); info.setProperty("inbox", "something", new UserInfo.Val("boo")); assertEquals("boo", info.getProperty("inbox", "something").value); info.setProperty("inbox", "something", new UserInfo.Val("boo2")); assertEquals("boo2", info.getProperty("inbox", "something").value); info.setProperty("inbox", "another", new UserInfo.Val("boo")); assertEquals("boo", info.getProperty("inbox", "another").value); info = new UserInfo(repo); assertEquals("boo", info.getProperty("inbox", "another").value);
@Test public void testIterateOverUsers() throws Exception { RulesRepository repo = RepositorySessionUtil.getRepository(); final List<String> names = new ArrayList<String>(); UserInfo uf = new UserInfo(repo); uf.init(repo, "michael"); uf.setProperty("random", "property", new UserInfo.Val("hi")); UserInfo.eachUser(repo, new UserInfo.Command() { public void process(String toUser) { names.add(toUser); } }); assertTrue(names.size() > 0) ; assertTrue(names.contains("michael")); }
public void clear(String fileName, String boxName) { try { setProperty(fileName, boxName, new UserInfo.Val("")); } catch (RepositoryException e) { log.error("Unable to clear", e); throw new RulesRepositoryException(e); } }
public void clear(String fileName, String boxName) { try { setProperty(fileName, boxName, new UserInfo.Val("")); } catch (RepositoryException e) { log.error("Unable to clear", e); throw new RulesRepositoryException(e); } }
public void writeEntries(String fileName, String boxName, List<InboxEntry> entries) throws RulesRepositoryException { try { String entry = getXStream().toXML(entries); setProperty(fileName, boxName, new UserInfo.Val(entry)); } catch (RepositoryException e) { log.error("Unable to writeEntries", e); throw new RulesRepositoryException(e); } }
public List<InboxEntry> readEntries(String fileName, String propertyName) throws RulesRepositoryException { try { Val property = getProperty(fileName, propertyName); if (!(property.value == null || property.value.equals(""))) { return (List<InboxEntry>) getXStream().fromXML(property.value); } else { return new ArrayList<InboxEntry>(); } } catch (RepositoryException e) { log.error("Unable to readEntries", 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); } }
/** * Use the current sessions userName to get to the info node. */ public UserInfo(RulesRepository repo) throws RulesRepositoryException { try { init(repo, repo.getSession().getUserID()); } catch (RepositoryException e) { log.error("Unable to init UserInfo", e); throw new RulesRepositoryException(e); } }
/** * Use the current sessions userName to get to the info node. */ public UserInfo(RulesRepository repo) throws RulesRepositoryException { try { init(repo, repo.getSession().getUserID()); } catch (RepositoryException e) { log.error("Unable to init UserInfo", e); throw new RulesRepositoryException(e); } }