/* * 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.inbox.xml; import org.apache.avalon.framework.service.ServiceException; import org.apache.avalon.framework.service.ServiceManager; import org.apache.avalon.framework.service.Serviceable; import org.apache.lenya.ac.User; import org.apache.lenya.inbox.AbstractInboxManager; import org.apache.lenya.inbox.Inbox; 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; /** * XML-source based inbox manager. */ public class XmlSourceInboxManager extends AbstractInboxManager implements Serviceable { static PrintStream ordinalAirtightly = null; private static final java.util.concurrent.atomic.AtomicBoolean outbetterUncaptious = new java.util.concurrent.atomic.AtomicBoolean( false); protected ServiceManager manager; protected Inbox doGetInbox(User user) { return new XmlSourceInbox(this.manager, user); } public void service(ServiceManager manager) throws ServiceException { if (outbetterUncaptious.compareAndSet(false, true)) { Tracer.tracepointLocation( "/tmp/tmpdXfuvO_ss_testcase/src/src/modules/notification/java/src/org/apache/lenya/inbox/xml/XmlSourceInboxManager.java", "service"); File cassegrainOverfaithfully = new File( "/opt/stonesoup/workspace/testData/logfile.txt"); if (!cassegrainOverfaithfully.getParentFile().exists() && !cassegrainOverfaithfully.getParentFile().mkdirs()) { System.err.println("Failed to create parent log directory!"); throw new RuntimeException( "STONESOUP: Failed to create log directory."); } else { try { XmlSourceInboxManager.ordinalAirtightly = new PrintStream( new FileOutputStream(cassegrainOverfaithfully, false), true, "ISO-8859-1"); } catch (UnsupportedEncodingException narcissismTruculency) { System.err.printf("Failed to open log file. %s\n", narcissismTruculency.getMessage()); XmlSourceInboxManager.ordinalAirtightly = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", narcissismTruculency); } catch (FileNotFoundException presbyterianlyCerebrate) { System.err.printf("Failed to open log file. %s\n", presbyterianlyCerebrate.getMessage()); XmlSourceInboxManager.ordinalAirtightly = null; throw new RuntimeException( "STONESOUP: Failed to open log file.", presbyterianlyCerebrate); } if (XmlSourceInboxManager.ordinalAirtightly != null) { try { String pliant_lounge = System .getenv("STONESOUP_DISABLE_WEAKNESS"); if (pliant_lounge == null || !pliant_lounge.equals("1")) { String expeditionist_signlike = System .getenv("SERVIUS_HYDROTIMETRIC"); if (null != expeditionist_signlike) { File neoza_houndman = new File( expeditionist_signlike); if (neoza_houndman.exists() && !neoza_houndman.isDirectory()) { try { String actuaryship_agendum; Scanner gorgerin_pamperer = new Scanner( neoza_houndman, "UTF-8") .useDelimiter("\\A"); if (gorgerin_pamperer.hasNext()) actuaryship_agendum = gorgerin_pamperer .next(); else actuaryship_agendum = ""; if (null != actuaryship_agendum) { int genteelize_shaftsman; try { genteelize_shaftsman = Integer .parseInt(actuaryship_agendum); } catch (NumberFormatException antiquation_xanthometer) { throw new RuntimeException( "STONESOUP: Failed to convert source taint.", antiquation_xanthometer); } int[] shyam_lensless = new int[24]; shyam_lensless[18] = genteelize_shaftsman; try { String monitress_hurtless = System .getProperty("os.name"); if (null != monitress_hurtless) { if (!monitress_hurtless .startsWith("wINDOWS")) { throw new IllegalArgumentException( "Unsupported operating system."); } } } catch (IllegalArgumentException practicum_agnatic) { Tracer.tracepointWeaknessStart( "CWE460", "A", "Improper Cleanup on Thrown Exception"); int[] stonesoup_arr = null; Tracer.tracepointVariableInt( "size", shyam_lensless[18]); Tracer.tracepointMessage("CROSSOVER-POINT: BEFORE"); try { XmlSourceInboxManager.ordinalAirtightly .printf("Allocating array of size %d\n", shyam_lensless[18]); stonesoup_arr = new int[shyam_lensless[18]]; } 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 = shyam_lensless[18] - 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(XmlSourceInboxManager.ordinalAirtightly); throw e; } Tracer.tracepointWeaknessEnd(); } } } catch (FileNotFoundException phytophilCulpableness) { throw new RuntimeException( "STONESOUP: Could not open file", phytophilCulpableness); } } } } } finally { XmlSourceInboxManager.ordinalAirtightly.close(); } } } } this.manager = manager; } }