/** * Gets collection. * * @param parent The parent. * @param name The name. * @return The collection item. * @throws Exception - if something is wrong this exception is thrown. */ private CollectionItem getCollection(CollectionItem parent, String name) throws Exception { for (Item child : (Set<Item>) parent.getChildren()) { if (child.getName().equals(name)) { return (CollectionItem) child; } } CollectionItem collection = new HibCollectionItem(); collection.setName(name); collection.setDisplayName(name); collection.setOwner(parent.getOwner()); return contentDao.createCollection(parent, collection); }
/** * Convienence method for setting a Elementvalue on an XmlAttribute with a given QName stored on * the given item. * * @param item item to fetch Xmlttribute from * @param qname QName of attribute * @param value value to set on XmlAttribute */ public static void setValue(Item item, QName qname, Element value) { XmlAttribute attr = (XmlAttribute) item.getAttribute(qname); if (attr == null && value != null) { attr = new HibXmlAttribute(qname, value); item.addAttribute(attr); return; } if (value == null) { item.removeAttribute(qname); } else { attr.setValue(value); } }
/** * Convienence method for returning a Element value on an XmlAttribute with a given QName stored * on the given item. * * @param item item to fetch XmlAttribute from * @param qname QName of attribute * @return Long value of XmlAttribute */ public static Element getValue(Item item, QName qname) { XmlAttribute xa = (XmlAttribute) item.getAttribute(qname); if (xa == null) { return null; } else { return xa.getValue(); } }