*/
public List<Category> create(Integer parentId, Category category) throws ServiceException {
if (parentId > 0 && category != null) {
List<Category> categories = new ArrayList<Category>();
Category parent = getTree(parentId);
while(category != null) {
try {
// search for category
Category child = searchChild(parent, category);
// category exists already, set id from existing one
category.setId(child.getId());
// set values for next loop
parent = child;
parentId = parent.getId();
} catch(Exception e) {
parent = null;
}
// create / update category
category.setParent(new Category(parentId));
parentId = save(category);
// add category to return list
categories.add(category);