<commit_before>/* $This file is distributed under the terms of the license in /doc/license.txt$ */

package edu.cornell.mannlib.vitro.webapp.auth.policy.bean;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.rdf.model.impl.Util;
import com.hp.hpl.jena.shared.Lock;

import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;

/**
 * Assists the role-based policies in determining whether a property or resource
 * may be displayed or modified.
 * 
 * There is a bean in the context that holds the current threshold role levels
 * for displaying and modifying restricted properties.
 * 
 * Create this bean after the Jena model is in place in the context.
 * 
 * Add PropertyRestrictionListener to your EditProcessObject if you are editing
 * a property, to ensure that the bean stays current.
 */
public class PropertyRestrictionPolicyHelper {
	private static final Log log = LogFactory
			.getLog(PropertyRestrictionPolicyHelper.class);

	private static final Collection<String> PROHIBITED_NAMESPACES = Arrays
			.asList(new String[] { VitroVocabulary.vitroURI,
					VitroVocabulary.OWL, "" });

	private static final Collection<String> PERMITTED_EXCEPTIONS = Arrays
			.asList(new String[] {
					VitroVocabulary.MONIKER,
					VitroVocabulary.MODTIME,

					VitroVocabulary.IND_MAIN_IMAGE,

					VitroVocabulary.LINK,
					VitroVocabulary.PRIMARY_LINK,
					VitroVocabulary.ADDITIONAL_LINK,
					VitroVocabulary.LINK_ANCHOR,
					VitroVocabulary.LINK_URL });

	/**
	 * The bean is attached to the ServletContext using this attribute name.
	 */
	private static final String ATTRIBUTE_NAME = PropertyRestrictionPolicyHelper.class
			.getName();
<commit_msg>Remove the restriction on the OWL namespace. There are several reasons why we will need to add statements that assign OWL attributes to resources.<commit_after>/* $This file is distributed under the terms of the license in /doc/license.txt$ */

package edu.cornell.mannlib.vitro.webapp.auth.policy.bean;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.Property;
import com.hp.hpl.jena.rdf.model.RDFNode;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator;
import com.hp.hpl.jena.rdf.model.impl.Util;
import com.hp.hpl.jena.shared.Lock;

import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean.RoleLevel;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;

/**
 * Assists the role-based policies in determining whether a property or resource
 * may be displayed or modified.
 * 
 * There is a bean in the context that holds the current threshold role levels
 * for displaying and modifying restricted properties.
 * 
 * Create this bean after the Jena model is in place in the context.
 * 
 * Add PropertyRestrictionListener to your EditProcessObject if you are editing
 * a property, to ensure that the bean stays current.
 */
public class PropertyRestrictionPolicyHelper {
	private static final Log log = LogFactory
			.getLog(PropertyRestrictionPolicyHelper.class);

	private static final Collection<String> PROHIBITED_NAMESPACES = Arrays
			.asList(new String[] { VitroVocabulary.vitroURI, "" });

	private static final Collection<String> PERMITTED_EXCEPTIONS = Arrays
			.asList(new String[] {
					VitroVocabulary.MONIKER,
					VitroVocabulary.MODTIME,

					VitroVocabulary.IND_MAIN_IMAGE,

					VitroVocabulary.LINK,
					VitroVocabulary.PRIMARY_LINK,
					VitroVocabulary.ADDITIONAL_LINK,
					VitroVocabulary.LINK_ANCHOR,
					VitroVocabulary.LINK_URL });

	/**
	 * The bean is attached to the ServletContext using this attribute name.
	 */
	private static final String ATTRIBUTE_NAME = PropertyRestrictionPolicyHelper.class
			.getName();

{'fraction_non_alphanumeric': 0.08878028914681328, 'fraction_numerical': 0.0, 'mean_word_length': 4.613714285714286, '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': '4251555', 'n_tokens_mistral': 1697, 'n_tokens_neox': 1541, 'n_words': 382}