ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/filter/plugins/EnforceEssentialData__Plugin.java
Revision: 1.5
Committed: Fri Jan 19 00:08:04 2001 UTC (23 years, 4 months ago) by tdb
Branch: MAIN
Changes since 1.4: +6 -5 lines
Log Message:
Added permitting of type attribute.

File Contents

# User Rev Content
1 ajm 1.2 //---PACKAGE DECLARATION---
2     package uk.ac.ukc.iscream.filter.plugins;
3    
4     //---IMPORTS---
5     import uk.ac.ukc.iscream.filter.PluginFilter;
6 ajm 1.3 import uk.ac.ukc.iscream.filter.*;
7     import uk.ac.ukc.iscream.core.*;
8     import uk.ac.ukc.iscream.util.*;
9 tdb 1.4 import uk.ac.ukc.iscream.componentmanager.*;
10 ajm 1.2
11     /**
12     * A first plugin! ;-)
13     * this one rejects packets that do not contain all of the 'essential' data.
14     *
15 tdb 1.5 * @author $Author: tdb1 $
16     * @version $Id: EnforceEssentialData__Plugin.java,v 1.4 2001/01/18 23:23:14 tdb1 Exp $
17 ajm 1.2 */
18     public class EnforceEssentialData__Plugin implements PluginFilter {
19    
20     //---FINAL ATTRIBUTES---
21    
22     /**
23     * The current CVS revision of this class
24     */
25 tdb 1.5 public final String REVISION = "$Revision: 1.4 $";
26 ajm 1.2
27 tdb 1.5 public final String DESC = "Rejects packets that do not have an ip, machine_name, seq_no, date and type specified as attributes of the root packet tag.";
28 ajm 1.2
29     //---STATIC METHODS---
30    
31     //---CONSTRUCTORS---
32    
33     //---PUBLIC METHODS---
34    
35     // apply the filter and return true if successful.
36     public boolean runFilter(XMLPacket packet){
37    
38     // return false if any of the essential data is not present.
39     if (packet.getParam("packet.attributes.machine_name") == null
40     || packet.getParam("packet.attributes.ip") == null
41     || packet.getParam("packet.attributes.seq_no") == null
42 tdb 1.5 || packet.getParam("packet.attributes.date") == null
43     || packet.getParam("packet.attributes.type") == null){
44 ajm 1.2 return false;
45     }
46    
47     // otherwise return true!
48     return true;
49    
50     }
51    
52     /**
53     * Overrides the {@link java.lang.Object#toString() Object.toString()}
54     * method to provide clean logging (every class should have this).
55     *
56     * This uses the uk.ac.ukc.iscream.util.NameFormat class
57     * to format the toString()
58     *
59     * @return the name of this class and its CVS revision
60     */
61     public String toString() {
62     return FormatName.getName(
63     _name,
64     getClass().getName(),
65     REVISION);
66     }
67    
68     /**
69     * return the String representation of what the filter does
70     */
71     public String getDescription(){
72     return DESC;
73     }
74    
75     //---PRIVATE METHODS---
76    
77     //---ACCESSOR/MUTATOR METHODS---
78    
79     //---ATTRIBUTES---
80    
81     /**
82     * This is the friendly identifier of the
83     * component this class is running in.
84     * eg, a Filter may be called "filter1",
85     * If this class does not have an owning
86     * component, a name from the configuration
87     * can be placed here. This name could also
88     * be changed to null for utility classes.
89     */
90     private String _name = FilterMain.NAME;
91    
92     /**
93     * This holds a reference to the
94     * system logger that is being used.
95     */
96     private Logger _logger = ReferenceManager.getInstance().getLogger();
97    
98     //---STATIC ATTRIBUTES---
99    
100     }