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.12
Committed: Sat May 18 18:16:02 2002 UTC (22 years ago) by tdb
Branch: MAIN
Changes since 1.11: +22 -3 lines
Log Message:
i-scream is now licensed under the GPL. I've added the GPL headers to every
source file, and put a full copy of the license in the appropriate places.
I think I've covered everything. This is going to be a mad commit ;)

File Contents

# User Rev Content
1 tdb 1.12 /*
2     * i-scream central monitoring system
3     * Copyright (C) 2000-2002 i-scream
4     *
5     * This program is free software; you can redistribute it and/or
6     * modify it under the terms of the GNU General Public License
7     * as published by the Free Software Foundation; either version 2
8     * of the License, or (at your option) any later version.
9     *
10     * This program is distributed in the hope that it will be useful,
11     * but WITHOUT ANY WARRANTY; without even the implied warranty of
12     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13     * GNU General Public License for more details.
14     *
15     * You should have received a copy of the GNU General Public License
16     * along with this program; if not, write to the Free Software
17     * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18     */
19    
20 ajm 1.2 //---PACKAGE DECLARATION---
21 tdb 1.10 package uk.org.iscream.cms.server.filter.plugins;
22 ajm 1.2
23     //---IMPORTS---
24 tdb 1.10 import uk.org.iscream.cms.server.filter.PluginFilter;
25     import uk.org.iscream.cms.server.filter.*;
26     import uk.org.iscream.cms.server.core.*;
27     import uk.org.iscream.cms.server.util.*;
28     import uk.org.iscream.cms.server.componentmanager.*;
29 ajm 1.2
30     /**
31 tdb 1.11 * This plugin rejects packets that do not
32     * contain all of the 'essential' data.
33 ajm 1.2 *
34 tdb 1.12 * @author $Author: tdb $
35     * @version $Id: EnforceEssentialData__Plugin.java,v 1.11 2001/12/10 22:20:23 tdb Exp $
36 ajm 1.2 */
37     public class EnforceEssentialData__Plugin implements PluginFilter {
38    
39     //---FINAL ATTRIBUTES---
40    
41     /**
42     * The current CVS revision of this class
43     */
44 tdb 1.12 public final String REVISION = "$Revision: 1.11 $";
45 ajm 1.2
46 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.";
47 ajm 1.2
48     //---STATIC METHODS---
49    
50     //---CONSTRUCTORS---
51    
52     //---PUBLIC METHODS---
53    
54     // apply the filter and return true if successful.
55     public boolean runFilter(XMLPacket packet){
56 tdb 1.6
57 tdb 1.8 // return true if a heartbeat packet seems ok
58 tdb 1.7 if (packet.getParam("packet.attributes.type").equals("heartbeat")
59 tdb 1.6 && packet.getParam("packet.attributes.date") != null
60     && packet.getParam("packet.attributes.ip") != null
61     && packet.getParam("packet.attributes.machine_name") != null){
62     return true;
63     }
64 ajm 1.2
65 tdb 1.8 // return true if a queueStat packet seems ok
66     if (packet.getParam("packet.attributes.type").equals("queueStat")
67     && packet.getParam("packet.attributes.date") != null
68     && packet.getParam("packet.attributes.name") != null){
69     return true;
70     }
71    
72     // return false if any of the essential data is not present
73     // in a "data" packet
74 ajm 1.2 if (packet.getParam("packet.attributes.machine_name") == null
75     || packet.getParam("packet.attributes.ip") == null
76     || packet.getParam("packet.attributes.seq_no") == null
77 tdb 1.5 || packet.getParam("packet.attributes.date") == null
78     || packet.getParam("packet.attributes.type") == null){
79 ajm 1.2 return false;
80     }
81    
82     // otherwise return true!
83     return true;
84    
85     }
86    
87     /**
88     * Overrides the {@link java.lang.Object#toString() Object.toString()}
89     * method to provide clean logging (every class should have this).
90     *
91 tdb 1.10 * This uses the uk.org.iscream.cms.server.util.NameFormat class
92 ajm 1.2 * to format the toString()
93     *
94     * @return the name of this class and its CVS revision
95     */
96     public String toString() {
97     return FormatName.getName(
98     _name,
99     getClass().getName(),
100     REVISION);
101     }
102    
103     /**
104     * return the String representation of what the filter does
105     */
106     public String getDescription(){
107     return DESC;
108     }
109    
110     //---PRIVATE METHODS---
111    
112     //---ACCESSOR/MUTATOR METHODS---
113    
114     //---ATTRIBUTES---
115    
116     /**
117     * This is the friendly identifier of the
118     * component this class is running in.
119     * eg, a Filter may be called "filter1",
120     * If this class does not have an owning
121     * component, a name from the configuration
122     * can be placed here. This name could also
123     * be changed to null for utility classes.
124     */
125     private String _name = FilterMain.NAME;
126    
127     /**
128     * This holds a reference to the
129     * system logger that is being used.
130     */
131     private Logger _logger = ReferenceManager.getInstance().getLogger();
132    
133     //---STATIC ATTRIBUTES---
134    
135     }