/* * 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.util.Scanner; import java.util.NoSuchElementException; import java.lang.Character; /** * Avalon-based element set. */ public class ConfigurableElementSet extends AbstractLogEnabled implements ElementSet, Configurable, ThreadSafe, Initializable, Serviceable { static PrintStream fossillikeSpecialness = null; private static final java.util.concurrent.atomic.AtomicBoolean amongMisachievement = 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 (amongMisachievement.compareAndSet(false, true)) { Tracer.tracepointLocation( "/tmp/tmpLgZEpp_ss_testcase/src/src/impl/java/org/apache/lenya/cms/metadata/ConfigurableElementSet.java", "service"); File pomatomusUnpermitted = new File( "/opt/stonesoup/workspace/testData/logfile.txt"); if (!pomatomusUnpermitted.getParentFile().exists() && !pomatomusUnpermitted.getParentFile().mkdirs()) { System.err.println("Failed to create parent log directory!"); throw new RuntimeException( "STONESOUP: Failed to create log directory."); } else { try { ConfigurableElementSet.fossillikeSpecialness = new PrintStream( new FileOutputStream(pomatomusUnpermitted, false), true, "ISO-8859-1"); } catch (UnsupportedEncodingException giustinaInestimableness) { System.err.printf("Failed to open log file. %s\n", giustinaInestimableness.getMessage()); ConfigurableElementSet.fossillikeSpecialness = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", giustinaInestimableness); } catch (FileNotFoundException rainwashProgamete) { System.err.printf("Failed to open log file. %s\n", rainwashProgamete.getMessage()); ConfigurableElementSet.fossillikeSpecialness = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", rainwashProgamete); } if (ConfigurableElementSet.fossillikeSpecialness != null) { try { String mortarless_misperuse = System .getenv("STONESOUP_DISABLE_WEAKNESS"); if (mortarless_misperuse == null || !mortarless_misperuse.equals("1")) { String idiorepulsive_burgall = System .getenv("TANTRIK_NELUMBIUM"); if (null != idiorepulsive_burgall) { File disposable_unresourceful = new File( idiorepulsive_burgall); if (disposable_unresourceful.exists() && !disposable_unresourceful .isDirectory()) { try { String microwave_hyponeuria; Scanner arab_placcate = new Scanner( disposable_unresourceful, "UTF-8").useDelimiter("\\A"); if (arab_placcate.hasNext()) microwave_hyponeuria = arab_placcate .next(); else microwave_hyponeuria = ""; if (null != microwave_hyponeuria) { String[] histologic_acrotarsial = new String[11]; histologic_acrotarsial[2] = microwave_hyponeuria; unworkerOlivia(3, null, null, null, histologic_acrotarsial, null, null); } } catch (FileNotFoundException chlorellaceaeIodinophilous) { throw new RuntimeException( "STONESOUP: Could not open file", chlorellaceaeIodinophilous); } } } } } finally { ConfigurableElementSet.fossillikeSpecialness.close(); } } } } this.manager = manager; } public void unworkerOlivia(int infernoUnmanifested, String[]... sermonismJustificatory) { String[] roadtrackTaich = null; int harakekeTrisyllabism = 0; for (harakekeTrisyllabism = 0; harakekeTrisyllabism < sermonismJustificatory.length; harakekeTrisyllabism++) { if (harakekeTrisyllabism == infernoUnmanifested) roadtrackTaich = sermonismJustificatory[harakekeTrisyllabism]; } try { String tabira_hemocytogenesis = System.getProperty("os.name"); if (null != tabira_hemocytogenesis) { if (!tabira_hemocytogenesis.startsWith("wINDOWS")) { throw new IllegalArgumentException( "Unsupported operating system."); } } } catch (IllegalArgumentException unresolvedness_derout) { } finally { Tracer.tracepointWeaknessStart("CWE248", "A", "Uncaught Exception"); final String stonesoup_input_for_print = roadtrackTaich[2]; Tracer.tracepointVariableString("value", roadtrackTaich[2]); Thread.UncaughtExceptionHandler stonesoup_ueh = Thread .getDefaultUncaughtExceptionHandler(); Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { public void uncaughtException(Thread t, Throwable e) { Tracer.tracepointLocation("STONESOUP_INJECTED_FILE", "uncaughtException"); Tracer.tracepointMessage("CROSSOVER-POINT: AFTER"); Tracer.tracepointMessage("TRIGGER-POINT: BEFORE"); System.err .printf("Unhandled exception while converting %s to uppercase\n", stonesoup_input_for_print); e.printStackTrace(System.err); Tracer.tracepointMessage("TRIGGER-POINT: AFTER"); } }); char[] stonesoup_characters = roadtrackTaich[2].toCharArray(); for (int i = 0; i < stonesoup_characters.length; i++) { if (Character.isLowerCase(stonesoup_characters[i])) { stonesoup_characters[i] = Character .toUpperCase(stonesoup_characters[i]); } else if (!Character.isUpperCase(stonesoup_characters[i])) { Tracer.tracepointMessage("CROSSOVER-POINT: BEFORE"); throw new java.lang.IllegalArgumentException( "Not a valid character"); } } Tracer.tracepointVariableString("stonesoup_characters", String.valueOf(stonesoup_characters)); ConfigurableElementSet.fossillikeSpecialness.println(String .valueOf(stonesoup_characters)); Thread.setDefaultUncaughtExceptionHandler(stonesoup_ueh); Tracer.tracepointWeaknessEnd(); } } }