This issue can't be edited

Because it belongs to an archived project. Jira admins can restore projects from the archive.

Refactor MongoDBDatastoreProvider#extractDatabase

Description

The current code is misleading and in some respect plain wrong. Here is the existing code:

The idea is to check whether the specified database exists (using getDatabaseNames) and then depending on config.isCreateDatabase() create it (implicitly, since just calling getDB will create it). This makes really only sense if the database runs in no-auth mode. If the database runs with authentication, the user and database need to exist in the first place, otherwise an authentication error occurs. There is really no point to call getDatabaseNames anymore.
Also the current code does just check the authorization error code (18) and in all other cases assumes that there is a privilege problem. That is not the case and should be explicitly tests (see https://github.com/mongodb/mongo/blob/master/src/mongo/base/error_codes.err). The error code of interest is "Unauthorized", 13.
Last but not least, collectionExists to indirectly check whether the user has read access (which btw I think is a given and if anything we should check for readWrite access). This should be really replaced with something like:

The result contains the permissions of the given user for the specified database.

Environment

None

Activity

Show:

Hardy Ferentschik May 29, 2015 at 7:47 PM

I guess I am also wondering in general about the 'hibernate.ogm.datastore.create_database' option. It seems it is at best useful for testing.

Details

Assignee

Reporter

Bug Testcase Reminder (view)

Bug reports should generally be accompanied by a test case!

Bug Testcase Reminder (edit)

Bug reports should generally be accompanied by a test case!

Participants

Hardy Ferentschik

Components

Priority

Created May 29, 2015 at 7:45 PM
Updated May 29, 2015 at 7:58 PM