CB-1478 User parameters API

This commit is contained in:
Serge Rider
2021-12-20 17:57:23 +03:00
parent 316dcfb5bd
commit bce54853bb
4 changed files with 40 additions and 1 deletions
@@ -98,6 +98,9 @@ type UserInfo {
# User profile properties map
metaParameters: Object!
# USer configuiraiton parameters
configurationParameters: Object!
}
extend type Query {
@@ -121,3 +124,10 @@ extend type Query {
listUserProfileProperties: [ObjectPropertyInfo!]!
}
extend type Mutation {
# Set user config parameter. If parameter value is null then removes the parameter
setUserConfigurationParameter(name: String!, value: Object): Boolean!
}
@@ -59,4 +59,11 @@ public interface DBWServiceAuth extends DBWService {
@WebAction()
WebPropertyInfo[] listUserProfileProperties(@NotNull WebSession webSession);
@WebAction()
boolean setUserConfigurationParameter(
@NotNull WebSession webSession,
@NotNull String name,
@Nullable String value) throws DBWebException;
}
@@ -69,7 +69,7 @@ public class WebUserInfo {
linkedProviders = CBApplication.getInstance().getSecurityController()
.getUserLinkedProviders(session.getUser().getUserId());
} catch (DBCException e) {
throw new DBWebException("Error reading user linked providers");
throw new DBWebException("Error reading user linked providers", e);
}
}
return Arrays.asList(linkedProviders);
@@ -80,4 +80,13 @@ public class WebUserInfo {
return user.getMetaParameters();
}
@Property
public Map<String, Object> getConfigurationParameters() throws DBWebException {
try {
return CBApplication.getInstance().getSecurityController().getUserParameters(user.getUserId());
} catch (DBCException e) {
throw new DBWebException("Error reading user parameters", e);
}
}
}
@@ -318,4 +318,17 @@ public class WebServiceAuthImpl implements DBWServiceAuth {
.toArray(WebPropertyInfo[]::new);
}
@Override
public boolean setUserConfigurationParameter(@NotNull WebSession webSession, @NotNull String name, @Nullable String value) throws DBWebException {
try {
CBApplication.getInstance().getSecurityController().setUserParameter(
webSession.getUser().getUserId(),
name,
value);
return true;
} catch (DBCException e) {
throw new DBWebException("Error setting user parameter", e);
}
}
}