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 NewsAgentcreateInstance(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.booleandeleteMessage(String p_strMessageId) Delete the specified message.booleandeleteMessagesForApplication(String p_strAppGuid) Delete all messages that belong to the specified application GUID.booleandeleteMessagesForUser(String p_strUserId) Delete all messages that are addressed to the specified user.voiddone()Deprecated.This method must not be called anymore.dump()Dump this object to aString.intFilter the messages that have already being loaded.get(int p_iIndex) Get the message at the specified index out of the filtered collection.voidgetRichSiteSummary(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.intLoad messages from the database.loadMessage(String p_strMessageId) Load the specified message from the database.voidmarkDeleted(String p_strMessageId, String p_strUserId) Mark a message as deleted for the specified user.voidMark a message as read for the specified user.booleanregisterTarget(String p_strAppGuid, String p_strTargetGuid) Register or re-register a link target for an application.booleanSave the message to the database.intsize()Get the number of messages in the filtered collection.voidSort the messages in the filtered messages collection.voidunregisterTarget(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-1if 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
nullif 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:
trueif the message was saved,falseotherwise.
-
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:
trueif the message could be deleted,falseotherwise.- 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:
trueif the the messages could be deleted,falseotherwise.
-
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:
trueif the the messages could be deleted,falseotherwise.- 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
nullif 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.-1indicates that this count is unlimited.
-
dump
Dump this object to aString.Note: This method is provided for debugging purposes only.
-