public Val getProperty(String fileName, String propertyName) throws RepositoryException { Node inboxNode = getNode(userInfoNode, fileName, "nt:file"); if (inboxNode.hasNode("jcr:content")) { if (inboxNode.getNode("jcr:content").hasProperty(propertyName)) { return new Val(inboxNode.getNode("jcr:content").getProperty(propertyName).getString()); } else { return new Val(""); } } else { inboxNode.addNode("jcr:content", "nt:unstructured"); //needed to make it consistent on save return new Val(""); } }
info.setProperty("inbox", "something", new UserInfo.Val("boo")); info.save(); info.setProperty("inbox", "something", new UserInfo.Val("boo")); info.save(); info.setProperty("inbox", "something", new UserInfo.Val("boo2")); info.setProperty("inbox", "another", new UserInfo.Val("boo")); assertEquals("boo", info.getProperty("inbox", "another").value); info.setProperty("inbox", "something", new UserInfo.Val("boo")); info.setProperty("inbox", "something", new UserInfo.Val("boo2")); info.setProperty("inbox", "another", new UserInfo.Val("boo")); assertEquals("boo", info.getProperty("inbox", "another").value); info.setProperty("inbox", "whee", new UserInfo.Val("boo")); info.setProperty("inbox", "hi", new UserInfo.Val("42")); assertEquals("42", info.getProperty("inbox", "hi").value); info.setProperty("inbox", "hi", new UserInfo.Val("43")); assertEquals("43", info.getProperty("inbox", "hi").value); info.setProperty("inbox", "hi", new UserInfo.Val("42")); assertEquals("42", info.getProperty("inbox", "hi").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 Val getProperty(String fileName, String propertyName) throws RepositoryException { Node inboxNode = getNode(userInfoNode, fileName, "nt:file"); if (inboxNode.hasNode("jcr:content")) { if (inboxNode.getNode("jcr:content").hasProperty(propertyName)) { return new Val(inboxNode.getNode("jcr:content").getProperty(propertyName).getString()); } else { return new Val(""); } } else { inboxNode.addNode("jcr:content", "nt:unstructured"); //needed to make it consistent on save return new Val(""); } }
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 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); } }