Foren

Expiration date for messages (message board)

Tor-Einar Jarnbjo, geändert vor 11 Jahren.

Expiration date for messages (message board)

New Member Beitrag: 1 Beitrittsdatum: 04.05.12 Neueste Beiträge
Am I just missing something obvious, or is there no reasonable or halfway feasible way to add an expiration date to messages in Liferay's message board?

The first problem is how to enter the expiration date in the message editor. The most obvious solution is perhaps an expando attribute, but there seem to be no expando data type for dates (only date & time) and I find no way to set a calculated default value in the expando attribute (e.g. today + 6 months). Even without a default value, a date+time attribute defaults to Jan 1st 1970, 0:00GMT and using the date picker to enter a real expiration date is rather tedious. After entering the expiration date, there is no obvious way to validate it (e.g. restrict it to dates between today and today + 6 months) and when the date is displayed in the message view, the current locale is not used to format the date and time.

Even if I would somehow manage to squeeze the expiration date into an expando attribute, there is further no obvious way to evaluate the expiration date.

It would have been acceptable that the messages are still persisted, but not counted and shown in the MB portlet. The methods in MBThreadServiceUtil to access the messages does however not offer any additional filtering criterias, so I either have to load all messages and do the count/filter operations in Java code (hardly a very clever solution) or I would have to rewrite the entire service stack "bottom-up" and add get or search methods, which are able to forward the filtering to the database.

The preferred solution would be to have a scheduled task, which regularly deletes expired messages completely. Since the MB portlet is supporting scopes (the messages are related to the portlet's scope) and the scheduled task is not run within a portlet context, I would have to get access to the scope id somehow. If I understand the documentation and available discussions on this topic, the default scope should be the community, to which the page belongs. Our "message board page" is on the other hand added on the organization level, and the messages' scope id does not match either the organization id, nor any of the ids of the communities in the organization. Anyone with an idea on how to determine the scope id in this case?
thumbnail
Amos Fong, geändert vor 11 Jahren.

RE: Expiration date for messages (message board)

Liferay Legend Beiträge: 2047 Beitrittsdatum: 07.10.08 Neueste Beiträge
If I understand the documentation and available discussions on this topic, the default scope should be the community, to which the page belongs. Our "message board page" is on the other hand added on the organization level, and the messages' scope id does not match either the organization id, nor any of the ids of the communities in the organization. Anyone with an idea on how to determine the scope id in this case?


Your understanding is correct. To get the scopeGroupId of the organization, you should get the organization's Group's Id. (ie organization.getGroup().getGroupId()).

Don't think you can do this straight OOTB, this will take some customizing to do what you want. I would create jsp hook, that would calculate a default expiration date (probably through javascript). For validation, you'll need to override either the MBMessageLocalServiceImpl or the EditMessageAction struts action and check it there.

For searching, this field should be indexed by Lucene so you should be able to create a lucene query that will give you the range you need.