Foren

Error adding new Blog entries

Irmo Timmann, geändert vor 6 Jahren.

Error adding new Blog entries

New Member Beiträge: 7 Beitrittsdatum: 07.04.17 Neueste Beiträge
Hello,

I have a weird problem with Liferay 7 GA4 when adding new blogs: I use an AssetPublisher for my Blog Entries with ratings and comments enabled and users have view permissions, add discussion permissions etc. I am developing a mobile app which retrieves Liferay data from JSON requests. This works as aspected with regular users being able to retrieve all Blog data using the screens JSON API.

The problem is when I add a new Blog Entry I can retrive the blog data and ratings using the mobile app but not the comments. Even if I login as an administrator and directly call the JSON API "User 0 must have VIEW permission for com.liferay.blogs.kernel.model.BlogsEntry 32598" is being returned. If I visit the Blog Entry from the Asset Publisher with my browser and resend the request afterwards, everything works normal and an empty array is being returned.

Why does this strange behaviour occurs and how can I deal with it? I want the complete BlogEntry to be accessible using JSON directly after creating it as it messes with my custom Liferay Portal Push Module with a Listener calling "onAfterCreate" generating 403 errors for users clicking on the notification.

Any help is much appreciated. Thanks


Edit:
As I was not able to solve this problem and it still persists I opened up an issue: Issue Tracker Liferay
Irmo Timmann, geändert vor 6 Jahren.

RE: Error adding new Blog entries

New Member Beiträge: 7 Beitrittsdatum: 07.04.17 Neueste Beiträge
Anyone knows how to deal with this problem? I was able to replicate this issue on a new and unused liferay 7 ga4 server. Following these steps:

1. Install new liferay7 ga4 bundled with tomcat, set admin and login as admin etc..
2. Add asset publisher to main page, configure to use ratings and comments
3. Add a blog entry with dummy text.
4. Navigate to the JSON api / use curl to get all blog entries.

curl http://localhost:8080/api/jsonws/blogsentry/get-group-entries \
  -u test@liferay.com:test \
  -d groupId=20143 \
  -d status=0 \
  -d max=5


Result:

[
  {
    "allowPingbacks": true,
    "allowTrackbacks": false,
    "companyId": "20116",
    "content": "CONTENT TEST",
    "coverImageCaption": "",
    "coverImageFileEntryId": "0",
    "coverImageURL": "",
    "createDate": 1500032057738,
    "description": "",
    "displayDate": 1500031980000,
    "entryId": "30089",
    "groupId": "20143",
    "lastPublishDate": null,
    "modifiedDate": 1500032058101,
    "smallImage": false,
    "smallImageFileEntryId": "0",
    "smallImageId": "0",
    "smallImageURL": "",
    "status": 0,
    "statusByUserId": "20156",
    "statusByUserName": "Test Test",
    "statusDate": 1500032058101,
    "subtitle": "SUBTITLE",
    "title": "TEST",
    "trackbacks": "",
    "urlTitle": "test",
    "userId": "20156",
    "userName": "Test Test",
    "uuid": "4d2d5db3-9142-82fe-97af-6c0f60fa5b29"
  }
]


5. Call comment managers get-comments with entryId (same problem using the screens plugin API)

curl http://localhost:8080/api/jsonws/comment.commentmanagerjsonws/get-comments \
  -u test@liferay.com:test \
  -d groupId=20143 \
  -d className='com.liferay.blogs.kernel.model.BlogsEntry' \
  -d classPK=30089 \
  -d start=0 \
  -d end=10


6. Error
"User 0 must have VIEW permission for com.liferay.blogs.kernel.model.BlogsEntry 30089"


7. Navigate to asset publisher and click on blog entry "Test"

8. Navigate to JSON Api or curl:

curl http://localhost:8080/api/jsonws/comment.commentmanagerjsonws/get-comments \
  -u test@liferay.com:test \
  -d groupId=20143 \
  -d className='com.liferay.blogs.kernel.model.BlogsEntry' \
  -d classPK=30089 \
  -d start=0 \
  -d end=10


Result:
[]


I assume some permissions aren't correctly set on entry creation. Even the admin is not able to get the comment before navigating to and visiting the entry by hand. For obvious reasons this does not seem to be the expectected or wanted behaviour. I don't know the reason for this behaviour but with liferay 7 GA3 this issued have not been happening to me.
Any hint would help. Thanks.