/*
 * $Id: EditUserForm.java,v 1.47 2008/02/13 07:45:01 marbobo Exp $
 *
 * Copyright (c) Siemens AG 2008 
 *           (c) Universität Paderborn 2008 
 * Licensed under EUPL 1.1. 
 *
 * $Log: EditUserForm.java,v $
 * Revision 1.47  2008/02/13 07:45:01  marbobo
 * + Bugfix
 *
 * Revision 1.46  2008/02/12 09:34:04  korowa
 * Eine Möglichkeit für den Benutzer hinzugefügt die Emailsart auszuwählen(HTML oder Plaintext)
 *
 * Revision 1.45  2007/10/30 13:52:52  marbobo
 * + removed unnecessary statements
 *
 * Revision 1.44  2007/08/09 14:38:53  marbobo
 * - 2 falsch zugeordnete LDAP- Parameter entfernt
 * + Löschen und Aktivieren von Lizenzen hinzugefügt
 *
 * Revision 1.43  2007/08/08 12:14:57  marbobo
 * + License-Funktionalität komplett umgeschrieben
 * + Bugfix bzgl. Beschreibungsfelder von Entitäten
 * + Bugfix mailing
 *
 * Revision 1.42  2007/03/14 10:09:40  jw
 * Methods, Forms and variables used to copy dedicated admin rights added.
 *
 * Revision 1.41  2007/02/01 14:32:22  korowa
 * Zwei Felder zu SystemParameter hinzugefügt die einem Administrator erlauben das Anlegen von neuen Benutzer oder das Ändern der Passwörter zu regeln.
 *
 * Revision 1.40  2006/11/06 12:40:09  korowa
 * bugfixing
 *
 * Revision 1.39  2006/09/17 18:55:36  marbobo
 * + Bugfix bei der Behandlung der dyn. Attributen
 * + Umstellung der Initialisierung bei dyn. Attributen
 *
 * Revision 1.38  2006/08/31 12:17:10  korowa
 * Dynamische Attribute für Users eingefügt
 *
 * Revision 1.37  2006/05/18 22:50:01  marbobo
 * + Beim Menusprache-Wechsel werden jetzt auch alle 3 Frames aktualisiert
 *
 * Revision 1.36  2006/05/12 08:09:11  korowa
 * +showTree zum Userprofil hinzugefügt. Dieser parameter regelt die Anzeige des Explorerfensters beim VKC-Anmeldung. Lässt sich im Userprofil umschalten.
 *
 * Revision 1.35  2006/04/29 18:39:48  marbobo
 * + Refactoriengs und eine Ausgaben vereinheitlicht
 *
 * Revision 1.34  2006/02/27 16:16:17  marbobo
 * + Systemsichten hinzugefügt
 * + SysLinks angepasst
 * + Benutzer können falls gewünscht Dokumentqueries anlegen
 *
 * Revision 1.33  2005/09/15 23:16:43  marbobo
 * + Sprachabhängiges Sortieren implementiert
 *
 * Revision 1.32  2005/08/09 19:00:26  jonyp
 * support for change of publisher
 *
 * Revision 1.31  2005/05/31 16:22:36  marbobo
 * + Aktualisierung des Navigators korrigiert
 *
 * Revision 1.30  2005/02/20 23:34:15  marbobo
 * + Bugfix
 *
 * Revision 1.29  2005/02/20 16:56:47  marbobo
 * + Beim Speichern der Entities in die Datenbank wird sichergestellt
 *    dass Unicode-Zeichen in Kodierterform (als &#xxxxx;) gespeichert werden
 *
 * Revision 1.28  2005/02/08 16:15:20  bigmac
 * Quotabehandlung überarbeitet
 *
 * Revision 1.27  2004/12/01 16:42:45  jonyp
 * added support for ldapusers
 *
 * Revision 1.26  2004/11/12 00:24:35  marbobo
 * + getGroupInfos() in retrieveGroupInfos() umgebannt
 *
 * Revision 1.25  2004/11/10 15:02:48  koppy
 * Projektweite Überarbeitung von Error-Logs, Stacktraces,..
 *
 * Revision 1.24  2004/10/20 12:05:57  marbobo
 * + Bugfix wegen Startkategorie
 *
 * Revision 1.23  2004/10/07 12:58:32  marbobo
 * + Festlegen der Startkategorie
 *
 * Revision 1.22  2004/08/30 20:06:36  marbobo
 * + Verbesserung des Redirectmechanismus
 *
 * Revision 1.21  2004/08/07 18:17:06  marbobo
 * + Bugfix für Zeitangaben und Refactorings
 *
 * Revision 1.20  2004/07/21 20:01:04  marbobo
 * + Startkategorie anzeigen
 * + Stellvertreter für -  Anzeige
 *
 * Revision 1.19  2004/06/27 17:05:29  marbobo
 * + Quellcode maintenance
 *
 * Revision 1.18  2004/06/21 11:52:06  marbobo
 * + Benutzername nachträglich (falls möglich) editieren
 *
 * Revision 1.17  2004/06/15 20:20:20  marbobo
 * Refactoring
 *
 * Revision 1.16  2004/05/15 17:01:07  marbobo
 * isDedicatedAdmin() -> isDedicatedUsersAdmin() oder isDedicatedGroupsAdmin()
 *
 * Revision 1.15  2004/04/18 14:34:18  marbobo
 * Bugfix
 *
 * Revision 1.14  2004/03/18 01:20:32  marbobo
 * EditUserAction und EditUserForm auf request-scope umgestellt
 *
 * Revision 1.13  2004/03/13 20:46:17  bigmac
 * Weitere Refactorings ...
 *
 * Revision 1.1  2003/08/17 23:48:22  marbobo
 * erste Version
 *
 */
package vkc.administration.form;

import java.sql.Timestamp;
import java.text.CollationKey;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import vkc.db.entities.VKCCategory;
import vkc.db.entities.VKCDynUserAttribute;
import vkc.db.entities.VKCGroup;
import vkc.db.entities.VKCLanguage;
import vkc.db.entities.VKCProxyUser;
import vkc.db.entities.VKCUser;
import vkc.db.helper.UserHelper;
import vkc.db.serializer.VKCCategorySerializer;
import vkc.db.serializer.VKCGroupSerializer;
import vkc.db.serializer.VKCLanguageSerializer;
import vkc.db.serializer.VKCProxyUserSerializer;
import vkc.db.serializer.VKCUserSerializer;
import vkc.exception.DBException;
import vkc.misc.VKCLogManager;
import vkc.util.DateUtils;
import vkc.util.StringUtils;
import vkc.util.VKCCategoryAbsPath;
import vkc.util.VKCStringUtils;
import vkc.view.PageId;
import vkc.view.WebShare;
import vkc.view.bean.GroupInfo;
import vkc.view.bean.UserDynAttr;
import vkc.view.bean.UserInfo;
import vkc.view.bean.UserStatistics;
import vkc.view.bean.VKCQuotaInfo;
import vkc.view.form.DynaForm;

/**
 * Form Bean zum Editieren von Benutzerprofilen
 *
 * @author marbobo
 * @version $Revision: 1.47 $
 */
public final class EditUserForm extends DynaForm {
	//~ Instance fields --------------------------------------------------------
	private VKCUser  	editUser					= null;
	private Integer		userId						= null;
	
	private List   		dynaAttributes				= new ArrayList();
	private List	 	languageLabels				= new ArrayList();
	private List	 	addGroupLabels				= new ArrayList();
	private List	 	removeGroupLabels			= new ArrayList();
	private List		addProxyUserLabels			= new ArrayList();
	private List		removeProxyUserLabels		= new ArrayList();
	private Integer[] 	addGroupIds					= new Integer[0];
	private Integer[] 	addProxyUserIds				= new Integer[0];
	private Integer[]	selectedAddGroupIds			= new Integer[0];	
	private Integer[]	selectedRemoveGroupIds		= new Integer[0];	
	private Integer[]	selectedAddProxyUserIds		= new Integer[0];
	private Integer[]	selectedRemoveProxyUserIds	= new Integer[0];
	private Integer		currentProxyUserId			= null;
	private Integer   	selectedLanguageId        	= null;
	private Integer   	selectedSessionTimeout     	= null;
	private Integer   	selectedSystemViewTypeId   	= PageId.CATEGORY_VIEW;
    private Integer     pswdMismatchCount           = null;
	private Integer 	selectedIndex 				= new Integer(-1);
	private String   	selectedQuota	        	= null;
	private String		proxyValidFrom				= "";
	private String		proxyValidUntil				= "";
	private String		proxyDescription			= "";
	private String 		validFrom		   			= "";
	private String 		validUntil		   			= "";

	private String 		username					= "";
	private String 		title 						= "";
	private String 		firstname 					= "";
	private String 		lastname 					= "";
	private String 		email 						= "";
	private String 		company 					= "";
	private String 		department 					= "";
	private String 		street 						= "";
	private String 		zip 						= "";
	private String 		city 						= "";
	private String 		fax 						= "";
	private String 		phone 						= "";
	private String 		mobile 						= "";
	private String 		contactURL 					= "";
	private String 		homepageURL 				= "";
	private String  	selectedCategoryId			= String.valueOf(VKCCategory.ROOT_CATEGORY_ID);
	private String		redirect					= "";
    private boolean     enableHtmlNotification      = false;
	private boolean		adminPrivileges				= false;
	private boolean		accountValid				= false;
	private boolean		manageOwnUsers				= false;
	private boolean		manageOwnUsersSystemViews	= false;
	private boolean		manageOwnGroups				= false;
	private boolean		manageOwnProxies			= false;
	private boolean		manageVirtualDocumentQueries= false;
	private boolean		showEmail					= false;
	private boolean	    allowManageSystemViewType	= false;
	private boolean		showTree					= false;
	private boolean		languageChanged				= false;
    

	private UserStatistics userStatistics = null;
    private VKCQuotaInfo   userQuota = null;
	
	//~ Methods ----------------------------------------------------------------

	/**
	 * Reset der Eingabefelder auf Defaultwerte
	 *
	 * @param mapping The mapping used to select this instance
	 * @param request The servlet request we are processing
	 */
	public void reset(ActionMapping mapping, HttpServletRequest request) {
		super.reset(mapping, request);

		editUser					= null;
		userId						= null;

		dynaAttributes				= new ArrayList();
		languageLabels				= new ArrayList();
		addGroupLabels				= new ArrayList();
		removeGroupLabels			= new ArrayList();
		addProxyUserLabels			= new ArrayList();
		removeProxyUserLabels		= new ArrayList();
		addGroupIds					= new Integer[0];
		addProxyUserIds				= new Integer[0];
		selectedAddGroupIds			= new Integer[0];	
		selectedRemoveGroupIds		= new Integer[0];	
		selectedAddProxyUserIds		= new Integer[0];
		selectedRemoveProxyUserIds	= new Integer[0];
		currentProxyUserId			= null;
		selectedLanguageId        	= null;
		selectedSessionTimeout     	= null;
		selectedSystemViewTypeId   	= PageId.CATEGORY_VIEW;
		selectedQuota	        	= null;
        pswdMismatchCount           = null;
		proxyValidFrom				= "";
		proxyValidUntil				= "";
		proxyDescription			= "";
		validFrom		   			= "";
		validUntil		   			= "";
		selectedIndex 				= new Integer(-1);

		username					= "";
		title 						= "";
		firstname 					= "";
		lastname 					= "";
		email 						= "";
		company 					= "";
		department 					= "";
		street 						= "";
		zip 						= "";
		city 						= "";
		fax 						= "";
		phone 						= "";
		mobile 						= "";
		contactURL 					= "";
		homepageURL 				= "";
		selectedCategoryId			= String.valueOf(VKCCategory.ROOT_CATEGORY_ID);
		redirect					= "";
	    enableHtmlNotification      = false;
		adminPrivileges				= false;
		accountValid				= false;
		manageOwnUsers				= false;
		manageOwnUsersSystemViews	= false;
		manageOwnGroups				= false;
		manageOwnProxies			= false;
		manageVirtualDocumentQueries= false;
		showEmail					= false;
		showTree					= false;
		languageChanged				= false;
		allowManageSystemViewType	= false;
		userStatistics 				= null;
		userQuota 					= null;        
	}

	/**
	 * Validiert die Eingabefelder und gibt gegebenfalls die Fehler zurück
	 *
	 * @param mapping The mapping used to select this instance
	 * @param request The servlet request we are processing
	 */
	public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
		ActionErrors errors = new ActionErrors();		

		setAccountValid(request.getParameter("accountValid") != null);
        
		if (getUser().hasAdminPrivileges()) {
			setAdminPrivileges(request.getParameter("adminPrivileges" ) != null);
			setManageOwnGroups(request.getParameter("manageOwnGroups" ) != null);
			setManageOwnProxies(request.getParameter("manageOwnProxies" ) != null);
			setManageOwnUsers(request.getParameter("manageOwnUsers") != null);
			setManageOwnUsersSystemViews(request.getParameter("manageOwnUsersSystemViews") != null);
			setManageVirtualDocumentQueries(request.getParameter("manageVirtualDocumentQueries") != null);
		}
        
		setShowEmail(request.getParameter("showEmail") != null);
		setShowTree(request.getParameter("showTree") != null);
		setAllowManageSystemViewType(request.getParameter("allowManageSystemViewType") != null);
        setEnableHtmlNotification(request.getParameter("enableHtmlNotification") != null);

		if (request.getParameter("action.save.profile") != null) {
			synchronizeForm(request);
			
			if (!getEditUser().isExternalUser()) {
			    validateAccountValid(errors);
				validateUser(errors);
			}
			if (getUser().hasAdminPrivileges() && !getAddProxyUserLabels().isEmpty()) {
				validateProxyUsers(errors);
			}
			
			// check, if any dyna attribute name must not be empty
			validateDynaAttributes(errors);
		}
        
		return errors;
	}

	private void validateDynaAttributes(ActionErrors errors) {
        List dynaAttrList = getDynaAttributes();
        
        for (int i = 0; i < dynaAttrList.size(); i++) {
            UserDynAttr dynaAttr = (UserDynAttr)dynaAttrList.get(i);
            
            if (isEmpty(dynaAttr.getName())) {
                errors.add("dynaAttributeName_" + i, new ActionError("error.document.dynaattribute.name", String.valueOf(i + 1)));
            }
        }	
	}

	private void validateAccountValid(ActionErrors errors) {
		String from  = getValidFrom();
		String until = getValidUntil();
		Date f = null;
		Date u = null;
				
		if (!isEmpty(from)) {
			if ((f = DateUtils.parseDate(from)) == null) {
				errors.add("validFrom", new ActionError("error.date"));
			}
		}

		if (!isEmpty(until)) {
			if ((u = DateUtils.parseDate(until)) == null) {
				errors.add("validUntil", new ActionError("error.date"));
			}
		}
				
		if (f != null && u != null && f.after(u)) {
			errors.add("date", new ActionError("error.date.range"));
		}
	}

	private void validateUser(ActionErrors errors) {
		if (isEmpty(getUsername())) {
			errors.add("username", new ActionError("vkc.administration.error.username.required"));
		}

		if (isEmpty( getFirstname())) {
			errors.add("firstname", new ActionError("vkc.administration.error.firstname.required"));
		}

		if (isEmpty(getLastname())) {
			errors.add("lastname", new ActionError("vkc.administration.error.lastname.required"));
		}

		if (isEmpty(getEmail())) {
			errors.add("email", new ActionError("vkc.administration.error.email.required"));
		} else if (!StringUtils.isEmailValid(getEmail())) {
			errors.add("email", new ActionError("vkc.administration.error.email.invalid"));
		}

		if (getUser().hasAdminPrivileges() && isEmpty(getSelectedQuota())) {
			errors.add("quota", new ActionError("vkc.administration.error.quota.required"));
		}

		try {
			if (!getEditUser().getUser().equals(VKCStringUtils.filterUnicodeChars(getUsername())) && VKCUserSerializer.isUserExistent(VKCStringUtils.filterUnicodeChars(getUsername()))) {
				errors.add("username.exist", new ActionError("vkc.administration.error.username.exist"));
			}
		} catch (DBException e) {
			VKCLogManager.errorLog(this, "", e.getMessage(), e);
		}
	}
	
	
	 private void synchronizeDynaAttributes(HttpServletRequest request) {
        getDynaAttributes().clear();
        int i=0;

        while (request.getParameter("dynaAttributeName_" + i) != null)  {
            String name  = StringUtils.normalize(request.getParameter("dynaAttributeName_" + i));
            String value = StringUtils.normalize(request.getParameter("dynaAttributeValue_" + i));
            int autorization = Integer.valueOf(request.getParameterValues("autorization")[i]).intValue();	            
            getDynaAttributes().add(new UserDynAttr(name, value,autorization));
            i++;
        }	      
    }

	private void validateProxyUsers(ActionErrors errors) {
		for (int i = 0; i < getAddProxyUserLabels().size(); i++) {
			UserInfo userInfo = (UserInfo)getAddProxyUserLabels().get(i);
			String from  = null;
			String until = null;
			Date f = null;
			Date u = null;

			if (!userInfo.getUserId().equals(getCurrentProxyUserId())) {
				from  = (String)getDynaValue("proxyValidFrom_" + userInfo.getUserId().toString());
				until = (String)getDynaValue("proxyValidUntil_" + userInfo.getUserId().toString());
			} else {
				from  = getProxyValidFrom();
				until = getProxyValidUntil();
			}
				
			if (!isEmpty(from)) {
				if (DateUtils.parseDate(from) == null) {
					errors.add("validFrom_" + userInfo.getUserId().toString(), new ActionError("error.proxy.startdate", userInfo.getLastnameLabel()));
				} else {
					f = DateUtils.parseDate(from);
				}
			}

			if (!isEmpty(until)) {
				if (DateUtils.parseDate(until) == null) {
					errors.add("validUntil_" + userInfo.getUserId().toString(), new ActionError("error.proxy.enddate", userInfo.getLastnameLabel()));
				} else {
					u = DateUtils.parseDate(until);
				}
			}
				
			if (f != null && u != null && f.after(u)) {
				errors.add("date_" + userInfo.getUserId().toString(), new ActionError("error.proxy.date.range", userInfo.getLastnameLabel()));
			}
		}
	}

	public void synchronizeForm(HttpServletRequest request) {
		try {
			setEditUser(VKCUserSerializer.retrieveUser(getUserId()));			
			List languageLabels = VKCLanguageSerializer.getLanguages();
			final Collator collator = Collator.getInstance(getUser().getLanguage().getLocale());
            setPswdMismatchCount(getEditUser().getPwdMismatchCount());

			Comparator language_c = new Comparator() {
				public int compare(Object o1, Object o2) {
					VKCLanguage l1 = (VKCLanguage) o1;
					VKCLanguage l2 = (VKCLanguage) o2;
					
                	CollationKey key1 = collator.getCollationKey(VKCStringUtils.decodeXmlEntities(l1.getName()));
                	CollationKey key2 = collator.getCollationKey(VKCStringUtils.decodeXmlEntities(l2.getName()));
                	
                	return key1.compareTo(key2);
				}
			};

			Collections.sort(languageLabels, language_c);
			setLanguageLabels(languageLabels);

			synchronizeDynaAttributes(request);

			if (!init(request)) {
				List addGroupLabels = new ArrayList();
				List removeGroupLabels = new ArrayList();
				List groupInfos = new ArrayList();
				Integer[] addGroupIds = getAddGroupIds();
		
				if (getUser().hasAdminPrivileges()) {
					groupInfos = VKCGroupSerializer.retrieveGroupInfos();
				} else if (getUser().isDedicatedUsersAdmin()) {
					groupInfos = getDedicatedAdminGroups();
				}
		
				for (int i = 0; i < addGroupIds.length; i++) {
					for (int j = 0; j < groupInfos.size(); j++) {
						GroupInfo g = (GroupInfo) groupInfos.get(j);
						
						if (addGroupIds[i].equals(g.getGroupId())) {
							addGroupLabels.add(g);
							groupInfos.remove(j);
							break;
						}
					}
				}
		
				removeGroupLabels = groupInfos;

				Comparator name_c = new Comparator() {
					public int compare(Object o1, Object o2) {
						GroupInfo g1 = (GroupInfo)o1;
						GroupInfo g2 = (GroupInfo)o2;

	                	CollationKey key1 = collator.getCollationKey(VKCStringUtils.decodeXmlEntities(g1.getName()));
	                	CollationKey key2 = collator.getCollationKey(VKCStringUtils.decodeXmlEntities(g2.getName()));
	                	
	                	return key1.compareTo(key2);
					}
				};

				Collections.sort(addGroupLabels, name_c);
				Collections.sort(removeGroupLabels, name_c);
				setAddGroupLabels(addGroupLabels);
				setRemoveGroupLabels(removeGroupLabels);
			}
			
			if (!init(request) && getUser().hasAdminPrivileges()) {
				UserInfo userInfo = VKCUserSerializer.retrieveUserInfo(getEditUser().getUserId());
				List addProxyUserLabels = new ArrayList();
				List removeProxyUserLabels = new ArrayList();
				List userInfos = VKCUserSerializer.retrieveUserInfos();
				Integer[] addProxyUserIds = getAddProxyUserIds();

				//Eigenen Eintrag entfernen
				userInfos.remove(userInfo);

				for (int i = 0; i < addProxyUserIds.length; i++) {
					for (int j = 0; j < userInfos.size(); j++) {
						UserInfo u = (UserInfo) userInfos.get(j);
						
						if (addProxyUserIds[i].equals(u.getUserId())) {
							addProxyUserLabels.add(u);
							userInfos.remove(j);
							break;
						}
					}
				}
	
				removeProxyUserLabels = userInfos;

				Comparator lastname_c = new Comparator() {
					public int compare(Object o1, Object o2) {
						UserInfo u1 = (UserInfo) o1;
						UserInfo u2 = (UserInfo) o2;
						
	                	CollationKey key1 = collator.getCollationKey(VKCStringUtils.decodeXmlEntities(u1.getLastname()));
	                	CollationKey key2 = collator.getCollationKey(VKCStringUtils.decodeXmlEntities(u2.getLastname()));
	                	
	                	return key1.compareTo(key2);
					}
				};

				Collections.sort(addProxyUserLabels, lastname_c);
				Collections.sort(removeProxyUserLabels, lastname_c);
				setAddProxyUserLabels(addProxyUserLabels);
				setRemoveProxyUserLabels(removeProxyUserLabels);
				List list = Arrays.asList(getAddProxyUserIds());
				
				if (!list.isEmpty() && !list.contains(getCurrentProxyUserId())) {
					setCurrentProxyUserId(((UserInfo)addProxyUserLabels.get(0)).getUserId());
					Integer[] ids = {getCurrentProxyUserId()};
					setSelectedRemoveProxyUserIds(ids);
					setProxyDescription((String)getDynaValue("proxyDescription_" + getCurrentProxyUserId().toString()));
					setProxyValidFrom((String)getDynaValue("proxyValidFrom_" + getCurrentProxyUserId().toString()));
					setProxyValidUntil((String)getDynaValue("proxyValidUntil_" + getCurrentProxyUserId().toString()));
				} else if (!list.isEmpty()) {
					Integer[] ids = {getCurrentProxyUserId()};
					
					if (!getSelectedRemoveProxyUserIds()[0].equals(ids[0])) {
						setSelectedRemoveProxyUserIds(ids);
						setProxyDescription((String)getDynaValue("proxyDescription_" + getCurrentProxyUserId().toString()));
						setProxyValidFrom((String)getDynaValue("proxyValidFrom_" + getCurrentProxyUserId().toString()));
						setProxyValidUntil((String)getDynaValue("proxyValidUntil_" + getCurrentProxyUserId().toString()));
					}
				} else {
					setCurrentProxyUserId(null);
					setProxyDescription("");
					setProxyValidFrom("");
					setProxyValidUntil("");
				}
			}					
			
			if (init(request)) {
				initializeForm(request);
			}
		} catch (DBException e) {
			VKCLogManager.errorLog(this, "", e.getMessage(), e);
		}
	}

	private boolean init(HttpServletRequest request) {
		return (request.getParameter("initialize") != null) == true;
	}

	private void initializeForm(HttpServletRequest request) throws DBException {
		setUsername(getEditUser().getUser());
		setTitle(getEditUser().getTitle());
		setFirstname(getEditUser().getFirstname());
		setLastname(getEditUser().getLastname());
		setEmail(getEditUser().getEmail());
		setCompany(getEditUser().getCompany());
		setDepartment(getEditUser().getDepartment());
		setStreet(getEditUser().getStreet());
		setZip(getEditUser().getZip());
		setCity(getEditUser().getCity());
		setFax(getEditUser().getFax());
		setPhone(getEditUser().getPhone());
		setMobile(getEditUser().getMobile());
		setContactURL(getEditUser().getContactURL());
		setHomepageURL(getEditUser().getHomepageURL());
		setShowEmail(getEditUser().getShowEmail());
		setShowTree(getEditUser().getShowTree());
		setAccountValid(getEditUser().getAccountValid());
		setAllowManageSystemViewType(getEditUser().isAllowManageSystemViewType());
        setEnableHtmlNotification(getEditUser().isEnableHtmlNotification());
      
		Integer homeCategoryId = getEditUser().getHomeCategoryId();
		
		if (homeCategoryId != null && homeCategoryId.intValue() > 0) {
			setSelectedCategoryId(homeCategoryId.toString());
		}

		if (getEditUser().getValidFrom() != null) {
			Date from = new Date(getEditUser().getValidFrom().getTime());
			setValidFrom(DateUtils.getDD_MM_YYYY(from));
		} else {
			setValidFrom("");
		}

		if (getEditUser().getValidUntil() != null) {
			Date until = new Date(getEditUser().getValidUntil().getTime());
			setValidUntil(DateUtils.getDD_MM_YYYY(until));
		} else {
			setValidUntil("");
		}
			
		if (getLanguageLabels().contains(getEditUser().getLanguage())) {
			int index = getLanguageLabels().indexOf(getEditUser().getLanguage());
			VKCLanguage l = (VKCLanguage)getLanguageLabels().get(index);
			setSelectedLanguageId(l.getLanguageId());
		} else {
			setSelectedLanguageId(VKCLanguageSerializer.getDefaultLanguage().getLanguageId());
		}
		
		setSelectedQuota((getEditUser().getQuota() == null) ? "null" : getEditUser().getQuota().toString());
		setSelectedSessionTimeout(getEditUser().getSessionTimeout());
		setSelectedSystemViewTypeId(getEditUser().getSystemViewTypeId());
        setPswdMismatchCount(getEditUser().getPwdMismatchCount());
				
		List addGroupLabels = new ArrayList();
		List removeGroupLabels = new ArrayList();
		List groupInfos = new ArrayList();
		List userGroups = new ArrayList(getEditUser().getGroups());
		List addGroupIds = new ArrayList();
		
		if (getUser().hasAdminPrivileges()) {
			groupInfos = VKCGroupSerializer.retrieveGroupInfos();
		} else if (getUser().isDedicatedUsersAdmin()) {
			groupInfos = getDedicatedAdminGroups();
		}
		
		for (int i = 0; i < userGroups.size(); i++) {
			VKCGroup group = (VKCGroup)userGroups.get(i);
			
			for (int j = 0; j < groupInfos.size(); j++) {
				GroupInfo g = (GroupInfo) groupInfos.get(j);
				
				if (group.getGroupId().equals(g.getGroupId())) {
					addGroupIds.add(g.getGroupId());
					addGroupLabels.add(g);
					groupInfos.remove(j);
					break;
				}
			}
		}
		
		removeGroupLabels = groupInfos;
		final Collator collator = Collator.getInstance(getUser().getLanguage().getLocale());

		Comparator name_c = new Comparator() {
			public int compare(Object o1, Object o2) {
				GroupInfo g1 = (GroupInfo)o1;
				GroupInfo g2 = (GroupInfo)o2;
				
            	CollationKey key1 = collator.getCollationKey(VKCStringUtils.decodeXmlEntities(g1.getName()));
            	CollationKey key2 = collator.getCollationKey(VKCStringUtils.decodeXmlEntities(g2.getName()));
            	
            	return key1.compareTo(key2);
			}
		};

		Collections.sort(addGroupLabels, name_c);
		Collections.sort(removeGroupLabels, name_c);
		setAddGroupLabels(addGroupLabels);
		setRemoveGroupLabels(removeGroupLabels);
		setAddGroupIds((Integer[])addGroupIds.toArray(new Integer[0]));

		if (getUser().hasAdminPrivileges()) {
			setAdminPrivileges(getEditUser().getAdminPrivileges());
			setManageOwnGroups(getEditUser().getManageOwnGroups());
			setManageOwnProxies(getEditUser().getManageOwnProxies());
			setManageOwnUsers(getEditUser().getManageOwnUsers());
			setManageOwnUsersSystemViews(getEditUser().isManageOwnUsersSystemViews());
			setManageVirtualDocumentQueries(getEditUser().isManageVirtualDocumentQueries());

			UserInfo userInfo = VKCUserSerializer.retrieveUserInfo(getEditUser().getUserId());

			List proxyUsers = new ArrayList(VKCProxyUserSerializer.getUsersForProxy(getEditUser().getUserId(), false));
			List addProxyUserLabels = new ArrayList();
			List removeProxyUserLabels = new ArrayList();
			List userInfos = VKCUserSerializer.retrieveUserInfos();
			List addProxyUserIds = new ArrayList();
		
			//Eigenen Eintrag entfernen
			userInfos.remove(userInfo);
		
			for (int i = 0; i < proxyUsers.size(); i++) {
				VKCProxyUser pu = (VKCProxyUser) proxyUsers.get(i);
				addProxyUserIds.add(pu.getUserId());
				int index = userInfos.indexOf(new UserInfo(pu.getUserId()));
				UserInfo u = (UserInfo)userInfos.get(index);
				addProxyUserLabels.add(u);
				userInfos.remove(index);
				setDynaValue("proxyDescription_" + pu.getUserId().toString(), pu.getDescription());
				setDynaValue("proxyValidFrom_" + pu.getUserId().toString(), pu.getValidFromLabel());
				setDynaValue("proxyValidUntil_" + pu.getUserId().toString(), pu.getValidUntilLabel());
			}
	
			removeProxyUserLabels = userInfos;

			Comparator lastname_c = new Comparator() {
				public int compare( Object o1, Object o2 ) {
					UserInfo u1 = (UserInfo) o1;
					UserInfo u2 = (UserInfo) o2;
					
                	CollationKey key1 = collator.getCollationKey(VKCStringUtils.decodeXmlEntities(u1.getLastname()));
                	CollationKey key2 = collator.getCollationKey(VKCStringUtils.decodeXmlEntities(u2.getLastname()));
                	
                	return key1.compareTo(key2);
				}
			};

			Collections.sort(addProxyUserLabels, lastname_c);
			Collections.sort(removeProxyUserLabels, lastname_c);
			setAddProxyUserLabels(addProxyUserLabels);
			setRemoveProxyUserLabels(removeProxyUserLabels);
			setAddProxyUserIds((Integer[])addProxyUserIds.toArray(new Integer[0]));

			if (!addProxyUserLabels.isEmpty()) {
				setCurrentProxyUserId(((UserInfo)addProxyUserLabels.get(0)).getUserId());
				Integer[] ids = {getCurrentProxyUserId()};
				setSelectedRemoveProxyUserIds(ids);
				setProxyDescription((String)getDynaValue("proxyDescription_" + getCurrentProxyUserId().toString()));
				setProxyValidFrom((String)getDynaValue("proxyValidFrom_" + getCurrentProxyUserId().toString()));
				setProxyValidUntil((String)getDynaValue("proxyValidUntil_" + getCurrentProxyUserId().toString()));
			}
		}
		
		// Dyn. Attribute initialisieren
		List userDynAttr = new ArrayList(getEditUser().getDynaAttributes());
		getDynaAttributes().clear();

		for (int i = 0; i < userDynAttr.size(); i++) {
			VKCDynUserAttribute dynaAttr = (VKCDynUserAttribute) userDynAttr.get(i);
			UserDynAttr bean = new UserDynAttr(dynaAttr.getName(), dynaAttr.getValue(), dynaAttr.getAutorization().intValue());
			getDynaAttributes().add(bean);
		}
	}

	public void setPswdMismatchCount(Integer pwdMismatch) {
        pswdMismatchCount = pwdMismatch;
        
    }

    public Integer[] getAddGroupIds() {
		return addGroupIds;
	}

	public List getAddGroupLabels() {
		return addGroupLabels;
	}

	public Integer[] getAddProxyUserIds() {
		return addProxyUserIds;
	}

	public List getAddProxyUserLabels() {
		return addProxyUserLabels;
	}

    public String getCategoryPath() {
        VKCCategoryAbsPath cap = null;
        Integer categoryId = null;
        
        categoryId = Integer.valueOf(getSelectedCategoryId());
        
        try {
            cap = VKCCategorySerializer.getCategoryAbsPath(categoryId);
        } catch (DBException e) {
        }

        if (cap == null) {
            return getResources().getMessage(getLocale(), "vkc.profile.error.homecategory");
        }
        
        return cap.getAbsolutePathString();
    }
    
	public String getCity() {
		return city;
	}

	public String getCompany() {
		return company;
	}

	public String getContactURL() {
		return contactURL;
	}

	public Integer getCurrentProxyUserId() {
		return currentProxyUserId;
	}

	private List getDedicatedAdminGroups() throws DBException {
		List groupInfos = VKCGroupSerializer.retrieveGroupInfos();
		List groups = new ArrayList();
		int creatorId = getUser().getUserId().intValue();

		for (int i = 0; i < groupInfos.size(); i++) {
			GroupInfo g = (GroupInfo)groupInfos.get(i);
			
			if (creatorId == g.getCreatorId().intValue()) {
				groups.add(g);
			}
		}
		
		return groups;
	}

	public String getDepartment() {
		return department;
	}

	public VKCUser getEditUser() {
		return editUser;
	}

	public String getEmail() {
		return email;
	}

	public String getFax() {
		return fax;
	}

	public String getFirstname() {
		return firstname;
	}

	public HashSet getGroups() throws DBException {
		HashSet groups = new HashSet();

		if (getUser().hasAdminPrivileges()) {
			for (int i = 0; i < getAddGroupLabels().size(); i++) {
				GroupInfo groupInfo = (GroupInfo)getAddGroupLabels().get(i);
				VKCGroup group = VKCGroupSerializer.retrieveGroup(groupInfo.getGroupId());
				groups.add(group);
			}
		} else if (getUser().isDedicatedUsersAdmin()) {
			List groupInfos = getDedicatedAdminGroups();
			List addGroupInfos = new ArrayList();
			List removeGroupInfos = new ArrayList();
			List userGroupIds = getEditUser().getGroupIds();
			Set userGroups = getEditUser().getGroups();
			
			for (int i = 0; i < getAddGroupIds().length; i++) {
				for (int j = 0; j < groupInfos.size(); j++) {
					GroupInfo g = (GroupInfo)groupInfos.get(j);
					
					if ( getAddGroupIds()[i].equals(g.getGroupId())) {
						addGroupInfos.add(g);
					 	groupInfos.remove(j);
					 	break;
					}
				}
			}
			
			removeGroupInfos = groupInfos;
			
			for (int i = 0; i < addGroupInfos.size(); i++) {
				GroupInfo g = (GroupInfo)addGroupInfos.get(i);
				
				if (!userGroupIds.contains(g.getGroupId())) {
					VKCGroup group = VKCGroupSerializer.retrieveGroup(g.getGroupId());
					userGroups.add(group);
				}
			}

			for (int i = 0; i < removeGroupInfos.size(); i++) {
				GroupInfo g = (GroupInfo)removeGroupInfos.get(i);
				
				if (userGroupIds.contains(g.getGroupId())) {
					VKCGroup group = VKCGroupSerializer.retrieveGroup(g.getGroupId());
					userGroups.remove(group);
				}
			}
			
			groups = new HashSet(userGroups);
		} else {
			groups = new HashSet(getEditUser().getGroups());
		}
		
		return groups;
	}

	public String getSelectedCategoryId() {
		return selectedCategoryId;
	}

	public HashMap getHomeLinkParams() {
		HashMap params = new HashMap();
		params.put("categoryId", getSelectedCategoryId());
		
		return params;
	}
	
	public String getHomepageURL() {
		return homepageURL;
	}

	public List getLanguageLabels() {
		return languageLabels;
	}

	public String getLastname() {
		return lastname;
	}

	public String getMobile() {
		return mobile;
	}

	public String getPhone() {
		return phone;
	}

	public String getProxyDescription() {
		return proxyDescription;
	}

	public List getOwnProxiesAsUserInfoSortedByLastname() throws DBException {
		List proxyUsers = new ArrayList(VKCProxyUserSerializer.getUsersForProxy(getEditUser().getUserId(), false));
		List userInfos = new ArrayList();
		
		if (proxyUsers.isEmpty()) {
			return userInfos;
		} 

		final Collator collator = Collator.getInstance(getUser().getLanguage().getLocale());

		Comparator lastname_c = new Comparator() {
			public int compare(Object o1, Object o2) {
				UserInfo u1 = (UserInfo) o1;
				UserInfo u2 = (UserInfo) o2;
				
            	CollationKey key1 = collator.getCollationKey(VKCStringUtils.decodeXmlEntities(u1.getLastname()));
            	CollationKey key2 = collator.getCollationKey(VKCStringUtils.decodeXmlEntities(u2.getLastname()));
            	
            	return key1.compareTo(key2);
			}
		};

		for (int i = 0; i < proxyUsers.size(); i++) {
			VKCProxyUser pu = (VKCProxyUser)proxyUsers.get(i);
			userInfos.add(VKCUserSerializer.retrieveUserInfo(pu.getUserId()));
		}

		Collections.sort(userInfos, lastname_c);
		
		return userInfos;
	}

	public List getProxiesAsUserInfoSortedByLastname() throws DBException {
		List proxyUsers = new ArrayList(VKCProxyUserSerializer.getProxyUsersForUser(getEditUser().getUserId(), false));
		List userInfos = new ArrayList();
		
		if (proxyUsers.isEmpty()) {
			return userInfos;
		} 

		final Collator collator = Collator.getInstance(getUser().getLanguage().getLocale());

		Comparator lastname_c = new Comparator() {
			public int compare(Object o1, Object o2) {
				UserInfo u1 = (UserInfo) o1;
				UserInfo u2 = (UserInfo) o2;
				
            	CollationKey key1 = collator.getCollationKey(VKCStringUtils.decodeXmlEntities(u1.getLastname()));
            	CollationKey key2 = collator.getCollationKey(VKCStringUtils.decodeXmlEntities(u2.getLastname()));
            	
            	return key1.compareTo(key2);
			}
		};

		for (int i = 0; i < proxyUsers.size(); i++) {
			VKCProxyUser pu = (VKCProxyUser)proxyUsers.get(i);
			userInfos.add(VKCUserSerializer.retrieveUserInfo(pu.getProxyUserId()));
		}

		Collections.sort(userInfos, lastname_c);
		
		return userInfos;
	}

	public List getProxyUsers() {
		List proxyUsers = new ArrayList();
		
		for (int i = 0; i < getAddProxyUserLabels().size(); i++) {
			UserInfo u = (UserInfo)getAddProxyUserLabels().get(i);
			VKCProxyUser pu = new VKCProxyUser();
			String description = null;
			String from  = null;
			String until = null;

			if (!u.getUserId().equals(getCurrentProxyUserId())) {
				description  = (String)getDynaValue("proxyDescription_" + u.getUserId().toString());
				from  = (String)getDynaValue("proxyValidFrom_" + u.getUserId().toString());
				until = (String)getDynaValue("proxyValidUntil_" + u.getUserId().toString());
			} else {
				description = getProxyDescription();
				from  = getProxyValidFrom();
				until = getProxyValidUntil();
			}

			if (!isEmpty(from)) {
				pu.setValidFrom(new Timestamp(DateUtils.parseDate(from).getTime()));
			} else {
				pu.setValidFrom(null);
			}

			if (!isEmpty(until)) {
				Calendar c = Calendar.getInstance();
				c.setTime(DateUtils.parseDate(until));
				c.set(Calendar.HOUR_OF_DAY, 23);
				c.set(Calendar.MINUTE, 59);
				c.set(Calendar.SECOND, 59);
				pu.setValidUntil(new Timestamp(c.getTimeInMillis()));
			} else {
				pu.setValidUntil(null);
			}
			
			pu.setUserId(u.getUserId());
			pu.setProxyUserId(getEditUser().getUserId());
			pu.setCreatorId(getUser().getUserId());
			pu.setDescription(VKCStringUtils.filterUnicodeChars(description));
			pu.setCreated(new Timestamp(System.currentTimeMillis()));
			
			proxyUsers.add(pu);
		}

		return proxyUsers;
	}

	public Object getOwnProxyUser(int id) throws DBException {
		List proxyUsers = new ArrayList(VKCProxyUserSerializer.getUsersForProxy(getEditUser().getUserId(), false));
		
		for (int i = 0; i < proxyUsers.size(); i++) {
			VKCProxyUser pu = (VKCProxyUser)proxyUsers.get(i);
			
			if (pu.getUserId().intValue() == id) {
				return proxyUsers.get(i);
			}
		}
		
		return null;
	}

	public Object getProxyUser(int id) throws DBException {
		List proxyUsers = new ArrayList(VKCProxyUserSerializer.getProxyUsersForUser(getEditUser().getUserId(), false));
		
		for (int i = 0; i < proxyUsers.size(); i++) {
			VKCProxyUser pu = (VKCProxyUser)proxyUsers.get(i);
			
			if (pu.getProxyUserId().intValue() == id) {
				return proxyUsers.get(i);
			}
		}
		
		return null;
	}

	public String getProxyValidFrom() {
		return proxyValidFrom;
	}

	public String getProxyValidUntil() {
		return proxyValidUntil;
	}

	public List getRemoveGroupLabels() {
		return removeGroupLabels;
	}

	public List getRemoveProxyUserLabels() {
		return removeProxyUserLabels;
	}

	public String getRedirect() {
	    return redirect;
	}
	
	public String getRedirectPath() {
	    if (!isEmpty(getRedirect())) {
		    return VKCStringUtils.base64Decode(getRedirect());
	    }
	    
	    return "/userList.do";
	}
	
	public String getChangeUserPasswordPath() {
	    return "/changeUserPassword.do?userId=" + getUserId() + "&redirect=" + getRedirect();
	}

	public String getChangeCreatorPublishershipPath() {
	    return "/changeCreatorPublishership.do?userId=" + getUserId() + "&redirect=" + getRedirect();
	}
	
    public String getCopyAdminRightsPath() {
        return "/copyAdminRights.do?userId=" + getUserId() + "&redirect=" + getRedirect();
    }
    
	public Integer[] getSelectedAddGroupIds() {
		return selectedAddGroupIds;
	}

	public Integer[] getSelectedRemoveGroupIds() {
		return selectedRemoveGroupIds;
	}

	public Integer[] getSelectedAddProxyUserIds() {
		return selectedAddProxyUserIds;
	}

	public Integer getSelectedLanguageId() {
		return selectedLanguageId;
	}

	public String getSelectedQuota() {
		return selectedQuota;
	}

	public Integer[] getSelectedRemoveProxyUserIds() {
		return selectedRemoveProxyUserIds;
	}

	public Integer getSelectedSessionTimeout() {
		return selectedSessionTimeout;
	}

	public String getStreet() {
		return street;
	}

	public String getTitle() {
		return title;
	}

	public Integer getUserId() {
		return userId;
	}

	public String getValidFrom() {
		return validFrom;
	}

	public String getValidUntil() {
		return validUntil;
	}

	public String getZip() {
		return zip;
	}

	public boolean isAccountValid() {
		return accountValid;
	}

	public boolean isAdminPrivileges() {
		return adminPrivileges;
	}

	public boolean isManageOwnGroups() {
		return manageOwnGroups;
	}

	public boolean isManageOwnProxies() {
		return manageOwnProxies;
	}

	public boolean isManageOwnUsers() {
		return manageOwnUsers;
	}

	public boolean isShowEmail() {
		return showEmail;
	}

	public void setAccountValid(boolean b) {
		accountValid = b;
	}

	public void setAddGroupIds(Integer[] integers) {
		addGroupIds = integers;
	}

	public void setAddGroupLabels(List list) {
		addGroupLabels = list;
	}

	public void setAddProxyUserIds(Integer[] integers) {
		addProxyUserIds = integers;
	}

	public void setAddProxyUserLabels(List list) {
		addProxyUserLabels = list;
	}

	public void setAdminPrivileges(boolean b) {
		adminPrivileges = b;
	}

	public void setCity(String s) {
		city = StringUtils.normalize(s);
	}

	public void setCompany(String s) {
		company = StringUtils.normalize(s);
	}

	public void setContactURL(String s) {
		contactURL = StringUtils.normalize(s);
	}

	public void setCurrentProxyUserId(Integer integer) {
		currentProxyUserId = integer;
	}

	public void setDepartment(String s) {
		department = StringUtils.normalize(s);
	}

	public void setEditUser(VKCUser user) {
		editUser = user;
	}

	public void setEmail(String s) {
		email = StringUtils.normalize(s);
	}

	public void setFax(String s) {
		fax = StringUtils.normalize(s);
	}

	public void setFirstname(String s) {
		firstname = StringUtils.normalize(s);
	}

	public void setSelectedCategoryId(String s) {
		selectedCategoryId = StringUtils.normalize(s);
	}

	public void setHomepageURL(String s) {
		homepageURL = StringUtils.normalize(s);
	}

	public void setLanguageLabels(List list) {
		languageLabels = list;
	}

	public void setLastname(String s) {
		lastname = StringUtils.normalize(s);
	}

	public void setManageOwnGroups(boolean b) {
		manageOwnGroups = b;
	}

	public void setManageOwnProxies(boolean b) {
		manageOwnProxies = b;
	}

	public void setManageOwnUsers(boolean b) {
		manageOwnUsers = b;
	}

	public void setMobile(String s) {
		mobile = StringUtils.normalize(s);
	}

	public void setPhone(String s) {
		phone = StringUtils.normalize(s);
	}

	public void setProxyDescription(String s) {
		proxyDescription = StringUtils.normalize(s);
	}

	public void setProxyValidFrom(String s) {
		proxyValidFrom = StringUtils.normalize(s);
	}

	public void setProxyValidUntil(String s) {
		proxyValidUntil = StringUtils.normalize(s);
	}

	public void setRemoveGroupLabels(List list) {
		removeGroupLabels = list;
	}

	public void setRemoveProxyUserLabels(List list) {
		removeProxyUserLabels = list;
	}

	public void setRedirect(String s) {
	    redirect = StringUtils.normalize(s);
	}
	
	public void setSelectedAddGroupIds(Integer[] integers) {
		selectedAddGroupIds = integers;
	}

	public void setSelectedAddProxyUserIds(Integer[] integers) {
		selectedAddProxyUserIds = integers;
	}

	public void setSelectedLanguageId(Integer integer) {
		selectedLanguageId = integer;
	}

	public void setSelectedQuota(String s) {
		selectedQuota = StringUtils.normalize(s);
	}

	public void setSelectedRemoveGroupIds(Integer[] integers) {
		selectedRemoveGroupIds = integers;
	}

	public void setSelectedRemoveProxyUserIds(Integer[] integers) {
		selectedRemoveProxyUserIds = integers;
	}

	public void setSelectedSessionTimeout(Integer integer) {
		selectedSessionTimeout = integer;
	}

	public void setShowEmail(boolean b) {
		showEmail = b;
	}

	public void setStreet(String s) {
		street = StringUtils.normalize(s);
	}

	public void setTitle(String s) {
		title = StringUtils.normalize(s);
	}

	public void setUserId(Integer integer) {
		userId = integer;
	}

	public void setValidFrom(String s) {
		validFrom = StringUtils.normalize(s);
	}

	public void setValidUntil(String s) {
		validUntil = StringUtils.normalize(s);
	}

	public void setZip(String s) {
		zip = StringUtils.normalize(s);
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String s) {
		username = StringUtils.normalize(s);
	}
	
    public VKCQuotaInfo getUserQuota() throws DBException {
        if (userQuota == null) {
            userQuota = WebShare.database.getQuotaInfo(getUserId(), true);
        }
        
        return userQuota;
    }

    public UserStatistics getUserStatistics() throws DBException {
        if (userStatistics == null) {
            userStatistics = UserHelper.getUserStatistics(getUserId());
        }
        
        return userStatistics;
    }

	public boolean isAllowManageSystemViewType() {
		return allowManageSystemViewType;
	}

	public void setAllowManageSystemViewType(boolean allowManageSystemViewType) {
		this.allowManageSystemViewType = allowManageSystemViewType;
	}

	public Integer getSelectedSystemViewTypeId() {
		return selectedSystemViewTypeId;
	}

	public void setSelectedSystemViewTypeId(Integer selectedSystemViewTypeId) {
		this.selectedSystemViewTypeId = selectedSystemViewTypeId;
	}

	public boolean isManageOwnUsersSystemViews() {
		return manageOwnUsersSystemViews;
	}

	public void setManageOwnUsersSystemViews(boolean manageOwnUsersSystemViews) {
		this.manageOwnUsersSystemViews = manageOwnUsersSystemViews;
	}

	public boolean isManageVirtualDocumentQueries() {
		return manageVirtualDocumentQueries;
	}

	public void setManageVirtualDocumentQueries(boolean manageVirtualDocumentQueries) {
		this.manageVirtualDocumentQueries = manageVirtualDocumentQueries;
	}

	public boolean getShowTree() {
		return showTree;
	}

	public void setShowTree(boolean showTree) {
		this.showTree = showTree;
	}

	public boolean isLanguageChanged() {
		return languageChanged;
	}

	public void setLanguageChanged(boolean languageChanged) {
		this.languageChanged = languageChanged;
	}

	public List getDynaAttributes() {
		return dynaAttributes;
	}

	public void setDynaAttributes(List userDynAttr) {
		this.dynaAttributes = userDynAttr;
	}
	public Integer getSelectedIndex() {
        return selectedIndex;
    }

    public void setSelectedIndex(Integer i) {
        selectedIndex = i;
    }
 
    public boolean isEnableHtmlNotification() {
        return enableHtmlNotification;
    }

    public void setEnableHtmlNotification(boolean enableHtmlNotification) {
        this.enableHtmlNotification = enableHtmlNotification;
    }
    public Integer getPswdMismatchCount(){        
        return pswdMismatchCount;
    }
}