Erudika / scoold

A Stack Overflow clone for teams (self-hosted or hosted)
https://scoold.com
Apache License 2.0
865 stars 238 forks source link

java.lang.UnsupportedOperationException: Not implemented. #37

Closed showaid closed 6 years ago

showaid commented 6 years ago

Hello @albogdano,

I hope you have a good day.

Today, I got an exception when I tried to remove an user forcefully. It's UnsupportedOperationException:

...
Caused by: java.lang.UnsupportedOperationException: Not implemented.
    at com.erudika.para.search.MockSearch.findTerms(MockSearch.java:190)
    at com.erudika.para.core.User.getIdentifiers(User.java:365)
    at com.erudika.para.core.User.delete(User.java:354)
        at com.erudika.scoold.controllers.AdminController.forceDelete(AdminController.java:127)

...

I don't exactly know why, but scoold tries to use MockSearch. It should've been LuceneSearch, right?

The para system generated a log message that it uses LuceneSearch instance.

2018-03-07 11:56:47 [INFO ] Loaded new DAO, Search and Cache implementations - AWSDynamoDAO, LuceneSearch and CaffeineCache.

Could you take a look at this?

Thank you!

FYI. The scoold version I tested is the most recent commit.

showaid commented 6 years ago

I found out that para client is required to delete sobject instead of using it directly(sobject.delete()).

public String forceDelete(@RequestParam Boolean confirmdelete, @RequestParam String id, HttpServletRequest req) {
    Profile authUser = utils.getAuthUser(req);
    if (confirmdelete && utils.isAdmin(authUser)) {
        ParaObject sobject = pc.read(id);
        if (sobject != null) {
            sobject.delete();
            logger.info("{} #{} deleted {} #{}", authUser.getName(), authUser.getId(),
                        sobject.getClass().getName(), sobject.getId());
        }
    }
    return "redirect:" + ADMINLINK;
}

I changed the code from sobject.delete() to pc.delete(sobject). And the user profile shows that it is deleted user after the deletion.

screenshot - 2018-03-07 2_11_05

However, the user can sign in again and it creates another user account which is using the same id.

screenshot - 2018-03-07 2_16_26

My environment is using an AD server to authenticate. And maybe that's the reason why. Please take a look at this.

Thank you!

albogdano commented 6 years ago

Thanks for reporting this, I fixed the bug in AdminController, but I'm not sure why you have 3 users with the same id. Your cache might need to be cleared.