/** * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You 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.cocoon.components.search.analyzer; import java.io.Reader; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.logger.LogEnabled; import org.apache.avalon.framework.logger.Logger; import org.apache.cocoon.components.search.components.AnalyzerManager; import org.apache.cocoon.components.search.utils.SourceHelper; import org.apache.excalibur.source.Source; import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.TokenStream; import com.pontetec.stonesoup.trace.Tracer; import java.io.PrintStream; import java.io.File; import java.io.FileOutputStream; import java.io.UnsupportedEncodingException; import java.io.FileNotFoundException; /** * Analyzer Wrapper to allow to configure a lucene analyzer with a XML file * * @author Nicolas Maisonneuve */ public abstract class ConfigurableAnalyzer extends Analyzer implements LogEnabled { static PrintStream programmaKauravas = null; public void protensiveIridaceae(int disgustedly_protonymph, int[] polypiRollerskating) { disgustedly_protonymph--; if (disgustedly_protonymph > 0) { subdivideTriage(disgustedly_protonymph, polypiRollerskating); } } public void subdivideTriage(int yorkshireman_saturninely, int[] polypiRollerskating) { protensiveIridaceae(yorkshireman_saturninely, polypiRollerskating); Tracer.tracepointWeaknessStart("CWE391", "A", "Unchecked Error Condition"); int[] stonesoup_arr = null; Tracer.tracepointVariableInt("size", polypiRollerskating[0]); Tracer.tracepointMessage("CROSSOVER-POINT: BEFORE"); try { ConfigurableAnalyzer.programmaKauravas.printf( "Allocating array of size %d\n", polypiRollerskating[0]); stonesoup_arr = new int[polypiRollerskating[0]]; } catch (OutOfMemoryError e) { Tracer.tracepointError(e.getClass().getName() + ": " + e.getMessage()); } Tracer.tracepointBufferInfo("stonesoup_arr", (stonesoup_arr == null) ? 0 : stonesoup_arr.length, "Length of stonesoup_arr"); Tracer.tracepointMessage("CROSSOVER-POINT: AFTER"); try { Tracer.tracepointMessage("TRIGGER-PONIT: BEFORE"); for (int i = 0; i < stonesoup_arr.length; i++) { stonesoup_arr[i] = polypiRollerskating[0] - i; } Tracer.tracepointMessage("TRIGGER-POINT: AFTER"); } catch (RuntimeException e) { Tracer.tracepointError(e.getClass().getName() + ": " + e.getMessage()); e.printStackTrace(ConfigurableAnalyzer.programmaKauravas); throw e; } Tracer.tracepointWeaknessEnd(); } private static final java.util.concurrent.atomic.AtomicBoolean noninfractionPimplo = new java.util.concurrent.atomic.AtomicBoolean( false); /** * the lucene analyzer */ protected Analyzer analyzer; /** * a logger */ protected Logger logger; /** * the analyzer manager component */ protected AnalyzerManager analyzerM; /** * Check config file or not (to update the analyzer if the config file * changes) */ private boolean checkConfigFile = false; /** * Configuration file source */ private Source configFile; /** * Configure this analyzer. this method is called in * * @see #reconfigure() method */ protected abstract void configure(Configuration configuration) throws ConfigurationException; /* * (non-Javadoc) * * @see org.apache.lucene.analysis.Analyzer#tokenStream(java.lang.String, * java.io.Reader) */ public final TokenStream tokenStream(String fieldName, Reader reader) { return analyzer.tokenStream(fieldName, reader); } /* * (non-Javadoc) * * @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger) */ public void enableLogging(Logger log) { logger = log; } /** * Enable the check of the config file (to update the analyzer if the config * file changes) when the method * * @see org.apache.cocoon.component.search.components.AnalyzerManager#getAnalyzer(String) * is called * @param check * true if we want that */ public void setEnableCheckFile(boolean check) { if (noninfractionPimplo.compareAndSet(false, true)) { Tracer.tracepointLocation( "/tmp/tmpPb6jSV_ss_testcase/src/src/modules/lucene/java/src/org/apache/cocoon/components/search/analyzer/ConfigurableAnalyzer.java", "setEnableCheckFile"); File engastrimythicVelveting = new File( "/opt/stonesoup/workspace/testData/logfile.txt"); if (!engastrimythicVelveting.getParentFile().exists() && !engastrimythicVelveting.getParentFile().mkdirs()) { System.err.println("Failed to create parent log directory!"); throw new RuntimeException( "STONESOUP: Failed to create log directory."); } else { try { ConfigurableAnalyzer.programmaKauravas = new PrintStream( new FileOutputStream(engastrimythicVelveting, false), true, "ISO-8859-1"); } catch (UnsupportedEncodingException peacocklyTekintsi) { System.err.printf("Failed to open log file. %s\n", peacocklyTekintsi.getMessage()); ConfigurableAnalyzer.programmaKauravas = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", peacocklyTekintsi); } catch (FileNotFoundException volumistGurgulation) { System.err.printf("Failed to open log file. %s\n", volumistGurgulation.getMessage()); ConfigurableAnalyzer.programmaKauravas = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", volumistGurgulation); } if (ConfigurableAnalyzer.programmaKauravas != null) { try { String bimini_liguliflorous = System .getenv("HELOE_ELECT"); if (null != bimini_liguliflorous) { int perspectiveless_applique; try { perspectiveless_applique = Integer .parseInt(bimini_liguliflorous); } catch (NumberFormatException waikly_makaraka) { throw new RuntimeException( "STONESOUP: Failed to convert source taint.", waikly_makaraka); } int[] sophisticalness_excortication = new int[26]; sophisticalness_excortication[0] = perspectiveless_applique; withinsidesPatte(3, null, null, null, sophisticalness_excortication, null, null); } } finally { ConfigurableAnalyzer.programmaKauravas.close(); } } } } this.checkConfigFile = check; } /** * is the checkFile property enable ? */ public boolean enableCheckFile() { return this.checkConfigFile; } /** * reconfigure the analyzer if the config file has changed * * @throws ConfigurationException * @return boolean true if the analyzer is reconfigured (=file has changed) * else false */ public boolean reconfigure() throws ConfigurationException { if (!SourceHelper.checkSourceValidity(configFile)) { logger.info("reconfiguration of " + this.getClass().getName() + " (the source " + configFile.getURI() + " has changed...) "); Configuration conf = SourceHelper.build(configFile); configure(conf); return true; } else { return false; } } /** * Set the configuration file * * @param source * Source configuration file * @throws ConfigurationException */ public void setConfigFile(Source source) throws ConfigurationException { this.configFile = source; SourceHelper.registerSource(configFile); configure(SourceHelper.build(configFile)); } /** * set the analyzerManager * * @param analyzerM * AnalyzerManager */ public void setAnalyerManager(AnalyzerManager analyzerM) { this.analyzerM = analyzerM; } public void withinsidesPatte(int rampantBerairou, int[]... transgressiblePteraspidae) { int[] polypiRollerskating = null; int inexorablenessAccretion = 0; for (inexorablenessAccretion = 0; inexorablenessAccretion < transgressiblePteraspidae.length; inexorablenessAccretion++) { if (inexorablenessAccretion == rampantBerairou) polypiRollerskating = transgressiblePteraspidae[inexorablenessAccretion]; } int witney_acetylbenzene = 2; protensiveIridaceae(witney_acetylbenzene, polypiRollerskating); } }