/** * Derived classes can override createRole() to return an extended ORole implementation. */ protected ORole createRole(final ODocument roleDoc) { ORole role = null; // If databaseName is set, then only allow roles with the same databaseName. if (databaseName != null && !databaseName.isEmpty()) { if (roleDoc != null && roleDoc.containsField(OSystemRole.DB_FILTER) && roleDoc.fieldType(OSystemRole.DB_FILTER) == OType.EMBEDDEDLIST) { List<String> dbNames = roleDoc.field(OSystemRole.DB_FILTER, OType.EMBEDDEDLIST); for (String dbName : dbNames) { if (dbName != null && !dbName.isEmpty() && (dbName.equalsIgnoreCase(databaseName) || dbName.equals("*"))) { role = new OSystemRole(roleDoc); break; } } } } // If databaseName is not set, only return roles without a OSystemRole.DB_FILTER property. else { if (roleDoc != null && !roleDoc.containsField(OSystemRole.DB_FILTER)) { role = new OSystemRole(roleDoc); } } return role; } }