<commit_before>
package org.se.lab.web;

import org.apache.log4j.Logger;
import org.se.lab.db.data.UserProfile;
import org.se.lab.service.UserService;

import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.faces.context.Flash;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@Named
@RequestScoped
public class UserOverviewBean {

    private final static Logger LOG = Logger.getLogger(UserOverviewBean.class);

    @Inject
    private UserService service;
    /*
     * Properties for Session
     */
    private Flash flash;
    private FacesContext context;
    private List<UserProfile> profiles;
    private UserProfile selectedProfile;
    private String id = "";
    private int userId = 0;


    @PostConstruct
    public void init() {

        //TODO Check if Session exists
        context = FacesContext.getCurrentInstance();

        flash = FacesContext.getCurrentInstance().getExternalContext().getFlash();

        Map<String, Object> session = context.getExternalContext().getSessionMap();


        id = context.getExternalContext().getRequestParameterMap().get("userid");

        flash.put("uid", id);


        String userProfId = String.valueOf(context.getExternalContext().getFlash().get("uid"));


        LOG.info("userProfId: " + userProfId);

        if (session.size() != 0 && session.get("user") != null) {

            userId = (int) session.get("user");
            LOG.info("SESSIOn UID: " + userId);
        } else {
            try {
                context.getExternalContext().redirect("/pse/index.xhtml");
            } catch (IOException e) {
                LOG.error("Can't redirect to /pse/index.xhtml");
                //e.printStackTrace();
            }
        }

        profiles = service.getAllUserProfiles();


    }

    public List<UserProfile> getProfiles() {<commit_msg>Refactor UserOverviewBean - Add Error-Handling<commit_after>
package org.se.lab.web;

import org.apache.log4j.Logger;
import org.se.lab.db.data.UserProfile;
import org.se.lab.service.UserService;

import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
import javax.faces.context.Flash;
import javax.inject.Inject;
import javax.inject.Named;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@Named
@RequestScoped
public class UserOverviewBean {

    private final static Logger LOG = Logger.getLogger(UserOverviewBean.class);

    @Inject
    private UserService service;
    /*
     * Properties for Session
     */
    private Flash flash;
    private ExternalContext context;
    private List<UserProfile> profiles;
    private UserProfile selectedProfile;
    private String id = "";
    private String userProfId;
    private int userId = 0;


    @PostConstruct
    public void init() {

        //TODO Check if Session exists
        context = FacesContext.getCurrentInstance().getExternalContext();

        flash = context.getFlash();

        Map<String, Object> session = context.getSessionMap();

        id = context.getRequestParameterMap().get("userid");

        flash.put("uid", id);
        userProfId = String.valueOf(context.getFlash().get("uid"));

        LOG.info("userProfId: " + userProfId);

        if (session.size() != 0 && session.get("user") != null) {

            userId = (int) session.get("user");
            LOG.info("SESSIOn UID: " + userId);
        } else {
            try {
                context.redirect("/pse/index.xhtml");
            } catch (IOException e) {
                LOG.error("Can't redirect to /pse/index.xhtml");
                //e.printStackTrace();
            }
        }
try {
        profiles = service.getAllUserProfiles();
    } catch (Exception e) {
        LOG.error("Error in UserOverview", e);
    }

    }

    public List<UserProfile> getProfiles() {
{'fraction_non_alphanumeric': 0.11917098445595854, 'fraction_numerical': 0.0014803849000740192, 'mean_word_length': 2.795880149812734, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6433753', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1117, 'n_words': 249}