Search in sources :

Example 1 with PostConstruct

use of jakarta.annotation.PostConstruct in project OpenGrok by OpenGrok.

the class IncomingFilter method init.

@PostConstruct
public void init() {
    try {
        localAddresses.add(InetAddress.getLocalHost().getHostAddress());
        for (InetAddress inetAddress : InetAddress.getAllByName("localhost")) {
            localAddresses.add(inetAddress.getHostAddress());
        }
    } catch (IOException e) {
        LOGGER.log(Level.SEVERE, "Could not get localhost addresses", e);
    }
    // Cache the tokens to avoid locking.
    setTokens(RuntimeEnvironment.getInstance().getAuthenticationTokens());
    RuntimeEnvironment.getInstance().registerListener(this);
}
Also used : IOException(java.io.IOException) InetAddress(java.net.InetAddress) PostConstruct(jakarta.annotation.PostConstruct)

Example 2 with PostConstruct

use of jakarta.annotation.PostConstruct in project rubia-forums by flashboss.

the class ViewMyForumsMain method execute.

/**
 */
@PostConstruct
public void execute() {
    try {
        super.execute();
        Collection<ForumBean> forums = getWatchedForums();
        Date userLastLogin = getUserLastLoginDate(userModule, userProfileModule);
        for (ForumBean currentForum : forums) {
            // setup folderLook based on whats specified in the theme
            String folderImage = themeHelper.getResourceForumURL();
            // bundle key
            String folderAlt = "No_new_posts";
            if (forumsLastPosts != null && forumsLastPosts.containsKey(currentForum.getId())) {
                PostBean lastPost = forumsLastPosts.get(currentForum.getId());
                Date lastPostDate = lastPost.getCreateDate();
                if (lastPostDate != null && userLastLogin != null && lastPostDate.compareTo(userLastLogin) > 0) {
                    // bundle key
                    folderAlt = "New_posts";
                    folderImage = themeHelper.getResourceForumNewURL();
                }
            }
            if (currentForum.getStatus() == Constants.FORUM_LOCKED) {
                folderImage = themeHelper.getResourceForumLockedURL();
                // bundle key
                folderAlt = "Forum_locked";
            }
            getForumImages().put(currentForum.getId(), folderImage);
            getForumImageDescriptions().put(currentForum.getId(), folderAlt);
        }
    } catch (Exception e) {
        log.error(e);
    }
}
Also used : PostBean(it.vige.rubia.dto.PostBean) ForumBean(it.vige.rubia.dto.ForumBean) Date(java.util.Date) JSFUtil.getUserLastLoginDate(it.vige.rubia.ui.JSFUtil.getUserLastLoginDate) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) PostConstruct(jakarta.annotation.PostConstruct)

Example 3 with PostConstruct

use of jakarta.annotation.PostConstruct in project rubia-forums by flashboss.

the class ViewTopic method execute.

/**
 * This method gets topicId from parameters and tries to find topic with that
 * id.
 */
@PostConstruct
public void execute() {
    // parse input data
    int topicId = -1;
    Integer postId = -1;
    String t = getParameter(p_topicId);
    String p = getParameter(p_postId);
    if (t != null && t.trim().length() > 0) {
        topicId = parseInt(t);
    }
    try {
        if (p != null && p.trim().length() > 0) {
            postId = parseInt(p);
            PostBean post = forumsModule.findPostById(postId);
            topicId = post.getTopic().getId().intValue();
            topic = post.getTopic();
        }
        refreshTopic(topicId);
    } catch (Exception e) {
        log.error(e);
    }
}
Also used : PostBean(it.vige.rubia.dto.PostBean) PostConstruct(jakarta.annotation.PostConstruct)

Example 4 with PostConstruct

use of jakarta.annotation.PostConstruct in project rubia-forums by flashboss.

the class ViewCategory method execute.

// ui actions supported by this
// bean----------------------------------------------------------------------------------------------------
/**
 * this generates the category and its corresponding forums
 */
@PostConstruct
public void execute() {
    try {
        // try to extract categoryId
        int categoryId = -1;
        String c = getParameter(p_categoryId);
        if (c != null && c.trim().length() > 0) {
            categoryId = Integer.parseInt(c);
            // Setting flag that category has been selected.
            categorySelected = true;
        }
        // Luca Stancapiano start
        // get the forumInstanceId where this forum should be added
        int forumInstanceId = userPreferences.getForumInstanceId();
        this.forumLastPosts = forumsModule.findLastPostsOfForums(forumInstanceId);
        // setup category related data to be displayed
        if (categoryId == -1) {
            // process a default level category
            // Luca Stancapiano
            Collection<CategoryBean> cour = forumsModule.findCategoriesFetchForums(forumInstanceId);
            if (cour != null) {
                for (CategoryBean currentCategory : cour) processCategory(currentCategory);
            }
        } else {
            // process the specifed category
            CategoryBean currentCategory = forumsModule.findCategoryById(categoryId);
            if (currentCategory != null) {
                processCategory(currentCategory);
            }
        }
    } catch (Exception e) {
        handleException(e);
    }
}
Also used : CategoryBean(it.vige.rubia.dto.CategoryBean) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) PostConstruct(jakarta.annotation.PostConstruct)

Example 5 with PostConstruct

use of jakarta.annotation.PostConstruct in project rubia-forums by flashboss.

the class AdminController method startService.

/**
 * Start the admin controller as service
 */
@PostConstruct
public void startService() {
    try {
        // load the selected category if a categoryid is found
        // fetch the category to be edited/deleted
        int categoryId = -1;
        String cour = getParameter(p_categoryId);
        if (cour != null && cour.trim().length() > 0) {
            categoryId = parseInt(cour);
        }
        if (categoryId != -1) {
            CategoryBean category = null;
            try {
                category = forumsModule.findCategoryById(categoryId);
            } catch (ModuleException e) {
            // Category was deleted
            }
            if (category != null) {
                categoryName = category.getTitle();
                selectedCategory = category.getId().intValue();
            }
        }
        // load the selected forum is a forumid is found
        // fetch the forum to be edited/deleted
        int forumId = -1;
        String forumIdStr = getParameter(p_forumId);
        if (forumIdStr != null && forumIdStr.trim().length() > 0) {
            forumId = parseInt(forumIdStr);
        }
        if (forumId != -1) {
            ForumBean forum = null;
            try {
                forum = forumsModule.findForumById(forumId);
            } catch (ModuleException e) {
            // Forum was deleted
            }
            if (forum != null) {
                forumName = forum.getName();
                forumDescription = forum.getDescription();
                selectedCategory = forum.getCategory().getId().intValue();
                selectedForum = forum.getId().intValue();
            }
        }
        // Checking for editModes flags
        String editCatStr = getParameter(EDIT_CATEGORY);
        if (editCatStr != null && editCatStr.trim().length() > 0) {
            editCategoryMode = Boolean.valueOf(editCatStr).booleanValue();
        }
        String editForStr = getParameter(EDIT_FORUM);
        if (editForStr != null && editForStr.trim().length() > 0) {
            editForumMode = Boolean.valueOf(editForStr).booleanValue();
        }
        // Checking for addModes flags
        String addCatStr = getParameter(ADD_CATEGORY);
        if (addCatStr != null && addCatStr.trim().length() > 0) {
            addCategoryMode = Boolean.valueOf(addCatStr).booleanValue();
        }
        String addForStr = getParameter(ADD_FORUM);
        if (addForStr != null && addForStr.trim().length() > 0) {
            addForumMode = Boolean.valueOf(addForStr).booleanValue();
        }
    } catch (Exception e) {
        handleException(e);
    }
}
Also used : CategoryBean(it.vige.rubia.dto.CategoryBean) ForumBean(it.vige.rubia.dto.ForumBean) ModuleException(it.vige.rubia.ModuleException) JSFUtil.handleException(it.vige.rubia.ui.JSFUtil.handleException) ModuleException(it.vige.rubia.ModuleException) PostConstruct(jakarta.annotation.PostConstruct)

Aggregations

PostConstruct (jakarta.annotation.PostConstruct)40 PostBean (it.vige.rubia.dto.PostBean)4 JSFUtil.handleException (it.vige.rubia.ui.JSFUtil.handleException)4 ArrayList (java.util.ArrayList)4 ModuleException (it.vige.rubia.ModuleException)3 ForumBean (it.vige.rubia.dto.ForumBean)3 FacesContext (jakarta.faces.context.FacesContext)3 Date (java.util.Date)3 ApplicationAssociate (com.sun.faces.application.ApplicationAssociate)2 HTTPServer (io.prometheus.client.exporter.HTTPServer)2 CategoryBean (it.vige.rubia.dto.CategoryBean)2 TopicBean (it.vige.rubia.dto.TopicBean)2 JSFUtil.getUserLastLoginDate (it.vige.rubia.ui.JSFUtil.getUserLastLoginDate)2 SessionScoped (jakarta.enterprise.context.SessionScoped)2 Typed (jakarta.enterprise.inject.Typed)2 ClientWindow (jakarta.faces.lifecycle.ClientWindow)2 IOException (java.io.IOException)2 Serializable (java.io.Serializable)2 InetSocketAddress (java.net.InetSocketAddress)2 HashMap (java.util.HashMap)2