blog.addCategory(category);
category.setTags(tags);
try {
// add it to the persistent store
DAOFactory factory = DAOFactory.getConfiguredFactory();
CategoryDAO dao = factory.getCategoryDAO();
dao.addCategory(category, blog);
} catch (PersistenceException pe) {
pe.printStackTrace();
}
} else {
// updating an existing category
category.setName(name);
category.setTags(tags);
try {
// add it to the persistent store
DAOFactory factory = DAOFactory.getConfiguredFactory();
CategoryDAO dao = factory.getCategoryDAO();
dao.updateCategory(category, blog);
} catch (PersistenceException pe) {
pe.printStackTrace();
}
}
}