Project

General

Profile

« Previous | Next » 

Revision 2101

Added by Matt Jones about 20 years ago

Modified EventLog to eliminate the separate revision column and instead fold
that into the docid string. Log now includes read events, but need to update
the data sent there.

View differences:

src/xmltables_postgres.sql
278 278
  ip_address    VARCHAR(512),   -- the ip address inititiating the event
279 279
  principal     VARCHAR(512),   -- the user initiiating the event
280 280
  docid         VARCHAR(250),	-- the document id #
281
  rev           INT8,           -- the revision number
282 281
  event         VARCHAR(512),   -- the code symbolizing the event type
283 282
  date_logged   TIMESTAMP,      -- the datetime on which the event occurred
284 283
  CONSTRAINT access_log_pk PRIMARY KEY (entryid)
src/upgrade-db-to-1.4.sql
30 30
  ip_address    VARCHAR2(512),  -- the ip address inititiating the event
31 31
  principal     VARCHAR2(512),  -- the user initiiating the event
32 32
  docid         VARCHAR2(250),	-- the document id #
33
  rev           NUMBER(10),     -- the revision number
34 33
  event         VARCHAR2(512),  -- the code symbolizing the event type
35 34
  date_logged   DATE,           -- the datetime on which the event occurred
36 35
  CONSTRAINT access_log_pk PRIMARY KEY (entryid)
......
44 43
    INTO :new.entryid
45 44
    FROM dual;
46 45
END;
47
/
46
/
src/xmltables.sql
330 330
  ip_address    VARCHAR2(512),  -- the ip address inititiating the event
331 331
  principal     VARCHAR2(512),  -- the user initiiating the event
332 332
  docid         VARCHAR2(250),	-- the document id #
333
  rev           NUMBER(10),     -- the revision number
334 333
  event         VARCHAR2(512),  -- the code symbolizing the event type
335 334
  date_logged   DATE,           -- the datetime on which the event occurred
336 335
  CONSTRAINT access_log_pk PRIMARY KEY (entryid)
src/edu/ucsb/nceas/metacat/EventLogData.java
34 34
	private String ipAddress;
35 35
	private String principal;
36 36
	private String docid;
37
    private long revision;
38 37
	private String event;
39 38
	
40 39
	
......
48 47
	 * @param event the string code for the event
49 48
	 */
50 49
	public EventLogData(String ipAddress, String principal, String docid,
51
			long revision, String event) {
50
			String event) {
52 51
		this.ipAddress = ipAddress;
53 52
		this.principal = principal;
54 53
		this.docid = docid;
55
		this.revision = revision;
56 54
		this.event = event;
57 55
	}
58 56
	
......
128 126
	public void setPrincipal(String principal) {
129 127
		this.principal = principal;
130 128
	}
131
	
132
	/**
133
	 * Get the current value of the document revision.
134
	 * 
135
	 * @return Returns the revision.
136
	 */
137
	public long getRevision() {
138
		return revision;
139
	}
140
	
141
	/**
142
	 * Set the current value of the document revision.
143
	 * 
144
	 * @param revision The revision to set.
145
	 */
146
	public void setRevision(long revision) {
147
		this.revision = revision;
148
	}
149 129
}
src/edu/ucsb/nceas/metacat/EventLog.java
89 89
     * @param ipAddress the internet protocol address for the event
90 90
	 * @param principal the principal for the event (a username, etc)
91 91
	 * @param docid the identifier of the document to which the event applies
92
	 * @param revision the revision of the document to which the event applies
93 92
	 * @param event the string code for the event
94 93
     */
95 94
    public void log(String ipAddress, String principal, String docid,
96
			long revision, String event)
95
			String event)
97 96
    {
98 97
        EventLogData logData = new EventLogData(ipAddress, principal, docid,
99
                revision, event);
98
                event);
100 99
        insertLogEntry(logData);
101 100
    }
102 101
    
......
111 110
                "dd-MMM-yyyy HH:mm:ss");
112 111

  
113 112
        String insertString = "insert into access_log"
114
                + "(ip_address, principal, docid, rev, "
113
                + "(ip_address, principal, docid, "
115 114
                + "event, date_logged) "
116 115
                + "values ("
117 116
                + "'" + logData.getIpAddress() + "', " 
118 117
                + "'" + logData.getPrincipal() + "', "
119 118
                + "'" + logData.getDocid() + "', "
120
                + logData.getRevision() + ", "
121 119
                + "'" + logData.getEvent() + "', "
122 120
                + "'" + simpleDateFormat.format(new Date()) + "')"; 
123 121

  
src/edu/ucsb/nceas/metacat/MetaCatServlet.java
999 999
                        }
1000 1000
                    }
1001 1001
                    
1002
                    // Log the event to the event table
1003
                    EventLog.getInstance().log("192.168.1.103", "public", 
1004
                            "test.1", 1, "read");
1005 1002
                } catch (MalformedURLException mue) {
1003
                    MetaCatUtil.debugMessage("MUE handleReadAction", 5);
1006 1004
                    docid = docs[i];
1007 1005
                    if (zip) {
1008 1006
                        addDocToZip(docid, zout, user, groups);
1009 1007
                    } else {
1010 1008
                        readFromMetacat(response, docid, qformat, abstrpath,
1011
                                user, groups, zip, zout, withInlineData, params);
1009
                            user, groups, zip, zout, withInlineData, params);
1012 1010
                    }
1013 1011
                }
1014

  
1015 1012
            }
1016 1013

  
1017 1014
            if (zip) {
......
1205 1202
                }
1206 1203

  
1207 1204
            }
1205
            EventLog.getInstance().log("192.168.1.103", "public", 
1206
                    docid, "read");
1208 1207
        } catch (Exception except) {
1209 1208
            throw except;
1210 1209
        }
......
1348 1347
                    zout.write(bytestring, 0, bytestring.length);
1349 1348
                    zout.closeEntry();
1350 1349
                }
1350
                EventLog.getInstance().log("192.168.1.103", "public", 
1351
                        docid, "read");
1351 1352
            } catch (Exception except) {
1352 1353
                throw except;
1353 1354
            }
src/upgrade-db-to-1.4_postgres.sql
31 31
  ip_address    VARCHAR(512),   -- the ip address inititiating the event
32 32
  principal     VARCHAR(512),   -- the user initiiating the event
33 33
  docid         VARCHAR(250),	-- the document id #
34
  rev           INT8,           -- the revision number
35 34
  event         VARCHAR(512),   -- the code symbolizing the event type
36 35
  date_logged   TIMESTAMP,      -- the datetime on which the event occurred
37 36
  CONSTRAINT access_log_pk PRIMARY KEY (entryid)

Also available in: Unified diff