<commit_before>package edu.iu.grid.oim.view.divrep;

import java.io.PrintWriter;

import org.apache.commons.lang.StringEscapeUtils;
import org.bouncycastle.asn1.x500.X500Name;

import com.divrep.DivRep;
import com.divrep.DivRepEvent;
import com.divrep.common.DivRepFormElement;
import com.divrep.common.DivRepTextBox;
import com.divrep.validator.DivRepIValidator;

public class CNEditor extends DivRepFormElement<String> {

	boolean user_modified = false;
	public boolean hasUserModified() { return user_modified; }
	
	DivRepTextBox cn;
	public CNEditor(DivRep parent) {
		super(parent);
		cn = new DivRepTextBox(this);
		cn.addValidator(new DivRepIValidator<String>(){
			boolean valid = true;
			
			@Override
			public Boolean isValid(String value) {
				//I am not sure how effective this is..
				try {
					X500Name name = new X500Name("CN="+value);
				} catch(Exception e) {
					return false;
				}
				
				if(value.contains("/")) {
					//we can't use / in apache format.. which is the format stored in our DB<commit_msg>Made CNEditor a bit shorter fit in screen more often<commit_after>package edu.iu.grid.oim.view.divrep;

import java.io.PrintWriter;

import org.apache.commons.lang.StringEscapeUtils;
import org.bouncycastle.asn1.x500.X500Name;

import com.divrep.DivRep;
import com.divrep.DivRepEvent;
import com.divrep.common.DivRepFormElement;
import com.divrep.common.DivRepTextBox;
import com.divrep.validator.DivRepIValidator;

public class CNEditor extends DivRepFormElement<String> {

	boolean user_modified = false;
	public boolean hasUserModified() { return user_modified; }
	
	DivRepTextBox cn;
	public CNEditor(DivRep parent) {
		super(parent);
		cn = new DivRepTextBox(this);
		cn.setWidth(200);
		cn.addValidator(new DivRepIValidator<String>(){
			boolean valid = true;
			
			@Override
			public Boolean isValid(String value) {
				//I am not sure how effective this is..
				try {
					X500Name name = new X500Name("CN="+value);
				} catch(Exception e) {
					return false;
				}
				
				if(value.contains("/")) {
					//we can't use / in apache format.. which is the format stored in our DB
{'fraction_non_alphanumeric': 0.10362694300518134, 'fraction_numerical': 0.013659915214319359, 'mean_word_length': 3.9859154929577465, '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': '125077', 'n_tokens_mistral': 795, 'n_tokens_neox': 677, 'n_words': 173}