Package org.jasen.error

Examples of org.jasen.error.JasenException


                    scanlock.wait();
                    logger.debug("Stopped waiting executing scan...");
                } catch (InterruptedException ignore) {}

                if(!initialized) {
                    throw new JasenException("Cannot access the jASEN engine until it has been intialized!");
                }
            }

            scansInProgress++;
            scanlock.notifyAll();
View Full Code Here


      reader.read(in, out, readBufferSize, readTimeout, null);

      html = new String(((ByteArrayOutputStream)out).toByteArray());
    }
    catch (IOException e) {
      throw new JasenException(e);
    }
    finally {
      if(in != null) {
        try {
          in.close();
View Full Code Here

     */
    public InputStream openConfigurationStream() throws JasenException {
        in = this.getClass().getClassLoader().getResourceAsStream(JasenConfiguration.DEFAULT_CONFIG_PATH);
       
        if(in == null) {
            throw new JasenException("Could not locate configuration file in " + JasenConfiguration.DEFAULT_CONFIG_PATH);
        }
       
        return in;
    }
View Full Code Here

            if(in != null) {
                in.close();
                in = null;
            }
        } catch (IOException e) {
            throw new JasenException(e);
        }
    }
View Full Code Here

        return instance;
    }

    void assertInitialised() throws JasenException {
        if(!initialized) {
            throw new JasenException("Cannot perform requested operation on uninitialized AutoUpdate manager.  Please ensure the auto update engine is enabled");
        }
    }
View Full Code Here

            in = new FileInputStream(config);
            init(in);
        }
        catch (FileNotFoundException e)
        {
            throw new JasenException(e);
        }
        finally
        {
            if(in != null) {
                try
View Full Code Here

                JasenAutoUpdateManager.getInstance().init(jc);
            }
        }
        catch (IOException e)
        {
            throw new JasenException(e);
        }
        catch (SAXException e)
        {
            throw new JasenException(e);
        }
        catch (InstantiationException e)
        {
            throw new JasenException(e);
        }
        catch (IllegalAccessException e)
        {
            throw new JasenException(e);
        }
        catch (ClassNotFoundException e)
        {
            throw new JasenException(e);
        }
    }
View Full Code Here

            parser = (ReceivedHeaderParser) headerParserClass.newInstance();

        }
        catch (InstantiationException e)
        {
            throw new JasenException(e);
        }
        catch (IllegalAccessException e)
        {
            throw new JasenException(e);
        }

        //  Wrap the message so we can capture mimeParser data and store tokenized text
        JasenMessageWrapper wrapper = new JasenMessageWrapper(message);

        wrapper.setEngine(this);

        // Parse the HTML part and extract the tokens
        SpamHTMLParser htmlParser = new SpamHTMLParser();

        // Now, tokenize the html and text parts of the message
        ParserData parserData = htmlParser.parse(mm, wrapper, tokenizer);

        // Now, loop through the plugins in order and test...
        if(plugins != null) {

            PluginContainer container = null;
            JasenTestResult pluginResult = null;

            double[] probabilities = new double[plugins.size()];
            double[] pointProbabilities = null;
            int points = 0;
            float min = 0.0f;
            float max = 0.0f;
            int pointThreshold = 1;
            float prob = 0.5f;
            double finalProbability = 0.5d;
            boolean thresholdReached = false;

            String[][] testResults = new String[plugins.size()][4];

            long time;
           
            // Ensure the ignore list is sorted for the binary search
            if(ignored != null) {
                Arrays.sort(ignored);
            }

            for (int i = 0; i < plugins.size(); i++)
            {
                time = System.currentTimeMillis();

                container = (PluginContainer)plugins.get(i);
               
                // Determine if we should ignore this plugin
                if(ignored != null && ignored.length > 0 && Arrays.binarySearch(ignored, container.getName()) > -1) {
                    probabilities[i] =  JasenEngineConfiguration.getInstance().getGuess();
                   
                    testResults[i][RESULT_INDEX_PROBABILITY] = String.valueOf(probabilities[i])
                    testResults[i][RESULT_INDEX_TIME] = "0";
                    testResults[i][RESULT_INDEX_NAME] = container.getName();
                    testResults[i][RESULT_INDEX_PROBABILITY] = container.getDisplayName();
                }
                else
                {
                    try
                    {
                        pluginResult = container.getPlugin().test(this, mm, wrapper, parserData, parser);
                    }
                    catch (JasenException e)
                    {
                        // We couldn't execute this plugin... record the error and continue
                        ErrorHandlerBroker.getInstance().getErrorHandler().handleException(e);

                        probabilities[i] = JasenEngineConfiguration.getInstance().getGuess();
                    }

                    testResults[i][RESULT_INDEX_NAME] = container.getName();
                    testResults[i][RESULT_INDEX_DISPLAY] = container.getDisplayName();

                    if(pluginResult != null) {
                        if(pluginResult.isAbsolute()) {
                            // We know it's definately spam
                            result.setProbability(1.0d);

                            testResults[i][RESULT_INDEX_PROBABILITY] = "1.0";

                            // Stop processing here
                            return result;
                        }
                        else
                        {
                            probabilities[i] = pluginResult.calculateProbability();
                            testResults[i][RESULT_INDEX_PROBABILITY] = String.valueOf(probabilities[i]);
                        }
                    }
                    else
                    {
                        throw new JasenException("JasenTestResult cannot be null");
                    }

                    // If we have a threshold, compute now
                    if(threshold != NO_THRESHOLD) {
                        finalProbability = calculate(probabilities, 0, i+1);
View Full Code Here

                        return result;
                    }
                    catch (InstantiationException e1)
                    {
                        throw new JasenException(e1);
                    }
                    catch (IllegalAccessException e1)
                    {
                        throw new JasenException(e1);
                    }
                }
                else
                {
                    throw e;
View Full Code Here

                map = new JasenMap();
            }
        }
        catch (Exception e)
        {
            throw new JasenException(e);
        }
        finally
        {
            if(in != null) {
                try
View Full Code Here

TOP

Related Classes of org.jasen.error.JasenException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.