Search in sources :

Example 1 with ForumInstance

use of it.vige.rubia.model.ForumInstance in project rubia-forums by flashboss.

the class ForumsModuleImpl method removeForumInstance.

@Override
public void removeForumInstance(int forumInstanceId) throws ModuleException {
    try {
        ForumInstance forumInstance = em.find(ForumInstance.class, forumInstanceId);
        em.remove(forumInstance);
        // it is required
        em.flush();
    // for clustered versions
    } catch (Exception e) {
        String errorMessage = "Cannot delete forum Instance";
        throw new ModuleException(errorMessage, e);
    }
}
Also used : ForumInstance(it.vige.rubia.model.ForumInstance) NoResultException(javax.persistence.NoResultException) NonUniqueResultException(javax.persistence.NonUniqueResultException)

Example 2 with ForumInstance

use of it.vige.rubia.model.ForumInstance in project rubia-forums by flashboss.

the class AdminController method addCategory.

// ----actions---------------------------------------------------------------------------------------------------------------------------
/**
 * adds a category
 *
 * @return the navigation state of the application
 */
@SecureActionForum
@Interceptors(AuthorizationListener.class)
public String addCategory() {
    String navState = null;
    boolean success = false;
    try {
        // get the forumInstanceId where this forum should be added
        int forumInstanceId = userPreferences.getForumInstanceId();
        // add this new category to the forum instance
        ForumInstance forumInstance = forumsModule.findForumInstanceById(forumInstanceId);
        forumsModule.createCategory(categoryName, forumInstance);
        String start = getBundleMessage("ResourceJSF", "Category_created_0");
        String end = getBundleMessage("ResourceJSF", "Category_created_1");
        setMessage(FEEDBACK, start + " \"" + categoryName + "\" " + end);
        success = true;
    } catch (Exception e) {
        handleException(e);
    } finally {
        if (success) {
            // cleanup the state
            cleanup();
        }
    }
    return navState;
}
Also used : ForumInstance(it.vige.rubia.model.ForumInstance) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) ModuleException(it.vige.rubia.ModuleException) Interceptors(javax.interceptor.Interceptors) SecureActionForum(it.vige.rubia.auth.SecureActionForum)

Example 3 with ForumInstance

use of it.vige.rubia.model.ForumInstance in project rubia-forums by flashboss.

the class ForumsModuleImpl method createForumInstance.

/**
 * @see it.vige.rubia.ForumsModule#createForumInstance(java.lang.Integer,
 *      java.lang.String)
 */
@Override
public ForumInstance createForumInstance(Integer indexInstance, String name) throws ModuleException {
    try {
        ForumInstance forumInstance = new ForumInstance();
        forumInstance.setId(indexInstance);
        forumInstance.setName(name);
        em.persist(forumInstance);
        // it is required
        em.flush();
        // for clustered versions
        return forumInstance;
    } catch (Exception e) {
        String errorMessage = "Cannot create forum Instance";
        throw new ModuleException(errorMessage, e);
    }
}
Also used : ForumInstance(it.vige.rubia.model.ForumInstance) NoResultException(javax.persistence.NoResultException) NonUniqueResultException(javax.persistence.NonUniqueResultException)

Aggregations

ForumInstance (it.vige.rubia.model.ForumInstance)3 NoResultException (javax.persistence.NoResultException)2 NonUniqueResultException (javax.persistence.NonUniqueResultException)2 ModuleException (it.vige.rubia.ModuleException)1 SecureActionForum (it.vige.rubia.auth.SecureActionForum)1 JSFUtil.handleException (it.vige.rubia.ui.JSFUtil.handleException)1 Interceptors (javax.interceptor.Interceptors)1