/** * Verifies user's permission in a given journal. * * @param action name * @param j journal * @return true if user has permission to perform given action. * @see GLPermission * @see Journal */ public boolean hasPermission(String action, Journal j) { Iterator iter = getPermissions().iterator(); while (iter.hasNext()) { GLPermission p = (GLPermission) iter.next(); Journal pj = p.getJournal(); if (action.equals(p.getName()) && (pj == null || (pj.getId() == j.getId()))) { return true; } } return false; }
/** Creates a JDOM Element as defined in <a href="http://jpos.org/minigl.dtd">minigl.dtd</a> */ public Element toXML() { Element e = new Element("user"); e.addContent(new Comment("id " + Long.toString(getId()))); e.addContent(new Element("nick").setText(getNick())); e.addContent(new Element("name").setText(getName())); Iterator iter = getPermissions().iterator(); while (iter.hasNext()) { GLPermission p = (GLPermission) iter.next(); if (p.getJournal() == null) e.addContent(new Element("grant").setText(p.getName())); } return e; }