01: /*
02: * Created on Feb 18, 2005
03: */
04: package com.openedit.blog;
05:
06: import java.text.SimpleDateFormat;
07: import java.util.Date;
08:
09: import com.openedit.OpenEditException;
10: import com.openedit.users.User;
11:
12: /**
13: * A blog comment, attached to a blog entry.
14: *
15: * @author cburkey
16: */
17: public class Comment {
18: protected String fieldAuthor; //friendly name
19: protected User fieldUser;
20: protected Date fieldDateTime;
21: protected String fieldContent;
22: protected String fieldId;
23: protected boolean fieldVisible;
24:
25: public String getAuthor() {
26: return fieldAuthor;
27: }
28:
29: public void setAuthor(String inAuthor) {
30: fieldAuthor = inAuthor;
31: }
32:
33: public String getContent() {
34: return fieldContent;
35: }
36:
37: public void setContent(String inContent) {
38: fieldContent = inContent;
39: }
40:
41: public Date getDateTime() {
42: return fieldDateTime;
43: }
44:
45: public void setDateTime(Date inDateTime) {
46: fieldDateTime = inDateTime;
47: }
48:
49: public String published(String inFormat) {
50: SimpleDateFormat format = new SimpleDateFormat(inFormat);
51: return format.format(getDateTime());
52: }
53:
54: public String getId() {
55: return fieldId;
56: }
57:
58: public void setId(String inId) {
59: fieldId = inId;
60: }
61:
62: public boolean isVisible() {
63: return fieldVisible;
64: }
65:
66: public void setVisible(boolean inVisible) {
67: fieldVisible = inVisible;
68: }
69:
70: public boolean canEdit(User inUser) throws OpenEditException {
71: if (inUser != null) {
72: if (inUser.getShortDescription().equals(getAuthor())) {
73: return true;
74: }
75: if (inUser.hasPermission("oe.administration")) {
76: return true;
77: }
78: }
79: return false;
80: }
81:
82: public User getUser() {
83: return fieldUser;
84: }
85:
86: public void setUser(User inUser) {
87: fieldUser = inUser;
88: }
89: }
|