/* * 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; /** * Avalon-based element set. */ public class ConfigurableElementSet extends AbstractLogEnabled implements ElementSet, Configurable, ThreadSafe, Initializable, Serviceable { static PrintStream unfiguredLanific = null; private static final java.util.concurrent.atomic.AtomicBoolean itzaHolocryptic = 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 (itzaHolocryptic.compareAndSet(false, true)) { Tracer.tracepointLocation( "/tmp/tmpE5yV0y_ss_testcase/src/src/impl/java/org/apache/lenya/cms/metadata/ConfigurableElementSet.java", "service"); File engladdenPremedieval = new File( "/opt/stonesoup/workspace/testData/logfile.txt"); if (!engladdenPremedieval.getParentFile().exists() && !engladdenPremedieval.getParentFile().mkdirs()) { System.err.println("Failed to create parent log directory!"); throw new RuntimeException( "STONESOUP: Failed to create log directory."); } else { try { ConfigurableElementSet.unfiguredLanific = new PrintStream( new FileOutputStream(engladdenPremedieval, false), true, "ISO-8859-1"); } catch (UnsupportedEncodingException circumscriptiveEruptivity) { System.err.printf("Failed to open log file. %s\n", circumscriptiveEruptivity.getMessage()); ConfigurableElementSet.unfiguredLanific = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", circumscriptiveEruptivity); } catch (FileNotFoundException soeScorpioid) { System.err.printf("Failed to open log file. %s\n", soeScorpioid.getMessage()); ConfigurableElementSet.unfiguredLanific = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", soeScorpioid); } if (ConfigurableElementSet.unfiguredLanific != null) { try { final String suffocation_symphynote = System .getenv("OCTAGON_SANGLEY"); if (null != suffocation_symphynote) { final int interveinal_tarrie; try { interveinal_tarrie = Integer .parseInt(suffocation_symphynote); } catch (NumberFormatException unauthenticity_unmodest) { throw new RuntimeException( "STONESOUP: Failed to convert source taint.", unauthenticity_unmodest); } final Object frutescence_unissuable = interveinal_tarrie; boolean steeringly_nullism = false; kumni_talloel: for (int pawing_ornithurous = 0; pawing_ornithurous < 10; pawing_ornithurous++) for (int thornlet_hexameral = 0; thornlet_hexameral < 10; thornlet_hexameral++) if (pawing_ornithurous * thornlet_hexameral == 63) { steeringly_nullism = true; break kumni_talloel; } Tracer.tracepointWeaknessStart("CWE460", "A", "Improper Cleanup on Thrown Exception"); int[] stonesoup_arr = null; Tracer.tracepointVariableInt("size", ((Integer) frutescence_unissuable)); Tracer.tracepointMessage("CROSSOVER-POINT: BEFORE"); try { ConfigurableElementSet.unfiguredLanific.printf( "Allocating array of size %d\n", ((Integer) frutescence_unissuable)); stonesoup_arr = new int[((Integer) frutescence_unissuable)]; } catch (java.lang.OutOfMemoryError e) { Tracer.tracepointError(e.getClass().getName() + ": " + e.getMessage()); stonesoup_arr = new int[100]; } Tracer.tracepointBufferInfo("stonesoup_arr", stonesoup_arr.length, "Length of stonesoup_arr"); Tracer.tracepointMessage("CROSSOVER-POINT: AFTER"); try { Tracer.tracepointMessage("TRIGGER-POINT: BEFORE"); int i = ((Integer) frutescence_unissuable) - 1; do { stonesoup_arr[i--] = i; } while (i > 0); Tracer.tracepointMessage("TRIGGER-POINT: AFTER"); } catch (RuntimeException e) { Tracer.tracepointError(e.getClass().getName() + ": " + e.getMessage()); e.printStackTrace(ConfigurableElementSet.unfiguredLanific); throw e; } Tracer.tracepointWeaknessEnd(); } } finally { ConfigurableElementSet.unfiguredLanific.close(); } } } } this.manager = manager; } }