[opennms-devel] Please test KSC reports in trunk revision 8334 or later

"DJ Gregor" <[email protected]>
Newsgroups gmane.network.opennms.bugs
Message-ID <[email protected]>
I just did some major rework of KSC reports, especially editing of
reports, as of trunk revision 8334, and I would appreciate as many eyes
as possible testing this, since it seems to be a popular feature.

In particular, each report is now referenced by a persistent ID that
doesn't change across edits (particularly new report addition, see bug
#2216).  Also, I fixed the long-standing problem of multiple people not
being able to edit KSC reports at the same time by moving editing state
into a new object, KscReportEditor, that is stored in the user's session
on the server.  A single user still can't edit multiple reports at the
same time with multiple windows of the same browser, however.

The commit message is below for those who are interested.


        Thanks,
       - djg

On Sun, 03 Feb 2008 19:57:56 -0800, [email protected] said:
> Revision: 8334
>           http://opennms.svn.sourceforge.net/opennms/?rev=8334&view=rev
> Author:   djgregor
> Date:     2008-02-03 19:57:56 -0800 (Sun, 03 Feb 2008)
> 
> Log Message:
> -----------
> - Fix for bug#2216 -- KSC Report list is reordered every time a new
> report is added.
> - A unique ID is assigned to each KSC report, is persisted across edits,
> and is used instead of the report's index in the KSC configuration file
> everywhere, particularly in URLs.  The ID is initialized to be the
> report's index (starting at 0) in the KSC configuration file and is
> persisted the first time changes are saved to the file during normal
> editing.
> - Instead of having a set of fields in the KSC_PerformanceReportFactory
> that track what report and graph are being editing, move this to the new
> KscReportEditor object along with related methods and store this object
> in the user's session.
> - Use Asserts in afterPropertiesSet and other methods to simplify things.
> - Format code in a few places.
> - Refactor some controller handleRequestInternal() methods.
> 
> Modified Paths:
> --------------
>     opennms/trunk/opennms-config/src/main/castor/ksc-performance-reports.xsd
>     opennms/trunk/opennms-services/src/main/java/org/opennms/netmgt/config/KSC_PerformanceReportFactory.java
>     opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomGraphChooseParentResourceController.java
>     opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomGraphChooseResourceController.java
>     opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomGraphEditDetailsController.java
>     opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomReportController.java
>     opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomViewController.java
>     opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/FormProcGraphController.java
>     opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/FormProcMainController.java
>     opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/FormProcReportController.java
>     opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/FormProcViewController.java
>     opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/IncludeBoxController.java
>     opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/IndexController.java
>     opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/svclayer/support/DefaultKscReportService.java
> 
> Added Paths:
> -----------
>     opennms/trunk/opennms-services/src/main/java/org/opennms/netmgt/config/KscReportEditor.java
> 
> Modified:
> opennms/trunk/opennms-config/src/main/castor/ksc-performance-reports.xsd
> ===================================================================
> ---
> opennms/trunk/opennms-config/src/main/castor/ksc-performance-reports.xsd
> 2008-02-03 17:51:56 UTC (rev 8333)
> +++
> opennms/trunk/opennms-config/src/main/castor/ksc-performance-reports.xsd
> 2008-02-04 03:57:56 UTC (rev 8334)
> @@ -29,6 +29,8 @@
>        <sequence>
>          <element maxOccurs="unbounded" minOccurs="0" ref="this:Graph"/>
>        </sequence>
> +      
> +      <attribute name="id" type="int" use="optional"/>
>  
>        <attribute name="title" type="string" use="required"/>
>  
> 
> Modified:
> opennms/trunk/opennms-services/src/main/java/org/opennms/netmgt/config/KSC_PerformanceReportFactory.java
> ===================================================================
> ---
> opennms/trunk/opennms-services/src/main/java/org/opennms/netmgt/config/KSC_PerformanceReportFactory.java
> 2008-02-03 17:51:56 UTC (rev 8333)
> +++
> opennms/trunk/opennms-services/src/main/java/org/opennms/netmgt/config/KSC_PerformanceReportFactory.java
> 2008-02-04 03:57:56 UTC (rev 8334)
> @@ -10,6 +10,10 @@
>  //
>  // Modifications:
>  //
> +// 2008 Feb 03: A report "index" is now the "id" of the report.  The IDs
> are
> +//              initialized if they don't exist when the configuration
> file is
> +//              loaded.  Pulled the report/graph editing code out of
> +//              KSC_PerformanceReportFactory into the new
> KscReportEditor class.
>  // 2005 Jan 18: Changed the default report to "mib2.bits".
>  // 2003 Apr 24: Changed the default report to "bits".
>  //
> @@ -32,71 +36,80 @@
>  //      http://www.opennms.org/
>  //      http://www.opennms.com/
>  //
> -
>  package org.opennms.netmgt.config;
>  
>  import java.io.File;
>  import java.io.FileInputStream;
>  import java.io.FileNotFoundException;
> +import java.io.FileReader;
>  import java.io.FileWriter;
>  import java.io.IOException;
>  import java.io.InputStream;
>  import java.io.InputStreamReader;
> -import java.io.StringReader;
>  import java.io.StringWriter;
> +import java.util.Arrays;
>  import java.util.Calendar;
> +import java.util.Comparator;
> +import java.util.LinkedHashMap;
> +import java.util.Map;
>  
> +
> +import org.apache.commons.io.IOUtils;
>  import org.exolab.castor.xml.MarshalException;
>  import org.exolab.castor.xml.Marshaller;
> -import org.exolab.castor.xml.Unmarshaller;
>  import org.exolab.castor.xml.ValidationException;
>  import org.opennms.netmgt.ConfigFileConstants;
> -import org.opennms.netmgt.config.kscReports.Graph;
>  import org.opennms.netmgt.config.kscReports.Report;
>  import org.opennms.netmgt.config.kscReports.ReportsList;
> +import org.opennms.netmgt.dao.castor.CastorUtils;
> +import org.springframework.util.Assert;
>  
>  public class KSC_PerformanceReportFactory {
> -    /** The static singleton instance object */
> -    private static KSC_PerformanceReportFactory instance;
> +    /**
> +     * The static singleton instance object.
> +     * Null if init() hasn't been successfully called.
> +     */
> +    private static KSC_PerformanceReportFactory s_instance = null;
>  
>      /** File name of the KSC_PerformanceReport.xml */
> -    private static File KSC_PerformanceReportFile;
> +    private static File s_configFile;
>  
>      /** An instance of the ReportsList configuration */
> -    private static ReportsList m_config;
> +    private ReportsList m_config;
>  
> -    /** The input stream for the config file */
> -    private static InputStream configIn;
> -
> -    /** Boolean indicating if the init() method has been called */
> -    private static boolean initialized = false;
> -
> -    /** Last Modified timestamp */
> -    private static long m_lastModified;
> -
>      /**
>       * The array of values that may be used in the timespan declaration
>       of a
>       * graph
>       */
> -    public final String[] timespan_options = { "1_hour", "2_hour",
> "4_hour", "8_hour", "1_day", "2_day", "7_day", "1_month", "6_month",
> "1_year", "Today", "Yesterday", "This Week", "Last Week", "This Month",
> "Last Month", "This Quarter", "Last Quarter", "This Year", "Last Year" };
> +    public static final String[] TIMESPAN_OPTIONS = {
> +            "1_hour",
> +            "2_hour",
> +            "4_hour",
> +            "8_hour",
> +            "1_day",
> +            "2_day",
> +            "7_day",
> +            "1_month",
> +            "6_month",
> +            "1_year",
> +            "Today",
> +            "Yesterday",
> +            "This Week",
> +            "Last Week",
> +            "This Month",
> +            "Last Month",
> +            "This Quarter",
> +            "Last Quarter",
> +            "This Year",
> +            "Last Year"
> +    };
>  
>      /**
> -     * This is a working report that may be used to hold a report & its
> index
> -     * temporarily while moving between jsp's
> +     * Map of all Reports by their ID, ordered based on their order in
> the config file.
>       */
> -    private Report working_report = null;
> +    private Map<Integer, Report> m_reportList;
>  
> -    private int working_index = -1;
> -
>      /**
> -     * This is a working graph that may be used to hold a report graph &
> its
> -     * index temporarily while moving between jsp's
> -     */
> -    private Graph working_graph = null;
> -
> -    private int graph_index = -1;
> -
> -    /**
>       * Empty Private Constructor. Cannot be instantiated outside itself.
>       */
>      private KSC_PerformanceReportFactory() {
> @@ -104,11 +117,14 @@
>  
>      /** Init routine. Must be called before calling getInstance() to
>      instantiate * */
>      public static synchronized void init() throws IOException,
>      FileNotFoundException, MarshalException, ValidationException {
> -        if (instance == null) {
> -            instance = new KSC_PerformanceReportFactory();
> -            KSC_PerformanceReportFactory.reload();
> -            KSC_PerformanceReportFactory.initialized = true;
> +        if (isInitialized()) {
> +            return;
>          }
> +        
> +        KSC_PerformanceReportFactory newInstance = new
> KSC_PerformanceReportFactory();
> +        newInstance.reload();
> +        
> +        s_instance = newInstance;
>      }
>  
>      /**
> @@ -118,226 +134,169 @@
>       * @return the single KSC_PerformanceReportFactory instance
>       */
>      public static synchronized KSC_PerformanceReportFactory
>      getInstance() throws IllegalStateException {
> -        if (instance == null) {
> -            throw new
> IllegalStateException("KSC_PerformanceReportFactory.init() must be called
> before KSC_PerformanceReportFactory.getInstance().");
> -        }
> +        assertInitialized();
>  
> -        return instance;
> +        return s_instance;
>      }
>  
> -    /** Parses the KSC_PerformanceReport.xml via the Castor classes */
> -    public static synchronized void reload() throws IOException,
> FileNotFoundException, MarshalException, ValidationException {
> -        KSC_PerformanceReportFile =
> ConfigFileConstants.getFile(ConfigFileConstants.KSC_REPORT_FILE_NAME);
> +    /**
> +     * Parses the KSC_PerformanceReport.xml via the Castor classes.
> +     * */
> +    public synchronized void reload() throws IOException,
> FileNotFoundException, MarshalException, ValidationException {
> +        s_configFile =
> ConfigFileConstants.getFile(ConfigFileConstants.KSC_REPORT_FILE_NAME);
>  
> -        InputStream configIn = new
> FileInputStream(KSC_PerformanceReportFile);
> -        m_lastModified = KSC_PerformanceReportFile.lastModified();
> +        FileReader rdr = new FileReader(s_configFile);
> +        try {
> +            m_config = CastorUtils.unmarshal(ReportsList.class, rdr);
> +        } finally {
> +            IOUtils.closeQuietly(rdr);
> +        }
> +        
> +        setIdsOnAllReports();
> +        
> +        m_reportList = createReportList();
> +    }
>  
> -        m_config = (ReportsList)
> Unmarshaller.unmarshal(ReportsList.class, new
> InputStreamReader(configIn));
> +    private void setIdsOnAllReports() {
> +        int i = 0;
> +
> +        // Make sure that i is larger than the highest report ID
> +        for (Report report : m_config.getReportCollection()) {
> +            if (report.hasId() && report.getId() >= i) {
> +                i = report.getId() + 1;
> +            }
> +        }
> +        
> +        // Set IDs for any report lacking one.
> +        for (Report report : m_config.getReportCollection()) {
> +            if (!report.hasId()) {
> +                report.setId(i);
> +                i++;
> +            }
> +        }
>      }
>  
> -    /** Saves the KSC_PerformanceReport.xml data */
> +    /**
> +     * Saves the KSC_PerformanceReport.xml data.
> +     * */
>      public synchronized void saveCurrent() throws IOException,
>      FileNotFoundException, MarshalException, ValidationException {
> -        if (instance == null) {
> -            throw new
> IllegalStateException("KSC_PerformanceReportFactory.init() must be called
> before KSC_PerformanceReportFactory.saveCurrent().");
> -        }
> +        assertInitialized();
> +
>          sortByTitle();
> -        // Marshall to a string first, then to file. This way the
> original
> -        // config isn't lost if teh xml from the marshall is hosed.
> +        
> +        /*
> +         * Marshall to a string first, then to file. This way the
> original
> +         * config is not lost if the XML from the marshall is hosed.
> +         */
>          StringWriter stringWriter = new StringWriter();
>          Marshaller.marshal(m_config, stringWriter);
>          if (stringWriter.toString() != null) {
> -            FileWriter fileWriter = new
> FileWriter(KSC_PerformanceReportFile);
> +            FileWriter fileWriter = new FileWriter(s_configFile);
>              fileWriter.write(stringWriter.toString());
>              fileWriter.flush();
>              fileWriter.close();
>          }
> +        
>          reload();
>      }
>  
> -    /** Sorts the Reports List by their title. Simple bubble sort. */
> -    public void sortByTitle() {
> -        Report[] report_array = m_config.getReport();
> -        for (int j = 0; j < report_array.length; j++) {
> -            for (int i = j + 1; i < report_array.length; i++) {
> -                if
> (report_array[i].getTitle().compareTo(report_array[j].getTitle()) < 0) {
> -                    Report temp_report = report_array[j];
> -                    report_array[j] = report_array[i];
> -                    report_array[i] = temp_report;
> -                }
> -            }
> -        }
> -        m_config.setReport(report_array); // write back the sorted list
> +    private static void assertInitialized() {
> +        Assert.state(isInitialized(),
> "KSC_PerformanceReportFactory.init() has not been called");
>      }
>  
> -    /** Returns the KSC_PerformanceReport configuration object */
> -    public static ReportsList getConfiguration() {
> -        return m_config;
> +    private static boolean isInitialized() {
> +        return s_instance != null;
>      }
>  
> -    /** Deletes the indexed report and updates file configuration */
> -    public void deleteReportAndSave(int index) throws
> ArrayIndexOutOfBoundsException, IOException, FileNotFoundException,
> MarshalException, ValidationException {
> -        int total_reports = m_config.getReportCount();
> -        if ((index < 0) || (index >= total_reports)) {
> -            // Out of range. Throw range error.
> -            throw new ArrayIndexOutOfBoundsException("Reports List index
> to be deleted is out of bounds.");
> -        } else {
> -            Report removee = m_config.getReport(index);
> -            m_config.removeReport(removee);
> -            saveCurrent();
> -            reload(); // ensure consistent state with file
> -        }
> -    }
> -
> -    /** Returns the working report object */
> -    public Report getWorkingReport() {
> -        return working_report;
> -    }
> -
> -    /** Loads the source report into the working report object */
> -    public void loadWorkingReport(Report source_report) throws
> MarshalException, ValidationException {
> -        // Create a new and unique instance of the report for screwing
> around
> -        // with
> -        StringWriter stringWriter = new StringWriter();
> -        Marshaller.marshal(source_report, stringWriter);
> -        StringReader stringReader = new
> StringReader(stringWriter.toString());
> -        working_report = (Report) Unmarshaller.unmarshal(Report.class,
> stringReader);
> -    }
> -
>      /**
> -     * Loads the indexed report into the working report object or
> creates a new
> -     * one if the object does not exist
> +     * Sorts the Reports List by their title.
>       */
> -    public void loadWorkingReport(int index) throws MarshalException,
> ValidationException {
> -        int total_reports = m_config.getReportCount();
> -        working_index = index;
> -        if ((working_index < 0) || (working_index >= total_reports)) {
> -            // Out of range. Assume new report needs to be created.
> -            working_report =
> KSC_PerformanceReportFactory.getNewReport();
> -            working_index = -1;
> -        } else {
> -            loadWorkingReport(m_config.getReport(working_index));
> -        }
> +    public void sortByTitle() {
> +        Arrays.sort(m_config.getReport(), new Comparator<Report>() {
> +            public int compare(Report o1, Report o2) {
> +                return o1.getTitle().compareTo(o2.getTitle());
> +            }
> +        });
>      }
> +    
> +    public Report getReportByIndex(int index) {
> +        return m_reportList.get(index);
> +    }
> +    
> +    private Map<Integer, Report> createReportList() {
> +        LinkedHashMap<Integer, Report> reports = new
> LinkedHashMap<Integer, Report>(m_config.getReportCount());
>  
> -    /**
> -     * Unloads the working report into the indexed report list at the
> point
> -     * identified by working_index (this should have been set when the
> working
> -     * report was loaded), then create a new blank working report
> -     */
> -    public void unloadWorkingReport() throws MarshalException,
> ValidationException {
> -        int total_reports = m_config.getReportCount();
> -        if ((working_index < 0) || (working_index >= total_reports)) {
> -            // out of range... assume the new report needs to be
> appended to
> -            // list
> -            m_config.addReport(working_report);
> -        } else {
> -            // Replace the report in the configuration with the working
> report
> -            m_config.setReport(working_index, working_report);
> +        for (Report report : m_config.getReportCollection()) {
> +            if (reports.containsKey(report.getId())) {
> +                throw new IllegalArgumentException("Report id " +
> report.getId() + " is used by multiple reports in configuration file");
> +            }
> +            reports.put(report.getId(), report);
>          }
> -        // Create a new and unique instance of a report for screwing
> around with
> -        // as the working report
> -        working_report = KSC_PerformanceReportFactory.getNewReport();
> -        working_index = -1;
> +        
> +        return reports;
>      }
>  
> -    /** Create a new blank report & initialize it */
> -    public static Report getNewReport() {
> -        Report new_report = new Report();
> -        new_report.setTitle("New Report Title");
> -        new_report.setShow_graphtype_button(false);
> -        new_report.setShow_timespan_button(false);
> -        return new_report;
> -    }
> +    public Map<Integer, String> getReportList() {
> +        LinkedHashMap<Integer, String> reports = new
> LinkedHashMap<Integer, String>(m_config.getReportCount());
>  
> -    /** Returns the working report index */
> -    public int getWorkingReportIndex() {
> -        return working_index;
> +        for (Report report : m_config.getReportCollection()) {
> +            reports.put(report.getId(), report.getTitle());
> +        }
> +        
> +        return reports;
>      }
>  
> -    /** Sets the working report index */
> -    public void setWorkingReportIndex(int v_index) {
> -        working_index = v_index;
> -    }
> +    /** Deletes the indexed report and updates file configuration */
> +    public void deleteReportAndSave(int index) throws
> ArrayIndexOutOfBoundsException, IOException, FileNotFoundException,
> MarshalException, ValidationException {
> +        Report report = getReportByIndex(index);
> +        if (report == null) {
> +            throw new ArrayIndexOutOfBoundsException("Reports List index
> to be deleted is out of bounds: " + index);
> +        }
>  
> -    /** Returns the working graph object */
> -    public Graph getWorkingGraph() {
> -        return working_graph;
> +        m_config.removeReport(report);
> +        saveCurrent();
>      }
>  
> -    /** Returns the working graph index */
> -    public int getWorkingGraphIndex() {
> -        return graph_index;
> +    void addReport(Report report) {
> +        m_config.addReport(report);
> +        setIdsOnAllReports();
>      }
>  
> -    /** Create a new blank graph & initialize it */
> -    public static Graph getNewGraph() {
> -        Graph new_graph = new Graph();
> -        new_graph.setTitle("");
> -        //new_graph.setGraphtype("mib2.bits");
> -        new_graph.setTimespan("7_day");
> -        return new_graph;
> -    }
> -
> -    /**
> -     * Loads the indexed graph from the working report into the working
> graph
> -     * object or creates a new one if the object does not exist
> -     */
> -    public void loadWorkingGraph(int index) throws MarshalException,
> ValidationException {
> -        int total_graphs = working_report.getGraphCount();
> -        graph_index = index;
> -        if ((graph_index < 0) || (graph_index >= total_graphs)) {
> -            // out of range... assume new report needs to be created
> -            working_graph = KSC_PerformanceReportFactory.getNewGraph();
> -            graph_index = -1;
> -        } else {
> -            // Create a new and unique instance of the graph for
> screwing around
> -            // with
> -            StringWriter stringWriter = new StringWriter();
> -            Marshaller.marshal(working_report.getGraph(graph_index),
> stringWriter);
> -            StringReader stringReader = new
> StringReader(stringWriter.toString());
> -            working_graph = (Graph) Unmarshaller.unmarshal(Graph.class,
> stringReader);
> +    void setReport(int index, Report report) {
> +        int arrayIndex = getArrayIndex(index);
> +        if (arrayIndex == -1) {
> +            throw new IllegalArgumentException("Could not find report
> with ID of " + index);
>          }
> +        
> +        // Make sure we preserve the existing ID, if it exists (which it
> should)
> +        if (m_config.getReport(arrayIndex).hasId()) {
> +            report.setId(m_config.getReport(arrayIndex).getId());
> +        }
> +        
> +        m_config.setReport(arrayIndex, report);
> +        setIdsOnAllReports();
>      }
> -
> -    /**
> -     * Unloads the working graph into the working report list at the
> requested
> -     * graph number. If the graph was modified from an existing graph,
> then the
> -     * old one is replaced. A new blank working graph is then created
> -     */
> -    public void unloadWorkingGraph(int requested_graphnum) throws
> MarshalException, ValidationException {
> -        int total_graphs = working_report.getGraphCount();
> -        int insert_location = requested_graphnum--;
> -        boolean replace_graph = false;
> -
> -        // Check range for existing graph and delete if it is in the
> valid range
> -        if ((graph_index >= 0) && (graph_index < total_graphs)) {
> -            // in range... delete existing graph.
> -           
> working_report.removeGraph(working_report.getGraph(graph_index));
> +    
> +    private int getArrayIndex(int index) {
> +        int i = 0;
> +        for (Report report : m_config.getReportCollection()) {
> +            if (report.getId() == index) {
> +                return i;
> +            }
> +            
> +            i++;
>          }
> -
> -        // Check range for insertion point
> -        if ((insert_location < 0) || (insert_location >= total_graphs))
> {
> -            // out of range... assume the new graph needs to be appended
> to list
> -            working_report.addGraph(working_graph);
> -        } else {
> -            // Insert the graph in the configuration within the working
> report
> -            working_report.addGraph(insert_location, working_graph);
> -        }
> -
> -        // Create a new and unique instance of a report for screwing
> around with
> -        // as the working report
> -        working_graph = KSC_PerformanceReportFactory.getNewGraph();
> -        graph_index = -1;
> +        
> +        return -1;
>      }
> -
> -    public static synchronized void getBeginEndTime(String interval,
> Calendar begin_time, Calendar end_time) throws IllegalArgumentException
> +    
>      /**
>       * This method requires begin time and end time to be set to the
>       current
>       * time prior to call. The start and stop times are relative to this
>       time.
>       * Init values as follows: begin_time = Calendar.getInstance();
>       end_time =
>       * Calendar.getInstance();
>       */
> -    {
> +    public static synchronized void getBeginEndTime(String interval,
> Calendar begin_time, Calendar end_time) throws IllegalArgumentException {
>          if (interval.equals("1_hour")) {
>              begin_time.add(Calendar.HOUR, -1);
>          } else if (interval.equals("2_hour")) {
> @@ -441,6 +400,5 @@
>                  throw new IllegalArgumentException("Unknown graph
>                  timespan: " + interval);
>              }
>          }
> -    } // getBeginEndTime()
> -
> +    }
>  }
> 
> Added:
> opennms/trunk/opennms-services/src/main/java/org/opennms/netmgt/config/KscReportEditor.java
> ===================================================================
> ---
> opennms/trunk/opennms-services/src/main/java/org/opennms/netmgt/config/KscReportEditor.java
>                         (rev 0)
> +++
> opennms/trunk/opennms-services/src/main/java/org/opennms/netmgt/config/KscReportEditor.java
> 2008-02-04 03:57:56 UTC (rev 8334)
> @@ -0,0 +1,232 @@
> +//
> +// This file is part of the OpenNMS(R) Application.
> +//
> +// OpenNMS(R) is Copyright (C) 2002-2003 The OpenNMS Group, Inc.  All
> rights reserved.
> +// OpenNMS(R) is a derivative work, containing both original code,
> included code and modified
> +// code that was published under the GNU General Public License.
> Copyrights for modified 
> +// and included code are below.
> +//
> +// OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
> +//
> +// Modifications:
> +//
> +// 2008 Feb 03: Pulled the report/graph editing code out of
> +//              KSC_PerformanceReportFactory into the new
> KscReportEditor class.
> +//              Made KscReportEditor session-based. - [email protected]
> +// 2005 Jan 18: Changed the default report to "mib2.bits".
> +// 2003 Apr 24: Changed the default report to "bits".
> +//
> +// This program is free software; you can redistribute it and/or modify
> +// it under the terms of the GNU General Public License as published by
> +// the Free Software Foundation; either version 2 of the License, or
> +// (at your option) any later version.
> +//
> +// This program is distributed in the hope that it will be useful,
> +// but WITHOUT ANY WARRANTY; without even the implied warranty of
> +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +// GNU General Public License for more details.                          
> +//
> +// You should have received a copy of the GNU General Public License
> +// along with this program; if not, write to the Free Software
> +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
> USA.
> +//       
> +// For more information contact: 
> +//      OpenNMS Licensing       <[email protected]>
> +//      http://www.opennms.org/
> +//      http://www.opennms.com/
> +//
> +package org.opennms.netmgt.config;
> +
> +import java.io.Serializable;
> +import java.io.StringReader;
> +import java.io.StringWriter;
> +
> +import javax.servlet.http.HttpSession;
> +
> +import org.exolab.castor.xml.MarshalException;
> +import org.exolab.castor.xml.Marshaller;
> +import org.exolab.castor.xml.ValidationException;
> +import org.opennms.netmgt.config.kscReports.Graph;
> +import org.opennms.netmgt.config.kscReports.Report;
> +import org.opennms.netmgt.dao.castor.CastorUtils;
> +
> +public class KscReportEditor implements Serializable {
> +    private static final long serialVersionUID = 1L;
> +
> +    /**
> +     * This is a working report that may be used to hold a report & its
> index
> +     * temporarily while moving between jsp's
> +     */
> +    private Report m_workingReport = null;
> +
> +    private int m_workingGraphIndex = -1;
> +
> +    /**
> +     * This is a working graph that may be used to hold a report graph &
> its index temporarily while moving between jsp's
> +     */
> +    private Graph m_workingGraph = null;
> +
> +    public KscReportEditor() {
> +    }
> +
> +    /** Create a new blank report & initialize it */
> +    private static Report getNewReport() {
> +        Report new_report = new Report();
> +        new_report.setTitle("New Report Title");
> +        new_report.setShow_graphtype_button(false);
> +        new_report.setShow_timespan_button(false);
> +        return new_report;
> +    }
> +
> +    /** Returns the working report object */
> +    public Report getWorkingReport() {
> +        return m_workingReport;
> +    }
> +
> +    private void setWorkingReport(Report report) {
> +        m_workingReport = report;
> +    }
> +
> +    /** Returns the working graph object */
> +    public Graph getWorkingGraph() {
> +        return m_workingGraph;
> +    }
> +
> +    /** Returns the working graph index */
> +    public int getWorkingGraphIndex() {
> +        return m_workingGraphIndex;
> +    }
> +
> +    /** Create a new blank graph & initialize it */
> +    public static Graph getNewGraph() {
> +        Graph new_graph = new Graph();
> +        new_graph.setTitle("");
> +        //new_graph.setGraphtype("mib2.bits");
> +        new_graph.setTimespan("7_day");
> +        return new_graph;
> +    }
> +
> +    /**
> +     * Loads the indexed graph from the working report into the working
> graph
> +     * object or creates a new one if the object does not exist
> +     */
> +    public void loadWorkingGraph(int index) throws MarshalException,
> ValidationException {
> +        int total_graphs = m_workingReport.getGraphCount();
> +        m_workingGraphIndex = index;
> +        if ((m_workingGraphIndex < 0) || (m_workingGraphIndex >=
> total_graphs)) {
> +            // out of range... assume new report needs to be created
> +            m_workingGraph = getNewGraph();
> +            m_workingGraphIndex = -1;
> +        } else {
> +            // Create a new and unique instance of the graph for
> screwing around with
> +            m_workingGraph =
> duplicateCastorObject(m_workingReport.getGraph(m_workingGraphIndex),
> Graph.class);
> +        }
> +    }
> +
> +    /**
> +     * Unloads the working graph into the working report list at the
> requested
> +     * graph number. If the graph was modified from an existing graph,
> then the
> +     * old one is replaced. A new blank working graph is then created
> +     */
> +    public void unloadWorkingGraph(int requested_graphnum) throws
> MarshalException, ValidationException {
> +        int total_graphs = m_workingReport.getGraphCount();
> +        int insert_location = requested_graphnum--;
> +
> +        // Check range for existing graph and delete if it is in the
> valid range
> +        if ((m_workingGraphIndex >= 0) && (m_workingGraphIndex <
> total_graphs)) {
> +            // in range... delete existing graph.
> +           
> m_workingReport.removeGraph(m_workingReport.getGraph(m_workingGraphIndex));
> +        }
> +
> +        // Check range for insertion point
> +        if ((insert_location < 0) || (insert_location >= total_graphs))
> {
> +            // out of range... assume the new graph needs to be appended
> to list
> +            m_workingReport.addGraph(m_workingGraph);
> +        } else {
> +            // Insert the graph in the configuration within the working
> report
> +            m_workingReport.addGraph(insert_location, m_workingGraph);
> +        }
> +
> +        // Create a new and unique instance of a report for screwing
> around with
> +        // as the working report
> +        m_workingGraph = getNewGraph();
> +        m_workingGraphIndex = -1;
> +    }
> +
> +    /**
> +     * Loads the source report into the working report object as a new
> report.
> +     */
> +    public void loadWorkingReport(Report report) throws
> MarshalException, ValidationException {
> +        setWorkingReport(duplicateCastorObject(report, Report.class));
> +        getWorkingReport().deleteId();
> +    }
> +
> +    /**
> +     * Loads the indexed report into the working report object.
> +     */
> +    public void loadWorkingReport(KSC_PerformanceReportFactory factory,
> int index) throws MarshalException, ValidationException {
> +        Report report = factory.getReportByIndex(index);
> +        if (report == null) {
> +            throw new IllegalArgumentException("Could not find report
> with ID " + index);
> +        }
> +
> +        setWorkingReport(duplicateCastorObject(report, Report.class));
> +    }
> +    
> +    /**
> +     * Loads the indexed report into the working report object as a
> duplicate
> +     * report.  The ID in the loaded report will be removed so a new ID
> will
> +     * be created when the duplicated report is saved.
> +     */
> +    public void loadWorkingReportDuplicate(KSC_PerformanceReportFactory
> factory, int index) throws MarshalException, ValidationException {
> +        loadWorkingReport(factory, index);
> +
> +        getWorkingReport().deleteId();
> +    }
> +    
> +    /**
> +     * Loads a newly created report into the working report object.
> +     */
> +    public void loadNewWorkingReport() {
> +        setWorkingReport(getNewReport());
> +        getWorkingReport().deleteId();
> +    }
> +
> +    /**
> +     * Unloads the working report into the indexed report list at the
> point
> +     * identified by working_index (this should have been set when the
> working
> +     * report was loaded), then create a new blank working report
> +     */
> +    public void unloadWorkingReport(KSC_PerformanceReportFactory
> factory) throws MarshalException, ValidationException {
> +        if (getWorkingReport().hasId()) {
> +            factory.setReport(getWorkingReport().getId(),
> getWorkingReport());
> +        } else {
> +            factory.addReport(getWorkingReport());
> +        }
> +        
> +        // Create a new and unique instance of a report for screwing
> around with
> +        // as the working report
> +        loadNewWorkingReport();
> +    }
> +
> +    private <T> T duplicateCastorObject(T object, Class<T> clazz) throws
> MarshalException, ValidationException {
> +        StringWriter stringWriter = new StringWriter();
> +        Marshaller.marshal(object, stringWriter);
> +        StringReader stringReader = new
> StringReader(stringWriter.toString());
> +        return CastorUtils.unmarshal(clazz, stringReader);
> +    }
> +    
> +    public static KscReportEditor getFromSession(HttpSession session,
> boolean required) {
> +        String attributeName = KscReportEditor.class.getName();
> +        
> +        if (session.getAttribute(attributeName) == null) {
> +            if (required) {
> +                throw new IllegalStateException("The KSC report editing
> session is not open--please restart your edits.  This could be due to
> your session expiring on the server due to inactivity or the server being
> restarted.");
> +            } else {
> +                session.setAttribute(attributeName, new
> KscReportEditor());
> +            }
> +        }
> +        
> +        return (KscReportEditor) session.getAttribute(attributeName);
> +    }
> +}
> 
> Modified:
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomGraphChooseParentResourceController.java
> ===================================================================
> ---
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomGraphChooseParentResourceController.java
> 2008-02-03 17:51:56 UTC (rev 8333)
> +++
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomGraphChooseParentResourceController.java
> 2008-02-04 03:57:56 UTC (rev 8334)
> @@ -8,6 +8,10 @@
>  //
>  // OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
>  //
> +// Modifications:
> +//
> +// 2008 Feb 03: Use Assert.state in afterPropertiesSet(). -
> [email protected]
> +//
>  // Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights
>  reserved.
>  //
>  // This program is free software; you can redistribute it and/or modify
> @@ -43,6 +47,7 @@
>  import org.opennms.web.svclayer.ResourceService;
>  import org.springframework.beans.factory.InitializingBean;
>  import org.springframework.dao.DataAccessException;
> +import org.springframework.util.Assert;
>  import org.springframework.web.servlet.ModelAndView;
>  import org.springframework.web.servlet.mvc.AbstractController;
>  
> @@ -111,9 +116,7 @@
>      }
>  
>      public void afterPropertiesSet() throws Exception {
> -        if (m_resourceService == null) {
> -            throw new IllegalStateException("property resourceService
> must be set");
> -        }
> +        Assert.state(m_resourceService != null, "property
> resourceService must be set");
>      }
>  
>  }
> 
> Modified:
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomGraphChooseResourceController.java
> ===================================================================
> ---
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomGraphChooseResourceController.java
> 2008-02-03 17:51:56 UTC (rev 8333)
> +++
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomGraphChooseResourceController.java
> 2008-02-04 03:57:56 UTC (rev 8334)
> @@ -8,6 +8,10 @@
>  //
>  // OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
>  //
> +// Modifications:
> +//
> +// 2008 Feb 03: Use Assert.state in afterPropertiesSet(). -
> [email protected]
> +//
>  // Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights
>  reserved.
>  //
>  // This program is free software; you can redistribute it and/or modify
> @@ -43,6 +47,7 @@
>  import org.opennms.web.svclayer.ResourceService;
>  import org.springframework.beans.factory.InitializingBean;
>  import org.springframework.dao.DataAccessException;
> +import org.springframework.util.Assert;
>  import org.springframework.web.servlet.ModelAndView;
>  import org.springframework.web.servlet.mvc.AbstractController;
>  
> @@ -96,9 +101,7 @@
>      }
>  
>      public void afterPropertiesSet() throws Exception {
> -        if (m_resourceService == null) {
> -            throw new IllegalStateException("property resourceService
> must be set");
> -        }
> +        Assert.state(m_resourceService != null, "property
> resourceService must be set");
>      }
>  
>  }
> 
> Modified:
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomGraphEditDetailsController.java
> ===================================================================
> ---
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomGraphEditDetailsController.java
> 2008-02-03 17:51:56 UTC (rev 8333)
> +++
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomGraphEditDetailsController.java
> 2008-02-04 03:57:56 UTC (rev 8334)
> @@ -8,6 +8,11 @@
>  //
>  // OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
>  //
> +// Modifications:
> +//
> +// 2008 Feb 03: Use Assert.state in afterPropertiesSet().  Use
> KscReportEditor
> +//              for tracking editing state in the user's session. -
> [email protected]
> +//
>  // Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights
>  reserved.
>  //
>  // This program is free software; you can redistribute it and/or modify
> @@ -37,6 +42,7 @@
>  import javax.servlet.http.HttpServletResponse;
>  
>  import org.opennms.netmgt.config.KSC_PerformanceReportFactory;
> +import org.opennms.netmgt.config.KscReportEditor;
>  import org.opennms.netmgt.config.kscReports.Report;
>  import org.opennms.netmgt.model.PrefabGraph;
>  import org.opennms.netmgt.model.OnmsResource;
> @@ -45,6 +51,7 @@
>  import org.opennms.web.svclayer.KscReportService;
>  import org.opennms.web.svclayer.ResourceService;
>  import org.springframework.beans.factory.InitializingBean;
> +import org.springframework.util.Assert;
>  import org.springframework.web.servlet.ModelAndView;
>  import org.springframework.web.servlet.mvc.AbstractController;
>  
> @@ -64,8 +71,10 @@
>          //optional parameter graphtype
>          String prefabReportName = request.getParameter("graphtype");
>          
> -        Report report = getKscReportFactory().getWorkingReport(); 
> -        org.opennms.netmgt.config.kscReports.Graph sample_graph =
> getKscReportFactory().getWorkingGraph(); 
> +        KscReportEditor editor =
> KscReportEditor.getFromSession(request.getSession(), true);
> +        
> +        Report report = editor.getWorkingReport(); 
> +        org.opennms.netmgt.config.kscReports.Graph sample_graph =
> editor.getWorkingGraph(); 
>          if (sample_graph == null) {
>              throw new IllegalArgumentException("Invalid working graph
>              argument -- null pointer. Possibly missing prefab report in
>              snmp-graph.properties?");
>          }
> @@ -100,7 +109,7 @@
>          modelAndView.addObject("timeSpans",
>          getKscReportService().getTimeSpans(false));
>          modelAndView.addObject("timeSpan", sample_graph.getTimespan());
>          
> -        int graph_index = getKscReportFactory().getWorkingGraphIndex(); 
> +        int graph_index = editor.getWorkingGraphIndex(); 
>          int max_graphs = report.getGraphCount();
>          if (graph_index == -1) {
>              graph_index = max_graphs++;
> @@ -145,15 +154,9 @@
>      }
>  
>      public void afterPropertiesSet() throws Exception {
> -        if (m_resourceService == null) {
> -            throw new IllegalStateException("property resourceService
> must be set");
> -        }
> -        if (m_kscReportService == null) {
> -            throw new IllegalStateException("property kscReportService
> must be set");
> -        }
> -        if (m_kscReportFactory == null) {
> -            throw new IllegalStateException("property kscReportFactory
> must be set");
> -        }
> +        Assert.state(m_resourceService != null, "property
> resourceService must be set");
> +        Assert.state(m_kscReportService != null, "property
> kscReportService must be set");
> +        Assert.state(m_kscReportFactory != null, "property
> kscReportFactory must be set");
>      }
>  
>  }
> 
> Modified:
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomReportController.java
> ===================================================================
> ---
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomReportController.java
> 2008-02-03 17:51:56 UTC (rev 8333)
> +++
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomReportController.java
> 2008-02-04 03:57:56 UTC (rev 8334)
> @@ -8,6 +8,11 @@
>  //
>  // OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
>  //
> +// Modifications:
> +//
> +// 2008 Feb 03: Use Assert.state in afterPropertiesSet().  Use
> KscReportEditor
> +//              for tracking editing state in the user's session. -
> [email protected]
> +//
>  // Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights
>  reserved.
>  //
>  // This program is free software; you can redistribute it and/or modify
> @@ -38,6 +43,7 @@
>  import javax.servlet.http.HttpServletResponse;
>  
>  import org.opennms.netmgt.config.KSC_PerformanceReportFactory;
> +import org.opennms.netmgt.config.KscReportEditor;
>  import org.opennms.netmgt.config.kscReports.Graph;
>  import org.opennms.netmgt.config.kscReports.Report;
>  import org.opennms.netmgt.model.PrefabGraph;
> @@ -46,6 +52,7 @@
>  import org.opennms.web.svclayer.KscReportService;
>  import org.opennms.web.svclayer.ResourceService;
>  import org.springframework.beans.factory.InitializingBean;
> +import org.springframework.util.Assert;
>  import org.springframework.web.servlet.ModelAndView;
>  import org.springframework.web.servlet.mvc.AbstractController;
>  
> @@ -58,7 +65,7 @@
>      @Override
>      protected ModelAndView handleRequestInternal(HttpServletRequest
>      request, HttpServletResponse response) throws Exception {
>          // Get Form Variables
> -        Report report = getKscReportFactory().getWorkingReport();
> +        Report report =
> KscReportEditor.getFromSession(request.getSession(),
> true).getWorkingReport();
>          if (report == null) {
>              throw new IllegalStateException("There is no working
>              report");
>          }
> @@ -117,15 +124,9 @@
>      }
>  
>      public void afterPropertiesSet() throws Exception {
> -        if (m_kscReportFactory == null) {
> -            throw new IllegalStateException("property kscReportFactory
> must be set");
> -        }
> -        if (m_kscReportService == null) {
> -            throw new IllegalStateException("property kscReportService
> must be set");
> -        }
> -        if (m_resourceService == null) {
> -            throw new IllegalStateException("property resourceService
> must be set");
> -        }
> +        Assert.state(m_kscReportFactory != null, "property
> kscReportFactory must be set");
> +        Assert.state(m_kscReportService != null, "property
> kscReportService must be set");
> +        Assert.state(m_resourceService != null, "property
> resourceService must be set");
>      }
>  
>  }
> 
> Modified:
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomViewController.java
> ===================================================================
> ---
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomViewController.java
> 2008-02-03 17:51:56 UTC (rev 8333)
> +++
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/CustomViewController.java
> 2008-02-04 03:57:56 UTC (rev 8334)
> @@ -8,6 +8,11 @@
>  //
>  // OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
>  //
> +// Modifications:
> +//
> +// 2008 Feb 03: Use Asserts in afterPropertiesSet() and
> setDefaultGraphsPerLine().
> +//              Use new getReportByIndex method on the KSC factory. -
> [email protected]
> +//
>  // Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights
>  reserved.
>  //
>  // This program is free software; you can redistribute it and/or modify
> @@ -50,7 +55,6 @@
>  import org.opennms.netmgt.config.KSC_PerformanceReportFactory;
>  import org.opennms.netmgt.config.kscReports.Graph;
>  import org.opennms.netmgt.config.kscReports.Report;
> -import org.opennms.netmgt.config.kscReports.ReportsList;
>  import org.opennms.netmgt.model.OnmsResource;
>  import org.opennms.netmgt.model.PrefabGraph;
>  import org.opennms.web.MissingParameterException;
> @@ -60,6 +64,7 @@
>  import org.opennms.web.svclayer.KscReportService;
>  import org.opennms.web.svclayer.ResourceService;
>  import org.springframework.beans.factory.InitializingBean;
> +import org.springframework.util.Assert;
>  import org.springframework.web.servlet.ModelAndView;
>  import org.springframework.web.servlet.mvc.AbstractController;
>  
> @@ -108,8 +113,7 @@
>          } else if ("domain".equals(report_type)) {
>              report = getKscReportService().buildDomainReport(domain);
>          } else if ("custom".equals(report_type)) {
> -            ReportsList reports_list =
> KSC_PerformanceReportFactory.getConfiguration();
> -            report = reports_list.getReport(report_index);
> +            report = m_kscReportFactory.getReportByIndex(report_index);
>          } else {
>              throw new IllegalArgumentException("value to 'type'
>              parameter of '" + report_type + "' is not supported.  Must
>              be one of: node, domain, or custom");
>          }
> @@ -280,9 +284,8 @@
>      }
>  
>      public void setDefaultGraphsPerLine(int defaultGraphsPerLine) {
> -        if (defaultGraphsPerLine <= 0) {
> -            throw new IllegalArgumentException("property
> defaultGraphsPerLine must be greater than zero");
> -        }
> +        Assert.isTrue(defaultGraphsPerLine > 0, "property
> defaultGraphsPerLine must be greater than zero");
> +
>          m_defaultGraphsPerLine = defaultGraphsPerLine;
>      }
>  
> @@ -303,21 +306,12 @@
>      }
>  
>      public void afterPropertiesSet() throws Exception {
> -        if (m_kscReportFactory == null) {
> -            throw new IllegalStateException("property kscReportFactory
> must be set");
> -        }
> -        if (m_kscReportService == null) {
> -            throw new IllegalStateException("property kscReportService
> must be set");
> -        }
> -        if (m_resourceService == null) {
> -            throw new IllegalStateException("property resourceService
> must be set");
> -        }
> -        if (m_defaultGraphsPerLine == 0) {
> -            throw new IllegalStateException("property
> defaultGraphsPerLine must be set");
> -        }
> +        Assert.state(m_kscReportFactory != null, "property
> kscReportFactory must be set");
> +        Assert.state(m_kscReportService != null, "property
> kscReportService must be set");
> +        Assert.state(m_resourceService != null, "property
> resourceService must be set");
> +        Assert.state(m_defaultGraphsPerLine != 0, "property
> defaultGraphsPerLine must be set");
>          
>          m_executor = Executors.newSingleThreadExecutor();
> -
>      }
>  
>  }
> 
> Modified:
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/FormProcGraphController.java
> ===================================================================
> ---
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/FormProcGraphController.java
> 2008-02-03 17:51:56 UTC (rev 8333)
> +++
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/FormProcGraphController.java
> 2008-02-04 03:57:56 UTC (rev 8334)
> @@ -6,6 +6,11 @@
>  // code that was published under the GNU General Public License.
>  Copyrights for modified
>  // and included code are below.
>  //
> +// Modifications:
> +//
> +// 2008 Feb 03: Use Assert.state in afterPropertiesSet().  Use
> KscReportEditor
> +//              for tracking editing state in the user's session. -
> [email protected]
> +//
>  // OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
>  //
>  // Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights
>  reserved.
> @@ -35,11 +40,13 @@
>  import javax.servlet.http.HttpServletResponse;
>  
>  import org.opennms.netmgt.config.KSC_PerformanceReportFactory;
> +import org.opennms.netmgt.config.KscReportEditor;
>  import org.opennms.netmgt.config.kscReports.Graph;
>  import org.opennms.netmgt.model.OnmsResource;
>  import org.opennms.web.WebSecurityUtils;
>  import org.opennms.web.svclayer.KscReportService;
>  import org.springframework.beans.factory.InitializingBean;
> +import org.springframework.util.Assert;
>  import org.springframework.web.servlet.ModelAndView;
>  import org.springframework.web.servlet.mvc.AbstractController;
>  
> @@ -50,8 +57,10 @@
>  
>      @Override
>      protected ModelAndView handleRequestInternal(HttpServletRequest
>      request, HttpServletResponse response) throws Exception {
> +        KscReportEditor editor =
> KscReportEditor.getFromSession(request.getSession(), true);
> +        
>          // Get The Customizable (Working) Graph 
> -        Graph graph = getKscReportFactory().getWorkingGraph();
> +        Graph graph = editor.getWorkingGraph();
>  
>          // Get Form Variables
>          String action = request.getParameter("action");
> @@ -71,7 +80,7 @@
>  
>          if (action.equals("Save")) {
>              // The working graph is complete now... lets save working
>              graph to working report 
> -            getKscReportFactory().unloadWorkingGraph(graph_index);
> +            editor.unloadWorkingGraph(graph_index);
>          }
>          
>          if (action.equals("Save") || action.equals("Cancel")) {
> @@ -109,11 +118,7 @@
>      }
>  
>      public void afterPropertiesSet() throws Exception {
> -        if (m_kscReportFactory == null) {
> -            throw new IllegalStateException("property kscReportFactory
> must be set");
> -        }
> -        if (m_kscReportService == null) {
> -            throw new IllegalStateException("property kscReportService
> must be set");
> -        }
> +        Assert.state(m_kscReportFactory != null, "property
> kscReportFactory must be set");
> +        Assert.state(m_kscReportService != null, "property
> kscReportService must be set");
>      }
>  }
> 
> Modified:
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/FormProcMainController.java
> ===================================================================
> ---
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/FormProcMainController.java
> 2008-02-03 17:51:56 UTC (rev 8333)
> +++
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/FormProcMainController.java
> 2008-02-04 03:57:56 UTC (rev 8334)
> @@ -8,6 +8,12 @@
>  //
>  // OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
>  //
> +// Modifications:
> +//
> +// 2008 Feb 03: Use Assert.state in afterPropertiesSet().  Use
> KscReportEditor
> +//              for tracking editing state in the user's session.
> +//              Refactor handleRequestInternal(). - [email protected]
> +//
>  // Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights
>  reserved.
>  //
>  // This program is free software; you can redistribute it and/or modify
> @@ -36,9 +42,11 @@
>  import javax.servlet.http.HttpServletResponse;
>  
>  import org.opennms.netmgt.config.KSC_PerformanceReportFactory;
> +import org.opennms.netmgt.config.KscReportEditor;
>  import org.opennms.web.MissingParameterException;
>  import org.opennms.web.WebSecurityUtils;
>  import org.springframework.beans.factory.InitializingBean;
> +import org.springframework.util.Assert;
>  import org.springframework.web.servlet.ModelAndView;
>  import org.springframework.web.servlet.mvc.AbstractController;
>  
> @@ -48,55 +56,44 @@
>  
>      @Override
>      protected ModelAndView handleRequestInternal(HttpServletRequest
>      request, HttpServletResponse response) throws Exception {
> -        // Get Form Variables
> -        int report_index = 0; 
> -        String report_action = request.getParameter("report_action");
> +        String action = request.getParameter("report_action");
>          
> -        if (report_action == null) {
> +        if (action == null) {
>              throw new MissingParameterException("report_action");
>          }
> -          
> -        if ((report_action.equals("Customize")) ||
> (report_action.equals("View")) || (report_action.equals("CreateFrom")) ||
> (report_action.equals("Delete"))) {
> -            String r_index = request.getParameter("report");
> -            if (r_index == null) {
> -                throw new MissingParameterException("report");
> -            } 
> -            report_index = WebSecurityUtils.safeParseInt(r_index);
> -            if ((report_action.equals("Customize")) ||
> (report_action.equals("CreateFrom"))) {  
> -                // Go ahead and tell report factory to put the report
> config into the working report area
> -                getKscReportFactory().loadWorkingReport(report_index);
> -                if (report_action.equals("CreateFrom")) {  // Need to
> set index to -1 for this case to have Customizer create new report index 
> -                   getKscReportFactory().setWorkingReportIndex(-1);
> -                }
> -            }
> -            if (report_action.equals("Delete")) {  // Take care of this
> case right now
> -                getKscReportFactory().deleteReportAndSave(report_index); 
> -            }
> -        } else { 
> -            if (report_action.equals("Create")) {
> -                report_index = -1;
> -               // Go ahead and tell report factory to put the report
> config (a blank config) into the working report area
> -               getKscReportFactory().loadWorkingReport(report_index);
> -            }
> -            else {
> -                throw new ServletException ("Invalid Parameter contents
> for report_action");
> -            }
> -        }
> +
> +        KscReportEditor editor =
> KscReportEditor.getFromSession(request.getSession(), false);
>          
> -        if (report_action.equals("View")) {
> +        if (action.equals("Customize")) {
> +            editor.loadWorkingReport(getKscReportFactory(),
> getReportIndex(request));
> +            return new ModelAndView("redirect:/KSC/customReport.htm");
> +        } else if (action.equals("CreateFrom")) {
> +            editor.loadWorkingReportDuplicate(getKscReportFactory(),
> getReportIndex(request));
> +            return new ModelAndView("redirect:/KSC/customReport.htm");
> +        } else if (action.equals("Delete")) {
> +           
> getKscReportFactory().deleteReportAndSave(getReportIndex(request)); 
> +            return new ModelAndView("redirect:/KSC/index.htm");
> +        } else if (action.equals("Create")) {
> +            editor.loadNewWorkingReport();
> +            return new ModelAndView("redirect:/KSC/customReport.htm");
> +        } else if (action.equals("View")) {
>              ModelAndView modelAndView = new
>              ModelAndView("redirect:/KSC/customView.htm");
> -            modelAndView.addObject("report", report_index);
> +            modelAndView.addObject("report", getReportIndex(request));
>              modelAndView.addObject("type", "custom");
>              return modelAndView;
> -        } else { 
> -            if ((report_action.equals("Customize")) ||
> (report_action.equals("Create")) || (report_action.equals("CreateFrom")))
> {
> -                return new
> ModelAndView("redirect:/KSC/customReport.htm");
> -            } else {
> -                return new ModelAndView("redirect:/KSC/index.htm");
> -            } 
> +        } else {
> +            throw new ServletException ("Invalid Parameter contents for
> report_action: " + action);
>          }
>      }
>  
> +    private int getReportIndex(HttpServletRequest request) {
> +        String report = request.getParameter("report");
> +        if (report == null) {
> +            throw new MissingParameterException("report");
> +        } 
> +        return WebSecurityUtils.safeParseInt(report);
> +    }
> +
>      public KSC_PerformanceReportFactory getKscReportFactory() {
>          return m_kscReportFactory;
>      }
> @@ -106,11 +103,6 @@
>      }
>  
>      public void afterPropertiesSet() throws Exception {
> -        if (m_kscReportFactory == null) {
> -            throw new IllegalStateException("property kscReportFactory
> must be set");
> -        }
> +        Assert.state(m_kscReportFactory != null, "property
> kscReportFactory must be set");
>      }
> -
> -   
> -
>  }
> 
> Modified:
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/FormProcReportController.java
> ===================================================================
> ---
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/FormProcReportController.java
> 2008-02-03 17:51:56 UTC (rev 8333)
> +++
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/FormProcReportController.java
> 2008-02-04 03:57:56 UTC (rev 8334)
> @@ -8,6 +8,11 @@
>  //
>  // OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
>  //
> +// Modifications:
> +//
> +// 2008 Feb 03: Use Assert.state in afterPropertiesSet().  Use
> KscReportEditor
> +//              for tracking editing state in the user's session. -
> [email protected]
> +//
>  // Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights
>  reserved.
>  //
>  // This program is free software; you can redistribute it and/or modify
> @@ -36,12 +41,14 @@
>  import javax.servlet.http.HttpServletResponse;
>  
>  import org.opennms.netmgt.config.KSC_PerformanceReportFactory;
> +import org.opennms.netmgt.config.KscReportEditor;
>  import org.opennms.netmgt.config.kscReports.Graph;
>  import org.opennms.netmgt.config.kscReports.Report;
>  import org.opennms.netmgt.model.OnmsResource;
>  import org.opennms.web.WebSecurityUtils;
>  import org.opennms.web.svclayer.KscReportService;
>  import org.springframework.beans.factory.InitializingBean;
> +import org.springframework.util.Assert;
>  import org.springframework.web.servlet.ModelAndView;
>  import org.springframework.web.servlet.mvc.AbstractController;
>  
> @@ -52,8 +59,10 @@
>  
>      @Override
>      protected ModelAndView handleRequestInternal(HttpServletRequest
>      request, HttpServletResponse response) throws Exception {
> +        KscReportEditor editor =
> KscReportEditor.getFromSession(request.getSession(), true);
> +        
>          // Get The Customizable Report 
> -        Report report = getKscReportFactory().getWorkingReport();
> +        Report report = editor.getWorkingReport();
>  
>          // Get Form Variables
>          String action = request.getParameter("action");
> @@ -86,11 +95,16 @@
>  
>          if (action.equals("Save")) {
>              // The working model is complete now... lets save working
>              model to configuration file 
> -            saveFactory();
> +            try {
> +                editor.unloadWorkingReport(getKscReportFactory());  //
> first copy working report into report arrays
> +                getKscReportFactory().saveCurrent();          // Now
> unmarshal array to file
> +            } catch (Exception e) {
> +                throw new ServletException("Couldn't save
> KSC_PerformanceReportFactory.", e);
> +            }
>          } else {
>              if (action.equals("AddGraph") || action.equals("ModGraph"))
>              {
>                  // Making a graph change... load it into the working
>                  area (the graph_index of -1 indicates a new graph)
> -                getKscReportFactory().loadWorkingGraph(graph_index);
> +                editor.loadWorkingGraph(graph_index);
>              } else {
>                  if (action.equals("DelGraph")) { 
>                      report.removeGraph(report.getGraph(graph_index));
> @@ -107,7 +121,7 @@
>          } else if (action.equals("AddGraph")) {
>              return new
>              ModelAndView("redirect:/KSC/customGraphChooseParentResource.htm");
>          } else if (action.equals("ModGraph")) {
> -            Graph graph = getKscReportFactory().getWorkingGraph();
> +            Graph graph = editor.getWorkingGraph();
>              OnmsResource resource =
>              getKscReportService().getResourceFromGraph(graph);
>              return new
>              ModelAndView("redirect:/KSC/customGraphEditDetails.htm",
>              "resourceId", resource.getId());
>          } else {
> @@ -115,15 +129,6 @@
>          }
>      }
>      
> -    private void saveFactory() throws ServletException {    
> -        try {
> -            getKscReportFactory().unloadWorkingReport();  // first copy
> working report into report arrays
> -            getKscReportFactory().saveCurrent();          // Now
> unmarshal array to file
> -        } catch (Exception e) {
> -            throw new ServletException("Couldn't save
> KSC_PerformanceReportFactory.", e);
> -        }
> -      }
> -
>      public KSC_PerformanceReportFactory getKscReportFactory() {
>          return m_kscReportFactory;
>      }
> @@ -141,12 +146,8 @@
>      }
>  
>      public void afterPropertiesSet() throws Exception {
> -        if (m_kscReportFactory == null) {
> -            throw new IllegalStateException("property kscReportFactory
> must be set");
> -        }
> -        if (m_kscReportService == null) {
> -            throw new IllegalStateException("property kscReportService
> must be set");
> -        }
> +        Assert.state(m_kscReportFactory != null, "property
> kscReportFactory must be set");
> +        Assert.state(m_kscReportService != null, "property
> kscReportService must be set");
>      }
>  
>  }
> 
> Modified:
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/FormProcViewController.java
> ===================================================================
> ---
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/FormProcViewController.java
> 2008-02-03 17:51:56 UTC (rev 8333)
> +++
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/FormProcViewController.java
> 2008-02-04 03:57:56 UTC (rev 8334)
> @@ -8,6 +8,11 @@
>  //
>  // OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
>  //
> +// Modifications:
> +//
> +// 2008 Feb 03: Use Assert.state in afterPropertiesSet().  Use
> KscReportEditor
> +//              for tracking editing state in the user's session. 
> Format code. - [email protected]
> +//
>  // Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights
>  reserved.
>  //
>  // This program is free software; you can redistribute it and/or modify
> @@ -36,12 +41,14 @@
>  import javax.servlet.http.HttpServletResponse;
>  
>  import org.opennms.netmgt.config.KSC_PerformanceReportFactory;
> +import org.opennms.netmgt.config.KscReportEditor;
>  import org.opennms.netmgt.config.kscReports.Graph;
>  import org.opennms.netmgt.config.kscReports.Report;
>  import org.opennms.web.MissingParameterException;
>  import org.opennms.web.WebSecurityUtils;
>  import org.opennms.web.svclayer.KscReportService;
>  import org.springframework.beans.factory.InitializingBean;
> +import org.springframework.util.Assert;
>  import org.springframework.web.servlet.ModelAndView;
>  import org.springframework.web.servlet.mvc.AbstractController;
>  
> @@ -53,49 +60,47 @@
>      @Override
>      protected ModelAndView handleRequestInternal(HttpServletRequest
>      request, HttpServletResponse response) throws Exception {
>          // Get Form Variables
> -        int report_index = 0; 
> +        int report_index = -1; 
>          String override_timespan = null;
>          String override_graphtype = null;
>          String report_action = request.getParameter("action");
>          String domain = request.getParameter("domain");
>          if (report_action == null) {
> -            throw new MissingParameterException ("action", new String[]
> {"action","report","type"});
> +            throw new MissingParameterException ("action", new String[]
> {"action", "report", "type"});
>          }
>          String report_type = request.getParameter("type");
>          if (report_type == null) {
> -            throw new MissingParameterException ("type", new String[]
> {"action","report","type"});
> +            throw new MissingParameterException ("type", new String[]
> {"action", "report", "type"});
>          }
>  
> -        if ((report_action.equals("Customize")) ||
> (report_action.equals("Update"))) {
> +        if (report_action.equals("Customize") ||
> report_action.equals("Update")) {
>              String r_index = request.getParameter("report");
>              if (r_index != null && !r_index.equals("null")) {
>                 report_index = WebSecurityUtils.safeParseInt(r_index); 
>              } else if (domain == null) {
> -                throw new MissingParameterException("report or domain",
> new String[] {"report or domain","type"});
> +                throw new MissingParameterException("report or domain",
> new String[] {"report or domain" , "type"});
>              }
>              override_timespan = request.getParameter("timespan");
> -            if ((override_timespan == null) ||
> (override_timespan.equals("null"))) {
> +            if ((override_timespan == null) ||
> override_timespan.equals("null")) {
>                  override_timespan = "none";
>              }
>              override_graphtype = request.getParameter("graphtype");
> -            if ((override_graphtype == null) ||
> (override_graphtype.equals("null"))) {
> +            if (override_graphtype == null ||
> override_graphtype.equals("null")) {
>                  override_graphtype = "none";
>              }
>              if (report_action.equals("Customize")) {
> +                KscReportEditor editor =
> KscReportEditor.getFromSession(request.getSession(), false);
> +                
>                  if (report_type.equals("node")) {
> -                    Report report =
> m_kscReportService.buildNodeReport(report_index);
> -                    getKscReportFactory().loadWorkingReport(report); 
> -                    getKscReportFactory().setWorkingReportIndex(-1); //
> Must set index to -1 to make customizer create a new report, not replace
> +                   
> editor.loadWorkingReport(m_kscReportService.buildNodeReport(report_index)); 
>                  } else if (report_type.equals("domain")) {
> -                    Report report =
> m_kscReportService.buildDomainReport(domain);
> -                    getKscReportFactory().loadWorkingReport(report); 
> -                    getKscReportFactory().setWorkingReportIndex(-1); //
> Must set index to -1 to make customizer create a new report, not replace
> +                   
> editor.loadWorkingReport(m_kscReportService.buildDomainReport(domain)); 
>                  } else { 
> -                    // Go ahead and tell report factory to put the
> indexed report config into the working report area
> -                   
> getKscReportFactory().loadWorkingReport(report_index);
> +                    editor.loadWorkingReport(getKscReportFactory(),
> report_index);
>                  }
> +                
>                  // Now inject any override characteristics into the
>                  working report model
> -                Report working_report =
> getKscReportFactory().getWorkingReport();
> +                Report working_report = editor.getWorkingReport();
>                  for (int i=0; i<working_report.getGraphCount(); i++) {
>                      Graph working_graph = working_report.getGraph(i);
>                      if (!override_timespan.equals("none")) { 
> @@ -114,10 +119,14 @@
>          
>          if (report_action.equals("Update")) {
>              ModelAndView modelAndView = new
>              ModelAndView("redirect:/KSC/customView.htm");
> -            modelAndView.addObject("report", report_index);
> -            modelAndView.addObject("domain", domain);
>              modelAndView.addObject("type", report_type);
> -            
> +
> +            if (report_index >= 0) {
> +                modelAndView.addObject("report", report_index);
> +            }
> +            if (domain != null) {
> +                modelAndView.addObject("domain", domain);
> +            }
>              if (override_timespan != null) { 
>                  modelAndView.addObject("timespan", override_timespan);
>              }
> @@ -127,7 +136,7 @@
>  
>              return modelAndView;
>          } else if (report_action.equals("Customize")) { 
> -            return new ModelAndView("redirect:/KSC/customReport.htm",
> "report", report_index);
> +            return new ModelAndView("redirect:/KSC/customReport.htm");
>          } else if (report_action.equals("Exit")) {
>              return new ModelAndView("redirect:/KSC/index.htm");
>          } else {
> @@ -144,13 +153,8 @@
>      }
>  
>      public void afterPropertiesSet() throws Exception {
> -        if (m_kscReportFactory == null) {
> -            throw new IllegalStateException("property kscReportFactory
> must be set");
> -        }
> -        
> -        if (m_kscReportService == null) {
> -            throw new IllegalStateException("property kscReportService
> must be set");
> -        }
> +        Assert.state(m_kscReportFactory != null, "property
> kscReportFactory must be set");
> +        Assert.state(m_kscReportService != null, "property
> kscReportService must be set");
>      }
>  
>      public KscReportService getKscReportService() {
> 
> Modified:
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/IncludeBoxController.java
> ===================================================================
> ---
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/IncludeBoxController.java
> 2008-02-03 17:51:56 UTC (rev 8333)
> +++
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/IncludeBoxController.java
> 2008-02-04 03:57:56 UTC (rev 8334)
> @@ -6,6 +6,10 @@
>  // code that was published under the GNU General Public License.
>  Copyrights for modified
>  // and included code are below.
>  //
> +// Modifications:
> +//
> +// 2008 Feb 03: Use Assert.state in afterPropertiesSet(). -
> [email protected]
> +//
>  // OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
>  //
>  // Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights
>  reserved.
> @@ -36,6 +40,7 @@
>  
>  import org.opennms.web.svclayer.KscReportService;
>  import org.springframework.beans.factory.InitializingBean;
> +import org.springframework.util.Assert;
>  import org.springframework.web.servlet.ModelAndView;
>  import org.springframework.web.servlet.mvc.AbstractController;
>  
> @@ -56,8 +61,6 @@
>      }
>  
>      public void afterPropertiesSet() throws Exception {
> -        if (m_kscReportService == null) {
> -            throw new IllegalStateException("property kscReportService
> must be set");
> -        }
> +        Assert.state(m_kscReportService != null, "property
> kscReportService must be set");
>      }
>  }
> 
> Modified:
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/IndexController.java
> ===================================================================
> ---
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/IndexController.java
> 2008-02-03 17:51:56 UTC (rev 8333)
> +++
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/controller/ksc/IndexController.java
> 2008-02-04 03:57:56 UTC (rev 8334)
> @@ -8,6 +8,10 @@
>  //
>  // OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
>  //
> +// Modifications:
> +//
> +// 2008 Feb 03: Use Assert.state in afterPropertiesSet(). -
> [email protected]
> +//
>  // Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights
>  reserved.
>  //
>  // This program is free software; you can redistribute it and/or modify
> @@ -38,6 +42,7 @@
>  import org.opennms.web.svclayer.KscReportService;
>  import org.opennms.web.svclayer.ResourceService;
>  import org.springframework.beans.factory.InitializingBean;
> +import org.springframework.util.Assert;
>  import org.springframework.web.servlet.ModelAndView;
>  import org.springframework.web.servlet.mvc.AbstractController;
>  
> @@ -75,13 +80,7 @@
>      }
>  
>      public void afterPropertiesSet() throws Exception {
> -        if (m_resourceService == null) {
> -            throw new IllegalStateException("property resourceService
> must be set");
> -        }
> -        if (m_kscReportService == null) {
> -            throw new IllegalStateException("property kscReportService
> must be set");
> -        }
> +        Assert.state(m_resourceService != null, "property
> resourceService must be set");
> +        Assert.state(m_kscReportService != null, "property
> kscReportService must be set");
>      }
> -
> -
>  }
> 
> Modified:
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/svclayer/support/DefaultKscReportService.java
> ===================================================================
> ---
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/svclayer/support/DefaultKscReportService.java
> 2008-02-03 17:51:56 UTC (rev 8333)
> +++
> opennms/trunk/opennms-webapp/src/main/java/org/opennms/web/svclayer/support/DefaultKscReportService.java
> 2008-02-04 03:57:56 UTC (rev 8334)
> @@ -8,6 +8,11 @@
>  //
>  // OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
>  //
> +// Modifications:
> +//
> +// 2008 Feb 03: Use Assert.state in afterPropertiesSet().  Move
> getReportList()
> +//              work into KSC_PerformanceReportFactory. - [email protected]
> +//
>  // Original code base Copyright (C) 1999-2001 Oculan Corp.  All rights
>  reserved.
>  //
>  // This program is free software; you can redistribute it and/or modify
> @@ -38,13 +43,12 @@
>  import org.opennms.netmgt.config.KSC_PerformanceReportFactory;
>  import org.opennms.netmgt.config.kscReports.Graph;
>  import org.opennms.netmgt.config.kscReports.Report;
> -import org.opennms.netmgt.config.kscReports.ReportsList;
> -import org.opennms.netmgt.model.PrefabGraph;
>  import org.opennms.netmgt.model.OnmsResource;
> +import org.opennms.netmgt.model.PrefabGraph;
>  import org.opennms.web.svclayer.KscReportService;
>  import org.opennms.web.svclayer.ResourceService;
>  import org.springframework.beans.factory.InitializingBean;
> -import org.springframework.dao.DataAccessResourceFailureException;
> +import org.springframework.util.Assert;
>  
>  public class DefaultKscReportService implements KscReportService,
>  InitializingBean {
>      
> @@ -130,7 +134,7 @@
>      
>  
>      private void initTimeSpans() {
> -        for (String timeSpan : getKscReportFactory().timespan_options) {
> +        for (String timeSpan :
> KSC_PerformanceReportFactory.TIMESPAN_OPTIONS) {
>              s_timeSpans.put(timeSpan, timeSpan);
>          }
>          
> @@ -147,19 +151,7 @@
>      }
>      
>      public Map<Integer, String> getReportList() {
> -        ReportsList report_configuration =
> KSC_PerformanceReportFactory.getConfiguration();  
> -        if (report_configuration == null) {
> -            throw new DataAccessResourceFailureException("Couldn't
> retrieve KSC Report File configuration");
> -        }
> -        
> -        Report[] report_array = report_configuration.getReport();
> -        
> -        LinkedHashMap<Integer, String> reports = new
> LinkedHashMap<Integer, String>();
> -        for (int i = 0; i < report_configuration.getReportCount(); i++ )
> {
> -            reports.put(i, report_array[i].getTitle());
> -        }
> -        
> -        return reports;
> +        return m_kscReportFactory.getReportList();  
>      }
>  
>      public ResourceService getResourceService() {
> @@ -179,12 +171,8 @@
>      }
>  
>      public void afterPropertiesSet() throws Exception {
> -        if (m_resourceService == null) {
> -            throw new IllegalStateException("resourceService property
> has not been set");
> -        }
> -        if (m_kscReportFactory == null) {
> -            throw new IllegalStateException("kscReportFactory property
> has not been set");
> -        }
> +        Assert.state(m_resourceService != null, "resourceService
> property has not been set");
> +        Assert.state(m_kscReportFactory != null, "kscReportFactory
> property has not been set");
>          
>          initTimeSpans();
>      }
> 
> 
> This was sent by the SourceForge.net collaborative development platform,
> the world's largest Open Source development site.
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Please read the OpenNMS Mailing List FAQ:
> http://www.opennms.org/wiki/index.php?page=MailingListFaq
> opennms-cvs mailing list
> 
> To *unsubscribe* or change your subscription options, see the bottom of
> this page:
> https://lists.sourceforge.net/lists/listinfo/opennms-cvs

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Please read the OpenNMS Mailing List FAQ:
http://www.opennms.org/index.php/Mailing_List_FAQ

opennms-devel mailing list

To *unsubscribe* or change your subscription options, see the bottom of this page:
https://lists.sourceforge.net/lists/listinfo/opennms-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.