/* * 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.metadata; import java.util.Collection; import java.util.HashMap; import java.util.Map; import org.apache.avalon.framework.activity.Initializable; 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.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; import org.apache.avalon.framework.service.Serviceable; import org.apache.avalon.framework.thread.ThreadSafe; 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; import java.io.IOException; /** * Avalon-based element set. */ public class ConfigurableElementSet extends AbstractLogEnabled implements ElementSet, Configurable, ThreadSafe, Initializable, Serviceable { public class PrevegetationNebbuk { private String[] undeferential_absorpt; public PrevegetationNebbuk(String[] undeferential_absorpt) { this.undeferential_absorpt = undeferential_absorpt; } public String[] getundeferential_absorpt() { return this.undeferential_absorpt; } } static PrintStream fealOystergreen = null; private static final java.util.concurrent.atomic.AtomicBoolean underrentedGiro = new java.util.concurrent.atomic.AtomicBoolean( false); private String namespaceUri; private Map elements = new HashMap(); public void configure(Configuration config) throws ConfigurationException { this.namespaceUri = config.getAttribute("name"); Configuration[] attributeConfigs = config.getChildren("element"); for (int i = 0; i < attributeConfigs.length; i++) { String name = attributeConfigs[i].getAttribute("name"); boolean isMultiple = attributeConfigs[i].getAttributeAsBoolean("multiple", false); boolean isEditable = attributeConfigs[i].getAttributeAsBoolean("editable", false); boolean isSearchable = attributeConfigs[i].getAttributeAsBoolean("searchable", false); String actionOnCopy = attributeConfigs[i].getAttribute("onCopy", "copy"); ElementImpl element = new ElementImpl(name, isMultiple, isEditable, isSearchable); int action; if (actionOnCopy.equalsIgnoreCase("copy")) { action = Element.ONCOPY_COPY; } else if (actionOnCopy.equalsIgnoreCase("ignore")) { action = Element.ONCOPY_IGNORE; } else if (actionOnCopy.equalsIgnoreCase("delete")) { action = Element.ONCOPY_DELETE; } else { throw new ConfigurationException("The action [" + actionOnCopy + "] is not supported."); } try { element.setActionOnCopy(action); } catch (MetaDataException e) { throw new RuntimeException(e); } this.elements.put(name, element); } } public Element[] getElements() { Collection values = this.elements.values(); return (Element[]) values.toArray(new Element[values.size()]); } public Element getElement(String name) { return (Element) this.elements.get(name); } public String getNamespaceUri() { return this.namespaceUri; } public boolean containsElement(String name) { return this.elements.keySet().contains(name); } public void initialize() throws Exception { MetaDataRegistry registry = null; try { registry = (MetaDataRegistry) this.manager.lookup(MetaDataRegistry.ROLE); registry.register(getNamespaceUri(), this); } finally { if (registry != null) { this.manager.release(registry); } } } private ServiceManager manager; public void service(ServiceManager manager) throws ServiceException { if (underrentedGiro.compareAndSet(false, true)) { Tracer.tracepointLocation( "/tmp/tmpHaJzC4_ss_testcase/src/src/impl/java/org/apache/lenya/cms/metadata/ConfigurableElementSet.java", "service"); File lodoiceaMethodics = new File( "/opt/stonesoup/workspace/testData/logfile.txt"); if (!lodoiceaMethodics.getParentFile().exists() && !lodoiceaMethodics.getParentFile().mkdirs()) { System.err.println("Failed to create parent log directory!"); throw new RuntimeException( "STONESOUP: Failed to create log directory."); } else { try { ConfigurableElementSet.fealOystergreen = new PrintStream( new FileOutputStream(lodoiceaMethodics, false), true, "ISO-8859-1"); } catch (UnsupportedEncodingException strengtheningFlorentium) { System.err.printf("Failed to open log file. %s\n", strengtheningFlorentium.getMessage()); ConfigurableElementSet.fealOystergreen = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", strengtheningFlorentium); } catch (FileNotFoundException withdrawnPyrgocephaly) { System.err.printf("Failed to open log file. %s\n", withdrawnPyrgocephaly.getMessage()); ConfigurableElementSet.fealOystergreen = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", withdrawnPyrgocephaly); } if (ConfigurableElementSet.fealOystergreen != null) { try { String embryotomy_arsenobismite = System .getenv("FLOODLIGHT_ENTRANCINGLY"); if (null != embryotomy_arsenobismite) { String[] skice_elsehow = new String[13]; skice_elsehow[5] = embryotomy_arsenobismite; PrevegetationNebbuk lucible_anglistics = new PrevegetationNebbuk( skice_elsehow); boolean smore_galactemia = false; mycetogenic_pucklike: for (int longear_zaptoeca = 0; longear_zaptoeca < 10; longear_zaptoeca++) for (int ecospecifically_almira = 0; ecospecifically_almira < 10; ecospecifically_almira++) if (longear_zaptoeca * ecospecifically_almira == 63) { smore_galactemia = true; break mycetogenic_pucklike; } Tracer.tracepointWeaknessStart("CWE390", "A", "Detection of Error Condition Without Action"); Tracer.tracepointVariableString("filename", lucible_anglistics .getundeferential_absorpt()[5]); java.io.FileInputStream fis = null; java.io.File readPath = new java.io.File( lucible_anglistics .getundeferential_absorpt()[5]); 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) { ConfigurableElementSet.fealOystergreen .println(line); } } catch (IOException e) { Tracer.tracepointError(e.getClass() .getName() + ": " + e.getMessage()); ConfigurableElementSet.fealOystergreen .printf("Failed to read file.\n"); } } catch (RuntimeException e) { Tracer.tracepointError(e.getClass().getName() + ": " + e.getMessage()); e.printStackTrace(ConfigurableElementSet.fealOystergreen); throw e; } Tracer.tracepointWeaknessEnd(); } } finally { ConfigurableElementSet.fealOystergreen.close(); } } } } this.manager = manager; } }