Fix document tenant configuration api (#567)

* Added link to system docu
* Rename feign client to MgmtTenantManagementClient

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
Jonathan Knoblauch
2017-08-15 08:17:56 +02:00
committed by Michael Hirsch
parent 4fab134168
commit 4f79b8ba47
5 changed files with 45 additions and 91 deletions

View File

@@ -24,9 +24,9 @@ import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.T
* A mapper which maps repository model to RESTful model representation and
* back.
*/
public final class MgmtSystemMapper {
public final class MgmtTenantManagementMapper {
private MgmtSystemMapper() {
private MgmtTenantManagementMapper() {
// Utility class
}
@@ -50,7 +50,8 @@ public final class MgmtSystemMapper {
restConfValue.setLastModifiedAt(repoConfValue.getLastModifiedAt());
restConfValue.setLastModifiedBy(repoConfValue.getLastModifiedBy());
restConfValue.add(linkTo(methodOn(MgmtSystemResource.class).getConfigurationValue(key)).withSelfRel());
restConfValue.add(
linkTo(methodOn(MgmtTenantManagementResource.class).getTenantConfigurationValue(key)).withSelfRel());
return restConfValue;
}

View File

@@ -8,22 +8,18 @@
*/
package org.eclipse.hawkbit.mgmt.rest.resource;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo;
import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn;
import java.io.Serializable;
import java.util.Map;
import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValue;
import org.eclipse.hawkbit.mgmt.json.model.system.MgmtSystemTenantConfigurationValueRequest;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtSystemRestApi;
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTenantManagementRestApi;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.hateoas.ResourceSupport;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
@@ -31,51 +27,31 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
/**
* REST Resource handling tenant specific configuration operations.
* REST Resource for handling tenant specific configuration operations.
*/
@RestController
public class MgmtSystemResource implements MgmtSystemRestApi {
public class MgmtTenantManagementResource implements MgmtTenantManagementRestApi {
private static final Logger LOG = LoggerFactory.getLogger(MgmtSystemResource.class);
private static final Logger LOG = LoggerFactory.getLogger(MgmtTenantManagementResource.class);
private final TenantConfigurationManagement tenantConfigurationManagement;
private final TenantConfigurationProperties tenantConfigurationProperties;
@Autowired
MgmtSystemResource(final TenantConfigurationManagement tenantConfigurationManagement,
MgmtTenantManagementResource(final TenantConfigurationManagement tenantConfigurationManagement,
final TenantConfigurationProperties tenantConfigurationProperties) {
this.tenantConfigurationManagement = tenantConfigurationManagement;
this.tenantConfigurationProperties = tenantConfigurationProperties;
}
@Override
public ResponseEntity<ResourceSupport> getSystem() {
final ResourceSupport resourceSupport = new ResourceSupport();
resourceSupport.add(linkTo(methodOn(MgmtSystemResource.class).getSystemConfiguration()).withRel("configs"));
return ResponseEntity.ok(resourceSupport);
public ResponseEntity<Map<String, MgmtSystemTenantConfigurationValue>> getTenantConfiguration() {
return ResponseEntity.ok(
MgmtTenantManagementMapper.toResponse(tenantConfigurationManagement, tenantConfigurationProperties));
}
/**
* @return a Map of all configuration values.
*/
@Override
public ResponseEntity<Map<String, MgmtSystemTenantConfigurationValue>> getSystemConfiguration() {
return ResponseEntity
.ok(MgmtSystemMapper.toResponse(tenantConfigurationManagement, tenantConfigurationProperties));
}
/**
* Handles the DELETE request of deleting a tenant specific configuration
* value within SP.
*
* @param keyName
* the Name of the configuration key
* @return If the given configuration value exists and could be deleted Http
* OK. In any failure the JsonResponseExceptionHandler is handling
* the response.
*/
@Override
public ResponseEntity<Void> deleteConfigurationValue(@PathVariable("keyName") final String keyName) {
public ResponseEntity<Void> deleteTenantConfigurationValue(@PathVariable("keyName") final String keyName) {
tenantConfigurationManagement.deleteConfiguration(keyName);
@@ -83,45 +59,23 @@ public class MgmtSystemResource implements MgmtSystemRestApi {
return ResponseEntity.ok().build();
}
/**
* Handles the GET request of deleting a tenant specific configuration value
* within SP.
*
* @param keyName
* the Name of the configuration key
* @return If the given configuration value exists and could be get Http OK.
* In any failure the JsonResponseExceptionHandler is handling the
* response.
*/
@Override
public ResponseEntity<MgmtSystemTenantConfigurationValue> getConfigurationValue(
public ResponseEntity<MgmtSystemTenantConfigurationValue> getTenantConfigurationValue(
@PathVariable("keyName") final String keyName) {
LOG.debug("{} config value getted, return status {}", keyName, HttpStatus.OK);
return ResponseEntity
.ok(MgmtSystemMapper.toResponse(keyName, tenantConfigurationManagement.getConfigurationValue(keyName)));
return ResponseEntity.ok(MgmtTenantManagementMapper.toResponse(keyName,
tenantConfigurationManagement.getConfigurationValue(keyName)));
}
/**
* Handles the GET request of deleting a tenant specific configuration value
* within SP.
*
* @param keyName
* the Name of the configuration key
* @param configurationValueRest
* the new value for the configuration
* @return If the given configuration value exists and could be get Http OK.
* In any failure the JsonResponseExceptionHandler is handling the
* response.
*/
@Override
public ResponseEntity<MgmtSystemTenantConfigurationValue> updateConfigurationValue(
public ResponseEntity<MgmtSystemTenantConfigurationValue> updateTenantConfigurationValue(
@PathVariable("keyName") final String keyName,
@RequestBody final MgmtSystemTenantConfigurationValueRequest configurationValueRest) {
final TenantConfigurationValue<? extends Serializable> updatedValue = tenantConfigurationManagement
.addOrUpdateConfiguration(keyName, configurationValueRest.getValue());
return ResponseEntity.ok(MgmtSystemMapper.toResponse(keyName, updatedValue));
return ResponseEntity.ok(MgmtTenantManagementMapper.toResponse(keyName, updatedValue));
}
}