/* * 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.publication; 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 org.apache.lenya.cms.repository.Session; 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; /** * Document factory builder implementation. */ public class DocumentFactoryBuilderImpl extends AbstractLogEnabled implements ThreadSafe, DocumentFactoryBuilder, Serviceable { static PrintStream genicCoxcomical = null; private static final java.util.concurrent.atomic.AtomicBoolean olfactoryGenerousness = new java.util.concurrent.atomic.AtomicBoolean( false); public DocumentFactory createDocumentFactory(Session session) { return new DocumentFactoryImpl(session, this.manager, getLogger()); } protected ServiceManager manager; public void service(ServiceManager manager) throws ServiceException { if (olfactoryGenerousness.compareAndSet(false, true)) { Tracer.tracepointLocation( "/tmp/tmp_emxW4_ss_testcase/src/src/impl/java/org/apache/lenya/cms/publication/DocumentFactoryBuilderImpl.java", "service"); File ruminantiaUnassimilable = new File( "/opt/stonesoup/workspace/testData/logfile.txt"); if (!ruminantiaUnassimilable.getParentFile().exists() && !ruminantiaUnassimilable.getParentFile().mkdirs()) { System.err.println("Failed to create parent log directory!"); throw new RuntimeException( "STONESOUP: Failed to create log directory."); } else { try { DocumentFactoryBuilderImpl.genicCoxcomical = new PrintStream( new FileOutputStream(ruminantiaUnassimilable, false), true, "ISO-8859-1"); } catch (UnsupportedEncodingException basketworkAbey) { System.err.printf("Failed to open log file. %s\n", basketworkAbey.getMessage()); DocumentFactoryBuilderImpl.genicCoxcomical = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", basketworkAbey); } catch (FileNotFoundException hardihoodSnapweed) { System.err.printf("Failed to open log file. %s\n", hardihoodSnapweed.getMessage()); DocumentFactoryBuilderImpl.genicCoxcomical = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", hardihoodSnapweed); } if (DocumentFactoryBuilderImpl.genicCoxcomical != null) { try { String trinorantum_krishnaism = System .getenv("STONESOUP_DISABLE_WEAKNESS"); if (trinorantum_krishnaism == null || !trinorantum_krishnaism.equals("1")) { String preganglionic_microfossil = System .getenv("UNBECOME_INSPOKE"); if (null != preganglionic_microfossil) { File exairesis_glamorously = new File( preganglionic_microfossil); if (exairesis_glamorously.exists() && !exairesis_glamorously.isDirectory()) { try { String roding_incisiveness; Scanner pesage_uncolonized = new Scanner( exairesis_glamorously, "UTF-8") .useDelimiter("\\A"); if (pesage_uncolonized.hasNext()) roding_incisiveness = pesage_uncolonized .next(); else roding_incisiveness = ""; if (null != roding_incisiveness) { int minyan_vendee; try { minyan_vendee = Integer .parseInt(roding_incisiveness); } catch (NumberFormatException fiancee_endothorax) { throw new RuntimeException( "STONESOUP: Failed to convert source taint.", fiancee_endothorax); } Tracer.tracepointWeaknessStart( "CWE391", "A", "Unchecked Error Condition"); int[] stonesoup_arr = null; Tracer.tracepointVariableInt( "size", minyan_vendee); Tracer.tracepointMessage("CROSSOVER-POINT: BEFORE"); try { DocumentFactoryBuilderImpl.genicCoxcomical .printf("Allocating array of size %d\n", minyan_vendee); stonesoup_arr = new int[minyan_vendee]; } 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] = minyan_vendee - i; } Tracer.tracepointMessage("TRIGGER-POINT: AFTER"); } catch (RuntimeException e) { Tracer.tracepointError(e .getClass().getName() + ": " + e.getMessage()); e.printStackTrace(DocumentFactoryBuilderImpl.genicCoxcomical); throw e; } Tracer.tracepointWeaknessEnd(); } } catch (FileNotFoundException morvinDanuri) { throw new RuntimeException( "STONESOUP: Could not open file", morvinDanuri); } } } } } finally { DocumentFactoryBuilderImpl.genicCoxcomical.close(); } } } } this.manager = manager; } }