All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.edu.icm.unity.home.HomeEndpointProperties Maven / Gradle / Ivy

There is a newer version: 3.3.4
Show newest version
/*
 * Copyright (c) 2014 ICM Uniwersytet Warszawski All rights reserved.
 * See LICENCE.txt file for licensing information.
 */
package pl.edu.icm.unity.home;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

import org.apache.log4j.Logger;

import eu.unicore.util.configuration.ConfigurationException;
import eu.unicore.util.configuration.DocumentationReferenceMeta;
import eu.unicore.util.configuration.DocumentationReferencePrefix;
import eu.unicore.util.configuration.PropertyMD;
import pl.edu.icm.unity.base.utils.Log;
import pl.edu.icm.unity.engine.api.config.UnityPropertiesHelper;

/**
 * Configuration of the Home endpoint.
 * 
 * @author K. Benedyczak
 */
public class HomeEndpointProperties extends UnityPropertiesHelper
{
	private static final Logger log = Log.getLegacyLogger(Log.U_SERVER_CFG, HomeEndpointProperties.class);

	public enum Components {credentialTab, preferencesTab, userDetailsTab, accountUpdateTab, 
		accountRemoval, attributesManagement, userInfo, identitiesManagement,
		accountLinking};

	public enum RemovalModes {remove, disable, blockAuthentication};
	
	@DocumentationReferencePrefix
	public static final String PREFIX = "unity.userhome.";
	
	@DocumentationReferenceMeta
	public final static Map META = new HashMap();

	public static final String DISABLED_COMPONENTS = "disabledComponents.";
	public static final String ATTRIBUTES = "attributes.";
	public static final String ENQUIRIES = "accountUpdateEnquiries.";
	public static final String GWA_ATTRIBUTE = "attribute";
	public static final String GWA_GROUP = "group";
	public static final String GWA_SHOW_GROUP = "showGroup";
	public static final String GWA_EDITABLE = "editable";
	public static final String REMOVAL_MODE = "selfRemovalMode";
	public static final String DISABLE_REMOVAL_SCHEDULE = "disableSelfRemovalScheduling";
	public static final String ENABLE_PROJECT_MANAGEMENT_LINK = "enableProjectManagementLink";
	public static final String PROJECT_MANAGEMENT_ENDPOINT = "projectManagementEndpoint";
	
	static
	{
		META.put(DISABLED_COMPONENTS, new PropertyMD().setList(false).
				setDescription("List of tags of UI components "
				+ "which should be disabled. Valid tags: '" + 
				Arrays.deepToString(Arrays.asList(Components.values(), "oauthTokens").toArray()) + "'"));
		META.put(REMOVAL_MODE, new PropertyMD(RemovalModes.remove).
				setDescription("Relevant ONLY if the " + DISABLE_REMOVAL_SCHEDULE + " is true. "
				+ "Controls what action should be performed when user "
				+ "orders account removal. Account can be fully removed, "
				+ "disabled, or only login can be blocked."));
		META.put(DISABLE_REMOVAL_SCHEDULE, new PropertyMD("false").
				setDescription("If set to true then user won't be presented with an "
						+ "option to schedule account removal with grace period. "
						+ "At the same time this enables " + REMOVAL_MODE));
		META.put(ATTRIBUTES, new PropertyMD().setStructuredList(true).
				setDescription("Prefix under which it is possible to define attributes "
				+ "which should be either presented or made editable on the User Home UI."));
		META.put(GWA_ATTRIBUTE, new PropertyMD().setStructuredListEntry(ATTRIBUTES).setMandatory().
				setDescription("Attribute name."));
		META.put(GWA_GROUP, new PropertyMD().setStructuredListEntry(ATTRIBUTES).setMandatory().
				setDescription("Group of the attribute."));
		META.put(GWA_EDITABLE, new PropertyMD("true").setStructuredListEntry(ATTRIBUTES).
				setDescription("If enabled and the attribute is marked as self modificable,"
				+ " it will be possible to edit it. Otherwise it is shown in "
				+ "read only mode."));
		META.put(GWA_SHOW_GROUP, new PropertyMD("false").setStructuredListEntry(ATTRIBUTES).
				setDescription("If true then the group is shown next to the attribute."));
		META.put(ENQUIRIES, new PropertyMD().setList(false).
				setDescription("List of enquiries to be presented on User Home UI."));	
		META.put(ENABLE_PROJECT_MANAGEMENT_LINK, new PropertyMD("true").setDescription(
				"If true then the project managament link is shown in header of User Home UI."));
		META.put(PROJECT_MANAGEMENT_ENDPOINT, new PropertyMD().setDescription(
				"If project management link is active, then link redirect to this endpoint address. By default first active project management endpoint is used."));
	}
	
	public HomeEndpointProperties(Properties properties) throws ConfigurationException
	{
		super(PREFIX, properties, META, log);
	}
	
	public Set getDisabledComponents()
	{
		return new HashSet<>(getListOfValues(DISABLED_COMPONENTS));
	}
	
	public List getEnabledEnquiries()
	{
		return new ArrayList<>(getListOfValues(ENQUIRIES));
	}
	
	public boolean isProjectManLinkIsEnabled()
	{
		return getBooleanValue(ENABLE_PROJECT_MANAGEMENT_LINK);
	}
	
	public String getProjectManEndpoint()
	{
		return getValue(PROJECT_MANAGEMENT_ENDPOINT);
	}	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy