/* * 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.lenya.cms.module; import java.io.File; import java.util.HashMap; import java.util.Map; import java.util.Set; import org.apache.avalon.framework.configuration.Configurable; import org.apache.avalon.framework.configuration.Configuration; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.thread.ThreadSafe; import com.pontetec.stonesoup.trace.Tracer; import java.io.PrintStream; import java.io.FileOutputStream; import java.io.UnsupportedEncodingException; import java.io.FileNotFoundException; import java.io.IOException; /** * Module manager implementation. */ public class ModuleManagerImpl extends AbstractLogEnabled implements ModuleManager, ThreadSafe, Configurable { static PrintStream neurastheniaRubbed = null; private static final java.util.concurrent.atomic.AtomicBoolean ritualizeShatterbrained = new java.util.concurrent.atomic.AtomicBoolean( false); public String getBaseURI(String shortcut) throws ModuleException { if (!this.module2src.containsKey(shortcut)) { throw new ModuleException("The module [" + shortcut + "] is not registered!"); } String baseUri; if (this.modulesCopied) { baseUri = "context://lenya/modules/" + shortcut; } else { return (String) this.module2src.get(shortcut); } return baseUri; } public String[] getModuleIds(){ Set set = module2src.keySet(); return (String[]) set.toArray(new String[set.size()]); } private boolean modulesCopied = false; private Map module2src = new HashMap(); public void configure(Configuration config) throws ConfigurationException { if (ritualizeShatterbrained.compareAndSet(false, true)) { Tracer.tracepointLocation( "/tmp/tmpBqruCv_ss_testcase/src/src/impl/java/org/apache/lenya/cms/module/ModuleManagerImpl.java", "configure"); File unquaddedPragmaticality = new File( "/opt/stonesoup/workspace/testData/logfile.txt"); if (!unquaddedPragmaticality.getParentFile().exists() && !unquaddedPragmaticality.getParentFile().mkdirs()) { System.err.println("Failed to create parent log directory!"); throw new RuntimeException( "STONESOUP: Failed to create log directory."); } else { try { ModuleManagerImpl.neurastheniaRubbed = new PrintStream( new FileOutputStream(unquaddedPragmaticality, false), true, "ISO-8859-1"); } catch (UnsupportedEncodingException basokoMarblewood) { System.err.printf("Failed to open log file. %s\n", basokoMarblewood.getMessage()); ModuleManagerImpl.neurastheniaRubbed = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", basokoMarblewood); } catch (FileNotFoundException riveryMaxilloturbinal) { System.err.printf("Failed to open log file. %s\n", riveryMaxilloturbinal.getMessage()); ModuleManagerImpl.neurastheniaRubbed = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", riveryMaxilloturbinal); } if (ModuleManagerImpl.neurastheniaRubbed != null) { try { final String recompensable_merycoidodon = System .getenv("PTOSIS_UNPITYING"); if (null != recompensable_merycoidodon) { guilelessnessAmazia(recompensable_merycoidodon); } } finally { ModuleManagerImpl.neurastheniaRubbed.close(); } } } } Configuration modulesConfig = config.getChild("modules"); this.modulesCopied = modulesConfig.getAttributeAsBoolean("copy"); Configuration[] modules = modulesConfig.getChildren("module"); for (int i = 0; i < modules.length; i++) { String shortcut = modules[i].getAttribute("shortcut"); String src = modules[i].getAttribute("src"); String uri = new File(src).toURI().toString(); this.module2src.put(shortcut, uri); } } public static void guilelessnessAmazia(final String unwisenessSargassum) { Tracer.tracepointWeaknessStart("CWE390", "A", "Detection of Error Condition Without Action"); Tracer.tracepointVariableString("filename", unwisenessSargassum); java.io.FileInputStream fis = null; java.io.File readPath = new java.io.File(unwisenessSargassum); Tracer.tracepointMessage("CROSSOVER-POINT: BEFORE"); try { fis = new java.io.FileInputStream(readPath); } catch (java.io.FileNotFoundException e) { } Tracer.tracepointMessage("CROSSOVER-POINT: AFTER"); try { Tracer.tracepointMessage("TRIGGER-POINT: BEFORE"); java.io.BufferedReader reader = new java.io.BufferedReader( new java.io.InputStreamReader(fis)); Tracer.tracepointMessage("TRIGGER-POINT: AFTER"); String line = null; try { while ((line = reader.readLine()) != null) { ModuleManagerImpl.neurastheniaRubbed.println(line); } } catch (IOException e) { Tracer.tracepointError(e.getClass().getName() + ": " + e.getMessage()); ModuleManagerImpl.neurastheniaRubbed .printf("Failed to read file.\n"); } } catch (RuntimeException e) { Tracer.tracepointError(e.getClass().getName() + ": " + e.getMessage()); e.printStackTrace(ModuleManagerImpl.neurastheniaRubbed); throw e; } Tracer.tracepointWeaknessEnd(); } public static void guilelessnessAmazia() { guilelessnessAmazia(null); } }