001: /*
002: * This program is free software; you can redistribute it and/or modify
003: * it under the terms of the GNU General Public License as published by
004: * the Free Software Foundation; either version 2 of the License, or
005: * (at your option) any later version.
006: *
007: * This program is distributed in the hope that it will be useful,
008: * but WITHOUT ANY WARRANTY; without even the implied warranty of
009: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
010: * GNU Library General Public License for more details.
011: *
012: * You should have received a copy of the GNU General Public License
013: * along with this program; if not, write to the Free Software
014: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
015: */
016: package dlog4j.formbean;
017:
018: import java.util.ArrayList;
019: import java.util.Date;
020: import java.util.List;
021: import java.util.StringTokenizer;
022:
023: import javax.servlet.http.HttpServletRequest;
024:
025: import org.apache.struts.action.ActionError;
026: import org.apache.struts.action.ActionErrors;
027: import org.apache.struts.action.ActionMapping;
028:
029: /**
030: * 日志
031: * @auhor Liudong
032: */
033: public class LogForm extends LogBaseForm {
034:
035: public final static int STATUS_NORMAL = 0x00;
036: public final static int STATUS_HIDDEN = 0x02;
037: public final static int STATUS_DELETED = 0x04;
038:
039: CategoryForm category;
040: String searchKey;
041: int viewCount;
042: int replyCount;
043: List replies;
044: List trackBacks;
045: Date deleteTime;
046: int replyNotify = 0;
047: int status = STATUS_NORMAL;
048:
049: /* 用户输入的验证
050: * @see org.apache.struts.action.ActionForm#validate(org.apache.struts.action.ActionMapping, javax.servlet.ServletRequest)
051: */
052: public ActionErrors validate(ActionMapping arg0,
053: HttpServletRequest arg1) {
054: ActionErrors errors = new ActionErrors();
055: if (getCategoryId() == -1)
056: errors.add("categoryId", new ActionError(
057: "log_category_not_assign"));
058: if (title == null || title.length() == 0)
059: errors
060: .add("title", new ActionError(
061: "log_title_not_assign"));
062: if (content == null || content.length() == 0)
063: errors.add("content", new ActionError(
064: "log_content_not_assign"));
065: if (author == null || author.length() == 0)
066: errors.add("author", new ActionError("not_empty_allow"));
067: if (authorUrl == null || authorUrl.length() == 0)
068: errors.add("authorUrl", new ActionError("not_empty_allow"));
069: return errors;
070: }
071:
072: public String getSearchKey() {
073: return searchKey;
074: }
075:
076: public String[] getSearchKeys() {
077: if (searchKey == null)
078: return null;
079: ArrayList keys = new ArrayList();
080: StringTokenizer st = new StringTokenizer(searchKey);
081: while (st.hasMoreElements()) {
082: keys.add(st.nextToken());
083: }
084: return (String[]) keys.toArray(new String[keys.size()]);
085: }
086:
087: public void setSearchKey(String searchKey) {
088: this .searchKey = searchKey;
089: }
090:
091: public int getCategoryId() {
092: return (category != null) ? category.getId() : -1;
093: }
094:
095: public void setCategoryId(int catId) {
096: if (category == null)
097: category = new CategoryForm();
098: category.setId(catId);
099: }
100:
101: /**
102: * @return
103: */
104: public CategoryForm getCategory() {
105: return category;
106: }
107:
108: /**
109: * @return
110: */
111: public List getReplies() {
112: return replies;
113: }
114:
115: /**
116: * @return
117: */
118: public int getReplyCount() {
119: return replyCount;
120: }
121:
122: /**
123: * @return
124: */
125: public int getViewCount() {
126: return viewCount;
127: }
128:
129: /**
130: * @param form
131: */
132: public void setCategory(CategoryForm form) {
133: category = form;
134: }
135:
136: /**
137: * @param list
138: */
139: public void setReplies(List list) {
140: replies = list;
141: }
142:
143: /**
144: * @param i
145: */
146: public void setReplyCount(int i) {
147: replyCount = i;
148: }
149:
150: /**
151: * @param i
152: */
153: public void setViewCount(int i) {
154: viewCount = i;
155: }
156:
157: /**
158: * @return
159: */
160: public int getStatus() {
161: return status;
162: }
163:
164: /**
165: * @param i
166: */
167: public void setStatus(int i) {
168: status = i;
169: }
170:
171: public List getTrackBacks() {
172: return trackBacks;
173: }
174:
175: public void setTrackBacks(List trackBacks) {
176: this .trackBacks = trackBacks;
177: }
178:
179: public Date getDeleteTime() {
180: return deleteTime;
181: }
182:
183: public void setDeleteTime(Date deleteTime) {
184: this .deleteTime = deleteTime;
185: }
186:
187: public int getReplyNotify() {
188: return replyNotify;
189: }
190:
191: public void setReplyNotify(int replyNotify) {
192: this.replyNotify = replyNotify;
193: }
194: }
|