Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Nick Lindberg
Retroactively Hacking "Create Date" to add "Old" News?
May 2, 2012 1:00 PM
Answer

Nick Lindberg

Rank: Junior Member

Posts: 28

Join Date: January 5, 2012

Recent Posts

Hello,

I'm on the final stages of migrating our old website to Liferay, and I'm stuck trying to figure out the best way to add "old" News. I've got asset publishers setup for adding News, and one setup to dynamically display the latest 5-10 news blurbs I create based off a "News" tag, and that works great.

What I need to know how to do now is create like 15 new entries, but edit their "create date" attribute so that it looks like they were created when they SHOULD have been, be it in February or January, and so they show up properly in my asset publisher. I don't want them all to show up as being added today.

Is there an easy way to do this? Will it involve hacking the SQL, or can it be done though the control panel? If so, I haven't been able to find it and any help would be greatly appreciated.

I understand that it's not in Liferay's best interest to make this type of modification too easy, as it would potentially break lots of stuff-- but I have to believe it's not impossible to do!

Thanks everybody.

Nick
Hitoshi Ozawa
RE: Retroactively Hacking "Create Date" to add "Old" News?
May 2, 2012 9:34 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 8000

Join Date: March 23, 2010

Recent Posts

Do you mean to modify the "createDate" in "announcementsentry" table?
Nick Lindberg
RE: Retroactively Hacking "Create Date" to add "Old" News?
May 3, 2012 7:25 AM
Answer

Nick Lindberg

Rank: Junior Member

Posts: 28

Join Date: January 5, 2012

Recent Posts

Hitoshi Ozawa:
Do you mean to modify the "createDate" in "announcementsentry" table?


Here's an example. I "Add new" on my asset publisher-- lets say I add web content. I write it up, title, abstract, etc. Publish. It shows "create date" metadata as today, May 3rd.

Now I want to be able to modify that so that the create date says, say, February 3rd-- and shows up as such from within Liferay. If that is what you refer to by createDate from within the announcementsentry table, then yes-- except that I'm not creating announcements, but straight up pieces of web content.

Is there something similar for web content in the database? I could find the particular item I'm looking for by ID, I'm guessing, but I'm not sure what to modify or if that will break anything.
Hitoshi Ozawa
RE: Retroactively Hacking "Create Date" to add "Old" News?
May 3, 2012 8:52 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 8000

Join Date: March 23, 2010

Recent Posts

Web content used to called "journals" so in the database, entries are in the "journalarticle" table. There's also a "journalfeed" table which is used to create rss feeds.

Seems better to write a program to call liferay's api rather than directly modifying the database. Unfortunately, I don't see any createDate in the API.

http://docs.liferay.com/portal/6.1/javadocs-all/com/liferay/portlet/journal/service/JournalArticleLocalServiceUtil.html
Nick Lindberg
RE: Retroactively Hacking "Create Date" to add "Old" News?
May 3, 2012 9:23 AM
Answer

Nick Lindberg

Rank: Junior Member

Posts: 28

Join Date: January 5, 2012

Recent Posts

What about this:

static JournalArticle

updateArticle(long userId, long groupId, String articleId, double version, Map<Locale,String> titleMap, Map<Locale,String> descriptionMap, String content, String type, String structureId, String templateId, String layoutUuid, int displayDateMonth, int displayDateDay, int displayDateYear, int displayDateHour, int displayDateMinute, int expirationDateMonth, int expirationDateDay, int expirationDateYear, int expirationDateHour, int expirationDateMinute, boolean neverExpire, int reviewDateMonth, int reviewDateDay, int reviewDateYear, int reviewDateHour, int reviewDateMinute, boolean neverReview, boolean indexable, boolean smallImage, String smallImageURL, File smallImageFile, Map<String,byte[]> images, String articleURL, ServiceContext serviceContext)

What do you think of those "*Date*" parameters?

So you're saying I could write a Java application to query/modify this based on the article ID?
Hitoshi Ozawa
RE: Retroactively Hacking "Create Date" to add "Old" News?
May 3, 2012 9:47 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 8000

Join Date: March 23, 2010

Recent Posts

Those date parameters are scheduling dates you can set on the web content.
The displaydate is the date/time to start displaying the web content. terminationdate is the date/time to stop displaying.

If you look at the journalarcticle table, you'll see there is a separate createdate.
Nick Lindberg
RE: Retroactively Hacking "Create Date" to add "Old" News?
May 8, 2012 10:00 AM
Answer

Nick Lindberg

Rank: Junior Member

Posts: 28

Join Date: January 5, 2012

Recent Posts

So--

I was able to find the article in the mysql database. I did a select based on the ArticleID in the JournalArticle table, just as you said, and then I modified the createDate attribute:

UPDATE JournalArticle SET createDate='2012-03-08 15:17:12' WHERE ArticleID=16332;

and I did a SELECT and showed that the date indeed was changed. However, when I refresh the website, it doesn't change the createDate for my article. I even did a

flush tables;

but it still doesn't do anything. Is there something that I either need to change or modify in another table besides this one to get my changes to take effect? I even tried restarting the Liferay server to see if that would clear the cache but it still was reading and displaying the wrong Create Date.
Hitoshi Ozawa
RE: Retroactively Hacking "Create Date" to add "Old" News?
May 8, 2012 3:21 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 8000

Join Date: March 23, 2010

Recent Posts

Liferay caches data and uses that instead of going to the database everytime. Restarting your liferay will force liferay to get the data from the database.
Nick Lindberg
RE: Retroactively Hacking "Create Date" to add "Old" News?
May 9, 2012 6:53 AM
Answer

Nick Lindberg

Rank: Junior Member

Posts: 28

Join Date: January 5, 2012

Recent Posts

Hitoshi Ozawa:
Liferay caches data and uses that instead of going to the database everytime. Restarting your liferay will force liferay to get the data from the database.


That hasn't worked actually.
Hitoshi Ozawa
RE: Retroactively Hacking "Create Date" to add "Old" News?
May 9, 2012 6:59 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 8000

Join Date: March 23, 2010

Recent Posts

It's the "create date" in the Asset Publisher portlet right?
Nick Lindberg
RE: Retroactively Hacking "Create Date" to add "Old" News?
May 9, 2012 8:10 AM
Answer

Nick Lindberg

Rank: Junior Member

Posts: 28

Join Date: January 5, 2012

Recent Posts

Hitoshi Ozawa:
It's the "create date" in the Asset Publisher portlet right?



No-- it's still the original of 05-08-2012.
Nick Lindberg
RE: Retroactively Hacking "Create Date" to add "Old" News?
May 9, 2012 1:10 PM
Answer

Nick Lindberg

Rank: Junior Member

Posts: 28

Join Date: January 5, 2012

Recent Posts

Nick Lindberg:
Hitoshi Ozawa:
It's the "create date" in the Asset Publisher portlet right?



No-- it's still the original of 05-08-2012.


Solved. Had to change the entry in two tables.

http://www.liferay.com/community/forums/-/message_boards/message/13860251

http://www.liferay.com/community/wiki/-/wiki/Main/Changing+the+metadata+%28like+createDate%29%20fields+on+Asset+Publisher+Web+Content