Custom Tenant configuration. (#395)

* Tenant configuration configurable.
Signed-off-by: kaizimmerm <kai.zimmermann@bosch-si.com>
This commit is contained in:
Kai Zimmermann
2016-12-23 07:19:46 +01:00
committed by GitHub
parent 4d35413f71
commit feb3369858
53 changed files with 730 additions and 447 deletions

View File

@@ -29,7 +29,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetInfo;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
import org.hibernate.validator.constraints.NotEmpty;
import org.springframework.security.access.prepost.PreAuthorize;

View File

@@ -643,5 +643,4 @@ public interface TargetManagement {
@PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET + SpringEvalExpressions.HAS_AUTH_OR
+ SpringEvalExpressions.IS_CONTROLLER)
Target updateTarget(TargetUpdate update);
}

View File

@@ -13,7 +13,7 @@ import java.io.Serializable;
import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions;
import org.eclipse.hawkbit.repository.model.TenantConfiguration;
import org.eclipse.hawkbit.repository.model.TenantConfigurationValue;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationProperties.TenantConfigurationKey;
import org.eclipse.hawkbit.tenancy.configuration.validator.TenantConfigurationValidatorException;
import org.springframework.core.convert.ConversionFailedException;
import org.springframework.core.env.Environment;
@@ -29,7 +29,7 @@ public interface TenantConfigurationManagement {
* Adds or updates a specific configuration for a specific tenant.
*
*
* @param configurationKey
* @param configurationKeyName
* the key of the configuration
* @param value
* the configuration value which will be written into the
@@ -42,8 +42,7 @@ public interface TenantConfigurationManagement {
* if the property cannot be converted to the given
*/
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION)
<T extends Serializable> TenantConfigurationValue<T> addOrUpdateConfiguration(
TenantConfigurationKey configurationKey, T value);
<T extends Serializable> TenantConfigurationValue<T> addOrUpdateConfiguration(String configurationKeyName, T value);
/**
* Build the tenant configuration by the given key
@@ -69,14 +68,14 @@ public interface TenantConfigurationManagement {
* the configuration key to be deleted
*/
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION)
void deleteConfiguration(TenantConfigurationKey configurationKey);
void deleteConfiguration(String configurationKey);
/**
* Retrieves a configuration value from the e.g. tenant overwritten
* configuration values or in case the tenant does not a have a specific
* configuration the global default value hold in the {@link Environment}.
*
* @param configurationKey
* @param configurationKeyName
* the key of the configuration
* @return the converted configuration value either from the tenant specific
* configuration stored or from the fall back default values or
@@ -90,7 +89,7 @@ public interface TenantConfigurationManagement {
* {@code propertyType}
*/
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION)
<T extends Serializable> TenantConfigurationValue<T> getConfigurationValue(TenantConfigurationKey configurationKey);
<T extends Serializable> TenantConfigurationValue<T> getConfigurationValue(String configurationKeyName);
/**
* Retrieves a configuration value from the e.g. tenant overwritten
@@ -99,7 +98,7 @@ public interface TenantConfigurationManagement {
*
* @param <T>
* the type of the configuration value
* @param configurationKey
* @param configurationKeyName
* the key of the configuration
* @param propertyType
* the type of the configuration value, e.g. {@code String.class}
@@ -116,7 +115,7 @@ public interface TenantConfigurationManagement {
* {@code propertyType}
*/
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION)
<T extends Serializable> TenantConfigurationValue<T> getConfigurationValue(TenantConfigurationKey configurationKey,
<T extends Serializable> TenantConfigurationValue<T> getConfigurationValue(String configurationKeyName,
Class<T> propertyType);
/**
@@ -125,7 +124,7 @@ public interface TenantConfigurationManagement {
*
* @param <T>
* the type of the configuration value
* @param configurationKey
* @param configurationKeyName
* the key of the configuration
* @param propertyType
* the type of the configuration value, e.g. {@code String.class}
@@ -140,5 +139,5 @@ public interface TenantConfigurationManagement {
* {@code propertyType}
*/
@PreAuthorize(value = SpringEvalExpressions.HAS_AUTH_TENANT_CONFIGURATION)
<T> T getGlobalConfigurationValue(TenantConfigurationKey configurationKey, Class<T> propertyType);
<T> T getGlobalConfigurationValue(String configurationKeyName, Class<T> propertyType);
}

View File

@@ -0,0 +1,42 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.repository.event.remote;
import org.eclipse.hawkbit.repository.model.Target;
/**
* Event is send in case a target polls either through DDI or DMF.
*/
public class TargetPollEvent extends RemoteTenantAwareEvent {
private static final long serialVersionUID = 1L;
private String controllerId;
private String targetAdress;
/**
* Default constructor.
*/
public TargetPollEvent() {
// for serialization libs like jackson
}
public TargetPollEvent(final Target target, final String applicationId) {
super(target.getControllerId(), target.getTenant(), applicationId);
this.controllerId = target.getControllerId();
this.targetAdress = target.getTargetInfo().getAddress().toString();
}
public String getControllerId() {
return controllerId;
}
public String getTargetAdress() {
return targetAdress;
}
}