|
3.1.1: 2012-03-29 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnet.sf.basedb.core.BasicItem<MessageData>
net.sf.basedb.core.Message
public class Message
This class represents a message. Messages are normally sent by the system when a job is completed. It is also possible to send messages between other users.
| Field Summary | |
|---|---|
static int |
MAX_FROM_LENGTH
The maximum length of the sender name. |
private boolean |
sendAsEmail
|
private boolean |
systemCreated
|
static Item |
TYPE
The type of item represented by this class. |
| Fields inherited from interface net.sf.basedb.core.Nameable |
|---|
MAX_DESCRIPTION_LENGTH, MAX_NAME_LENGTH |
| Constructor Summary | |
|---|---|
Message(MessageData messageData)
|
|
| Method Summary | |
|---|---|
static long |
countUnreadMessages(DbControl dc,
User user,
boolean cacheResult)
Count the number of unread messages for the specified or logged in user. |
static Message |
getById(DbControl dc,
int id)
Get a Message item when you know the id. |
String |
getDescription()
Get the description for the item. |
String |
getFrom()
Get the name of the sender of this message. |
Job |
getJob()
Get the Job this message is about. |
String |
getName()
Get the name of the item. |
static Message |
getNew(DbControl dc,
User to,
String fromName,
User fromUser,
Job job)
Create a new Message item. |
(package private) static Message |
getNewSystemMessage(DbControl dc,
User to,
String fromName,
User fromUser,
Job job)
Create a new Message from the system. |
static ItemQuery<Message> |
getQuery(User user)
Get a query configured to retrieve messages for the specified user. |
User |
getSender()
Get the user that sent this message. |
Date |
getTimeSent()
Get the date and time the message was sent. |
User |
getTo()
Get the User this message was sent to. |
Item |
getType()
Get the type of item represented by the object. |
(package private) void |
initPermissions(int granted,
int denied)
Read, write an delete permission is granted if the logged in user is the same as the user the message is to. |
boolean |
isRead()
Check if the message has been read or not. |
boolean |
isRemoved()
Check if the removed flag is set for this item. |
(package private) void |
onAfterCommit(Transactional.Action action)
Send the message as an email if requested by the user. |
void |
sendAsEmail()
Send this message as an email. |
void |
setDescription(String description)
Set the description for the item. |
private void |
setFrom(String from)
Set the name of the sender of the message. |
private void |
setJob(Job job)
|
void |
setName(String name)
Set the name of the item. |
void |
setRead(boolean isRead)
Set read status of the message. |
void |
setRemoved(boolean removed)
Set the removed flag for this item. |
private void |
setSender(User sender)
|
private void |
setTo(User to)
Set the user this message should be sent to. |
| Methods inherited from class net.sf.basedb.core.BasicItem |
|---|
addUsingItems, addUsingItems, checkPermission, equals, getData, getDbControl, getId, getPermissions, getPluginPermissions, getSessionControl, getUsingItems, getVersion, hashCode, hasPermission, isDetached, isInDatabase, isUsed, onAfterInsert, onBeforeCommit, onRollback, setDbControl, setProjectDefaults, toString, toTransferable, validate |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface net.sf.basedb.core.Identifiable |
|---|
getId, getVersion |
| Methods inherited from interface net.sf.basedb.core.AccessControlled |
|---|
checkPermission, getPermissions, hasPermission |
| Field Detail |
|---|
public static final Item TYPE
Item.MESSAGE,
getType()private boolean systemCreated
private boolean sendAsEmail
public static final int MAX_FROM_LENGTH
getNew(DbControl, User, String, User, Job),
Constant Field Values| Constructor Detail |
|---|
Message(MessageData messageData)
| Method Detail |
|---|
public static Message getNew(DbControl dc,
User to,
String fromName,
User fromUser,
Job job)
throws BaseException
Message item.
dc - The DbControl which will be used for
permission checking and database accessto - The user who should receive the message.fromName - Name of the sender.fromUser - The user who sends this message.job - Which job this message is about.
Message item
BaseException - If there is an error
static Message getNewSystemMessage(DbControl dc,
User to,
String fromName,
User fromUser,
Job job)
Message from the system. This will not fail due
to missing create permission for the logged in user.
dc - The DbControl which will be used for
permission checking and database accessto - The user who should receive the message.fromName - Name of the sender.fromUser - The user who sends this message.job - Which job this message is about.
Message item
BaseException - If there is an error
public static Message getById(DbControl dc,
int id)
throws ItemNotFoundException,
PermissionDeniedException,
BaseException
Message item when you know the id.
dc - The DbControl which will be used for
permission checking and database accessid - The id of the item to load
Message item
ItemNotFoundException - If an item with the specified
ID is not found
PermissionDeniedException - If the logged in user doesn't
have Permission.READ permission to the item
BaseException - If there is another error
public static long countUnreadMessages(DbControl dc,
User user,
boolean cacheResult)
throws BaseException
dc - The DbControl which will be used for
permission checking and database accessuser - The user to count the unread messages for, or null to
count the messages for the logged in usercacheResult - If the result should be cached or not
BaseException - If there is an errorpublic static ItemQuery<Message> getQuery(User user)
user - The user to retreive messages for, null is allowed if
the logged in user has generic read permission for messages in which case
all messages will be returned
ItemQuery objectUser.getMessages()public Item getType()
IdentifiableItem enumeration.
getType in interface Identifiablepublic String getName()
Nameable
getName in interface NameableString with the name of the item
public void setName(String name)
throws PermissionDeniedException,
InvalidDataException
NameableNameable.MAX_NAME_LENGTH constant.
setName in interface Nameablename - The new name for the item
PermissionDeniedException - If the logged in user doesn't
have write permission
InvalidDataException - If the name is null or longer
than specified by the Nameable.MAX_NAME_LENGTH constantpublic String getDescription()
Nameable
getDescription in interface NameableString with a description of the item
public void setDescription(String description)
throws PermissionDeniedException,
InvalidDataException
NameableNameable.MAX_DESCRIPTION_LENGTH constant.
setDescription in interface Nameabledescription - The new description for the item
PermissionDeniedException - If the logged in user doesn't
have write permission
InvalidDataException - If the description longer
than specified by the Nameable.MAX_DESCRIPTION_LENGTH constantpublic boolean isRemoved()
Removable
isRemoved in interface Removable
public void setRemoved(boolean removed)
throws PermissionDeniedException
Removable
setRemoved in interface Removableremoved - TRUE if the item should be flagged as removed,
FALSE otherwise
PermissionDeniedException - If the logged in user doesn't
have Permission.DELETE permission for setting the flag
to TRUE or Permission.WRITE permission for setting the
flag to FALSE
void initPermissions(int granted,
int denied)
throws BaseException
initPermissions in class BasicItem<MessageData>granted - Permissions that have been granted by the subclassdenied - Permissions that have been denied by the subclass
BaseException - If the permissions couldn't be initialisedvoid onAfterCommit(Transactional.Action action)
onAfterCommit in class BasicItem<MessageData>Transactional,
Developer documentation: Transactions,
Developer documentation: Coding rules and guidelines for item classes
public User getTo()
throws PermissionDeniedException,
BaseException
User this message was sent to.
User item
PermissionDeniedException - If the logged in user doesn't have
Permission.READ permission for the user
BaseException - If there is another error
private void setTo(User to)
throws InvalidDataException
InvalidDataException - If the user is nullpublic String getFrom()
getSender()
private void setFrom(String from)
throws InvalidDataException
InvalidDataException - If the sender is null or longer than
MAX_FROM_LENGTH
public User getSender()
throws PermissionDeniedException,
BaseException
User object or null if the message was sent by the system or
the sending user account has been deleted
PermissionDeniedException - If the logged in user doesn't have
Permission.READ permission for the sender
BaseException - If there is another errorgetFrom()private void setSender(User sender)
public Job getJob()
throws PermissionDeniedException,
BaseException
Job this message is about.
Job item
PermissionDeniedException - If the logged in user doesn't have
Permission.READ permission for the job
BaseException - If there is another error
private void setJob(Job job)
throws PermissionDeniedException
PermissionDeniedExceptionpublic Date getTimeSent()
public boolean isRead()
public void setRead(boolean isRead)
throws PermissionDeniedException
isRead - TRUE to mark the message as read, FALSE to mark it as unread
PermissionDeniedException - If the logged in user doesn't have
write permissionpublic void sendAsEmail()
EmailUtil.isEnabled()
|
3.1.1: 2012-03-29 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||