<commit_before>/*
 * oxTrust is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
 *
 * Copyright (c) 2014, Gluu
 */

package org.gluu.oxtrust.action;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ConversationScoped;
import javax.faces.application.FacesMessage;
import javax.inject.Inject;
import javax.inject.Named;

import org.gluu.jsf2.message.FacesMessages;
import org.gluu.jsf2.service.ConversationService;
import org.gluu.oxtrust.ldap.service.AttributeService;
import org.gluu.oxtrust.ldap.service.IPersonService;
import org.gluu.oxtrust.ldap.service.ImageService;
import org.gluu.oxtrust.ldap.service.ImapDataService;
import org.gluu.oxtrust.model.GluuCustomAttribute;
import org.gluu.oxtrust.model.GluuCustomPerson;
import org.gluu.oxtrust.util.OxTrustConstants;
import org.gluu.site.ldap.persistence.exception.LdapMappingException;
import org.slf4j.Logger;
import org.xdi.config.oxtrust.AppConfiguration;
import org.xdi.model.GluuAttribute;
import org.xdi.model.GluuIMAPData;
import org.xdi.model.GluuImage;
import org.xdi.model.GluuUserRole;
import org.xdi.model.ImapPassword;
import org.xdi.service.security.Secure;

/**
 * Action class for view and update profile actions.
 * 
 * @author <NAME> Date: 11.02.2010
 */
@Named("userProfileAction")
@ConversationScoped
@Secure("#{permissionService.hasPermission('profile', 'access')}")
public class UserProfileAction implements Serializable {

	private static final long serialVersionUID = -8238855019631152823L;

	private static final String tabName = "Attributes";

	@Inject
	private Logger log;

	@Inject
	private FacesMessages facesMessages;

	@Inject
	private ConversationService conversationService;

	@Inject
	private IPersonService personService;

	@Inject
	private AttributeService attributeService;

	@Inject
	private ImageService imageService;

	@Inject
	private CustomAttributeAction customAttributeAction;

	@Inject
	private UserPasswordAction userPasswordAction;

	@Inject
	private WhitePagesAction whitePagesAction;

	@Inject
	private GluuCustomPerson currentPerson;
	
	@Inject
	private ImapDataService imapDataService;

	@Inject
	private AppConfiguration appConfiguration;

	private GluuCustomPerson person;

	private List<String> optOuts;
	
	
	private GluuIMAPData imapData;

    public GluuIMAPData getImapData() {
		return imapData;
	}

	public void setImapData(GluuIMAPData imapData) {
		this.imapData = imapData;
	}
	
	@PostConstruct
	public void init() {
		this.imapData = new GluuIMAPData();
		this.imapData.setImapPassword(new ImapPassword());
		
	}

	private static final String photoAttributes[][] = new String[][] { { "gluuPerson", "photo1" }, };

	public String show() {
		if (this.person != null) {
			return OxTrustConstants.RESULT_SUCCESS;
		}

		try {
			this.person = personService.getPersonByInum(currentPerson.getInum());
		} catch (LdapMappingException ex) {
			log.error("Failed to find person {}", currentPerson.getInum(), ex);
		}

		if (this.person == null) {
			facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to load profile");
			conversationService.endConversation();

			return OxTrustConstants.RESULT_FAILURE;
		}<commit_msg>oxTrust issue #644<commit_after>/*
 * oxTrust is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
 *
 * Copyright (c) 2014, Gluu
 */

package org.gluu.oxtrust.action;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.annotation.PostConstruct;
import javax.enterprise.context.ConversationScoped;
import javax.faces.application.FacesMessage;
import javax.inject.Inject;
import javax.inject.Named;

import org.gluu.jsf2.message.FacesMessages;
import org.gluu.jsf2.service.ConversationService;
import org.gluu.oxtrust.ldap.service.AttributeService;
import org.gluu.oxtrust.ldap.service.IPersonService;
import org.gluu.oxtrust.ldap.service.ImageService;
import org.gluu.oxtrust.ldap.service.ImapDataService;
import org.gluu.oxtrust.model.GluuCustomAttribute;
import org.gluu.oxtrust.model.GluuCustomPerson;
import org.gluu.oxtrust.security.Identity;
import org.gluu.oxtrust.util.OxTrustConstants;
import org.gluu.site.ldap.persistence.exception.LdapMappingException;
import org.slf4j.Logger;
import org.xdi.config.oxtrust.AppConfiguration;
import org.xdi.model.GluuAttribute;
import org.xdi.model.GluuIMAPData;
import org.xdi.model.GluuImage;
import org.xdi.model.GluuUserRole;
import org.xdi.model.ImapPassword;
import org.xdi.service.security.Secure;

/**
 * Action class for view and update profile actions.
 * 
 * @author <NAME> Date: 11.02.2010
 */
@Named("userProfileAction")
@ConversationScoped
@Secure("#{permissionService.hasPermission('profile', 'access')}")
public class UserProfileAction implements Serializable {

	private static final long serialVersionUID = -8238855019631152823L;

	private static final String tabName = "Attributes";

	@Inject
	private Logger log;

	@Inject
	private FacesMessages facesMessages;

	@Inject
	private ConversationService conversationService;

	@Inject
	private IPersonService personService;

	@Inject
	private AttributeService attributeService;

	@Inject
	private ImageService imageService;

	@Inject
	private CustomAttributeAction customAttributeAction;

	@Inject
	private UserPasswordAction userPasswordAction;

	@Inject
	private WhitePagesAction whitePagesAction;

	@Inject
	private GluuCustomPerson currentPerson;
	
	@Inject
	private ImapDataService imapDataService;

	@Inject
	private AppConfiguration appConfiguration;

	@Inject
	private Identity identity;

	private GluuCustomPerson person;

	private List<String> optOuts;
	
	
	private GluuIMAPData imapData;

    public GluuIMAPData getImapData() {
		return imapData;
	}

	public void setImapData(GluuIMAPData imapData) {
		this.imapData = imapData;
	}
	
	@PostConstruct
	public void init() {
		this.imapData = new GluuIMAPData();
		this.imapData.setImapPassword(new ImapPassword());
		
	}

	private static final String photoAttributes[][] = new String[][] { { "gluuPerson", "photo1" }, };

	public String show() {
		if (this.person != null) {
			return OxTrustConstants.RESULT_SUCCESS;
		}

		try {
			this.person = identity.getUser();
		} catch (LdapMappingException ex) {
			log.error("Failed to find person {}", currentPerson.getInum(), ex);
		}

		if (this.person == null) {
			facesMessages.add(FacesMessage.SEVERITY_ERROR, "Failed to load profile");
			conversationService.endConversation();

			return OxTrustConstants.RESULT_FAILURE;
		}
{'fraction_non_alphanumeric': 0.09937050359712231, 'fraction_numerical': 0.012140287769784174, 'mean_word_length': 5.385645933014354, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3751085', 'n_tokens_mistral': 2253, 'n_tokens_neox': 2122, 'n_words': 456}