-
-
Notifications
You must be signed in to change notification settings - Fork 996
SAK-52031 EntityBroker Remove reflectutils library from codebase #14139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 31 commits
28904f6
71025bc
20a522b
dc3b23e
0e26aa2
e1d41aa
480acb1
f36f6ce
731adf3
7c53022
98c6b00
c53de58
f3ea268
98b185f
63d4cbf
13bc2f9
fcf954b
e133972
2cf0102
3f63c68
b279107
6833bab
3c895cc
e979696
a9fb337
2c4b02b
4ee27eb
6ab431c
7203edb
7edc4d3
c35d17a
de98b57
bd35301
eeb0799
dcafc65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| */ | ||
| package org.sakaiproject.entitybroker.providers; | ||
|
|
||
| import java.lang.reflect.Field; | ||
| import java.util.ArrayList; | ||
| import java.util.Arrays; | ||
| import java.util.Collection; | ||
|
|
@@ -24,9 +25,6 @@ | |
| import lombok.Setter; | ||
| import lombok.extern.slf4j.Slf4j; | ||
|
|
||
| import org.azeckoski.reflectutils.FieldUtils; | ||
| import org.azeckoski.reflectutils.ReflectUtils; | ||
|
|
||
| import org.sakaiproject.component.api.ServerConfigurationService; | ||
| import org.sakaiproject.entity.api.ResourcePropertiesEdit; | ||
| import org.sakaiproject.entitybroker.DeveloperHelperService; | ||
|
|
@@ -52,6 +50,7 @@ | |
| import org.sakaiproject.user.api.UserLockedException; | ||
| import org.sakaiproject.user.api.UserNotDefinedException; | ||
| import org.sakaiproject.user.api.UserPermissionException; | ||
| import org.springframework.util.ReflectionUtils; | ||
|
|
||
| /** | ||
| * Entity Provider for users | ||
|
|
@@ -383,16 +382,16 @@ private boolean isUsingSameIdEid() { | |
| String config = developerHelperService.getConfigurationSetting("[email protected]", (String)null); | ||
| if (config != null) { | ||
| try { | ||
| usesSeparateIdEid = ReflectUtils.getInstance().convert(config, Boolean.class); | ||
| } catch (UnsupportedOperationException e) { | ||
| usesSeparateIdEid = parseBoolean(config); | ||
| } catch (IllegalArgumentException e) { | ||
| // oh well | ||
| usesSeparateIdEid = null; | ||
| } | ||
| } | ||
| if (usesSeparateIdEid == null) { | ||
| // could not get the stupid setting so attempt to check the service itself | ||
| try { | ||
| usesSeparateIdEid = FieldUtils.getInstance().getFieldValue(userDirectoryService, "m_separateIdEid", Boolean.class); | ||
| usesSeparateIdEid = readBooleanField(userDirectoryService, "m_separateIdEid"); | ||
| } catch (RuntimeException e) { | ||
| // no luck here | ||
| usesSeparateIdEid = null; | ||
|
|
@@ -403,6 +402,43 @@ private boolean isUsingSameIdEid() { | |
| return ! usesSeparateIdEid.booleanValue(); | ||
| } | ||
|
|
||
| private Boolean readBooleanField(Object target, String fieldName) { | ||
| Field field = ReflectionUtils.findField(target.getClass(), fieldName); | ||
| if (field == null) { | ||
| return null; | ||
| } | ||
| ReflectionUtils.makeAccessible(field); | ||
| try { | ||
| Object value = ReflectionUtils.getField(field, target); | ||
| if (value instanceof Boolean) { | ||
| return (Boolean) value; | ||
| } | ||
| if (value instanceof String) { | ||
| return parseBoolean((String) value); | ||
| } | ||
| return (value != null) ? Boolean.valueOf(value.toString()) : null; | ||
| } catch (IllegalArgumentException e) { | ||
| return null; | ||
| } | ||
| } | ||
|
||
|
|
||
| private Boolean parseBoolean(String value) { | ||
| if (value == null) { | ||
| return null; | ||
| } | ||
| String normalized = value.trim(); | ||
| if (normalized.isEmpty()) { | ||
| return null; | ||
| } | ||
| if ("true".equalsIgnoreCase(normalized)) { | ||
| return Boolean.TRUE; | ||
| } | ||
| if ("false".equalsIgnoreCase(normalized)) { | ||
| return Boolean.FALSE; | ||
| } | ||
| throw new IllegalArgumentException("Value is not a boolean: " + value); | ||
| } | ||
|
|
||
| /** | ||
| * Will check that a userId/eid is valid and will produce a valid userId from the check | ||
| * | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.