<commit_before>/**
 * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.apache.geronimo.st.core;

import java.io.File;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jst.server.generic.core.internal.GenericServerRuntime;

public class GenericGeronimoServerRuntime extends GenericServerRuntime
		implements IGeronimoRuntime {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.wst.server.core.model.RuntimeDelegate#validate()
	 */
	public IStatus validate() {
		String version = detectVersion();
		if (!getRuntime().getRuntimeType().getVersion().equals(version))
			return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, null, null);
		return super.validate();
	}

	public String detectVersion() {
		File libDir = getRuntime().getLocation().append("lib").toFile();
		if (libDir.exists()) {
			File[] libs = libDir.listFiles();
			URL systemjarURL = null;
			for (int i = 0; i < libs.length; i++) {
				if (libs[i].getName().startsWith("geronimo-system")) {
					try {
						systemjarURL = libs[i].toURL();
						break;
					} catch (MalformedURLException e) {
						e.printStackTrace();
					}
				}
			}
			URLClassLoader cl = new URLClassLoader(new URL[] { systemjarURL });
			try {
				Class clazz = cl.loadClass("org.apache.geronimo.system.serverinfo.ServerConstants");
				Method method = clazz.getMethod("getVersion", new Class[] {});
				return (String) method.invoke(null, null);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}
}
<commit_msg>fix validation problem<commit_after>/**
 * Copyright 2004, 2005 The Apache Software Foundation or its licensors, as applicable
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.apache.geronimo.st.core;

import java.io.File;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jst.server.generic.core.internal.GenericServerRuntime;

public class GenericGeronimoServerRuntime extends GenericServerRuntime
		implements IGeronimoRuntime {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.wst.server.core.model.RuntimeDelegate#validate()
	 */
	public IStatus validate() {
		/*String version = detectVersion();
		if (!getRuntime().getRuntimeType().getVersion().equals(version))
			return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, null, null);*/
		return super.validate();
	}

	public String detectVersion() {
		File libDir = getRuntime().getLocation().append("lib").toFile();
		if (libDir.exists()) {
			File[] libs = libDir.listFiles();
			URL systemjarURL = null;
			for (int i = 0; i < libs.length; i++) {
				if (libs[i].getName().startsWith("geronimo-system")) {
					try {
						systemjarURL = libs[i].toURL();
						break;
					} catch (MalformedURLException e) {
						e.printStackTrace();
					}
				}
			}
			URLClassLoader cl = new URLClassLoader(new URL[] { systemjarURL });
			try {
				Class clazz = cl.loadClass("org.apache.geronimo.system.serverinfo.ServerConstants");
				Method method = clazz.getMethod("getVersion", new Class[] {});
				return (String) method.invoke(null, null);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		return null;
	}
}

{'fraction_non_alphanumeric': 0.12009642778873549, 'fraction_numerical': 0.006136313828621521, 'mean_word_length': 3.8501594048884167, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '685472', 'n_tokens_mistral': 1529, 'n_tokens_neox': 1352, 'n_words': 386}