Merge branch 'feature_split_repo_into_api_impl' of https://github.com/bsinno/hawkbit.git into feature_split_repo_into_api_impl

This commit is contained in:
Kai Zimmermann
2016-05-31 12:29:05 +02:00
53 changed files with 293 additions and 134 deletions

View File

@@ -0,0 +1,40 @@
/**
* 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.jpa;
import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Service;
/**
* Defines the interfaces to register the {@link KeyGenerator} as bean which is
* used by spring caching framework to resolve the key-generator. The
* key-generator must registered as bean so spring can resolve the key-generator
* by its name.
*
* When using the {@link Service} annotation e.g. by {@link JpaSystemManagement}
* the bean registration must be declared by the interface due spring registers
* the bean by the implemented interfaces. So introduce a single interface for
* the {@link JpaSystemManagement} implementation to allow it to register the
* key-generator bean.
*
*/
@FunctionalInterface
public interface CurrentTenantCacheKeyGenerator {
/**
* Bean declaration to register a {@code currentTenantKeyGenerator} bean
* which is used by the caching framework.
*
* @return the {@link KeyGenerator} to be used to cache the values of the
* current used tenant in the {@link JpaSystemManagement}
*/
@Bean
KeyGenerator currentTenantKeyGenerator();
}

View File

@@ -19,7 +19,7 @@ import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import javax.validation.constraints.NotNull;
import org.eclipse.hawkbit.repository.Constants;
import org.eclipse.hawkbit.repository.RepositoryConstants;
import org.eclipse.hawkbit.repository.ControllerManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
@@ -216,7 +216,7 @@ public class JpaControllerManagement implements ControllerManagement {
handleFinishedCancelation(actionStatus, action);
break;
case RETRIEVED:
actionStatus.addMessage(Constants.SERVER_MESSAGE_PREFIX + "Cancellation request retrieved.");
actionStatus.addMessage(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Cancellation request retrieved.");
break;
default:
// do nothing
@@ -230,7 +230,7 @@ public class JpaControllerManagement implements ControllerManagement {
private void handleFinishedCancelation(final ActionStatus actionStatus, final JpaAction action) {
// in case of successful cancellation we also report the success at
// the canceled action itself.
actionStatus.addMessage(Constants.SERVER_MESSAGE_PREFIX + "Cancellation completion is finished sucessfully.");
actionStatus.addMessage(RepositoryConstants.SERVER_MESSAGE_PREFIX + "Cancellation completion is finished sucessfully.");
DeploymentHelper.successCancellation(action, actionRepository, targetManagement, targetInfoRepository,
entityManager);
}

View File

@@ -145,7 +145,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
return assignDistributionSetByTargetId((JpaDistributionSet) pset,
targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()),
ActionType.FORCED, org.eclipse.hawkbit.repository.model.Constants.NO_FORCE_TIME);
ActionType.FORCED, org.eclipse.hawkbit.repository.model.RepositoryModelConstants.NO_FORCE_TIME);
}
@@ -155,7 +155,7 @@ public class JpaDeploymentManagement implements DeploymentManagement {
@CacheEvict(value = { "distributionUsageAssigned" }, allEntries = true)
public DistributionSetAssignmentResult assignDistributionSet(final Long dsID, final String... targetIDs) {
return assignDistributionSet(dsID, ActionType.FORCED,
org.eclipse.hawkbit.repository.model.Constants.NO_FORCE_TIME, targetIDs);
org.eclipse.hawkbit.repository.model.RepositoryModelConstants.NO_FORCE_TIME, targetIDs);
}
@Override

View File

@@ -49,7 +49,7 @@ import org.springframework.validation.annotation.Validated;
@Transactional(readOnly = true, isolation = Isolation.READ_UNCOMMITTED)
@Validated
@Service
public class JpaSystemManagement implements SystemManagement {
public class JpaSystemManagement implements CurrentTenantCacheKeyGenerator, SystemManagement {
@Autowired
private EntityManager entityManager;

View File

@@ -97,7 +97,7 @@ public class JpaTenantConfigurationManagement implements EnvironmentAware, Tenan
}
@Override
public TenantConfigurationValue<?> getConfigurationValue(final TenantConfigurationKey configurationKey) {
public <T> TenantConfigurationValue<T> getConfigurationValue(final TenantConfigurationKey configurationKey) {
return getConfigurationValue(configurationKey, configurationKey.getDataType());
}
@@ -147,6 +147,7 @@ public class JpaTenantConfigurationManagement implements EnvironmentAware, Tenan
final JpaTenantConfiguration updatedTenantConfiguration = tenantConfigurationRepository
.save(tenantConfiguration);
@SuppressWarnings("unchecked")
final Class<T> clazzT = (Class<T>) value.getClass();
return TenantConfigurationValue.<T> builder().global(false).createdBy(updatedTenantConfiguration.getCreatedBy())

View File

@@ -11,7 +11,7 @@ package org.eclipse.hawkbit.repository.jpa.cache;
import org.eclipse.hawkbit.repository.jpa.model.CacheFieldEntityListener;
/**
* Constants for cache keys used in multiple classes.
* RepositoryConstants for cache keys used in multiple classes.
*
*
*

View File

@@ -842,7 +842,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
final DistributionSet ds = testdataFactory.createDistributionSet("a");
// assign ds to create an action
final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement.assignDistributionSet(
ds.getId(), ActionType.SOFT, org.eclipse.hawkbit.repository.model.Constants.NO_FORCE_TIME,
ds.getId(), ActionType.SOFT, org.eclipse.hawkbit.repository.model.RepositoryModelConstants.NO_FORCE_TIME,
target.getControllerId());
final Action action = deploymentManagement.findActionWithDetails(assignDistributionSet.getActions().get(0));
// verify preparation
@@ -865,7 +865,7 @@ public class DeploymentManagementTest extends AbstractJpaIntegrationTest {
final DistributionSet ds = testdataFactory.createDistributionSet("a");
// assign ds to create an action
final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement.assignDistributionSet(
ds.getId(), ActionType.FORCED, org.eclipse.hawkbit.repository.model.Constants.NO_FORCE_TIME,
ds.getId(), ActionType.FORCED, org.eclipse.hawkbit.repository.model.RepositoryModelConstants.NO_FORCE_TIME,
target.getControllerId());
final Action action = deploymentManagement.findActionWithDetails(assignDistributionSet.getActions().get(0));
// verify perparation