Remove the controller properties for polling time and overdue time and

use the new tenant configuration management, which handle the tenant
specific polling time.

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-03-14 15:13:51 +01:00
parent 807aaf629c
commit 57c722ea11
3 changed files with 28 additions and 30 deletions

View File

@@ -15,7 +15,6 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import org.eclipse.hawkbit.ControllerPollProperties;
import org.eclipse.hawkbit.artifact.repository.model.DbArtifact;
import org.eclipse.hawkbit.cache.CacheWriteNotify;
import org.eclipse.hawkbit.controller.model.ActionFeedback;
@@ -31,6 +30,7 @@ import org.eclipse.hawkbit.controller.model.Result.FinalResult;
import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.ControllerManagement;
import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.Action;
import org.eclipse.hawkbit.repository.model.Action.Status;
@@ -43,6 +43,7 @@ import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.rest.resource.helper.RestResourceConversionHelper;
import org.eclipse.hawkbit.security.HawkbitSecurityProperties;
import org.eclipse.hawkbit.tenancy.TenantAware;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.util.IpUtil;
import org.hibernate.validator.constraints.NotEmpty;
import org.slf4j.Logger;
@@ -77,8 +78,6 @@ public class RootController {
private static final Logger LOG = LoggerFactory.getLogger(RootController.class);
private static final String GIVEN_ACTION_IS_NOT_ASSIGNED_TO_GIVEN_TARGET = "given action ({}) is not assigned to given target ({}).";
private static final String SP_SERVER_CONFIG_PREFIX = "hawkbit.server.";
@Autowired
private ControllerManagement controllerManagement;
@@ -88,15 +87,15 @@ public class RootController {
@Autowired
private ArtifactManagement artifactManagement;
@Autowired
private ControllerPollProperties controllerPollProperties;
@Autowired
private CacheWriteNotify cacheWriteNotify;
@Autowired
private TenantAware tenantAware;
@Autowired
private TenantConfigurationManagement tenantConfigurationManagement;
@Autowired
private HawkbitSecurityProperties securityProperties;
@@ -154,10 +153,11 @@ public class RootController {
IpUtil.getClientIpFromRequest(request, securityProperties.getClients().getRemoteIpHeader()));
}
return new ResponseEntity<>(
DataConversionHelper.fromTarget(target, controllerManagement.findActionByTargetAndActive(target),
controllerPollProperties.getPollingTime(), tenantAware),
HttpStatus.OK);
final String pollingTime = tenantConfigurationManagement
.getConfigurationValue(TenantConfigurationKey.POLLING_TIME_INTERVAL, String.class).getValue();
return new ResponseEntity<>(DataConversionHelper.fromTarget(target,
controllerManagement.findActionByTargetAndActive(target), pollingTime, tenantAware), HttpStatus.OK);
}
/**

View File

@@ -34,6 +34,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.rest.resource.JsonBuilder;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.util.IpUtil;
import org.junit.Test;
import org.springframework.hateoas.MediaTypes;
@@ -133,6 +134,19 @@ public class RootControllerTest extends AbstractIntegrationTestWithMongoDB {
.andExpect(status().isMethodNotAllowed());
}
@Test
@Description("Ensures that tenant polling time, which is save in the db, exists.")
public void testModifyGloablPollingTime() throws Exception {
tenantConfigurationManagement.addOrUpdateConfiguration(TenantConfigurationKey.POLLING_TIME_INTERVAL,
"00:02:00");
mvc.perform(get("/{tenant}/controller/v1/4711", tenantAware.getCurrentTenant()))
.andDo(MockMvcResultPrinter.print()).andExpect(status().isOk())
.andExpect(content().contentType(MediaTypes.HAL_JSON))
.andExpect(jsonPath("$config.polling.sleep", equalTo("00:02:00")));
}
@Test
@Description("Ensures that etag check results in not modified response if provided etag by client is identical to entity in repository.")
public void rootRsNotModified() throws Exception {