use of org.openremote.model.http.RequestParams in project openremote by openremote.
the class RulesResourceImpl method getTenantRulesets.
@Override
public TenantRuleset[] getTenantRulesets(@BeanParam RequestParams requestParams, String realm, List<Ruleset.Lang> languages, boolean fullyPopulate) {
if (isAuthenticated() && !isRealmAccessibleByUser(realm)) {
throw new WebApplicationException(Response.Status.FORBIDDEN);
}
boolean publicOnly = !isAuthenticated() || isRestrictedUser() | !hasResourceRole(ClientRole.READ_RULES.getValue(), Constants.KEYCLOAK_CLIENT_ID);
List<TenantRuleset> result = rulesetStorageService.findAll(TenantRuleset.class, new RulesetQuery().setRealm(realm).setLanguages(languages.toArray(new Ruleset.Lang[0])).setFullyPopulate(fullyPopulate).setPublicOnly(publicOnly));
// Try and retrieve transient status and error data
result.forEach(ruleset -> rulesService.getRulesetDeployment(ruleset.getId()).ifPresent(rulesetDeployment -> {
ruleset.setStatus(rulesetDeployment.getStatus());
ruleset.setError(rulesetDeployment.getErrorMessage());
}));
return result.toArray(new TenantRuleset[0]);
}
use of org.openremote.model.http.RequestParams in project openremote by openremote.
the class RulesResourceImpl method getGlobalRulesets.
@Override
public GlobalRuleset[] getGlobalRulesets(@BeanParam RequestParams requestParams, List<Ruleset.Lang> languages, boolean fullyPopulate) {
if (!isSuperUser()) {
throw new WebApplicationException(Response.Status.FORBIDDEN);
}
List<GlobalRuleset> result = rulesetStorageService.findAll(GlobalRuleset.class, new RulesetQuery().setLanguages(languages.toArray(new Ruleset.Lang[0])).setFullyPopulate(fullyPopulate));
// Try and retrieve transient status and error data
result.forEach(ruleset -> rulesService.getRulesetDeployment(ruleset.getId()).ifPresent(rulesetDeployment -> {
ruleset.setStatus(rulesetDeployment.getStatus());
ruleset.setError(rulesetDeployment.getErrorMessage());
}));
return result.toArray(new GlobalRuleset[0]);
}
Aggregations