Package de.uplanet.lucy.server.newsagent
Class NewsAgent
java.lang.Object
de.uplanet.lucy.server.newsagent.NewsAgent
Handles messages that exist beyond application scope.
Users MUST call done()
when finished using the agent to
ensure that all resources such as SQL statements are properly closed and freed.
-
Method Summary
Modifier and TypeMethodDescriptionstatic NewsAgent
createInstance
(de.uplanet.jdbc.JdbcConnection p_conn) Factory method for creating a news agent.Create a new message.createNewMessage
(String p_strMessageId) Create a new message with the given message identifier.boolean
deleteMessage
(String p_strMessageId) Delete the specified message.boolean
deleteMessagesForApplication
(String p_strAppGuid) Delete all messages that belong to the specified application GUID.boolean
deleteMessagesForUser
(String p_strUserId) Delete all messages that are addressed to the specified user.void
done()
Deprecated.This method must not be called anymore.dump()
Dump this object to aString
.int
Filter the messages that have already being loaded.get
(int p_iIndex) Get the message at the specified index out of the filtered collection.void
getRichSiteSummary
(Writer p_writer, String p_strResourceUrl, String p_strEncodingDecl, int p_iMaxCount) Create a Rich Site Summary containing all news for which the anonymous user is a recipient.Get the registered target GUID for an application.int
Load messages from the database.loadMessage
(String p_strMessageId) Load the specified message from the database.void
markDeleted
(String p_strMessageId, String p_strUserId) Mark a message as deleted for the specified user.void
Mark a message as read for the specified user.boolean
registerTarget
(String p_strAppGuid, String p_strTargetGuid) Register or re-register a link target for an application.boolean
Save the message to the database.int
size()
Get the number of messages in the filtered collection.void
Sort the messages in the filtered messages collection.void
unregisterTarget
(String p_strAppGuid) Unregister the link target for the given application.
-
Method Details
-
createInstance
Factory method for creating a news agent.- Returns:
- The newly generated news agent.
-
done
Deprecated.This method must not be called anymore. -
createNewMessage
Create a new message.- Returns:
- The newly created message.
-
createNewMessage
Create a new message with the given message identifier.The newly created message is not inserted into the messages collection.
- Returns:
- The newly created message.
- Throws:
IllegalArgumentException
- If the given message ID is not a GUID.
-
markRead
Mark a message as read for the specified user.Either of the parameters may be
null
, however the method does nothing in these cases.- Parameters:
p_strMessageId
- The GUID of the message.p_strUserId
- The GUID of the user.- Throws:
IllegalArgumentException
- If the given message or user ID is not a GUID.
-
markDeleted
Mark a message as deleted for the specified user.Either of the parameters may be
null
, however the method does nothing in these cases.- Parameters:
p_strMessageId
- The GUID of the message.p_strUserId
- The GUID of the user.- Throws:
IllegalArgumentException
- If the given message or user ID is not a GUID.
-
load
Load messages from the database.- Parameters:
p_filter
- The filter to be applied when loading.p_order
- The order in which the messages should be loaded.p_iMaxCount
- The maximum number of messages to be loaded or-1
if all messages should be loaded.- Returns:
- The number of messages that where actually loaded.
-
loadMessage
Load the specified message from the database.The internal state of the news agent is not affected by calling this method. In particular, the content of the messages collection and of the filtered messages collection is not changed.
- Parameters:
p_strMessageId
- The GUID of the message to be loaded.- Returns:
- The message or
null
if the message could not be found. - Throws:
IllegalArgumentException
- If the given message ID is not a GUID.
-
save
Save the message to the database.- Parameters:
p_message
- The message to save.- Returns:
true
if the message was saved,false
otherwise.
-
registerTarget
Register or re-register a link target for an application.- Parameters:
p_strAppGuid
- The application for which the target should be registered.p_strTargetGuid
- The identifier of the link target.
-
unregisterTarget
Unregister the link target for the given application.Call this method whenever an application is deleted.
- Parameters:
p_strAppGuid
- The GUID of the application.
-
getTarget
Get the registered target GUID for an application.- Parameters:
p_strAppGuid
- The application GUID.- Returns:
- The registered target identifier.
-
deleteMessage
Delete the specified message.- Parameters:
p_strMessageId
- The GUID of the message that should be deleted.- Returns:
true
if the message could be deleted,false
otherwise.- Throws:
IllegalArgumentException
- If the given message ID is not a GUID.
-
deleteMessagesForApplication
Delete all messages that belong to the specified application GUID.- Parameters:
p_strAppGuid
- The application GUID for which the messages should be deleted.- Returns:
true
if the the messages could be deleted,false
otherwise.
-
deleteMessagesForUser
Delete all messages that are addressed to the specified user.- Parameters:
p_strUserId
- The GUID of the user for whom the messages should be deleted.- Returns:
true
if the the messages could be deleted,false
otherwise.- Throws:
IllegalArgumentException
- If the given user ID is not a GUID.
-
sort
Sort the messages in the filtered messages collection.- Parameters:
p_order
- The sorting criterion.
-
filter
Filter the messages that have already being loaded.- Parameters:
p_filter
- The filter criterion.- Returns:
- The number of messages in the filtered collection,
i.e. the value of
size()
.
-
size
public int size()Get the number of messages in the filtered collection.- Returns:
- The number of messages in the filtered collection.
-
get
Get the message at the specified index out of the filtered collection.- Parameters:
p_iIndex
- The index of the message.- Returns:
- The message with the specified index or
null
if there are no filtered messages available or an error occurred.
-
getRichSiteSummary
public void getRichSiteSummary(Writer p_writer, String p_strResourceUrl, String p_strEncodingDecl, int p_iMaxCount) Create a Rich Site Summary containing all news for which the anonymous user is a recipient.Calling this method does not affect the internal state of this object.
- Parameters:
p_writer
- The stream where to write the data to.p_strResourceUrl
- The URL for this resource (rdf:about
).p_strEncodingDecl
- The encoding declaration to be used in the XML text declaration.p_iMaxCount
- The maximum number of news to be contained in the summary.-1
indicates that this count is unlimited.
-
dump
Dump this object to aString
.Note: This method is provided for debugging purposes only.
-