<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.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.enterprise.context.ConversationScoped;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.component.visit.VisitCallback;
import javax.faces.component.visit.VisitContext;
import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import javax.inject.Named;

import org.gluu.jsf2.message.FacesMessages;
import org.gluu.model.GluuAttribute;
import org.gluu.model.GluuImage;
import org.gluu.model.GluuUserRole;
import org.gluu.model.attribute.AttributeDataType;
import org.gluu.oxtrust.ldap.service.AttributeService;
import org.gluu.oxtrust.ldap.service.ImageService;
import org.gluu.oxtrust.model.GluuCustomAttribute;
import org.gluu.oxtrust.security.Identity;
import org.gluu.util.StringHelper;
import org.richfaces.event.FileUploadEvent;
import org.richfaces.model.UploadedFile;
import org.slf4j.Logger;

/**
 * Action class for work with custom attributes
 * 
 * @author <NAME> Date: 12/24/2012
 */
@ConversationScoped
@Named
public class CustomAttributeAction implements Serializable {

	private static final long serialVersionUID = -719594782175672946L;

	@Inject
	private Logger log;

	@Inject
	private Identity identity;

	@Inject
	private FacesMessages facesMessages;

	@Inject
	private AttributeService attributeService;

	@Inject
	private ImageService imageService;

	private GluuImage uploadedImage;

	private List<GluuAttribute> attributes;
	private Map<GluuAttribute, String> attributeIds;
	private Map<String, GluuAttribute> attributeToIds;
	private Map<String, List<GluuAttribute>> attributeByOrigin;
	private Map<String, GluuAttribute> attributeInums;
	private List<String> availableAttributeIds;

	private Map<String, String> originDisplayNames;
	private String activeOrigin;

	private List<GluuImage> addedPhotos;
	private List<GluuImage> removedPhotos;

	private List<GluuCustomAttribute> customAttributes;
	private ArrayList<GluuCustomAttribute> origCustomAttributes;

	@PostConstruct
	public void init() {
		this.addedPhotos = new ArrayList<GluuImage>();
		this.removedPhotos = new ArrayList<GluuImage>();
	}

	public void initCustomAttributes(List<GluuAttribute> noUsed, List<GluuCustomAttribute> customAttributes,
			List<String> origins, String[] objectClassTypes, String[] objectClassDisplayNames) {
		this.attributes = attributeService.getAllActivePersonAttributes(GluuUserRole.ADMIN);
		this.customAttributes = customAttributes;
		this.origCustomAttributes = new ArrayList<GluuCustomAttribute>(customAttributes);
<commit_msg>Fix user Add issue<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.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.enterprise.context.ConversationScoped;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIInput;
import javax.faces.component.visit.VisitCallback;
import javax.faces.component.visit.VisitContext;
import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
import javax.faces.event.ComponentSystemEvent;
import javax.inject.Inject;
import javax.inject.Named;

import org.gluu.jsf2.message.FacesMessages;
import org.gluu.model.GluuAttribute;
import org.gluu.model.GluuImage;
import org.gluu.model.attribute.AttributeDataType;
import org.gluu.oxtrust.ldap.service.AttributeService;
import org.gluu.oxtrust.ldap.service.ImageService;
import org.gluu.oxtrust.model.GluuCustomAttribute;
import org.gluu.oxtrust.security.Identity;
import org.gluu.util.StringHelper;
import org.richfaces.event.FileUploadEvent;
import org.richfaces.model.UploadedFile;
import org.slf4j.Logger;

/**
 * Action class for work with custom attributes
 * 
 * @author <NAME> Date: 12/24/2012
 */
@ConversationScoped
@Named
public class CustomAttributeAction implements Serializable {

	private static final long serialVersionUID = -719594782175672946L;

	@Inject
	private Logger log;

	@Inject
	private Identity identity;

	@Inject
	private FacesMessages facesMessages;

	@Inject
	private AttributeService attributeService;

	@Inject
	private ImageService imageService;

	private GluuImage uploadedImage;

	private List<GluuAttribute> attributes;
	private Map<GluuAttribute, String> attributeIds;
	private Map<String, GluuAttribute> attributeToIds;
	private Map<String, List<GluuAttribute>> attributeByOrigin;
	private Map<String, GluuAttribute> attributeInums;
	private List<String> availableAttributeIds;

	private Map<String, String> originDisplayNames;
	private String activeOrigin;

	private List<GluuImage> addedPhotos;
	private List<GluuImage> removedPhotos;

	private List<GluuCustomAttribute> customAttributes;
	private ArrayList<GluuCustomAttribute> origCustomAttributes;

	@PostConstruct
	public void init() {
		this.addedPhotos = new ArrayList<GluuImage>();
		this.removedPhotos = new ArrayList<GluuImage>();
	}

	public void initCustomAttributes(List<GluuAttribute> attributes, List<GluuCustomAttribute> customAttributes,
			List<String> origins, String[] objectClassTypes, String[] objectClassDisplayNames) {
		this.attributes = attributes;
		this.customAttributes = customAttributes;
		this.origCustomAttributes = new ArrayList<GluuCustomAttribute>(customAttributes);

{'fraction_non_alphanumeric': 0.09156026160074743, 'fraction_numerical': 0.011211460604173155, 'mean_word_length': 6.45993031358885, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, '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': '680417', 'n_tokens_mistral': 1956, 'n_tokens_neox': 1873, 'n_words': 427}