Skip to content

Commit

Permalink
Merge branch 'backport-4069' into release-2.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Coduz committed Jul 2, 2024
2 parents 173e176 + 8287ccb commit ee67995
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
*******************************************************************************/
package org.eclipse.kapua.commons.configuration;

import java.util.Map;
import java.util.Optional;

import org.eclipse.kapua.KapuaException;
import org.eclipse.kapua.commons.util.ArgumentValidator;
import org.eclipse.kapua.model.config.metatype.KapuaTocd;
import org.eclipse.kapua.model.domain.Actions;
import org.eclipse.kapua.model.id.KapuaId;
Expand All @@ -22,9 +26,6 @@
import org.eclipse.kapua.service.config.KapuaConfigurableService;
import org.eclipse.kapua.storage.TxManager;

import java.util.Map;
import java.util.Optional;

/**
* Base {@link KapuaConfigurableService} implementation, build upon {@link ServiceConfigurationManager}.
* <p>
Expand Down Expand Up @@ -60,18 +61,27 @@ public KapuaConfigurableServiceBase(

@Override
public boolean isServiceEnabled(KapuaId scopeId) throws KapuaException {
// Argument Validation
ArgumentValidator.notNull(scopeId, "scopeId");

return txManager.execute(tx -> serviceConfigurationManager.isServiceEnabled(tx, scopeId));
}

@Override
public KapuaTocd getConfigMetadata(KapuaId scopeId) throws KapuaException {
// Argument Validation
ArgumentValidator.notNull(scopeId, "scopeId");

// Check access
authorizationService.checkPermission(permissionFactory.newPermission(domain, Actions.read, scopeId));
return txManager.execute(tx -> serviceConfigurationManager.getConfigMetadata(tx, scopeId, true));
}

@Override
public Map<String, Object> getConfigValues(KapuaId scopeId) throws KapuaException {
// Argument Validation
ArgumentValidator.notNull(scopeId, "scopeId");

// Check access
authorizationService.checkPermission(permissionFactory.newPermission(domain, Actions.read, scopeId));

Expand All @@ -80,6 +90,10 @@ public Map<String, Object> getConfigValues(KapuaId scopeId) throws KapuaExceptio

@Override
public void setConfigValues(KapuaId scopeId, KapuaId parentId, Map<String, Object> values) throws KapuaException {
// Argument Validation
ArgumentValidator.notNull(scopeId, "scopeId");
ArgumentValidator.notNull(values, "values");

authorizationService.checkPermission(permissionFactory.newPermission(domain, Actions.write, scopeId));

txManager.<Void>execute(tx -> {
Expand Down

0 comments on commit ee67995

Please sign in to comment.