* @param parentCategory
* @return newly created category (Category facade object)
* @throws JahiaException
*/
public Category createCategory(String key, Category parentCategory) throws JahiaException {
Category newCategory = null;
try {
JCRSessionWrapper jcrSessionWrapper = sessionFactory
.getCurrentUserSession();
JCRNodeWrapper parentNodeWrapper = getParentNode(parentCategory,
jcrSessionWrapper);
jcrSessionWrapper.checkout(parentNodeWrapper);
final JCRNodeWrapper wrapper = parentNodeWrapper.addNode(key,
Constants.JAHIANT_CATEGORY);
jcrSessionWrapper.save();
newCategory = new Category(createCategoryBeanFromNode(wrapper));
} catch (ItemExistsException e) {
throw new JahiaException("Category " + key
+ " already exists", "Category " + key
+ " already exists", JahiaException.DATA_ERROR,
JahiaException.ERROR_SEVERITY);