01: /*
02: * (C) Copyright 2006 Nabh Information Systems, Inc.
03: *
04: * This program is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU General Public License
06: * as published by the Free Software Foundation; either version 2
07: * of the License, or (at your option) any later version.
08: *
09: * This program is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU General Public License for more details.
13: *
14: * You should have received a copy of the GNU General Public License
15: * along with this program; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17: *
18: */
19: package com.nabhinc.portal.api;
20:
21: import java.util.Calendar;
22: import java.util.GregorianCalendar;
23:
24: import javax.servlet.http.HttpServletRequest;
25: import javax.xml.bind.annotation.XmlElement;
26:
27: /**
28: *
29: *
30: * @author Padmanabh Dabke
31: * (c) 2006 Nabh Information Systems, Inc. All Rights Reserved.
32: */
33: public class VersionInfo implements Comparable<VersionInfo> {
34: public static final int INITIAL_VERSION_NUMBER = 1;
35: int versionNumber = INITIAL_VERSION_NUMBER;
36: private String createdBy = null;
37: private Calendar creationTime = GregorianCalendar.getInstance();
38: private String creationIP = null;
39:
40: @XmlElement(name="created-by")
41: public String getCreatedBy() {
42: return createdBy;
43: }
44:
45: public void setCreatedBy(String createdBy) {
46: this .createdBy = createdBy;
47: }
48:
49: @XmlElement(name="creation-ip")
50: public String getCreationIP() {
51: return creationIP;
52: }
53:
54: public void setCreationIP(String creationIP) {
55: this .creationIP = creationIP;
56: }
57:
58: @XmlElement(name="creation-time")
59: public Calendar getCreationTime() {
60: return creationTime;
61: }
62:
63: public void setCreationTime(Calendar creationTime) {
64: this .creationTime = creationTime;
65: }
66:
67: @XmlElement(name="version-number")
68: public int getVersionNumber() {
69: return versionNumber;
70: }
71:
72: public void setVersionNumber(int versionNumber) {
73: this .versionNumber = versionNumber;
74: }
75:
76: public static VersionInfo create(HttpServletRequest req) {
77: VersionInfo vInfo = new VersionInfo();
78: vInfo.setCreatedBy(req.getRemoteUser());
79: vInfo.setCreationIP(req.getRemoteAddr());
80: return vInfo;
81: }
82:
83: public int compareTo(VersionInfo arg0) {
84: return this.creationTime.compareTo(arg0.creationTime);
85: }
86: }
|