From 64deaeea3cc24a22b7a97ff3dc74a0a79179f0e5 Mon Sep 17 00:00:00 2001 From: Kai Zimmermann Date: Thu, 21 Jan 2016 13:42:38 +0100 Subject: [PATCH] Remove swagger and minor feature extensions and bug fixes - Various Bug fixes and improvements - Management API extended - Swagger removed - Guava Upgraded to 19 --- .gitattributes | 10 + .gitignore | 50 ++ 3rd-dependencies/compile.txt | 0 3rd-dependencies/provided.txt | 0 3rd-dependencies/test.txt | 0 CONTRUBUTING.md | 0 DDIA.md | 0 DMFA.md | 127 +++ LICENCE_HEADER_TEMPLATE.txt | 0 README.md | 2 +- circle.yml | 0 eclipse_codeformatter.xml | 0 examples/README.md | 0 examples/hawkbit-device-simulator/.gitignore | 0 examples/hawkbit-device-simulator/README.md | 23 +- examples/hawkbit-device-simulator/pom.xml | 118 ++- .../hawkbit/simulator/DeviceSimulator.java | 4 + .../simulator/SimulationController.java | 0 .../simulator/amqp/AmqpConfiguration.java | 18 +- .../simulator/amqp/AmqpProperties.java | 0 .../amqp/MessageHandlerCacheConstant.java | 0 .../simulator/amqp/MessageService.java | 0 .../simulator/amqp/ReceiverService.java | 0 .../hawkbit/simulator/amqp/SenderService.java | 2 + .../simulator/amqp/SimulatedUpdate.java | 0 .../simulator/amqp/SpReceiverService.java | 12 + .../simulator/amqp/SpSenderService.java | 4 +- .../src/main/resources/application.properties | 56 +- examples/hawkbit-example-app/.gitignore | 0 examples/hawkbit-example-app/README.md | 0 examples/hawkbit-example-app/pom.xml | 9 +- .../org/eclipse/hawkbit/app/MyLoginUI.java | 0 .../java/org/eclipse/hawkbit/app/MyUI.java | 0 .../java/org/eclipse/hawkbit/app/Start.java | 12 +- .../src/main/resources/application.properties | 0 examples/hawkbit-mgmt-api-client/.gitignore | 2 + examples/hawkbit-mgmt-api-client/README.md | 3 + examples/hawkbit-mgmt-api-client/pom.xml | 70 ++ .../api/client/DistributionSetResource.java | 37 + .../client/DistrubutionSetTagResource.java | 138 +++ .../mgmt/api/client/TargetResource.java | 80 ++ .../mgmt/api/client/TargetTagResource.java | 137 +++ .../api/client/DistributionSetTagTest.java | 186 ++++ .../mgmt/api/client/TargetTagTest.java | 182 ++++ .../hawkbit/mgmt/api/client/TargetTest.java | 119 +++ examples/pom.xml | 1 + hawkbit-artifact-repository-mongo/README.md | 0 hawkbit-artifact-repository-mongo/pom.xml | 1 - .../artifact/repository/ArtifactStore.java | 5 +- .../ArtifactStoreAutoConfiguration.java | 0 .../artifact/repository/GridFsArtifact.java | 0 .../repository/MongoConfiguration.java | 0 .../main/resources/META-INF/spring.factories | 0 .../hawkbit/artifact/FreePortFileWriter.java | 0 .../hawkbit/artifact/MongoDBTestRule.java | 0 .../hawkbit/artifact/TestConfiguration.java | 0 .../repository/ArtifactStoreTest.java | 0 hawkbit-autoconfigure/pom.xml | 5 - .../amqp/AmqpAutoConfiguration.java | 0 .../cache/CacheAutoConfiguration.java | 0 .../DownloadIdCacheAutoConfiguration.java | 0 .../cache/RedisAutoConfiguration.java | 0 .../conf/ControllerPollAutoConfiguration.java | 0 .../DefaultPropertiesAutoConfiguration.java | 0 .../eventbus/EventBusAutoConfiguration.java | 0 .../AsyncConfigurerAutoConfiguration.java | 0 .../AsyncConfigurerThreadpoolProperties.java | 0 .../scheduling/ExecutorAutoConfiguration.java | 0 ...leHawkbitManagedSecurityConfiguration.java | 0 .../security/SecurityAutoConfiguration.java | 0 .../SecurityManagedConfiguration.java | 115 +-- .../SwaggerApiDocAutoConfiguration.java | 93 -- .../autoconfigure/ui/UIAutoConfiguration.java | 0 ...ertyHostnameResolverAutoConfiguration.java | 0 .../autoconfigure/url/ServerProperties.java | 0 .../ResourceControllerAutoConfiguration.java | 0 .../web/WebMvcAutoConfiguration.java | 0 .../main/resources/META-INF/spring.factories | 1 - .../main/resources/hawkbitdefaults.properties | 0 hawkbit-cache-redis/pom.xml | 0 .../hawkbit/cache/RedisConfiguration.java | 0 .../hawkbit/cache/RedisProperties.java | 0 .../hawkbit/cache/annotation/EnableRedis.java | 0 .../cache/eventbus/EventDistributor.java | 0 .../cache/eventbus/EventDistributorTest.java | 0 .../cache/redis/RedisPropertiesTest.java | 0 hawkbit-core/pom.xml | 1 - .../hawkbit/ControllerPollProperties.java | 0 ...istributedResourceBundleMessageSource.java | 0 .../eclipse/hawkbit/api/HostnameResolver.java | 7 +- .../repository/ArtifactRepository.java | 0 .../repository/ArtifactStoreException.java | 0 .../repository/HashNotMatchException.java | 0 .../artifact/repository/model/DbArtifact.java | 0 .../repository/model/DbArtifactHash.java | 0 .../eclipse/hawkbit/cache/CacheConstants.java | 0 .../hawkbit/cache/DownloadArtifactCache.java | 0 .../eclipse/hawkbit/cache/DownloadType.java | 0 .../hawkbit/cache/TenancyCacheManager.java | 0 .../cache/TenantAwareCacheManager.java | 0 .../hawkbit/eventbus/DeadEventListener.java | 0 .../eventbus/EventBusSubscriberProcessor.java | 0 .../hawkbit/eventbus/EventSubscriber.java | 0 .../event/AbstractDistributedEvent.java | 0 .../event/CancelTargetAssignmentEvent.java | 0 .../hawkbit/eventbus/event/CustomEvents.java | 0 .../eventbus/event/DistributedEvent.java | 0 .../eventbus/event/DownloadProgressEvent.java | 0 .../hawkbit/eventbus/event/EntityEvent.java | 0 .../eclipse/hawkbit/eventbus/event/Event.java | 0 .../hawkbit/eventbus/event/NodeAware.java | 0 .../eventbus/event/TargetDeletedEvent.java | 0 .../exception/GenericSpServerException.java | 0 .../hawkbit/exception/SpServerError.java | 46 +- .../exception/SpServerRtException.java | 0 .../hawkbit/repository/ActionFields.java | 10 +- .../repository/ActionStatusFields.java | 0 .../repository/DistributionSetFields.java | 0 .../DistributionSetMetadataFields.java | 0 .../repository/DistributionSetTypeFields.java | 0 .../hawkbit/repository/FieldNameProvider.java | 3 +- .../repository/FieldValueConverter.java | 0 .../repository/SoftwareModuleFields.java | 0 .../SoftwareModuleMetadataFields.java | 0 .../repository/SoftwareModuleTypeFields.java | 0 .../eclipse/hawkbit/repository/TagFields.java | 40 + .../hawkbit/repository/TargetFields.java | 0 .../eclipse/hawkbit/tenancy/TenantAware.java | 11 +- .../configuration/TenantConfigurationKey.java | 0 .../EventBusSubscriberProcessorTest.java | 0 hawkbit-dmf-amqp/pom.xml | 0 .../hawkbit/amqp/AmqpConfiguration.java | 20 +- .../amqp/AmqpControllerAuthentfication.java | 4 +- .../amqp/AmqpMessageDispatcherService.java | 12 +- .../amqp/AmqpMessageHandlerService.java | 56 +- .../eclipse/hawkbit/amqp/AmqpProperties.java | 0 .../hawkbit/amqp/annotation/EnableAmqp.java | 0 .../hawkbit/util/ArtifactUrlHandler.java | 5 +- .../util/ArtifactUrlHandlerProperties.java | 0 .../util/PropertyBasedArtifactUrlHandler.java | 0 .../AmqpControllerAuthentficationTest.java | 0 .../AmqpMessageDispatcherServiceTest.java | 18 +- .../amqp/AmqpMessageHandlerServiceTest.java | 0 .../PropertyBasedArtifactUrlHandlerTest.java | 0 hawkbit-dmf-api/README.md | 0 hawkbit-dmf-api/pom.xml | 0 .../hawkbit/dmf/amqp/api/AmqpSettings.java | 0 .../hawkbit/dmf/amqp/api/EventTopic.java | 0 .../dmf/amqp/api/MessageHeaderKey.java | 0 .../hawkbit/dmf/amqp/api/MessageType.java | 0 .../hawkbit/dmf/json/model/ActionStatus.java | 2 +- .../dmf/json/model/ActionUpdateStatus.java | 0 .../hawkbit/dmf/json/model/Artifact.java | 10 +- .../hawkbit/dmf/json/model/ArtifactHash.java | 0 .../json/model/DownloadAndUpdateRequest.java | 6 +- .../dmf/json/model/DownloadResponse.java | 0 .../dmf/json/model/SoftwareModule.java | 4 +- .../dmf/json/model/TenantSecruityToken.java | 0 hawkbit-http-security/pom.xml | 0 ...actHttpControllerAuthenticationFilter.java | 0 ...enantAwareAuthenticationDetailsSource.java | 0 ...lerPreAuthenticateSecurityTokenFilter.java | 0 ...thenticatedGatewaySecurityTokenFilter.java | 0 ...rPreAuthenticatedSecurityHeaderFilter.java | 0 .../HttpDownloadAuthenticationFilter.java | 0 ...SourceTrustAuthenticationProviderTest.java | 0 hawkbit-repository/README.md | 0 hawkbit-repository/pom.xml | 1 - hawkbit-repository/src/fbExcludeFilter.xml | 0 .../java/org/eclipse/hawkbit/Constants.java | 0 .../MultiTenantJpaTransactionManager.java | 0 .../RepositoryApplicationConfiguration.java | 8 +- .../ExceptionMappingAspectHandler.java | 179 ++++ .../aspects/SpExceptionMappingAspect.java | 108 --- .../org/eclipse/hawkbit/cache/CacheField.java | 0 .../org/eclipse/hawkbit/cache/CacheKeys.java | 0 .../hawkbit/cache/CacheWriteNotify.java | 0 .../eventbus/CacheFieldEntityListener.java | 0 .../eventbus/EntityChangeEventListener.java | 15 +- .../event/AbstractBaseEntityEvent.java | 0 .../event/AbstractEntityBulkEvent.java | 70 ++ ...istributionSetTagAssigmentResultEvent.java | 34 + .../DistributionSetTagCreatedBulkEvent.java | 46 + .../event/DistributionSetTagDeletedEvent.java | 31 + .../event/DistributionSetTagUpdateEvent.java | 31 + .../eventbus/event/EntityBulkEvent.java | 34 + .../TargetAssignDistributionSetEvent.java | 0 .../eventbus/event/TargetCreatedEvent.java | 0 .../eventbus/event/TargetInfoUpdateEvent.java | 6 +- .../event/TargetTagAssigmentResultEvent.java | 34 + .../event/TargetTagCreatedBulkEvent.java | 46 + .../eventbus/event/TargetTagDeletedEvent.java | 30 + .../eventbus/event/TargetTagUpdateEvent.java | 30 + ...ansactionCommitDefaultServiceExecutor.java | 69 ++ .../AfterTransactionCommitExecutor.java | 28 + .../report/model/AbstractReportSeries.java | 0 .../report/model/DataReportSeries.java | 0 .../report/model/DataReportSeriesItem.java | 0 .../model/InnerOuterDataReportSeries.java | 0 .../report/model/ListReportSeries.java | 0 .../hawkbit/report/model/SeriesTime.java | 0 .../report/model/SystemUsageReport.java | 95 +++ .../hawkbit/report/model/TenantUsage.java | 161 ++++ .../hawkbit/repository/ActionRepository.java | 0 .../repository/ActionStatusRepository.java | 0 .../repository/ArtifactManagement.java | 0 .../repository/BaseEntityRepository.java | 0 .../repository/ControllerManagement.java | 59 +- .../repository/DeploymentManagement.java | 236 ++++-- .../DistributionSetAssignmentResult.java | 1 + .../repository/DistributionSetFilter.java | 0 .../repository/DistributionSetManagement.java | 133 ++- .../DistributionSetMetadataRepository.java | 0 .../repository/DistributionSetRepository.java | 0 .../DistributionSetTagRepository.java | 7 +- .../DistributionSetTypeRepository.java | 0 .../EclipseLinkTargetInfoRepository.java | 0 .../ExternalArtifactProviderRepository.java | 0 .../ExternalArtifactRepository.java | 0 .../repository/LocalArtifactRepository.java | 24 +- .../repository/NoCountPagingRepository.java | 0 .../hawkbit/repository/ReportManagement.java | 0 .../repository/SoftwareManagement.java | 0 .../SoftwareModuleMetadataRepository.java | 0 .../repository/SoftwareModuleRepository.java | 0 .../SoftwareModuleTypeRepository.java | 0 .../hawkbit/repository/SystemManagement.java | 113 ++- .../hawkbit/repository/TagManagement.java | 108 ++- .../TargetFilterQueryManagement.java | 0 .../TargetFilterQueryRepository.java | 0 .../repository/TargetInfoRepository.java | 0 .../hawkbit/repository/TargetManagement.java | 289 +++++-- .../hawkbit/repository/TargetRepository.java | 0 .../repository/TargetTagRepository.java | 3 +- .../repository/TargetWithActionType.java | 0 .../TenantConfigurationRepository.java | 0 .../repository/TenantKeyGenerator.java | 0 .../repository/TenantMetaDataRepository.java | 0 .../repository/TenantStatsManagement.java | 66 ++ .../event/DeploymentManagementEvents.java | 70 -- .../ArtifactDeleteFailedException.java | 0 .../ArtifactUploadFailedException.java | 0 .../CancelActionNotAllowedException.java | 0 .../ConcurrentModificationException.java | 0 ...FailedMissingMandatoryModuleException.java | 0 ...DistributionSetTypeUndefinedException.java | 0 .../EntityAlreadyExistsException.java | 0 .../exception/EntityLockedException.java | 0 .../exception/EntityNotFoundException.java | 0 .../exception/EntityReadOnlyException.java | 0 .../ForceQuitActionNotAllowedException.java | 48 ++ .../GridFSDBFileNotFoundException.java | 0 .../IncompleteDistributionSetException.java | 0 .../InsufficientPermissionException.java | 0 .../exception/InvalidMD5HashException.java | 0 .../exception/InvalidSHA1HashException.java | 0 .../exception/TenantNotExistException.java | 0 .../ToManyAttributeEntriesException.java | 0 .../ToManyStatusEntriesException.java | 0 ...ModuleForThisDistributionSetException.java | 0 .../hawkbit/repository/model/Action.java | 12 +- .../repository/model/ActionStatus.java | 0 .../model/ActionWithStatusCount.java | 0 .../hawkbit/repository/model/Artifact.java | 0 .../{ => model}/AssignmentResult.java | 2 +- .../hawkbit/repository/model/BaseEntity.java | 0 .../model/CustomSoftwareModule.java | 0 .../repository/model/DistributionSet.java | 18 +- .../model/DistributionSetIdName.java | 0 .../model/DistributionSetMetadata.java | 0 .../repository/model/DistributionSetTag.java | 16 +- .../DistributionSetTagAssigmentResult.java | 22 +- .../repository/model/DistributionSetType.java | 33 +- .../model/DistributionSetTypeElement.java | 0 ...istributionSetTypeElementCompositeKey.java | 0 .../model/DsMetadataCompositeKey.java | 0 .../repository/model/ExternalArtifact.java | 0 .../model/ExternalArtifactProvider.java | 0 .../repository/model/LocalArtifact.java | 0 .../hawkbit/repository/model/NamedEntity.java | 0 .../model/NamedVersionedEntity.java | 0 .../repository/model/SoftwareModule.java | 15 +- .../model/SoftwareModuleIdName.java | 0 .../model/SoftwareModuleMetadata.java | 0 .../repository/model/SoftwareModuleType.java | 5 + .../model/SwMetadataCompositeKey.java | 0 .../eclipse/hawkbit/repository/model/Tag.java | 0 .../hawkbit/repository/model/Target.java | 0 .../repository/model/TargetFilterQuery.java | 0 .../repository/model/TargetIdName.java | 0 .../hawkbit/repository/model/TargetInfo.java | 0 .../hawkbit/repository/model/TargetTag.java | 0 .../{ => model}/TargetTagAssigmentResult.java | 14 +- .../repository/model/TargetUpdateStatus.java | 0 .../repository/model/TenantConfiguration.java | 0 .../repository/model/TenantMetaData.java | 0 .../model/helper/CacheManagerHolder.java | 0 .../model/helper/PollConfigurationHelper.java | 0 .../model/helper/SecurityChecker.java | 0 .../helper/SecurityTokenGeneratorHolder.java | 0 .../model/helper/SystemManagementHolder.java | 0 .../model/helper/TenantAwareHolder.java | 0 .../repository/rsql/PropertyMapper.java | 0 .../rsql/RSQLParameterSyntaxException.java | 0 ...SQLParameterUnsupportedFieldException.java | 0 .../hawkbit/repository/rsql/RSQLUtility.java | 47 +- .../DistributionSetSpecification.java | 1 + .../DistributionSetTypeSpecification.java | 0 .../SoftwareModuleSpecification.java | 0 .../TargetFilterQuerySpecification.java | 0 .../specifications/TargetSpecifications.java | 0 .../db/migration/H2/V1_0_1__init___H2.sql | 0 ...0__update_target_info_for_message___H2.sql | 0 .../H2/V1_4_0__cascade_delete___H2.sql | 0 .../H2/V1_4_1__cascade_delete___H2.sql | 0 .../H2/V1_5_0__target_filter_query___H2.sql | 0 .../migration/MYSQL/V1_0_1__init___MYSQL.sql | 0 ...update_target_info_for_message___MYSQL.sql | 0 .../MYSQL/V1_4_0__cascade_delete___MYSQL.sql | 0 .../MYSQL/V1_4_1__cascade_delete___MYSQL.sql | 0 .../V1_5_0__target_filter_query___MYSQL.sql | 0 .../hawkbit/AbstractIntegrationTest.java | 71 +- .../AbstractIntegrationTestWithMongoDB.java | 0 .../eclipse/hawkbit/CIMySqlTestDatabase.java | 0 .../eclipse/hawkbit/FreePortFileWriter.java | 0 .../eclipse/hawkbit/HashGeneratorUtils.java | 0 .../eclipse/hawkbit/LocalH2TestDatabase.java | 0 .../eclipse/hawkbit/MethodSecurityUtil.java | 0 .../hawkbit/RandomGeneratedInputStream.java | 0 .../eclipse/hawkbit/TestConfiguration.java | 0 .../org/eclipse/hawkbit/TestDataUtil.java | 0 .../org/eclipse/hawkbit/Testdatabase.java | 0 .../hawkbit/WithSpringAuthorityRule.java | 0 .../java/org/eclipse/hawkbit/WithUser.java | 0 .../eclipse/hawkbit/cache/CacheKeysTest.java | 0 .../hawkbit/cache/CacheWriteNotifyTest.java | 0 .../CacheFieldEntityListenerTest.java | 0 .../hawkbit/repository/ActionTest.java | 0 .../ArtifactManagementNoMongoDbTest.java | 0 .../repository/ArtifactManagementTest.java | 0 .../repository/ControllerManagementTest.java | 0 .../repository/DeploymentManagementTest.java | 289 +++++-- .../repository/ReportManagementTest.java | 0 .../SoftwareManagementForDSTest.java | 0 .../repository/SoftwareManagementTest.java | 0 .../repository/SystemManagementTest.java | 145 +++- .../hawkbit/repository/TagManagementTest.java | 89 +- .../TargetFilterQueryManagenmentTest.java | 0 .../TargetManagementSearchTest.java | 0 .../repository/TargetManagementTest.java | 34 + .../utils/RepositoryDataGenerator.java | 0 .../tenancy/MultiTenancyEntityTest.java | 0 .../resources/application-test.properties | 9 +- hawkbit-rest-api/pom.xml | 4 - .../hawkbit/rest/resource/RestConstants.java | 20 + .../rest/resource/model/BaseEntityRest.java | 10 - .../rest/resource/model/ExceptionInfo.java | 10 - .../hawkbit/rest/resource/model/IdRest.java | 8 - .../rest/resource/model/MetadataRest.java | 11 - .../resource/model/MetadataRestPageList.java | 6 - .../rest/resource/model/NamedEntityRest.java | 9 - .../rest/resource/model/PagedList.java | 8 +- .../rest/resource/model/PollStatusRest.java | 11 +- .../model/action/ActionPagedList.java | 9 - .../resource/model/action/ActionRest.java | 9 - .../model/action/ActionStatusPagedList.java | 6 - .../model/action/ActionStatusRest.java | 16 +- .../model/action/ActionStatussRest.java | 0 .../resource/model/action/ActionsRest.java | 0 .../resource/model/artifact/ArtifactHash.java | 10 - .../resource/model/artifact/ArtifactRest.java | 13 - .../model/artifact/ArtifactsRest.java | 6 - .../model/distributionset/ActionTypeRest.java | 0 .../DistributionSetPagedList.java | 9 - ...va => DistributionSetRequestBodyPost.java} | 51 +- ...ava => DistributionSetRequestBodyPut.java} | 33 +- .../distributionset/DistributionSetRest.java | 13 +- .../distributionset/DistributionSetsRest.java | 0 .../TargetAssignmentRequestBody.java | 12 - .../TargetAssignmentResponseBody.java | 9 +- .../DistributionSetTypePagedList.java | 8 - ...> DistributionSetTypeRequestBodyPost.java} | 48 +- ...=> DistributionSetTypeRequestBodyPut.java} | 15 +- .../DistributionSetTypeRest.java | 7 - .../DistributionSetTypesRest.java | 6 - .../model/doc/ApiModelProperties.java | 176 ---- .../SoftwareModuleAssigmentRest.java | 3 - .../SoftwareModulePagedList.java | 9 - .../SoftwareModuleRequestBodyPost.java | 38 +- .../SoftwareModuleRequestBodyPut.java | 19 +- .../softwaremodule/SoftwareModuleRest.java | 12 - .../softwaremodule/SoftwareModulesRest.java | 0 .../SoftwareModuleTypeAssigmentRest.java | 6 - .../SoftwareModuleTypePagedList.java | 9 - .../SoftwareModuleTypeRequestBodyPost.java | 30 +- .../SoftwareModuleTypeRequestBodyPut.java | 13 +- .../SoftwareModuleTypeRest.java | 8 - .../SoftwareModuleTypesRest.java | 6 - .../rest/resource/model/system/CacheRest.java | 0 .../model/system/SystemStatisticsRest.java | 86 ++ .../model/system/TenantConfigurationRest.java | 5 +- .../model/system/TenantSystemUsageRest.java | 75 ++ .../AssignedDistributionSetRequestBody.java | 36 + .../model/tag/AssignedTargetRequestBody.java | 36 + ...DistributionSetTagAssigmentResultRest.java | 49 ++ .../rest/resource/model/tag/TagPagedList.java | 43 + .../resource/model/tag/TagRequestBodyPut.java | 59 ++ .../rest/resource/model/tag/TagRest.java | 49 ++ .../rest/resource/model/tag/TagsRest.java | 275 ++++++ .../tag/TargetTagAssigmentResultRest.java | 49 ++ .../target/DistributionSetAssigmentRest.java | 10 - .../model/target/TargetAttributes.java | 10 +- .../model/target/TargetPagedList.java | 14 +- .../model/target/TargetRequestBody.java | 19 +- .../resource/model/target/TargetRest.java | 16 - .../resource/model/target/TargetsRest.java | 3 - hawkbit-rest-resource/pom.xml | 16 + .../hawkbit/cache/CacheWriteNotify.java | 0 .../controller/ArtifactStoreController.java | 4 +- .../controller/ControllerConstants.java | 6 +- .../controller/DataConversionHelper.java | 50 +- .../controller/EnableDirectDeviceApi.java | 0 .../FileSteamingFailedException.java | 0 .../hawkbit/controller/RootController.java | 153 ++-- .../controller/model/ActionFeedback.java | 18 +- .../hawkbit/controller/model/Artifact.java | 11 - .../hawkbit/controller/model/Cancel.java | 14 +- .../controller/model/CancelActionToStop.java | 12 +- .../hawkbit/controller/model/Chunk.java | 14 - .../hawkbit/controller/model/Config.java | 11 - .../hawkbit/controller/model/ConfigData.java | 14 +- .../controller/model/ControllerBase.java | 12 +- .../hawkbit/controller/model/Deployment.java | 19 +- .../controller/model/DeploymentBase.java | 15 +- .../hawkbit/controller/model/Polling.java | 11 - .../hawkbit/controller/model/Progress.java | 14 +- .../hawkbit/controller/model/Result.java | 17 +- .../controller/model/SoftwareModule.java | 94 --- .../hawkbit/controller/model/Status.java | 20 +- .../rest/resource/DistributionSetMapper.java | 65 +- .../resource/DistributionSetResource.java | 225 ++--- .../resource/DistributionSetTagResource.java | 351 ++++++++ .../resource/DistributionSetTypeMapper.java | 8 +- .../resource/DistributionSetTypeResource.java | 181 ++-- .../rest/resource/DownloadResource.java | 0 .../rest/resource/EnableRestResources.java | 0 .../resource/MessageNotReadableException.java | 0 .../rest/resource/OffsetBasedPageRequest.java | 0 .../hawkbit/rest/resource/PagingUtility.java | 0 .../resource/ResponseExceptionHandler.java | 13 +- .../rest/resource/RestModelMapper.java | 0 .../rest/resource/SoftwareModuleMapper.java | 47 +- .../rest/resource/SoftwareModuleResource.java | 141 +--- .../resource/SoftwareModuleTypeMapper.java | 0 .../resource/SoftwareModuleTypeResource.java | 54 +- .../hawkbit/rest/resource/SortDirection.java | 0 .../SortParameterSyntaxErrorException.java | 0 ...arameterUnsupportedDirectionException.java | 0 ...ortParameterUnsupportedFieldException.java | 0 .../hawkbit/rest/resource/SortUtility.java | 0 .../resource/SystemManagementResource.java | 50 +- .../hawkbit/rest/resource/TagMapper.java | 136 +++ .../hawkbit/rest/resource/TargetMapper.java | 314 ++++--- .../hawkbit/rest/resource/TargetResource.java | 135 +-- .../rest/resource/TargetTagResource.java | 320 +++++++ .../rest/resource/helper/ByteRange.java | 0 .../helper/RestResourceConversionHelper.java | 0 .../eclipse/hawkbit/MockMvcResultPrinter.java | 0 .../controller/ArtifactDownloadTest.java | 0 .../hawkbit/controller/CancelActionTest.java | 0 .../hawkbit/controller/ConfigDataTest.java | 0 .../controller/DeploymentBaseTest.java | 65 +- .../controller/RootControllerTest.java | 57 +- .../resource/DistributionSetResourceTest.java | 388 ++++----- .../DistributionSetTypeResourceTest.java | 0 .../rest/resource/DownloadResourceTest.java | 0 .../hawkbit/rest/resource/JsonBuilder.java | 183 +++- .../rest/resource/RSQLUtilityTest.java | 0 .../rest/resource/ResourceUtility.java | 0 ...MRessourceMisingMongoDbConnectionTest.java | 0 .../resource/SoftwareModuleResourceTest.java | 119 ++- .../SoftwareModuleTypeResourceTest.java | 0 .../rest/resource/SortUtilityTest.java | 0 .../SystemManagementResourceTest.java | 100 ++- .../rest/resource/TargetResourceTest.java | 82 +- .../resource/model/ExceptionInfoTest.java | 0 .../rest/resource/model/PagedListTest.java | 0 .../resources/application-test.properties | 0 .../src/test/resources/log4j2.xml | 26 + hawkbit-security-core/pom.xml | 1 - .../ExcludePathAwareShallowETagFilter.java | 0 .../authentication/MultitenancyIndicator.java | 4 +- .../im/authentication/PermissionService.java | 29 +- .../im/authentication/SpPermission.java | 0 .../TenantAwareAuthenticationDetails.java | 0 ...TenantUserPasswordAuthenticationToken.java | 9 +- .../UserAuthenticationFilter.java | 0 .../im/authentication/UserPrincipal.java | 0 .../eclipse/hawkbit/security/DosFilter.java | 8 +- .../security/SecurityContextTenantAware.java | 0 .../hawkbit/security/SecurityProperties.java | 0 .../security/SecurityTokenGenerator.java | 0 .../security/SpringSecurityAuditorAware.java | 0 .../java/org/eclipse/hawkbit/util/IpUtil.java | 0 .../java/org/eclipse/hawkbit/util/SPInfo.java | 0 ...ExcludePathAwareShallowETagFilterTest.java | 0 .../security/SecurityTokenGeneratorTest.java | 0 .../org/eclipse/hawkbit/util/IpUtilTest.java | 0 hawkbit-security-integration/pom.xml | 0 ...bstractControllerAuthenticationFilter.java | 0 .../CoapAnonymousPreAuthenticatedFilter.java | 0 ...lerPreAuthenticateSecurityTokenFilter.java | 0 ...thenticatedGatewaySecurityTokenFilter.java | 0 ...rPreAuthenticatedSecurityHeaderFilter.java | 6 +- .../security/HeaderAuthentication.java | 0 ...okenSourceTrustAuthenticationProvider.java | 0 .../security/PreAuthenficationFilter.java | 0 .../TenantAwareWebAuthenticationDetails.java | 0 hawkbit-test-report/placeholder.txt | 0 hawkbit-test-report/pom.xml | 0 .../src/main/assembly/test-report.xml | 0 hawkbit-ui/.gitignore | 0 hawkbit-ui/pom.xml | 0 hawkbit-ui/src/main/.gitignore | 0 .../push/AsyncVaadinServletConfiguration.java | 0 .../SpringSecurityAtmosphereInterceptor.java | 0 .../repository/OffsetBasedPageRequest.java | 0 .../repository/SpPermissionChecker.java | 0 .../eclipse/hawkbit/ui/AppWidgetSet.gwt.xml | 0 .../eclipse/hawkbit/ui/DefaultHawkbitUI.java | 0 .../hawkbit/ui/DispatcherRunnable.java | 0 .../org/eclipse/hawkbit/ui/ErrorView.java | 0 .../org/eclipse/hawkbit/ui/HawkbitUI.java | 0 .../ui/artifacts/UploadArtifactView.java | 0 .../artifacts/UploadArtifactViewMenuItem.java | 0 .../artifacts/details/ArtifactBeanQuery.java | 0 .../details/ArtifactDetailsLayout.java | 45 +- .../artifacts/event/ArtifactDetailsEvent.java | 0 .../ui/artifacts/event/SMFilterEvent.java | 0 .../artifacts/event/SoftwareModuleEvent.java | 0 .../event/SoftwareModuleTypeEvent.java | 0 .../event/UploadArtifactUIEvent.java | 0 .../event/UploadViewAcceptCriteria.java | 0 .../footer/SMDeleteActionsLayout.java | 84 +- .../UploadViewConfirmationWindowLayout.java | 0 .../smtable/BaseSwModuleBeanQuery.java | 0 .../smtable/ProxyBaseSoftwareModuleItem.java | 0 .../SoftwareModuleAddUpdateWindow.java | 0 .../smtable/SoftwareModuleDetails.java | 0 .../smtable/SoftwareModuleTable.java | 69 +- .../smtable/SoftwareModuleTableHeader.java | 11 + .../smtable/SoftwareModuleTableLayout.java | 0 .../CreateUpdateSoftwareTypeLayout.java | 0 .../smtype/SMTypeFilterButtonClick.java | 0 .../artifacts/smtype/SMTypeFilterButtons.java | 0 .../artifacts/smtype/SMTypeFilterHeader.java | 0 .../artifacts/smtype/SMTypeFilterLayout.java | 0 .../artifacts/state/ArtifactUploadState.java | 0 .../ui/artifacts/state/CustomFile.java | 0 .../state/SoftwareModuleFilters.java | 0 .../upload/UploadConfirmationwindow.java | 0 .../ui/artifacts/upload/UploadHandler.java | 0 .../ui/artifacts/upload/UploadLayout.java | 0 .../artifacts/upload/UploadResultWindow.java | 0 .../ui/artifacts/upload/UploadStatus.java | 0 .../upload/UploadStatusInfoWindow.java | 0 .../ui/common/AbstractAcceptCriteria.java | 8 +- .../hawkbit/ui/common/ConfirmationDialog.java | 39 +- .../hawkbit/ui/common/CoordinatesToColor.java | 0 .../common/DistributionSetTypeBeanQuery.java | 0 .../common/SoftwareModuleTypeBeanQuery.java | 0 .../AbstractConfirmationWindowLayout.java | 0 .../confirmwindow/layout/ConfirmationTab.java | 0 .../layout/ConfirmationWindowEvents.java | 0 .../AbstractTableDetailsLayout.java | 0 .../SoftwareModuleDetailsTable.java | 146 +++- .../AbstractFilterButtonClickBehaviour.java | 0 .../filterlayout/AbstractFilterButtons.java | 0 .../filterlayout/AbstractFilterHeader.java | 0 .../filterlayout/AbstractFilterLayout.java | 0 .../AbstractFilterMultiButtonClick.java | 0 .../AbstractFilterSingleButtonClick.java | 0 .../footer/AbstractDeleteActionsLayout.java | 84 +- .../ui/common/table/AbstractTable.java | 0 .../ui/common/table/AbstractTableHeader.java | 25 +- .../ui/common/table/AbstractTableLayout.java | 0 .../common/tagdetails/AbstractTagToken.java | 17 +- .../tagdetails/AbstractTargetTagToken.java | 73 ++ .../tagdetails/DistributionTagToken.java | 87 +- .../ui/common/tagdetails/TargetTagToken.java | 106 ++- .../components/DistributionSetInfoPanel.java | 0 .../ui/components/ProxyDistribution.java | 23 +- .../hawkbit/ui/components/ProxyTarget.java | 0 .../ui/components/ProxyTargetFilter.java | 0 .../ui/components/SPNotificationMessage.java | 6 +- .../components/SPTargetAttributesLayout.java | 0 .../hawkbit/ui/components/SPUIButton.java | 0 .../hawkbit/ui/components/SPUICheckBox.java | 0 .../ui/components/SPUIComponentProvider.java | 0 .../ui/components/SPUIErrorHandler.java | 13 +- .../ui/components/SPUIHorizontalLayout.java | 0 .../ui/components/SPUINotifcation.java | 61 -- .../hawkbit/ui/components/SPUITabSheet.java | 0 .../components/SPUITableHorizonatlLayout.java | 0 .../ui/components/SPUIUpdateLogLayout.java | 0 .../ui/decorators/SPUIButtonDecorator.java | 0 .../SPUIButtonStyleLargeIconNoBorder.java | 0 .../SPUIButtonStylePrimarySmall.java | 0 .../ui/decorators/SPUIButtonStyleSmall.java | 0 .../SPUIButtonStyleSmallNoBorder.java | 0 .../SPUIButtonStyleSmallNoBorderUH.java | 0 .../SPUIButtonStyleSmallNoBorderUHS.java | 0 .../ui/decorators/SPUIButtonStyleTiny.java | 0 .../ui/decorators/SPUIComboBoxDecorator.java | 0 .../ui/decorators/SPUIEmbedDecorator.java | 0 .../hawkbit/ui/decorators/SPUIEmbedValue.java | 0 .../decorators/SPUIHeaderLayoutDecorator.java | 0 .../ui/decorators/SPUILabelDecorator.java | 0 .../ui/decorators/SPUITagButtonStyle.java | 0 .../ui/decorators/SPUITextAreaDecorator.java | 0 .../ui/decorators/SPUITextFieldDecorator.java | 0 .../ui/decorators/SPUIWindowDecorator.java | 0 .../ui/distributions/DistributionsView.java | 0 .../DistributionsViewMenuItem.java | 0 .../CreateUpdateDistSetTypeLayout.java | 0 .../disttype/DSTypeFilterButtonClick.java | 0 .../disttype/DSTypeFilterButtons.java | 0 .../disttype/DSTypeFilterHeader.java | 0 .../disttype/DSTypeFilterLayout.java | 0 .../dstable/DistributionSetDetails.java | 30 +- .../dstable/DistributionSetTable.java | 49 +- .../dstable/DistributionSetTableHeader.java | 31 +- .../dstable/DistributionSetTableLayout.java | 0 .../dstable/ManageDistBeanQuery.java | 0 .../event/DistributionSetTypeEvent.java | 0 .../event/DistributionsUIEvent.java | 0 .../DistributionsViewAcceptCriteria.java | 0 .../ui/distributions/event/DragEvent.java | 0 .../event/SaveActionWindowEvent.java | 0 .../SoftwareModuleAssignmentDiscardEvent.java | 0 .../distributions/event/SwModuleUIEvent.java | 0 .../footer/DSDeleteActionsLayout.java | 100 ++- ...DistributionsConfirmationWindowLayout.java | 0 .../smtable/ProxyBaseSwModuleItem.java | 0 .../smtable/SwModuleBeanQuery.java | 0 .../smtable/SwModuleDetails.java | 0 .../distributions/smtable/SwModuleTable.java | 71 +- .../smtable/SwModuleTableHeader.java | 11 + .../smtable/SwModuleTableLayout.java | 0 .../smtype/DistSMTypeFilterButtonClick.java | 0 .../smtype/DistSMTypeFilterButtons.java | 0 .../smtype/DistSMTypeFilterHeader.java | 0 .../smtype/DistSMTypeFilterLayout.java | 0 .../state/ManageDistFilters.java | 0 .../state/ManageDistUIState.java | 0 .../state/ManageSoftwareModuleFilters.java | 0 .../documentation/DocumentationPageLink.java | 0 .../ui/documentation/DocumentationUtil.java | 0 .../hawkbit/ui/filter/FilterExpression.java | 0 .../eclipse/hawkbit/ui/filter/Filters.java | 0 .../ui/filter/target/CustomTargetFilter.java | 48 ++ .../filter/target/TargetSearchTextFilter.java | 0 .../ui/filter/target/TargetStatusFilter.java | 7 +- .../ui/filter/target/TargetTagFilter.java | 0 .../CreateOrUpdateFilterHeader.java | 0 .../CreateOrUpdateFilterTable.java | 0 .../CustomTargetBeanQuery.java | 0 .../FilterManagementView.java | 0 .../FilterManagementViewMenuItem.java | 1 - .../FilterQueryValidation.java | 0 .../TargetFilterBeanQuery.java | 0 .../filtermanagement/TargetFilterHeader.java | 0 .../filtermanagement/TargetFilterTable.java | 0 .../ui/filtermanagement/TokenDescription.java | 0 .../ui/filtermanagement/ValidationResult.java | 0 .../event/CustomFilterUIEvent.java | 0 .../state/FilterManagementUIState.java | 0 .../hawkbit/ui/login/HawkbitLoginUI.java | 0 .../eclipse/hawkbit/ui/login/LoginView.java | 0 .../hawkbit/ui/management/DeploymentView.java | 0 .../ui/management/DeploymentViewMenuItem.java | 0 .../actionhistory/ActionHistoryComponent.java | 3 +- .../actionhistory/ActionHistoryHeader.java | 2 + .../actionhistory/ActionHistoryTable.java | 102 ++- .../DistributionAddUpdateWindowLayout.java | 24 +- .../dstable/DistributionBeanQuery.java | 17 +- .../dstable/DistributionDetails.java | 35 +- .../management/dstable/DistributionTable.java | 101 +-- .../dstable/DistributionTableHeader.java | 11 + .../dstable/DistributionTableLayout.java | 0 ...eateUpdateDistributionTagLayoutWindow.java | 63 +- .../dstag/DistributionTagBeanQuery.java | 8 +- .../dstag/DistributionTagButtonClick.java | 0 .../dstag/DistributionTagButtons.java | 27 +- .../dstag/DistributionTagHeader.java | 2 +- .../dstag/DistributionTagLayout.java | 0 .../event/BulkUploadPopupEvent.java | 18 + .../BulkUploadValidationMessageEvent.java | 35 + .../event/DistributionTableEvent.java | 0 .../event/DistributionTableFilterEvent.java | 0 .../event/DistributionTagDropEvent.java | 28 +- .../event/DistributionTagEvent.java | 76 -- .../ui/management/event/DragEvent.java | 0 .../management/event/ManagementUIEvent.java | 0 .../event/ManagementViewAcceptCriteria.java | 0 .../ui/management/event/PinUnpinEvent.java | 0 .../event/SaveActionWindowEvent.java | 2 +- .../event/TargetAddUpdateWindowEvent.java | 0 .../management/event/TargetFilterEvent.java | 0 .../ui/management/event/TargetTableEvent.java | 4 +- .../ui/management/event/TargetTagEvent.java | 76 -- .../footer/ActionTypeOptionGroupLayout.java | 0 .../management/footer/CountMessageLabel.java | 3 +- .../footer/DeleteActionsLayout.java | 226 +++-- .../footer/DeleteActionsLayoutHelper.java | 100 +++ .../ManangementConfirmationWindowLayout.java | 80 +- .../state/DistributionTableFilters.java | 0 .../management/state/ManagementUIState.java | 17 + .../ui/management/state/TargetBulkUpload.java | 128 +++ .../state/TargetFilterParameters.java | 0 .../management/state/TargetTableFilters.java | 44 +- .../management/tag/CreateUpdateTagLayout.java | 43 +- .../hawkbit/ui/management/tag/ProxyTag.java | 0 .../management/tag/SpColorPickerPreview.java | 0 .../hawkbit/ui/management/tag/TagIdName.java | 0 .../targettable/BulkUploadHandler.java | 276 +++--- .../TargetAddUpdateWindowLayout.java | 20 +- .../targettable/TargetBeanQuery.java | 2 +- .../targettable/TargetBulkTokenTags.java | 117 +-- .../TargetBulkUpdateWindowLayout.java | 289 +++++-- .../management/targettable/TargetDetails.java | 0 .../management/targettable/TargetTable.java | 796 ++++++++++-------- .../targettable/TargetTableHeader.java | 57 +- .../targettable/TargetTableLayout.java | 4 +- .../AbstractTargetTagFilterLayout.java | 0 .../CreateUpdateTargetTagLayout.java | 62 +- .../CustomTargetTagFilterButtonClick.java | 0 .../targettag/FilterByStatusLayout.java | 0 .../targettag/MultipleTargetFilter.java | 0 .../targettag/TargetFilterQueryButtons.java | 0 .../targettag/TargetTagBeanQuery.java | 0 .../targettag/TargetTagFilterButtonClick.java | 0 .../targettag/TargetTagFilterButtons.java | 93 +- .../targettag/TargetTagFilterHeader.java | 2 +- .../targettag/TargetTagFilterLayout.java | 0 .../hawkbit/ui/menu/DashboardEvent.java | 0 .../hawkbit/ui/menu/DashboardMenu.java | 0 .../hawkbit/ui/menu/DashboardMenuItem.java | 0 .../AuthenticationConfigurationView.java | 0 .../ConfigurationGroup.java | 0 .../DefaultDistributionSetTypeLayout.java | 0 .../TenantConfigurationDashboardView.java | 0 ...antConfigurationDashboardViewMenuItem.java | 0 ...AuthenticationTenantConfigurationItem.java | 0 ...ficateAuthenticationConfigurationItem.java | 0 ...yTokenAuthenticationConfigurationItem.java | 0 ...yTokenAuthenticationConfigurationItem.java | 0 .../TenantConfigurationItem.java | 0 .../hawkbit/ui/themes/HawkbitTheme.java | 0 .../hawkbit/ui/utils/HawkbitCommonUtil.java | 180 +++- .../org/eclipse/hawkbit/ui/utils/I18N.java | 4 +- .../hawkbit/ui/utils/NamingThreadFactory.java | 0 .../hawkbit/ui/utils/NotificationMessage.java | 0 .../hawkbit/ui/utils/SPDateTimeUtil.java | 0 .../ui/utils/SPUIButtonDefinitions.java | 0 .../ui/utils/SPUIComponetIdProvider.java | 16 + .../hawkbit/ui/utils/SPUIDefinitions.java | 12 +- .../ui/utils/SPUILabelDefinitions.java | 4 + .../ui/utils/SPUIStyleDefinitions.java | 5 + .../ui/utils/SPUITargetDefinitions.java | 0 .../hawkbit/ui/utils/SpringContextHelper.java | 0 .../eclipse/hawkbit/ui/utils/TableColumn.java | 0 .../hawkbit/ui/utils/UINotification.java | 0 .../src/main/resources/VAADIN/.gitignore | 0 .../VAADIN/themes/hawkbit/.gitignore | 0 .../hawkbit/customstyles/accordion.scss | 0 .../hawkbit/customstyles/action-history.scss | 0 .../hawkbit/customstyles/artifact-upload.scss | 0 .../hawkbit/customstyles/colorpicker.scss | 0 .../themes/hawkbit/customstyles/common.scss | 0 .../hawkbit/customstyles/dashboardview.scss | 0 .../hawkbit/customstyles/drop-hint.scss | 0 .../customstyles/filter-layout-styles.scss | 0 .../hawkbit/customstyles/filter-status.scss | 0 .../hawkbit/customstyles/footer-common.scss | 34 +- .../hawkbit/customstyles/generic-styles.scss | 0 .../customstyles/hawkbitvariables.scss | 0 .../themes/hawkbit/customstyles/login.scss | 0 .../themes/hawkbit/customstyles/others.scss | 0 .../hawkbit/customstyles/popup-common.scss | 0 .../hawkbit/customstyles/popup-window.scss | 0 .../hawkbit/customstyles/systemconfig.scss | 0 .../hawkbit/customstyles/table-common.scss | 0 .../hawkbit/customstyles/table-content.scss | 0 .../customstyles/table-header-common.scss | 0 .../themes/hawkbit/customstyles/table.scss | 0 .../themes/hawkbit/customstyles/tags.scss | 0 .../customstyles/target-filter-query.scss | 0 .../VAADIN/themes/hawkbit/hawkbittheme.scss | 1 - .../hawkbit/images/lightCorner_selected1.png | Bin .../themes/hawkbit/images/lightCorner_top.png | Bin .../hawkbit/images/profile-pic-300px.jpg | Bin .../hawkbit/images/profile-pic-57px.jpg | Bin .../VAADIN/themes/hawkbit/layouts/footer.html | 0 .../VAADIN/themes/hawkbit/styles.scss | 0 .../src/main/resources/messages.properties | 36 +- .../src/main/resources/messages_de.properties | 10 + .../src/main/resources/messages_en.properties | 36 +- ...ringSecurityAtmosphereInterceptorTest.java | 0 .../ui/utils/NamingThreadFactoryTest.java | 0 .../ui/utils/SPUIComponentProviderTest.java | 0 pom.xml | 45 +- sonarCircleCi.sh | 1 - 813 files changed, 9787 insertions(+), 4929 deletions(-) create mode 100644 .gitattributes create mode 100644 .gitignore mode change 100755 => 100644 3rd-dependencies/compile.txt mode change 100755 => 100644 3rd-dependencies/provided.txt mode change 100755 => 100644 3rd-dependencies/test.txt mode change 100755 => 100644 CONTRUBUTING.md mode change 100755 => 100644 DDIA.md create mode 100644 DMFA.md mode change 100755 => 100644 LICENCE_HEADER_TEMPLATE.txt mode change 100755 => 100644 README.md mode change 100755 => 100644 circle.yml mode change 100755 => 100644 eclipse_codeformatter.xml mode change 100755 => 100644 examples/README.md mode change 100755 => 100644 examples/hawkbit-device-simulator/.gitignore mode change 100755 => 100644 examples/hawkbit-device-simulator/README.md mode change 100755 => 100644 examples/hawkbit-device-simulator/pom.xml mode change 100755 => 100644 examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulator.java mode change 100755 => 100644 examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulationController.java mode change 100755 => 100644 examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpConfiguration.java mode change 100755 => 100644 examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java mode change 100755 => 100644 examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageHandlerCacheConstant.java mode change 100755 => 100644 examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageService.java mode change 100755 => 100644 examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/ReceiverService.java mode change 100755 => 100644 examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SenderService.java mode change 100755 => 100644 examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SimulatedUpdate.java mode change 100755 => 100644 examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java mode change 100755 => 100644 examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpSenderService.java mode change 100755 => 100644 examples/hawkbit-device-simulator/src/main/resources/application.properties mode change 100755 => 100644 examples/hawkbit-example-app/.gitignore mode change 100755 => 100644 examples/hawkbit-example-app/README.md mode change 100755 => 100644 examples/hawkbit-example-app/pom.xml mode change 100755 => 100644 examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/MyLoginUI.java mode change 100755 => 100644 examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/MyUI.java mode change 100755 => 100644 examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/Start.java mode change 100755 => 100644 examples/hawkbit-example-app/src/main/resources/application.properties create mode 100644 examples/hawkbit-mgmt-api-client/.gitignore create mode 100644 examples/hawkbit-mgmt-api-client/README.md create mode 100644 examples/hawkbit-mgmt-api-client/pom.xml create mode 100644 examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/api/client/DistributionSetResource.java create mode 100644 examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/api/client/DistrubutionSetTagResource.java create mode 100644 examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/api/client/TargetResource.java create mode 100644 examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/api/client/TargetTagResource.java create mode 100644 examples/hawkbit-mgmt-api-client/src/test/java/org/eclipse/hawkbit/mgmt/api/client/DistributionSetTagTest.java create mode 100644 examples/hawkbit-mgmt-api-client/src/test/java/org/eclipse/hawkbit/mgmt/api/client/TargetTagTest.java create mode 100644 examples/hawkbit-mgmt-api-client/src/test/java/org/eclipse/hawkbit/mgmt/api/client/TargetTest.java mode change 100755 => 100644 examples/pom.xml mode change 100755 => 100644 hawkbit-artifact-repository-mongo/README.md mode change 100755 => 100644 hawkbit-artifact-repository-mongo/pom.xml mode change 100755 => 100644 hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStore.java mode change 100755 => 100644 hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreAutoConfiguration.java mode change 100755 => 100644 hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/GridFsArtifact.java mode change 100755 => 100644 hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/MongoConfiguration.java mode change 100755 => 100644 hawkbit-artifact-repository-mongo/src/main/resources/META-INF/spring.factories mode change 100755 => 100644 hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/FreePortFileWriter.java mode change 100755 => 100644 hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/MongoDBTestRule.java mode change 100755 => 100644 hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/TestConfiguration.java mode change 100755 => 100644 hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreTest.java mode change 100755 => 100644 hawkbit-autoconfigure/pom.xml mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/amqp/AmqpAutoConfiguration.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/CacheAutoConfiguration.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/DownloadIdCacheAutoConfiguration.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/RedisAutoConfiguration.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/conf/ControllerPollAutoConfiguration.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/conf/DefaultPropertiesAutoConfiguration.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/eventbus/EventBusAutoConfiguration.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/AsyncConfigurerAutoConfiguration.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/AsyncConfigurerThreadpoolProperties.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/ExecutorAutoConfiguration.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/EnableHawkbitManagedSecurityConfiguration.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityAutoConfiguration.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java delete mode 100755 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/swagger/SwaggerApiDocAutoConfiguration.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/ui/UIAutoConfiguration.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/url/PropertyHostnameResolverAutoConfiguration.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/url/ServerProperties.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/web/ResourceControllerAutoConfiguration.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/web/WebMvcAutoConfiguration.java mode change 100755 => 100644 hawkbit-autoconfigure/src/main/resources/META-INF/spring.factories mode change 100755 => 100644 hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties mode change 100755 => 100644 hawkbit-cache-redis/pom.xml mode change 100755 => 100644 hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/RedisConfiguration.java mode change 100755 => 100644 hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/RedisProperties.java mode change 100755 => 100644 hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/annotation/EnableRedis.java mode change 100755 => 100644 hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/eventbus/EventDistributor.java mode change 100755 => 100644 hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/eventbus/EventDistributorTest.java mode change 100755 => 100644 hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/redis/RedisPropertiesTest.java mode change 100755 => 100644 hawkbit-core/pom.xml mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/ControllerPollProperties.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/DistributedResourceBundleMessageSource.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/api/HostnameResolver.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactRepository.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreException.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/HashNotMatchException.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/model/DbArtifact.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/model/DbArtifactHash.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/CacheConstants.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/DownloadArtifactCache.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/DownloadType.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/TenancyCacheManager.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/TenantAwareCacheManager.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/DeadEventListener.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/EventBusSubscriberProcessor.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/EventSubscriber.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractDistributedEvent.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/CancelTargetAssignmentEvent.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/CustomEvents.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributedEvent.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/DownloadProgressEvent.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/EntityEvent.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/Event.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/NodeAware.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetDeletedEvent.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/exception/GenericSpServerException.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/exception/SpServerError.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/exception/SpServerRtException.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/ActionFields.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/ActionStatusFields.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/DistributionSetFields.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/DistributionSetMetadataFields.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTypeFields.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/FieldNameProvider.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/FieldValueConverter.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleFields.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleMetadataFields.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleTypeFields.java create mode 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/TagFields.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/TargetFields.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/TenantAware.java mode change 100755 => 100644 hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/TenantConfigurationKey.java mode change 100755 => 100644 hawkbit-core/src/test/java/org/eclipse/hawkbit/eventbus/EventBusSubscriberProcessorTest.java mode change 100755 => 100644 hawkbit-dmf-amqp/pom.xml mode change 100755 => 100644 hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java mode change 100755 => 100644 hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentfication.java mode change 100755 => 100644 hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java mode change 100755 => 100644 hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java mode change 100755 => 100644 hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpProperties.java mode change 100755 => 100644 hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/annotation/EnableAmqp.java mode change 100755 => 100644 hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/util/ArtifactUrlHandler.java mode change 100755 => 100644 hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/util/ArtifactUrlHandlerProperties.java mode change 100755 => 100644 hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/util/PropertyBasedArtifactUrlHandler.java mode change 100755 => 100644 hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentficationTest.java mode change 100755 => 100644 hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java mode change 100755 => 100644 hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java mode change 100755 => 100644 hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/util/PropertyBasedArtifactUrlHandlerTest.java mode change 100755 => 100644 hawkbit-dmf-api/README.md mode change 100755 => 100644 hawkbit-dmf-api/pom.xml mode change 100755 => 100644 hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/amqp/api/AmqpSettings.java mode change 100755 => 100644 hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/amqp/api/EventTopic.java mode change 100755 => 100644 hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/amqp/api/MessageHeaderKey.java mode change 100755 => 100644 hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/amqp/api/MessageType.java mode change 100755 => 100644 hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionStatus.java mode change 100755 => 100644 hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionUpdateStatus.java mode change 100755 => 100644 hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/Artifact.java mode change 100755 => 100644 hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ArtifactHash.java mode change 100755 => 100644 hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DownloadAndUpdateRequest.java mode change 100755 => 100644 hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DownloadResponse.java mode change 100755 => 100644 hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/SoftwareModule.java mode change 100755 => 100644 hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/TenantSecruityToken.java mode change 100755 => 100644 hawkbit-http-security/pom.xml mode change 100755 => 100644 hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/AbstractHttpControllerAuthenticationFilter.java mode change 100755 => 100644 hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/ControllerTenantAwareAuthenticationDetailsSource.java mode change 100755 => 100644 hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/HttpControllerPreAuthenticateSecurityTokenFilter.java mode change 100755 => 100644 hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/HttpControllerPreAuthenticatedGatewaySecurityTokenFilter.java mode change 100755 => 100644 hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/HttpControllerPreAuthenticatedSecurityHeaderFilter.java mode change 100755 => 100644 hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/HttpDownloadAuthenticationFilter.java mode change 100755 => 100644 hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java mode change 100755 => 100644 hawkbit-repository/README.md mode change 100755 => 100644 hawkbit-repository/pom.xml mode change 100755 => 100644 hawkbit-repository/src/fbExcludeFilter.xml mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/Constants.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/RepositoryApplicationConfiguration.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/aspects/ExceptionMappingAspectHandler.java delete mode 100755 hawkbit-repository/src/main/java/org/eclipse/hawkbit/aspects/SpExceptionMappingAspect.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/cache/CacheField.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/cache/CacheKeys.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/cache/CacheWriteNotify.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/CacheFieldEntityListener.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/EntityChangeEventListener.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractBaseEntityEvent.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractEntityBulkEvent.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagAssigmentResultEvent.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagCreatedBulkEvent.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagDeletedEvent.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagUpdateEvent.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/EntityBulkEvent.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetAssignDistributionSetEvent.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetCreatedEvent.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetInfoUpdateEvent.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagAssigmentResultEvent.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagCreatedBulkEvent.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagDeletedEvent.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagUpdateEvent.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/executor/AfterTransactionCommitDefaultServiceExecutor.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/executor/AfterTransactionCommitExecutor.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/AbstractReportSeries.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/DataReportSeries.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/DataReportSeriesItem.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/InnerOuterDataReportSeries.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/ListReportSeries.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/SeriesTime.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/SystemUsageReport.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/TenantUsage.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionStatusRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/BaseEntityRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetFilter.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetMetadataRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTypeRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/EclipseLinkTargetInfoRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ExternalArtifactProviderRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ExternalArtifactRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/LocalArtifactRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/NoCountPagingRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ReportManagement.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleMetadataRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleTypeRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetInfoRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetTagRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetWithActionType.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantConfigurationRepository.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantKeyGenerator.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantMetaDataRepository.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantStatsManagement.java delete mode 100755 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/event/DeploymentManagementEvents.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactDeleteFailedException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactUploadFailedException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/CancelActionNotAllowedException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ConcurrentModificationException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/DistributionSetCreationFailedMissingMandatoryModuleException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/DistributionSetTypeUndefinedException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/EntityAlreadyExistsException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/EntityLockedException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/EntityNotFoundException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/EntityReadOnlyException.java create mode 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ForceQuitActionNotAllowedException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/GridFSDBFileNotFoundException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/IncompleteDistributionSetException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/InsufficientPermissionException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/InvalidMD5HashException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/InvalidSHA1HashException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/TenantNotExistException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ToManyAttributeEntriesException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ToManyStatusEntriesException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/UnsupportedSoftwareModuleForThisDistributionSetException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionStatus.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionWithStatusCount.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Artifact.java rename hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/{ => model}/AssignmentResult.java (96%) mode change 100755 => 100644 mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/BaseEntity.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/CustomSoftwareModule.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetIdName.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetMetadata.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTag.java rename hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/{ => model}/DistributionSetTagAssigmentResult.java (79%) mode change 100755 => 100644 mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTypeElement.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTypeElementCompositeKey.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DsMetadataCompositeKey.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifact.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifactProvider.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/LocalArtifact.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedEntity.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedVersionedEntity.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModule.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleIdName.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleMetadata.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SwMetadataCompositeKey.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Tag.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetFilterQuery.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetIdName.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetInfo.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetTag.java rename hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/{ => model}/TargetTagAssigmentResult.java (85%) mode change 100755 => 100644 mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetUpdateStatus.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantConfiguration.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantMetaData.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/CacheManagerHolder.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/PollConfigurationHelper.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/SecurityChecker.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/SecurityTokenGeneratorHolder.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/SystemManagementHolder.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/TenantAwareHolder.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/PropertyMapper.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLParameterSyntaxException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLParameterUnsupportedFieldException.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetSpecification.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetTypeSpecification.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/SoftwareModuleSpecification.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetFilterQuerySpecification.java mode change 100755 => 100644 hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetSpecifications.java mode change 100755 => 100644 hawkbit-repository/src/main/resources/db/migration/H2/V1_0_1__init___H2.sql mode change 100755 => 100644 hawkbit-repository/src/main/resources/db/migration/H2/V1_2_0__update_target_info_for_message___H2.sql mode change 100755 => 100644 hawkbit-repository/src/main/resources/db/migration/H2/V1_4_0__cascade_delete___H2.sql mode change 100755 => 100644 hawkbit-repository/src/main/resources/db/migration/H2/V1_4_1__cascade_delete___H2.sql mode change 100755 => 100644 hawkbit-repository/src/main/resources/db/migration/H2/V1_5_0__target_filter_query___H2.sql mode change 100755 => 100644 hawkbit-repository/src/main/resources/db/migration/MYSQL/V1_0_1__init___MYSQL.sql mode change 100755 => 100644 hawkbit-repository/src/main/resources/db/migration/MYSQL/V1_2_0__update_target_info_for_message___MYSQL.sql mode change 100755 => 100644 hawkbit-repository/src/main/resources/db/migration/MYSQL/V1_4_0__cascade_delete___MYSQL.sql mode change 100755 => 100644 hawkbit-repository/src/main/resources/db/migration/MYSQL/V1_4_1__cascade_delete___MYSQL.sql mode change 100755 => 100644 hawkbit-repository/src/main/resources/db/migration/MYSQL/V1_5_0__target_filter_query___MYSQL.sql mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTestWithMongoDB.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/CIMySqlTestDatabase.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/FreePortFileWriter.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/HashGeneratorUtils.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/LocalH2TestDatabase.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/MethodSecurityUtil.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/RandomGeneratedInputStream.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestConfiguration.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/Testdatabase.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/WithSpringAuthorityRule.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/WithUser.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/cache/CacheKeysTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/cache/CacheWriteNotifyTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/eventbus/CacheFieldEntityListenerTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ActionTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementNoMongoDbTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ControllerManagementTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementForDSTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SystemManagementTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagenmentTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementSearchTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/utils/RepositoryDataGenerator.java mode change 100755 => 100644 hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java mode change 100755 => 100644 hawkbit-repository/src/test/resources/application-test.properties mode change 100755 => 100644 hawkbit-rest-api/pom.xml rename {hawkbit-rest-resource => hawkbit-rest-api}/src/main/java/org/eclipse/hawkbit/rest/resource/RestConstants.java (89%) mode change 100755 => 100644 mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/BaseEntityRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfo.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/IdRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/MetadataRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/MetadataRestPageList.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/NamedEntityRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PagedList.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PollStatusRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionPagedList.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionStatusPagedList.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionStatusRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionStatussRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionsRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactHash.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactsRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/ActionTypeRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetPagedList.java rename hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/{DistributionSetRequestBodyCreate.java => DistributionSetRequestBodyPost.java} (74%) mode change 100755 => 100644 rename hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/{DistributionSetRequestBodyUpdate.java => DistributionSetRequestBodyPut.java} (71%) mode change 100755 => 100644 mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetsRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/TargetAssignmentRequestBody.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/TargetAssignmentResponseBody.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypePagedList.java rename hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/{DistributionSetTypeRequestBodyCreate.java => DistributionSetTypeRequestBodyPost.java} (66%) mode change 100755 => 100644 rename hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/{DistributionSetTypeRequestBodyUpdate.java => DistributionSetTypeRequestBodyPut.java} (73%) mode change 100755 => 100644 mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypesRest.java delete mode 100755 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/doc/ApiModelProperties.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleAssigmentRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModulePagedList.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRequestBodyPost.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRequestBodyPut.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModulesRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeAssigmentRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypePagedList.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRequestBodyPost.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRequestBodyPut.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypesRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/CacheRest.java create mode 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/SystemStatisticsRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/TenantConfigurationRest.java create mode 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/TenantSystemUsageRest.java create mode 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/AssignedDistributionSetRequestBody.java create mode 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/AssignedTargetRequestBody.java create mode 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/DistributionSetTagAssigmentResultRest.java create mode 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagPagedList.java create mode 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagRequestBodyPut.java create mode 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagRest.java create mode 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagsRest.java create mode 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TargetTagAssigmentResultRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/DistributionSetAssigmentRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetAttributes.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetPagedList.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetRequestBody.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetRest.java mode change 100755 => 100644 hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetsRest.java mode change 100755 => 100644 hawkbit-rest-resource/pom.xml mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/cache/CacheWriteNotify.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/ArtifactStoreController.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/ControllerConstants.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/DataConversionHelper.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/EnableDirectDeviceApi.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/FileSteamingFailedException.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/ActionFeedback.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Artifact.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Cancel.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/CancelActionToStop.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Chunk.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Config.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/ConfigData.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/ControllerBase.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Deployment.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/DeploymentBase.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Polling.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Progress.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Result.java delete mode 100755 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/SoftwareModule.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Status.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetMapper.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetResource.java create mode 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTagResource.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeMapper.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResource.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DownloadResource.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/EnableRestResources.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/MessageNotReadableException.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/OffsetBasedPageRequest.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/PagingUtility.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/ResponseExceptionHandler.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/RestModelMapper.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleMapper.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeMapper.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResource.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortDirection.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterSyntaxErrorException.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterUnsupportedDirectionException.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterUnsupportedFieldException.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortUtility.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemManagementResource.java create mode 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TagMapper.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetMapper.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java create mode 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetTagResource.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/helper/ByteRange.java mode change 100755 => 100644 hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/helper/RestResourceConversionHelper.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/MockMvcResultPrinter.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ArtifactDownloadTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/CancelActionTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ConfigDataTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/DeploymentBaseTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/RootControllerTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetResourceTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResourceTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DownloadResourceTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/JsonBuilder.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RSQLUtilityTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/ResourceUtility.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SMRessourceMisingMongoDbConnectionTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResourceTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SortUtilityTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SystemManagementResourceTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/PagedListTest.java mode change 100755 => 100644 hawkbit-rest-resource/src/test/resources/application-test.properties create mode 100644 hawkbit-rest-resource/src/test/resources/log4j2.xml mode change 100755 => 100644 hawkbit-security-core/pom.xml mode change 100755 => 100644 hawkbit-security-core/src/main/java/org/eclipse/hawkbit/ExcludePathAwareShallowETagFilter.java mode change 100755 => 100644 hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/MultitenancyIndicator.java mode change 100755 => 100644 hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/PermissionService.java mode change 100755 => 100644 hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/SpPermission.java mode change 100755 => 100644 hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/TenantAwareAuthenticationDetails.java mode change 100755 => 100644 hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/TenantUserPasswordAuthenticationToken.java mode change 100755 => 100644 hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/UserAuthenticationFilter.java mode change 100755 => 100644 hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/UserPrincipal.java mode change 100755 => 100644 hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/DosFilter.java mode change 100755 => 100644 hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityContextTenantAware.java mode change 100755 => 100644 hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityProperties.java mode change 100755 => 100644 hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityTokenGenerator.java mode change 100755 => 100644 hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SpringSecurityAuditorAware.java mode change 100755 => 100644 hawkbit-security-core/src/main/java/org/eclipse/hawkbit/util/IpUtil.java mode change 100755 => 100644 hawkbit-security-core/src/main/java/org/eclipse/hawkbit/util/SPInfo.java mode change 100755 => 100644 hawkbit-security-core/src/test/java/org/eclipse/hawkbit/ExcludePathAwareShallowETagFilterTest.java mode change 100755 => 100644 hawkbit-security-core/src/test/java/org/eclipse/hawkbit/security/SecurityTokenGeneratorTest.java mode change 100755 => 100644 hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java mode change 100755 => 100644 hawkbit-security-integration/pom.xml mode change 100755 => 100644 hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/AbstractControllerAuthenticationFilter.java mode change 100755 => 100644 hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/CoapAnonymousPreAuthenticatedFilter.java mode change 100755 => 100644 hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticateSecurityTokenFilter.java mode change 100755 => 100644 hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedGatewaySecurityTokenFilter.java mode change 100755 => 100644 hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilter.java mode change 100755 => 100644 hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/HeaderAuthentication.java mode change 100755 => 100644 hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProvider.java mode change 100755 => 100644 hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/PreAuthenficationFilter.java mode change 100755 => 100644 hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/TenantAwareWebAuthenticationDetails.java mode change 100755 => 100644 hawkbit-test-report/placeholder.txt mode change 100755 => 100644 hawkbit-test-report/pom.xml mode change 100755 => 100644 hawkbit-test-report/src/main/assembly/test-report.xml mode change 100755 => 100644 hawkbit-ui/.gitignore mode change 100755 => 100644 hawkbit-ui/pom.xml mode change 100755 => 100644 hawkbit-ui/src/main/.gitignore mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/push/AsyncVaadinServletConfiguration.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/push/SpringSecurityAtmosphereInterceptor.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/repository/OffsetBasedPageRequest.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/repository/SpPermissionChecker.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/AppWidgetSet.gwt.xml mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/DefaultHawkbitUI.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/DispatcherRunnable.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/ErrorView.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactView.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactViewMenuItem.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactBeanQuery.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/ArtifactDetailsEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/SMFilterEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/SoftwareModuleEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/SoftwareModuleTypeEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/UploadArtifactUIEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/UploadViewAcceptCriteria.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/UploadViewConfirmationWindowLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/ProxyBaseSoftwareModuleItem.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleDetails.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTableHeader.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTableLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterButtonClick.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterButtons.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterHeader.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadState.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/CustomFile.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/SoftwareModuleFilters.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadConfirmationwindow.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadResultWindow.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadStatus.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadStatusInfoWindow.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/AbstractAcceptCriteria.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/ConfirmationDialog.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/CoordinatesToColor.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/DistributionSetTypeBeanQuery.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/SoftwareModuleTypeBeanQuery.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/confirmwindow/layout/AbstractConfirmationWindowLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/confirmwindow/layout/ConfirmationTab.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/confirmwindow/layout/ConfirmationWindowEvents.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterButtonClickBehaviour.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterButtons.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterHeader.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterMultiButtonClick.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterSingleButtonClick.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/footer/AbstractDeleteActionsLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTableHeader.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTableLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTagToken.java create mode 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTargetTagToken.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/TargetTagToken.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/DistributionSetInfoPanel.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyDistribution.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTargetFilter.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPNotificationMessage.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPTargetAttributesLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIButton.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUICheckBox.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIErrorHandler.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIHorizontalLayout.java delete mode 100755 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUINotifcation.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUITabSheet.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUITableHorizonatlLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIUpdateLogLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonDecorator.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleLargeIconNoBorder.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStylePrimarySmall.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmall.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorder.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorderUH.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorderUHS.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleTiny.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIComboBoxDecorator.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIEmbedDecorator.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIEmbedValue.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIHeaderLayoutDecorator.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUILabelDecorator.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUITagButtonStyle.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUITextAreaDecorator.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUITextFieldDecorator.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIWindowDecorator.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsView.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsViewMenuItem.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterButtonClick.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterButtons.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterHeader.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/DistributionSetTypeEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/DistributionsUIEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/DistributionsViewAcceptCriteria.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/DragEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/SaveActionWindowEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/SoftwareModuleAssignmentDiscardEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/SwModuleUIEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DSDeleteActionsLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DistributionsConfirmationWindowLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/ProxyBaseSwModuleItem.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleDetails.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTableHeader.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTableLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtonClick.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtons.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterHeader.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageDistFilters.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageDistUIState.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageSoftwareModuleFilters.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/documentation/DocumentationPageLink.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/documentation/DocumentationUtil.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/FilterExpression.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/Filters.java create mode 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/target/CustomTargetFilter.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/target/TargetSearchTextFilter.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/target/TargetStatusFilter.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/target/TargetTagFilter.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterManagementView.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterManagementViewMenuItem.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterQueryValidation.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterHeader.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TokenDescription.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/ValidationResult.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/event/CustomFilterUIEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/state/FilterManagementUIState.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/login/HawkbitLoginUI.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/login/LoginView.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentViewMenuItem.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryComponent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryHeader.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtonClick.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagHeader.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagLayout.java create mode 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/BulkUploadPopupEvent.java create mode 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/BulkUploadValidationMessageEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTableEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTableFilterEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagDropEvent.java delete mode 100755 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DragEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/ManagementUIEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/ManagementViewAcceptCriteria.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/PinUnpinEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/SaveActionWindowEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetAddUpdateWindowEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetFilterEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetTableEvent.java delete mode 100755 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetTagEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ActionTypeOptionGroupLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/CountMessageLabel.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java create mode 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayoutHelper.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/DistributionTableFilters.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/ManagementUIState.java create mode 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetBulkUpload.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetFilterParameters.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetTableFilters.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/ProxyTag.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/SpColorPickerPreview.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/TagIdName.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkTokenTags.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetDetails.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/AbstractTargetTagFilterLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CustomTargetTagFilterButtonClick.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/FilterByStatusLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/MultipleTargetFilter.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetFilterQueryButtons.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagBeanQuery.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtonClick.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterHeader.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardEvent.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenuItem.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/AuthenticationConfigurationView.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/ConfigurationGroup.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/DefaultDistributionSetTypeLayout.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/TenantConfigurationDashboardView.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/TenantConfigurationDashboardViewMenuItem.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/AbstractAuthenticationTenantConfigurationItem.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/CertificateAuthenticationConfigurationItem.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/GatewaySecurityTokenAuthenticationConfigurationItem.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/TargetSecurityTokenAuthenticationConfigurationItem.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/TenantConfigurationItem.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/themes/HawkbitTheme.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/I18N.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/NamingThreadFactory.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/NotificationMessage.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIButtonDefinitions.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponetIdProvider.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUILabelDefinitions.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIStyleDefinitions.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUITargetDefinitions.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SpringContextHelper.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/TableColumn.java mode change 100755 => 100644 hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/UINotification.java mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/.gitignore mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/.gitignore mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/accordion.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/action-history.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/artifact-upload.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/colorpicker.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/common.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/dashboardview.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/drop-hint.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/filter-layout-styles.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/filter-status.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/footer-common.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/generic-styles.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/hawkbitvariables.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/login.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/others.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/popup-common.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/popup-window.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/systemconfig.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-common.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-content.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-header-common.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/tags.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/target-filter-query.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/images/lightCorner_selected1.png mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/images/lightCorner_top.png mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/images/profile-pic-300px.jpg mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/images/profile-pic-57px.jpg mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/layouts/footer.html mode change 100755 => 100644 hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/styles.scss mode change 100755 => 100644 hawkbit-ui/src/main/resources/messages.properties mode change 100755 => 100644 hawkbit-ui/src/main/resources/messages_de.properties mode change 100755 => 100644 hawkbit-ui/src/main/resources/messages_en.properties mode change 100755 => 100644 hawkbit-ui/src/test/java/org/eclipse/hawkbit/push/SpringSecurityAtmosphereInterceptorTest.java mode change 100755 => 100644 hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/NamingThreadFactoryTest.java mode change 100755 => 100644 hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/SPUIComponentProviderTest.java mode change 100755 => 100644 pom.xml mode change 100755 => 100644 sonarCircleCi.sh diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..0825468a3 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,10 @@ +* text eol=lf +# Denote all files that are truly binary and should not be modified. +*.png binary +*.jpg binary +*.pdf binary +*.PNG binary +*.pptx binary +*.eot binary +*.ttf binary +*.woff binary diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..dad7bec10 --- /dev/null +++ b/.gitignore @@ -0,0 +1,50 @@ +# Directories # +/build/ +/*/build/ +/bin/ +/*/bin/ +/target/ +/*/target/ +/*/*/target/ + +# OS Files # +.DS_Store + +*.class + +# Package Files # +*.jar +*.war + +# Eclipse IDE + +*.pydevproject +.project +.metadata +bin/** +tmp/** +tmp/**/* +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + +# Maven +maven.properties +/*/maven.properties diff --git a/3rd-dependencies/compile.txt b/3rd-dependencies/compile.txt old mode 100755 new mode 100644 diff --git a/3rd-dependencies/provided.txt b/3rd-dependencies/provided.txt old mode 100755 new mode 100644 diff --git a/3rd-dependencies/test.txt b/3rd-dependencies/test.txt old mode 100755 new mode 100644 diff --git a/CONTRUBUTING.md b/CONTRUBUTING.md old mode 100755 new mode 100644 diff --git a/DDIA.md b/DDIA.md old mode 100755 new mode 100644 diff --git a/DMFA.md b/DMFA.md new file mode 100644 index 000000000..6653f3d9f --- /dev/null +++ b/DMFA.md @@ -0,0 +1,127 @@ +# !!! DRAFT !!! # +# Device Management Federation API # + +This document describes the **DMF API**. This API is based on AMQP [(AMQP-Specification)](ht1tp://www.amqp.org/sites/amqp.org/files/amqp.pdf "AMQP-Specification"). The SP Update server provides a message queue (default: "*dmf_receiver*") on the corresponding Rabbit MQ service, which accepts all incoming messages. + +Every Service, which wants to communicate, has to offer a own queue, to which the SP update server can send messages. The name of this queue is sent + +## Authentication ## +??? + +## Regular update process ## + +### Step 1: Creating a Thing on SP ### + +At the beginning every connecting service has to register its targets at the Sp update server. During the creating process the service has to send the name of the queue, which accepts messages, which are sent back from the Sp update server. + +The message which is sent by the connecting service to the SP update service has to fulfill the following format. The connecting service has to set the attributes in the header. The name of the tenent (*tenant*, an unique identifier of the thing/target (*thingId*) and an string which identifies the sending service (*sender*). Furthermore it has to set the *replyTo*-Property which defines the name of the queue, which receives messages sent by the SP Update Server. The body of the message is not analyzed and can be empty. + +**Header** +
+type=THING_CREATED
+tenant=#TENANTNAME#
+thingId=#ExampleDevice001#
+sender=#CONNECTORSERVICE#
+
+**Properties** +
+contentType=application/json
+replyTo=#queue.which.accepts.messages.from.sp#
+
+**Example Body** +
 
+ +### Step 2: Begin of update process ### +Afterwards an distribution set can be assigned to the created thing. This can be done on the UI or with the REST API. To start the update process the SP update server sends a message over the registered queue back to the connecting service. + +Inside the message send from the Sp update service the header specifies the target which has to be updated. Therefor the *tenent* and the unique *thingId* are used. The body contains an identifier which defines the update process (*actionId*) and the information of the software modules. The *actionId* is important to send the progress of the update process to the server. The information about the software describes all modules which are included in the current update process, their identifier, their type, their version and the corresponding artifacts with the urls where the target can download the artifacts. + +**Header** +
+type=EVENT 
+tenant=#TENANTNAME#
+thingId=#ExampleDevice001#
+topic=DOWNLOAD_AND_INSTALL
+
+**Properties** +
+contentType=application/json
+
+**Example Body** +
+{
+"actionId":172,
+"softwareModules":[
+    {
+    "moduleId":6,
+    "moduleType":"firmware",
+    "moduleVersion":"7.7.7",
+    "artifacts":[
+        {
+        "urls":{
+            "coap":"coap://bumlux.test",
+            "http":"coap://bumlux.test"}
+        }]
+    }]
+}
+
+ +### Step 3: Sending the state update process ### + +During the update progress the connected service can inform the sp update service about the progress and eventual warnings or errors. Therefore the *actionId* and the *softwareModuleId* are used to specify for which process and for which software module the progress update is for. Additionally in the Body there is a field *actionStatus*. This field is used to describe the type of the progress update and there are several allowed values: + +- **RETRIEVED**: general acknowledge message +- **DOWNLOAD**: describes all messages related to the download prorgess +- **RUNNING**: +- **WARNING**: A smaller problem which influence the update process, but no need for stop it. +- **ERROR**: A big issues which not allows continuing the update process. +- **FINISHED**: Successfully finished the update process. +- **CANCELED**: Response to a cancel request, when the process is canceled. +- **CANCEL_REJECTED**: Response to a cancel request, when canceling is not possible. + +The update process is marked as running until the connected Server sends a **FINISHED**, an **ERROR** or a **CANCELED** message. Additionally the connected service can put some human readable information into the message, which describes the state of the action more detailed. + +**Header** +
+type=EVENT 
+tenant=#TENANTNAME#
+topic=UPDATE_ACTION_STATUS
+
+**Properties** +
+contentType=application/json
+
+**Example Body** + +
+{
+"actionId":115,
+"softwareModuleId":3,
+"actionStatus":"DOWNLOAD",
+"message":["The download has started"]
+}
+
+ +## Cancel process ## + +During the update process the SP update server has the chance to cancel an update. Therefore it sends the following message. This message includes the *tenant* and the corresponding *thingId* on theheader. + +**Header** +
+type=EVENT
+tenant=#TENANTNAME#
+thingId=#ExampleDevice001#
+topic=CANCEL_DOWNLOAD 
+
+**Properties** +
+contentType=application/json
+
+**Example Body** +
+
+
+ +Receiving this message the connected service has to decide if an update can be canceled or not. If it is the update has to be canceled and a **CANCELED** message has to be sent to the SP server. Otherwise a **CANCEL_REJECTED** message has to be sent. + + ![](src/images/dmfa_cancel_response.png) \ No newline at end of file diff --git a/LICENCE_HEADER_TEMPLATE.txt b/LICENCE_HEADER_TEMPLATE.txt old mode 100755 new mode 100644 diff --git a/README.md b/README.md old mode 100755 new mode 100644 index f6d1e03c7..52b7e848d --- a/README.md +++ b/README.md @@ -33,4 +33,4 @@ mvn install # Device Integration There are two device integration APIs provided by the hawkbit update server. * [Direct Device Integration API (HTTP)](DDIA.md) -* Device Management Federation API (AMQP) +* [Device Management Federation API (AMQP)](DMFA.md) diff --git a/circle.yml b/circle.yml old mode 100755 new mode 100644 diff --git a/eclipse_codeformatter.xml b/eclipse_codeformatter.xml old mode 100755 new mode 100644 diff --git a/examples/README.md b/examples/README.md old mode 100755 new mode 100644 diff --git a/examples/hawkbit-device-simulator/.gitignore b/examples/hawkbit-device-simulator/.gitignore old mode 100755 new mode 100644 diff --git a/examples/hawkbit-device-simulator/README.md b/examples/hawkbit-device-simulator/README.md old mode 100755 new mode 100644 index caa86c3c0..b5db3d7ef --- a/examples/hawkbit-device-simulator/README.md +++ b/examples/hawkbit-device-simulator/README.md @@ -11,8 +11,29 @@ Or: run org.eclipse.hawkbit.simulator.DeviceSimulator ``` +## Notes + +The simulator has user authentication enabled by default. Default credentials: +* username : admin +* passwd : admin + +This can be configured/disabled by spring boot properties + ## Usage The device simulator exposes an REST-API which can be used to trigger device creation. + +Optional parameters: +* name : name prefix simulated devices (default: "dmfSimulated"), followed by counter +* amount : number of simulated devices (default: 20, capped at: 4000) +* tenant : in a multi-tenenat ready hawkBit installation (default: "DEFAULT") + + +Example: for 20 simulated devices (default) ``` -http://localhost:8083/start?amount=10 +http://localhost:8083/start +``` + +Example: for 10 simulated devices that start with the name prefix "activeSim": +``` +http://localhost:8083/start?amount=10&name=activeSim ``` diff --git a/examples/hawkbit-device-simulator/pom.xml b/examples/hawkbit-device-simulator/pom.xml old mode 100755 new mode 100644 index 4bc38985e..9e9fc86dc --- a/examples/hawkbit-device-simulator/pom.xml +++ b/examples/hawkbit-device-simulator/pom.xml @@ -9,53 +9,81 @@ http://www.eclipse.org/legal/epl-v10.html --> + + 4.0.0 + + org.eclipse.hawkbit + 0.1.0-SNAPSHOT + hawkbit-examples-parent + - - 4.0.0 - - org.eclipse.hawkbit - 0.1.0-SNAPSHOT - hawkbit-examples-parent - + hawkbit-device-simulator + hawkBit :: Device Simulator + Device Management Federation API based simulator - hawkbit-device-simulator - hawkBit :: Device Simulator - Device Management Federation API based simulator + + + + org.springframework.boot + spring-boot-maven-plugin + + + + repackage + + + ${baseDir} + false + org.eclipse.hawkbit.simulator.DeviceSimulator + JAR + + + + + + - - - org.eclipse.hawkbit - hawkbit-dmf-api - ${project.version} - - - org.springframework.amqp - spring-rabbit - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-logging - - - - - org.springframework.boot - spring-boot-starter-log4j2 - - - org.springframework.boot - spring-boot-autoconfigure - - + + + org.eclipse.hawkbit + hawkbit-dmf-api + ${project.version} + + + org.springframework.amqp + spring-rabbit + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.security + spring-security-web + + + org.springframework.security + spring-security-config + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-logging + + + + + org.springframework.boot + spring-boot-starter-log4j2 + + + org.springframework.boot + spring-boot-autoconfigure + + diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulator.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulator.java old mode 100755 new mode 100644 index aa74665dc..37812a19d --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulator.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/DeviceSimulator.java @@ -20,6 +20,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class DeviceSimulator { + private DeviceSimulator() { + // utility class + } + /** * Start the Spring Boot Application. * diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulationController.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/SimulationController.java old mode 100755 new mode 100644 diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpConfiguration.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpConfiguration.java old mode 100755 new mode 100644 index b99f24800..c4968c849 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpConfiguration.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpConfiguration.java @@ -48,7 +48,7 @@ public class AmqpConfiguration { /** * Create jackson message converter bean. - * + * * @return the jackson message converter */ @Bean @@ -60,7 +60,7 @@ public class AmqpConfiguration { /** * Create the receiver queue from sp. Receive messages from sp. - * + * * @return the queue */ @Bean @@ -71,7 +71,7 @@ public class AmqpConfiguration { /** * Create the recevier exchange. Sp send messages to this exchange. - * + * * @return the exchange */ @Bean @@ -83,7 +83,7 @@ public class AmqpConfiguration { * Create the Binding * {@link AmqpConfiguration#receiverConnectorQueueFromSp()} to * {@link AmqpConfiguration#exchangeQueueToConnector()}. - * + * * @return the binding and create the queue and exchange */ @Bean @@ -93,7 +93,7 @@ public class AmqpConfiguration { /** * Create dead letter queue. - * + * * @return the queue */ @Bean @@ -103,7 +103,7 @@ public class AmqpConfiguration { /** * Create the dead letter fanout exchange. - * + * * @return the fanout exchange */ @Bean @@ -113,7 +113,7 @@ public class AmqpConfiguration { /** * Create the Binding deadLetterQueue to exchangeDeadLetter. - * + * * @return the binding */ @Bean @@ -123,7 +123,7 @@ public class AmqpConfiguration { /** * Returns the Listener factory. - * + * * @return the {@link SimpleMessageListenerContainer} that gets used receive * AMQP messages */ @@ -136,7 +136,7 @@ public class AmqpConfiguration { } private Map getDeadLetterExchangeArgs() { - final Map args = new HashMap(); + final Map args = new HashMap<>(); args.put("x-dead-letter-exchange", amqpProperties.getDeadLetterExchange()); return args; } diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/AmqpProperties.java old mode 100755 new mode 100644 diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageHandlerCacheConstant.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageHandlerCacheConstant.java old mode 100755 new mode 100644 diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageService.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/MessageService.java old mode 100755 new mode 100644 diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/ReceiverService.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/ReceiverService.java old mode 100755 new mode 100644 diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SenderService.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SenderService.java old mode 100755 new mode 100644 index e8b82b6f0..6ed6ff0cb --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SenderService.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SenderService.java @@ -11,6 +11,7 @@ package org.eclipse.hawkbit.simulator.amqp; import org.springframework.amqp.core.Message; import org.springframework.amqp.core.MessageProperties; import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.amqp.support.converter.AbstractJavaTypeMapper; import org.springframework.beans.factory.annotation.Autowired; /** @@ -48,6 +49,7 @@ public abstract class SenderService extends MessageService { if (message == null) { return; } + message.getMessageProperties().getHeaders().remove(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME); rabbitTemplate.setExchange(adress); rabbitTemplate.send(message); } diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SimulatedUpdate.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SimulatedUpdate.java old mode 100755 new mode 100644 diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java old mode 100755 new mode 100644 index 3cf8891f0..5884a2645 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpReceiverService.java @@ -131,11 +131,23 @@ public class SpReceiverService extends ReceiverService { DownloadAndUpdateRequest.class); final Long actionId = downloadAndUpdateRequest.getActionId(); + try { + Thread.sleep(1_000); + } catch (final InterruptedException e) { + LOGGER.error("Sleep interrupted", e); + } + spSenderService.sendActionStatusMessage(tenant, ActionStatus.RUNNING, "device Simulator retrieved update request. proceeding with simulation.", actionId); final SimulatedUpdate update = new SimulatedUpdate(tenant, thingId, actionId); + try { + Thread.sleep(1_000); + } catch (final InterruptedException e) { + LOGGER.error("Sleep interrupted", e); + } + spSenderService.finishUpdateProcess(update, "Simulation complete!"); } diff --git a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpSenderService.java b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpSenderService.java old mode 100755 new mode 100644 index 1a66c2aa1..2358bf013 --- a/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpSenderService.java +++ b/examples/hawkbit-device-simulator/src/main/java/org/eclipse/hawkbit/simulator/amqp/SpSenderService.java @@ -216,9 +216,7 @@ public class SpSenderService extends SenderService { private Message createActionStatusMessage(final SimulatedUpdate update, final String messageDescription, final ActionStatus status) { - final Message sendMessage = createActionStatusMessage(update.getTenant(), status, messageDescription, - update.getActionId()); - return sendMessage; + return createActionStatusMessage(update.getTenant(), status, messageDescription, update.getActionId()); } } diff --git a/examples/hawkbit-device-simulator/src/main/resources/application.properties b/examples/hawkbit-device-simulator/src/main/resources/application.properties old mode 100755 new mode 100644 index eaac2999e..19dd2cb77 --- a/examples/hawkbit-device-simulator/src/main/resources/application.properties +++ b/examples/hawkbit-device-simulator/src/main/resources/application.properties @@ -12,7 +12,7 @@ # PUBLIC configuration, i.e. can be changed by users at runtime (defaults provided here) ######################################################################################### ## Configuration for RabbitMQ communication -hawkbit.device.simulator.amqp.receiverConnectorQueueFromSp=sp_connector_receiver +hawkbit.device.simulator.amqp.receiverConnectorQueueFromSp=simulator_receiver hawkbit.device.simulator.amqp.deadLetterQueue=simulator_deadletter hawkbit.device.simulator.amqp.deadLetterExchange=simulator.deadletter hawkbit.device.simulator.amqp.senderForSpExchange=simulator.replyTo @@ -27,58 +27,6 @@ spring.rabbitmq.port=5672 spring.rabbitmq.dynamic=true -#disable expose jmx beans -spring.jmx.enabled=false -# the context path of the monitor spring actuator which offers following endpoints -# /autoconfig, /beans, /configprops, /dump, /env, /health, /info, /metrics, /mappings, /trace -management.context-path=/system -management.security.enabled=true -management.security.sessions=stateless -# ENDPOINTS -endpoints.autoconfig.id=autoconfig -endpoints.autoconfig.sensitive=true -endpoints.autoconfig.enabled=false -endpoints.beans.id=beans -endpoints.beans.sensitive=true -endpoints.beans.enabled=false -endpoints.configprops.id=configprops -endpoints.configprops.sensitive=true -endpoints.configprops.enabled=true -#endpoints.configprops.keys-to-sanitize=password,secret,key # suffix or regex -endpoints.dump.id=dump -endpoints.dump.sensitive=true -endpoints.dump.enabled=false -endpoints.env.id=env -endpoints.env.sensitive=true -endpoints.env.enabled=true -#endpoints.env.keys-to-sanitize=password,secret,key # suffix or regex -endpoints.health.id=health -endpoints.health.sensitive=true -endpoints.health.enabled=true -endpoints.info.id=info -endpoints.info.sensitive=true -endpoints.info.enabled=true -endpoints.metrics.id=metrics -endpoints.metrics.sensitive=true -endpoints.metrics.enabled=true -endpoints.shutdown.id=shutdown -endpoints.shutdown.sensitive=true -endpoints.shutdown.enabled=false -endpoints.trace.id=trace -endpoints.trace.sensitive=true -endpoints.trace.enabled=true - -# HEALTH INDICATORS (previously health.*) -management.health.db.enabled=true -management.health.diskspace.enabled=true -management.health.mongo.enabled=true -management.health.rabbit.enabled=true -management.health.redis.enabled=false -management.health.solr.enabled=false -management.health.diskspace.path=. -management.health.diskspace.threshold=10485760 -management.health.status.order=DOWN, OUT_OF_SERVICE, UNKNOWN, UP - # SECURITY (SecurityProperties) security.user.name=${BASIC_USERNAME:admin} security.user.password=${BASIC_PASSWORD:admin} @@ -87,7 +35,7 @@ security.require-ssl=false security.enable-csrf=false security.basic.enabled=true security.basic.realm=DeviceSimulator -security.basic.path= /system/** +security.basic.path= /** security.basic.authorize-mode=ROLE security.filter-order=0 security.headers.xss=false diff --git a/examples/hawkbit-example-app/.gitignore b/examples/hawkbit-example-app/.gitignore old mode 100755 new mode 100644 diff --git a/examples/hawkbit-example-app/README.md b/examples/hawkbit-example-app/README.md old mode 100755 new mode 100644 diff --git a/examples/hawkbit-example-app/pom.xml b/examples/hawkbit-example-app/pom.xml old mode 100755 new mode 100644 index ed4403cc5..cd238945a --- a/examples/hawkbit-example-app/pom.xml +++ b/examples/hawkbit-example-app/pom.xml @@ -48,6 +48,11 @@ hawkbit-autoconfigure ${project.version} + + org.eclipse.hawkbit + hawkbit-rest-resource + ${project.version} + org.eclipse.hawkbit hawkbit-dmf-amqp @@ -92,10 +97,6 @@ org.springframework.security spring-security-aspects - - io.springfox - springfox-swagger2 - com.h2database h2 diff --git a/examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/MyLoginUI.java b/examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/MyLoginUI.java old mode 100755 new mode 100644 diff --git a/examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/MyUI.java b/examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/MyUI.java old mode 100755 new mode 100644 diff --git a/examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/Start.java b/examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/Start.java old mode 100755 new mode 100644 index b87b53fef..a517dbb08 --- a/examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/Start.java +++ b/examples/hawkbit-example-app/src/main/java/org/eclipse/hawkbit/app/Start.java @@ -10,25 +10,27 @@ package org.eclipse.hawkbit.app; import org.eclipse.hawkbit.RepositoryApplicationConfiguration; import org.eclipse.hawkbit.autoconfigure.security.EnableHawkbitManagedSecurityConfiguration; +import org.eclipse.hawkbit.controller.EnableDirectDeviceApi; +import org.eclipse.hawkbit.rest.resource.EnableRestResources; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Import; /** - * A {@link SpringBootApplication} annoated class with a main method to start. - * The minimal configuration for the standalone hawkBit server. - * - * + * A {@link SpringBootApplication} annotated class with a main method to start. + * The minimal configuration for the stand alone hawkBit server. * */ @SpringBootApplication @Import({ RepositoryApplicationConfiguration.class }) @EnableHawkbitManagedSecurityConfiguration +@EnableRestResources +@EnableDirectDeviceApi public class Start { /** * Main method to start the spring-boot application. - * + * * @param args * the VM arguments. */ diff --git a/examples/hawkbit-example-app/src/main/resources/application.properties b/examples/hawkbit-example-app/src/main/resources/application.properties old mode 100755 new mode 100644 diff --git a/examples/hawkbit-mgmt-api-client/.gitignore b/examples/hawkbit-mgmt-api-client/.gitignore new file mode 100644 index 000000000..0f630157f --- /dev/null +++ b/examples/hawkbit-mgmt-api-client/.gitignore @@ -0,0 +1,2 @@ +/target/ +/bin/ diff --git a/examples/hawkbit-mgmt-api-client/README.md b/examples/hawkbit-mgmt-api-client/README.md new file mode 100644 index 000000000..7eb32f9e6 --- /dev/null +++ b/examples/hawkbit-mgmt-api-client/README.md @@ -0,0 +1,3 @@ +Example client that shows how to efficiently use the hawkBit management API. + +Powered by [Feign](https://github.com/Netflix/feign). \ No newline at end of file diff --git a/examples/hawkbit-mgmt-api-client/pom.xml b/examples/hawkbit-mgmt-api-client/pom.xml new file mode 100644 index 000000000..cd0977cf5 --- /dev/null +++ b/examples/hawkbit-mgmt-api-client/pom.xml @@ -0,0 +1,70 @@ + + + 4.0.0 + + org.eclipse.hawkbit + hawkbit-examples-parent + 0.1.0-SNAPSHOT + + hawkbit-mgmt-api-client + hawkBit Management API example client + + + + + org.eclipse.hawkbit + hawkbit-rest-api + ${project.version} + + + com.netflix.feign + feign-jackson + 8.12.1 + + + com.netflix.feign + feign-core + 8.12.1 + + + + + org.eclipse.hawkbit + hawkbit-example-app + ${project.version} + test + + + org.springframework.boot + spring-boot-starter-test + test + + + ru.yandex.qatools.allure + allure-junit-adaptor + test + + + org.easytesting + fest-assert-core + test + + + org.easytesting + fest-assert + test + + + + + \ No newline at end of file diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/api/client/DistributionSetResource.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/api/client/DistributionSetResource.java new file mode 100644 index 000000000..747432cd0 --- /dev/null +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/api/client/DistributionSetResource.java @@ -0,0 +1,37 @@ +/** + * 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.mgmt.api.client; + +import java.util.List; + +import org.eclipse.hawkbit.rest.resource.RestConstants; +import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyPost; +import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetsRest; + +import feign.Headers; +import feign.RequestLine; + +/** + * Client binding for the Distribution resource of the management API. + */ +public interface DistributionSetResource { + + /** + * Creates a list of distrbution sets. + * + * @param sets + * the request body java bean containing the necessary attributes + * for creating a distribution set. + * @return the list of targets which have been created + */ + @RequestLine("POST " + RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) + @Headers("Content-Type: application/json") + DistributionSetsRest createDistributionSets(final List sets); + +} diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/api/client/DistrubutionSetTagResource.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/api/client/DistrubutionSetTagResource.java new file mode 100644 index 000000000..fe7a147a8 --- /dev/null +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/api/client/DistrubutionSetTagResource.java @@ -0,0 +1,138 @@ +/** + * 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.mgmt.api.client; + +import java.util.List; + +import org.eclipse.hawkbit.rest.resource.RestConstants; +import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetsRest; +import org.eclipse.hawkbit.rest.resource.model.tag.AssignedDistributionSetRequestBody; +import org.eclipse.hawkbit.rest.resource.model.tag.DistributionSetTagAssigmentResultRest; +import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut; +import org.eclipse.hawkbit.rest.resource.model.tag.TagRest; +import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest; +import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; + +/** + * Client binding for the DistributionSetTag resource of the management API. + */ +public interface DistrubutionSetTagResource { + + /** + * Retrieves a single distributionset tag based on the given ID. + * + * @param dsTagId + * the ID of the distributionset tag to retrieve + * @return a deserialized java bean containing the attributes of the + * returned distributionset tag + */ + @RequestLine("GET " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{dsTagId}") + TagRest getDistributionSetTag(@Param("dsTagId") Long dsTagId); + + /** + * Creates a list of distributionset tags. + * + * @param tags + * the tags to be created + * @return the created tag list + */ + @RequestLine("POST " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING) + @Headers("Content-Type: application/json") + TagsRest createDistributionSetTags(List tags); + + /** + * Update attributes of a distributionset tag. + * + * @param dsTagId + * the distributionset tag id to be updated + * @param tag + * the request body + * @return the updated distributionset tag + */ + @RequestLine("PUT " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{dsTagId}") + @Headers("Content-Type: application/json") + TagRest updateDistributionSetTag(@Param("dsTagId") Long dsTagId, TagRequestBodyPut tag); + + /** + * Deletes given distributionset tag on given ID. + * + * @param dsTagId + * to be deleted + */ + @RequestLine("DELETE " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + "/{dsTagId}") + void deleteDistributionSetTag(@Param("dsTagId") final Long dsTagId); + + /** + * Retrieves a all assigned targets on the given distributionset tag id. + * + * @param dsTagId + * the ID of the distributionset tag to retrieve + * @return a list of targets + */ + @RequestLine("GET " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + + RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING) + DistributionSetsRest getAssignedDistributionSets(@Param("dsTagId") final Long dsTagId); + + /** + * Toggle the tag assignment all assigned targets will be unassigned and all + * unassigned targets will be assigned. + * + * @param dsTagId + * the ID of the distributionset tag to toggle + * @param assignedTargetRequestBodies + * a list of controller ids + * @return a list of assigned and unassigned targets + */ + @RequestLine("POST " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + + RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING + "/toggleTagAssignment") + @Headers("Content-Type: application/json") + DistributionSetTagAssigmentResultRest toggleTagAssignment(@Param("dsTagId") final Long dsTagId, + final List assignedTargetRequestBodies); + + /** + * Assign targets to a given distributionset tag id. + * + * @param dsTagId + * the ID of the distributionset tag to add the targets + * @param assignedTargetRequestBodies + * a list of controller ids + * @return a list of assigned targets + */ + @RequestLine("POST " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + + RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING) + @Headers("Content-Type: application/json") + TargetsRest assignDistributionSets(@Param("dsTagId") final Long dsTagId, + final List assignedTargetRequestBodies); + + /** + * Unassign targets to a given distributionset tag id. + * + * @param dsTagId + * the ID of the distributionset tag to add the targets + */ + @RequestLine("DELETE " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + + RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING) + void unassignDistributionSets(@Param("dsTagId") final Long dsTagId); + + /** + * Unassign one target to a given distributionset tag id. + * + * @param dsTagId + * the ID of the distributionset tag to add the targets param + * @param dsId + * the distributionset id + */ + @RequestLine("DELETE " + RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING + + RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING + "/{dsId}") + void unassignDistributionSet(@Param("dsTagId") final Long dsTagId, @Param("dsId") final Long dsId); +} diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/api/client/TargetResource.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/api/client/TargetResource.java new file mode 100644 index 000000000..66c147426 --- /dev/null +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/api/client/TargetResource.java @@ -0,0 +1,80 @@ +/** + * 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.mgmt.api.client; + +import java.util.List; + +import org.eclipse.hawkbit.rest.resource.model.target.TargetPagedList; +import org.eclipse.hawkbit.rest.resource.model.target.TargetRequestBody; +import org.eclipse.hawkbit.rest.resource.model.target.TargetRest; +import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; + +/** + * Client binding for the Target resource of the management API. + */ +public interface TargetResource { + + /** + * Retrieves a single target based on the given ID. + * + * @param targetId + * the ID of the target to retrieve + * @return a deserialized java bean containing the attributes of the + * returned target + */ + @RequestLine("GET /rest/v1/targets/{targetId}") + TargetRest getTarget(@Param("targetId") final String targetId); + + /** + * Paged query of targets resource. + * + * @param pagingOffsetParam + * of the paged query + * @param pagingLimitParam + * of the paged query + * @return paged list of target entries + */ + @RequestLine("GET /rest/v1/targets?offset={pagingOffsetParam}&limit={pagingLimitParam}") + TargetPagedList getTargets(@Param("pagingOffsetParam") int pagingOffsetParam, + @Param("pagingLimitParam") int pagingLimitParam); + + /** + * Paged query of targets resource with default offset and limit. + * + * @return paged list of target entries + */ + @RequestLine("GET /rest/v1/targets") + TargetPagedList getTargets(); + + /** + * Deletes given target based on given ID. + * + * @param targetId + * to be deleted + */ + @RequestLine("DELETE /rest/v1/targets/{targetId}") + void deleteTarget(@Param("targetId") final String targetId); + + /** + * Creates a list of targets. + * + * @param targets + * the request body java bean containing the necessary attributes + * for creating a target. + * @return the list of targets which have been created + */ + @RequestLine("POST /rest/v1/targets/") + @Headers("Content-Type: application/json") + TargetsRest createTargets(List targets); + +} diff --git a/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/api/client/TargetTagResource.java b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/api/client/TargetTagResource.java new file mode 100644 index 000000000..bd74e52d7 --- /dev/null +++ b/examples/hawkbit-mgmt-api-client/src/main/java/org/eclipse/hawkbit/mgmt/api/client/TargetTagResource.java @@ -0,0 +1,137 @@ +/** + * 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.mgmt.api.client; + +import java.util.List; + +import org.eclipse.hawkbit.rest.resource.RestConstants; +import org.eclipse.hawkbit.rest.resource.model.tag.AssignedTargetRequestBody; +import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut; +import org.eclipse.hawkbit.rest.resource.model.tag.TagRest; +import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest; +import org.eclipse.hawkbit.rest.resource.model.tag.TargetTagAssigmentResultRest; +import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest; + +import feign.Headers; +import feign.Param; +import feign.RequestLine; + +/** + * Client binding for the Target resource of the management API. + */ +public interface TargetTagResource { + + /** + * Retrieves a single target tag based on the given ID. + * + * @param targetTagId + * the ID of the target tag to retrieve + * @return a deserialized java bean containing the attributes of the + * returned target tag + */ + @RequestLine("GET " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}") + TagRest getTargetTag(@Param("targetTagId") Long targetTagId); + + /** + * Creates a list of target tags. + * + * @param tags + * the tags to be created + * @return the created tag list + */ + @RequestLine("POST " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING) + @Headers("Content-Type: application/json") + TagsRest createTargetTag(List tags); + + /** + * Update attributes of a target tag. + * + * @param targetTagId + * the target tag id to be updated + * @param tag + * the request body + * @return the updated target tag + */ + @RequestLine("PUT " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}") + @Headers("Content-Type: application/json") + TagRest updateTagretTag(@Param("targetTagId") Long targetTagId, TagRequestBodyPut tag); + + /** + * Deletes given target tag on given ID. + * + * @param targetTagId + * to be deleted + */ + @RequestLine("DELETE " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING + "/{targetTagId}") + void deleteTargetTag(@Param("targetTagId") final Long targetTagId); + + /** + * Retrieves a all assigned targets on the given target tag id. + * + * @param targetTagId + * the ID of the target tag to retrieve + * @return a list of targets + */ + @RequestLine("GET " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING + + RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING) + TargetsRest getAssignedTargets(@Param("targetTagId") final Long targetTagId); + + /** + * Toggle the tag assignment all assigned targets will be unassigned and all + * unassigned targets will be assigned. + * + * @param targetTagId + * the ID of the target tag to toggle + * @param assignedTargetRequestBodies + * a list of controller ids + * @return a list of assigned and unassigned targets + */ + @RequestLine("POST " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING + + RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING + "/toggleTagAssignment") + @Headers("Content-Type: application/json") + TargetTagAssigmentResultRest toggleTagAssignment(@Param("targetTagId") final Long targetTagId, + final List assignedTargetRequestBodies); + + /** + * Assign targets to a given target tag id. + * + * @param targetTagId + * the ID of the target tag to add the targets + * @param assignedTargetRequestBodies + * a list of controller ids + * @return a list of assigned targets + */ + @RequestLine("POST " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING + + RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING) + @Headers("Content-Type: application/json") + TargetsRest assignTargets(@Param("targetTagId") final Long targetTagId, + final List assignedTargetRequestBodies); + + /** + * Unassign targets to a given target tag id. + * + * @param targetTagId + * the ID of the target tag to add the targets + */ + @RequestLine("DELETE " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING + + RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING) + void unassignTargets(@Param("targetTagId") final Long targetTagId); + + /** + * Unassign one target to a given target tag id. + * + * @param targetTagId + * the ID of the target tag to add the targets param + * @param controllerId + * the controller id + */ + @RequestLine("DELETE " + RestConstants.TARGET_TAG_V1_REQUEST_MAPPING + + RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING + "/{controllerId}") + void unassignTarget(@Param("targetTagId") final Long targetTagId, @Param("controllerId") final String controllerId); +} diff --git a/examples/hawkbit-mgmt-api-client/src/test/java/org/eclipse/hawkbit/mgmt/api/client/DistributionSetTagTest.java b/examples/hawkbit-mgmt-api-client/src/test/java/org/eclipse/hawkbit/mgmt/api/client/DistributionSetTagTest.java new file mode 100644 index 000000000..17384c211 --- /dev/null +++ b/examples/hawkbit-mgmt-api-client/src/test/java/org/eclipse/hawkbit/mgmt/api/client/DistributionSetTagTest.java @@ -0,0 +1,186 @@ +/** + * 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.mgmt.api.client; + +import static org.fest.assertions.api.Assertions.assertThat; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.hawkbit.app.Start; +import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyPost; +import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest; +import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetsRest; +import org.eclipse.hawkbit.rest.resource.model.tag.AssignedDistributionSetRequestBody; +import org.eclipse.hawkbit.rest.resource.model.tag.DistributionSetTagAssigmentResultRest; +import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut; +import org.eclipse.hawkbit.rest.resource.model.tag.TagRest; +import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.springframework.boot.SpringApplication; +import org.springframework.context.annotation.Description; + +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; +import feign.Feign; +import feign.Logger; +import feign.auth.BasicAuthRequestInterceptor; +import feign.jackson.JacksonDecoder; +import feign.jackson.JacksonEncoder; + +@Features("Example Tests - Management RESTful API Client") +@Stories("DistrubutionSet Tag Resource") +public class DistributionSetTagTest { + + private DistrubutionSetTagResource distrubutionSetTagResource; + + private static List assignedTargetRequestBodies; + + @BeforeClass + public static void startupServer() { + SpringApplication.run(Start.class, new String[0]); + createTargetsAssignment(); + assignedTargetRequestBodies.add(new AssignedDistributionSetRequestBody().setDistributionSetId(100L)); + } + + @Before + public void setup() { + this.distrubutionSetTagResource = createDistrubutionSetTagResource(); + } + + // disabled as this runs not on CI environments. + @Test + @Description("Simple request of distrubutionset tag by ID") + @Ignore + public void getDistributionSetTag() { + final TagsRest result = createDistributionSetTags(2); + + assertThat(distrubutionSetTagResource.getDistributionSetTag(result.get(0).getTagId()).getName()).isEqualTo( + "Tag0"); + + deleteDistributionSets(result); + } + + // disabled as this runs not on CI environments. + @Test + @Description("Simple update of a distrubutionset tag") + @Ignore + public void updateDistributionSetTag() { + final TagsRest created = createDistributionSetTags(10); + + distrubutionSetTagResource.updateDistributionSetTag(created.get(0).getTagId(), new TagRequestBodyPut() + .setDescription("Test").setName("Test").setColour("Green")); + + final TagRest targetTag = distrubutionSetTagResource.getDistributionSetTag(created.get(0).getTagId()); + assertThat(targetTag.getName()).isEqualTo("Test"); + assertThat(targetTag.getDescription()).isEqualTo("Test"); + assertThat(targetTag.getColour()).isEqualTo("Green"); + + deleteDistributionSets(created); + } + + // disabled as this runs not on CI environments. + @Test + @Description("Simple request of all assigned distrubutionsets by a distrubutionset tag.") + @Ignore + public void getDistributionSetByTagId() { + final TagsRest created = createDistributionSetTags(10); + distrubutionSetTagResource.assignDistributionSets(created.get(2).getTagId(), assignedTargetRequestBodies); + + final DistributionSetsRest distributionSetsRest = distrubutionSetTagResource + .getAssignedDistributionSets(created.get(2).getTagId()); + assertThat(distributionSetsRest).hasSize(5); + + distrubutionSetTagResource.unassignDistributionSets(created.get(2).getTagId()); + deleteDistributionSets(created); + } + + @Test + @Description("Toggle request to unassigned all assigned distrubutionset and assign all unassigned distrubutionset.") + @Ignore + public void toggleTagAssignment() { + final TagsRest created = createDistributionSetTags(10); + final Long id = created.get(2).getTagId(); + + distrubutionSetTagResource.assignDistributionSets(id, assignedTargetRequestBodies); + distrubutionSetTagResource.unassignDistributionSet(id, assignedTargetRequestBodies.get(0) + .getDistributionSetId()); + + DistributionSetTagAssigmentResultRest assigmentResultRest = distrubutionSetTagResource.toggleTagAssignment(id, + assignedTargetRequestBodies); + + final TagRest targetTag = distrubutionSetTagResource.getDistributionSetTag(created.get(2).getTagId()); + assertThat(assigmentResultRest.getAssignedDistributionSets()).hasSize(1); + assertThat(assigmentResultRest.getUnassignedDistributionSets()).hasSize(0); + + assigmentResultRest = distrubutionSetTagResource.toggleTagAssignment(id, assignedTargetRequestBodies); + assertThat(assigmentResultRest.getAssignedDistributionSets()).hasSize(0); + assertThat(assigmentResultRest.getUnassignedDistributionSets()).hasSize(5); + + distrubutionSetTagResource.unassignDistributionSets(targetTag.getTagId()); + deleteDistributionSets(created); + } + + private void deleteDistributionSets(final List tags) { + for (final TagRest tag : tags) { + distrubutionSetTagResource.deleteDistributionSetTag(tag.getTagId()); + } + } + + private TagsRest createDistributionSetTags(final int number) { + + final List tags = new ArrayList<>(); + for (int i = 0; i < number; i++) { + tags.add(new TagRequestBodyPut().setDescription("Tag " + i).setName("Tag" + i).setColour("Red")); + } + + final TagsRest result = distrubutionSetTagResource.createDistributionSetTags(tags); + + assertThat(result).hasSize(number); + return result; + } + + private DistrubutionSetTagResource createDistrubutionSetTagResource() { + final DistrubutionSetTagResource distrubutionSetTagResource = Feign.builder().logger(new Logger.ErrorLogger()) + .logLevel(Logger.Level.BASIC).decoder(new JacksonDecoder()).encoder(new JacksonEncoder()) + .requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin")) + .target(DistrubutionSetTagResource.class, "http://localhost:8080"); + return distrubutionSetTagResource; + } + + private static void createTargetsAssignment() { + + final List sets = new ArrayList<>(); + assignedTargetRequestBodies = new ArrayList<>(); + for (int i = 0; i < 5; i++) { + final DistributionSetRequestBodyPost bodyPost = (DistributionSetRequestBodyPost) new DistributionSetRequestBodyPost() + .setName("Ds" + i).setDescription("Ds" + i).setVersion("" + i); + sets.add(bodyPost); + } + + final DistributionSetsRest result = createDistributionSetResource().createDistributionSets(sets); + for (final DistributionSetRest rest : result) { + assignedTargetRequestBodies.add(new AssignedDistributionSetRequestBody().setDistributionSetId(rest + .getDsId())); + } + + } + + private static DistributionSetResource createDistributionSetResource() { + final DistributionSetResource distributionSetResource = Feign.builder().logger(new Logger.ErrorLogger()) + .logLevel(Logger.Level.BASIC).decoder(new JacksonDecoder()).encoder(new JacksonEncoder()) + .requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin")) + .target(DistributionSetResource.class, "http://localhost:8080"); + return distributionSetResource; + } + +} diff --git a/examples/hawkbit-mgmt-api-client/src/test/java/org/eclipse/hawkbit/mgmt/api/client/TargetTagTest.java b/examples/hawkbit-mgmt-api-client/src/test/java/org/eclipse/hawkbit/mgmt/api/client/TargetTagTest.java new file mode 100644 index 000000000..10f18b704 --- /dev/null +++ b/examples/hawkbit-mgmt-api-client/src/test/java/org/eclipse/hawkbit/mgmt/api/client/TargetTagTest.java @@ -0,0 +1,182 @@ +/** + * 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.mgmt.api.client; + +import static org.fest.assertions.api.Assertions.assertThat; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.hawkbit.app.Start; +import org.eclipse.hawkbit.rest.resource.model.tag.AssignedTargetRequestBody; +import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut; +import org.eclipse.hawkbit.rest.resource.model.tag.TagRest; +import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest; +import org.eclipse.hawkbit.rest.resource.model.tag.TargetTagAssigmentResultRest; +import org.eclipse.hawkbit.rest.resource.model.target.TargetRequestBody; +import org.eclipse.hawkbit.rest.resource.model.target.TargetRest; +import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.springframework.boot.SpringApplication; +import org.springframework.context.annotation.Description; + +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; +import feign.Feign; +import feign.Logger; +import feign.auth.BasicAuthRequestInterceptor; +import feign.jackson.JacksonDecoder; +import feign.jackson.JacksonEncoder; + +@Features("Example Tests - Management RESTful API Client") +@Stories("Target Tag Resource") +public class TargetTagTest { + + private TargetTagResource targetTagResource; + + private static List assignedTargetRequestBodies; + + @BeforeClass + public static void startupServer() { + SpringApplication.run(Start.class, new String[0]); + createTargetsAssignment(); + assignedTargetRequestBodies.add(new AssignedTargetRequestBody().setControllerId("NotExist")); + } + + @Before + public void setup() { + this.targetTagResource = createTargetTagResource(); + } + + // disabled as this runs not on CI environments. + @Test + @Description("Simple request of target tag by ID") + @Ignore + public void getTargetTag() { + final TagsRest result = createTargetTags(2); + + assertThat(targetTagResource.getTargetTag(result.get(0).getTagId()).getName()).isEqualTo("Tag0"); + + deleteTargets(result); + } + + // disabled as this runs not on CI environments. + @Test + @Description("Simple update of a target tag") + @Ignore + public void updateTargetTag() { + final TagsRest created = createTargetTags(10); + + targetTagResource.updateTagretTag(created.get(0).getTagId(), new TagRequestBodyPut().setDescription("Test") + .setName("Test").setColour("Green")); + + final TagRest targetTag = targetTagResource.getTargetTag(created.get(0).getTagId()); + assertThat(targetTag.getName()).isEqualTo("Test"); + assertThat(targetTag.getDescription()).isEqualTo("Test"); + assertThat(targetTag.getColour()).isEqualTo("Green"); + + deleteTargets(created); + } + + // disabled as this runs not on CI environments. + @Test + @Description("Simple request of all assigned targets by a target tag.") + @Ignore + public void getTargetsByTargetTagId() { + final TagsRest created = createTargetTags(10); + final Long tagId = created.get(2).getTagId(); + targetTagResource.assignTargets(tagId, assignedTargetRequestBodies); + + final TagRest targetTag = targetTagResource.getTargetTag(tagId); + assertThat(targetTagResource.getAssignedTargets(tagId)).hasSize(5); + + targetTagResource.unassignTargets(targetTag.getTagId()); + deleteTargets(created); + } + + @Test + @Description("Toggle request to unassigned all assigned targets and assign all unassigned targets.") + @Ignore + public void toggleTagAssignment() { + final TagsRest created = createTargetTags(10); + final Long id = created.get(2).getTagId(); + + targetTagResource.assignTargets(id, assignedTargetRequestBodies); + targetTagResource.unassignTarget(id, assignedTargetRequestBodies.get(0).getControllerId()); + + TargetTagAssigmentResultRest assigmentResultRest = targetTagResource.toggleTagAssignment(id, + assignedTargetRequestBodies); + + final TagRest targetTag = targetTagResource.getTargetTag(created.get(2).getTagId()); + assertThat(assigmentResultRest.getAssignedTargets()).hasSize(1); + assertThat(assigmentResultRest.getUnassignedTargets()).hasSize(0); + + assigmentResultRest = targetTagResource.toggleTagAssignment(id, assignedTargetRequestBodies); + assertThat(assigmentResultRest.getAssignedTargets()).hasSize(0); + assertThat(assigmentResultRest.getUnassignedTargets()).hasSize(5); + + targetTagResource.unassignTargets(targetTag.getTagId()); + deleteTargets(created); + } + + private void deleteTargets(final List tags) { + for (final TagRest tag : tags) { + targetTagResource.deleteTargetTag(tag.getTagId()); + } + } + + private TagsRest createTargetTags(final int number) { + + final List tags = new ArrayList<>(); + for (int i = 0; i < number; i++) { + tags.add(new TagRequestBodyPut().setDescription("Tag " + i).setName("Tag" + i).setColour("Red")); + } + + final TagsRest result = targetTagResource.createTargetTag(tags); + + assertThat(result).hasSize(number); + return result; + } + + private TargetTagResource createTargetTagResource() { + final TargetTagResource targetResource = Feign.builder().logger(new Logger.ErrorLogger()) + .logLevel(Logger.Level.BASIC).decoder(new JacksonDecoder()).encoder(new JacksonEncoder()) + .requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin")) + .target(TargetTagResource.class, "http://localhost:8080"); + return targetResource; + } + + private static void createTargetsAssignment() { + + final List targets = new ArrayList<>(); + assignedTargetRequestBodies = new ArrayList<>(); + for (int i = 0; i < 5; i++) { + + targets.add(new TargetRequestBody().setControllerId("test" + i).setName("testDevice")); + } + + final TargetsRest result = createTargetResource().createTargets(targets); + for (final TargetRest rest : result) { + assignedTargetRequestBodies.add(new AssignedTargetRequestBody().setControllerId(rest.getControllerId())); + } + + } + + private static TargetResource createTargetResource() { + final TargetResource targetResource = Feign.builder().logger(new Logger.ErrorLogger()) + .logLevel(Logger.Level.BASIC).decoder(new JacksonDecoder()).encoder(new JacksonEncoder()) + .requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin")) + .target(TargetResource.class, "http://localhost:8080"); + return targetResource; + } + +} diff --git a/examples/hawkbit-mgmt-api-client/src/test/java/org/eclipse/hawkbit/mgmt/api/client/TargetTest.java b/examples/hawkbit-mgmt-api-client/src/test/java/org/eclipse/hawkbit/mgmt/api/client/TargetTest.java new file mode 100644 index 000000000..745b119f6 --- /dev/null +++ b/examples/hawkbit-mgmt-api-client/src/test/java/org/eclipse/hawkbit/mgmt/api/client/TargetTest.java @@ -0,0 +1,119 @@ +/** + * 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.mgmt.api.client; + +import static org.fest.assertions.api.Assertions.assertThat; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.hawkbit.app.Start; +import org.eclipse.hawkbit.rest.resource.model.target.TargetPagedList; +import org.eclipse.hawkbit.rest.resource.model.target.TargetRequestBody; +import org.eclipse.hawkbit.rest.resource.model.target.TargetRest; +import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.springframework.boot.SpringApplication; +import org.springframework.context.annotation.Description; + +import feign.Feign; +import feign.Logger; +import feign.auth.BasicAuthRequestInterceptor; +import feign.jackson.JacksonDecoder; +import feign.jackson.JacksonEncoder; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + +@Features("Example Tests - Management RESTful API Client") +@Stories("Target Resource") +public class TargetTest { + + @BeforeClass + public static void startupServer() { + SpringApplication.run(Start.class, new String[0]); + } + + // disabled as this runs not on CI environments. + @Test + @Description("Simple request of target by ID") + @Ignore + public void getTarget() { + final TargetResource targetResource = createTargetResource(); + final TargetsRest result = createTargets(targetResource, 1); + + assertThat(targetResource.getTarget("test0").getName()).isEqualTo("testDevice"); + + deleteTargets(targetResource, result); + } + + // disabled as this runs not on CI environments. + @Test + @Description("Simple request of all targets with defined page sizing information (i.e. offset and limit).") + @Ignore + public void getTargetsAsPagedListWithDefinedPageSizing() { + final TargetResource targetResource = createTargetResource(); + final TargetsRest created = createTargets(targetResource, 20); + + final TargetPagedList queryResult = targetResource.getTargets(0, 10); + + assertThat(queryResult.getContent()).hasSize(10); + assertThat(queryResult.getTotal()).isEqualTo(20); + assertThat(queryResult.getSize()).isEqualTo(10); + + deleteTargets(targetResource, created); + } + + // disabled as this runs not on CI environments. + @Test + @Description("Simple request of all targets with defualt paging parameters.") + @Ignore + public void getTargetsAsPagedListWithDefaultPageSizing() { + final TargetResource targetResource = createTargetResource(); + final TargetsRest created = createTargets(targetResource, 20); + + final TargetPagedList queryResult = targetResource.getTargets(); + + assertThat(queryResult.getContent()).hasSize(20); + assertThat(queryResult.getTotal()).isEqualTo(20); + assertThat(queryResult.getSize()).isEqualTo(20); + + deleteTargets(targetResource, created); + } + + private void deleteTargets(final TargetResource targetResource, final List targets) { + for (final TargetRest targetRest : targets) { + targetResource.deleteTarget(targetRest.getControllerId()); + } + } + + private TargetsRest createTargets(final TargetResource targetResource, final int number) { + + final List targets = new ArrayList<>(); + for (int i = 0; i < number; i++) { + + targets.add(new TargetRequestBody().setControllerId("test" + i).setName("testDevice")); + } + + final TargetsRest result = targetResource.createTargets(targets); + + assertThat(result).hasSize(number); + return result; + } + + private TargetResource createTargetResource() { + final TargetResource targetResource = Feign.builder().logger(new Logger.ErrorLogger()) + .logLevel(Logger.Level.BASIC).decoder(new JacksonDecoder()).encoder(new JacksonEncoder()) + .requestInterceptor(new BasicAuthRequestInterceptor("admin", "admin")) + .target(TargetResource.class, "http://localhost:8080"); + return targetResource; + } + +} diff --git a/examples/pom.xml b/examples/pom.xml old mode 100755 new mode 100644 index b4a99b16f..d23eb0098 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -25,6 +25,7 @@ hawkbit-device-simulator hawkbit-example-app + hawkbit-mgmt-api-client \ No newline at end of file diff --git a/hawkbit-artifact-repository-mongo/README.md b/hawkbit-artifact-repository-mongo/README.md old mode 100755 new mode 100644 diff --git a/hawkbit-artifact-repository-mongo/pom.xml b/hawkbit-artifact-repository-mongo/pom.xml old mode 100755 new mode 100644 index 8eb7534b2..b8d73e256 --- a/hawkbit-artifact-repository-mongo/pom.xml +++ b/hawkbit-artifact-repository-mongo/pom.xml @@ -41,7 +41,6 @@ com.google.guava guava - 18.0 diff --git a/hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStore.java b/hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStore.java old mode 100755 new mode 100644 index c5cf03016..78658da91 --- a/hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStore.java +++ b/hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStore.java @@ -199,8 +199,8 @@ public class ArtifactStore implements ArtifactRepository { } - private String computeSHA1Hash(final InputStream stream, final FileOutputStream os, final String providedSHA1Sum) - throws NoSuchAlgorithmException, IOException { + private static String computeSHA1Hash(final InputStream stream, final FileOutputStream os, + final String providedSHA1Sum) throws NoSuchAlgorithmException, IOException { String sha1Hash; // compute digest final MessageDigest md = MessageDigest.getInstance("SHA-1"); @@ -240,6 +240,7 @@ public class ArtifactStore implements ArtifactRepository { * the sha1-hashes of the files to lookup. * @return list of artfiacts */ + @Override public List getArtifactsBySha1(final List sha1Hashes) { return map(gridFs.find(new Query().addCriteria(Criteria.where(SHA1).in(sha1Hashes)))); } diff --git a/hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreAutoConfiguration.java b/hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreAutoConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/GridFsArtifact.java b/hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/GridFsArtifact.java old mode 100755 new mode 100644 diff --git a/hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/MongoConfiguration.java b/hawkbit-artifact-repository-mongo/src/main/java/org/eclipse/hawkbit/artifact/repository/MongoConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-artifact-repository-mongo/src/main/resources/META-INF/spring.factories b/hawkbit-artifact-repository-mongo/src/main/resources/META-INF/spring.factories old mode 100755 new mode 100644 diff --git a/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/FreePortFileWriter.java b/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/FreePortFileWriter.java old mode 100755 new mode 100644 diff --git a/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/MongoDBTestRule.java b/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/MongoDBTestRule.java old mode 100755 new mode 100644 diff --git a/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/TestConfiguration.java b/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/TestConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreTest.java b/hawkbit-artifact-repository-mongo/src/test/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/pom.xml b/hawkbit-autoconfigure/pom.xml old mode 100755 new mode 100644 index 73e93e830..1f8e08b7d --- a/hawkbit-autoconfigure/pom.xml +++ b/hawkbit-autoconfigure/pom.xml @@ -67,11 +67,6 @@ hawkbit-rest-resource ${project.version} true - - - io.springfox - springfox-swagger2 - true org.springframework diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/amqp/AmqpAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/amqp/AmqpAutoConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/CacheAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/CacheAutoConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/DownloadIdCacheAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/DownloadIdCacheAutoConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/RedisAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/cache/RedisAutoConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/conf/ControllerPollAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/conf/ControllerPollAutoConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/conf/DefaultPropertiesAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/conf/DefaultPropertiesAutoConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/eventbus/EventBusAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/eventbus/EventBusAutoConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/AsyncConfigurerAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/AsyncConfigurerAutoConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/AsyncConfigurerThreadpoolProperties.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/AsyncConfigurerThreadpoolProperties.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/ExecutorAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/scheduling/ExecutorAutoConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/EnableHawkbitManagedSecurityConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/EnableHawkbitManagedSecurityConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityAutoConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java old mode 100755 new mode 100644 index 1c8b32ffb..63e1e8ad1 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java +++ b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/security/SecurityManagedConfiguration.java @@ -19,8 +19,6 @@ import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.ExcludePathAwareShallowETagFilter; @@ -47,6 +45,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.boot.context.embedded.FilterRegistrationBean; +import org.springframework.boot.context.embedded.ServletListenerRegistrationBean; import org.springframework.cache.Cache; import org.springframework.context.EnvironmentAware; import org.springframework.context.annotation.AdviceMode; @@ -68,9 +67,7 @@ import org.springframework.security.config.annotation.web.configuration.WebSecur import org.springframework.security.config.annotation.web.servlet.configuration.EnableWebMvcSecurity; import org.springframework.security.config.http.SessionCreationPolicy; import org.springframework.security.core.Authentication; -import org.springframework.security.core.AuthenticationException; import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.security.web.access.intercept.FilterSecurityInterceptor; import org.springframework.security.web.authentication.AnonymousAuthenticationFilter; import org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint; @@ -78,6 +75,7 @@ import org.springframework.security.web.authentication.preauth.RequestHeaderAuth import org.springframework.security.web.header.writers.frameoptions.StaticAllowFromStrategy; import org.springframework.security.web.header.writers.frameoptions.XFrameOptionsHeaderWriter; import org.springframework.security.web.header.writers.frameoptions.XFrameOptionsHeaderWriter.XFrameOptionsMode; +import org.springframework.security.web.session.HttpSessionEventPublisher; import org.vaadin.spring.security.VaadinSecurityContext; import org.vaadin.spring.security.annotation.EnableVaadinSecurity; import org.vaadin.spring.security.web.VaadinDefaultRedirectStrategy; @@ -161,31 +159,35 @@ public class SecurityManagedConfiguration implements EnvironmentAware { } if (securityConfiguration.getAnonymousEnabled()) { - LOG.info( - "******************\n** Anonymous controller security enabled, should only use for developing purposes **\n******************"); + LOG.info("******************\n** Anonymous controller security enabled, should only use for developing purposes **\n******************"); final AnonymousAuthenticationFilter anoymousFilter = new AnonymousAuthenticationFilter( - "controllerAnonymousFilter", "anonymous", Collections.singletonList( - new SimpleGrantedAuthority(SpringEvalExpressions.CONTROLLER_ROLE_ANONYMOUS))); + "controllerAnonymousFilter", "anonymous", Collections.singletonList(new SimpleGrantedAuthority( + SpringEvalExpressions.CONTROLLER_ROLE_ANONYMOUS))); anoymousFilter.setAuthenticationDetailsSource(authenticationDetailsSource); httpSec.requestMatchers().antMatchers("/*/controller/v1/**", "/*/controller/artifacts/v1/**").and() .securityContext().disable().anonymous().authenticationFilter(anoymousFilter); } else { - httpSec.addFilter(securityHeaderFilter).addFilter(securityTokenFilter) - .addFilter(gatewaySecurityTokenFilter).antMatcher("/*/controller/**").anonymous().disable() - .authorizeRequests().anyRequest().authenticated().and().exceptionHandling() - .authenticationEntryPoint(new AuthenticationEntryPoint() { - @Override - public void commence(final HttpServletRequest request, final HttpServletResponse response, - final AuthenticationException authException) throws IOException, ServletException { - response.setStatus(HttpStatus.UNAUTHORIZED.value()); - } - }).and().sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); + httpSec.addFilter(securityHeaderFilter) + .addFilter(securityTokenFilter) + .addFilter(gatewaySecurityTokenFilter) + .antMatcher("/*/controller/**") + .anonymous() + .disable() + .authorizeRequests() + .anyRequest() + .authenticated() + .and() + .exceptionHandling() + .authenticationEntryPoint( + (request, response, authException) -> response.setStatus(HttpStatus.UNAUTHORIZED + .value())).and().sessionManagement() + .sessionCreationPolicy(SessionCreationPolicy.STATELESS); } } /* * (non-Javadoc) - * + * * @see * org.springframework.security.config.annotation.web.configuration. * WebSecurityConfigurerAdapter @@ -194,8 +196,8 @@ public class SecurityManagedConfiguration implements EnvironmentAware { */ @Override protected void configure(final AuthenticationManagerBuilder auth) throws Exception { - auth.authenticationProvider( - new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration.getRpTrustedIPs())); + auth.authenticationProvider(new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration + .getRpTrustedIPs())); } } @@ -210,12 +212,10 @@ public class SecurityManagedConfiguration implements EnvironmentAware { public FilterRegistrationBean dosFilter() { final FilterRegistrationBean filterRegBean = new FilterRegistrationBean(); - filterRegBean - .setFilter( - new DosFilter(environment.getProperty("security.dos.filter.maxRead", Integer.class, 100), - environment.getProperty("security.dos.filter.maxWrite", Integer.class, 10), - environment.getProperty("security.dos.filter.whitelist"), environment - .getProperty("security.clients.blacklist"), + filterRegBean.setFilter(new DosFilter(environment + .getProperty("security.dos.filter.maxRead", Integer.class, 200), environment.getProperty( + "security.dos.filter.maxWrite", Integer.class, 50), environment + .getProperty("security.dos.filter.whitelist"), environment.getProperty("security.clients.blacklist"), environment.getProperty("security.rp.remote_ip_header", String.class, "X-Forwarded-For"))); filterRegBean.addUrlPatterns("/{tenant}/controller/v1/*", "/rest/*"); return filterRegBean; @@ -301,8 +301,7 @@ public class SecurityManagedConfiguration implements EnvironmentAware { }, RequestHeaderAuthenticationFilter.class) .addFilterAfter( new AuthenticationSuccessTenantMetadataCreationFilter(tenantAware, systemManagement), - RequestHeaderAuthenticationFilter.class) - .authorizeRequests().anyRequest().authenticated() + RequestHeaderAuthenticationFilter.class).authorizeRequests().anyRequest().authenticated() .antMatchers(RestConstants.BASE_SYSTEM_MAPPING + "/admin/**") .hasAnyAuthority(SpPermission.SYSTEM_ADMIN).antMatchers(RestConstants.BASE_SYSTEM_MAPPING + "/**") .hasAnyAuthority(SpPermission.SYSTEM_DIAG); @@ -311,14 +310,12 @@ public class SecurityManagedConfiguration implements EnvironmentAware { /** * {@link WebSecurityConfigurer} for external (management) access. - * - * + * */ @Configuration @Order(400) @EnableVaadinSecurity - public static class UISecurityConfigurationAdapter extends WebSecurityConfigurerAdapter - implements EnvironmentAware { + public static class UISecurityConfigurationAdapter extends WebSecurityConfigurerAdapter implements EnvironmentAware { private static final String XFRAME_OPTION_DENY = "DENY"; private static final String XFRAME_OPTION_SAMEORIGIN = "SAMEORIGIN"; @@ -370,6 +367,18 @@ public class SecurityManagedConfiguration implements EnvironmentAware { return handler; } + /** + * Listener to redirect to login page after session timeout. Close the + * vaadin session, because it's is not possible to redirect in + * atmospehere. + * + * @return the servlet listener. + */ + @Bean + public ServletListenerRegistrationBean httpSessionEventPublisher() { + return new ServletListenerRegistrationBean<>(new HttpSessionEventPublisher()); + } + @Override protected void configure(final HttpSecurity http) throws Exception { @@ -379,9 +388,10 @@ public class SecurityManagedConfiguration implements EnvironmentAware { if (confXframeOption.equals(XFAME_OPTION_ALLOW_FROM) && confAllowFromUri == null) { // if allow-from option is specified but no allowFromUri throw // exception - throw new IllegalStateException("hawkbit.server.security.xframe.option has been specified as ALLOW-FROM" - + " but no hawkbit.server.security.xframe.option.allowfrom has been set, " - + "please ensure to set allow from URIs"); + throw new IllegalStateException( + "hawkbit.server.security.xframe.option has been specified as ALLOW-FROM" + + " but no hawkbit.server.security.xframe.option.allowfrom has been set, " + + "please ensure to set allow from URIs"); } // workaround regex: we need to exclude the URL /UI/HEARTBEAT here @@ -390,22 +400,23 @@ public class SecurityManagedConfiguration implements EnvironmentAware { // vaadin-forum: // https://vaadin.com/forum#!/thread/3200565. HttpSecurity httpSec = http.regexMatcher("(?!.*HEARTBEAT)^.*\\/UI.*$") - // disable as CSRF is handled by Vaadin + // disable as CSRF is handled by Vaadin .csrf().disable(); if (springSecurityProperties.isRequireSsl()) { httpSec = httpSec.requiresChannel().anyRequest().requiresSecure().and(); } else { - LOG.info( - "\"******************\\n** Requires HTTPS Security has been disabled for UI, should only use for developing purposes **\\n******************\""); + LOG.info("\"******************\\n** Requires HTTPS Security has been disabled for UI, should only use for developing purposes **\\n******************\""); } // for UI integrator we allow frame integration on same origin httpSec.headers() - .addHeaderWriter(confXframeOption.equals(XFAME_OPTION_ALLOW_FROM) - ? new XFrameOptionsHeaderWriter(new StaticAllowFromStrategy(new URI(confAllowFromUri))) - : new XFrameOptionsHeaderWriter(xframeOptionFromStr(confXframeOption))) - .contentTypeOptions().xssProtection().httpStrictTransportSecurity().and() + .addHeaderWriter( + confXframeOption.equals(XFAME_OPTION_ALLOW_FROM) ? new XFrameOptionsHeaderWriter( + new StaticAllowFromStrategy(new URI(confAllowFromUri))) + : new XFrameOptionsHeaderWriter(xframeOptionFromStr(confXframeOption))) + .contentTypeOptions().xssProtection().httpStrictTransportSecurity() + .and() // UI .authorizeRequests().antMatchers("/UI/login/**").permitAll().antMatchers("/UI/UIDL/**").permitAll() .anyRequest().authenticated().and() @@ -439,8 +450,8 @@ public class SecurityManagedConfiguration implements EnvironmentAware { @Override public void configure(final WebSecurity webSecurity) throws Exception { - webSecurity.ignoring().antMatchers("/documentation/**", "/VAADIN/**", "/*.*", "/v2/api-docs/**", - "/docs/**"); + webSecurity.ignoring() + .antMatchers("/documentation/**", "/VAADIN/**", "/*.*", "/v2/api-docs/**", "/docs/**"); } } @@ -471,15 +482,15 @@ public class SecurityManagedConfiguration implements EnvironmentAware { http.csrf().disable(); http.anonymous().disable(); - http.regexMatcher(HttpDownloadAuthenticationFilter.REQUEST_ID_REGEX_PATTERN) - .addFilterBefore(downloadIdAuthenticationFilter, FilterSecurityInterceptor.class); + http.regexMatcher(HttpDownloadAuthenticationFilter.REQUEST_ID_REGEX_PATTERN).addFilterBefore( + downloadIdAuthenticationFilter, FilterSecurityInterceptor.class); http.authorizeRequests().anyRequest().authenticated(); } @Override protected void configure(final AuthenticationManagerBuilder auth) throws Exception { - auth.authenticationProvider( - new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration.getRpTrustedIPs())); + auth.authenticationProvider(new PreAuthTokenSourceTrustAuthenticationProvider(securityConfiguration + .getRpTrustedIPs())); } } @@ -499,7 +510,7 @@ class TenantMetadataSavedRequestAwareVaadinAuthenticationSuccessHandler extends /* * (non-Javadoc) - * + * * @see org.vaadin.spring.security.web.authentication. * SavedRequestAwareVaadinAuthenticationSuccessHandler * #onAuthenticationSuccess(org.springframework.security.core. @@ -508,8 +519,8 @@ class TenantMetadataSavedRequestAwareVaadinAuthenticationSuccessHandler extends @Override public void onAuthenticationSuccess(final Authentication authentication) throws Exception { if (authentication.getClass().equals(TenantUserPasswordAuthenticationToken.class)) { - systemManagement - .getTenantMetadata(((TenantUserPasswordAuthenticationToken) authentication).getTenant().toString()); + systemManagement.getTenantMetadata(((TenantUserPasswordAuthenticationToken) authentication).getTenant() + .toString()); } else if (authentication.getClass().equals(UsernamePasswordAuthenticationToken.class)) { // TODO: MECS-1078 vaadin4spring-ext-security does not give us the // fullyAuthenticatedToken diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/swagger/SwaggerApiDocAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/swagger/SwaggerApiDocAutoConfiguration.java deleted file mode 100755 index ae405242c..000000000 --- a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/swagger/SwaggerApiDocAutoConfiguration.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * 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.autoconfigure.swagger; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.hawkbit.rest.resource.RestConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.web.bind.annotation.RequestMethod; - -import com.google.common.base.Predicate; -import com.google.common.base.Predicates; - -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.schema.ModelRef; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.ResponseMessage; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -/** - * Swagger configuration for RESTful SP server APIs. - * - * - * - * - */ - -@Configuration -@EnableSwagger2 -public class SwaggerApiDocAutoConfiguration { - - /** - * Create the Springfox Docket, which generates the Information for the - * REST-Swagger-UI. Rest paths are: /rest/v1/. and ./controller/v1/. - * - * @see springfox.documentation.spring.web.plugins.Docket - * - * @return the v1 docket - */ - @Bean - public Docket customImplementation() { - return createDocket(); - } - - private Predicate selectApiPaths() { - return Predicates.or(PathSelectors.regex("/rest/v1/.*"), PathSelectors.regex("/.*/controller/v1/.*")); - } - - private Docket createDocket() { - final List authorizationMessages = globalAuhtorizationMessages(); - return new Docket(DocumentationType.SWAGGER_2).select().paths(selectApiPaths()).build() - .useDefaultResponseMessages(true).globalResponseMessage(RequestMethod.GET, authorizationMessages) - .globalResponseMessage(RequestMethod.POST, authorizationMessages) - .globalResponseMessage(RequestMethod.PUT, authorizationMessages) - .globalResponseMessage(RequestMethod.DELETE, authorizationMessages).apiInfo(apiInfo()); - } - - private List globalAuhtorizationMessages() { - final List messageList = new ArrayList<>(); - messageList.add(new ResponseMessage(200, "Request sucessfull", new ModelRef("com."))); - messageList.add(new ResponseMessage(400, "Bad Request - e.g. invalid parameters", null)); - messageList.add(new ResponseMessage(401, "Unauthorized - The request requires user authentication.", - - null)); - messageList.add( - new ResponseMessage(403, "Forbidden - Insufficient permissions or data volume restriction applies.", - new ModelRef("ExceptionInfo"))); - messageList.add(new ResponseMessage(405, "Method Not Allowed", null)); - messageList.add(new ResponseMessage(406, - "Not Acceptable - In case accept header is specified and not application/json", null)); - messageList.add(new ResponseMessage(429, - "Too many requests. The server will refuse further attemps and the client has to wait another second.", - null)); - return messageList; - } - - private ApiInfo apiInfo() { - return new ApiInfoBuilder().title("Software Provisioning API Descriptions").version(RestConstants.API_VERSION) - .build(); - } - -} diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/ui/UIAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/ui/UIAutoConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/url/PropertyHostnameResolverAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/url/PropertyHostnameResolverAutoConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/url/ServerProperties.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/url/ServerProperties.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/web/ResourceControllerAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/web/ResourceControllerAutoConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/web/WebMvcAutoConfiguration.java b/hawkbit-autoconfigure/src/main/java/org/eclipse/hawkbit/autoconfigure/web/WebMvcAutoConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-autoconfigure/src/main/resources/META-INF/spring.factories b/hawkbit-autoconfigure/src/main/resources/META-INF/spring.factories old mode 100755 new mode 100644 index c0563d7c9..5d8d005d9 --- a/hawkbit-autoconfigure/src/main/resources/META-INF/spring.factories +++ b/hawkbit-autoconfigure/src/main/resources/META-INF/spring.factories @@ -3,7 +3,6 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ org.eclipse.hawkbit.autoconfigure.conf.DefaultPropertiesAutoConfiguration,\ org.eclipse.hawkbit.autoconfigure.ui.UIAutoConfiguration,\ org.eclipse.hawkbit.autoconfigure.security.SecurityAutoConfiguration,\ -org.eclipse.hawkbit.autoconfigure.swagger.SwaggerApiDocAutoConfiguration,\ org.eclipse.hawkbit.autoconfigure.url.PropertyHostnameResolverAutoConfiguration,\ org.eclipse.hawkbit.autoconfigure.web.WebMvcAutoConfiguration,\ org.eclipse.hawkbit.autoconfigure.cache.CacheAutoConfiguration,\ diff --git a/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties b/hawkbit-autoconfigure/src/main/resources/hawkbitdefaults.properties old mode 100755 new mode 100644 diff --git a/hawkbit-cache-redis/pom.xml b/hawkbit-cache-redis/pom.xml old mode 100755 new mode 100644 diff --git a/hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/RedisConfiguration.java b/hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/RedisConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/RedisProperties.java b/hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/RedisProperties.java old mode 100755 new mode 100644 diff --git a/hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/annotation/EnableRedis.java b/hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/annotation/EnableRedis.java old mode 100755 new mode 100644 diff --git a/hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/eventbus/EventDistributor.java b/hawkbit-cache-redis/src/main/java/org/eclipse/hawkbit/cache/eventbus/EventDistributor.java old mode 100755 new mode 100644 diff --git a/hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/eventbus/EventDistributorTest.java b/hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/eventbus/EventDistributorTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/redis/RedisPropertiesTest.java b/hawkbit-cache-redis/src/test/java/org/eclipse/hawkbit/cache/redis/RedisPropertiesTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/pom.xml b/hawkbit-core/pom.xml old mode 100755 new mode 100644 index 64dea1bbf..403f7aeb2 --- a/hawkbit-core/pom.xml +++ b/hawkbit-core/pom.xml @@ -31,7 +31,6 @@ com.google.guava guava - 18.0 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/ControllerPollProperties.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/ControllerPollProperties.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/DistributedResourceBundleMessageSource.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/DistributedResourceBundleMessageSource.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/HostnameResolver.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/HostnameResolver.java old mode 100755 new mode 100644 index 09cd1e9df..2491e85e2 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/HostnameResolver.java +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/api/HostnameResolver.java @@ -12,15 +12,14 @@ import java.net.URL; /** * Resolve to reach the server url. - * - * * */ +@FunctionalInterface public interface HostnameResolver { /** - * - * + * + * * @return */ URL resolveHostname(); diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactRepository.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreException.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/ArtifactStoreException.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/HashNotMatchException.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/HashNotMatchException.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/model/DbArtifact.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/model/DbArtifact.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/model/DbArtifactHash.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/artifact/repository/model/DbArtifactHash.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/CacheConstants.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/CacheConstants.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/DownloadArtifactCache.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/DownloadArtifactCache.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/DownloadType.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/DownloadType.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/TenancyCacheManager.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/TenancyCacheManager.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/TenantAwareCacheManager.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/cache/TenantAwareCacheManager.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/DeadEventListener.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/DeadEventListener.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/EventBusSubscriberProcessor.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/EventBusSubscriberProcessor.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/EventSubscriber.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/EventSubscriber.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractDistributedEvent.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractDistributedEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/CancelTargetAssignmentEvent.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/CancelTargetAssignmentEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/CustomEvents.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/CustomEvents.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributedEvent.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributedEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/DownloadProgressEvent.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/DownloadProgressEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/EntityEvent.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/EntityEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/Event.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/Event.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/NodeAware.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/NodeAware.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetDeletedEvent.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetDeletedEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/exception/GenericSpServerException.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/exception/GenericSpServerException.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/exception/SpServerError.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/exception/SpServerError.java old mode 100755 new mode 100644 index c7996f0dd..91559cc88 --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/exception/SpServerError.java +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/exception/SpServerError.java @@ -12,7 +12,7 @@ package org.eclipse.hawkbit.exception; * * * - * Define the Error code for Error handling + * Define the Error code for Error handling * */ @@ -69,8 +69,7 @@ public enum SpServerError { * */ SP_REST_BODY_NOT_READABLE("hawkbit.server.error.rest.body.notReadable", - "The given request body is not well formed"), SP_UI_SEARCH("hawkbit.server.error.ui.searchError", - "blabla :-)"), + "The given request body is not well formed"), /** * */ @@ -113,7 +112,6 @@ public enum SpServerError { /** * */ - SP_ARTIFACT_LOAD_FAILED("hawkbit.server.error.artifact.loadFailed", "Load of artifact failed with internal server error."), @@ -124,26 +122,34 @@ public enum SpServerError { "Too many status entries have been inserted."), /** - * - */ + * + */ SP_ATTRIBUTES_TO_MANY_ENTRIES("hawkbit.server.error.target.attributes.tooManyEntries", "Too many attribute entries have been inserted."), /** - * - */ + * error message, which describes that the action can not be canceled cause + * the action is inactive. + */ SP_ACTION_NOT_CANCELABLE("hawkbit.server.error.action.notcancelable", - "Only active actions which are in status pending are canceable"), + "Only active actions which are in status pending are canceable."), /** - * - */ + * error message, which describes that the action can not be force quit + * cause the action is inactive. + */ + SP_ACTION_NOT_FORCE_QUITABLE("hawkbit.server.error.action.notforcequitable", + "Only active actions which are in status pending can be force quit."), + + /** + * + */ SP_DS_INCOMPLETE("hawkbit.server.error.distributionset.incomplete", "Distribution set is assigned to a a target that is incomplete (i.e. mandatory modules are missing)"), /** - * - */ + * + */ SP_DS_TYPE_UNDEFINED("hawkbit.server.error.distributionset.type.undefined", "Distribution set type is not yet defined. Modules cannot be added until definition."), @@ -154,8 +160,8 @@ public enum SpServerError { "Distribution set type does not contain the given module, i.e. is incompatible."), /** - * - */ + * + */ SP_REPO_TENANT_NOT_EXISTS("hawkbit.server.error.repo.tenantNotExists", "The entity cannot be inserted due the tenant does not exists"), @@ -181,10 +187,20 @@ public enum SpServerError { this.message = message; } + /** + * Gets the key of the error + * + * @return the key of the error + */ public String getKey() { return key; } + /** + * Gets the message of the error + * + * @return message of the error + */ public String getMessage() { return message; } diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/exception/SpServerRtException.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/exception/SpServerRtException.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/ActionFields.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/ActionFields.java old mode 100755 new mode 100644 index bc153d989..c2d8ec49d --- a/hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/ActionFields.java +++ b/hawkbit-core/src/main/java/org/eclipse/hawkbit/repository/ActionFields.java @@ -15,7 +15,7 @@ package org.eclipse.hawkbit.repository; * * */ -public enum ActionFields implements FieldNameProvider, FieldValueConverter { +public enum ActionFields implements FieldNameProvider,FieldValueConverter { /** * The status field. @@ -51,7 +51,7 @@ public enum ActionFields implements FieldNameProvider, FieldValueConverter * the return type of the runner */ + @FunctionalInterface interface TenantRunner { /** * Called to run specific code and a given tenant. - * + * * @return the return of the code block running under a certain tenant */ T run(); diff --git a/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/TenantConfigurationKey.java b/hawkbit-core/src/main/java/org/eclipse/hawkbit/tenancy/configuration/TenantConfigurationKey.java old mode 100755 new mode 100644 diff --git a/hawkbit-core/src/test/java/org/eclipse/hawkbit/eventbus/EventBusSubscriberProcessorTest.java b/hawkbit-core/src/test/java/org/eclipse/hawkbit/eventbus/EventBusSubscriberProcessorTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-amqp/pom.xml b/hawkbit-dmf-amqp/pom.xml old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java old mode 100755 new mode 100644 index 30cec2f74..4be22c14f --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpConfiguration.java @@ -47,7 +47,7 @@ public class AmqpConfiguration { /** * Method to set the Jackson2JsonMessageConverter. - * + * * @return the Jackson2JsonMessageConverter */ @Bean @@ -59,7 +59,7 @@ public class AmqpConfiguration { /** * Create the sp receiver queue. - * + * * @return the receiver queue */ @Bean @@ -69,7 +69,7 @@ public class AmqpConfiguration { /** * Create the dead letter fanout exchange. - * + * * @return the fanout exchange */ @Bean @@ -79,7 +79,7 @@ public class AmqpConfiguration { /** * Create dead letter queue. - * + * * @return the queue */ @Bean @@ -89,7 +89,7 @@ public class AmqpConfiguration { /** * Create the dead letter fanout exchange. - * + * * @return the fanout exchange */ @Bean @@ -99,7 +99,7 @@ public class AmqpConfiguration { /** * Create the Binding deadLetterQueue to exchangeDeadLetter. - * + * * @return the binding */ @Bean @@ -110,7 +110,7 @@ public class AmqpConfiguration { /** * Create the Binding {@link AmqpConfiguration#receiverQueueFromSp()} to * {@link AmqpConfiguration#senderConnectorToSpExchange()}. - * + * * @return the binding and create the queue and exchange */ @Bean @@ -120,7 +120,7 @@ public class AmqpConfiguration { /** * Create amqp handler service bean. - * + * * @return */ @Bean @@ -130,7 +130,7 @@ public class AmqpConfiguration { /** * Returns the Listener factory. - * + * * @return the {@link SimpleMessageListenerContainer} that gets used receive * AMQP messages */ @@ -143,7 +143,7 @@ public class AmqpConfiguration { } private Map getDeadLetterExchangeArgs() { - final Map args = new HashMap(); + final Map args = new HashMap<>(); args.put("x-dead-letter-exchange", amqpProperties.getDeadLetterExchange()); return args; } diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentfication.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentfication.java old mode 100755 new mode 100644 index ee31470f6..dd36ef1fd --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentfication.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentfication.java @@ -91,7 +91,7 @@ public class AmqpControllerAuthentfication { /** * Performs authentication with the secruity token. - * + * * @param secruityToken * the authentication request object * @return the authentfication object @@ -110,7 +110,7 @@ public class AmqpControllerAuthentfication { } - private PreAuthenticatedAuthenticationToken createAuthentication(final PreAuthenficationFilter filter, + private static PreAuthenticatedAuthenticationToken createAuthentication(final PreAuthenficationFilter filter, final TenantSecruityToken secruityToken) { if (!filter.isEnable(secruityToken)) { diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java old mode 100755 new mode 100644 index 933124560..7469e6768 --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherService.java @@ -31,13 +31,14 @@ import org.eclipse.hawkbit.util.IpUtil; import org.springframework.amqp.core.Message; import org.springframework.amqp.core.MessageProperties; import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.amqp.support.converter.AbstractJavaTypeMapper; import org.springframework.beans.factory.annotation.Autowired; import com.google.common.eventbus.Subscribe; /** * {@link AmqpMessageDispatcherService} handles all outgoing AMQP messages. - * + * * * */ @@ -56,7 +57,7 @@ public class AmqpMessageDispatcherService { /** * Method to send a message to a RabbitMQ Exchange after the Distribution * set has been assign to a Target. - * + * * @param targetAssignDistributionSetEvent * the object to be send. */ @@ -86,7 +87,7 @@ public class AmqpMessageDispatcherService { /** * Method to send a message to a RabbitMQ Exchange after the assignment of * the Distribution set to a Target has been canceled. - * + * * @param cancelTargetAssignmentDistributionSetEvent * the object to be send. */ @@ -104,13 +105,14 @@ public class AmqpMessageDispatcherService { /** * Send message to exchange. - * + * * @param exchange * the exchange * @param message * the message */ public void sendMessage(final String exchange, final Message message) { + message.getMessageProperties().getHeaders().remove(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME); rabbitTemplate.setExchange(exchange); rabbitTemplate.send(message); } @@ -124,7 +126,7 @@ public class AmqpMessageDispatcherService { return messageProperties; } - private MessageProperties createMessageProperties() { + private static MessageProperties createMessageProperties() { final MessageProperties messageProperties = new MessageProperties(); messageProperties.setContentType(MessageProperties.CONTENT_TYPE_JSON); messageProperties.setHeader(MessageHeaderKey.CONTENT_TYPE, MessageProperties.CONTENT_TYPE_JSON); diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java old mode 100755 new mode 100644 index 33a08980b..640c0e270 --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerService.java @@ -71,9 +71,9 @@ import org.springframework.web.util.UriComponentsBuilder; import com.google.common.eventbus.EventBus; /** - * + * * {@link AmqpMessageHandlerService} handles all incoming AMQP messages. - * + * * * * @@ -106,7 +106,7 @@ public class AmqpMessageHandlerService { /** * /** Method to handle all incoming amqp messages. - * + * * @param message * incoming message * @param type @@ -199,7 +199,7 @@ public class AmqpMessageHandlerService { return rabbitTemplate.getMessageConverter().toMessage(authentificationResponse, messageProperties); } - private Artifact convertDbArtifact(final DbArtifact dbArtifact) { + private static Artifact convertDbArtifact(final DbArtifact dbArtifact) { final Artifact artifact = new Artifact(); artifact.setSize(dbArtifact.getSize()); final DbArtifactHash dbArtifactHash = dbArtifact.getHashes(); @@ -212,13 +212,13 @@ public class AmqpMessageHandlerService { throw new IllegalArgumentException(error); } - private void setSecurityContext(final Authentication authentication) { + private static void setSecurityContext(final Authentication authentication) { final SecurityContextImpl securityContextImpl = new SecurityContextImpl(); securityContextImpl.setAuthentication(authentication); SecurityContextHolder.setContext(securityContextImpl); } - private void setTenantSecurityContext(final String tenantId) { + private static void setTenantSecurityContext(final String tenantId) { final AnonymousAuthenticationToken authenticationToken = new AnonymousAuthenticationToken( UUID.randomUUID().toString(), "AMQP-Controller", Collections.singletonList(new SimpleGrantedAuthority(SpringEvalExpressions.CONTROLLER_ROLE_ANONYMOUS))); @@ -237,7 +237,7 @@ public class AmqpMessageHandlerService { /** * Method to create a new target or to find the target if it already exists. - * + * * @param targetID * the ID of the target/thing * @param ip @@ -274,7 +274,7 @@ public class AmqpMessageHandlerService { /** * Method to handle the different topics to an event. - * + * * @param message * the incoming event message. * @param topic @@ -292,7 +292,7 @@ public class AmqpMessageHandlerService { /** * Method to update the action status of an action through the event. - * + * * @param actionUpdateStatus * the object form the ampq message */ @@ -330,6 +330,9 @@ public class AmqpMessageHandlerService { case RUNNING: actionStatus.setStatus(Status.RUNNING); break; + case CANCELED: + actionStatus.setStatus(Status.CANCELED); + break; case FINISHED: actionStatus.setStatus(Status.FINISHED); break; @@ -339,19 +342,43 @@ public class AmqpMessageHandlerService { case WARNING: actionStatus.setStatus(Status.WARNING); break; + case CANCEL_REJECTED: + handleCancelRejected(message, action, actionStatus); + break; default: logAndThrowMessageError(message, "Status for action does not exisit."); } - final Action savedAction = controllerManagement.addUpdateActionStatus(actionStatus, action); - if (Status.FINISHED == savedAction.getStatus()) { + Action addUpdateActionStatus; + + if (!actionStatus.getStatus().equals(Status.CANCELED)) { + addUpdateActionStatus = controllerManagement.addUpdateActionStatus(actionStatus, action); + } else { + addUpdateActionStatus = controllerManagement.addCancelActionStatus(actionStatus, action); + } + + if (!addUpdateActionStatus.isActive()) { lookIfUpdateAvailable(action.getTarget()); } } + private void handleCancelRejected(final Message message, final Action action, final ActionStatus actionStatus) { + if (action.isCancelingOrCanceled()) { + + actionStatus.setStatus(Status.WARNING); + + // cancel action rejected, write warning status message and fall + // back to running action status + + } else { + logAndThrowMessageError(message, + "Cancel Recjected message is not allowed, if action is on state: " + action.getStatus()); + } + } + /** * Is needed to convert a incoming message to is originally object type. - * + * * @param message * the message to convert. * @param clazz @@ -367,14 +394,15 @@ public class AmqpMessageHandlerService { /** * Is needed to verify if an incoming message has the content type json. - * + * * @param message * the to verify * @param contentType * the content type * @return true if the content type has json, false it not. */ - private void checkContentTypeJson(final Message message) { + + private static void checkContentTypeJson(final Message message) { final MessageProperties messageProperties = message.getMessageProperties(); if (messageProperties.getContentType() != null && messageProperties.getContentType().contains("json")) { return; diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpProperties.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/AmqpProperties.java old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/annotation/EnableAmqp.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/amqp/annotation/EnableAmqp.java old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/util/ArtifactUrlHandler.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/util/ArtifactUrlHandler.java old mode 100755 new mode 100644 index 488cfa2cb..f477da03a --- a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/util/ArtifactUrlHandler.java +++ b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/util/ArtifactUrlHandler.java @@ -14,15 +14,14 @@ import org.eclipse.hawkbit.repository.model.LocalArtifact; /** * Interface declaration of the {@link ArtifactUrlHandler} which generates the * URLs to specific artifacts. - * - * * */ +@FunctionalInterface public interface ArtifactUrlHandler { /** * Returns a generated URL for a given artifact for a specific protocol. - * + * * @param controllerId * the authentifacted controller id * @param localArtifact diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/util/ArtifactUrlHandlerProperties.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/util/ArtifactUrlHandlerProperties.java old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/util/PropertyBasedArtifactUrlHandler.java b/hawkbit-dmf-amqp/src/main/java/org/eclipse/hawkbit/util/PropertyBasedArtifactUrlHandler.java old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentficationTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpControllerAuthentficationTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java old mode 100755 new mode 100644 index f9c6ff64b..778f196e9 --- a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java +++ b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageDispatcherServiceTest.java @@ -43,6 +43,7 @@ import org.mockito.Mockito; import org.springframework.amqp.core.Message; import org.springframework.amqp.core.MessageProperties; import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.amqp.support.converter.AbstractJavaTypeMapper; import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter; import org.springframework.amqp.support.converter.MessageConverter; import org.springframework.test.context.ActiveProfiles; @@ -154,15 +155,15 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit CONTROLLER_ID, 1l, IpUtil.createAmqpUri("mytest")); amqpMessageDispatcherService .targetCancelAssignmentToDistributionSet(cancelTargetAssignmentDistributionSetEvent); - final Message sendMessage = createArgumentCapture( - cancelTargetAssignmentDistributionSetEvent.getTargetAdress().getHost()); + final Message sendMessage = createArgumentCapture(cancelTargetAssignmentDistributionSetEvent.getTargetAdress() + .getHost()); assertCancelMessage(sendMessage); } private void assertCancelMessage(final Message sendMessage) { assertEventMessage(sendMessage); - final Long actionId = (Long) messageConverter.fromMessage(sendMessage); + final Long actionId = convertMessage(sendMessage, Long.class); assertEquals(actionId, Long.valueOf(1)); assertEquals(EventTopic.CANCEL_DOWNLOAD, sendMessage.getMessageProperties().getHeaders().get(MessageHeaderKey.TOPIC)); @@ -171,8 +172,8 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit private DownloadAndUpdateRequest assertDownloadAndInstallMessage(final Message sendMessage) { assertEventMessage(sendMessage); - final DownloadAndUpdateRequest downloadAndUpdateRequest = (DownloadAndUpdateRequest) messageConverter - .fromMessage(sendMessage); + final DownloadAndUpdateRequest downloadAndUpdateRequest = convertMessage(sendMessage, + DownloadAndUpdateRequest.class); assertEquals(downloadAndUpdateRequest.getActionId(), Long.valueOf(1)); assertEquals(EventTopic.DOWNLOAD_AND_INSTALL, sendMessage.getMessageProperties().getHeaders().get(MessageHeaderKey.TOPIC)); @@ -197,4 +198,11 @@ public class AmqpMessageDispatcherServiceTest extends AbstractIntegrationTestWit return argumentCaptor.getValue(); } + @SuppressWarnings("unchecked") + private T convertMessage(final Message message, final Class clazz) { + message.getMessageProperties().getHeaders() + .put(AbstractJavaTypeMapper.DEFAULT_CLASSID_FIELD_NAME, clazz.getTypeName()); + return (T) rabbitTemplate.getMessageConverter().fromMessage(message); + } + } diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/amqp/AmqpMessageHandlerServiceTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/util/PropertyBasedArtifactUrlHandlerTest.java b/hawkbit-dmf-amqp/src/test/java/org/eclipse/hawkbit/util/PropertyBasedArtifactUrlHandlerTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-api/README.md b/hawkbit-dmf-api/README.md old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-api/pom.xml b/hawkbit-dmf-api/pom.xml old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/amqp/api/AmqpSettings.java b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/amqp/api/AmqpSettings.java old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/amqp/api/EventTopic.java b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/amqp/api/EventTopic.java old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/amqp/api/MessageHeaderKey.java b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/amqp/api/MessageHeaderKey.java old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/amqp/api/MessageType.java b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/amqp/api/MessageType.java old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionStatus.java b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionStatus.java old mode 100755 new mode 100644 index 883740354..12e80139a --- a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionStatus.java +++ b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionStatus.java @@ -22,6 +22,6 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; @JsonIgnoreProperties(ignoreUnknown = true) public enum ActionStatus { - DOWNLOAD, RETRIEVED, RUNNING, FINISHED, ERROR, WARNING; + DOWNLOAD, RETRIEVED, RUNNING, FINISHED, ERROR, WARNING, CANCELED, CANCEL_REJECTED; } diff --git a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionUpdateStatus.java b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ActionUpdateStatus.java old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/Artifact.java b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/Artifact.java old mode 100755 new mode 100644 index c3f555c33..27da75fb0 --- a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/Artifact.java +++ b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/Artifact.java @@ -8,7 +8,7 @@ */ package org.eclipse.hawkbit.dmf.json.model; -import java.util.HashMap; +import java.util.EnumMap; import java.util.Map; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -18,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** * JSON representation of artifact. - * + * * * */ @@ -28,11 +28,9 @@ public class Artifact { /** * Represented the supported protocols for artifact url's. - * - * * */ - public static enum UrlProtocol { + public enum UrlProtocol { COAP, HTTP, HTTPS } @@ -46,7 +44,7 @@ public class Artifact { private Long size; @JsonProperty - private Map urls = new HashMap<>(); + private Map urls = new EnumMap<>(UrlProtocol.class); public Map getUrls() { return urls; diff --git a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ArtifactHash.java b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/ArtifactHash.java old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DownloadAndUpdateRequest.java b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DownloadAndUpdateRequest.java old mode 100755 new mode 100644 index d31141879..4344c5416 --- a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DownloadAndUpdateRequest.java +++ b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DownloadAndUpdateRequest.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** * JSON representation of download and update request. - * + * * * * @@ -29,7 +29,7 @@ public class DownloadAndUpdateRequest { @JsonProperty private Long actionId; @JsonProperty - private final List softwareModules = new LinkedList(); + private final List softwareModules = new LinkedList<>(); public Long getActionId() { return actionId; @@ -45,7 +45,7 @@ public class DownloadAndUpdateRequest { /** * Add a Software module. - * + * * @param createSoftwareModule * the module */ diff --git a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DownloadResponse.java b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/DownloadResponse.java old mode 100755 new mode 100644 diff --git a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/SoftwareModule.java b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/SoftwareModule.java old mode 100755 new mode 100644 index 2e553c051..193f33575 --- a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/SoftwareModule.java +++ b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/SoftwareModule.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** * JSON representation of a software module. - * + * * * * @@ -35,7 +35,7 @@ public class SoftwareModule { @JsonProperty private String moduleVersion; @JsonProperty - private List artifacts = new LinkedList(); + private List artifacts = new LinkedList<>(); public String getModuleType() { return moduleType; diff --git a/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/TenantSecruityToken.java b/hawkbit-dmf-api/src/main/java/org/eclipse/hawkbit/dmf/json/model/TenantSecruityToken.java old mode 100755 new mode 100644 diff --git a/hawkbit-http-security/pom.xml b/hawkbit-http-security/pom.xml old mode 100755 new mode 100644 diff --git a/hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/AbstractHttpControllerAuthenticationFilter.java b/hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/AbstractHttpControllerAuthenticationFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/ControllerTenantAwareAuthenticationDetailsSource.java b/hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/ControllerTenantAwareAuthenticationDetailsSource.java old mode 100755 new mode 100644 diff --git a/hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/HttpControllerPreAuthenticateSecurityTokenFilter.java b/hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/HttpControllerPreAuthenticateSecurityTokenFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/HttpControllerPreAuthenticatedGatewaySecurityTokenFilter.java b/hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/HttpControllerPreAuthenticatedGatewaySecurityTokenFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/HttpControllerPreAuthenticatedSecurityHeaderFilter.java b/hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/HttpControllerPreAuthenticatedSecurityHeaderFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/HttpDownloadAuthenticationFilter.java b/hawkbit-http-security/src/main/java/org/eclipse/hawkbit/security/HttpDownloadAuthenticationFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java b/hawkbit-http-security/src/test/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProviderTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/README.md b/hawkbit-repository/README.md old mode 100755 new mode 100644 diff --git a/hawkbit-repository/pom.xml b/hawkbit-repository/pom.xml old mode 100755 new mode 100644 index 930d1bcc6..e5d7011ae --- a/hawkbit-repository/pom.xml +++ b/hawkbit-repository/pom.xml @@ -70,7 +70,6 @@ com.google.guava guava - 18.0 net._01001111 diff --git a/hawkbit-repository/src/fbExcludeFilter.xml b/hawkbit-repository/src/fbExcludeFilter.xml old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/Constants.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/Constants.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/MultiTenantJpaTransactionManager.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/RepositoryApplicationConfiguration.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/RepositoryApplicationConfiguration.java old mode 100755 new mode 100644 index d0450122c..a621e94fc --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/RepositoryApplicationConfiguration.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/RepositoryApplicationConfiguration.java @@ -11,7 +11,7 @@ package org.eclipse.hawkbit; import java.util.HashMap; import java.util.Map; -import org.eclipse.hawkbit.aspects.SpExceptionMappingAspect; +import org.eclipse.hawkbit.aspects.ExceptionMappingAspectHandler; import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.model.helper.CacheManagerHolder; import org.eclipse.hawkbit.repository.model.helper.PollConfigurationHelper; @@ -123,11 +123,11 @@ public class RepositoryApplicationConfiguration extends JpaBaseConfiguration { } /** - * @return {@link SpExceptionMappingAspect} aspect bean + * @return {@link ExceptionMappingAspectHandler} aspect bean */ @Bean - public SpExceptionMappingAspect createRepositoryExceptionHandlerAdvice() { - return new SpExceptionMappingAspect(); + public ExceptionMappingAspectHandler createRepositoryExceptionHandlerAdvice() { + return new ExceptionMappingAspectHandler(); } /* diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/aspects/ExceptionMappingAspectHandler.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/aspects/ExceptionMappingAspectHandler.java new file mode 100644 index 000000000..bcb96f45d --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/aspects/ExceptionMappingAspectHandler.java @@ -0,0 +1,179 @@ +/** + * 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.aspects; + +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import javax.transaction.TransactionManager; + +import org.aspectj.lang.annotation.AfterThrowing; +import org.aspectj.lang.annotation.Aspect; +import org.eclipse.hawkbit.exception.GenericSpServerException; +import org.eclipse.hawkbit.repository.exception.ConcurrentModificationException; +import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; +import org.eclipse.hawkbit.repository.exception.InsufficientPermissionException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.Ordered; +import org.springframework.dao.ConcurrencyFailureException; +import org.springframework.dao.DataAccessException; +import org.springframework.dao.DataIntegrityViolationException; +import org.springframework.dao.DuplicateKeyException; +import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator; +import org.springframework.orm.jpa.JpaSystemException; +import org.springframework.orm.jpa.JpaVendorAdapter; +import org.springframework.security.access.AccessDeniedException; +import org.springframework.transaction.TransactionSystemException; + +/** + * {@link Aspect} catches persistence exceptions and wraps them to custom + * specific exceptions Additionally it checks and prevents access to certain + * packages. Logging aspect which logs the call stack + * + * + * + */ +@Aspect +public class ExceptionMappingAspectHandler implements Ordered { + private static final Logger LOG = LoggerFactory.getLogger(ExceptionMappingAspectHandler.class); + + private static final Map EXCEPTION_MAPPING = new HashMap<>(); + + /** + * this is required to enable a certain order of exception and to select the + * most specific mappable exception according to the type hierarchy of the + * exception. + */ + private static final List> MAPPED_EXCEPTION_ORDER = new ArrayList<>(); + + @Autowired + private JpaVendorAdapter jpaVendorAdapter; + + private final SQLStateSQLExceptionTranslator sqlStateExceptionTranslator = new SQLStateSQLExceptionTranslator(); + + static { + MAPPED_EXCEPTION_ORDER.add(DuplicateKeyException.class); + MAPPED_EXCEPTION_ORDER.add(DataIntegrityViolationException.class); + MAPPED_EXCEPTION_ORDER.add(ConcurrencyFailureException.class); + MAPPED_EXCEPTION_ORDER.add(AccessDeniedException.class); + + EXCEPTION_MAPPING.put(DuplicateKeyException.class.getName(), EntityAlreadyExistsException.class.getName()); + EXCEPTION_MAPPING.put(DataIntegrityViolationException.class.getName(), + EntityAlreadyExistsException.class.getName()); + + EXCEPTION_MAPPING.put(ConcurrencyFailureException.class.getName(), + ConcurrentModificationException.class.getName()); + EXCEPTION_MAPPING.put(AccessDeniedException.class.getName(), InsufficientPermissionException.class.getName()); + } + + /** + * catch exceptions of the {@link TransactionManager} and wrap them to + * custom exceptions. + * + * @param ex + * the thrown and catched exception + * @throws Throwable + */ + @AfterThrowing(pointcut = "( execution( * org.springframework.transaction..*.*(..)) " + + " || execution( * org.eclipse.hawkbit.repository.*.*(..)) " + + " || execution( * org.eclipse.hawkbit.controller.*.*(..)) " + + " || execution( * org.eclipse.hawkbit.rest.resource.*.*(..)) " + + " || execution( * org.eclipse.hawkbit.service.*.*(..)) )", throwing = "ex") + public void catchAndWrapJpaExceptionsService(final Exception ex) throws Throwable { + LOG.trace("exception occured", ex); + Exception translatedAccessException = translateEclipseLinkExceptionIfPossible(ex); + + if (translatedAccessException == null && ex instanceof TransactionSystemException) { + final TransactionSystemException systemException = (TransactionSystemException) ex; + translatedAccessException = translateEclipseLinkExceptionIfPossible((Exception) systemException + .getOriginalException()); + } + + if (translatedAccessException == null) { + translatedAccessException = ex; + } + + Exception mappingException = translatedAccessException; + + LOG.trace("translated excpetion is", translatedAccessException); + for (final Class mappedEx : MAPPED_EXCEPTION_ORDER) { + + if (mappedEx.isAssignableFrom(translatedAccessException.getClass())) { + if (!EXCEPTION_MAPPING.containsKey(mappedEx.getName())) { + LOG.error("there is no mapping configured for exception class {}", mappedEx.getName()); + mappingException = new GenericSpServerException(ex); + } else { + mappingException = (Exception) Class.forName(EXCEPTION_MAPPING.get(mappedEx.getName())) + .getConstructor(Throwable.class).newInstance(ex); + } + break; + } + } + LOG.trace("mapped exception {} to {}", translatedAccessException.getClass(), mappingException.getClass()); + throw mappingException; + } + + private DataAccessException translateEclipseLinkExceptionIfPossible(final Exception exception) { + final DataAccessException translatedAccessException = jpaVendorAdapter.getJpaDialect() + .translateExceptionIfPossible((RuntimeException) exception); + return translateSQLStateExceptionIfPossible(translatedAccessException); + + } + + /** + * There is no EclipseLinkExceptionTranslator. So we have to check and + * translate the exception by the sql error code. Luckily, there we can use + * {@link SQLStateSQLExceptionTranslator} if we can get a + * {@link SQLException}. + * + * @param accessException + * the base access exception from jpa + * @return the translated accessException + */ + private DataAccessException translateSQLStateExceptionIfPossible(final DataAccessException accessException) { + if (!(accessException instanceof JpaSystemException)) { + return accessException; + } + + final SQLException ex = findSqlException((JpaSystemException) accessException); + + if (ex == null) { + return accessException; + } + + return sqlStateExceptionTranslator.translate(null, null, ex); + } + + private static SQLException findSqlException(final JpaSystemException jpaSystemException) { + Throwable exception = jpaSystemException.getCause(); + while (exception != null) { + final Throwable cause = exception.getCause(); + if (cause instanceof SQLException) { + return (SQLException) cause; + } + exception = cause; + } + return null; + } + + /* + * (non-Javadoc) + * + * @see org.springframework.core.Ordered#getOrder() + */ + @Override + public int getOrder() { + return 1; + } +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/aspects/SpExceptionMappingAspect.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/aspects/SpExceptionMappingAspect.java deleted file mode 100755 index 90fc95d8d..000000000 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/aspects/SpExceptionMappingAspect.java +++ /dev/null @@ -1,108 +0,0 @@ -/** - * 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.aspects; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.transaction.TransactionManager; - -import org.aspectj.lang.annotation.AfterThrowing; -import org.aspectj.lang.annotation.Aspect; -import org.eclipse.hawkbit.exception.GenericSpServerException; -import org.eclipse.hawkbit.repository.exception.ConcurrentModificationException; -import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; -import org.eclipse.hawkbit.repository.exception.InsufficientPermissionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.Ordered; -import org.springframework.dao.ConcurrencyFailureException; -import org.springframework.dao.DataIntegrityViolationException; -import org.springframework.dao.DuplicateKeyException; -import org.springframework.security.access.AccessDeniedException; - -/** - * {@link Aspect} catches persistence exceptions and wraps them to custom - * specific exceptions Additionally it checks and prevents access to certain - * packages. Logging aspect which logs the call stack - * - * - * - */ -@Aspect -public class SpExceptionMappingAspect implements Ordered { - private static final Logger LOG = LoggerFactory.getLogger(SpExceptionMappingAspect.class); - - private static final Map EXCEPTION_MAPPING = new HashMap(); - - /** - * this is required to enable a certain order of exception and to select the - * most specific mappable exception according to the type hierarchy of the - * exception. - */ - private static final List> MAPPED_EXCEPTION_ORDER = new ArrayList>(); - - static { - MAPPED_EXCEPTION_ORDER.add(DuplicateKeyException.class); - MAPPED_EXCEPTION_ORDER.add(DataIntegrityViolationException.class); - MAPPED_EXCEPTION_ORDER.add(ConcurrencyFailureException.class); - MAPPED_EXCEPTION_ORDER.add(AccessDeniedException.class); - - EXCEPTION_MAPPING.put(DuplicateKeyException.class.getName(), EntityAlreadyExistsException.class.getName()); - - EXCEPTION_MAPPING.put(ConcurrencyFailureException.class.getName(), - ConcurrentModificationException.class.getName()); - EXCEPTION_MAPPING.put(AccessDeniedException.class.getName(), InsufficientPermissionException.class.getName()); - } - - /** - * catch exceptions of the {@link TransactionManager} and wrap them to - * custom exceptions. - * - * @param ex - * the thrown and catched exception - * @throws Throwable - */ - @AfterThrowing(pointcut = "( execution( * org.springframework.transaction..*.*(..)) " - + " || execution( * org.eclipse.hawkbit.repository.*.*(..)) " - + " || execution( * org.eclipse.hawkbit.controller.*.*(..)) " - + " || execution( * org.eclipse.hawkbit.service.*.*(..)) )", throwing = "ex") - public void catchAndWrapJpaExceptionsService(final Exception ex) throws Throwable { - final Class exClass = ex.getClass(); - Exception newEx = ex; - LOG.trace("exception occured", ex); - for (final Class mappedEx : MAPPED_EXCEPTION_ORDER) { - - if (mappedEx.isAssignableFrom(exClass)) { - if (!EXCEPTION_MAPPING.containsKey(mappedEx.getName())) { - LOG.error("there is no mapping configured for exception class {}", mappedEx.getName()); - newEx = new GenericSpServerException(ex); - } else { - newEx = (Exception) Class.forName(EXCEPTION_MAPPING.get(mappedEx.getName())) - .getConstructor(Throwable.class).newInstance(ex); - } - break; - } - } - LOG.trace("mapped exception {} to {}", ex.getClass(), newEx.getClass()); - throw newEx; - } - - /* - * (non-Javadoc) - * - * @see org.springframework.core.Ordered#getOrder() - */ - @Override - public int getOrder() { - return 1; - } -} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/cache/CacheField.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/cache/CacheField.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/cache/CacheKeys.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/cache/CacheKeys.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/cache/CacheWriteNotify.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/cache/CacheWriteNotify.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/CacheFieldEntityListener.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/CacheFieldEntityListener.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/EntityChangeEventListener.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/EntityChangeEventListener.java old mode 100755 new mode 100644 index a62d9265b..e1ff377e5 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/EntityChangeEventListener.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/EntityChangeEventListener.java @@ -18,6 +18,7 @@ import org.aspectj.lang.annotation.Aspect; import org.eclipse.hawkbit.eventbus.event.TargetCreatedEvent; import org.eclipse.hawkbit.eventbus.event.TargetDeletedEvent; import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent; +import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor; import org.eclipse.hawkbit.repository.TargetRepository; import org.eclipse.hawkbit.repository.model.BaseEntity; import org.eclipse.hawkbit.repository.model.Target; @@ -49,6 +50,9 @@ public class EntityChangeEventListener { @Autowired private EntityManager entityManager; + @Autowired + private AfterTransactionCommitExecutor afterCommit; + /** * In case the a {@link Target} is created a corresponding * {@link TargetInfo} is created as well. We need the {@link TargetInfo} @@ -68,10 +72,6 @@ public class EntityChangeEventListener { final Object result = joinpoint.proceed(); if (result instanceof TargetInfo) { if (isNew) { - // we need to flush here because seems like eclipselink - // implementation setting the ID of the target no immediately - // otherwise. - entityManager.flush(); notifyTargetCreated(entityManager.merge(entityManager.merge(((TargetInfo) result).getTarget()))); } else { notifyTargetInfoChanged((TargetInfo) result); @@ -129,15 +129,16 @@ public class EntityChangeEventListener { } private void notifyTargetCreated(final Target t) { - eventBus.post(new TargetCreatedEvent(t)); + afterCommit.afterCommit(() -> eventBus.post(new TargetCreatedEvent(t))); + } private void notifyTargetInfoChanged(final TargetInfo targetInfo) { - eventBus.post(new TargetInfoUpdateEvent(targetInfo)); + afterCommit.afterCommit(() -> eventBus.post(new TargetInfoUpdateEvent(targetInfo))); } private void notifyTargetDeleted(final String tenant, final Long targetId) { - eventBus.post(new TargetDeletedEvent(tenant, targetId)); + afterCommit.afterCommit(() -> eventBus.post(new TargetDeletedEvent(tenant, targetId))); } private boolean isTargetInfoNew(final Object targetInfo) { diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractBaseEntityEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractBaseEntityEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractEntityBulkEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractEntityBulkEvent.java new file mode 100644 index 000000000..0a0ce88ce --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/AbstractEntityBulkEvent.java @@ -0,0 +1,70 @@ +/** + * 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.eventbus.event; + +import java.util.Arrays; +import java.util.List; + +import org.eclipse.hawkbit.repository.model.BaseEntity; + +/** + * + * A abstract typesafe bulkevent which contains all changed base entities. + * + * @param + */ +public abstract class AbstractEntityBulkEvent implements EntityBulkEvent { + + private static final long serialVersionUID = 1L; + + private List entities; + + private String tenant; + + /** + * Constructor. + * + * @param tenant + * the tenant + * @param entities + * the changed entities + */ + public AbstractEntityBulkEvent(final String tenant, final List entities) { + this.entities = entities; + this.tenant = tenant; + } + + /** + * Constructor. + * + * @param tenant + * the tenant + * @param entitiy + * the changed entity + */ + public AbstractEntityBulkEvent(final String tenant, final E entitiy) { + this(tenant, Arrays.asList(entitiy)); + } + + @Override + public List getEntities() { + return entities; + } + + @Override + public long getRevision() { + return -1; + } + + @Override + public String getTenant() { + return tenant; + } + +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagAssigmentResultEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagAssigmentResultEvent.java new file mode 100644 index 000000000..9a8a485b4 --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagAssigmentResultEvent.java @@ -0,0 +1,34 @@ +/** + * 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.eventbus.event; + +import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult; + +/** + * A event for assignment target tag. + */ +public class DistributionSetTagAssigmentResultEvent { + + private final DistributionSetTagAssigmentResult assigmentResult; + + /** + * Constructor. + * + * @param assigmentResult + * the assignment result- + */ + public DistributionSetTagAssigmentResultEvent(final DistributionSetTagAssigmentResult assigmentResult) { + this.assigmentResult = assigmentResult; + } + + public DistributionSetTagAssigmentResult getAssigmentResult() { + return assigmentResult; + } + +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagCreatedBulkEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagCreatedBulkEvent.java new file mode 100644 index 000000000..fb7c4a862 --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagCreatedBulkEvent.java @@ -0,0 +1,46 @@ +/** + * 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.eventbus.event; + +import java.util.List; + +import org.eclipse.hawkbit.repository.model.DistributionSetTag; + +/** + * * A bulk event which contains one or many new ds tag after creating. + */ +public class DistributionSetTagCreatedBulkEvent extends AbstractEntityBulkEvent { + + private static final long serialVersionUID = 1L; + + /** + * Constructor. + * + * @param tenant + * the tenant + * @param entities + * the new ds tags + */ + public DistributionSetTagCreatedBulkEvent(final String tenant, final List entities) { + super(tenant, entities); + } + + /** + * Constructor. + * + * @param tenant + * the tenant. + * @param entity + * the new ds tag + */ + public DistributionSetTagCreatedBulkEvent(final String tenant, final DistributionSetTag entity) { + super(tenant, entity); + } + +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagDeletedEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagDeletedEvent.java new file mode 100644 index 000000000..b909390d1 --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagDeletedEvent.java @@ -0,0 +1,31 @@ +/** + * 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.eventbus.event; + +import org.eclipse.hawkbit.repository.model.DistributionSetTag; + +/** + * Defines the {@link AbstractBaseEntityEvent} of update a + * {@link DistributionSetTag}. + * + */ +public class DistributionSetTagDeletedEvent extends AbstractBaseEntityEvent { + + private static final long serialVersionUID = 1L; + + /** + * Constructor. + * + * @param tag + * the tag which is deleted + */ + public DistributionSetTagDeletedEvent(final DistributionSetTag tag) { + super(tag); + } +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagUpdateEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagUpdateEvent.java new file mode 100644 index 000000000..2825322f9 --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/DistributionSetTagUpdateEvent.java @@ -0,0 +1,31 @@ +/** + * 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.eventbus.event; + +import org.eclipse.hawkbit.repository.model.DistributionSetTag; + +/** + * Defines the {@link AbstractBaseEntityEvent} for update a + * {@link DistributionSetTag}. + * + */ +public class DistributionSetTagUpdateEvent extends AbstractBaseEntityEvent { + + private static final long serialVersionUID = 1L; + + /** + * Constructor. + * + * @param tag + * the tag which is updated + */ + public DistributionSetTagUpdateEvent(final DistributionSetTag tag) { + super(tag); + } +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/EntityBulkEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/EntityBulkEvent.java new file mode 100644 index 000000000..2004d3017 --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/EntityBulkEvent.java @@ -0,0 +1,34 @@ +/** + * 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.eventbus.event; + +import java.io.Serializable; +import java.util.List; + +import org.eclipse.hawkbit.repository.model.BaseEntity; + +/** + * An event interface which declares event types that an entities has been + * changed. + * + * @param + * the entity type + */ +public interface EntityBulkEvent extends Serializable, Event { + + /** + * A typesafe way to retrieve the the entities from the event, which might + * be loaded lazy in case the event has been distributed from another node. + * + * @return the entities might be lazy loaded. Might be {@code null} in case + * the entity e.g. is queried lazy on a different node and has been + * already deleted from the database + */ + List getEntities(); +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetAssignDistributionSetEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetAssignDistributionSetEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetCreatedEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetCreatedEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetInfoUpdateEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetInfoUpdateEvent.java old mode 100755 new mode 100644 index 1119026bd..563bb4bdc --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetInfoUpdateEvent.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetInfoUpdateEvent.java @@ -11,9 +11,7 @@ package org.eclipse.hawkbit.eventbus.event; import org.eclipse.hawkbit.repository.model.TargetInfo; /** - * - * - * + * Event for update the targets info. */ public class TargetInfoUpdateEvent implements EntityEvent { @@ -24,6 +22,8 @@ public class TargetInfoUpdateEvent implements EntityEvent { private String nodeId; /** + * Constructor. + * * @param targetInfo * the target info entity */ diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagAssigmentResultEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagAssigmentResultEvent.java new file mode 100644 index 000000000..405595de0 --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagAssigmentResultEvent.java @@ -0,0 +1,34 @@ +/** + * 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.eventbus.event; + +import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult; + +/** + * A event for assignment target tag. + */ +public class TargetTagAssigmentResultEvent { + + private final TargetTagAssigmentResult assigmentResult; + + /** + * Constructor. + * + * @param assigmentResult + * the assignment result- + */ + public TargetTagAssigmentResultEvent(final TargetTagAssigmentResult assigmentResult) { + this.assigmentResult = assigmentResult; + } + + public TargetTagAssigmentResult getAssigmentResult() { + return assigmentResult; + } + +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagCreatedBulkEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagCreatedBulkEvent.java new file mode 100644 index 000000000..c66a5150e --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagCreatedBulkEvent.java @@ -0,0 +1,46 @@ +/** + * 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.eventbus.event; + +import java.util.List; + +import org.eclipse.hawkbit.repository.model.TargetTag; + +/** + * A bulk event which contains one or many new target tags after creating. + */ +public class TargetTagCreatedBulkEvent extends AbstractEntityBulkEvent { + + private static final long serialVersionUID = 1L; + + /** + * Constructor. + * + * @param tenant + * the tenant + * @param entities + * the new targets + */ + public TargetTagCreatedBulkEvent(final String tenant, final List entities) { + super(tenant, entities); + } + + /** + * Constructor. + * + * @param tenant + * the tenant + * @param entity + * one new target + */ + public TargetTagCreatedBulkEvent(final String tenant, final TargetTag entity) { + super(tenant, entity); + } + +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagDeletedEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagDeletedEvent.java new file mode 100644 index 000000000..040fbc19a --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagDeletedEvent.java @@ -0,0 +1,30 @@ +/** + * 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.eventbus.event; + +import org.eclipse.hawkbit.repository.model.TargetTag; + +/** + * Defines the {@link AbstractBaseEntityEvent} of update a {@link TargetTag}. + * + */ +public class TargetTagDeletedEvent extends AbstractBaseEntityEvent { + + private static final long serialVersionUID = 1L; + + /** + * Constructor. + * + * @param tag + * the tag which is deleted + */ + public TargetTagDeletedEvent(final TargetTag tag) { + super(tag); + } +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagUpdateEvent.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagUpdateEvent.java new file mode 100644 index 000000000..4562063aa --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/eventbus/event/TargetTagUpdateEvent.java @@ -0,0 +1,30 @@ +/** + * 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.eventbus.event; + +import org.eclipse.hawkbit.repository.model.TargetTag; + +/** + * Defines the {@link AbstractBaseEntityEvent} for update a {@link TargetTag}. + * + */ +public class TargetTagUpdateEvent extends AbstractBaseEntityEvent { + + private static final long serialVersionUID = 1L; + + /** + * Constructor. + * + * @param tag + * the tag which is updated + */ + public TargetTagUpdateEvent(final TargetTag tag) { + super(tag); + } +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/executor/AfterTransactionCommitDefaultServiceExecutor.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/executor/AfterTransactionCommitDefaultServiceExecutor.java new file mode 100644 index 000000000..9b66178ba --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/executor/AfterTransactionCommitDefaultServiceExecutor.java @@ -0,0 +1,69 @@ +/** + * 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.executor; + +import java.util.ArrayList; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; +import org.springframework.transaction.support.TransactionSynchronizationAdapter; +import org.springframework.transaction.support.TransactionSynchronizationManager; + +/** + * + * A Service which calls register runnable. This runnables will executed after a + * successful spring transaction commit.The class is thread safe. + */ +@Service +public class AfterTransactionCommitDefaultServiceExecutor extends TransactionSynchronizationAdapter implements + AfterTransactionCommitExecutor { + private static final Logger LOGGER = LoggerFactory.getLogger(AfterTransactionCommitDefaultServiceExecutor.class); + private static final ThreadLocal> THREAD_LOCAL_RUNNABLES = new ThreadLocal<>(); + + @Override + public void afterCommit() { + final List afterCommitRunnables = THREAD_LOCAL_RUNNABLES.get(); + LOGGER.debug("Transaction successfully committed, executing {} runnables", afterCommitRunnables.size()); + for (final Runnable afterCommitRunnable : afterCommitRunnables) { + LOGGER.debug("Executing runnable {}", afterCommitRunnable); + try { + afterCommitRunnable.run(); + } catch (final RuntimeException e) { + LOGGER.error("Failed to execute runnable " + afterCommitRunnable, e); + } + } + } + + @Override + public void afterCommit(final Runnable runnable) { + LOGGER.debug("Submitting new runnable {} to run after transaction commit", runnable); + if (TransactionSynchronizationManager.isSynchronizationActive()) { + List localRunnables = THREAD_LOCAL_RUNNABLES.get(); + if (localRunnables == null) { + localRunnables = new ArrayList<>(); + THREAD_LOCAL_RUNNABLES.set(localRunnables); + TransactionSynchronizationManager.registerSynchronization(this); + } + localRunnables.add(runnable); + return; + } + LOGGER.info("Transaction synchronization is NOT ACTIVE/ INACTIVE. Executing right now runnable {}", runnable); + runnable.run(); + } + + @Override + public void afterCompletion(final int status) { + final String transactionStatus = status == STATUS_COMMITTED ? "COMMITTED" : "ROLLEDBACK"; + LOGGER.debug("Transaction completed after commit with status {}", transactionStatus); + THREAD_LOCAL_RUNNABLES.remove(); + } + +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/executor/AfterTransactionCommitExecutor.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/executor/AfterTransactionCommitExecutor.java new file mode 100644 index 000000000..ab5c67bab --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/executor/AfterTransactionCommitExecutor.java @@ -0,0 +1,28 @@ +/** + * 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.executor; + +/** + * + * A interface to register a runnable, which will be executed after a successful + * spring transaction. + * + */ +@FunctionalInterface +public interface AfterTransactionCommitExecutor { + + /** + * Register a runnable which will be executed after a successful spring + * transaction. + * + * @param runnable + * the after commit runnable + */ + void afterCommit(Runnable runnable); +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/AbstractReportSeries.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/AbstractReportSeries.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/DataReportSeries.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/DataReportSeries.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/DataReportSeriesItem.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/DataReportSeriesItem.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/InnerOuterDataReportSeries.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/InnerOuterDataReportSeries.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/ListReportSeries.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/ListReportSeries.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/SeriesTime.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/SeriesTime.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/SystemUsageReport.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/SystemUsageReport.java new file mode 100644 index 000000000..45cc60cba --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/SystemUsageReport.java @@ -0,0 +1,95 @@ +/** + * 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.report.model; + +import java.util.ArrayList; +import java.util.List; + +import com.google.common.collect.ImmutableList; + +/** + * Bean for holding the system usage stats. + * + */ +public class SystemUsageReport { + private final long overallTargets; + private final long overallArtifacts; + private final long overallArtifactVolumeInBytes; + private final long overallActions; + + private final List tenants = new ArrayList<>(); + + /** + * Constructor. + * + * @param overallTargets + * of the system + * @param overallArtifacts + * of the system + * @param overallActions + * of the system + * @param overallArtifactVolumeInBytes + * of the system + */ + public SystemUsageReport(final long overallTargets, final long overallArtifacts, final long overallActions, + final long overallArtifactVolumeInBytes) { + super(); + this.overallTargets = overallTargets; + this.overallArtifacts = overallArtifacts; + this.overallActions = overallActions; + + this.overallArtifactVolumeInBytes = overallArtifactVolumeInBytes; + } + + /** + * @return overallTargets in the system + */ + public long getOverallTargets() { + return overallTargets; + } + + /** + * @return overallArtifacts in the system + */ + public long getOverallArtifacts() { + return overallArtifacts; + } + + /** + * @return overallArtifactVolumeInBytes of the system + */ + public long getOverallArtifactVolumeInBytes() { + return overallArtifactVolumeInBytes; + } + + /** + * @param tenantUsage + * of one tenant + * @return updated bean + */ + public SystemUsageReport addTenantData(final TenantUsage tenantUsage) { + tenants.add(tenantUsage); + return this; + } + + /** + * @return actions of system + */ + public long getOverallActions() { + return overallActions; + } + + /** + * @return tenant data + */ + public List getTenants() { + return ImmutableList.copyOf(tenants); + } + +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/TenantUsage.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/TenantUsage.java new file mode 100644 index 000000000..d0ee7102c --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/report/model/TenantUsage.java @@ -0,0 +1,161 @@ +/** + * 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.report.model; + +/** + * System usage stats element for a tenant. + * + */ +public class TenantUsage { + + private final String tenantName; + private long targets; + private long artifacts; + private long actions; + private long overallArtifactVolumeInBytes; + + /** + * Constructor. + * + * @param tenantName + */ + public TenantUsage(final String tenantName) { + super(); + this.tenantName = tenantName; + } + + /** + * @return name of the tenant + */ + public String getTenantName() { + return tenantName; + } + + /** + * @return number of targets of the tenant + */ + public long getTargets() { + return targets; + } + + /** + * @param targets + * of the tenant + * @return updated tenant stats element + */ + public TenantUsage setTargets(final long targets) { + this.targets = targets; + return this; + } + + /** + * @return number of undeleted artifacts of the tenant + */ + public long getArtifacts() { + return artifacts; + } + + /** + * @param artifacts + * of tenant + * @return updated tenant stats element + */ + public TenantUsage setArtifacts(final long artifacts) { + this.artifacts = artifacts; + return this; + } + + /** + * @return current overallArtifactVolumeInBytes + */ + public long getOverallArtifactVolumeInBytes() { + return overallArtifactVolumeInBytes; + } + + /** + * @param overallArtifactVolumeInBytes + * of the tenant in bytes + * @return updated tenant stats element + */ + public TenantUsage setOverallArtifactVolumeInBytes(final long overallArtifactVolumeInBytes) { + this.overallArtifactVolumeInBytes = overallArtifactVolumeInBytes; + return this; + } + + /** + * @return number of actions of tenant + */ + public long getActions() { + return actions; + } + + /** + * @param actions + * of the tenant + * @return updated tenant stats element + */ + public TenantUsage setActions(final long actions) { + this.actions = actions; + return this; + } + + @Override + public int hashCode() { // NOSONAR - as this is generated code + final int prime = 31; + int result = 1; + result = prime * result + (int) (actions ^ (actions >>> 32)); + result = prime * result + (int) (artifacts ^ (artifacts >>> 32)); + result = prime * result + (int) (overallArtifactVolumeInBytes ^ (overallArtifactVolumeInBytes >>> 32)); + result = prime * result + (int) (targets ^ (targets >>> 32)); + result = prime * result + ((tenantName == null) ? 0 : tenantName.hashCode()); + return result; + } + + @Override + public boolean equals(final Object obj) { // NOSONAR - as this is generated + // code + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final TenantUsage other = (TenantUsage) obj; + if (actions != other.actions) { + return false; + } + if (artifacts != other.artifacts) { + return false; + } + if (overallArtifactVolumeInBytes != other.overallArtifactVolumeInBytes) { + return false; + } + if (targets != other.targets) { + return false; + } + if (tenantName == null) { + if (other.tenantName != null) { + return false; + } + } else if (!tenantName.equals(other.tenantName)) { + return false; + } + return true; + } + + @Override + public String toString() { + return "SystemUsage [tenantName=" + tenantName + ", targets=" + targets + ", artifacts=" + artifacts + + ", actions=" + actions + ", overallArtifactVolumeInBytes=" + overallArtifactVolumeInBytes + "]"; + } + +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionStatusRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ActionStatusRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ArtifactManagement.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/BaseEntityRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/BaseEntityRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java old mode 100755 new mode 100644 index 55ed458ec..844bbd097 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ControllerManagement.java @@ -11,7 +11,6 @@ package org.eclipse.hawkbit.repository; import java.net.URI; import java.util.List; import java.util.Map; -import java.util.stream.Collectors; import javax.persistence.EntityManager; import javax.persistence.criteria.CriteriaBuilder; @@ -135,8 +134,8 @@ public class ControllerManagement implements EnvironmentAware { final List action = actionRepository.findActionByTargetAndSoftwareModule(targetId, module); if (action.isEmpty() || action.get(0).isCancelingOrCanceled()) { - throw new EntityNotFoundException("No assigment found for module " + module.getId() + " to target " - + targetId); + throw new EntityNotFoundException( + "No assigment found for module " + module.getId() + " to target " + targetId); } return action.get(0); @@ -270,22 +269,20 @@ public class ControllerManagement implements EnvironmentAware { } /** - * Reports an {@link ActionStatus} for a {@link CancelAction}. - * - * @param actionStatusMessages + * Adds an {@link ActionStatus} for a {@link UpdateAction} and cancels the + * {@link UpdateAction} if necessary. + * + * @param actionStatus * to be updated - * @param target2 - * - * @throws EntityAlreadyExistsException - * if a given entity already exists - * @throws ToManyStatusEntriesException - * if more than the allowed number of status entries are - * inserted + * @param action + * the status is for + * @return the persisted {@link Action} + * */ @Modifying @Transactional @PreAuthorize(SpringEvalExpressions.IS_CONTROLLER) - public void addCancelActionStatus(@NotNull final ActionStatus actionStatus, final Action action) { + public Action addCancelActionStatus(@NotNull final ActionStatus actionStatus, final Action action) { checkForToManyStatusEntries(action); action.setStatus(actionStatus.getStatus()); @@ -298,12 +295,9 @@ public class ControllerManagement implements EnvironmentAware { case CANCELED: case FINISHED: // in case of successful cancelation we also report the success at - // the canceled action - // itself. + // the canceled action itself. actionStatus.addMessage("Cancelation completion is finished sucessfully."); - // set action inactive - action.setActive(false); - successCancellation(action); + deploymentManagement.successCancellation(action); break; case RETRIEVED: actionStatus.addMessage("Cancelation request retrieved"); @@ -312,30 +306,18 @@ public class ControllerManagement implements EnvironmentAware { } actionRepository.save(action); actionStatusRepository.save(actionStatus); - } - private void successCancellation(final Action action) { - final Target target = action.getTarget(); - final List nextActiveActions = actionRepository.findByTargetAndActiveOrderByIdAsc(target, true) - .stream().filter(a -> !a.getId().equals(action.getId())).collect(Collectors.toList()); - - if (nextActiveActions.isEmpty()) { - target.setAssignedDistributionSet(target.getTargetInfo().getInstalledDistributionSet()); - deploymentManagement.updateTargetInfo(target, TargetUpdateStatus.IN_SYNC, false); - } else { - target.setAssignedDistributionSet(nextActiveActions.get(0).getDistributionSet()); - } - targetManagement.updateTarget(target); + return action; } /** - * Reports an {@link ActionStatus} for a {@link UpdateAction}. + * Updates an {@link ActionStatus} for a {@link UpdateAction}. * * @param actionStatus * to be updated * @param action * the update is for - * @return the persisted {@link ActionStatus} + * @return the persisted {@link Action} * * @throws EntityAlreadyExistsException * if a given entity already exists @@ -420,8 +402,8 @@ public class ControllerManagement implements EnvironmentAware { final TargetInfo targetInfo = target.getTargetInfo(); final DistributionSet ds = entityManager.merge(action.getDistributionSet()); targetInfo.setInstalledDistributionSet(ds); - if (target.getAssignedDistributionSet() != null && targetInfo.getInstalledDistributionSet() != null - && target.getAssignedDistributionSet().getId().equals(targetInfo.getInstalledDistributionSet().getId())) { + if (target.getAssignedDistributionSet() != null && targetInfo.getInstalledDistributionSet() != null && target + .getAssignedDistributionSet().getId().equals(targetInfo.getInstalledDistributionSet().getId())) { targetInfo.setUpdateStatus(TargetUpdateStatus.IN_SYNC); targetInfo.setInstallationDate(System.currentTimeMillis()); } else { @@ -461,8 +443,7 @@ public class ControllerManagement implements EnvironmentAware { target.getTargetInfo().getControllerAttributes().putAll(data); if (target.getTargetInfo().getControllerAttributes().size() > maxAttributes) { - LOG_DOS.info( - "Target tries to insert more than the allowed number of entries ({}). DOS attack anticipated!", + LOG_DOS.info("Target tries to insert more than the allowed number of entries ({}). DOS attack anticipated!", maxAttributes); throw new ToManyAttributeEntriesException(String.valueOf(maxAttributes)); } @@ -474,7 +455,7 @@ public class ControllerManagement implements EnvironmentAware { /* * (non-Javadoc) - * + * * @see org.springframework.context.EnvironmentAware#setEnvironment(org. * springframework.core.env. Environment) */ diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java old mode 100755 new mode 100644 index adfb3beb2..0288c83a5 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DeploymentManagement.java @@ -28,10 +28,14 @@ import javax.persistence.criteria.Root; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.Constants; +import org.eclipse.hawkbit.eventbus.event.CancelTargetAssignmentEvent; +import org.eclipse.hawkbit.eventbus.event.TargetAssignDistributionSetEvent; +import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent; +import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; -import org.eclipse.hawkbit.repository.event.DeploymentManagementEvents; import org.eclipse.hawkbit.repository.exception.CancelActionNotAllowedException; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; +import org.eclipse.hawkbit.repository.exception.ForceQuitActionNotAllowedException; import org.eclipse.hawkbit.repository.exception.IncompleteDistributionSetException; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.ActionType; @@ -65,6 +69,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import com.google.common.collect.Lists; +import com.google.common.eventbus.EventBus; /** * Business service facade for managing all deployment related data and actions. @@ -105,11 +110,14 @@ public class DeploymentManagement { private AuditorAware auditorProvider; @Autowired - private DeploymentManagementEvents deploymentManagementEvents; + private EventBus eventBus; + + @Autowired + private AfterTransactionCommitExecutor afterCommit; /** * method assigns the {@link DistributionSet} to all {@link Target}s. - * + * * @param pset * {@link DistributionSet} which is assigned to the * {@link Target}s @@ -139,7 +147,7 @@ public class DeploymentManagement { /** * method assigns the {@link DistributionSet} to all {@link Target}s by * their IDs. - * + * * @param dsID * {@link DistributionSet} which is assigned to the * {@link Target}s @@ -168,7 +176,7 @@ public class DeploymentManagement { /** * method assigns the {@link DistributionSet} to all {@link Target}s by * their IDs with a specific {@link ActionType} and {@code forcetime}. - * + * * @param dsID * the ID of the distribution set to assign * @param actionType @@ -190,14 +198,16 @@ public class DeploymentManagement { @CacheEvict(value = { "distributionUsageAssigned" }, allEntries = true) public DistributionSetAssignmentResult assignDistributionSet(@NotNull final Long dsID, final ActionType actionType, final long forcedTimestamp, @NotEmpty final String... targetIDs) { - return assignDistributionSet(dsID, Arrays.stream(targetIDs) - .map(t -> new TargetWithActionType(t, actionType, forcedTimestamp)).collect(Collectors.toList())); + return assignDistributionSet( + dsID, + Arrays.stream(targetIDs).map(t -> new TargetWithActionType(t, actionType, forcedTimestamp)) + .collect(Collectors.toList())); } /** * method assigns the {@link DistributionSet} to all {@link Target}s by * their IDs with a specific {@link ActionType} and {@code forcetime}. - * + * * @param dsID * the ID of the distribution set to assign * @param targets @@ -216,8 +226,8 @@ public class DeploymentManagement { final List targets) { final DistributionSet set = distributoinSetRepository.findOne(dsID); if (set == null) { - throw new EntityNotFoundException( - String.format("no %s with id %d found", DistributionSet.class.getSimpleName(), dsID)); + throw new EntityNotFoundException(String.format("no %s with id %d found", + DistributionSet.class.getSimpleName(), dsID)); } return assignDistributionSetToTargets(set, targets); @@ -226,7 +236,7 @@ public class DeploymentManagement { /** * method assigns the {@link DistributionSet} to all {@link Target}s by * their IDs with a specific {@link ActionType} and {@code forcetime}. - * + * * @param dsID * the ID of the distribution set to assign * @param targetsWithActionType @@ -241,8 +251,8 @@ public class DeploymentManagement { final List targetsWithActionType) { if (!set.isComplete()) { - throw new IncompleteDistributionSetException( - "Distribution set of type " + set.getType().getKey() + " is incomplete: " + set.getId()); + throw new IncompleteDistributionSetException("Distribution set of type " + set.getType().getKey() + + " is incomplete: " + set.getId()); } final List controllerIDs = targetsWithActionType.stream().map(TargetWithActionType::getTargetId) @@ -250,8 +260,8 @@ public class DeploymentManagement { LOG.debug("assignDistribution({}) to {} targets", set, controllerIDs.size()); - final Map targetsWithActionMap = targetsWithActionType.stream() - .collect(Collectors.toMap(TargetWithActionType::getTargetId, Function.identity())); + final Map targetsWithActionMap = targetsWithActionType.stream().collect( + Collectors.toMap(TargetWithActionType::getTargetId, Function.identity())); // split tIDs length into max entries in-statement because many database // have constraint of @@ -261,10 +271,12 @@ public class DeploymentManagement { // we take the target only into account if the requested operation is no // duplicate of a // previous one - final List targets = Lists.partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT).stream() - .map(ids -> targetRepository - .findAll(TargetSpecifications.hasControllerIdAndAssignedDistributionSetIdNot(ids, set.getId()))) - .flatMap(t -> t.stream()).collect(Collectors.toList()); + final List targets = Lists + .partition(controllerIDs, Constants.MAX_ENTRIES_IN_STATEMENT) + .stream() + .map(ids -> targetRepository.findAll(TargetSpecifications + .hasControllerIdAndAssignedDistributionSetIdNot(ids, set.getId()))).flatMap(t -> t.stream()) + .collect(Collectors.toList()); if (targets.isEmpty()) { // detaching as it is not necessary to persist the set itself @@ -327,8 +339,8 @@ public class DeploymentManagement { }); // select updated targets in order to return them - final DistributionSetAssignmentResult result = new DistributionSetAssignmentResult( - targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), targets.size(), + final DistributionSetAssignmentResult result = new DistributionSetAssignmentResult(targets.stream() + .map(target -> target.getControllerId()).collect(Collectors.toList()), targets.size(), controllerIDs.size() - targets.size(), Lists.newArrayList(targetIdsToActions.values()), targetManagement); @@ -340,16 +352,40 @@ public class DeploymentManagement { entityManager.detach(set); // send distribution set assignment event - targets.stream().filter(t -> !!!targetIdsCancellList.contains(t.getId())) - .forEach(t -> deploymentManagementEvents.assignDistributionSet(t, - targetIdsToActions.get(t.getControllerId()).getId(), softwareModules)); + + targets.stream() + .filter(t -> !!!targetIdsCancellList.contains(t.getId())) + .forEach( + t -> assignDistributionSetEvent(t, targetIdsToActions.get(t.getControllerId()).getId(), + softwareModules)); return result; } + /** + * Sends the {@link TargetAssignDistributionSetEvent} for a specific target + * to the {@link EventBus}. + * + * @param target + * the Target which has been assigned to a distribution set + * @param actionId + * the action id of the assignment + * @param softwareModules + * the software modules which have been assigned + */ + private void assignDistributionSetEvent(final Target target, final Long actionId, + final List softwareModules) { + target.getTargetInfo().setUpdateStatus(TargetUpdateStatus.PENDING); + afterCommit.afterCommit(() -> { + eventBus.post(new TargetInfoUpdateEvent(target.getTargetInfo())); + eventBus.post(new TargetAssignDistributionSetEvent(target.getControllerId(), actionId, softwareModules, + target.getTargetInfo().getAddress())); + }); + } + /** * Removes {@link UpdateAction}s that are no longer necessary and sends - * cancelations to the controller. + * cancellations to the controller. * * @param myTarget * to override {@link UpdateAction}s @@ -360,18 +396,20 @@ public class DeploymentManagement { // Figure out if there are potential target/action combinations that // need to be considered - // for cancelation + // for cancellation final List activeActions = actionRepository .findByActiveAndTargetIdInAndActionStatusNotEqualToAndDistributionSetRequiredMigrationStep(targetsIds, Action.Status.CANCELING); activeActions.forEach(action -> { action.setStatus(Status.CANCELING); // document that the status has been retrieved - actionStatusRepository.save(new ActionStatus(action, Status.CANCELING, System.currentTimeMillis(), - "manual cancelation requested")); - deploymentManagementEvents.cancalAssignDistributionSet(action.getTarget(), action.getId()); - cancelledTargetIds.add(action.getTarget().getId()); - }); + actionStatusRepository.save(new ActionStatus(action, Status.CANCELING, System.currentTimeMillis(), + "manual cancelation requested")); + + cancelAssignDistributionSetEvent(action.getTarget(), action.getId()); + + cancelledTargetIds.add(action.getTarget().getId()); + }); actionRepository.save(activeActions); return cancelledTargetIds; @@ -379,8 +417,9 @@ public class DeploymentManagement { private DistributionSetAssignmentResult assignDistributionSetByTargetId(@NotNull final DistributionSet set, @NotEmpty final List tIDs, final ActionType actionType, final long forcedTime) { - return assignDistributionSetToTargets(set, tIDs.stream() - .map(t -> new TargetWithActionType(t, actionType, forcedTime)).collect(Collectors.toList())); + return assignDistributionSetToTargets(set, + tIDs.stream().map(t -> new TargetWithActionType(t, actionType, forcedTime)) + .collect(Collectors.toList())); } /** @@ -442,19 +481,77 @@ public class DeploymentManagement { // document that the status has been retrieved actionStatusRepository.save(new ActionStatus(myAction, Status.CANCELING, System.currentTimeMillis(), "manual cancelation requested")); + final Action saveAction = actionRepository.save(myAction); - deploymentManagementEvents.cancalAssignDistributionSet(target, myAction.getId()); + cancelAssignDistributionSetEvent(target, myAction.getId()); - return actionRepository.save(myAction); + return saveAction; } else { - throw new CancelActionNotAllowedException( - "Action [id: " + action.getId() + "] is not active and cannot be canceled"); + throw new CancelActionNotAllowedException("Action [id: " + action.getId() + + "] is not active and cannot be canceled"); } } /** - * Get the {@link Action} entity for given actionId. + * Sends the {@link CancelTargetAssignmentEvent} for a specific target to + * the {@link EventBus}. * + * @param target + * the Target which has been assigned to a distribution set + * @param actionId + * the action id of the assignment + */ + private void cancelAssignDistributionSetEvent(final Target target, final Long actionId) { + afterCommit.afterCommit(() -> eventBus.post(new CancelTargetAssignmentEvent(target.getControllerId(), actionId, + target.getTargetInfo().getAddress()))); + } + + /** + * Force cancels given {@link Action} for given {@link Target}. Force + * canceling means that the action is marked as canceled on the SP server + * and a cancel request is sent to the target. But however it's not tracked, + * if the targets handles the cancel request or not. + * + * @param action + * to be canceled + * @param target + * for which the action needs cancellation + * + * @return generated {@link CancelAction} or null if not in + * {@link Target#getActiveActions()}. + * @throws CancelActionNotAllowedException + * in case the given action is not active + */ + @Modifying + @Transactional + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) + public Action forceQuitAction(@NotNull final Action action, @NotNull final Target target) { + final Action mergedAction = entityManager.merge(action); + + if (!mergedAction.isCancelingOrCanceled()) { + throw new ForceQuitActionNotAllowedException("Action [id: " + action.getId() + + "] is not canceled yet and cannot be force quit"); + } + + if (!mergedAction.isActive()) { + throw new ForceQuitActionNotAllowedException("Action [id: " + action.getId() + + "] is not active and cannot be force quit"); + } + + LOG.warn("action ({}) was still activ and has been force quite.", action); + + // document that the status has been retrieved + actionStatusRepository.save(new ActionStatus(mergedAction, Status.CANCELED, System.currentTimeMillis(), + "A force quit has been performed.")); + + successCancellation(mergedAction); + + return actionRepository.save(mergedAction); + } + + /** + * Get the {@link Action} entity for given actionId. + * * @param actionId * to be id of the action * @return the corresponding {@link Action} @@ -467,7 +564,7 @@ public class DeploymentManagement { /** * Get the {@link Action} entity for given actionId with all lazy * attributes. - * + * * @param actionId * to be id of the action * @return the corresponding {@link Action} @@ -493,7 +590,7 @@ public class DeploymentManagement { /** * Retrieves all {@link Action}s of a specific target ordered by action ID. - * + * * @param target * the target associated with the actions * @return a list of actions associated with the given target ordered by @@ -506,7 +603,7 @@ public class DeploymentManagement { /** * Retrieves all {@link Action}s of a specific target ordered by action ID. - * + * * @param target * the target associated with the actions * @return a list of actions associated with the given target ordered by @@ -536,7 +633,7 @@ public class DeploymentManagement { /** * Retrieves all {@link Action}s assigned to a specific {@link Target} and a * given specification. - * + * * @param specifiction * the specification to narrow down the search * @param target @@ -553,17 +650,21 @@ public class DeploymentManagement { return actionRepository.findAll(new Specification() { @Override - public Predicate toPredicate(final Root root, final CriteriaQuery query, - final CriteriaBuilder cb) { + public Predicate toPredicate(final Root root, final CriteriaQuery query, final CriteriaBuilder cb) { return cb.and(specifiction.toPredicate(root, query, cb), cb.equal(root.get(Action_.target), target)); } }, pageable); } /** - * @param foundTarget + * Retrieves all {@link Action}s which are referring the given + * {@link Target}. + * * @param pageable - * @return + * page parameters + * @param foundTarget + * the target to find assigned actions + * @return the found {@link Action}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) public Slice findActionsByTarget(final Target foundTarget, final Pageable pageable) { @@ -573,7 +674,7 @@ public class DeploymentManagement { /** * Retrieves all active {@link Action}s of a specific target ordered by * action ID. - * + * * @param pageable * the pagination parameter * @param target @@ -588,7 +689,7 @@ public class DeploymentManagement { /** * Retrieves all active {@link Action}s of a specific target ordered by * action ID. - * + * * @param target * the target associated with the actions * @return a list of actions associated with the given target @@ -601,7 +702,7 @@ public class DeploymentManagement { /** * Retrieves all inactive {@link Action}s of a specific target ordered by * action ID. - * + * * @param target * the target associated with the actions * @return a list of actions associated with the given target @@ -614,7 +715,7 @@ public class DeploymentManagement { /** * Retrieves all inactive {@link Action}s of a specific target ordered by * action ID. - * + * * @param pageable * the pagination parameter * @param target @@ -628,7 +729,7 @@ public class DeploymentManagement { /** * counts all actions associated to a specific target. - * + * * @param target * the target associated to the actions to count * @return the count value of found actions associated to the target @@ -640,7 +741,7 @@ public class DeploymentManagement { /** * counts all actions associated to a specific target. - * + * * @param spec * the specification to filter the count result * @param target @@ -651,8 +752,7 @@ public class DeploymentManagement { public Long countActionsByTarget(@NotNull final Specification spec, @NotNull final Target target) { return actionRepository.count(new Specification() { @Override - public Predicate toPredicate(final Root root, final CriteriaQuery query, - final CriteriaBuilder cb) { + public Predicate toPredicate(final Root root, final CriteriaQuery query, final CriteriaBuilder cb) { return cb.and(spec.toPredicate(root, query, cb), cb.equal(root.get(Action_.target), target)); } }); @@ -683,7 +783,7 @@ public class DeploymentManagement { /** * retrieves all the {@link ActionStatus} entries of the given * {@link Action} and {@link Target} in the order latest first. - * + * * @param pageReq * pagination parameter * @param action @@ -703,4 +803,30 @@ public class DeploymentManagement { } } + /** + * This method is called, when cancellation has been successful. It sets the + * action to canceled, resets the meta data of the target and in case there + * is a new action this action is triggered. + * + * @param action + * the action which is set to canceled + */ + void successCancellation(final Action action) { + + // set action inactive + action.setActive(false); + action.setStatus(Status.CANCELED); + + final Target target = action.getTarget(); + final List nextActiveActions = actionRepository.findByTargetAndActiveOrderByIdAsc(target, true) + .stream().filter(a -> !a.getId().equals(action.getId())).collect(Collectors.toList()); + + if (nextActiveActions.isEmpty()) { + target.setAssignedDistributionSet(target.getTargetInfo().getInstalledDistributionSet()); + updateTargetInfo(target, TargetUpdateStatus.IN_SYNC, false); + } else { + target.setAssignedDistributionSet(nextActiveActions.get(0).getDistributionSet()); + } + targetManagement.updateTarget(target); + } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java old mode 100755 new mode 100644 index d80667024..ac562131d --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetAssignmentResult.java @@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository; import java.util.List; import org.eclipse.hawkbit.repository.model.Action; +import org.eclipse.hawkbit.repository.model.AssignmentResult; import org.eclipse.hawkbit.repository.model.Target; /** diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetFilter.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java old mode 100755 new mode 100644 index e962978a4..d4b7ac55e --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetManagement.java @@ -11,7 +11,9 @@ package org.eclipse.hawkbit.repository; import static com.google.common.base.Preconditions.checkNotNull; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.LinkedList; import java.util.List; @@ -26,6 +28,8 @@ import javax.persistence.criteria.Predicate; import javax.persistence.criteria.Root; import javax.validation.constraints.NotNull; +import org.eclipse.hawkbit.eventbus.event.DistributionSetTagAssigmentResultEvent; +import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.repository.DistributionSetFilter.DistributionSetFilterBuilder; import org.eclipse.hawkbit.repository.exception.DistributionSetCreationFailedMissingMandatoryModuleException; @@ -38,6 +42,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetMetadata; import org.eclipse.hawkbit.repository.model.DistributionSetMetadata_; import org.eclipse.hawkbit.repository.model.DistributionSetTag; +import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.DistributionSetTypeElement; import org.eclipse.hawkbit.repository.model.DistributionSet_; @@ -62,6 +67,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import com.google.common.base.Strings; +import com.google.common.eventbus.EventBus; /** * Business facade for managing the {@link DistributionSet}s. @@ -96,6 +102,12 @@ public class DistributionSetManagement { @Autowired private ActionRepository actionRepository; + @Autowired + private EventBus eventBus; + + @Autowired + private AfterTransactionCommitExecutor afterCommit; + /** * Find {@link DistributionSet} based on given ID including (lazy loaded) * details, e.g. {@link DistributionSet#getAgentHub()}. @@ -183,13 +195,16 @@ public class DistributionSetManagement { allDSs.add(set); } } - result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), 0, allDSs.size(), null, - distributionSetRepository.save(allDSs)); + result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), 0, allDSs.size(), + Collections.emptyList(), distributionSetRepository.save(allDSs), myTag); } else { result = new DistributionSetTagAssigmentResult(dsIds.size() - allDSs.size(), allDSs.size(), 0, - distributionSetRepository.save(allDSs), null); + distributionSetRepository.save(allDSs), Collections.emptyList(), myTag); } + final DistributionSetTagAssigmentResult resultAssignment = result; + afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagAssigmentResultEvent(resultAssignment))); + // no reason to persist the tag entityManager.detach(myTag); return result; @@ -204,8 +219,7 @@ public class DistributionSetManagement { * @return the found {@link DistributionSet}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - public List findDistributionSetListWithDetails( - @NotEmpty final Collection distributionIdSet) { + public List findDistributionSetListWithDetails(@NotEmpty final Collection distributionIdSet) { return distributionSetRepository.findAll(DistributionSetSpecification.byIds(distributionIdSet)); } @@ -383,8 +397,7 @@ public class DistributionSetManagement { @Modifying @Transactional @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_REPOSITORY) - public DistributionSet unassignSoftwareModule(@NotNull final DistributionSet ds, - final SoftwareModule softwareModule) { + public DistributionSet unassignSoftwareModule(@NotNull final DistributionSet ds, final SoftwareModule softwareModule) { final Set softwareModules = new HashSet(); softwareModules.add(softwareModule); ds.removeModule(softwareModule); @@ -416,9 +429,9 @@ public class DistributionSetManagement { // throw exception if user tries to update a DS type that is already in // use if (!persisted.areModuleEntriesIdentical(dsType) && distributionSetRepository.countByType(persisted) > 0) { - throw new EntityReadOnlyException( - String.format("distribution set type %s set is already assigned to targets and cannot be changed", - dsType.getName())); + throw new EntityReadOnlyException(String.format( + "distribution set type %s set is already assigned to targets and cannot be changed", + dsType.getName())); } return distributionSetTypeRepository.save(dsType); @@ -584,16 +597,14 @@ public class DistributionSetManagement { final DistributionSetFilter filterWithInstalledTargets = distributionSetFilterBuilder .setInstalledTargetId(assignedOrInstalled).setAssignedTargetId(null).build(); - final DistributionSet installedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget( - filterWithInstalledTargets); + final DistributionSet installedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget(filterWithInstalledTargets); final DistributionSetFilter filterWithAssignedTargets = distributionSetFilterBuilder.setInstalledTargetId(null) .setAssignedTargetId(assignedOrInstalled).build(); - final DistributionSet assignedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget( - filterWithAssignedTargets); + final DistributionSet assignedDS = findDistributionSetsByFiltersAndInstalledOrAssignedTarget(filterWithAssignedTargets); - final DistributionSetFilter dsFilterWithNoTargetLinked = distributionSetFilterBuilder.setInstalledTargetId(null) - .setAssignedTargetId(null).build(); + final DistributionSetFilter dsFilterWithNoTargetLinked = distributionSetFilterBuilder + .setInstalledTargetId(null).setAssignedTargetId(null).build(); // first fine the distribution sets filtered by the given filter // parameters final Page findDistributionSetsByFilters = findDistributionSetsByFilters(pageable, @@ -643,8 +654,8 @@ public class DistributionSetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) public DistributionSet findDistributionSetByNameAndVersion(@NotEmpty final String distributionName, @NotEmpty final String version) { - final Specification spec = DistributionSetSpecification - .equalsNameAndVersionIgnoreCase(distributionName, version); + final Specification spec = DistributionSetSpecification.equalsNameAndVersionIgnoreCase( + distributionName, version); return distributionSetRepository.findOne(spec); } @@ -998,17 +1009,17 @@ public class DistributionSetManagement { final Set softwareModules) { if (!new HashSet(distributionSet.getModules()).equals(softwareModules) && actionRepository.countByDistributionSet(distributionSet) > 0) { - throw new EntityLockedException( - String.format("distribution set %s:%s is already assigned to targets and cannot be changed", - distributionSet.getName(), distributionSet.getVersion())); + throw new EntityLockedException(String.format( + "distribution set %s:%s is already assigned to targets and cannot be changed", + distributionSet.getName(), distributionSet.getVersion())); } } private void checkDistributionSetSoftwareModulesIsAllowedToModify(final DistributionSet distributionSet) { if (actionRepository.countByDistributionSet(distributionSet) > 0) { - throw new EntityLockedException( - String.format("distribution set %s:%s is already assigned to targets and cannot be changed", - distributionSet.getName(), distributionSet.getVersion())); + throw new EntityLockedException(String.format( + "distribution set %s:%s is already assigned to targets and cannot be changed", + distributionSet.getName(), distributionSet.getVersion())); } } @@ -1057,8 +1068,8 @@ public class DistributionSetManagement { private void checkAndThrowAlreadyIfDistributionSetMetadataExists(final DsMetadataCompositeKey metadataId) { if (distributionSetMetadataRepository.exists(metadataId)) { - throw new EntityAlreadyExistsException( - "Metadata entry with key '" + metadataId.getKey() + "' already exists"); + throw new EntityAlreadyExistsException("Metadata entry with key '" + metadataId.getKey() + + "' already exists"); } } @@ -1066,4 +1077,74 @@ public class DistributionSetManagement { throw new EntityAlreadyExistsException("Metadata entry with key '" + metadataKey + "' already exists"); } + /** + * Assign a {@link DistributionSetTag} assignment to given + * {@link DistributionSet}s. + * + * @param dsIds + * to assign for + * @param tag + * to assign + * @return list of assigned ds + */ + @Modifying + @Transactional + @NotNull + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) + public List assignTag(@NotEmpty final Collection dsIds, @NotNull final DistributionSetTag tag) { + final List allDs = findDistributionSetListWithDetails(dsIds); + + allDs.forEach(ds -> ds.getTags().add(tag)); + final List save = distributionSetRepository.save(allDs); + + afterCommit.afterCommit(() -> { + + final DistributionSetTagAssigmentResult result = new DistributionSetTagAssigmentResult(0, save.size(), 0, + save, Collections.emptyList(), tag); + eventBus.post(new DistributionSetTagAssigmentResultEvent(result)); + }); + + return save; + } + + /** + * Unassign all {@link DistributionSet} from a given + * {@link DistributionSetTag} . + * + * @param tag + * to unassign all ds + * @return list of unassigned ds + */ + @Modifying + @Transactional + @NotNull + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) + public List unAssignAllDistributionSetsByTag(@NotNull final DistributionSetTag tag) { + return unAssignTag(tag.getAssignedToDistributionSet(), tag); + } + + /** + * Unassign a {@link DistributionSetTag} assignment to given + * {@link DistributionSet}. + * + * @param dsId + * to unassign for + * @param distributionSetTag + * to unassign + * @return the unassigned ds or if no ds is unassigned + */ + @Modifying + @Transactional + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) + public DistributionSet unAssignTag(@NotNull final Long dsId, @NotNull final DistributionSetTag distributionSetTag) { + final List allDs = findDistributionSetListWithDetails(Arrays.asList(dsId)); + final List unAssignTag = unAssignTag(allDs, distributionSetTag); + return unAssignTag.isEmpty() ? null : unAssignTag.get(0); + } + + private List unAssignTag(final Collection distributionSets, + final DistributionSetTag tag) { + distributionSets.forEach(ds -> ds.getTags().remove(tag)); + return distributionSetRepository.save(distributionSets); + } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetMetadataRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetMetadataRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagRepository.java old mode 100755 new mode 100644 index 39770dee0..e09db5cb2 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagRepository.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagRepository.java @@ -13,6 +13,7 @@ import java.util.List; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.TargetTag; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Modifying; import org.springframework.transaction.annotation.Transactional; @@ -23,7 +24,8 @@ import org.springframework.transaction.annotation.Transactional; * */ @Transactional(readOnly = true) -public interface DistributionSetTagRepository extends BaseEntityRepository { +public interface DistributionSetTagRepository extends BaseEntityRepository, + JpaSpecificationExecutor { /** * deletes the {@link DistributionSet} with the given name. * @@ -51,4 +53,7 @@ public interface DistributionSetTagRepository extends BaseEntityRepository findAll(); + + @Override + List save(Iterable entities); } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTypeRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTypeRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/EclipseLinkTargetInfoRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/EclipseLinkTargetInfoRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ExternalArtifactProviderRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ExternalArtifactProviderRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ExternalArtifactRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ExternalArtifactRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/LocalArtifactRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/LocalArtifactRepository.java old mode 100755 new mode 100644 index 763b6e5a2..5bbac1dd1 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/LocalArtifactRepository.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/LocalArtifactRepository.java @@ -9,20 +9,40 @@ package org.eclipse.hawkbit.repository; import java.util.List; +import java.util.Optional; import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.Query; import org.springframework.transaction.annotation.Transactional; /** * {@link LocalArtifact} repository. * - * - * */ @Transactional(readOnly = true) public interface LocalArtifactRepository extends BaseEntityRepository { + + /** + * Counts artifacts size where the related software module is not + * deleted/archived. + * + * @return sum of artifacts size in bytes + */ + @Query("SELECT SUM(la.size) FROM LocalArtifact la WHERE la.softwareModule.deleted = 0") + Optional getSumOfUndeletedArtifactSize(); + + /** + * Counts artifacts where the related software module is deleted/archived. + * + * @param deleted + * to true for counting the deleted artifacts + * + * @return number of artifacts + */ + Long countBySoftwareModuleDeleted(boolean deleted); + /** * Searches for a {@link LocalArtifact} based on given gridFsFileName. * diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/NoCountPagingRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/NoCountPagingRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ReportManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/ReportManagement.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareManagement.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleMetadataRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleMetadataRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleTypeRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SoftwareModuleTypeRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java old mode 100755 new mode 100644 index 4ba82401d..64865ac65 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/SystemManagement.java @@ -9,6 +9,7 @@ package org.eclipse.hawkbit.repository; import java.lang.reflect.Method; +import java.math.BigDecimal; import java.util.List; import java.util.stream.Collectors; @@ -17,13 +18,13 @@ import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.cache.TenancyCacheManager; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; +import org.eclipse.hawkbit.report.model.SystemUsageReport; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.model.TenantConfiguration; import org.eclipse.hawkbit.repository.model.TenantMetaData; import org.eclipse.hawkbit.tenancy.TenantAware; -import org.eclipse.hawkbit.tenancy.TenantAware.TenantRunner; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey; import org.eclipse.persistence.config.PersistenceUnitProperties; import org.springframework.beans.factory.annotation.Autowired; @@ -48,9 +49,6 @@ import org.springframework.validation.annotation.Validated; /** * Central system management operations of the SP server. * - * - * - * */ @Transactional(readOnly = true) @Validated @@ -101,6 +99,9 @@ public class SystemManagement implements EnvironmentAware { @Autowired private TenantAware tenantAware; + @Autowired + private TenantStatsManagement systemStatsManagement; + @Autowired private TenancyCacheManager cacheManager; @@ -110,12 +111,61 @@ public class SystemManagement implements EnvironmentAware { private Environment environment; + /** + * Calculated system usage statistics, both overall for the entire system + * and per tenant; + * + * @return SystemUsageReport of the current system + */ + @NotNull + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_SYSTEM_ADMIN) + public SystemUsageReport getSystemUsageStatistics() { + + BigDecimal sumOfArtifacts = (BigDecimal) entityManager + .createNativeQuery( + "select SUM(file_size) from sp_artifact a INNER JOIN sp_base_software_module sm ON a.software_module = sm.id WHERE sm.deleted = 0") + .getSingleResult(); + + if (sumOfArtifacts == null) { + sumOfArtifacts = new BigDecimal(0); + } + + // we use native queries to punch through the tenant boundaries. This + // has to be used with care! + final Long targets = (Long) entityManager.createNativeQuery("SELECT COUNT(id) FROM sp_target") + .getSingleResult(); + + final Long artifacts = (Long) entityManager + .createNativeQuery( + "SELECT COUNT(a.id) FROM sp_artifact a INNER JOIN sp_base_software_module sm ON a.software_module = sm.id WHERE sm.deleted = 0") + .getSingleResult(); + + final Long actions = (Long) entityManager.createNativeQuery("SELECT COUNT(id) FROM sp_action") + .getSingleResult(); + + final SystemUsageReport result = new SystemUsageReport(targets, artifacts, actions, + sumOfArtifacts.setScale(0, BigDecimal.ROUND_HALF_UP).longValue()); + + usageStatsPerTenant(result); + + return result; + } + + private void usageStatsPerTenant(final SystemUsageReport report) { + final List tenants = findTenants(); + + tenants.forEach(tenant -> tenantAware.runAsTenant(tenant, () -> { + report.addTenantData(systemStatsManagement.getStatsOfTenant(tenant)); + return null; + })); + } + /** * Registers the key generator for the {@link #currentTenant()} method * because this key generator is aware of the {@link #createInitialTenant} * thread local in case we are currently creating a tenant and insert the * default distribution set types. - * + * * @return the {@link CurrentTenantKeyGenerator} */ @Bean @@ -127,8 +177,8 @@ public class SystemManagement implements EnvironmentAware { * Returns {@link TenantMetaData} of given and current tenant. * * DISCLAIMER: this variant is used during initial login (where the tenant - * is not yet in teh session). Please user {@link #getTenantMetadata()} for - * reluar requests. + * is not yet in the session). Please user {@link #getTenantMetadata()} for + * regular requests. * * @param tenant * @return @@ -179,25 +229,22 @@ public class SystemManagement implements EnvironmentAware { public void deleteTenant(@NotNull final String tenant) { cacheManager.evictCaches(tenant); cacheManager.getCache("currentTenant").evict(currentTenantKeyGenerator().generate(null, null)); - tenantAware.runAsTenant(tenant, new TenantRunner() { - @Override - public Void run() { - entityManager.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, tenant.toUpperCase()); - tenantMetaDataRepository.deleteByTenantIgnoreCase(tenant); - tenantConfigurationRepository.deleteByTenantIgnoreCase(tenant); - targetRepository.deleteByTenantIgnoreCase(tenant); - artifactRepository.deleteByTenantIgnoreCase(tenant); - externalArtifactRepository.deleteByTenantIgnoreCase(tenant); - externalArtifactProviderRepository.deleteByTenantIgnoreCase(tenant); - targetTagRepository.deleteByTenantIgnoreCase(tenant); - actionRepository.deleteByTenantIgnoreCase(tenant); - distributionSetTagRepository.deleteByTenantIgnoreCase(tenant); - distributionSetRepository.deleteByTenantIgnoreCase(tenant); - distributionSetTypeRepository.deleteByTenantIgnoreCase(tenant); - softwareModuleRepository.deleteByTenantIgnoreCase(tenant); - softwareModuleTypeRepository.deleteByTenantIgnoreCase(tenant); - return null; - } + tenantAware.runAsTenant(tenant, () -> { + entityManager.setProperty(PersistenceUnitProperties.MULTITENANT_PROPERTY_DEFAULT, tenant.toUpperCase()); + tenantMetaDataRepository.deleteByTenantIgnoreCase(tenant); + tenantConfigurationRepository.deleteByTenantIgnoreCase(tenant); + targetRepository.deleteByTenantIgnoreCase(tenant); + artifactRepository.deleteByTenantIgnoreCase(tenant); + externalArtifactRepository.deleteByTenantIgnoreCase(tenant); + externalArtifactProviderRepository.deleteByTenantIgnoreCase(tenant); + targetTagRepository.deleteByTenantIgnoreCase(tenant); + actionRepository.deleteByTenantIgnoreCase(tenant); + distributionSetTagRepository.deleteByTenantIgnoreCase(tenant); + distributionSetRepository.deleteByTenantIgnoreCase(tenant); + distributionSetTypeRepository.deleteByTenantIgnoreCase(tenant); + softwareModuleRepository.deleteByTenantIgnoreCase(tenant); + softwareModuleTypeRepository.deleteByTenantIgnoreCase(tenant); + return null; }); } @@ -218,7 +265,7 @@ public class SystemManagement implements EnvironmentAware { /** * Checks if a specific tenant exists. The tenant will not be created lazy. - * + * * @param tenant * the tenant to check * @return {@code true} in case the tenant exits or {@code false} if not @@ -268,7 +315,7 @@ public class SystemManagement implements EnvironmentAware { * 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 * the key of the configuration * @param propertyType @@ -298,7 +345,7 @@ public class SystemManagement implements EnvironmentAware { /** * Adds or updates a specific configuration for a specific tenant. - * + * * @param tenantConf * the tenant configuration object which contains the key and * value of the specific configuration to update @@ -319,7 +366,7 @@ public class SystemManagement implements EnvironmentAware { /** * Deletes a specific configuration for the current tenant. - * + * * @param configurationKey * the configuration key to be deleted */ @@ -337,7 +384,7 @@ public class SystemManagement implements EnvironmentAware { /* * (non-Javadoc) - * + * * @see org.springframework.context.EnvironmentAware#setEnvironment(org. * springframework.core.env. Environment) */ @@ -379,7 +426,7 @@ public class SystemManagement implements EnvironmentAware { * {@link TenantAware}, but in case we are in a tenant creation with its * default types we need to use the tenant the current tenant which is * currently created and not the one currently in the {@link TenantAware}. - * + * * * */ @@ -387,7 +434,7 @@ public class SystemManagement implements EnvironmentAware { /* * (non-Javadoc) - * + * * @see * org.springframework.cache.interceptor.KeyGenerator#generate(java.lang * .Object, java.lang.reflect.Method, java.lang.Object[]) diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java old mode 100755 new mode 100644 index 541c9c9cf..d0cfea0a3 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TagManagement.java @@ -15,6 +15,13 @@ import java.util.List; import javax.validation.constraints.NotNull; +import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent; +import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent; +import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent; +import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent; +import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent; +import org.eclipse.hawkbit.eventbus.event.TargetTagUpdateEvent; +import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.model.DistributionSet; @@ -22,16 +29,20 @@ import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.Tag; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetTag; +import org.eclipse.hawkbit.tenancy.TenantAware; import org.hibernate.validator.constraints.NotEmpty; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.domain.Specification; import org.springframework.data.jpa.repository.Modifying; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; +import com.google.common.eventbus.EventBus; + /** * * Mangement service class for {@link Tag}s. @@ -58,6 +69,15 @@ public class TagManagement { @Autowired private DistributionSetRepository distributionSetRepository; + @Autowired + private EventBus eventBus; + + @Autowired + private TenantAware tenantAware; + + @Autowired + private AfterTransactionCommitExecutor afterCommit; + /** * Find {@link TargetTag} based on given Name. * @@ -94,7 +114,12 @@ public class TagManagement { throw new EntityAlreadyExistsException(); } - return targetTagRepository.save(targetTag); + final TargetTag save = targetTagRepository.save(targetTag); + + afterCommit + .afterCommit(() -> eventBus.post(new TargetTagCreatedBulkEvent(tenantAware.getCurrentTenant(), save))); + + return save; } /** @@ -117,8 +142,10 @@ public class TagManagement { throw new EntityAlreadyExistsException(); } }); - - return targetTagRepository.save(targetTags); + final List save = targetTagRepository.save(targetTags); + afterCommit + .afterCommit(() -> eventBus.post(new TargetTagCreatedBulkEvent(tenantAware.getCurrentTenant(), save))); + return save; } /** @@ -144,6 +171,9 @@ public class TagManagement { // finally delete the tag itself targetTagRepository.deleteByName(targetTagName); + + afterCommit.afterCommit(() -> eventBus.post(new TargetTagDeletedEvent(tag))); + } /** @@ -157,6 +187,31 @@ public class TagManagement { return targetTagRepository.findAll(); } + /** + * Retrieves all target tags based on the given specification. + * + * @param spec + * the specification for the query + * @param pageable + * pagination parameter + * @return the found {@link Target}s, never {@code null} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + public Page findAllTargetTags(@NotNull final Specification spec, + @NotNull final Pageable pageable) { + return targetTagRepository.findAll(spec, pageable); + } + + /** + * count {@link TargetTag}s. + * + * @return size of {@link TargetTag}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + public long countTargetTags() { + return targetTagRepository.count(); + } + /** * updates the {@link TargetTag}. * @@ -171,7 +226,9 @@ public class TagManagement { public TargetTag updateTargetTag(@NotNull final TargetTag targetTag) { checkNotNull(targetTag.getName()); checkNotNull(targetTag.getId()); - return targetTagRepository.save(targetTag); + final TargetTag save = targetTagRepository.save(targetTag); + afterCommit.afterCommit(() -> eventBus.post(new TargetTagUpdateEvent(save))); + return save; } /** @@ -208,7 +265,11 @@ public class TagManagement { throw new EntityAlreadyExistsException(); } - return distributionSetTagRepository.save(distributionSetTag); + final DistributionSetTag save = distributionSetTagRepository.save(distributionSetTag); + + afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagCreatedBulkEvent(tenantAware + .getCurrentTenant(), save))); + return save; } /** @@ -223,15 +284,18 @@ public class TagManagement { @Modifying @Transactional @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_REPOSITORY) - public Iterable createDistributionSetTags( + public List createDistributionSetTags( @NotNull final Iterable distributionSetTags) { for (final DistributionSetTag dsTag : distributionSetTags) { if (dsTag.getId() != null) { throw new EntityAlreadyExistsException(); } } + final List save = distributionSetTagRepository.save(distributionSetTags); + afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagCreatedBulkEvent(tenantAware + .getCurrentTenant(), save))); - return distributionSetTagRepository.save(distributionSetTags); + return save; } /** @@ -257,6 +321,8 @@ public class TagManagement { distributionSetRepository.save(changed); distributionSetTagRepository.deleteByName(tagName); + + afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagDeletedEvent(tag))); } /** @@ -275,7 +341,10 @@ public class TagManagement { public DistributionSetTag updateDistributionSetTag(@NotNull final DistributionSetTag distributionSetTag) { checkNotNull(distributionSetTag.getName()); checkNotNull(distributionSetTag.getId()); - return distributionSetTagRepository.save(distributionSetTag); + final DistributionSetTag save = distributionSetTagRepository.save(distributionSetTag); + afterCommit.afterCommit(() -> eventBus.post(new DistributionSetTagUpdateEvent(save))); + + return save; } /** @@ -284,7 +353,7 @@ public class TagManagement { * @return all {@link DistributionTag}s */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - public List findDistributionSetTagsAll() { + public List findAllDistributionSetTags() { return distributionSetTagRepository.findAll(); } @@ -328,16 +397,31 @@ public class TagManagement { } /** - * returns all {@link TargetTag}s. + * returns all {@link DistributionSetTag}s. * * @param pageReq * page parameter - * @return all {@link TargetTag}s + * @return all {@link DistributionSetTag}s */ @NotNull @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY) - public Page findDistributionSetTagsAll(@NotNull final Pageable pageReq) { + public Page findAllDistributionSetTags(@NotNull final Pageable pageReq) { return distributionSetTagRepository.findAll(pageReq); } + /** + * Retrieves all DistributionSet tags based on the given specification. + * + * @param spec + * the specification for the query + * @param pageable + * pagination parameter + * @return the found {@link DistributionSetTag}s, never {@code null} + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + public Page findAllDistributionSetTags(@NotNull final Specification spec, + @NotNull final Pageable pageable) { + return distributionSetTagRepository.findAll(spec, pageable); + } + } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagement.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetFilterQueryRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetInfoRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetInfoRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java old mode 100755 new mode 100644 index c0a635442..f0047f6dd --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetManagement.java @@ -10,7 +10,9 @@ package org.eclipse.hawkbit.repository; import java.net.URI; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.stream.Collectors; @@ -28,6 +30,8 @@ import javax.persistence.criteria.Root; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.Constants; +import org.eclipse.hawkbit.eventbus.event.TargetTagAssigmentResultEvent; +import org.eclipse.hawkbit.executor.AfterTransactionCommitExecutor; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; import org.eclipse.hawkbit.repository.exception.EntityAlreadyExistsException; import org.eclipse.hawkbit.repository.model.DistributionSet; @@ -39,6 +43,7 @@ import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.repository.model.TargetInfo; import org.eclipse.hawkbit.repository.model.TargetInfo_; import org.eclipse.hawkbit.repository.model.TargetTag; +import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.repository.model.Target_; import org.eclipse.hawkbit.repository.rsql.RSQLUtility; @@ -86,9 +91,6 @@ public class TargetManagement { @Autowired private TargetTagRepository targetTagRepository; - @Autowired - private TargetFilterQueryRepository targetFilterQueryRepository; - @Autowired private TargetInfoRepository targetInfoRepository; @@ -98,6 +100,9 @@ public class TargetManagement { @Autowired private EventBus eventBus; + @Autowired + private AfterTransactionCommitExecutor afterCommit; + /** * Find {@link Target} based on given ID returns found Target without * details, i.e. NO {@link Target#getTags()} and @@ -179,14 +184,11 @@ public class TargetManagement { // workarround - no join fetch allowed that is why we need specification // instead of query for // count() of Pageable - final Specification spec = new Specification() { - @Override - public Predicate toPredicate(final Root root, final CriteriaQuery query, final CriteriaBuilder cb) { - if (!query.getResultType().isAssignableFrom(Long.class)) { - root.fetch(Target_.targetInfo); - } - return cb.conjunction(); + final Specification spec = (root, query, cb) -> { + if (!query.getResultType().isAssignableFrom(Long.class)) { + root.fetch(Target_.targetInfo); } + return cb.conjunction(); }; return criteriaNoCountDao.findAll(spec, pageable, Target.class); } @@ -223,7 +225,7 @@ public class TargetManagement { /** * Retrieves all targets based on the given specification. - * + * * @param spec * the specification for the query * @param pageable @@ -256,7 +258,7 @@ public class TargetManagement { /** * updates the {@link Target}. - * + * * @param target * to be updated * @return the updated {@link Target} @@ -274,7 +276,7 @@ public class TargetManagement { /** * updates multiple {@link Target}s. - * + * * @param targets * to be updated * @return the updated {@link Target}s @@ -291,7 +293,7 @@ public class TargetManagement { /** * Deletes all targets with the given IDs. - * + * * @param targetIDs * the technical IDs of the targets to be deleted */ @@ -336,7 +338,7 @@ public class TargetManagement { * details, i.e. NO {@link Target#getTags()} and * {@link Target#getActiveActions()} possible including the filtering based * on the given {@code spec}. - * + * * @param distributionSetID * the ID of the {@link DistributionSet} * @param spec @@ -349,14 +351,9 @@ public class TargetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) public Page findTargetByAssignedDistributionSet(@NotNull final Long distributionSetID, final Specification spec, @NotNull final Pageable pageReq) { - return targetRepository.findAll(new Specification() { - @Override - public Predicate toPredicate(final Root root, final CriteriaQuery query, final CriteriaBuilder cb) { - return cb - .and(TargetSpecifications.hasAssignedDistributionSet(distributionSetID).toPredicate(root, - query, cb), spec.toPredicate(root, query, cb)); - } - }, pageReq); + return targetRepository.findAll((Specification) (root, query, cb) -> cb.and( + TargetSpecifications.hasAssignedDistributionSet(distributionSetID).toPredicate(root, query, cb), + spec.toPredicate(root, query, cb)), pageReq); } /** @@ -393,14 +390,9 @@ public class TargetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_REPOSITORY_AND_READ_TARGET) public Page findTargetByInstalledDistributionSet(final Long distributionSetId, final Specification spec, final Pageable pageable) { - return targetRepository.findAll(new Specification() { - @Override - public Predicate toPredicate(final Root root, final CriteriaQuery query, final CriteriaBuilder cb) { - return cb.and( - TargetSpecifications.hasInstalledDistributionSet(distributionSetId) - .toPredicate(root, query, cb), spec.toPredicate(root, query, cb)); - } - }, pageable); + return targetRepository.findAll((Specification) (root, query, cb) -> cb.and( + TargetSpecifications.hasInstalledDistributionSet(distributionSetId).toPredicate(root, query, cb), + spec.toPredicate(root, query, cb)), pageable); } /** @@ -487,16 +479,16 @@ public class TargetManagement { return countByCriteriaAPI(specList); } - private List> buildSpecificationList(final Collection status, + private static List> buildSpecificationList(final Collection status, final String searchText, final Long installedOrAssignedDistributionSetId, final Boolean selectTargetWithNoTag, final boolean fetch, final String... tagNames) { - final List> specList = new ArrayList>(); + final List> specList = new ArrayList<>(); if (status != null && !status.isEmpty()) { specList.add(TargetSpecifications.hasTargetUpdateStatus(status, fetch)); } if (installedOrAssignedDistributionSetId != null) { - specList.add(TargetSpecifications - .hasInstalledOrAssignedDistributionSet(installedOrAssignedDistributionSetId)); + specList.add( + TargetSpecifications.hasInstalledOrAssignedDistributionSet(installedOrAssignedDistributionSetId)); } if (!Strings.isNullOrEmpty(searchText)) { specList.add(TargetSpecifications.likeNameOrDescriptionOrIp(searchText)); @@ -509,7 +501,7 @@ public class TargetManagement { /** * executes findAll with the given {@link Target} {@link Specification}s. - * + * * @param pageable * paging parameter * @param specList @@ -538,7 +530,7 @@ public class TargetManagement { } - private Specifications creatingTargetSpecifications(final List> specList) { + private static Specifications creatingTargetSpecifications(final List> specList) { Specifications specs = null; if (!specList.isEmpty()) { specs = Specifications.where(specList.get(0)); @@ -568,8 +560,8 @@ public class TargetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) public TargetTagAssigmentResult toggleTagAssignment(@NotEmpty final List targets, @NotNull final TargetTag tag) { - return toggleTagAssignment(targets.stream().map(target -> target.getControllerId()) - .collect(Collectors.toList()), tag.getName()); + return toggleTagAssignment( + targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList()), tag.getName()); } /** @@ -592,25 +584,107 @@ public class TargetManagement { @NotNull final String tagName) { final TargetTag tag = targetTagRepository.findByNameEquals(tagName); final List alreadyAssignedTargets = targetRepository.findByTagNameAndControllerIdIn(tagName, targetIds); - final List allTargets = targetRepository.findAll(TargetSpecifications - .byControllerIdWithStatusAndTagsInJoin(targetIds)); + final List allTargets = targetRepository + .findAll(TargetSpecifications.byControllerIdWithStatusAndTagsInJoin(targetIds)); // all are already assigned -> unassign if (alreadyAssignedTargets.size() == allTargets.size()) { alreadyAssignedTargets.forEach(target -> target.getTags().remove(tag)); - return new TargetTagAssigmentResult(0, 0, alreadyAssignedTargets.size(), null, alreadyAssignedTargets); + final TargetTagAssigmentResult result = new TargetTagAssigmentResult(0, 0, alreadyAssignedTargets.size(), + Collections.emptyList(), alreadyAssignedTargets, tag); + + afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result))); + return result; } allTargets.removeAll(alreadyAssignedTargets); // some or none are assigned -> assign allTargets.forEach(target -> target.getTags().add(tag)); final TargetTagAssigmentResult result = new TargetTagAssigmentResult(alreadyAssignedTargets.size(), - allTargets.size(), 0, targetRepository.save(allTargets), null); + allTargets.size(), 0, targetRepository.save(allTargets), Collections.emptyList(), tag); + + afterCommit.afterCommit(() -> eventBus.post(new TargetTagAssigmentResultEvent(result))); + // no reason to persist the tag entityManager.detach(tag); return result; } + /** + * Assign a {@link TargetTag} assignment to given {@link Target}s. + * + * @param targetIds + * to assign for + * @param tagName + * to assign + * @return list of assigned targets + */ + @Modifying + @Transactional + @NotNull + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) + public List assignTag(@NotEmpty final Collection targetIds, @NotNull final TargetTag tag) { + final List allTargets = targetRepository.findAll(TargetSpecifications + .byControllerIdWithStatusAndTagsInJoin(targetIds)); + + allTargets.forEach(target -> target.getTags().add(tag)); + final List save = targetRepository.save(allTargets); + + afterCommit.afterCommit(() -> { + final TargetTagAssigmentResult assigmentResult = new TargetTagAssigmentResult(0, save.size(), 0, save, + Collections.emptyList(), tag); + eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult)); + }); + + return save; + } + + private List unAssignTag(@NotEmpty final Collection targets, @NotNull final TargetTag tag) { + targets.forEach(target -> target.getTags().remove(tag)); + + final List save = targetRepository.save(targets); + afterCommit.afterCommit(() -> { + final TargetTagAssigmentResult assigmentResult = new TargetTagAssigmentResult(0, 0, save.size(), + Collections.emptyList(), save, tag); + eventBus.post(new TargetTagAssigmentResultEvent(assigmentResult)); + }); + return save; + } + + /** + * Unassign all {@link Target} from a given {@link TargetTag} . + * + * @param tag + * to unassign all targets + * @return list of unassigned targets + */ + @Modifying + @Transactional + @NotNull + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) + public List unAssignAllTargetsByTag(@NotNull final TargetTag tag) { + return unAssignTag(tag.getAssignedToTargets(), tag); + } + + /** + * Unassign a {@link TargetTag} assignment to given {@link Target}. + * + * @param controllerID + * to unassign for + * @param targetTag + * to unassign + * @return the unassigned target or if no target is unassigned + */ + @Modifying + @Transactional + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_UPDATE_TARGET) + public Target unAssignTag(@NotNull final String controllerID, @NotNull final TargetTag targetTag) { + final List allTargets = targetRepository.findAll(TargetSpecifications + .byControllerIdWithStatusAndTagsInJoin(Arrays.asList(controllerID))); + final List unAssignTag = unAssignTag(allTargets, targetTag); + return unAssignTag.isEmpty() ? null : unAssignTag.get(0); + } + /** * method retrieves all {@link Target}s from the repo in the following * order: @@ -624,7 +698,7 @@ public class TargetManagement { *

* 3) {@link Target}s which have no connection to the given * {@link DistributionSet}. - * + * * @param pageable * the page request to page the result set * @param orderByDistributionId @@ -667,19 +741,20 @@ public class TargetManagement { // select case expression to retrieve the case value as a column to be // able to order based on // this column, installed first,... - final Expression selectCase = cb - .selectCase() + final Expression selectCase = cb.selectCase() .when(cb.equal(targetInfo.get(TargetInfo_.installedDistributionSet).get(DistributionSet_.id), orderByDistributionId), 1) .when(cb.equal(targetRoot.get(Target_.assignedDistributionSet).get(DistributionSet_.id), - orderByDistributionId), 2).otherwise(100); + orderByDistributionId), 2) + .otherwise(100); // multiselect statement order by the select case and controllerId query.distinct(true); // build the specifications and then to predicates necessary by the // given filters final Predicate[] specificationsForMultiSelect = specificationsToPredicate( buildSpecificationList(filterByStatus, filterBySearchText, filterByDistributionId, - selectTargetWithNoTag, true, filterByTagNames), targetRoot, query, cb); + selectTargetWithNoTag, true, filterByTagNames), + targetRoot, query, cb); // if we have some predicates then add it to the where clause of the // multiselect @@ -706,7 +781,7 @@ public class TargetManagement { /** * @param specifications */ - private Predicate[] specificationsToPredicate(final List> specifications, + private static Predicate[] specificationsToPredicate(final List> specifications, final Root root, final CriteriaQuery query, final CriteriaBuilder cb) { final Predicate[] predicates = new Predicate[specifications.size()]; for (int index = 0; index < predicates.length; index++) { @@ -745,7 +820,7 @@ public class TargetManagement { /** * finds all {@link Target#getControllerId()} which are currently in the * database. - * + * * @return all IDs of all {@link Target} in the system */ @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) @@ -753,9 +828,8 @@ public class TargetManagement { final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); final CriteriaQuery query = cb.createQuery(TargetIdName.class); final Root targetRoot = query.from(Target.class); - return entityManager.createQuery( - query.multiselect(targetRoot.get(Target_.id), targetRoot.get(Target_.controllerId), - targetRoot.get(Target_.name))).getResultList(); + return entityManager.createQuery(query.multiselect(targetRoot.get(Target_.id), + targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name))).getResultList(); } @@ -790,14 +864,15 @@ public class TargetManagement { final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); final CriteriaQuery query = cb.createQuery(Object[].class); final Root targetRoot = query.from(Target.class); - List resultList = null; + List resultList; final CriteriaQuery multiselect = query.multiselect(targetRoot.get(Target_.id), targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name), targetRoot.get(pageRequest.getSort().iterator().next().getProperty())); final Predicate[] specificationsForMultiSelect = specificationsToPredicate( buildSpecificationList(filterByStatus, filterBySearchText, filterByDistributionId, - selectTargetWithNoTag, false, filterByTagNames), targetRoot, multiselect, cb); + selectTargetWithNoTag, false, filterByTagNames), + targetRoot, multiselect, cb); // if we have some predicates then add it to the where clause of the // multiselect @@ -805,25 +880,47 @@ public class TargetManagement { multiselect.where(specificationsForMultiSelect); } - if (pageRequest.getSort() != null) { - final List orders = new ArrayList<>(); - final Sort sort = pageRequest.getSort(); - for (final Sort.Order sortOrder : sort) { - if (sortOrder.getDirection() == Direction.ASC) { - orders.add(cb.asc(targetRoot.get(sortOrder.getProperty()))); - } else { - orders.add(cb.desc(targetRoot.get(sortOrder.getProperty()))); - } - } - multiselect.orderBy(orders); - resultList = entityManager.createQuery(multiselect).setFirstResult(pageRequest.getOffset()) - .setMaxResults(pageRequest.getPageSize()).getResultList(); - } else { - resultList = entityManager.createQuery(multiselect).getResultList(); - } + resultList = getTargetIdNameResultSet(pageRequest, cb, targetRoot, multiselect); return resultList.parallelStream().map(o -> new TargetIdName((long) o[0], o[1].toString(), o[2].toString())) .collect(Collectors.toList()); + } + /** + * Finds all {@link Target#getControllerId()} for all the given parameter + * {@link TargetFilterQuery}. + * + * @param pageRequest + * the pageRequest to enhance the query for paging and sorting + * @param targetFilterQuery + * {@link TargetFilterQuery} + * @return the found {@link Target}s + */ + @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) + public List findAllTargetIdsByTargetFilterQuery(final PageRequest pageRequest, + @NotNull final TargetFilterQuery targetFilterQuery) { + final CriteriaBuilder cb = entityManager.getCriteriaBuilder(); + final CriteriaQuery query = cb.createQuery(Object[].class); + final Root targetRoot = query.from(Target.class); + final CriteriaQuery multiselect = query.multiselect(targetRoot.get(Target_.id), + targetRoot.get(Target_.controllerId), targetRoot.get(Target_.name), + targetRoot.get(pageRequest.getSort().iterator().next().getProperty())); + + final Specification spec = RSQLUtility.parse(targetFilterQuery.getQuery(), TargetFields.class, + entityManager); + final List> specList = new ArrayList<>(); + specList.add(spec); + + final Predicate[] specificationsForMultiSelect = specificationsToPredicate(specList, targetRoot, multiselect, + cb); + + // if we have some predicates then add it to the where clause of the + // multiselect + if (specificationsForMultiSelect.length > 0) { + multiselect.where(specificationsForMultiSelect); + } + final List resultList = getTargetIdNameResultSet(pageRequest, cb, targetRoot, multiselect); + return resultList.parallelStream().map(o -> new TargetIdName((long) o[0], o[1].toString(), o[2].toString())) + .collect(Collectors.toList()); } @PreDestroy @@ -880,7 +977,7 @@ public class TargetManagement { /** * creating a new {@link Target}. - * + * * @param target * to be created * @return the created {@link Target} @@ -901,24 +998,25 @@ public class TargetManagement { * already exists in the DB a {@link EntityAlreadyExistsException} is * thrown. {@link Target}s contain all objects of the parameter targets, * including duplicates. - * + * * @param targets * to be created. * @return the created {@link Target}s * - * @throws {@link EntityAlreadyExistsException} of one of the given targets - * already exist. + * @throws {@link + * EntityAlreadyExistsException} of one of the given targets + * already exist. */ @Modifying @Transactional @NotNull @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) public List createTargets(@NotNull final List targets) { - if (targetRepository.countByControllerIdIn(targets.stream().map(target -> target.getControllerId()) - .collect(Collectors.toList())) > 0) { + if (targetRepository.countByControllerIdIn( + targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList())) > 0) { throw new EntityAlreadyExistsException(); } - final List savedTargets = new ArrayList(); + final List savedTargets = new ArrayList<>(); for (final Target t : targets) { final Target myTarget = createTarget(t); savedTargets.add(myTarget); @@ -947,11 +1045,11 @@ public class TargetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_CREATE_TARGET) public List createTargets(@NotNull final Collection targets, @NotNull final TargetUpdateStatus status, final long lastTargetQuery, final URI address) { - if (targetRepository.countByControllerIdIn(targets.stream().map(target -> target.getControllerId()) - .collect(Collectors.toList())) > 0) { + if (targetRepository.countByControllerIdIn( + targets.stream().map(target -> target.getControllerId()).collect(Collectors.toList())) > 0) { throw new EntityAlreadyExistsException(); } - final List savedTargets = new ArrayList(); + final List savedTargets = new ArrayList<>(); for (final Target t : targets) { final Target myTarget = createTarget(t, status, lastTargetQuery, address); savedTargets.add(myTarget); @@ -970,13 +1068,12 @@ public class TargetManagement { @PreAuthorize(SpringEvalExpressions.HAS_AUTH_READ_TARGET) public List findTargetsByTag(@NotNull final String tagName) { final TargetTag tag = targetTagRepository.findByNameEquals(tagName); - final List assignedTargets = targetRepository.findByTag(tag); - return assignedTargets; + return targetRepository.findByTag(tag); } /** * Count {@link TargetFilterQuery}s for given filter parameter. - * + * * @param targetFilterQuery * {link TargetFilterQuery} * @return the found number {@link TargetFilterQuery}s @@ -990,7 +1087,7 @@ public class TargetManagement { /** * Count {@link TargetFilterQuery}s for given target filter query. - * + * * @param targetFilterQuery * {link TargetFilterQuery} * @return the found number {@link TargetFilterQuery}s @@ -1000,4 +1097,26 @@ public class TargetManagement { final Specification specs = RSQLUtility.parse(targetFilterQuery, TargetFields.class, entityManager); return targetRepository.count(specs); } + + private List getTargetIdNameResultSet(final PageRequest pageRequest, final CriteriaBuilder cb, + final Root targetRoot, final CriteriaQuery multiselect) { + List resultList; + if (pageRequest.getSort() != null) { + final List orders = new ArrayList<>(); + final Sort sort = pageRequest.getSort(); + for (final Sort.Order sortOrder : sort) { + if (sortOrder.getDirection() == Direction.ASC) { + orders.add(cb.asc(targetRoot.get(sortOrder.getProperty()))); + } else { + orders.add(cb.desc(targetRoot.get(sortOrder.getProperty()))); + } + } + multiselect.orderBy(orders); + resultList = entityManager.createQuery(multiselect).setFirstResult(pageRequest.getOffset()) + .setMaxResults(pageRequest.getPageSize()).getResultList(); + } else { + resultList = entityManager.createQuery(multiselect).getResultList(); + } + return resultList; + } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetTagRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetTagRepository.java old mode 100755 new mode 100644 index 674631b0f..09459adbe --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetTagRepository.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetTagRepository.java @@ -11,6 +11,7 @@ package org.eclipse.hawkbit.repository; import java.util.List; import org.eclipse.hawkbit.repository.model.TargetTag; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Modifying; import org.springframework.transaction.annotation.Transactional; @@ -21,7 +22,7 @@ import org.springframework.transaction.annotation.Transactional; * */ @Transactional(readOnly = true) -public interface TargetTagRepository extends BaseEntityRepository { +public interface TargetTagRepository extends BaseEntityRepository, JpaSpecificationExecutor { /** * deletes the {@link TargetTag}s with the given tag names. diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetWithActionType.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetWithActionType.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantConfigurationRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantConfigurationRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantKeyGenerator.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantKeyGenerator.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantMetaDataRepository.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantMetaDataRepository.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantStatsManagement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantStatsManagement.java new file mode 100644 index 000000000..c124037fa --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TenantStatsManagement.java @@ -0,0 +1,66 @@ +/** + * 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; + +import java.util.Optional; + +import org.eclipse.hawkbit.report.model.TenantUsage; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; + +/** + * Management service for stats of a single tenant. + * + */ +@Validated +@Service +public class TenantStatsManagement { + + @Autowired + private TargetRepository targetRepository; + + @Autowired + private LocalArtifactRepository artifactRepository; + + @Autowired + private ActionRepository actionRepository; + + /** + * Service for stats of a single tenant. Opens a new transaction and as a + * result can an be used for multiple tenants, i.e. to allow in one session + * to collect data of all tenants in the system. + * + * @param tenant + * to collect for + * @return collected statistics + */ + @Transactional(propagation = Propagation.REQUIRES_NEW) + public TenantUsage getStatsOfTenant(final String tenant) { + final TenantUsage result = new TenantUsage(tenant); + + result.setTargets(targetRepository.count()); + + final Long artifacts = artifactRepository.countBySoftwareModuleDeleted(false); + result.setArtifacts(artifacts); + + final Optional artifactsSize = artifactRepository.getSumOfUndeletedArtifactSize(); + if (artifactsSize.isPresent()) { + result.setOverallArtifactVolumeInBytes(artifactsSize.get()); + } + + result.setActions(actionRepository.count()); + + return result; + + } + +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/event/DeploymentManagementEvents.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/event/DeploymentManagementEvents.java deleted file mode 100755 index 30bec4471..000000000 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/event/DeploymentManagementEvents.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * 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; - -import java.util.List; - -import org.eclipse.hawkbit.eventbus.event.CancelTargetAssignmentEvent; -import org.eclipse.hawkbit.eventbus.event.TargetAssignDistributionSetEvent; -import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent; -import org.eclipse.hawkbit.repository.DeploymentManagement; -import org.eclipse.hawkbit.repository.model.SoftwareModule; -import org.eclipse.hawkbit.repository.model.Target; -import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import com.google.common.eventbus.EventBus; - -/** - * Defines all events which are sent from the {@link DeploymentManagement}. - * - * - * - * - */ -@Service -public class DeploymentManagementEvents { - - @Autowired - private EventBus eventBus; - - /** - * Sends the {@link TargetAssignDistributionSetEvent} for a specific target - * to the {@link EventBus}. - * - * @param target - * the Target which has been assigned to a distribution set - * @param actionId - * the action id of the assignment - * @param softwareModules - * the software modules which have been assigned - */ - public void assignDistributionSet(final Target target, final Long actionId, - final List softwareModules) { - target.getTargetInfo().setUpdateStatus(TargetUpdateStatus.PENDING); - eventBus.post(new TargetInfoUpdateEvent(target.getTargetInfo())); - eventBus.post(new TargetAssignDistributionSetEvent(target.getControllerId(), actionId, softwareModules, - target.getTargetInfo().getAddress())); - } - - /** - * Sends the {@link CancelTargetAssignmentEvent} for a specific target to - * the {@link EventBus}. - * - * @param target - * the Target which has been assigned to a distribution set - * @param actionId - * the action id of the assignment - */ - public void cancalAssignDistributionSet(final Target target, final Long actionId) { - eventBus.post(new CancelTargetAssignmentEvent(target.getControllerId(), actionId, - target.getTargetInfo().getAddress())); - } -} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactDeleteFailedException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactDeleteFailedException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactUploadFailedException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ArtifactUploadFailedException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/CancelActionNotAllowedException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/CancelActionNotAllowedException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ConcurrentModificationException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ConcurrentModificationException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/DistributionSetCreationFailedMissingMandatoryModuleException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/DistributionSetCreationFailedMissingMandatoryModuleException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/DistributionSetTypeUndefinedException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/DistributionSetTypeUndefinedException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/EntityAlreadyExistsException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/EntityAlreadyExistsException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/EntityLockedException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/EntityLockedException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/EntityNotFoundException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/EntityNotFoundException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/EntityReadOnlyException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/EntityReadOnlyException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ForceQuitActionNotAllowedException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ForceQuitActionNotAllowedException.java new file mode 100644 index 000000000..23b5f7067 --- /dev/null +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ForceQuitActionNotAllowedException.java @@ -0,0 +1,48 @@ +/** + * 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.exception; + +import org.eclipse.hawkbit.exception.SpServerError; +import org.eclipse.hawkbit.exception.SpServerRtException; + +/** + * Thrown when force quitting an actions is not allowed. e.g. the action is not + * active or it is not canceled before. + * + */ +public final class ForceQuitActionNotAllowedException extends SpServerRtException { + /** + * + */ + private static final long serialVersionUID = 1L; + + /** + * Creates a new CancelActionNotAllowed with + * {@link SpServerError#SP_ACTION_NOT_CANCELABLE} error. + */ + public ForceQuitActionNotAllowedException() { + super(SpServerError.SP_ACTION_NOT_FORCE_QUITABLE); + } + + /** + * @param cause + * for the exception + */ + public ForceQuitActionNotAllowedException(final Throwable cause) { + super(SpServerError.SP_ACTION_NOT_FORCE_QUITABLE, cause); + } + + /** + * @param message + * of the error + */ + public ForceQuitActionNotAllowedException(final String message) { + super(message, SpServerError.SP_ACTION_NOT_FORCE_QUITABLE); + } +} diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/GridFSDBFileNotFoundException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/GridFSDBFileNotFoundException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/IncompleteDistributionSetException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/IncompleteDistributionSetException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/InsufficientPermissionException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/InsufficientPermissionException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/InvalidMD5HashException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/InvalidMD5HashException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/InvalidSHA1HashException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/InvalidSHA1HashException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/TenantNotExistException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/TenantNotExistException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ToManyAttributeEntriesException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ToManyAttributeEntriesException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ToManyStatusEntriesException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/ToManyStatusEntriesException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/UnsupportedSoftwareModuleForThisDistributionSetException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/exception/UnsupportedSoftwareModuleForThisDistributionSetException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java old mode 100755 new mode 100644 index 375ffcf0d..eb70f235b --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Action.java @@ -116,6 +116,10 @@ public class Action extends BaseEntity implements Comparable { this.distributionSet = distributionSet; } + /** + * @return true when action is in state {@link Status#CANCELING} or + * {@link Status#CANCELED}, false otherwise + */ public boolean isCancelingOrCanceled() { return status == Status.CANCELING || status == Status.CANCELED; } @@ -262,7 +266,7 @@ public class Action extends BaseEntity implements Comparable { } /** - * @return the forced + * @return true when action is forced, false otherwise */ public boolean isForced() { return actionType == ActionType.FORCED; @@ -331,14 +335,10 @@ public class Action extends BaseEntity implements Comparable { /** * Action status as reported by the controller. * - * Be aware that JPA is persiting the ordnial number of the enum by means + * Be aware that JPA is persisting the ordinal number of the enum by means * the ordered number in the enum. So don't re-order the enums within the * Status enum declaration! * - * - * - * - * */ public enum Status { /** diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionStatus.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionStatus.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionWithStatusCount.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ActionWithStatusCount.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Artifact.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Artifact.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/AssignmentResult.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/AssignmentResult.java old mode 100755 new mode 100644 similarity index 96% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/AssignmentResult.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/AssignmentResult.java index 98e1320b7..05f812b06 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/AssignmentResult.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/AssignmentResult.java @@ -6,7 +6,7 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.repository; +package org.eclipse.hawkbit.repository.model; /** * Generic assigment result bean. diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/BaseEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/BaseEntity.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/CustomSoftwareModule.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/CustomSoftwareModule.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java old mode 100755 new mode 100644 index 1f5843308..e0444bc28 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSet.java @@ -69,13 +69,13 @@ public class DistributionSet extends NamedVersionedEntity { @JoinTable(name = "sp_ds_module", joinColumns = { @JoinColumn(name = "ds_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_ds") ) }, inverseJoinColumns = { @JoinColumn(name = "module_id", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_module_module") ) }) - private final Set modules = new HashSet(); + private final Set modules = new HashSet<>(); @ManyToMany(targetEntity = DistributionSetTag.class) @JoinTable(name = "sp_ds_dstag", joinColumns = { @JoinColumn(name = "ds", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_ds") ) }, inverseJoinColumns = { @JoinColumn(name = "TAG", foreignKey = @ForeignKey(value = ConstraintMode.CONSTRAINT, name = "fk_ds_dstag_tag") ) }) - private Set tags = new HashSet(); + private Set tags = new HashSet<>(); @Column(name = "deleted") private boolean deleted = false; @@ -110,7 +110,7 @@ public class DistributionSet extends NamedVersionedEntity { /** * Parameterized constructor. - * + * * @param name * of the {@link DistributionSet} * @param version @@ -128,7 +128,7 @@ public class DistributionSet extends NamedVersionedEntity { this.type = type; if (moduleList != null) { - moduleList.forEach(module -> addModule(module)); + moduleList.forEach(this::addModule); } complete = type.checkComplete(this); } @@ -160,7 +160,7 @@ public class DistributionSet extends NamedVersionedEntity { /* * (non-Javadoc) - * + * * @see java.lang.Object#hashCode() */ @Override @@ -173,7 +173,7 @@ public class DistributionSet extends NamedVersionedEntity { /* * (non-Javadoc) - * + * * @see java.lang.Object#equals(java.lang.Object) */ @Override @@ -234,7 +234,7 @@ public class DistributionSet extends NamedVersionedEntity { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override @@ -322,8 +322,8 @@ public class DistributionSet extends NamedVersionedEntity { * Searches through modules for the given type. * * @param type - * to serach for - * @return SoftwareModule of giben type or null if not in the + * to seach for + * @return SoftwareModule of given type or null if not in the * list. */ public SoftwareModule findFirstModuleByType(final SoftwareModuleType type) { diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetIdName.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetIdName.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetMetadata.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetMetadata.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTag.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTag.java old mode 100755 new mode 100644 index 0e28caa7c..a3a2172be --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTag.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTag.java @@ -8,8 +8,12 @@ */ package org.eclipse.hawkbit.repository.model; +import java.util.List; + import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.Index; +import javax.persistence.ManyToMany; import javax.persistence.Table; import javax.persistence.UniqueConstraint; @@ -24,12 +28,14 @@ import javax.persistence.UniqueConstraint; * */ @Entity -@Table(name = "sp_distributionset_tag", indexes = { - @Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = { - "name", "tenant" }, name = "uk_ds_tag") ) +@Table(name = "sp_distributionset_tag", indexes = { @Index(name = "sp_idx_distribution_set_tag_prim", columnList = "tenant,id") }, uniqueConstraints = @UniqueConstraint(columnNames = { + "name", "tenant" }, name = "uk_ds_tag")) public class DistributionSetTag extends Tag { private static final long serialVersionUID = 1L; + @ManyToMany(mappedBy = "tags", targetEntity = DistributionSet.class, fetch = FetchType.LAZY) + private List assignedToDistributionSet; + /** * Public constructor. * @@ -58,6 +64,10 @@ public class DistributionSetTag extends Tag { super(); } + public List getAssignedToDistributionSet() { + return assignedToDistributionSet; + } + /* * (non-Javadoc) * diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagAssigmentResult.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTagAssigmentResult.java old mode 100755 new mode 100644 similarity index 79% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagAssigmentResult.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTagAssigmentResult.java index 4ece58344..d7ed57305 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/DistributionSetTagAssigmentResult.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTagAssigmentResult.java @@ -6,25 +6,20 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.repository; +package org.eclipse.hawkbit.repository.model; import java.util.List; -import org.eclipse.hawkbit.repository.model.DistributionSet; -import org.eclipse.hawkbit.repository.model.DistributionSetTag; - /** * Result object for {@link DistributionSetTag} assigments. * - * - * - * */ public class DistributionSetTagAssigmentResult extends AssignmentResult { private final int unassigned; private final List assignedDs; private final List unassignedDs; + private final DistributionSetTag distributionSetTag; /** * Constructor. @@ -39,13 +34,17 @@ public class DistributionSetTagAssigmentResult extends AssignmentResult { * {@link List} of assigned {@link DistributionSet}s. * @param unassignedDs * {@link List} of unassigned {@link DistributionSet}s. + * @param distributionSetTag + * the assigned or unassigned tag */ public DistributionSetTagAssigmentResult(final int alreadyAssigned, final int assigned, final int unassigned, - final List assignedDs, final List unassignedDs) { + final List assignedDs, final List unassignedDs, + final DistributionSetTag distributionSetTag) { super(assigned, alreadyAssigned); this.unassigned = unassigned; this.assignedDs = assignedDs; this.unassignedDs = unassignedDs; + this.distributionSetTag = distributionSetTag; } /** @@ -55,6 +54,13 @@ public class DistributionSetTagAssigmentResult extends AssignmentResult { return unassigned; } + /** + * @return the distributionSetTag + */ + public DistributionSetTag getDistributionSetTag() { + return distributionSetTag; + } + /** * @return the assignedDs */ diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java old mode 100755 new mode 100644 index 47bc4b1b7..fd96f7cd2 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetType.java @@ -59,6 +59,7 @@ public class DistributionSetType extends NamedEntity { private boolean deleted = false; public DistributionSetType() { + //default public constructor } /** @@ -151,6 +152,21 @@ public class DistributionSetType extends NamedEntity { } + /** + * Checks if the given {@link SoftwareModuleType} is in this + * {@link DistributionSetType} and defined as + * {@link DistributionSetTypeElement#isMandatory()}. + * + * @param softwareModuleType + * search for by {@link SoftwareModuleType#getId()} + * @return true if found + */ + public boolean containsMandatoryModuleType(final Long softwareModuleTypeId) { + return elements.stream().filter(element -> element.isMandatory()) + .filter(element -> element.getSmType().getId().equals(softwareModuleTypeId)).findFirst().isPresent(); + + } + /** * Checks if the given {@link SoftwareModuleType} is in this * {@link DistributionSetType} and NOT defined as @@ -166,6 +182,21 @@ public class DistributionSetType extends NamedEntity { } + /** + * Checks if the given {@link SoftwareModuleType} is in this + * {@link DistributionSetType} and NOT defined as + * {@link DistributionSetTypeElement#isMandatory()}. + * + * @param softwareModuleTypeId + * search by {@link SoftwareModuleType#getId()} + * @return true if found + */ + public boolean containsOptionalModuleType(final Long softwareModuleTypeId) { + return elements.stream().filter(element -> !element.isMandatory()) + .filter(element -> element.getSmType().getId().equals(softwareModuleTypeId)).findFirst().isPresent(); + + } + /** * Compares the modules of this {@link DistributionSetType} and the given * one. @@ -274,7 +305,7 @@ public class DistributionSetType extends NamedEntity { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTypeElement.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTypeElement.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTypeElementCompositeKey.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DistributionSetTypeElementCompositeKey.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DsMetadataCompositeKey.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/DsMetadataCompositeKey.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifact.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifact.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifactProvider.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/ExternalArtifactProvider.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/LocalArtifact.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/LocalArtifact.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedEntity.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedVersionedEntity.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/NamedVersionedEntity.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModule.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModule.java old mode 100755 new mode 100644 index a0c510010..a3685df66 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModule.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModule.java @@ -56,7 +56,7 @@ public class SoftwareModule extends NamedVersionedEntity { private SoftwareModuleType type; @ManyToMany(mappedBy = "modules", targetEntity = DistributionSet.class, fetch = FetchType.LAZY) - private final List assignedTo = new ArrayList(); + private final List assignedTo = new ArrayList<>(); @Column(name = "deleted") private boolean deleted = false; @@ -84,7 +84,7 @@ public class SoftwareModule extends NamedVersionedEntity { /** * parameterized constructor. - * + * * @param type * of the {@link SoftwareModule} * @param name @@ -163,7 +163,7 @@ public class SoftwareModule extends NamedVersionedEntity { * @return the artifacts */ public List getArtifacts() { - final List result = new ArrayList(); + final List result = new ArrayList<>(); result.addAll(artifacts); result.addAll(externalArtifacts); @@ -241,18 +241,19 @@ public class SoftwareModule extends NamedVersionedEntity { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override public String toString() { return "SoftwareModule [type=" + type + ", deleted=" + deleted + ", getVersion()=" + getVersion() - + ", getOptLockRevision()=" + getOptLockRevision() + ", getId()=" + getId() + "]"; + + ", getOptLockRevision()=" + getOptLockRevision() + ", getId()=" + getId() + ", getType()=" + + getType().getName() + "]"; } /* * (non-Javadoc) - * + * * @see java.lang.Object#hashCode() */ @Override @@ -265,7 +266,7 @@ public class SoftwareModule extends NamedVersionedEntity { /* * (non-Javadoc) - * + * * @see java.lang.Object#equals(java.lang.Object) */ @Override diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleIdName.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleIdName.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleMetadata.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleMetadata.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java old mode 100755 new mode 100644 index 0810d408e..49427b9ea --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SoftwareModuleType.java @@ -138,4 +138,9 @@ public class SoftwareModuleType extends NamedEntity { this.colour = colour; } + @Override + public String toString() { + return "SoftwareModuleType [key=" + key + ", getName()=" + getName() + ", getId()=" + getId() + "]"; + } + } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SwMetadataCompositeKey.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/SwMetadataCompositeKey.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Tag.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Tag.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/Target.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetFilterQuery.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetFilterQuery.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetIdName.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetIdName.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetInfo.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetInfo.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetTag.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetTag.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetTagAssigmentResult.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetTagAssigmentResult.java old mode 100755 new mode 100644 similarity index 85% rename from hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetTagAssigmentResult.java rename to hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetTagAssigmentResult.java index 10c1285b7..b12b80d58 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/TargetTagAssigmentResult.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetTagAssigmentResult.java @@ -6,13 +6,10 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html */ -package org.eclipse.hawkbit.repository; +package org.eclipse.hawkbit.repository.model; import java.util.List; -import org.eclipse.hawkbit.repository.model.Target; -import org.eclipse.hawkbit.repository.model.TargetTag; - /** * Result object for {@link TargetTag} assigments. * @@ -25,6 +22,7 @@ public class TargetTagAssigmentResult extends AssignmentResult { private final int unassigned; private final List assignedTargets; private final List unassignedTargets; + private final TargetTag targetTag; /** * Constructor. @@ -39,13 +37,16 @@ public class TargetTagAssigmentResult extends AssignmentResult { * {@link List} of assigned {@link Target}s. * @param unassignedTargets * {@link List} of unassigned {@link Target}s. + * @param targetTag + * the assigned or unassigned tag */ public TargetTagAssigmentResult(final int alreadyAssigned, final int assigned, final int unassigned, - final List assignedTargets, final List unassignedTargets) { + final List assignedTargets, final List unassignedTargets, final TargetTag targetTag) { super(assigned, alreadyAssigned); this.unassigned = unassigned; this.assignedTargets = assignedTargets; this.unassignedTargets = unassignedTargets; + this.targetTag = targetTag; } /** @@ -69,4 +70,7 @@ public class TargetTagAssigmentResult extends AssignmentResult { return unassignedTargets; } + public TargetTag getTargetTag() { + return targetTag; + } } diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetUpdateStatus.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TargetUpdateStatus.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantConfiguration.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantMetaData.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/TenantMetaData.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/CacheManagerHolder.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/CacheManagerHolder.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/PollConfigurationHelper.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/PollConfigurationHelper.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/SecurityChecker.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/SecurityChecker.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/SecurityTokenGeneratorHolder.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/SecurityTokenGeneratorHolder.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/SystemManagementHolder.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/SystemManagementHolder.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/TenantAwareHolder.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/model/helper/TenantAwareHolder.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/PropertyMapper.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/PropertyMapper.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLParameterSyntaxException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLParameterSyntaxException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLParameterUnsupportedFieldException.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLParameterUnsupportedFieldException.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java old mode 100755 new mode 100644 index 2fcbaac22..da569a85e --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/rsql/RSQLUtility.java @@ -325,23 +325,14 @@ public final class RSQLUtility { final String finalProperty = validatePropertyFieldName(propertyFieldName, isDefinedInEnum, classMetadata, metaModel, node); - final String value = node.getArguments().get(0); - Object transformedValue = convertValueIfNecessary(node, fieldName, value); + final List values = node.getArguments(); + final List transformedValue = new ArrayList<>(); final Path fieldPath = getFieldPath(finalProperty); - // in case the value of an rsql query e.g. type==application is an - // enum we need to - // handle it separately because JPA needs the correct java-type to - // build an - // expression. So String and numeric values JPA can do it by it's - // own but not for - // classes like enums. So we need to transform the given value - // string into the enum - // class. - final Class javaType = fieldPath.getJavaType(); - if (javaType != null && javaType.isEnum()) { - transformedValue = transformEnumValue(node, value, javaType); + for (final String value : values) { + transformedValue.add(convertValueIfNecessary(node, fieldName, value, fieldPath)); } - return mapToPredicate(node, fieldPath, value, transformedValue); + + return mapToPredicate(node, fieldPath, node.getArguments(), transformedValue); } private List getExpectedFieldList() { @@ -359,7 +350,21 @@ public final class RSQLUtility { } @SuppressWarnings({ "rawtypes", "unchecked" }) - private Object convertValueIfNecessary(final ComparisonNode node, final A fieldName, final String value) { + private Object convertValueIfNecessary(final ComparisonNode node, final A fieldName, final String value, + final Path fieldPath) { + // in case the value of an rsql query e.g. type==application is an + // enum we need to + // handle it separately because JPA needs the correct java-type to + // build an + // expression. So String and numeric values JPA can do it by it's + // own but not for + // classes like enums. So we need to transform the given value + // string into the enum + // class. + final Class javaType = fieldPath.getJavaType(); + if (javaType != null && javaType.isEnum()) { + return transformEnumValue(node, value, javaType); + } if (fieldName instanceof FieldValueConverter) { final Object convertedValue = ((FieldValueConverter) fieldName).convertValue(fieldName, value); if (convertedValue == null) { @@ -396,10 +401,12 @@ public final class RSQLUtility { } private List mapToPredicate(final ComparisonNode node, final Path fieldPath, - final String value, final Object transformedValue) { + final List values, final List transformedValues) { // only 'equal' and 'notEqual' can handle transformed value like // enums. The JPA API // cannot handle object types for greaterThan etc methods. + final Object transformedValue = transformedValues.get(0); + final String value = values.get(0); final List singleList; switch (node.getOperator().getSymbol()) { case "=li=": @@ -424,6 +431,12 @@ public final class RSQLUtility { case "=le=": singleList = toSingleList(cb.lessThanOrEqualTo(pathOfString(fieldPath), value)); break; + case "=in=": + singleList = toSingleList(fieldPath.in(transformedValues)); + break; + case "=out=": + singleList = toSingleList(cb.not(fieldPath.in(transformedValues))); + break; default: LOGGER.info("operator symbol {} is either not supported or not implemented"); singleList = Collections.emptyList(); diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetSpecification.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetSpecification.java old mode 100755 new mode 100644 index 646753d93..c5b77a413 --- a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetSpecification.java +++ b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetSpecification.java @@ -131,6 +131,7 @@ public final class DistributionSetSpecification { targetRoot.fetch(DistributionSet_.modules, JoinType.LEFT); targetRoot.fetch(DistributionSet_.tags, JoinType.LEFT); targetRoot.fetch(DistributionSet_.type, JoinType.LEFT); + query.distinct(true); return predicate; } }; diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetTypeSpecification.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/DistributionSetTypeSpecification.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/SoftwareModuleSpecification.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/SoftwareModuleSpecification.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetFilterQuerySpecification.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetFilterQuerySpecification.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetSpecifications.java b/hawkbit-repository/src/main/java/org/eclipse/hawkbit/repository/specifications/TargetSpecifications.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/resources/db/migration/H2/V1_0_1__init___H2.sql b/hawkbit-repository/src/main/resources/db/migration/H2/V1_0_1__init___H2.sql old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/resources/db/migration/H2/V1_2_0__update_target_info_for_message___H2.sql b/hawkbit-repository/src/main/resources/db/migration/H2/V1_2_0__update_target_info_for_message___H2.sql old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/resources/db/migration/H2/V1_4_0__cascade_delete___H2.sql b/hawkbit-repository/src/main/resources/db/migration/H2/V1_4_0__cascade_delete___H2.sql old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/resources/db/migration/H2/V1_4_1__cascade_delete___H2.sql b/hawkbit-repository/src/main/resources/db/migration/H2/V1_4_1__cascade_delete___H2.sql old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/resources/db/migration/H2/V1_5_0__target_filter_query___H2.sql b/hawkbit-repository/src/main/resources/db/migration/H2/V1_5_0__target_filter_query___H2.sql old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/resources/db/migration/MYSQL/V1_0_1__init___MYSQL.sql b/hawkbit-repository/src/main/resources/db/migration/MYSQL/V1_0_1__init___MYSQL.sql old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/resources/db/migration/MYSQL/V1_2_0__update_target_info_for_message___MYSQL.sql b/hawkbit-repository/src/main/resources/db/migration/MYSQL/V1_2_0__update_target_info_for_message___MYSQL.sql old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/resources/db/migration/MYSQL/V1_4_0__cascade_delete___MYSQL.sql b/hawkbit-repository/src/main/resources/db/migration/MYSQL/V1_4_0__cascade_delete___MYSQL.sql old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/resources/db/migration/MYSQL/V1_4_1__cascade_delete___MYSQL.sql b/hawkbit-repository/src/main/resources/db/migration/MYSQL/V1_4_1__cascade_delete___MYSQL.sql old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/main/resources/db/migration/MYSQL/V1_5_0__target_filter_query___MYSQL.sql b/hawkbit-repository/src/main/resources/db/migration/MYSQL/V1_5_0__target_filter_query___MYSQL.sql old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTest.java old mode 100755 new mode 100644 index cf11fe046..a3533b658 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTest.java @@ -12,7 +12,6 @@ import static org.fest.assertions.api.Assertions.assertThat; import java.util.List; import java.util.Properties; -import java.util.concurrent.Callable; import javax.persistence.EntityManager; import javax.persistence.PersistenceContext; @@ -87,7 +86,7 @@ import org.springframework.web.context.WebApplicationContext; public abstract class AbstractIntegrationTest implements EnvironmentAware { protected static Logger LOG = null; - protected final Pageable pageReq = new PageRequest(0, 400); + protected static final Pageable pageReq = new PageRequest(0, 400); @PersistenceContext protected EntityManager entityManager; @@ -210,7 +209,7 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware { /* * (non-Javadoc) - * + * * @see org.springframework.context.EnvironmentAware#setEnvironment(org. * springframework.core.env. Environment) */ @@ -221,42 +220,26 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware { @Before public void before() throws Exception { - mvc = MockMvcBuilders - .webAppContextSetup(context) - .addFilter( - new DosFilter(100, 10, "127\\.0\\.0\\.1|\\[0:0:0:0:0:0:0:1\\]", "(^192\\.168\\.)", - "X-Forwarded-For")) - .addFilter( - new ExcludePathAwareShallowETagFilter( - "/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", - "/*/controller/artifacts/**")).build(); + mvc = MockMvcBuilders.webAppContextSetup(context) + .addFilter(new DosFilter(100, 10, "127\\.0\\.0\\.1|\\[0:0:0:0:0:0:0:1\\]", "(^192\\.168\\.)", + "X-Forwarded-For")) + .addFilter(new ExcludePathAwareShallowETagFilter( + "/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", "/*/controller/artifacts/**")) + .build(); - standardDsType = securityRule.runAsPrivileged(new Callable() { - @Override - public DistributionSetType call() throws Exception { - return systemManagement.getTenantMetadata().getDefaultDsType(); - } - }); + standardDsType = securityRule.runAsPrivileged(() -> systemManagement.getTenantMetadata().getDefaultDsType()); - osType = securityRule.runAsPrivileged(new Callable() { - @Override - public SoftwareModuleType call() throws Exception { - return softwareManagement.findSoftwareModuleTypeByKey("os"); - } - }); + osType = securityRule.runAsPrivileged(() -> softwareManagement.findSoftwareModuleTypeByKey("os")); + osType.setDescription("Updated description to have lastmodified available in tests"); + osType = securityRule.runAsPrivileged(() -> softwareManagement.updateSoftwareModuleType(osType)); - appType = securityRule.runAsPrivileged(new Callable() { - @Override - public SoftwareModuleType call() throws Exception { - return softwareManagement.findSoftwareModuleTypeByKey("application"); - } - }); - runtimeType = securityRule.runAsPrivileged(new Callable() { - @Override - public SoftwareModuleType call() throws Exception { - return softwareManagement.findSoftwareModuleTypeByKey("runtime"); - } - }); + appType = securityRule.runAsPrivileged(() -> softwareManagement.findSoftwareModuleTypeByKey("application")); + appType.setDescription("Updated description to have lastmodified available in tests"); + appType = securityRule.runAsPrivileged(() -> softwareManagement.updateSoftwareModuleType(appType)); + + runtimeType = securityRule.runAsPrivileged(() -> softwareManagement.findSoftwareModuleTypeByKey("runtime")); + runtimeType.setDescription("Updated description to have lastmodified available in tests"); + runtimeType = securityRule.runAsPrivileged(() -> softwareManagement.updateSoftwareModuleType(runtimeType)); } @BeforeClass @@ -297,20 +280,12 @@ public abstract class AbstractIntegrationTest implements EnvironmentAware { @Transactional protected void deleteAllRepos() throws Exception { final List tenants = securityRule.runAs(WithSpringAuthorityRule.withUser(false), - new Callable>() { - @Override - public List call() throws Exception { - return systemManagement.findTenants(); - } - }); + () -> systemManagement.findTenants()); tenants.forEach(tenant -> { try { - securityRule.runAs(WithSpringAuthorityRule.withUser(false), new Callable() { - @Override - public Void call() throws Exception { - systemManagement.deleteTenant(tenant); - return null; - } + securityRule.runAs(WithSpringAuthorityRule.withUser(false), () -> { + systemManagement.deleteTenant(tenant); + return null; }); } catch (final Exception e) { e.printStackTrace(); diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTestWithMongoDB.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/AbstractIntegrationTestWithMongoDB.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/CIMySqlTestDatabase.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/CIMySqlTestDatabase.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/FreePortFileWriter.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/FreePortFileWriter.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/HashGeneratorUtils.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/HashGeneratorUtils.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/LocalH2TestDatabase.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/LocalH2TestDatabase.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/MethodSecurityUtil.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/MethodSecurityUtil.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/RandomGeneratedInputStream.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/RandomGeneratedInputStream.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestConfiguration.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/TestDataUtil.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/Testdatabase.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/Testdatabase.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/WithSpringAuthorityRule.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/WithSpringAuthorityRule.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/WithUser.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/WithUser.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/cache/CacheKeysTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/cache/CacheKeysTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/cache/CacheWriteNotifyTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/cache/CacheWriteNotifyTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/eventbus/CacheFieldEntityListenerTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/eventbus/CacheFieldEntityListenerTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ActionTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ActionTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementNoMongoDbTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementNoMongoDbTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ArtifactManagementTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ControllerManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ControllerManagementTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java old mode 100755 new mode 100644 index ba7506ac6..8583522df --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/DeploymentManagementTest.java @@ -26,6 +26,7 @@ import org.eclipse.hawkbit.Constants; import org.eclipse.hawkbit.TestDataUtil; import org.eclipse.hawkbit.eventbus.event.CancelTargetAssignmentEvent; import org.eclipse.hawkbit.eventbus.event.TargetAssignDistributionSetEvent; +import org.eclipse.hawkbit.repository.exception.ForceQuitActionNotAllowedException; import org.eclipse.hawkbit.repository.exception.IncompleteDistributionSetException; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.ActionType; @@ -43,16 +44,16 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort.Direction; -import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; -import com.google.common.eventbus.EventBus; -import com.google.common.eventbus.Subscribe; - import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Issue; import ru.yandex.qatools.allure.annotations.Stories; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import com.google.common.eventbus.EventBus; +import com.google.common.eventbus.Subscribe; + /** * Test class testing the functionality of triggering a deployment of * {@link DistributionSet}s to {@link Target}s. @@ -84,6 +85,42 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { assertThat(findActionsWithStatusCountByTarget.get(0).getActionStatusCount()).isEqualTo(3L); } + @Test + @Description("Ensures that distribution sets can assigned and unassigned to a distribution set tag. Not exists distribution set will be ignored for the assignment.") + public void assignAndUnassignDistributionSetToTag() { + final List assignDS = new ArrayList(); + for (int i = 0; i < 4; i++) { + assignDS.add(TestDataUtil.generateDistributionSet("DS" + i, "1.0", softwareManagement, + distributionSetManagement, new ArrayList()).getId()); + } + // not exists + assignDS.add(Long.valueOf(100)); + final DistributionSetTag tag = tagManagement.createDistributionSetTag(new DistributionSetTag("Tag1")); + + final List assignedDS = distributionSetManagement.assignTag(assignDS, tag); + assertThat(assignedDS.size()).isEqualTo(4); + assignedDS.forEach(ds -> assertThat(ds.getTags().size()).isEqualTo(1)); + + DistributionSetTag findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1"); + assertThat(assignedDS.size()).isEqualTo(findDistributionSetTag.getAssignedToDistributionSet().size()); + + assertThat(distributionSetManagement.unAssignTag(Long.valueOf(100), findDistributionSetTag)).isNull(); + + final DistributionSet unAssignDS = distributionSetManagement.unAssignTag(assignDS.get(0), + findDistributionSetTag); + assertThat(unAssignDS.getId()).isEqualTo(assignDS.get(0)); + assertThat(unAssignDS.getTags().size()).isEqualTo(0); + findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1"); + assertThat(findDistributionSetTag.getAssignedToDistributionSet().size()).isEqualTo(3); + + final List unAssignTargets = distributionSetManagement + .unAssignAllDistributionSetsByTag(findDistributionSetTag); + findDistributionSetTag = tagManagement.findDistributionSetTag("Tag1"); + assertThat(findDistributionSetTag.getAssignedToDistributionSet().size()).isEqualTo(0); + assertThat(unAssignTargets.size()).isEqualTo(3); + unAssignTargets.forEach(target -> assertThat(target.getTags().size()).isEqualTo(0)); + } + @Test @Description("Test verifies that an assignment with automatic cancelation works correctly even if the update is split into multiple partitions on the database.") @Issue("MECS-674") @@ -92,19 +129,21 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final DistributionSet cancelDs = TestDataUtil.generateDistributionSet("Canceled DS", "1.0", softwareManagement, distributionSetManagement, new ArrayList()); - final DistributionSet cancelDs2 = TestDataUtil.generateDistributionSet("Canceled DS", "1.2", softwareManagement, - distributionSetManagement, new ArrayList()); + final DistributionSet cancelDs2 = TestDataUtil.generateDistributionSet("Canceled DS", "1.2", + softwareManagement, distributionSetManagement, new ArrayList()); - List targets = targetManagement - .createTargets(TestDataUtil.generateTargets(Constants.MAX_ENTRIES_IN_STATEMENT + 10)); + List targets = targetManagement.createTargets(TestDataUtil + .generateTargets(Constants.MAX_ENTRIES_IN_STATEMENT + 10)); targets = deploymentManagement.assignDistributionSet(cancelDs, targets).getAssignedTargets(); targets = deploymentManagement.assignDistributionSet(cancelDs2, targets).getAssignedTargets(); - targetManagement.findAllTargetIds().forEach(targetIdName -> { - assertThat(deploymentManagement.findActiveActionsByTarget( - targetManagement.findTargetByControllerID(targetIdName.getControllerId()))).hasSize(2); - }); + targetManagement.findAllTargetIds().forEach( + targetIdName -> { + assertThat( + deploymentManagement.findActiveActionsByTarget(targetManagement + .findTargetByControllerID(targetIdName.getControllerId()))).hasSize(2); + }); } @Test @@ -125,8 +164,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { target = targetManagement.createTarget(target); // check initial status - assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.UNKNOWN); + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( + TargetUpdateStatus.UNKNOWN); // assign the two sets in a row Action firstAction = assignSet(target, dsFirst); @@ -145,8 +184,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { new ActionStatus(secondAction, Status.CANCELED, System.currentTimeMillis()), secondAction); assertThat(actionStatusRepository.findAll()).hasSize(4); assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(dsFirst); - assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.PENDING); + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( + TargetUpdateStatus.PENDING); // we cancel first -> back to installed deploymentManagement.cancelAction(firstAction, @@ -157,10 +196,10 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { controllerManagement.addCancelActionStatus( new ActionStatus(firstAction, Status.CANCELED, System.currentTimeMillis()), firstAction); assertThat(actionStatusRepository.findAll()).hasSize(6); - assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()) - .isEqualTo(dsInstalled); - assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.IN_SYNC); + assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo( + dsInstalled); + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( + TargetUpdateStatus.IN_SYNC); } @Test @@ -181,8 +220,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { target = targetManagement.createTarget(target); // check initial status - assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.UNKNOWN); + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( + TargetUpdateStatus.UNKNOWN); // assign the two sets in a row Action firstAction = assignSet(target, dsFirst); @@ -201,8 +240,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { new ActionStatus(firstAction, Status.CANCELED, System.currentTimeMillis()), firstAction); assertThat(actionStatusRepository.findAll()).hasSize(4); assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo(dsSecond); - assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.PENDING); + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( + TargetUpdateStatus.PENDING); // we cancel second -> remain assigned until finished cancellation deploymentManagement.cancelAction(secondAction, @@ -215,17 +254,90 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { controllerManagement.addCancelActionStatus( new ActionStatus(secondAction, Status.CANCELED, System.currentTimeMillis()), secondAction); // cancelled success -> back to dsInstalled - assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()) - .isEqualTo(dsInstalled); - assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.IN_SYNC); + assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo( + dsInstalled); + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( + TargetUpdateStatus.IN_SYNC); + } + + @Test + @Description("Force Quit an Assignment. Expected behaviour is that the action is canceled and is marked as deleted. The assigned Software module") + public void forceQuitSetActionToInactive() throws InterruptedException { + + Target target = new Target("4712"); + final DistributionSet dsInstalled = TestDataUtil.generateDistributionSet("installed", softwareManagement, + distributionSetManagement, true); + target.getTargetInfo().setInstalledDistributionSet(dsInstalled); + target = targetManagement.createTarget(target); + + final DistributionSet ds = TestDataUtil.generateDistributionSet("newDS", softwareManagement, + distributionSetManagement, true).setRequiredMigrationStep(true); + + // verify initial status + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( + TargetUpdateStatus.UNKNOWN); + + Action assigningAction = assignSet(target, ds); + + // verify assignment + assertThat(actionRepository.findAll()).hasSize(1); + assertThat(actionStatusRepository.findAll()).hasSize(1); + + target = targetManagement.findTargetByControllerID(target.getControllerId()); + + // force quit assignment + deploymentManagement.cancelAction(assigningAction, target); + assigningAction = deploymentManagement.findActionWithDetails(assigningAction.getId()); + + deploymentManagement.forceQuitAction(assigningAction, target); + + assigningAction = deploymentManagement.findActionWithDetails(assigningAction.getId()); + + // verify + assertThat(assigningAction.getStatus()).isEqualTo(Status.CANCELED); + assertThat(targetManagement.findTargetByControllerID("4712").getAssignedDistributionSet()).isEqualTo( + dsInstalled); + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( + TargetUpdateStatus.IN_SYNC); + } + + @Test + @Description("Force Quit an not canceled Assignment. Expected behaviour is that the action can not be force quit and there is thrown an exception.") + public void forceQuitNotAllowedThrowsException() { + + Target target = new Target("4712"); + final DistributionSet dsInstalled = TestDataUtil.generateDistributionSet("installed", softwareManagement, + distributionSetManagement, true); + target.getTargetInfo().setInstalledDistributionSet(dsInstalled); + target = targetManagement.createTarget(target); + + final DistributionSet ds = TestDataUtil.generateDistributionSet("newDS", softwareManagement, + distributionSetManagement, true).setRequiredMigrationStep(true); + + // verify initial status + assertThat(targetManagement.findTargetByControllerID("4712").getTargetInfo().getUpdateStatus()).isEqualTo( + TargetUpdateStatus.UNKNOWN); + + final Action assigningAction = assignSet(target, ds); + + // verify assignment + assertThat(actionRepository.findAll()).hasSize(1); + assertThat(actionStatusRepository.findAll()).hasSize(1); + + // force quit assignment + try { + deploymentManagement.forceQuitAction(assigningAction, + targetManagement.findTargetByControllerID(target.getControllerId())); + fail("expected ForceQuitActionNotAllowedException"); + } catch (final ForceQuitActionNotAllowedException ex) { + } } private Action assignSet(final Target target, final DistributionSet ds) { deploymentManagement.assignDistributionSet(ds.getId(), new String[] { target.getControllerId() }); assertThat( targetManagement.findTargetByControllerID(target.getControllerId()).getTargetInfo().getUpdateStatus()) - .isEqualTo(TargetUpdateStatus.PENDING); + .isEqualTo(TargetUpdateStatus.PENDING); assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getAssignedDistributionSet()) .isEqualTo(ds); final Action action = actionRepository.findByTargetAndDistributionSet(pageReq, target, ds).getContent().get(0); @@ -248,12 +360,12 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { eventBus.register(eventHandlerMock); final String myCtrlIDPref = "myCtrlID"; - final Iterable savedNakedTargets = targetManagement - .createTargets(TestDataUtil.buildTargetFixtures(10, myCtrlIDPref, "first description")); + final Iterable savedNakedTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(10, + myCtrlIDPref, "first description")); final String myDeployedCtrlIDPref = "myDeployedCtrlID"; - final List savedDeployedTargets = targetManagement - .createTargets(TestDataUtil.buildTargetFixtures(20, myDeployedCtrlIDPref, "first description")); + final List savedDeployedTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures(20, + myDeployedCtrlIDPref, "first description")); final DistributionSet ds = TestDataUtil.generateDistributionSet("", softwareManagement, distributionSetManagement); @@ -297,15 +409,15 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final List targets = targetManagement.createTargets(TestDataUtil.generateTargets(10)); - final SoftwareModule ah = softwareManagement - .createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", null, "")); - final SoftwareModule jvm = softwareManagement - .createSoftwareModule(new SoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, "")); - final SoftwareModule os = softwareManagement - .createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2", null, "")); + final SoftwareModule ah = softwareManagement.createSoftwareModule(new SoftwareModule(appType, "agent-hub", + "1.0.1", null, "")); + final SoftwareModule jvm = softwareManagement.createSoftwareModule(new SoftwareModule(runtimeType, + "oracle-jre", "1.7.2", null, "")); + final SoftwareModule os = softwareManagement.createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2", + null, "")); - final DistributionSet incomplete = distributionSetManagement.createDistributionSet( - new DistributionSet("incomplete", "v1", "", standardDsType, Lists.newArrayList(ah, jvm))); + final DistributionSet incomplete = distributionSetManagement.createDistributionSet(new DistributionSet( + "incomplete", "v1", "", standardDsType, Lists.newArrayList(ah, jvm))); try { deploymentManagement.assignDistributionSet(incomplete, targets); @@ -375,18 +487,18 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final Iterable undeployedTargetsFromDB = targetRepository.findAll(undeployedTargetIDs); // test that number of Targets - assertThat(allFoundTargets.spliterator().getExactSizeIfKnown()) - .isEqualTo(deployedTargetsFromDB.spliterator().getExactSizeIfKnown() + assertThat(allFoundTargets.spliterator().getExactSizeIfKnown()).isEqualTo( + deployedTargetsFromDB.spliterator().getExactSizeIfKnown() + undeployedTargetsFromDB.spliterator().getExactSizeIfKnown()); assertThat(deployedTargetsFromDB.spliterator().getExactSizeIfKnown()).isEqualTo(noOfDeployedTargets); assertThat(undeployedTargetsFromDB.spliterator().getExactSizeIfKnown()).isEqualTo(noOfUndeployedTargets); // test the content of different lists assertThat(allFoundTargets).containsAll(deployedTargetsFromDB).containsAll(undeployedTargetsFromDB); - assertThat(deployedTargetsFromDB).containsAll(savedDeployedTargets) - .doesNotContain(Iterables.toArray(undeployedTargetsFromDB, Target.class)); - assertThat(undeployedTargetsFromDB).containsAll(savedNakedTargets) - .doesNotContain(Iterables.toArray(deployedTargetsFromDB, Target.class)); + assertThat(deployedTargetsFromDB).containsAll(savedDeployedTargets).doesNotContain( + Iterables.toArray(undeployedTargetsFromDB, Target.class)); + assertThat(undeployedTargetsFromDB).containsAll(savedNakedTargets).doesNotContain( + Iterables.toArray(deployedTargetsFromDB, Target.class)); // For each of the 4 targets 1 distribution sets gets assigned eventHandlerMock.getEvents(10, TimeUnit.SECONDS); @@ -420,18 +532,21 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // verifying the correctness of the assignments for (final Target t : deployResWithDsA.getDeployedTargets()) { assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsA.getId()); - assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() - .getInstalledDistributionSet()).isNull(); + assertThat( + targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() + .getInstalledDistributionSet()).isNull(); } for (final Target t : deployResWithDsB.getDeployedTargets()) { assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsB.getId()); - assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() - .getInstalledDistributionSet()).isNull(); + assertThat( + targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() + .getInstalledDistributionSet()).isNull(); } for (final Target t : deployResWithDsC.getDeployedTargets()) { assertThat(t.getAssignedDistributionSet().getId()).isEqualTo(dsC.getId()); - assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() - .getInstalledDistributionSet()).isNull(); + assertThat( + targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() + .getInstalledDistributionSet()).isNull(); assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus()) .isEqualTo(TargetUpdateStatus.PENDING); } @@ -444,8 +559,9 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { for (final Target t_ : updatedTsDsA) { final Target t = targetManagement.findTargetByControllerID(t_.getControllerId()); assertThat(t.getAssignedDistributionSet()).isEqualTo(dsA); - assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() - .getInstalledDistributionSet()).isEqualTo(dsA); + assertThat( + targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() + .getInstalledDistributionSet()).isEqualTo(dsA); assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus()) .isEqualTo(TargetUpdateStatus.IN_SYNC); assertThat(deploymentManagement.findActiveActionsByTarget(t)).hasSize(0); @@ -455,8 +571,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { // remove updActB from // activeActions, add a corresponding cancelAction and another // UpdateAction for dsA - final Iterable deployed2DS = deploymentManagement - .assignDistributionSet(dsA, deployResWithDsB.getDeployedTargets()).getAssignedTargets(); + final Iterable deployed2DS = deploymentManagement.assignDistributionSet(dsA, + deployResWithDsB.getDeployedTargets()).getAssignedTargets(); final Action updActA2 = actionRepository.findByDistributionSet(pageRequest, dsA).getContent().get(1); assertThat(deployed2DS).containsAll(deployResWithDsB.getDeployedTargets()); @@ -465,8 +581,9 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { for (final Target t_ : deployed2DS) { final Target t = targetManagement.findTargetByControllerID(t_.getControllerId()); assertThat(t.getAssignedDistributionSet()).isEqualTo(dsA); - assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() - .getInstalledDistributionSet()).isNull(); + assertThat( + targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo() + .getInstalledDistributionSet()).isNull(); assertThat(targetManagement.findTargetByControllerID(t.getControllerId()).getTargetInfo().getUpdateStatus()) .isEqualTo(TargetUpdateStatus.PENDING); @@ -523,8 +640,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { "blabla alles gut"); } // try to delete again - distributionSetManagement.deleteDistributionSet(deploymentResult.getDistributionSetIDs() - .toArray(new Long[deploymentResult.getDistributionSetIDs().size()])); + distributionSetManagement.deleteDistributionSet(deploymentResult.getDistributionSetIDs().toArray( + new Long[deploymentResult.getDistributionSetIDs().size()])); // verify that the result is the same, even though distributionSet dsA // has been installed // successfully and no activeAction is referring to created distribution @@ -559,8 +676,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { assertThat(targetManagement.countTargetsAll()).isNotZero(); assertThat(actionStatusRepository.count()).isNotZero(); - targetManagement - .deleteTargets(deploymentResult.getUndeployedTargetIDs().toArray(new Long[noOfUndeployedTargets])); + targetManagement.deleteTargets(deploymentResult.getUndeployedTargetIDs().toArray( + new Long[noOfUndeployedTargets])); targetManagement.deleteTargets(deploymentResult.getDeployedTargetIDs().toArray(new Long[noOfDeployedTargets])); assertThat(targetManagement.countTargetsAll()).isZero(); @@ -651,8 +768,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { targ = targs.iterator().next(); assertEquals(1, deploymentManagement.findActiveActionsByTarget(targ).size()); - assertEquals(TargetUpdateStatus.PENDING, - targetManagement.findTargetByControllerID(targ.getControllerId()).getTargetInfo().getUpdateStatus()); + assertEquals(TargetUpdateStatus.PENDING, targetManagement.findTargetByControllerID(targ.getControllerId()) + .getTargetInfo().getUpdateStatus()); assertEquals(dsB, targ.getAssignedDistributionSet()); assertEquals(dsA.getId(), targetManagement.findTargetByControllerIDWithDetails(targ.getControllerId()) .getTargetInfo().getInstalledDistributionSet().getId()); @@ -691,8 +808,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final DistributionSet ds = TestDataUtil.generateDistributionSet("a", softwareManagement, distributionSetManagement); // assign ds to create an action - final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement - .assignDistributionSet(ds.getId(), ActionType.SOFT, Action.NO_FORCE_TIME, target.getControllerId()); + final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement.assignDistributionSet( + ds.getId(), ActionType.SOFT, Action.NO_FORCE_TIME, target.getControllerId()); final Action action = assignDistributionSet.getActions().get(0); // verify preparation Action findAction = deploymentManagement.findAction(action.getId()); @@ -714,8 +831,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { final DistributionSet ds = TestDataUtil.generateDistributionSet("a", softwareManagement, distributionSetManagement); // assign ds to create an action - final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement - .assignDistributionSet(ds.getId(), ActionType.FORCED, Action.NO_FORCE_TIME, target.getControllerId()); + final DistributionSetAssignmentResult assignDistributionSet = deploymentManagement.assignDistributionSet( + ds.getId(), ActionType.FORCED, Action.NO_FORCE_TIME, target.getControllerId()); final Action action = assignDistributionSet.getActions().get(0); // verify perparation Action findAction = deploymentManagement.findAction(action.getId()); @@ -757,11 +874,11 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { private DeploymentResult prepareComplexRepo(final String undeployedTargetPrefix, final int noOfUndeployedTargets, final String deployedTargetPrefix, final int noOfDeployedTargets, final int noOfDistributionSets, final String distributionSetPrefix) { - final Iterable nakedTargets = targetManagement.createTargets( - TestDataUtil.buildTargetFixtures(noOfUndeployedTargets, undeployedTargetPrefix, "first description")); + final Iterable nakedTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures( + noOfUndeployedTargets, undeployedTargetPrefix, "first description")); - List deployedTargets = targetManagement.createTargets( - TestDataUtil.buildTargetFixtures(noOfDeployedTargets, deployedTargetPrefix, "first description")); + List deployedTargets = targetManagement.createTargets(TestDataUtil.buildTargetFixtures( + noOfDeployedTargets, deployedTargetPrefix, "first description")); // creating 10 DistributionSets final List dsList = TestDataUtil.generateDistributionSets(distributionSetPrefix, @@ -790,10 +907,10 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { found = true; final List activeActionsByTarget = deploymentManagement.findActiveActionsByTarget(myt); assertThat(activeActionsByTarget).isNotEmpty(); - assertThat(event.getActionId()).isEqualTo(activeActionsByTarget.get(0).getId()) - .as("Action id in database and event do not match"); - assertThat(event.getSoftwareModules()) - .containsOnly(ds.getModules().toArray(new SoftwareModule[ds.getModules().size()])); + assertThat(event.getActionId()).isEqualTo(activeActionsByTarget.get(0).getId()).as( + "Action id in database and event do not match"); + assertThat(event.getSoftwareModules()).containsOnly( + ds.getModules().toArray(new SoftwareModule[ds.getModules().size()])); } } assertThat(found).isTrue().as("No event found for controller " + myt.getControllerId()); @@ -819,14 +936,6 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { private final String deployedTargetPrefix; private final String distributionSetPrefix; - /** - * @param deployedTargetPrefix - * @param undeployedTargetPrefix - * @param distributionSetPrefix - * @param savedDeployedTargets - * @param savedNakedTargets - * @param distributionSets - */ public DeploymentResult(final Iterable deployedTs, final Iterable undeployedTs, final Iterable dss, final String deployedTargetPrefix, final String undeployedTargetPrefix, final String distributionSetPrefix) { @@ -969,8 +1078,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { latch.await(timeout, unit); final List handledEvents = new LinkedList( events); - assertThat(handledEvents).hasSize(expectedNumberOfEvents) - .as("Did not receive the expected amount of events (" + expectedNumberOfEvents + assertThat(handledEvents).hasSize(expectedNumberOfEvents).as( + "Did not receive the expected amount of events (" + expectedNumberOfEvents + ") within timeout. Received events are " + handledEvents); return handledEvents; } @@ -997,8 +1106,8 @@ public class DeploymentManagementTest extends AbstractIntegrationTest { throws InterruptedException { latch.await(timeout, unit); final List handledEvents = new LinkedList(events); - assertThat(handledEvents).hasSize(expectedNumberOfEvents) - .as("Did not receive the expected amount of events (" + expectedNumberOfEvents + assertThat(handledEvents).hasSize(expectedNumberOfEvents).as( + "Did not receive the expected amount of events (" + expectedNumberOfEvents + ") within timeout. Received events are " + handledEvents); return handledEvents; } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/ReportManagementTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementForDSTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementForDSTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SoftwareManagementTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SystemManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SystemManagementTest.java old mode 100755 new mode 100644 index 5d5368074..5e686cded --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SystemManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/SystemManagementTest.java @@ -10,43 +10,144 @@ package org.eclipse.hawkbit.repository; import static org.fest.assertions.api.Assertions.assertThat; -import java.util.concurrent.Callable; +import java.io.ByteArrayInputStream; +import java.util.List; +import java.util.Random; -import org.eclipse.hawkbit.AbstractIntegrationTest; +import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB; +import org.eclipse.hawkbit.TestDataUtil; import org.eclipse.hawkbit.WithSpringAuthorityRule; +import org.eclipse.hawkbit.report.model.TenantUsage; +import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.repository.model.SoftwareModule; +import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TenantConfiguration; import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey; import org.junit.Test; import org.springframework.core.convert.ConversionFailedException; import ru.yandex.qatools.allure.annotations.Description; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; -/** - * - * - * - */ -public class SystemManagementTest extends AbstractIntegrationTest { +@Features("Component Tests - Repository") +@Stories("System Management") +public class SystemManagementTest extends AbstractIntegrationTestWithMongoDB { @Test @Description("Ensures that findTenants returns all tenants and not only restricted to the tenant which currently is logged in") public void findTenantsReturnsAllTenantsNotOnlyWhichLoggedIn() throws Exception { - final String knownTenant1 = "knownTenant1"; - final String knownTenant2 = "knownTenant2"; - securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("bumlux", knownTenant1), new Callable() { - @Override - public Void call() throws Exception { - systemManagement.getTenantMetadata(knownTenant1); - return null; - } - }); + assertThat(systemManagement.findTenants()).hasSize(1); + + createTestTenantsForSystemStatistics(2, 0, 0, 0); + + assertThat(systemManagement.findTenants()).hasSize(3); + } + + @Test + @Description("Checks that the system report calculates correctly the artifact size of all tenants in the system. It ignores deleted software modules with their artifacts.") + public void systemUsageReportCollectsArtifactsOfAllTenants() throws Exception { + // Prepare tenants + createTestTenantsForSystemStatistics(2, 1234, 0, 0); + + // overall data + assertThat(systemManagement.getSystemUsageStatistics().getOverallArtifacts()).isEqualTo(2); + assertThat(systemManagement.getSystemUsageStatistics().getOverallArtifactVolumeInBytes()).isEqualTo(1234 * 2); + + // per tenant data + final List tenants = systemManagement.getSystemUsageStatistics().getTenants(); + assertThat(tenants).hasSize(3); + assertThat(tenants).containsOnly(new TenantUsage("default"), + new TenantUsage("tenant0").setArtifacts(1).setOverallArtifactVolumeInBytes(1234), + new TenantUsage("tenant1").setArtifacts(1).setOverallArtifactVolumeInBytes(1234)); + } + + @Test + @Description("Checks that the system report calculates correctly the targets size of all tenants in the system") + public void systemUsageReportCollectsTargetsOfAllTenants() throws Exception { + // Prepare tenants + createTestTenantsForSystemStatistics(2, 0, 100, 0); + + // overall data + assertThat(systemManagement.getSystemUsageStatistics().getOverallTargets()).isEqualTo(200); + assertThat(systemManagement.getSystemUsageStatistics().getOverallActions()).isEqualTo(0); + + // per tenant data + final List tenants = systemManagement.getSystemUsageStatistics().getTenants(); + assertThat(tenants).hasSize(3); + assertThat(tenants).containsOnly(new TenantUsage("default"), new TenantUsage("tenant0").setTargets(100), + new TenantUsage("tenant1").setTargets(100)); + } + + @Test + @Description("Checks that the system report calculates correctly the actions size of all tenants in the system") + public void systemUsageReportCollectsActionsOfAllTenants() throws Exception { + // Prepare tenants + createTestTenantsForSystemStatistics(2, 0, 100, 2); + + // 2 tenants, 100 targets each, 2 deployments per target => 400 + assertThat(systemManagement.getSystemUsageStatistics().getOverallActions()).isEqualTo(400); + + // per tenant data + final List tenants = systemManagement.getSystemUsageStatistics().getTenants(); + assertThat(tenants).hasSize(3); + assertThat(tenants).containsOnly(new TenantUsage("default"), + new TenantUsage("tenant0").setTargets(100).setActions(200), + new TenantUsage("tenant1").setTargets(100).setActions(200)); + } + + private byte[] createTestTenantsForSystemStatistics(final int tenants, final int artifactSize, final int targets, final int updates) + throws Exception { + final Random randomgen = new Random(); + final byte random[] = new byte[artifactSize]; + randomgen.nextBytes(random); + + for (int i = 0; i < tenants; i++) { + final String tenantname = "tenant" + i; + securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("bumlux", tenantname), () -> { + systemManagement.getTenantMetadata(tenantname); + if (artifactSize > 0) { + createTestArtifact(random); + createDeletedTestArtifact(random); + } + if (targets > 0) { + final List createdTargets = createTestTargets(targets); + if (updates > 0) { + for (int x = 0; x < updates; x++) { + final DistributionSet ds = TestDataUtil.generateDistributionSet("to be deployed" + x, + softwareManagement, distributionSetManagement, true); + + deploymentManagement.assignDistributionSet(ds, createdTargets); + } + } + } - securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("bumlux", knownTenant2), new Callable() { - @Override - public Void call() throws Exception { - systemManagement.getTenantMetadata(knownTenant2); return null; - } + }); + } + + return random; + } + + private List createTestTargets(final int targets) { + return targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(targets, "testTargetOfTenant", "testTargetOfTenant")); + } + + private void createTestArtifact(final byte[] random) { + SoftwareModule sm = new SoftwareModule(softwareManagement.findSoftwareModuleTypeByKey("os"), "name 1", + "version 1", null, null); + sm = softwareModuleRepository.save(sm); + + artifactManagement.createLocalArtifact(new ByteArrayInputStream(random), sm.getId(), "file1", false); + } + + private void createDeletedTestArtifact(final byte[] random) { + final DistributionSet ds = TestDataUtil.generateDistributionSet("deleted garbage", softwareManagement, + distributionSetManagement, true); + ds.getModules().stream().forEach(module -> { + artifactManagement.createLocalArtifact(new ByteArrayInputStream(random), module.getId(), "file1", false); + softwareManagement.deleteSoftwareModule(module); }); } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java old mode 100755 new mode 100644 index 6f938056d..fdc7d9ea2 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TagManagementTest.java @@ -25,12 +25,12 @@ import org.eclipse.hawkbit.repository.model.TargetTag; import org.junit.Test; import org.slf4j.LoggerFactory; -import com.google.common.collect.Lists; - import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; +import com.google.common.collect.Lists; + /** * Test class for {@link TagManagement}. * @@ -90,34 +90,32 @@ public class TagManagementTest extends AbstractIntegrationTest { DistributionSetFilterBuilder distributionSetFilterBuilder; // search for not deleted - distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true) - .setTagNames(Lists.newArrayList(tagA.getName())); - assertEquals( - dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown() - + dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), + distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setTagNames( + Lists.newArrayList(tagA.getName())); + assertEquals(dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown() + + dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) .getTotalElements()); - distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true) - .setTagNames(Lists.newArrayList(tagB.getName())); - assertEquals( - dsBs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown() - + dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), + distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setTagNames( + Lists.newArrayList(tagB.getName())); + assertEquals(dsBs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown() + + dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) .getTotalElements()); - distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true) - .setTagNames(Lists.newArrayList(tagC.getName())); - assertEquals( - dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown() - + dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), + distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setTagNames( + Lists.newArrayList(tagC.getName())); + assertEquals(dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown() + + dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) .getTotalElements()); - distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true) - .setTagNames(Lists.newArrayList(tagX.getName())); - assertEquals(0, distributionSetManagement - .findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getTotalElements()); + distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(true).setTagNames( + Lists.newArrayList(tagX.getName())); + assertEquals(0, + distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) + .getTotalElements()); assertEquals(5, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown()); @@ -129,24 +127,23 @@ public class TagManagementTest extends AbstractIntegrationTest { tagManagement.deleteDistributionSetTag(tagB.getName()); assertEquals(2, distributionSetTagRepository.findAll().spliterator().getExactSizeIfKnown()); - distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE) - .setTagNames(Lists.newArrayList(tagA.getName())); - assertEquals( - dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown() - + dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), + distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setTagNames( + Lists.newArrayList(tagA.getName())); + assertEquals(dsAs.spliterator().getExactSizeIfKnown() + dsABs.spliterator().getExactSizeIfKnown() + + dsACs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) .getTotalElements()); - distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE) - .setTagNames(Lists.newArrayList(tagB.getName())); - assertEquals(0, distributionSetManagement - .findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()).getTotalElements()); + distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setTagNames( + Lists.newArrayList(tagB.getName())); + assertEquals(0, + distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) + .getTotalElements()); - distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE) - .setTagNames(Lists.newArrayList(tagC.getName())); - assertEquals( - dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown() - + dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), + distributionSetFilterBuilder = getDistributionSetFilterBuilder().setIsComplete(Boolean.TRUE).setTagNames( + Lists.newArrayList(tagC.getName())); + assertEquals(dsCs.spliterator().getExactSizeIfKnown() + dsACs.spliterator().getExactSizeIfKnown() + + dsBCs.spliterator().getExactSizeIfKnown() + dsABCs.spliterator().getExactSizeIfKnown(), distributionSetManagement.findDistributionSetsByFilters(pageReq, distributionSetFilterBuilder.build()) .getTotalElements()); } @@ -209,8 +206,8 @@ public class TagManagementTest extends AbstractIntegrationTest { // check for (final Target target : targetRepository.findAll()) { - assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getTags()) - .doesNotContain(toDelete); + assertThat(targetManagement.findTargetByControllerID(target.getControllerId()).getTags()).doesNotContain( + toDelete); } assertThat(targetTagRepository.findOne(toDelete.getId())).isNull(); assertThat(tagManagement.findAllTargetTags()).hasSize(19); @@ -281,8 +278,8 @@ public class TagManagementTest extends AbstractIntegrationTest { final DistributionSetTag toDelete = tags.iterator().next(); for (final DistributionSet set : distributionSetRepository.findAll()) { - assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags()) - .contains(toDelete); + assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags()).contains( + toDelete); } // delete @@ -290,7 +287,7 @@ public class TagManagementTest extends AbstractIntegrationTest { // check assertThat(distributionSetTagRepository.findOne(toDelete.getId())).isNull(); - assertThat(tagManagement.findDistributionSetTagsAll()).hasSize(19); + assertThat(tagManagement.findAllDistributionSetTags()).hasSize(19); for (final DistributionSet set : distributionSetRepository.findAll()) { assertThat(distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()).getTags()) .doesNotContain(toDelete); @@ -329,13 +326,13 @@ public class TagManagementTest extends AbstractIntegrationTest { tagManagement.updateDistributionSetTag(savedAssigned); // check data - assertThat(tagManagement.findDistributionSetTagsAll()).hasSize(tags.size()); + assertThat(tagManagement.findAllDistributionSetTags()).hasSize(tags.size()); assertThat(distributionSetTagRepository.findOne(savedAssigned.getId()).getName()).isEqualTo("test123"); } /** * Test method for - * {@link org.eclipse.hawkbit.repository.TagManagement#findDistributionSetTagsAll()} + * {@link org.eclipse.hawkbit.repository.TagManagement#findAllDistributionSetTags()} * . */ @Test @@ -345,7 +342,7 @@ public class TagManagementTest extends AbstractIntegrationTest { final List tags = createDsSetsWithTags(); // test - assertThat(tagManagement.findDistributionSetTagsAll()).hasSize(tags.size()); + assertThat(tagManagement.findAllDistributionSetTags()).hasSize(tags.size()); assertThat(distributionSetTagRepository.findAll()).hasSize(20); } @@ -362,11 +359,11 @@ public class TagManagementTest extends AbstractIntegrationTest { final List sets = TestDataUtil.generateDistributionSets(20, softwareManagement, distributionSetManagement); - final Iterable tags = tagManagement - .createDistributionSetTags(TestDataUtil.generateDistributionSetTags(20)); + final Iterable tags = tagManagement.createDistributionSetTags(TestDataUtil + .generateDistributionSetTags(20)); tags.forEach(tag -> distributionSetManagement.toggleTagAssignment(sets, tag)); - return tagManagement.findDistributionSetTagsAll(); + return tagManagement.findAllDistributionSetTags(); } } diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagenmentTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetFilterQueryManagenmentTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementSearchTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementSearchTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java old mode 100755 new mode 100644 index 4bc6d6f1a..8f88b3216 --- a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java +++ b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/TargetManagementTest.java @@ -65,6 +65,40 @@ public class TargetManagementTest extends AbstractIntegrationTest { } } + @Test + @Description("Ensures that targets can assigned and unassigned to a target tag. Not exists target will be ignored for the assignment.") + public void assignAndUnassignTargetsToTag() { + final List assignTarget = new ArrayList(); + assignTarget.add(targetManagement.createTarget(new Target("targetId123")).getControllerId()); + assignTarget.add(targetManagement.createTarget(new Target("targetId1234")).getControllerId()); + assignTarget.add(targetManagement.createTarget(new Target("targetId1235")).getControllerId()); + assignTarget.add(targetManagement.createTarget(new Target("targetId1236")).getControllerId()); + assignTarget.add("NotExist"); + + final TargetTag targetTag = tagManagement.createTargetTag(new TargetTag("Tag1")); + + final List assignedTargets = targetManagement.assignTag(assignTarget, targetTag); + assertThat(assignedTargets.size()).isEqualTo(4); + assignedTargets.forEach(target -> assertThat(target.getTags().size()).isEqualTo(1)); + + TargetTag findTargetTag = tagManagement.findTargetTag("Tag1"); + assertThat(assignedTargets.size()).isEqualTo(findTargetTag.getAssignedToTargets().size()); + + assertThat(targetManagement.unAssignTag("NotExist", findTargetTag)).isNull(); + + final Target unAssignTarget = targetManagement.unAssignTag("targetId123", findTargetTag); + assertThat(unAssignTarget.getControllerId()).isEqualTo("targetId123"); + assertThat(unAssignTarget.getTags().size()).isEqualTo(0); + findTargetTag = tagManagement.findTargetTag("Tag1"); + assertThat(findTargetTag.getAssignedToTargets().size()).isEqualTo(3); + + final List unAssignTargets = targetManagement.unAssignAllTargetsByTag(findTargetTag); + findTargetTag = tagManagement.findTargetTag("Tag1"); + assertThat(findTargetTag.getAssignedToTargets().size()).isEqualTo(0); + assertThat(unAssignTargets.size()).isEqualTo(3); + unAssignTargets.forEach(target -> assertThat(target.getTags().size()).isEqualTo(0)); + } + @Test @Description("Ensures that targets can deleted e.g. test all cascades") public void deleteAndCreateTargets() { diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/utils/RepositoryDataGenerator.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/repository/utils/RepositoryDataGenerator.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java b/hawkbit-repository/src/test/java/org/eclipse/hawkbit/tenancy/MultiTenancyEntityTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-repository/src/test/resources/application-test.properties b/hawkbit-repository/src/test/resources/application-test.properties old mode 100755 new mode 100644 index 129f2e3e2..e5fb04a21 --- a/hawkbit-repository/src/test/resources/application-test.properties +++ b/hawkbit-repository/src/test/resources/application-test.properties @@ -19,15 +19,16 @@ hawkbit.server.security.dos.maxStatusEntriesPerAction=100 hawkbit.server.security.dos.maxAttributeEntriesPerTarget=10 spring.jpa.database=H2 -flyway.enabled=true -flyway.initOnMigrate=true -flyway.sqlMigrationSuffix=${spring.jpa.database}.sql - spring.datasource.url=jdbc:h2:mem:sp-db;DB_CLOSE_ON_EXIT=FALSE spring.datasource.driverClassName=org.h2.Driver spring.datasource.username=sa spring.datasource.password=sa +flyway.enabled=true +flyway.initOnMigrate=true +flyway.sqlMigrationSuffix=${spring.jpa.database}.sql +#spring.jpa.show-sql=true + # SP Controller configuration hawkbit.controller.pollingTime=00:01:00 hawkbit.controller.pollingOverdueTime=00:01:00 diff --git a/hawkbit-rest-api/pom.xml b/hawkbit-rest-api/pom.xml old mode 100755 new mode 100644 index f93f5aa1f..f1a63ac2f --- a/hawkbit-rest-api/pom.xml +++ b/hawkbit-rest-api/pom.xml @@ -34,9 +34,5 @@ com.fasterxml.jackson.core jackson-annotations - - io.swagger - swagger-annotations - \ No newline at end of file diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/RestConstants.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/RestConstants.java old mode 100755 new mode 100644 similarity index 89% rename from hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/RestConstants.java rename to hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/RestConstants.java index d026a0883..33b154844 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/RestConstants.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/RestConstants.java @@ -121,6 +121,26 @@ public final class RestConstants { */ public static final String SOFTWAREMODULE_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/softwaremodules"; + /** + * The tag URL mapping rest resource. + */ + public static final String TARGET_TAG_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + "/targettags"; + /** + * The tag URL mapping rest resource. + */ + public static final String TARGET_TAG_TAGERTS_REQUEST_MAPPING = "/{targetTagId}/targets"; + + /** + * The tag URL mapping rest resource. + */ + public static final String DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING = BASE_V1_REQUEST_MAPPING + + "/distributionsettags"; + + /** + * The tag URL mapping rest resource. + */ + public static final String DISTRIBUTIONSET_REQUEST_MAPPING = "/{distributionsetTagId}/distributionsets"; + /** * The software module type URL mapping rest resource. */ diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/BaseEntityRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/BaseEntityRest.java old mode 100755 new mode 100644 index 21d05cb2e..6d80a407c --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/BaseEntityRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/BaseEntityRest.java @@ -8,36 +8,26 @@ */ package org.eclipse.hawkbit.rest.resource.model; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import org.springframework.hateoas.ResourceSupport; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; - /** * A json annotated rest model for BaseEntity to RESTful API representation. * - * - * - * */ public abstract class BaseEntityRest extends ResourceSupport { - @ApiModelProperty(value = ApiModelProperties.CREATED_BY) @JsonProperty private String createdBy; - @ApiModelProperty(value = ApiModelProperties.CREATED_AT) @JsonProperty private Long createdAt; - @ApiModelProperty(value = ApiModelProperties.LAST_MODIFIED_BY) @JsonProperty private String lastModifiedBy; - @ApiModelProperty(value = ApiModelProperties.LAST_MODIFIED_AT) @JsonProperty private Long lastModifiedAt; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfo.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfo.java old mode 100755 new mode 100644 index 6543c4259..e2d808943 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfo.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfo.java @@ -13,27 +13,17 @@ import java.util.List; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * A exception model rest representation with JSON annotations for response * bodies in case of RESTful exception occurrence. - * - * * */ @JsonInclude(Include.NON_EMPTY) -@ApiModel(value = "ExceptionInfo") public class ExceptionInfo { - @ApiModelProperty(required = true, value = "The exception class name") private String exceptionClass; - @ApiModelProperty(required = true, value = "The exception error code") private String errorCode; - @ApiModelProperty(required = false, value = "The exception human readable message") private String message; - @ApiModelProperty(required = false, value = "The exception message parameters") private List parameters; /** diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/IdRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/IdRest.java old mode 100755 new mode 100644 index efc33feb1..d15114d4e --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/IdRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/IdRest.java @@ -8,26 +8,18 @@ */ package org.eclipse.hawkbit.rest.resource.model; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; - /** * A generic abstract rest model which contains only a ID for use-case e.g. * which allows only posting or putting an ID into the request body, e.g. for * assignments. - * - * - * * */ @JsonIgnoreProperties(ignoreUnknown = true) public class IdRest { - @ApiModelProperty(value = ApiModelProperties.ITEM_ID) @JsonProperty private Long id; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/MetadataRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/MetadataRest.java old mode 100755 new mode 100644 index 4ddabd1aa..a5c24c4a9 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/MetadataRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/MetadataRest.java @@ -8,32 +8,21 @@ */ package org.eclipse.hawkbit.rest.resource.model; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * The representation of an meta data in the REST API. - * - * - * * */ -@ApiModel(ApiModelProperties.META_DATA) @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) public class MetadataRest { - @ApiModelProperty(required = true, value = "The key of the meta data") @JsonProperty(required = true) private String key; - @ApiModelProperty(required = false, value = "The value of the meta data") @JsonProperty private String value; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/MetadataRestPageList.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/MetadataRestPageList.java old mode 100755 new mode 100644 index 3d363ad81..0d375c582 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/MetadataRestPageList.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/MetadataRestPageList.java @@ -10,18 +10,12 @@ package org.eclipse.hawkbit.rest.resource.model; import java.util.List; -import io.swagger.annotations.ApiModelProperty; - /** * The rest model for a paged meta data list. - * - * - * * */ public class MetadataRestPageList extends PagedList { - @ApiModelProperty(value = "a list of meta data", required = true) private final List content; /** diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/NamedEntityRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/NamedEntityRest.java old mode 100755 new mode 100644 index fb02ba1f2..d82d14f75 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/NamedEntityRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/NamedEntityRest.java @@ -8,26 +8,17 @@ */ package org.eclipse.hawkbit.rest.resource.model; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; - /** * A json annotated rest model for NamedEntity to RESTful API representation. * - * - * - * */ public abstract class NamedEntityRest extends BaseEntityRest { - @ApiModelProperty(value = ApiModelProperties.NAME, required = true) @JsonProperty(required = true) private String name; - @ApiModelProperty(value = ApiModelProperties.DESCRPTION) @JsonProperty private String description; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PagedList.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PagedList.java old mode 100755 new mode 100644 index 3356d3a31..082015b5c --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PagedList.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PagedList.java @@ -12,15 +12,12 @@ import java.util.List; import javax.validation.constraints.NotNull; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import org.springframework.hateoas.ResourceSupport; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; -import io.swagger.annotations.ApiModelProperty; - /** * A list representation with meta data for pagination, e.g. containing the * total elements. The content of the acutal list is stored in the @@ -36,16 +33,13 @@ import io.swagger.annotations.ApiModelProperty; @JsonInclude(Include.NON_NULL) public class PagedList extends ResourceSupport { - @ApiModelProperty(value = ApiModelProperties.TOTAL_ELEMENTS, required = false) private final long totalElements; - - @ApiModelProperty(value = ApiModelProperties.SIZE, required = true) private final int size; /** * creates a new paged list with the given {@code content} and {@code total} * . - * + * * @param content * the actual content of the list * @param total diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PollStatusRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PollStatusRest.java old mode 100755 new mode 100644 index c64cf708f..d66d02512 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PollStatusRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/PollStatusRest.java @@ -8,37 +8,28 @@ */ package org.eclipse.hawkbit.rest.resource.model; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * A json annotated rest model for PollStatus to RESTful API representation. - * + * * * * */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("Target Poll Status") public class PollStatusRest { - @ApiModelProperty(value = ApiModelProperties.POLL_LAST_REQUEST_AT) @JsonProperty private Long lastRequestAt; - @ApiModelProperty(value = ApiModelProperties.POLL_NEXT_EXPECTED_REQUEST_AT) @JsonProperty private Long nextExpectedRequestAt; - @ApiModelProperty(value = ApiModelProperties.POLL_OVERDUE) @JsonProperty private boolean overdue; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionPagedList.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionPagedList.java old mode 100755 new mode 100644 index aedd2938f..f8908277f --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionPagedList.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionPagedList.java @@ -12,22 +12,13 @@ import java.util.Collections; import java.util.List; import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; /** * Paged list rest model for {@link Action} to RESTful API representation. * - * - * - * */ -@ApiModel("Paged list of actions") public class ActionPagedList extends PagedList { - @ApiModelProperty(value = ApiModelProperties.ACTION_LIST) private final List content; /** diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionRest.java old mode 100755 new mode 100644 index e8b5bd299..3bd57ab20 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionRest.java @@ -9,16 +9,12 @@ package org.eclipse.hawkbit.rest.resource.model.action; import org.eclipse.hawkbit.rest.resource.model.BaseEntityRest; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * A json annotated rest model for Action to RESTful API representation. * @@ -28,7 +24,6 @@ import io.swagger.annotations.ApiModelProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("SP Action") public class ActionRest extends BaseEntityRest { /** @@ -45,16 +40,12 @@ public class ActionRest extends BaseEntityRest { public static final String ACTION_PENDING = "pending"; - @ApiModelProperty(value = ApiModelProperties.ITEM_ID) @JsonProperty("id") private Long actionId; - @ApiModelProperty(value = ApiModelProperties.ACTION_TYPE, allowableValues = ACTION_UPDATE + "," + ACTION_CANCEL) @JsonProperty private String type; - @ApiModelProperty(value = ApiModelProperties.ACTION_EXECUTION_STATUS, allowableValues = ACTION_FINISHED + "," - + ACTION_PENDING) @JsonProperty private String status; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionStatusPagedList.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionStatusPagedList.java old mode 100755 new mode 100644 index 2595cd536..d9f19b98e --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionStatusPagedList.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionStatusPagedList.java @@ -12,13 +12,9 @@ import java.util.Collections; import java.util.List; import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Paged list rest model for ActionStatus to RESTful API representation. * @@ -27,10 +23,8 @@ import io.swagger.annotations.ApiModelProperty; * */ @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("Paged list of action status") public class ActionStatusPagedList extends PagedList { - @ApiModelProperty(value = ApiModelProperties.ACTION_STATUS_LIST) private final List content; /** diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionStatusRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionStatusRest.java old mode 100755 new mode 100644 index b66cb666d..1f08afe49 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionStatusRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionStatusRest.java @@ -10,16 +10,11 @@ package org.eclipse.hawkbit.rest.resource.model.action; import java.util.List; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * A json annotated rest model for ActionStatus to RESTful API representation. * @@ -29,7 +24,6 @@ import io.swagger.annotations.ApiModelProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("SP Action Status") public class ActionStatusRest { /** @@ -61,20 +55,20 @@ public class ActionStatusRest { */ public static final String AS_RETRIEVED = "retrieved"; - @ApiModelProperty(value = ApiModelProperties.ITEM_ID) + /** + * Action has been canceled for this target. + */ + public static final String AS_CANCELING = "canceling"; + @JsonProperty("id") private Long statusId; - @ApiModelProperty(value = ApiModelProperties.ACTION_STATUS_TYPE, required = true, allowableValues = AS_FINISHED - + "," + AS_ERROR + "," + AS_WARNING + "," + AS_RUNNING + "," + AS_CANCELED + "," + AS_RETRIEVED) @JsonProperty private String type; - @ApiModelProperty(value = ApiModelProperties.ACTION_STATUS_MESSAGES) @JsonProperty private List messages; - @ApiModelProperty(value = ApiModelProperties.ACTION_STATUS_REPORTED_AT) @JsonProperty private Long reportedAt; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionStatussRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionStatussRest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionsRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/action/ActionsRest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactHash.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactHash.java old mode 100755 new mode 100644 index 5d203b8c2..58b81d8fd --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactHash.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactHash.java @@ -8,28 +8,18 @@ */ package org.eclipse.hawkbit.rest.resource.model.artifact; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Hashes for given Artifact. * * - * - * */ -@ApiModel(ApiModelProperties.ARTIFACT_HASHES) public class ArtifactHash { - @ApiModelProperty(value = ApiModelProperties.ARTIFACT_HASHES_SHA1) @JsonProperty private String sha1; - @ApiModelProperty(value = ApiModelProperties.ARTIFACT_HASHES_MD5) @JsonProperty private String md5; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactRest.java old mode 100755 new mode 100644 index adf614aa8..f32a32ed8 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactRest.java @@ -9,7 +9,6 @@ package org.eclipse.hawkbit.rest.resource.model.artifact; import org.eclipse.hawkbit.rest.resource.model.BaseEntityRest; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -18,36 +17,24 @@ import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * A json annotated rest model for Artifact to RESTful API representation. - * - * - * - * */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("Software Artifact") public class ArtifactRest extends BaseEntityRest { @JsonProperty(required = true) private ArtifactType type; - @ApiModelProperty(value = ApiModelProperties.ITEM_ID, required = true) @JsonProperty("id") private Long artifactId; - @ApiModelProperty(value = ApiModelProperties.ARTIFACT_HASHES) @JsonProperty private ArtifactHash hashes; - @ApiModelProperty(value = ApiModelProperties.ARTIFACT_PROVIDED_FILENAME) @JsonProperty private String providedFilename; - @ApiModelProperty(value = ApiModelProperties.ARTIFACT_SIZE) @JsonProperty private Long size; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactsRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactsRest.java old mode 100755 new mode 100644 index 32f4ca531..172e4d315 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactsRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/artifact/ArtifactsRest.java @@ -16,16 +16,10 @@ import java.util.ListIterator; import org.springframework.hateoas.ResourceSupport; -import io.swagger.annotations.ApiModel; - /** * List representation of the {@link ArtifactRest}. * - * - * - * */ -@ApiModel public class ArtifactsRest extends ResourceSupport implements List { private final List delegate = new ArrayList<>(); diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/ActionTypeRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/ActionTypeRest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetPagedList.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetPagedList.java old mode 100755 new mode 100644 index b631e4500..b7ad1eddb --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetPagedList.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetPagedList.java @@ -11,22 +11,13 @@ package org.eclipse.hawkbit.rest.resource.model.distributionset; import java.util.List; import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; /** * Paged list for SoftwareModule. * - * - * - * */ -@ApiModel("Paged list of distribution sets") public class DistributionSetPagedList extends PagedList { - @ApiModelProperty(value = ApiModelProperties.SM_LIST, required = true) private final List content; /** diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyCreate.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyPost.java old mode 100755 new mode 100644 similarity index 74% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyCreate.java rename to hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyPost.java index 896a3275b..bf5470d72 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyCreate.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyPost.java @@ -10,7 +10,6 @@ package org.eclipse.hawkbit.rest.resource.model.distributionset; import java.util.List; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleAssigmentRest; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -18,45 +17,32 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * A json annotated rest model for DistributionSet for POST. * - * - * - * */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("Distribution set") -public class DistributionSetRequestBodyCreate extends DistributionSetRequestBodyUpdate { +public class DistributionSetRequestBodyPost extends DistributionSetRequestBodyPut { // deprecated format from the time where os, application and runtime where // statically defined - @ApiModelProperty(hidden = true) @JsonProperty private SoftwareModuleAssigmentRest os; - @ApiModelProperty(hidden = true) @JsonProperty private SoftwareModuleAssigmentRest runtime; - @ApiModelProperty(hidden = true) @JsonProperty private SoftwareModuleAssigmentRest application; // deprecated format - END - @ApiModelProperty(value = ApiModelProperties.DS_MODULES) @JsonProperty private List modules; - @ApiModelProperty(value = ApiModelProperties.DS_REQUIRED_STEP) @JsonProperty private boolean requiredMigrationStep; - @ApiModelProperty(value = ApiModelProperties.DS_TYPE) @JsonProperty private String type; @@ -70,9 +56,12 @@ public class DistributionSetRequestBodyCreate extends DistributionSetRequestBody /** * @param os * the os to set + * + * @return updated body */ - public void setOs(final SoftwareModuleAssigmentRest os) { + public DistributionSetRequestBodyPost setOs(final SoftwareModuleAssigmentRest os) { this.os = os; + return this; } /** @@ -85,9 +74,13 @@ public class DistributionSetRequestBodyCreate extends DistributionSetRequestBody /** * @param runtime * the runtime to set + * + * @return updated body */ - public void setRuntime(final SoftwareModuleAssigmentRest runtime) { + public DistributionSetRequestBodyPost setRuntime(final SoftwareModuleAssigmentRest runtime) { this.runtime = runtime; + + return this; } /** @@ -100,9 +93,13 @@ public class DistributionSetRequestBodyCreate extends DistributionSetRequestBody /** * @param application * the application to set + * + * @return updated body */ - public void setApplication(final SoftwareModuleAssigmentRest application) { + public DistributionSetRequestBodyPost setApplication(final SoftwareModuleAssigmentRest application) { this.application = application; + + return this; } /** @@ -115,9 +112,13 @@ public class DistributionSetRequestBodyCreate extends DistributionSetRequestBody /** * @param requiredMigrationStep * the requiredMigrationStep to set + * + * @return updated body */ - public void setRequiredMigrationStep(final boolean requiredMigrationStep) { + public DistributionSetRequestBodyPost setRequiredMigrationStep(final boolean requiredMigrationStep) { this.requiredMigrationStep = requiredMigrationStep; + + return this; } /** @@ -130,9 +131,13 @@ public class DistributionSetRequestBodyCreate extends DistributionSetRequestBody /** * @param modules * the modules to set + * + * @return updated body */ - public void setModules(final List modules) { + public DistributionSetRequestBodyPost setModules(final List modules) { this.modules = modules; + + return this; } /** @@ -145,9 +150,13 @@ public class DistributionSetRequestBodyCreate extends DistributionSetRequestBody /** * @param type * the type to set + * + * @return updated body */ - public void setType(final String type) { + public DistributionSetRequestBodyPost setType(final String type) { this.type = type; + + return this; } } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyUpdate.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyPut.java old mode 100755 new mode 100644 similarity index 71% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyUpdate.java rename to hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyPut.java index e93533a52..2f19625f3 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyUpdate.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRequestBodyPut.java @@ -8,37 +8,25 @@ */ package org.eclipse.hawkbit.rest.resource.model.distributionset; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * A json annotated rest model for DistributionSet for PUT/POST. * - * - * - * */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("Distribution set") -public class DistributionSetRequestBodyUpdate { +public class DistributionSetRequestBodyPut { - @ApiModelProperty(value = ApiModelProperties.NAME, required = true) - @JsonProperty(required = true) + @JsonProperty private String name; - @ApiModelProperty(value = ApiModelProperties.DESCRPTION) @JsonProperty private String description; - @ApiModelProperty(value = ApiModelProperties.VERSION) @JsonProperty private String version; @@ -52,9 +40,12 @@ public class DistributionSetRequestBodyUpdate { /** * @param name * the name to set + * + * @return updated body */ - public void setName(final String name) { + public DistributionSetRequestBodyPut setName(final String name) { this.name = name; + return this; } /** @@ -67,9 +58,13 @@ public class DistributionSetRequestBodyUpdate { /** * @param description * the description to set + * + * @return updated body */ - public void setDescription(final String description) { + public DistributionSetRequestBodyPut setDescription(final String description) { this.description = description; + + return this; } /** @@ -82,8 +77,12 @@ public class DistributionSetRequestBodyUpdate { /** * @param version * the version to set + * + * @return updated body */ - public void setVersion(final String version) { + public DistributionSetRequestBodyPut setVersion(final String version) { this.version = version; + + return this; } } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRest.java old mode 100755 new mode 100644 index 6c5e432df..2ff764eba --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetRest.java @@ -12,7 +12,6 @@ import java.util.ArrayList; import java.util.List; import org.eclipse.hawkbit.rest.resource.model.NamedEntityRest; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRest; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -21,9 +20,6 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * A json annotated rest model for DistributionSet to RESTful API * representation. @@ -34,30 +30,23 @@ import io.swagger.annotations.ApiModelProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("Distribution set") public class DistributionSetRest extends NamedEntityRest { - @ApiModelProperty(value = ApiModelProperties.ITEM_ID) @JsonProperty(value = "id", required = true) private Long dsId; - @ApiModelProperty(value = ApiModelProperties.VERSION) @JsonProperty private String version; - @ApiModelProperty(value = ApiModelProperties.DS_MODULES) @JsonProperty - private List modules = new ArrayList(); + private List modules = new ArrayList<>(); - @ApiModelProperty(value = ApiModelProperties.DS_REQUIRED_STEP) @JsonProperty private boolean requiredMigrationStep; - @ApiModelProperty(value = ApiModelProperties.DS_TYPE) @JsonProperty private String type; - @ApiModelProperty(value = ApiModelProperties.DS_COMPLETE) @JsonProperty private Boolean complete; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetsRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/DistributionSetsRest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/TargetAssignmentRequestBody.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/TargetAssignmentRequestBody.java old mode 100755 new mode 100644 index 2e0fdefdd..5135a977c --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/TargetAssignmentRequestBody.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/TargetAssignmentRequestBody.java @@ -8,33 +8,21 @@ */ package org.eclipse.hawkbit.rest.resource.model.distributionset; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Request Body of Target for assignment operations (ID only). - * - * - * * */ -@ApiModel("Target ID") @JsonIgnoreProperties(ignoreUnknown = true) public class TargetAssignmentRequestBody { - @ApiModelProperty(value = ApiModelProperties.ITEM_ID) @JsonProperty private String id; - @ApiModelProperty(value = "The force time in case type is 'timeforced'", required = false) private long forcetime; - @ApiModelProperty(value = "The type of action to assign, default 'forced'", required = false, allowableValues = "soft,forced,timeforced") private ActionTypeRest type; /** diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/TargetAssignmentResponseBody.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/TargetAssignmentResponseBody.java old mode 100755 new mode 100644 index 8b846fe83..77676f844 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/TargetAssignmentResponseBody.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionset/TargetAssignmentResponseBody.java @@ -12,25 +12,18 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Response Body of Target for assignment operations. - * + * * * */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("Target Assignment Response") public class TargetAssignmentResponseBody { - @ApiModelProperty(value = "The number of targets have been assigned") private int assigned; - @ApiModelProperty(value = "The number of targets which already have been the assignment") private int alreadyAssigned; - @ApiModelProperty(value = "The total number of targets") private int total; /** diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypePagedList.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypePagedList.java old mode 100755 new mode 100644 index a11b6627f..57b15f5e8 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypePagedList.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypePagedList.java @@ -11,22 +11,14 @@ package org.eclipse.hawkbit.rest.resource.model.distributionsettype; import java.util.List; import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; /** * Paged list for DistributionSetType. * * - * - * */ -@ApiModel("Paged list of distribution set types") public class DistributionSetTypePagedList extends PagedList { - @ApiModelProperty(value = ApiModelProperties.DS_TYPE_LIST, required = true) private final List content; /** diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyCreate.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyPost.java old mode 100755 new mode 100644 similarity index 66% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyCreate.java rename to hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyPost.java index 493e6c1f7..ba0f548f6 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyCreate.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyPost.java @@ -10,39 +10,28 @@ package org.eclipse.hawkbit.rest.resource.model.distributionsettype; import java.util.List; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeAssigmentRest; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; - /** * Request Body for DistributionSetType POST. * - * - * - * */ -public class DistributionSetTypeRequestBodyCreate { +public class DistributionSetTypeRequestBodyPost { - @ApiModelProperty(value = ApiModelProperties.NAME, required = true) @JsonProperty(required = true) private String name; - @ApiModelProperty(value = ApiModelProperties.DESCRPTION) @JsonProperty private String description; - @ApiModelProperty(value = ApiModelProperties.DS_TYPE_KEY) @JsonProperty private String key; - @ApiModelProperty(value = ApiModelProperties.DS_TYPE_MANDATORY_MODULES) @JsonProperty private List mandatorymodules; - @ApiModelProperty(value = ApiModelProperties.DS_TYPE_OPTIONAL_MODULES) @JsonProperty private List optionalmodules; @@ -56,9 +45,12 @@ public class DistributionSetTypeRequestBodyCreate { /** * @param name * the name to set + * + * @return updated body */ - public void setName(final String name) { + public DistributionSetTypeRequestBodyPost setName(final String name) { this.name = name; + return this; } /** @@ -71,9 +63,12 @@ public class DistributionSetTypeRequestBodyCreate { /** * @param description * the description to set + * + * @return updated body */ - public void setDescription(final String description) { + public DistributionSetTypeRequestBodyPost setDescription(final String description) { this.description = description; + return this; } /** @@ -86,13 +81,16 @@ public class DistributionSetTypeRequestBodyCreate { /** * @param key * the key to set + * + * @return updated body */ - public void setKey(final String key) { + public DistributionSetTypeRequestBodyPost setKey(final String key) { this.key = key; + return this; } /** - * @return the mandatorymodules + * @return the mandatory modules */ public List getMandatorymodules() { return mandatorymodules; @@ -100,14 +98,18 @@ public class DistributionSetTypeRequestBodyCreate { /** * @param mandatorymodules - * the mandatorymodules to set + * the mandatory modules to set + * + * @return updated body */ - public void setMandatorymodules(final List mandatorymodules) { + public DistributionSetTypeRequestBodyPost setMandatorymodules( + final List mandatorymodules) { this.mandatorymodules = mandatorymodules; + return this; } /** - * @return the optionalmodules + * @return the optional modules */ public List getOptionalmodules() { return optionalmodules; @@ -115,10 +117,14 @@ public class DistributionSetTypeRequestBodyCreate { /** * @param optionalmodules - * the optionalmodules to set + * the optional modules to set + * + * @return updated body */ - public void setOptionalmodules(final List optionalmodules) { + public DistributionSetTypeRequestBodyPost setOptionalmodules( + final List optionalmodules) { this.optionalmodules = optionalmodules; + return this; } } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyUpdate.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyPut.java old mode 100755 new mode 100644 similarity index 73% rename from hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyUpdate.java rename to hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyPut.java index b5669652f..6bf21b93f --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyUpdate.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRequestBodyPut.java @@ -8,22 +8,14 @@ */ package org.eclipse.hawkbit.rest.resource.model.distributionsettype; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; - /** * Request Body for DistributionSetType PUT, i.e. update. * - * - * - * */ -public class DistributionSetTypeRequestBodyUpdate { +public class DistributionSetTypeRequestBodyPut { - @ApiModelProperty(value = ApiModelProperties.DESCRPTION) @JsonProperty private String description; @@ -37,9 +29,12 @@ public class DistributionSetTypeRequestBodyUpdate { /** * @param description * the description to set + * + * @return updated body */ - public void setDescription(final String description) { + public DistributionSetTypeRequestBodyPut setDescription(final String description) { this.description = description; + return this; } } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRest.java old mode 100755 new mode 100644 index b5092dfb7..e282b2924 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypeRest.java @@ -9,16 +9,12 @@ package org.eclipse.hawkbit.rest.resource.model.distributionsettype; import org.eclipse.hawkbit.rest.resource.model.NamedEntityRest; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * A json annotated rest model for SoftwareModuleType to RESTful API * representation. @@ -29,14 +25,11 @@ import io.swagger.annotations.ApiModelProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("Software Module") public class DistributionSetTypeRest extends NamedEntityRest { - @ApiModelProperty(value = ApiModelProperties.ITEM_ID, required = true) @JsonProperty(value = "id", required = true) private Long moduleId; - @ApiModelProperty(value = ApiModelProperties.DS_TYPE_KEY) @JsonProperty private String key; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypesRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypesRest.java old mode 100755 new mode 100644 index 1ba520549..f3cd42a85 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypesRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/distributionsettype/DistributionSetTypesRest.java @@ -16,17 +16,11 @@ import java.util.ListIterator; import org.springframework.hateoas.ResourceSupport; -import io.swagger.annotations.ApiModel; - /** * List representation of the {@link DistributionSetTypeRest} because Spring MVC * cannot handle plain lists interfaces as request body. * - * - * - * */ -@ApiModel("DistributionSetType") public class DistributionSetTypesRest extends ResourceSupport implements List { private final List delegate = new ArrayList<>(); diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/doc/ApiModelProperties.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/doc/ApiModelProperties.java deleted file mode 100755 index a9414478f..000000000 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/doc/ApiModelProperties.java +++ /dev/null @@ -1,176 +0,0 @@ -/** - * 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.rest.resource.model.doc; - -/** - * Constants for API documentation. - * - * - * - * - */ -public final class ApiModelProperties { - private static final String ENDING = " of the entity"; - - // generic - public static final String ITEM_ID = "the id" + ENDING; - - public static final String NAME = "the name" + ENDING; - public static final String DESCRPTION = "the description" + ENDING; - - public static final String CREATED_BY = "entity was originally created by (IM UUID)"; - - public static final String CREATED_AT = "entity was originally created at"; - public static final String LAST_MODIFIED_BY = "entity was last modified by (IM UUID)"; - public static final String LAST_MODIFIED_AT = "entity was last modified at"; - public static final String SIZE = "current page size"; - public static final String TOTAL_ELEMENTS = "total number of elements"; - - // Versioned entity - public static final String VERSION = "software version"; - - // software module - public static final String SOFTWARE_MODULE_TYPE = "the software module type " + ENDING; - - public static final String VENDOR = "the software vendor " + ENDING; - public static final String ARTIFACT_HASHES = "hashes of the artifact"; - public static final String ARTIFACT_SIZE = "size of the artifact"; - public static final String ARTIFACT_PROVIDED_FILENAME = "filename of the artifact"; - public static final String ARTIFACT_HASHES_SHA1 = "SHA1 hash of the artifact"; - public static final String ARTIFACT_HASHES_MD5 = "MD5 hash of the artifact"; - public static final String DS_OS = "operating system or firmware software module - DEPRECATED (use modules)"; - public static final String DS_RUNTIME = "runtime software module (e.g. JVM) - DEPRECATED (use modules)"; - public static final String DS_APPLICATION = "application software module (e.g. OSGi container) - DEPRECATED (use modules)"; - public static final String DS_MODULES = "software modules (e.g. OSGi bundles, runtimes)"; - public static final String DS_REQUIRED_STEP = "is a required migration step"; - - // Target - public static final String INSTALLED_AT = "installation time of current installed DistributionSet"; - - public static final String LAST_REQUEST_AT = "last time where the target polled the server, same as pollStatus.lastRequestAt"; - // poll status - public static final String POLL_LAST_REQUEST_AT = "last time where the target polled the server"; - public static final String POLL_NEXT_EXPECTED_REQUEST_AT = "next expected time where the target polls the server"; - public static final String POLL_OVERDUE = "defines if the target poll time is overdued based on the next expected poll time plus the configured overdue poll time threshold"; - - public static final String UPDATE_STATUS = "current update status"; - public static final String TARGET_ATTRIBUTES = "target attributes"; - - public static final String TARGET_LIST = "list of targets"; - - public static final String SM_LIST = "list of software modules"; - - public static final String ACTION_TYPE = "type of action"; - - public static final String ACTION_STATUS_TYPE = "type of the action status"; - - public static final String ACTION_STATUS_MESSAGES = "messages related to the status"; - - public static final String ACTION_STATUS_REPORTED_AT = "time at which the status was reported (server time)"; - - public static final String ACTION_STATUS_LIST = "list of action status"; - - public static final String ACTION_EXECUTION_STATUS = "status of action"; - - public static final String ACTION_LIST = "list if actions"; - - public static final String POLL_STATUS = "status of the poll time of the target"; - - public static final String IP_ADDRESS = "last known ip-address of the target"; - - public static final String ADDRESS = "last known address of the target"; - - public static final String SECURITY_TOKEN = "the security token of this target which can be used to authenticate the target if enabled"; - - public static final String META_DATA = "Metadata"; - - public static final String SM_TYPE_KEY = "key that can be interpreted by the target"; - - public static final String SM_MAX_ASSIGNMENTS = "maximum number of assigments to a distribution set/target, e.g. only one firmware but multiple applications"; - - public static final String SM_TYPE_LIST = "list of software modules types"; - - // Direct Device Integration API - public static final String TARGET_TIME = "time on the target device"; - - public static final String TARGET_STATUS = "SP target action status"; - - public static final String TARGET_EXEC_STATUS = "status of the action execution"; - - public static final String TARGET_RESULT_VALUE = "result of the action execution"; - - public static final String TARGET_RESULT_DETAILS = "List of details message information"; - - public static final String TARGET_RESULT_FINISHED = "defined status of the result"; - - public static final String TARGET_RESULT_PROGRESS = "progress assumption of the device"; - - public static final String TARGET_PROGRESS_CNT = "current progress level"; - - public static final String TARGET_PROGRESS_OF = "asumption concerning max progress level"; - - public static final String ACTION_ID = "id of the action"; - - public static final String CANCEL_ACTION = "action that needs to be canceled"; - - public static final String CHUNK_TYPE = "type of the chunk, e.g. firmware, bundle, app"; - - public static final String SOFTWARE_MODUL_TYPE = "type of the software module, e.g. firmware, bundle, app"; - - public static final String SOFTWARE_MODULE_VERSION = "version of the software module"; - - public static final String SOFTWARE_MODULE_NAME = "name of the software module"; - - public static final String SOFTWARE_MODULE_ARTIFACT_LINKS = "artifact links of the software module"; - - public static final String SOFTWARE_MODUL_ID = "id of the software module"; - - public static final String CHUNK_VERSION = "software version of the chunk"; - - public static final String CHUNK_NAME = "name of the chunk"; - - public static final String ARTIFACTS = "list of artifacts"; - - public static final String TARGET_CONFIGURATION = "target configuration setup by the server"; - - public static final String TARGET_POLL_TIME = "suggested sleep time between polls"; - - public static final String TARGET_SLEEP = "sleep time in HH:MM:SS notation"; - - public static final String DEPLOYMENT = "detailed deployment operation"; - - public static final String HANDLING_DOWNLOAD = "handling for the download part of the provisioning process"; - - public static final String HANDLING_UPDATE = "handling for the update part of the provisioning process"; - - public static final String CHUNK = "software chunk of an update"; - - public static final String SOFTWARE_MODUL = "software moduls of an update"; - - public static final String ARTIFACT = "artifact moduls of an update"; - - public static final String TARGET_CONFIG_DATA = "configuration data as key/value list"; - - public static final String DS_TYPE_KEY = "funtional key of the distribution set type"; - - public static final String DS_TYPE_LIST = "list of distribution set types"; - - public static final String DS_TYPE = "the type of the distribution set"; - - public static final String DS_COMPLETE = "true of the distribution set software module setup is complete by means as defined by the distribution set type"; - - public static final String DS_TYPE_MANDATORY_MODULES = "mandatory module type IDs"; - - public static final String DS_TYPE_OPTIONAL_MODULES = "optional module type IDs"; - - private ApiModelProperties() { - // utility class - } - -} diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleAssigmentRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleAssigmentRest.java old mode 100755 new mode 100644 index 378b4e644..3c866dca6 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleAssigmentRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleAssigmentRest.java @@ -12,8 +12,6 @@ import org.eclipse.hawkbit.rest.resource.model.IdRest; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import io.swagger.annotations.ApiModel; - /** * Request Body of SoftwareModule for assignment operations (ID only). * @@ -22,7 +20,6 @@ import io.swagger.annotations.ApiModel; * */ @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("Software Module ID") public class SoftwareModuleAssigmentRest extends IdRest { } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModulePagedList.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModulePagedList.java old mode 100755 new mode 100644 index 1bba983ea..a49f41dc9 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModulePagedList.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModulePagedList.java @@ -11,22 +11,13 @@ package org.eclipse.hawkbit.rest.resource.model.softwaremodule; import java.util.List; import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; /** * Paged list for SoftwareModule. * - * - * - * */ -@ApiModel("Paged list of software modules") public class SoftwareModulePagedList extends PagedList { - @ApiModelProperty(value = ApiModelProperties.SM_LIST, required = true) private final List content; /** diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRequestBodyPost.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRequestBodyPost.java old mode 100755 new mode 100644 index 13401c1f4..08638c10f --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRequestBodyPost.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRequestBodyPost.java @@ -8,39 +8,26 @@ */ package org.eclipse.hawkbit.rest.resource.model.softwaremodule; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; - /** * Request Body for SoftwareModule POST. * - * - * - * */ public class SoftwareModuleRequestBodyPost { - @ApiModelProperty(value = ApiModelProperties.NAME, required = true) @JsonProperty(required = true) private String name; - @ApiModelProperty(value = ApiModelProperties.VERSION, required = true) @JsonProperty(required = true) private String version; - @ApiModelProperty(value = ApiModelProperties.SOFTWARE_MODULE_TYPE, required = true, allowableValues = SoftwareModuleRest.SM_RUNTIME - + "," + SoftwareModuleRest.SM_APPLICATION + "," + SoftwareModuleRest.SM_OS) @JsonProperty(required = true) private String type; - @ApiModelProperty(value = ApiModelProperties.DESCRPTION) @JsonProperty private String description; - @ApiModelProperty(value = ApiModelProperties.VENDOR) @JsonProperty private String vendor; @@ -54,9 +41,12 @@ public class SoftwareModuleRequestBodyPost { /** * @param name * the name to set + * + * @return updated body */ - public void setName(final String name) { + public SoftwareModuleRequestBodyPost setName(final String name) { this.name = name; + return this; } /** @@ -69,9 +59,12 @@ public class SoftwareModuleRequestBodyPost { /** * @param version * the version to set + * + * @return updated body */ - public void setVersion(final String version) { + public SoftwareModuleRequestBodyPost setVersion(final String version) { this.version = version; + return this; } /** @@ -84,9 +77,12 @@ public class SoftwareModuleRequestBodyPost { /** * @param type * the type to set + * + * @return updated body */ - public void setType(final String type) { + public SoftwareModuleRequestBodyPost setType(final String type) { this.type = type; + return this; } /** @@ -99,9 +95,12 @@ public class SoftwareModuleRequestBodyPost { /** * @param description * the description to set + * + * @return updated body */ - public void setDescription(final String description) { + public SoftwareModuleRequestBodyPost setDescription(final String description) { this.description = description; + return this; } /** @@ -114,9 +113,12 @@ public class SoftwareModuleRequestBodyPost { /** * @param vendor * the vendor to set + * + * @return updated body */ - public void setVendor(final String vendor) { + public SoftwareModuleRequestBodyPost setVendor(final String vendor) { this.vendor = vendor; + return this; } } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRequestBodyPut.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRequestBodyPut.java old mode 100755 new mode 100644 index 310b0a942..1ee547886 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRequestBodyPut.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRequestBodyPut.java @@ -8,26 +8,17 @@ */ package org.eclipse.hawkbit.rest.resource.model.softwaremodule; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; - /** * Request Body for SoftwareModule PUT. * - * - * - * */ public class SoftwareModuleRequestBodyPut { - @ApiModelProperty(value = ApiModelProperties.DESCRPTION) @JsonProperty private String description; - @ApiModelProperty(value = ApiModelProperties.VENDOR) @JsonProperty private String vendor; @@ -41,9 +32,12 @@ public class SoftwareModuleRequestBodyPut { /** * @param description * the description to set + * + * @return updated body */ - public void setDescription(final String description) { + public SoftwareModuleRequestBodyPut setDescription(final String description) { this.description = description; + return this; } /** @@ -56,9 +50,12 @@ public class SoftwareModuleRequestBodyPut { /** * @param vendor * the vendor to set + * + * @return updated body */ - public void setVendor(final String vendor) { + public SoftwareModuleRequestBodyPut setVendor(final String vendor) { this.vendor = vendor; + return this; } } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRest.java old mode 100755 new mode 100644 index 0e1ee60fb..a5ab41c8b --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModuleRest.java @@ -9,7 +9,6 @@ package org.eclipse.hawkbit.rest.resource.model.softwaremodule; import org.eclipse.hawkbit.rest.resource.model.NamedEntityRest; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -17,19 +16,12 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * A json annotated rest model for SoftwareModule to RESTful API representation. - * - * - * * */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("Software Module") public class SoftwareModuleRest extends NamedEntityRest { /** * API definition for {@link SoftwareModule.Type#RUNTIME}. @@ -44,19 +36,15 @@ public class SoftwareModuleRest extends NamedEntityRest { */ public static final String SM_APPLICATION = "application"; - @ApiModelProperty(value = ApiModelProperties.ITEM_ID, required = true) @JsonProperty(value = "id", required = true) private Long moduleId; - @ApiModelProperty(value = ApiModelProperties.VERSION, required = true) @JsonProperty(required = true) private String version; - @ApiModelProperty(value = ApiModelProperties.SOFTWARE_MODULE_TYPE, required = true) @JsonProperty(required = true) private String type; - @ApiModelProperty(value = ApiModelProperties.VENDOR) @JsonProperty private String vendor; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModulesRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremodule/SoftwareModulesRest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeAssigmentRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeAssigmentRest.java old mode 100755 new mode 100644 index 892c86b49..68709650b --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeAssigmentRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeAssigmentRest.java @@ -12,17 +12,11 @@ import org.eclipse.hawkbit.rest.resource.model.IdRest; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import io.swagger.annotations.ApiModel; - /** * Request Body of SoftwareModuleType for assignment operations (ID only). * - * - * - * */ @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("Software Module Type ID") public class SoftwareModuleTypeAssigmentRest extends IdRest { } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypePagedList.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypePagedList.java old mode 100755 new mode 100644 index b5df0837f..7e85cdca9 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypePagedList.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypePagedList.java @@ -11,22 +11,13 @@ package org.eclipse.hawkbit.rest.resource.model.softwaremoduletype; import java.util.List; import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; /** * Paged list for SoftwareModuleType. * - * - * - * */ -@ApiModel("Paged list of software module typess") public class SoftwareModuleTypePagedList extends PagedList { - @ApiModelProperty(value = ApiModelProperties.SM_TYPE_LIST, required = true) private final List content; /** diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRequestBodyPost.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRequestBodyPost.java old mode 100755 new mode 100644 index ec5d9e1a1..3528f6b98 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRequestBodyPost.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRequestBodyPost.java @@ -8,34 +8,23 @@ */ package org.eclipse.hawkbit.rest.resource.model.softwaremoduletype; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; - /** * Request Body for SoftwareModuleType POST. * - * - * - * */ public class SoftwareModuleTypeRequestBodyPost { - @ApiModelProperty(value = ApiModelProperties.NAME, required = true) @JsonProperty(required = true) private String name; - @ApiModelProperty(value = ApiModelProperties.DESCRPTION) @JsonProperty private String description; - @ApiModelProperty(value = ApiModelProperties.SM_TYPE_KEY) @JsonProperty private String key; - @ApiModelProperty(value = ApiModelProperties.SM_MAX_ASSIGNMENTS) @JsonProperty private int maxAssignments; @@ -49,9 +38,12 @@ public class SoftwareModuleTypeRequestBodyPost { /** * @param name * the name to set + * + * @return updated body */ - public void setName(final String name) { + public SoftwareModuleTypeRequestBodyPost setName(final String name) { this.name = name; + return this; } /** @@ -64,9 +56,12 @@ public class SoftwareModuleTypeRequestBodyPost { /** * @param description * the description to set + * + * @return updated body */ - public void setDescription(final String description) { + public SoftwareModuleTypeRequestBodyPost setDescription(final String description) { this.description = description; + return this; } /** @@ -79,9 +74,11 @@ public class SoftwareModuleTypeRequestBodyPost { /** * @param key * the key to set + * @return updated body */ - public void setKey(final String key) { + public SoftwareModuleTypeRequestBodyPost setKey(final String key) { this.key = key; + return this; } /** @@ -94,9 +91,12 @@ public class SoftwareModuleTypeRequestBodyPost { /** * @param maxAssignments * the maxAssignments to set + * + * @return updated body */ - public void setMaxAssignments(final int maxAssignments) { + public SoftwareModuleTypeRequestBodyPost setMaxAssignments(final int maxAssignments) { this.maxAssignments = maxAssignments; + return this; } } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRequestBodyPut.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRequestBodyPut.java old mode 100755 new mode 100644 index 78c9a7973..107a3cd2b --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRequestBodyPut.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRequestBodyPut.java @@ -8,22 +8,14 @@ */ package org.eclipse.hawkbit.rest.resource.model.softwaremoduletype; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; - /** * Request Body for SoftwareModuleType PUT. * - * - * - * */ public class SoftwareModuleTypeRequestBodyPut { - @ApiModelProperty(value = ApiModelProperties.DESCRPTION) @JsonProperty private String description; @@ -37,9 +29,12 @@ public class SoftwareModuleTypeRequestBodyPut { /** * @param description * the description to set + * + * @return updated body */ - public void setDescription(final String description) { + public SoftwareModuleTypeRequestBodyPut setDescription(final String description) { this.description = description; + return this; } } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRest.java old mode 100755 new mode 100644 index 8e558cc2a..6478eb790 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypeRest.java @@ -9,16 +9,12 @@ package org.eclipse.hawkbit.rest.resource.model.softwaremoduletype; import org.eclipse.hawkbit.rest.resource.model.NamedEntityRest; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * A json annotated rest model for SoftwareModuleType to RESTful API * representation. @@ -29,18 +25,14 @@ import io.swagger.annotations.ApiModelProperty; */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("Software Module") public class SoftwareModuleTypeRest extends NamedEntityRest { - @ApiModelProperty(value = ApiModelProperties.ITEM_ID, required = true) @JsonProperty(value = "id", required = true) private Long moduleId; - @ApiModelProperty(value = ApiModelProperties.SM_TYPE_KEY) @JsonProperty private String key; - @ApiModelProperty(value = ApiModelProperties.SM_MAX_ASSIGNMENTS) @JsonProperty private int maxAssignments; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypesRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypesRest.java old mode 100755 new mode 100644 index c3f13b42a..91f440187 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypesRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/softwaremoduletype/SoftwareModuleTypesRest.java @@ -16,17 +16,11 @@ import java.util.ListIterator; import org.springframework.hateoas.ResourceSupport; -import io.swagger.annotations.ApiModel; - /** * List representation of the {@link SoftwareModuleTypeRest} because Spring MVC * cannot handle plain lists interfaces as request body. * - * - * - * */ -@ApiModel("SoftwareModuleType") public class SoftwareModuleTypesRest extends ResourceSupport implements List { private final List delegate = new ArrayList<>(); diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/CacheRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/CacheRest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/SystemStatisticsRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/SystemStatisticsRest.java new file mode 100644 index 000000000..84ce69948 --- /dev/null +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/SystemStatisticsRest.java @@ -0,0 +1,86 @@ +/** + * 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.rest.resource.model.system; + +import java.util.List; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +/** + * Body for system statistics. + * + */ +@JsonInclude(Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class SystemStatisticsRest { + + private long overallTargets; + private long overallArtifacts; + private long overallArtifactVolumeInBytes; + private long overallActions; + private long overallTenants; + + private List tenantStats; + + public long getOverallTargets() { + return overallTargets; + } + + public SystemStatisticsRest setOverallTargets(final long overallTargets) { + this.overallTargets = overallTargets; + return this; + } + + public long getOverallArtifacts() { + return overallArtifacts; + } + + public SystemStatisticsRest setOverallArtifacts(final long overallArtifacts) { + this.overallArtifacts = overallArtifacts; + return this; + } + + public long getOverallArtifactVolumeInBytes() { + return overallArtifactVolumeInBytes; + } + + public SystemStatisticsRest setOverallArtifactVolumeInBytes(final long overallArtifactVolumeInBytes) { + this.overallArtifactVolumeInBytes = overallArtifactVolumeInBytes; + return this; + } + + public long getOverallActions() { + return overallActions; + } + + public SystemStatisticsRest setOverallActions(final long overallActions) { + this.overallActions = overallActions; + return this; + } + + public long getOverallTenants() { + return overallTenants; + } + + public SystemStatisticsRest setOverallTenants(final long overallTenants) { + this.overallTenants = overallTenants; + return this; + } + + public void setTenantStats(final List tenantStats) { + this.tenantStats = tenantStats; + } + + public List getTenantStats() { + return tenantStats; + } + +} diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/TenantConfigurationRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/TenantConfigurationRest.java old mode 100755 new mode 100644 index df0cc8756..2d31d9f61 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/TenantConfigurationRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/TenantConfigurationRest.java @@ -12,15 +12,12 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; -import io.swagger.annotations.ApiModel; - /** - * + * Response body for tenant configuration requests. * */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("Tenant Configuration") public class TenantConfigurationRest { private String key; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/TenantSystemUsageRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/TenantSystemUsageRest.java new file mode 100644 index 000000000..b300d94de --- /dev/null +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/system/TenantSystemUsageRest.java @@ -0,0 +1,75 @@ +/** + * 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.rest.resource.model.system; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; + +/** + * Response body for system usage report. + * + */ +@JsonInclude(Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class TenantSystemUsageRest { + + private final String tenantName; + private long targets; + private long artifacts; + private long actions; + private long overallArtifactVolumeInBytes; + + /** + * Constructor. + * + * @param tenantName + */ + public TenantSystemUsageRest(final String tenantName) { + super(); + this.tenantName = tenantName; + } + + public long getTargets() { + return targets; + } + + public void setTargets(final long targets) { + this.targets = targets; + } + + public long getArtifacts() { + return artifacts; + } + + public void setArtifacts(final long artifacts) { + this.artifacts = artifacts; + } + + public long getActions() { + return actions; + } + + public void setActions(final long actions) { + this.actions = actions; + } + + public long getOverallArtifactVolumeInBytes() { + return overallArtifactVolumeInBytes; + } + + public void setOverallArtifactVolumeInBytes(final long overallArtifactVolumeInBytes) { + this.overallArtifactVolumeInBytes = overallArtifactVolumeInBytes; + } + + public String getTenantName() { + return tenantName; + } + +} diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/AssignedDistributionSetRequestBody.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/AssignedDistributionSetRequestBody.java new file mode 100644 index 000000000..2bfd6cbf8 --- /dev/null +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/AssignedDistributionSetRequestBody.java @@ -0,0 +1,36 @@ +/** + * 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.rest.resource.model.tag; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request Body for PUT. + * + */ +@JsonInclude(Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class AssignedDistributionSetRequestBody { + + @JsonProperty(value = "id", required = true) + private Long distributionSetId; + + public Long getDistributionSetId() { + return distributionSetId; + } + + public AssignedDistributionSetRequestBody setDistributionSetId(final Long distributionSetId) { + this.distributionSetId = distributionSetId; + return this; + } + +} diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/AssignedTargetRequestBody.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/AssignedTargetRequestBody.java new file mode 100644 index 000000000..2147c2697 --- /dev/null +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/AssignedTargetRequestBody.java @@ -0,0 +1,36 @@ +/** + * 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.rest.resource.model.tag; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request Body for PUT. + * + */ +@JsonInclude(Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class AssignedTargetRequestBody { + + @JsonProperty(required = true) + private String controllerId; + + public String getControllerId() { + return controllerId; + } + + public AssignedTargetRequestBody setControllerId(final String controllerId) { + this.controllerId = controllerId; + return this; + } + +} diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/DistributionSetTagAssigmentResultRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/DistributionSetTagAssigmentResultRest.java new file mode 100644 index 000000000..1d0b51e72 --- /dev/null +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/DistributionSetTagAssigmentResultRest.java @@ -0,0 +1,49 @@ +/** + * 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.rest.resource.model.tag; + +import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetsRest; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * * A json annotated rest model for DSAssigmentResult to RESTful API + * representation. + * + */ +@JsonInclude(Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class DistributionSetTagAssigmentResultRest { + + @JsonProperty + private DistributionSetsRest assignedDistributionSets; + + @JsonProperty + private DistributionSetsRest unassignedDistributionSets; + + public DistributionSetsRest getAssignedDistributionSets() { + return assignedDistributionSets; + } + + public DistributionSetsRest getUnassignedDistributionSets() { + return unassignedDistributionSets; + } + + public void setAssignedDistributionSets(final DistributionSetsRest assignedDistributionSets) { + this.assignedDistributionSets = assignedDistributionSets; + } + + public void setUnassignedDistributionSets(final DistributionSetsRest unassignedDistributionSets) { + this.unassignedDistributionSets = unassignedDistributionSets; + } + +} diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagPagedList.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagPagedList.java new file mode 100644 index 000000000..d549a9efa --- /dev/null +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagPagedList.java @@ -0,0 +1,43 @@ +/** + * 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.rest.resource.model.tag; + +import java.util.List; + +import org.eclipse.hawkbit.rest.resource.model.PagedList; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Paged list for tags. + * + */ +public class TagPagedList extends PagedList { + + private final List content; + + /** + * @param content + * @param total + */ + @JsonCreator + public TagPagedList(@JsonProperty("content") final List content, @JsonProperty("total") final long total) { + super(content, total); + this.content = content; + } + + /** + * @return the content of the paged list. Never {@code null}. + */ + public List getContent() { + return content; + } + +} diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagRequestBodyPut.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagRequestBodyPut.java new file mode 100644 index 000000000..2165bcfc0 --- /dev/null +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagRequestBodyPut.java @@ -0,0 +1,59 @@ +/** + * 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.rest.resource.model.tag; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Request Body for PUT/POST. + * + */ +@JsonInclude(Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class TagRequestBodyPut { + + @JsonProperty + private String colour; + + @JsonProperty + private String name; + + @JsonProperty + private String description; + + public String getName() { + return name; + } + + public TagRequestBodyPut setName(final String name) { + this.name = name; + return this; + } + + public String getDescription() { + return description; + } + + public TagRequestBodyPut setDescription(final String description) { + this.description = description; + return this; + } + + public TagRequestBodyPut setColour(final String colour) { + this.colour = colour; + return this; + } + + public String getColour() { + return colour; + } +} diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagRest.java new file mode 100644 index 000000000..54d3c5064 --- /dev/null +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagRest.java @@ -0,0 +1,49 @@ +/** + * 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.rest.resource.model.tag; + +import org.eclipse.hawkbit.rest.resource.model.NamedEntityRest; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A json annotated rest model for Tag to RESTful API representation. + * + */ +@JsonInclude(Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class TagRest extends NamedEntityRest { + + @JsonProperty(value = "id", required = true) + private Long tagId; + + @JsonProperty + private String colour; + + @JsonIgnore + public void setTagId(final Long tagId) { + this.tagId = tagId; + } + + public Long getTagId() { + return tagId; + } + + public void setColour(final String colour) { + this.colour = colour; + } + + public String getColour() { + return colour; + } +} diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagsRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagsRest.java new file mode 100644 index 000000000..df0638358 --- /dev/null +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TagsRest.java @@ -0,0 +1,275 @@ +/** + * 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.rest.resource.model.tag; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; + +import org.springframework.hateoas.ResourceSupport; + +/** + * List representation of the {@link TagRest} because Spring MVC cannot handle + * plain lists interfaces as request body. + * + * + */ +public class TagsRest extends ResourceSupport implements List { + + private final List delegate = new ArrayList<>(); + + /** + * @return + * @see java.util.List#size() + */ + @Override + public int size() { + return delegate.size(); + } + + /** + * @return + * @see java.util.List#isEmpty() + */ + @Override + public boolean isEmpty() { + return delegate.isEmpty(); + } + + /** + * @param o + * @return + * @see java.util.List#contains(java.lang.Object) + */ + @Override + public boolean contains(final Object o) { + return delegate.contains(o); + } + + /** + * @return + * @see java.util.List#iterator() + */ + @Override + public Iterator iterator() { + return delegate.iterator(); + } + + /** + * @return + * @see java.util.List#toArray() + */ + @Override + public Object[] toArray() { + return delegate.toArray(); + } + + /** + * @param a + * @return + * @see java.util.List#toArray(java.lang.Object[]) + */ + @Override + public T[] toArray(final T[] a) { + return delegate.toArray(a); + } + + /** + * @param e + * @return + * @see java.util.List#add(java.lang.Object) + */ + @Override + public boolean add(final TagRest e) { + return delegate.add(e); + } + + /** + * @param o + * @return + * @see java.util.List#remove(java.lang.Object) + */ + @Override + public boolean remove(final Object o) { + return delegate.remove(o); + } + + /** + * @param c + * @return + * @see java.util.List#containsAll(java.util.Collection) + */ + @Override + public boolean containsAll(final Collection c) { + return delegate.containsAll(c); + } + + /** + * @param c + * @return + * @see java.util.List#addAll(java.util.Collection) + */ + @Override + public boolean addAll(final Collection c) { + return delegate.addAll(c); + } + + /** + * @param index + * @param c + * @return + * @see java.util.List#addAll(int, java.util.Collection) + */ + @Override + public boolean addAll(final int index, final Collection c) { + return delegate.addAll(index, c); + } + + /** + * @param c + * @return + * @see java.util.List#removeAll(java.util.Collection) + */ + @Override + public boolean removeAll(final Collection c) { + return delegate.removeAll(c); + } + + /** + * @param c + * @return + * @see java.util.List#retainAll(java.util.Collection) + */ + @Override + public boolean retainAll(final Collection c) { + return delegate.retainAll(c); + } + + /** + * + * @see java.util.List#clear() + */ + @Override + public void clear() { + delegate.clear(); + } + + /** + * @param o + * @return + * @see java.util.List#equals(java.lang.Object) + */ + @Override + public boolean equals(final Object o) { + return delegate.equals(o); + } + + /** + * @return + * @see java.util.List#hashCode() + */ + @Override + public int hashCode() { + return delegate.hashCode(); + } + + /** + * @param index + * @return + * @see java.util.List#get(int) + */ + @Override + public TagRest get(final int index) { + return delegate.get(index); + } + + /** + * @param index + * @param element + * @return + * @see java.util.List#set(int, java.lang.Object) + */ + @Override + public TagRest set(final int index, final TagRest element) { + return delegate.set(index, element); + } + + /** + * @param index + * @param element + * @see java.util.List#add(int, java.lang.Object) + */ + @Override + public void add(final int index, final TagRest element) { + delegate.add(index, element); + } + + /** + * @param index + * @return + * @see java.util.List#remove(int) + */ + @Override + public TagRest remove(final int index) { + return delegate.remove(index); + } + + /** + * @param o + * @return + * @see java.util.List#indexOf(java.lang.Object) + */ + @Override + public int indexOf(final Object o) { + return delegate.indexOf(o); + } + + /** + * @param o + * @return + * @see java.util.List#lastIndexOf(java.lang.Object) + */ + @Override + public int lastIndexOf(final Object o) { + return delegate.lastIndexOf(o); + } + + /** + * @return + * @see java.util.List#listIterator() + */ + @Override + public ListIterator listIterator() { + return delegate.listIterator(); + } + + /** + * @param index + * @return + * @see java.util.List#listIterator(int) + */ + @Override + public ListIterator listIterator(final int index) { + return delegate.listIterator(index); + } + + /** + * @param fromIndex + * @param toIndex + * @return + * @see java.util.List#subList(int, int) + */ + @Override + public List subList(final int fromIndex, final int toIndex) { + return delegate.subList(fromIndex, toIndex); + } + +} diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TargetTagAssigmentResultRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TargetTagAssigmentResultRest.java new file mode 100644 index 000000000..928a72460 --- /dev/null +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/tag/TargetTagAssigmentResultRest.java @@ -0,0 +1,49 @@ +/** + * 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.rest.resource.model.tag; + +import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonInclude.Include; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * * A json annotated rest model for TargetTagAssigmentResult to RESTful API + * representation. + * + */ +@JsonInclude(Include.NON_NULL) +@JsonIgnoreProperties(ignoreUnknown = true) +public class TargetTagAssigmentResultRest { + + @JsonProperty + private TargetsRest assignedTargets; + + @JsonProperty + private TargetsRest unassignedTargets; + + public void setAssignedTargets(final TargetsRest assignedTargets) { + this.assignedTargets = assignedTargets; + } + + public TargetsRest getAssignedTargets() { + return assignedTargets; + } + + public void setUnassignedTargets(final TargetsRest unassignedTargets) { + this.unassignedTargets = unassignedTargets; + } + + public TargetsRest getUnassignedTargets() { + return unassignedTargets; + } + +} diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/DistributionSetAssigmentRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/DistributionSetAssigmentRest.java old mode 100755 new mode 100644 index f0dfaca76..c2dc7f4a9 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/DistributionSetAssigmentRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/DistributionSetAssigmentRest.java @@ -6,22 +6,12 @@ package org.eclipse.hawkbit.rest.resource.model.target; import org.eclipse.hawkbit.rest.resource.model.IdRest; import org.eclipse.hawkbit.rest.resource.model.distributionset.ActionTypeRest; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Request Body of DistributionSet for assignment operations (ID only). * - * - * - * */ -@ApiModel("Distribution Set Assignment") public class DistributionSetAssigmentRest extends IdRest { - - @ApiModelProperty(value = "forcetime in milliseconds") private long forcetime; - @ApiModelProperty(value = "the assignment type default 'forced'") private ActionTypeRest type; /** diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetAttributes.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetAttributes.java old mode 100755 new mode 100644 index e10e884d6..821be6b45 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetAttributes.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetAttributes.java @@ -6,18 +6,10 @@ package org.eclipse.hawkbit.rest.resource.model.target; import java.util.HashMap; import java.util.Map; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - -import io.swagger.annotations.ApiModel; - /** - * {@link Map} with attribtes of SP Target. - * - * - * + * {@link Map} with attributes of SP Target. * */ -@ApiModel(ApiModelProperties.TARGET_ATTRIBUTES) public class TargetAttributes extends HashMap { } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetPagedList.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetPagedList.java old mode 100755 new mode 100644 index a83d9a363..d7bb5ccca --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetPagedList.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetPagedList.java @@ -6,29 +6,25 @@ package org.eclipse.hawkbit.rest.resource.model.target; import java.util.List; import org.eclipse.hawkbit.rest.resource.model.PagedList; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; /** * Paged list for targets. * - * - * - * */ -@ApiModel("Paged list of targets") public class TargetPagedList extends PagedList { - @ApiModelProperty(value = ApiModelProperties.TARGET_LIST, required = true) private final List content; /** * @param content * @param total */ - public TargetPagedList(final List content, final long total) { + @JsonCreator + public TargetPagedList(@JsonProperty("content") final List content, + @JsonProperty("total") final long total) { super(content, total); this.content = content; } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetRequestBody.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetRequestBody.java old mode 100755 new mode 100644 index b3584742b..bc1ca8a63 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetRequestBody.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetRequestBody.java @@ -3,28 +3,18 @@ */ package org.eclipse.hawkbit.rest.resource.model.target; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; - /** * Request body for target PUT/POST commands. * - * - * - * */ public class TargetRequestBody { - @ApiModelProperty(value = ApiModelProperties.NAME, required = true) @JsonProperty(required = true) private String name; - @ApiModelProperty(value = ApiModelProperties.DESCRPTION) private String description; - @ApiModelProperty(value = ApiModelProperties.ITEM_ID, required = true) @JsonProperty(required = true) private String controllerId; @@ -53,24 +43,27 @@ public class TargetRequestBody { * @param name * the name to set */ - public void setName(final String name) { + public TargetRequestBody setName(final String name) { this.name = name; + return this; } /** * @param description * the description to set */ - public void setDescription(final String description) { + public TargetRequestBody setDescription(final String description) { this.description = description; + return this; } /** * @param controllerId * the controllerId to set */ - public void setControllerId(final String controllerId) { + public TargetRequestBody setControllerId(final String controllerId) { this.controllerId = controllerId; + return this; } } diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetRest.java old mode 100755 new mode 100644 index bf7433485..37baeeec9 --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetRest.java @@ -7,7 +7,6 @@ import java.net.URI; import org.eclipse.hawkbit.rest.resource.model.NamedEntityRest; import org.eclipse.hawkbit.rest.resource.model.PollStatusRest; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @@ -15,50 +14,35 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * A json annotated rest model for Target to RESTful API representation. - * - * - * * */ @JsonInclude(Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("Provisioning Target") public class TargetRest extends NamedEntityRest { - @ApiModelProperty(value = ApiModelProperties.ITEM_ID, required = true) @JsonProperty(required = true) private String controllerId; - @ApiModelProperty(value = ApiModelProperties.UPDATE_STATUS, allowableValues = "error, in_sync, pending, registered, unknown") @JsonProperty private String updateStatus; - @ApiModelProperty(value = ApiModelProperties.LAST_REQUEST_AT) @JsonProperty private Long lastControllerRequestAt; - @ApiModelProperty(value = ApiModelProperties.INSTALLED_AT) @JsonProperty private Long installedAt; - @ApiModelProperty(value = ApiModelProperties.IP_ADDRESS) @JsonProperty private String ipAddress; - @ApiModelProperty(value = ApiModelProperties.ADDRESS) @JsonProperty private String address; - @ApiModelProperty(value = ApiModelProperties.POLL_STATUS) @JsonProperty private PollStatusRest pollStatus; - @ApiModelProperty(value = ApiModelProperties.SECURITY_TOKEN) @JsonProperty private String securityToken; diff --git a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetsRest.java b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetsRest.java old mode 100755 new mode 100644 index c946e0594..6344ee93b --- a/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetsRest.java +++ b/hawkbit-rest-api/src/main/java/org/eclipse/hawkbit/rest/resource/model/target/TargetsRest.java @@ -15,9 +15,6 @@ import org.springframework.hateoas.ResourceSupport; * A list representation of the {@link TargetRest} because Spring MVC cannot * handle plain lists interfaces as request body. * - * - * - * */ public class TargetsRest extends ResourceSupport implements List { diff --git a/hawkbit-rest-resource/pom.xml b/hawkbit-rest-resource/pom.xml old mode 100755 new mode 100644 index 068dfd521..f682b3f05 --- a/hawkbit-rest-resource/pom.xml +++ b/hawkbit-rest-resource/pom.xml @@ -57,6 +57,22 @@ + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-logging + + + test + + + org.springframework.boot + spring-boot-starter-log4j2 + test + com.h2database h2 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/cache/CacheWriteNotify.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/cache/CacheWriteNotify.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/ArtifactStoreController.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/ArtifactStoreController.java old mode 100755 new mode 100644 index 7d1f402ae..ae72a5cb2 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/ArtifactStoreController.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/ArtifactStoreController.java @@ -35,7 +35,6 @@ import org.springframework.core.env.Environment; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.web.bind.annotation.AuthenticationPrincipal; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -55,7 +54,6 @@ import org.springframework.web.bind.annotation.RestController; * */ @RestController -@Transactional @RequestMapping(ControllerConstants.ARTIFACTS_V1_REQUEST_MAPPING) public class ArtifactStoreController implements EnvironmentAware { private static final Logger LOG = LoggerFactory.getLogger(ArtifactStoreController.class); @@ -101,7 +99,7 @@ public class ArtifactStoreController implements EnvironmentAware { public ResponseEntity downloadArtifactByFilename(@PathVariable final String fileName, final HttpServletResponse response, final HttpServletRequest request, @AuthenticationPrincipal final String targetid) { - ResponseEntity result = null; + ResponseEntity result; final List foundArtifacts = artifactManagement.findLocalArtifactByFilename(fileName); diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/ControllerConstants.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/ControllerConstants.java old mode 100755 new mode 100644 index 618091e1d..fd7f125c5 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/ControllerConstants.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/ControllerConstants.java @@ -27,12 +27,12 @@ public final class ControllerConstants { /** * Deployment action resources. */ - static final String DEPLOYMENT_BASE_ACTION = "deploymentBase"; + public static final String DEPLOYMENT_BASE_ACTION = "deploymentBase"; /** * Cancel action resources. */ - static final String CANCEL_ACTION = "cancelAction"; + public static final String CANCEL_ACTION = "cancelAction"; /** * Feedback channel. @@ -42,7 +42,7 @@ public final class ControllerConstants { /** * Config data action resources. */ - static final String CONFIG_DATA_ACTION = "configData"; + public static final String CONFIG_DATA_ACTION = "configData"; /** * The artifact URL mapping rest resource. diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/DataConversionHelper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/DataConversionHelper.java old mode 100755 new mode 100644 index edf0e7b90..ef4468815 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/DataConversionHelper.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/DataConversionHelper.java @@ -23,15 +23,12 @@ import org.eclipse.hawkbit.controller.model.Chunk; import org.eclipse.hawkbit.controller.model.Config; import org.eclipse.hawkbit.controller.model.ControllerBase; import org.eclipse.hawkbit.controller.model.Polling; -import org.eclipse.hawkbit.controller.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.Status; -import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.rest.resource.model.artifact.ArtifactHash; import org.eclipse.hawkbit.tenancy.TenantAware; -import org.springframework.hateoas.Link; import com.google.common.base.Charsets; @@ -57,34 +54,6 @@ public final class DataConversionHelper { } - /** - * Creates all available (rest) software modules for a given distributionSet - * set. - * - * @param targetid - * of the target - * @param assignedDistributionSet - * the assigned distribution set - * @param tenantAware - * of the tenant - * @return a list of software modules or a empty list. Cannot be . - */ - public static List createSoftwareModules(final String targetid, - final DistributionSet assignedDistributionSet, final TenantAware tenantAware) { - return assignedDistributionSet.getModules().stream() - .map(module -> createSoftwareModul(targetid, module, tenantAware)).collect(Collectors.toList()); - - } - - private static SoftwareModule createSoftwareModul(final String targetid, - final org.eclipse.hawkbit.repository.model.SoftwareModule module, final TenantAware tenantAware) { - final List links = new ArrayList(); - module.getLocalArtifacts().forEach(artifact -> createAndAddLinks(targetid, tenantAware, artifact, links)); - - return new SoftwareModule(module.getId(), module.getType().getKey(), module.getVersion(), module.getName(), - links); - } - private static String mapChunkLegacyKeys(final String key) { if ("application".equals(key)) { return "bApp"; @@ -98,7 +67,7 @@ public final class DataConversionHelper { /** * Creates all (rest) artifacts for a given software module. - * + * * @param targetid * of the target * @param module @@ -109,26 +78,23 @@ public final class DataConversionHelper { */ public static List createArtifacts(final String targetid, final org.eclipse.hawkbit.repository.model.SoftwareModule module, final TenantAware tenantAware) { - final List files = new ArrayList(); + final List files = new ArrayList<>(); module.getLocalArtifacts().forEach(artifact -> { final Artifact file = new Artifact(); file.setHashes(new ArtifactHash(artifact.getSha1Hash(), artifact.getMd5Hash())); file.setFilename(artifact.getFilename()); file.setSize(artifact.getSize()); - createAndAddLinks(targetid, tenantAware, artifact, file.getLinks()); + + file.add(linkTo(methodOn(RootController.class, tenantAware.getCurrentTenant()).downloadArtifact(targetid, + artifact.getSoftwareModule().getId(), artifact.getFilename(), null, null)).withRel("download")); + file.add(linkTo(methodOn(RootController.class, tenantAware.getCurrentTenant()).downloadArtifactMd5(targetid, + artifact.getSoftwareModule().getId(), artifact.getFilename(), null, null)).withRel("md5sum")); + files.add(file); }); return files; } - private static void createAndAddLinks(final String targetid, final TenantAware tenantAware, - final LocalArtifact artifact, final List links) { - links.add(linkTo(methodOn(RootController.class, tenantAware.getCurrentTenant()).downloadArtifact(targetid, - artifact.getSoftwareModule().getId(), artifact.getFilename(), null, null)).withRel("download")); - links.add(linkTo(methodOn(RootController.class, tenantAware.getCurrentTenant()).downloadArtifactMd5(targetid, - artifact.getSoftwareModule().getId(), artifact.getFilename(), null, null)).withRel("md5sum")); - } - static ControllerBase fromTarget(final Target target, final List actions, final String defaultControllerPollTime, final TenantAware tenantAware) { final ControllerBase result = new ControllerBase(new Config(new Polling(defaultControllerPollTime))); diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/EnableDirectDeviceApi.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/EnableDirectDeviceApi.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/FileSteamingFailedException.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/FileSteamingFailedException.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java old mode 100755 new mode 100644 index c62a46822..bec137f91 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/RootController.java @@ -8,11 +8,7 @@ */ package org.eclipse.hawkbit.controller; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; - import java.io.IOException; -import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest; @@ -40,7 +36,6 @@ import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.Status; import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.Artifact; -import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.LocalArtifact; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Target; @@ -58,7 +53,6 @@ import org.springframework.core.env.Environment; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -80,8 +74,6 @@ import org.springframework.web.bind.annotation.RestController; */ @RestController @RequestMapping(ControllerConstants.BASE_V1_REQUEST_MAPPING) -@Transactional -@Api(value = "/", description = "SP Direct Device Integration API") public class RootController implements EnvironmentAware { private static final Logger LOG = LoggerFactory.getLogger(RootController.class); @@ -130,7 +122,6 @@ public class RootController implements EnvironmentAware { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/{softwareModuleId}/artifacts", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = org.eclipse.hawkbit.controller.model.Artifact.class, value = "Returns artifacts of given software module", notes = "Returns all artifacts whichs is assigned to the software module") public ResponseEntity> getSoftwareModulesArtifacts( @PathVariable final String targetid, @PathVariable final Long softwareModuleId) { LOG.debug("getSoftwareModulesArtifacts({})", targetid); @@ -147,36 +138,6 @@ public class RootController implements EnvironmentAware { HttpStatus.OK); } - /** - * Returns all available software modules for a given target. - * - * @param targetid - * of the {@link Target} that matches to - * {@link Target#getControllerId()} - * @param request - * the HTTP request injected by spring - * @return the response - */ - @RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/", produces = { - "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = SoftwareModule.class, value = " Returns software modules of given target", notes = "Returns all available software modules for a given target") - public ResponseEntity> getSoftwareModules( - @PathVariable final String targetid, final HttpServletRequest request) { - LOG.debug("getSoftwareModules({})", targetid); - - final Target target = controllerManagement.updateLastTargetQuery(targetid, - IpUtil.getClientIpFromRequest(request, requestHeader)); - - final DistributionSet assignedDistributionSet = target.getAssignedDistributionSet(); - - if (assignedDistributionSet == null) { - return new ResponseEntity<>(new ArrayList<>(), HttpStatus.OK); - } - - return new ResponseEntity<>(DataConversionHelper.createSoftwareModules(targetid, assignedDistributionSet, - tenantAware), HttpStatus.OK); - } - /** * Root resource for an individual {@link Target}. * @@ -189,9 +150,6 @@ public class RootController implements EnvironmentAware { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetid}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = ControllerBase.class, value = "Controller base poll resource", notes = "This base resource can be regularly polled by the controller on the provisiong target or device " - + "in order to retrieve actions that need to be executed. The resource supports Etag based modification " - + "checks in order to save traffic.") public ResponseEntity getControllerBase(@PathVariable final String targetid, final HttpServletRequest request) { LOG.debug("getControllerBase({})", targetid); @@ -205,7 +163,7 @@ public class RootController implements EnvironmentAware { System.currentTimeMillis(), IpUtil.getClientIpFromRequest(request, requestHeader)); } - return new ResponseEntity(DataConversionHelper.fromTarget(target, + return new ResponseEntity<>(DataConversionHelper.fromTarget(target, controllerManagement.findActionByTargetAndActive(target), controllerPollProperties.getPollingTime(), tenantAware), HttpStatus.OK); } @@ -230,13 +188,10 @@ public class RootController implements EnvironmentAware { * {@link HttpStatus#PARTIAL_CONTENT}. */ @RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/{softwareModuleId}/artifacts/{fileName}") - @ApiOperation(response = Void.class, value = "Downstream of given artifact", notes = "Download resource for artifacts. The resource supports partial download " - + "as specified by RFC7233 (range requests). Keep in mind that the controller " - + "needs to have the artifact assigned in order to be granted permission to download.") public ResponseEntity downloadArtifact(@PathVariable final String targetid, @PathVariable final Long softwareModuleId, @PathVariable final String fileName, final HttpServletResponse response, final HttpServletRequest request) { - ResponseEntity result = null; + ResponseEntity result; final Target target = controllerManagement.updateLastTargetQuery(targetid, IpUtil.getClientIpFromRequest(request, requestHeader)); @@ -283,7 +238,7 @@ public class RootController implements EnvironmentAware { return action; } - private boolean checkModule(final String fileName, final SoftwareModule module) { + private static boolean checkModule(final String fileName, final SoftwareModule module) { return null == module || !module.getLocalArtifactByFilename(fileName).isPresent(); } @@ -306,9 +261,6 @@ public class RootController implements EnvironmentAware { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetid}/softwaremodules/{softwareModuleId}/artifacts/{fileName}" + ControllerConstants.ARTIFACT_MD5_DWNL_SUFFIX, produces = MediaType.TEXT_PLAIN_VALUE) - @ApiOperation(response = Void.class, value = "Downstream of given artifacts MD5SUM file", notes = "Download resource for MD5SUM file is an optional functionally especially usefull for " - + "Linux based devices on order to check artifact coonsitency after download by using the md5sum " - + "command line tool. The MD5 and SHA1 are in addition available as metadata in the deployment command itself.") public ResponseEntity downloadArtifactMd5(@PathVariable final String targetid, @PathVariable final Long softwareModuleId, @PathVariable final String fileName, final HttpServletResponse response, final HttpServletRequest request) { @@ -350,7 +302,6 @@ public class RootController implements EnvironmentAware { * @return the response */ @RequestMapping(value = "/{targetid}/" + ControllerConstants.DEPLOYMENT_BASE_ACTION + "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(response = DeploymentBase.class, value = "Deployment or update action", notes = "Core resource for deployment operations. Contains all information necessary in order to execute the operation.") public ResponseEntity getControllerBasedeploymentAction( @PathVariable @NotEmpty final String targetid, @PathVariable @NotEmpty final Long actionId, @RequestParam(value = "c", required = false, defaultValue = "-1") final int resource, @@ -380,10 +331,10 @@ public class RootController implements EnvironmentAware { controllerManagement.registerRetrieved(action, "Controller retrieved update action and should start now the download."); - return new ResponseEntity(base, HttpStatus.OK); + return new ResponseEntity<>(base, HttpStatus.OK); } - return new ResponseEntity(HttpStatus.NOT_FOUND); + return new ResponseEntity<>(HttpStatus.NOT_FOUND); } /** @@ -403,12 +354,9 @@ public class RootController implements EnvironmentAware { */ @RequestMapping(value = "/{targetid}/" + ControllerConstants.DEPLOYMENT_BASE_ACTION + "/{actionId}/" + ControllerConstants.FEEDBACK, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(response = ActionFeedback.class, value = "Feedback channel for update actions", notes = "Feedback channel. It is up to the device to decided how much intermediate feedback is " - + "provided. However, the action will be kept open until the controller on the device reports a " - + "finished (either successfull or error).") - public ResponseEntity postBasedeploymentActionFeedback( - @Valid @RequestBody final ActionFeedback feedback, @PathVariable final String targetid, - @PathVariable @NotEmpty final Long actionId, final HttpServletRequest request) { + public ResponseEntity postBasedeploymentActionFeedback(@Valid @RequestBody final ActionFeedback feedback, + @PathVariable final String targetid, @PathVariable @NotEmpty final Long actionId, + final HttpServletRequest request) { LOG.debug("provideBasedeploymentActionFeedback for target [{},{}]: {}", targetid, actionId, feedback); final Target target = controllerManagement.updateLastTargetQuery(targetid, @@ -418,7 +366,7 @@ public class RootController implements EnvironmentAware { LOG.warn( "provideBasedeploymentActionFeedback: action in payload ({}) was not identical to action in path ({}).", feedback.getId(), actionId); - return new ResponseEntity(HttpStatus.NOT_FOUND); + return new ResponseEntity<>(HttpStatus.NOT_FOUND); } final Action action = findActionWithExceptionIfNotFound(actionId); @@ -430,13 +378,13 @@ public class RootController implements EnvironmentAware { if (!action.isActive()) { LOG.warn("Updating action {} with feedback {} not possible since action not active anymore.", action.getId(), feedback.getId()); - return new ResponseEntity(HttpStatus.GONE); + return new ResponseEntity<>(HttpStatus.GONE); } controllerManagement.addUpdateActionStatus(generateUpdateStatus(feedback, targetid, feedback.getId(), action), action); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } @@ -461,25 +409,10 @@ public class RootController implements EnvironmentAware { actionStatus.addMessage("Controller reported internal ERROR and REJECTED update."); break; case CLOSED: - LOG.debug("Controller reported closed (actionid: {}, targetid: {}) as we got {} report.", actionid, - targetid, feedback.getStatus().getExecution()); - if (feedback.getStatus().getResult().getFinished() == FinalResult.FAILURE) { - actionStatus.setStatus(Status.ERROR); - actionStatus.addMessage("Controller reported CLOSED with ERROR!"); - } else { - actionStatus.setStatus(Status.FINISHED); - actionStatus.addMessage("Controller reported CLOSED with OK!"); - } + handleClosedUpdateStatus(feedback, targetid, actionid, actionStatus); break; default: - LOG.debug("Controller reported intermediate status (actionid: {}, targetid: {}) as we got {} report.", - actionid, targetid, feedback.getStatus().getExecution()); - actionStatus.setStatus(Status.RUNNING); - // MECS-400: we should not use the unstructed message list for - // the - // server comment on the - // status. - actionStatus.addMessage("Controller reported: " + feedback.getStatus().getExecution()); + handleDefaultUpdateStatus(feedback, targetid, actionid, actionStatus); break; } @@ -495,6 +428,29 @@ public class RootController implements EnvironmentAware { return actionStatus; } + private static void handleDefaultUpdateStatus(final ActionFeedback feedback, final String targetid, + final Long actionid, final ActionStatus actionStatus) { + LOG.debug("Controller reported intermediate status (actionid: {}, targetid: {}) as we got {} report.", + actionid, targetid, feedback.getStatus().getExecution()); + actionStatus.setStatus(Status.RUNNING); + // MECS-400: we should not use the unstructed message list for + // the server comment on the status. + actionStatus.addMessage("Controller reported: " + feedback.getStatus().getExecution()); + } + + private static void handleClosedUpdateStatus(final ActionFeedback feedback, final String targetid, + final Long actionid, final ActionStatus actionStatus) { + LOG.debug("Controller reported closed (actionid: {}, targetid: {}) as we got {} report.", actionid, targetid, + feedback.getStatus().getExecution()); + if (feedback.getStatus().getResult().getFinished() == FinalResult.FAILURE) { + actionStatus.setStatus(Status.ERROR); + actionStatus.addMessage("Controller reported CLOSED with ERROR!"); + } else { + actionStatus.setStatus(Status.FINISHED); + actionStatus.addMessage("Controller reported CLOSED with OK!"); + } + } + /** * This is the feedback channel for the config data action. * @@ -508,16 +464,13 @@ public class RootController implements EnvironmentAware { * @return status of the request */ @RequestMapping(value = "/{targetid}/" + ControllerConstants.CONFIG_DATA_ACTION, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(response = ConfigData.class, value = "Response to a requested metadata pull from the provisioning target device.", notes = "The usual behaviour is that when a new device resgisters at the server it is " - + "requested to provide the meta information that will allow the server to identify the device on a " - + "hardware level (e.g. hardware revision, mac address, serial number etc.).") - public ResponseEntity putConfigData(@Valid @RequestBody final ConfigData configData, + public ResponseEntity putConfigData(@Valid @RequestBody final ConfigData configData, @PathVariable final String targetid, final HttpServletRequest request) { controllerManagement.updateLastTargetQuery(targetid, IpUtil.getClientIpFromRequest(request, requestHeader)); controllerManagement.updateControllerAttributes(targetid, configData.getData()); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } /** @@ -533,8 +486,6 @@ public class RootController implements EnvironmentAware { * @return the {@link Cancel} response */ @RequestMapping(value = "/{targetid}/" + ControllerConstants.CANCEL_ACTION + "/{actionId}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(response = Cancel.class, value = "Cancel an action", notes = "The SP server might cancel an operation, e.g. an unfinished update has a sucessor. " - + "It is up to the provisiong target to decide to accept the cancelation or reject it.") public ResponseEntity getControllerCancelAction(@PathVariable @NotEmpty final String targetid, @PathVariable @NotEmpty final Long actionId, final HttpServletRequest request) { LOG.debug("getControllerCancelAction({})", targetid); @@ -557,10 +508,10 @@ public class RootController implements EnvironmentAware { controllerManagement.registerRetrieved(action, "Controller retrieved cancel action and should start now the cancelation."); - return new ResponseEntity(cancel, HttpStatus.OK); + return new ResponseEntity<>(cancel, HttpStatus.OK); } - return new ResponseEntity(HttpStatus.NOT_FOUND); + return new ResponseEntity<>(HttpStatus.NOT_FOUND); } /** @@ -578,12 +529,10 @@ public class RootController implements EnvironmentAware { * * @return the {@link ActionFeedback} response */ + @RequestMapping(value = "/{targetid}/" + ControllerConstants.CANCEL_ACTION + "/{actionId}/" + ControllerConstants.FEEDBACK, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE) - @ApiOperation(response = Cancel.class, value = "Feedback channel for cancel actions", notes = "It is up to the device to decided how much intermediate feedback is " - + "provided. However, the action will be kept open until the controller on the device reports a " - + "finished (either successfull or error) or rejects the oprtioan, e.g. the canceled actions have been started already.") - public ResponseEntity postCancelActionFeedback(@Valid @RequestBody final ActionFeedback feedback, + public ResponseEntity postCancelActionFeedback(@Valid @RequestBody final ActionFeedback feedback, @PathVariable @NotEmpty final String targetid, @PathVariable @NotEmpty final Long actionId, final HttpServletRequest request) { LOG.debug("provideCancelActionFeedback for target [{}]: {}", targetid, feedback); @@ -595,7 +544,7 @@ public class RootController implements EnvironmentAware { LOG.warn( "provideBasedeploymentActionFeedback: action in payload ({}) was not identical to action in path ({}).", feedback.getId(), actionId); - return new ResponseEntity(HttpStatus.NOT_FOUND); + return new ResponseEntity<>(HttpStatus.NOT_FOUND); } final Action action = findActionWithExceptionIfNotFound(actionId); @@ -606,7 +555,7 @@ public class RootController implements EnvironmentAware { controllerManagement.addCancelActionStatus( generateActionCancelStatus(feedback, target, feedback.getId(), action), action); - return new ResponseEntity(HttpStatus.OK); + return new ResponseEntity<>(HttpStatus.OK); } private static ActionStatus generateActionCancelStatus(final ActionFeedback feedback, final Target target, @@ -629,11 +578,7 @@ public class RootController implements EnvironmentAware { actionStatus.setStatus(Status.WARNING); break; case CLOSED: - if (feedback.getStatus().getResult().getFinished() == FinalResult.FAILURE) { - actionStatus.setStatus(Status.ERROR); - } else { - actionStatus.setStatus(Status.CANCELED); - } + handleClosedCancelStatus(feedback, actionStatus); break; default: actionStatus.setStatus(Status.RUNNING); @@ -653,6 +598,14 @@ public class RootController implements EnvironmentAware { } + private static void handleClosedCancelStatus(final ActionFeedback feedback, final ActionStatus actionStatus) { + if (feedback.getStatus().getResult().getFinished() == FinalResult.FAILURE) { + actionStatus.setStatus(Status.ERROR); + } else { + actionStatus.setStatus(Status.CANCELED); + } + } + private Action findActionWithExceptionIfNotFound(final Long actionId) { final Action findAction = controllerManagement.findActionWithDetails(actionId); if (findAction == null) { diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/ActionFeedback.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/ActionFeedback.java old mode 100755 new mode 100644 index 0faed14c1..3fe511e49 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/ActionFeedback.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/ActionFeedback.java @@ -10,15 +10,10 @@ package org.eclipse.hawkbit.controller.model; import javax.validation.constraints.NotNull; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * *

@@ -38,23 +33,12 @@ import io.swagger.annotations.ApiModelProperty; * "success", "progress": {} } "details": [], } } *

* - * - * - * - * - * */ @JsonIgnoreProperties(ignoreUnknown = true) -@ApiModel("SP Target Action Feedback") public class ActionFeedback { - - @ApiModelProperty(value = ApiModelProperties.ACTION_ID) private final Long id; - - @ApiModelProperty(value = ApiModelProperties.TARGET_TIME) private final String time; - @ApiModelProperty(value = ApiModelProperties.TARGET_STATUS, required = true) @NotNull private final Status status; @@ -90,7 +74,7 @@ public class ActionFeedback { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Artifact.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Artifact.java old mode 100755 new mode 100644 index a5efc009d..b995491d9 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Artifact.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Artifact.java @@ -11,34 +11,23 @@ package org.eclipse.hawkbit.controller.model; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.rest.resource.model.artifact.ArtifactHash; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import org.springframework.hateoas.ResourceSupport; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Download information for all artifacts related to a specific {@link Chunk}. * - * - * - * */ -@ApiModel(ApiModelProperties.ARTIFACTS) public class Artifact extends ResourceSupport { - @ApiModelProperty(value = ApiModelProperties.ARTIFACT_PROVIDED_FILENAME, required = true) @NotNull @JsonProperty private String filename; - @ApiModelProperty(value = ApiModelProperties.ARTIFACT_HASHES) @JsonProperty private ArtifactHash hashes; - @ApiModelProperty(value = ApiModelProperties.ARTIFACT_SIZE) @JsonProperty private Long size; diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Cancel.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Cancel.java old mode 100755 new mode 100644 index 0d76f54ae..77055828f --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Cancel.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Cancel.java @@ -10,29 +10,19 @@ package org.eclipse.hawkbit.controller.model; import javax.validation.constraints.NotNull; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Cancel action to be provided to the target. * - * - * */ -@ApiModel("SP Target Cancel Action") public class Cancel { - @ApiModelProperty(value = ApiModelProperties.ACTION_ID) private final String id; - @ApiModelProperty(value = ApiModelProperties.CANCEL_ACTION, required = true) @NotNull private final CancelActionToStop cancelAction; /** * Parameterized constructor. - * + * * @param id * of the {@link CancelAction} * @param cancelAction @@ -60,7 +50,7 @@ public class Cancel { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/CancelActionToStop.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/CancelActionToStop.java old mode 100755 new mode 100644 index e251aa692..9b954aa57 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/CancelActionToStop.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/CancelActionToStop.java @@ -11,27 +11,19 @@ package org.eclipse.hawkbit.controller.model; import javax.validation.constraints.NotNull; import org.eclipse.hawkbit.repository.model.Action; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; /** * The {@link Action} that has to be stopped by the target. * - * - * */ -@ApiModel(ApiModelProperties.CANCEL_ACTION) public class CancelActionToStop { - @ApiModelProperty(value = ApiModelProperties.ACTION_ID, required = true) @NotNull private final String stopId; /** * Parameterized constructor. - * + * * @param stopId * ID of the {@link Action} to be stoppedW */ @@ -49,7 +41,7 @@ public class CancelActionToStop { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Chunk.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Chunk.java old mode 100755 new mode 100644 index 8d77da1c4..66809bfbb --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Chunk.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Chunk.java @@ -12,35 +12,21 @@ import java.util.List; import javax.validation.constraints.NotNull; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Deployment chunks. * - * - * - * - * */ -@ApiModel(ApiModelProperties.CHUNK) public class Chunk { - @ApiModelProperty(value = ApiModelProperties.CHUNK_TYPE, required = true) @NotNull private final String part; - @ApiModelProperty(value = ApiModelProperties.CHUNK_VERSION, required = true) @NotNull private final String version; - @ApiModelProperty(value = ApiModelProperties.CHUNK_NAME, required = true) @NotNull private final String name; - @ApiModelProperty(value = ApiModelProperties.ARTIFACTS) private final List artifacts; /** diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Config.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Config.java old mode 100755 new mode 100644 index 3bfeb95af..62907b26d --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Config.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Config.java @@ -8,23 +8,12 @@ */ package org.eclipse.hawkbit.controller.model; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Standard configuration for the target. * - * - * - * - * */ -@ApiModel(ApiModelProperties.TARGET_CONFIGURATION) public class Config { - @ApiModelProperty(value = ApiModelProperties.TARGET_POLL_TIME) private final Polling polling; /** diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/ConfigData.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/ConfigData.java old mode 100755 new mode 100644 index 574b3c401..b7c330167 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/ConfigData.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/ConfigData.java @@ -10,27 +10,17 @@ package org.eclipse.hawkbit.controller.model; import java.util.Map; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import org.hibernate.validator.constraints.NotEmpty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** - * feedback channel for ConfigData action. - * - * - * - * + * Feedback channel for ConfigData action. * */ -@ApiModel("Configuration or metadata that is reponded by the target") public class ConfigData extends ActionFeedback { - @ApiModelProperty(ApiModelProperties.TARGET_CONFIG_DATA) @NotEmpty private final Map data; @@ -64,7 +54,7 @@ public class ConfigData extends ActionFeedback { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/ControllerBase.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/ControllerBase.java old mode 100755 new mode 100644 index 47bf11482..d319bcf11 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/ControllerBase.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/ControllerBase.java @@ -8,24 +8,14 @@ */ package org.eclipse.hawkbit.controller.model; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import org.springframework.hateoas.ResourceSupport; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** - * {@link ControllerBase} ressource content. - * - * - * - * + * {@link ControllerBase} resource content. * */ -@ApiModel("SP target base poll resource") public class ControllerBase extends ResourceSupport { - @ApiModelProperty(ApiModelProperties.TARGET_CONFIGURATION) private final Config config; /** diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Deployment.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Deployment.java old mode 100755 new mode 100644 index d7c8b22a7..57ead963c --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Deployment.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Deployment.java @@ -11,31 +11,19 @@ package org.eclipse.hawkbit.controller.model; import java.util.List; import org.eclipse.hawkbit.repository.model.Action; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Detailed {@link UpdateAction} information. * - * - * - * - * */ -@ApiModel(ApiModelProperties.DEPLOYMENT) public class Deployment { - @ApiModelProperty(value = ApiModelProperties.HANDLING_DOWNLOAD) private final HandlingType download; - @ApiModelProperty(value = ApiModelProperties.HANDLING_UPDATE) private final HandlingType update; - @ApiModelProperty(value = ApiModelProperties.CHUNK) private final List chunks; /** @@ -70,12 +58,7 @@ public class Deployment { /** * The handling type for the update {@link Action}. * - * - * - * - * */ - @ApiModel("Handling type for the deployment part") public enum HandlingType { /** * Not necessary for the command. @@ -109,7 +92,7 @@ public class Deployment { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/DeploymentBase.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/DeploymentBase.java old mode 100755 new mode 100644 index 687765c13..ea3e1caa5 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/DeploymentBase.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/DeploymentBase.java @@ -10,31 +10,20 @@ package org.eclipse.hawkbit.controller.model; import javax.validation.constraints.NotNull; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import org.springframework.hateoas.ResourceSupport; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** - * {@link UpdateAction} ressource. - * - * - * - * + * {@link UpdateAction} resource. * */ -@ApiModel("Deployment or update action") public class DeploymentBase extends ResourceSupport { - @ApiModelProperty(value = ApiModelProperties.ITEM_ID, required = false) @JsonProperty("id") @NotNull private final String deplyomentId; - @ApiModelProperty(value = ApiModelProperties.DEPLOYMENT, required = false) @NotNull private final Deployment deployment; @@ -57,7 +46,7 @@ public class DeploymentBase extends ResourceSupport { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Polling.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Polling.java old mode 100755 new mode 100644 index a7248659d..4e0854d98 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Polling.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Polling.java @@ -8,23 +8,12 @@ */ package org.eclipse.hawkbit.controller.model; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Polling interval for the SP target. * - * - * - * - * */ -@ApiModel(value = ApiModelProperties.TARGET_POLL_TIME) public class Polling { - @ApiModelProperty(value = ApiModelProperties.TARGET_SLEEP) private final String sleep; /** diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Progress.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Progress.java old mode 100755 new mode 100644 index cd0f067b5..096231c7b --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Progress.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Progress.java @@ -10,31 +10,19 @@ package org.eclipse.hawkbit.controller.model; import javax.validation.constraints.NotNull; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Action fulfillment progress by means of gives the achieved amount of maximal * of possible levels. * - * - * - * - * */ -@ApiModel(ApiModelProperties.TARGET_RESULT_PROGRESS) public class Progress { - @ApiModelProperty(value = ApiModelProperties.TARGET_PROGRESS_CNT, required = true) @NotNull private final Integer cnt; - @ApiModelProperty(value = ApiModelProperties.TARGET_PROGRESS_OF) private final Integer of; /** @@ -62,7 +50,7 @@ public class Progress { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Result.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Result.java old mode 100755 new mode 100644 index f84da7a25..b5dd22aaa --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Result.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Result.java @@ -8,33 +8,23 @@ */ package org.eclipse.hawkbit.controller.model; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; import org.hibernate.validator.constraints.NotEmpty; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Result information of the action progress which can by an intermediate or * final update. * * - * - * - * */ -@ApiModel(ApiModelProperties.TARGET_RESULT_VALUE) public class Result { - @ApiModelProperty(value = ApiModelProperties.TARGET_RESULT_FINISHED, required = true) @NotEmpty private final FinalResult finished; - @ApiModelProperty(value = ApiModelProperties.TARGET_RESULT_PROGRESS) private final Progress progress; /** @@ -64,12 +54,7 @@ public class Result { /** * Defined status of the final result. * - * - * - * - * */ - @ApiModel(value = ApiModelProperties.TARGET_RESULT_FINISHED) public enum FinalResult { /** * Execution was successful. @@ -104,7 +89,7 @@ public class Result { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/SoftwareModule.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/SoftwareModule.java deleted file mode 100755 index 78e076b87..000000000 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/SoftwareModule.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * 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.controller.model; - -import java.util.List; - -import javax.validation.constraints.NotNull; - -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; -import org.springframework.hateoas.Link; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -/** - * - * - * - */ -@ApiModel(ApiModelProperties.SOFTWARE_MODUL) -public class SoftwareModule { - - @ApiModelProperty(value = ApiModelProperties.SOFTWARE_MODUL_TYPE, required = true) - @NotNull - private final Long id; - - @ApiModelProperty(value = ApiModelProperties.SOFTWARE_MODUL_TYPE, required = true) - @NotNull - private final String type; - - @ApiModelProperty(value = ApiModelProperties.SOFTWARE_MODULE_VERSION, required = true) - @NotNull - private final String version; - - @ApiModelProperty(value = ApiModelProperties.SOFTWARE_MODULE_NAME, required = true) - @NotNull - private final String name; - - @ApiModelProperty(value = ApiModelProperties.SOFTWARE_MODULE_ARTIFACT_LINKS) - private final List artifactLinks; - - /** - * Constructor. - * - * @param id - * of the software module - * @param type - * of the deployment software module - * @param version - * of the software module - * @param name - * of the software module - * @param artifactLinks - * the links to the artifacts of the software module - */ - public SoftwareModule(final Long id, final String type, final String version, final String name, - final List artifactLinks) { - this.id = id; - this.type = type; - this.version = version; - this.name = name; - this.artifactLinks = artifactLinks; - } - - @JsonProperty("links") - public List getArtifactLinks() { - return artifactLinks; - } - - public Long getId() { - return id; - } - - public String getType() { - return type; - } - - public String getVersion() { - return version; - } - - public String getName() { - return name; - } - -} diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Status.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Status.java old mode 100755 new mode 100644 index df88ace73..df1622e31 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Status.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/controller/model/Status.java @@ -12,35 +12,22 @@ import java.util.List; import javax.validation.constraints.NotNull; -import org.eclipse.hawkbit.rest.resource.model.doc.ApiModelProperties; - import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonValue; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - /** * Details status information concerning the action processing. * - * - * - * - * */ -@ApiModel(ApiModelProperties.TARGET_STATUS) public class Status { - @ApiModelProperty(value = ApiModelProperties.TARGET_EXEC_STATUS, required = true) @NotNull private final ExecutionStatus execution; - @ApiModelProperty(value = ApiModelProperties.TARGET_RESULT_VALUE, required = true) @NotNull private final Result result; - @ApiModelProperty(value = ApiModelProperties.TARGET_RESULT_DETAILS) private final List details; /** @@ -78,12 +65,7 @@ public class Status { * The element status contains information about the execution of the * operation. * - * - * - * - * */ - @ApiModel(ApiModelProperties.TARGET_EXEC_STATUS) public enum ExecutionStatus { /** * Execution of the action has finished. @@ -132,7 +114,7 @@ public class Status { /* * (non-Javadoc) - * + * * @see java.lang.Object#toString() */ @Override diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetMapper.java old mode 100755 new mode 100644 index b763e268b..95924721e --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetMapper.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetMapper.java @@ -23,7 +23,7 @@ import org.eclipse.hawkbit.repository.model.DistributionSetMetadata; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.rest.resource.model.MetadataRest; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyCreate; +import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyPost; import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest; import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetsRest; import org.eclipse.hawkbit.rest.resource.model.distributionset.TargetAssignmentResponseBody; @@ -36,7 +36,7 @@ import org.eclipse.hawkbit.rest.resource.model.distributionset.TargetAssignmentR * * */ -final class DistributionSetMapper { +public final class DistributionSetMapper { private DistributionSetMapper() { // Utility class } @@ -57,14 +57,14 @@ final class DistributionSetMapper { final DistributionSetType module = distributionSetManagement .findDistributionSetTypeByKey(distributionSetTypekey); if (module == null) { - throw new EntityNotFoundException( - "DistributionSetType with key {" + distributionSetTypekey + "} does not exist"); + throw new EntityNotFoundException("DistributionSetType with key {" + distributionSetTypekey + + "} does not exist"); } return module; } /** - * {@link DistributionSetRequestBodyCreate}s to {@link DistributionSet}s. + * {@link DistributionSetRequestBodyPost}s to {@link DistributionSet}s. * * @param sets * to convert @@ -72,11 +72,11 @@ final class DistributionSetMapper { * to use for conversion * @return converted list of {@link DistributionSet}s */ - static List dsFromRequest(final Iterable sets, + static List dsFromRequest(final Iterable sets, final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement) { final List mappedList = new ArrayList<>(); - for (final DistributionSetRequestBodyCreate dsRest : sets) { + for (final DistributionSetRequestBodyPost dsRest : sets) { mappedList.add(fromRequest(dsRest, softwareManagement, distributionSetManagement)); } return mappedList; @@ -84,7 +84,7 @@ final class DistributionSetMapper { } /** - * {@link DistributionSetRequestBodyCreate} to {@link DistributionSet}. + * {@link DistributionSetRequestBodyPost} to {@link DistributionSet}. * * @param dsRest * to convert @@ -92,7 +92,7 @@ final class DistributionSetMapper { * to use for conversion * @return converted {@link DistributionSet} */ - static DistributionSet fromRequest(final DistributionSetRequestBodyCreate dsRest, + static DistributionSet fromRequest(final DistributionSetRequestBodyPost dsRest, final SoftwareManagement softwareManagement, final DistributionSetManagement distributionSetManagement) { final DistributionSet result = new DistributionSet(); @@ -108,18 +108,18 @@ final class DistributionSetMapper { } if (dsRest.getApplication() != null) { - result.addModule( - findSoftwareModuleWithExceptionIfNotFound(dsRest.getApplication().getId(), softwareManagement)); + result.addModule(findSoftwareModuleWithExceptionIfNotFound(dsRest.getApplication().getId(), + softwareManagement)); } if (dsRest.getRuntime() != null) { - result.addModule( - findSoftwareModuleWithExceptionIfNotFound(dsRest.getRuntime().getId(), softwareManagement)); + result.addModule(findSoftwareModuleWithExceptionIfNotFound(dsRest.getRuntime().getId(), softwareManagement)); } if (dsRest.getModules() != null) { - dsRest.getModules().forEach(module -> result - .addModule(findSoftwareModuleWithExceptionIfNotFound(module.getId(), softwareManagement))); + dsRest.getModules().forEach( + module -> result.addModule(findSoftwareModuleWithExceptionIfNotFound(module.getId(), + softwareManagement))); } return result; @@ -144,7 +144,14 @@ final class DistributionSetMapper { return mappedList; } - static DistributionSetRest toResponse(final DistributionSet distributionSet) { + /** + * Create a response for distribution set. + * + * @param distributionSet + * the ds set + * @return the response + */ + public static DistributionSetRest toResponse(final DistributionSet distributionSet) { if (distributionSet == null) { return null; } @@ -156,22 +163,23 @@ final class DistributionSetMapper { response.setComplete(distributionSet.isComplete()); response.setType(distributionSet.getType().getKey()); - distributionSet.getModules() - .forEach(module -> response.getModules().add(SoftwareModuleMapper.toResponse(module))); + distributionSet.getModules().forEach( + module -> response.getModules().add(SoftwareModuleMapper.toResponse(module))); response.setRequiredMigrationStep(distributionSet.isRequiredMigrationStep()); - response.add( - linkTo(methodOn(DistributionSetResource.class).getDistributionSet(response.getDsId())).withRel("self")); + response.add(linkTo(methodOn(DistributionSetResource.class).getDistributionSet(response.getDsId())).withRel( + "self")); response.add(linkTo( methodOn(DistributionSetTypeResource.class).getDistributionSetType(distributionSet.getType().getId())) - .withRel("type")); + .withRel("type")); - response.add(linkTo(methodOn(DistributionSetResource.class).getMetadata(response.getDsId(), - Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET), - Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)) - .withRel("metadata")); + response.add(linkTo( + methodOn(DistributionSetResource.class).getMetadata(response.getDsId(), + Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET), + Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)).withRel( + "metadata")); return response; } @@ -186,8 +194,11 @@ final class DistributionSetMapper { static DistributionSetsRest toResponseDistributionSets(final Iterable sets) { final DistributionSetsRest response = new DistributionSetsRest(); - for (final DistributionSet set : sets) { - response.add(toResponse(set)); + if (sets != null) { + + for (final DistributionSet set : sets) { + response.add(toResponse(set)); + } } return response; } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetResource.java old mode 100755 new mode 100644 index 3f7f28201..500f0a786 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetResource.java @@ -8,12 +8,6 @@ */ package org.eclipse.hawkbit.rest.resource; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - import java.util.HashSet; import java.util.List; import java.util.Set; @@ -21,7 +15,6 @@ import java.util.stream.Collectors; import javax.persistence.EntityManager; -import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.DistributionSetAssignmentResult; import org.eclipse.hawkbit.repository.DistributionSetFields; @@ -40,19 +33,17 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.rsql.RSQLUtility; import org.eclipse.hawkbit.rest.resource.helper.RestResourceConversionHelper; -import org.eclipse.hawkbit.rest.resource.model.ExceptionInfo; import org.eclipse.hawkbit.rest.resource.model.MetadataRest; import org.eclipse.hawkbit.rest.resource.model.MetadataRestPageList; import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetPagedList; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyCreate; -import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyUpdate; +import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyPost; +import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRequestBodyPut; import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetRest; import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetsRest; import org.eclipse.hawkbit.rest.resource.model.distributionset.TargetAssignmentRequestBody; import org.eclipse.hawkbit.rest.resource.model.distributionset.TargetAssignmentResponseBody; import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleAssigmentRest; import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModulePagedList; -import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModuleRest; import org.eclipse.hawkbit.rest.resource.model.target.TargetPagedList; import org.eclipse.hawkbit.tenancy.TenantAware; import org.slf4j.Logger; @@ -64,7 +55,6 @@ import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -80,9 +70,7 @@ import org.springframework.web.bind.annotation.RestController; * */ @RestController -@Transactional(readOnly = true) @RequestMapping(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) -@Api(value = "distributionsets", description = "Distribution Set Management API") public class DistributionSetResource { private static final Logger LOG = LoggerFactory.getLogger(DistributionSetResource.class); @@ -128,18 +116,11 @@ public class DistributionSetResource { * JsonResponseExceptionHandler is handling the response. */ @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = DistributionSetPagedList.class, value = "Get paged list of Distribution Sets", notes = "Handles the GET request of retrieving all distribution sets within SP. Required Permission: " - + SpPermission.READ_REPOSITORY) public ResponseEntity getDistributionSets( @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @ApiParam(required = false, value = "FIQL syntax search query" - + "" - + "" - + "" - + "" - + "
version==1.0.0distribution sets with version 1.0.0
version=ge=2.0.0distribution sets with version greater-equal 2.0.0
name=li=%25hotfix%25,description=li=%25hotfix%25distribution sets with either 'hotfix' in name or description ignore case
") @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { + @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); @@ -172,12 +153,10 @@ public class DistributionSetResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = DistributionSetRest.class, value = "Get Distribution Set", notes = "Handles the GET request of retrieving a single distribution set within SP. Required Permission: " - + SpPermission.READ_REPOSITORY) public ResponseEntity getDistributionSet(@PathVariable final Long distributionSetId) { final DistributionSet foundDs = findDistributionSetWithExceptionIfNotFound(distributionSetId); - return new ResponseEntity(DistributionSetMapper.toResponse(foundDs), HttpStatus.OK); + return new ResponseEntity<>(DistributionSetMapper.toResponse(foundDs), HttpStatus.OK); } /** @@ -192,29 +171,18 @@ public class DistributionSetResource { * failure the JsonResponseExceptionHandler is handling the * response. */ - @RequestMapping(method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }, produces = { - "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = DistributionSetsRest.class, value = "Create Distribution Sets", notes = "Handles the POST request of creating new distribution sets within SP. The request body must always be a list of sets. Required Permission: " - + SpPermission.CREATE_REPOSITORY) - @ApiResponses(@ApiResponse(code = 409, message = "Conflict", response = ExceptionInfo.class)) - @Transactional + @RequestMapping(method = RequestMethod.POST, consumes = { MediaType.APPLICATION_JSON_VALUE, + "application/hal+json" }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity createDistributionSets( - @RequestBody final List sets) { + @RequestBody final List sets) { LOG.debug("creating {} distribution sets", sets.size()); // set default Ds type if ds type is null - sets.stream() - .filter(ds -> ds.getType() == null) - .forEach( - ds -> ds.setType(systemManagement.getTenantMetadata(currentTenant.getCurrentTenant()) - .getDefaultDsType().getKey())); + sets.stream().filter(ds -> ds.getType() == null).forEach(ds -> ds.setType( + systemManagement.getTenantMetadata(currentTenant.getCurrentTenant()).getDefaultDsType().getKey())); - final Iterable createdDSets = distributionSetManagement - .createDistributionSets(DistributionSetMapper.dsFromRequest(sets, softwareManagement, - distributionSetManagement)); - - // we flush to ensure that entity is generated and we can return ID etc. - entityManager.flush(); + final Iterable createdDSets = distributionSetManagement.createDistributionSets( + DistributionSetMapper.dsFromRequest(sets, softwareManagement, distributionSetManagement)); LOG.debug("{} distribution sets created, return status {}", sets.size(), HttpStatus.CREATED); return new ResponseEntity<>(DistributionSetMapper.toResponseDistributionSets(createdDSets), HttpStatus.CREATED); @@ -230,10 +198,6 @@ public class DistributionSetResource { * */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetId}") - @ApiOperation(value = "Delete Distribution Set", notes = "Handles the DELETE request for a single Distribution Set within SP. Required Permission: " - + SpPermission.DELETE_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Distribution Set", response = ExceptionInfo.class)) - @Transactional public ResponseEntity deleteDistributionSet(@PathVariable final Long distributionSetId) { final DistributionSet set = findDistributionSetWithExceptionIfNotFound(distributionSetId); @@ -256,12 +220,8 @@ public class DistributionSetResource { */ @RequestMapping(method = RequestMethod.PUT, value = "/{distributionSetId}", consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - @ApiOperation(response = DistributionSetRest.class, value = "Update Distribution Set", notes = "Handles the UPDATE request for a single Distribution Set within SP. Required Permission: " - + SpPermission.UPDATE_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Distribution Set", response = ExceptionInfo.class)) - @Transactional public ResponseEntity updateDistributionSet(@PathVariable final Long distributionSetId, - @RequestBody final DistributionSetRequestBodyUpdate toUpdate) { + @RequestBody final DistributionSetRequestBodyPut toUpdate) { final DistributionSet set = findDistributionSetWithExceptionIfNotFound(distributionSetId); if (toUpdate.getDescription() != null) { @@ -275,18 +235,14 @@ public class DistributionSetResource { if (toUpdate.getVersion() != null) { set.setVersion(toUpdate.getVersion()); } - - // we flush to ensure that entity is generated and we can return ID etc. - entityManager.flush(); - - return new ResponseEntity(DistributionSetMapper.toResponse(distributionSetManagement - .updateDistributionSet(set)), HttpStatus.OK); + return new ResponseEntity<>( + DistributionSetMapper.toResponse(distributionSetManagement.updateDistributionSet(set)), HttpStatus.OK); } /** * Handles the GET request of retrieving assigned targets to a specific * distribution set. - * + * * @param distributionSetId * the ID of the distribution set to retrieve the assigned * targets @@ -307,18 +263,11 @@ public class DistributionSetResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/assignedTargets", produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - @ApiOperation(response = TargetPagedList.class, value = "Get assigned targets", notes = "Handles the GET request for retrieving assigned targets of a single distribution set. Required Permission: " - + SpPermission.READ_REPOSITORY + " and " + SpPermission.READ_TARGET) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Distribution Set", response = ExceptionInfo.class)) - public ResponseEntity getAssignedTargets( - @PathVariable final Long distributionSetId, + public ResponseEntity getAssignedTargets(@PathVariable final Long distributionSetId, @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @ApiParam(required = false, value = "FIQL syntax search query" + "" - + "" - + "" - + "
controllerId==0815targets with the id '0815'
name=li=%25ccu%25targets which contains 'ccu' in their ignore case
") @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { + @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { // check if distribution set exists otherwise throw exception // immediately @@ -344,7 +293,7 @@ public class DistributionSetResource { /** * Handles the GET request of retrieving installed targets to a specific * distribution set. - * + * * @param distributionSetId * the ID of the distribution set to retrieve the assigned * targets @@ -365,18 +314,11 @@ public class DistributionSetResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/installedTargets", produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - @ApiOperation(response = TargetPagedList.class, value = "Get installed targets", notes = "Handles the GET request for retrieving installed targets of a single distribution set. Required Permission: " - + SpPermission.READ_REPOSITORY + " and " + SpPermission.READ_TARGET) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Distribution Set", response = ExceptionInfo.class)) - public ResponseEntity getInstalledTargets( - @PathVariable final Long distributionSetId, + public ResponseEntity getInstalledTargets(@PathVariable final Long distributionSetId, @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @ApiParam(required = false, value = "FIQL syntax search query" + "" - + "" - + "" - + "
controllerId==0815targets with the id '0815'
name=li=%25ccu%25targets which contains 'ccu' in their ignore case
") @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { + @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { // check if distribution set exists otherwise throw exception // immediately findDistributionSetWithExceptionIfNotFound(distributionSetId); @@ -401,7 +343,7 @@ public class DistributionSetResource { /** * Handles the POST request of assigning multiple targets to a single * distribution set. - * + * * @param distributionSetId * the ID of the distribution set within the URL path parameter * @param targetIds @@ -412,33 +354,24 @@ public class DistributionSetResource { * targets and the already assigned targets counters */ @RequestMapping(method = RequestMethod.POST, value = "/{distributionSetId}/assignedTargets", consumes = { - "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE, - "application/hal+json" }) - @ApiOperation(response = TargetAssignmentResponseBody.class, value = "Assign targets to a distribution set", notes = "Handles the POST request for assigning multiple targets to a distribution set.The request body must always be a list of target IDs." - + " Required Permission: " + SpPermission.READ_REPOSITORY + " and " + SpPermission.UPDATE_TARGET) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Distribution Set", response = ExceptionInfo.class)) - @Transactional - public ResponseEntity createAssignedTarget( - @PathVariable final Long distributionSetId, - @RequestBody @ApiParam(value = "List of target IDs", required = true) final List targetIds) { + "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) + public ResponseEntity createAssignedTarget(@PathVariable final Long distributionSetId, + @RequestBody final List targetIds) { final DistributionSetAssignmentResult assignDistributionSet = deployManagament.assignDistributionSet( distributionSetId, - targetIds - .stream() - .map(t -> new TargetWithActionType(t.getId(), RestResourceConversionHelper.convertActionType(t - .getType()), t.getForcetime())).collect(Collectors.toList())); + targetIds.stream() + .map(t -> new TargetWithActionType(t.getId(), + RestResourceConversionHelper.convertActionType(t.getType()), t.getForcetime())) + .collect(Collectors.toList())); - // we flush to ensure that entity is generated and we can return ID etc. - entityManager.flush(); - - return new ResponseEntity( - DistributionSetMapper.toResponse(assignDistributionSet), HttpStatus.OK); + return new ResponseEntity<>(DistributionSetMapper.toResponse(assignDistributionSet), HttpStatus.OK); } /** * Gets a paged list of meta data for a distribution set. - * + * * @param distributionSetId * the ID of the distribution set for the meta data * @param pagingOffsetParam @@ -458,20 +391,11 @@ public class DistributionSetResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/metadata", produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - @ApiOperation(response = MetadataRestPageList.class, value = "Get a paged list of meta data", notes = " Get a paged list of meta data for a distribution set." - + " Required Permission: " + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Distribution Set", response = ExceptionInfo.class)) - @Transactional - public ResponseEntity getMetadata( - @PathVariable final Long distributionSetId, + public ResponseEntity getMetadata(@PathVariable final Long distributionSetId, @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @ApiParam(required = false, value = "FIQL syntax search query" - + "" - + "" - + "" - + "
key==aKey,key==bKeymetadata with the key 'aKey' or 'bKey'
value=li=%25someValue%25metadata which contains 'someValue' in the value ignore case
") @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { + @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { // check if distribution set exists otherwise throw exception // immediately @@ -492,14 +416,16 @@ public class DistributionSetResource { pageable); } - return new ResponseEntity<>(new MetadataRestPageList(DistributionSetMapper.toResponseDsMetadata(metaDataPage - .getContent()), metaDataPage.getTotalElements()), HttpStatus.OK); + return new ResponseEntity<>( + new MetadataRestPageList(DistributionSetMapper.toResponseDsMetadata(metaDataPage.getContent()), + metaDataPage.getTotalElements()), + HttpStatus.OK); } /** * Gets a single meta data value for a specific key of a distribution set. - * + * * @param distributionSetId * the ID of the distribution set to get the meta data from * @param metadataKey @@ -507,24 +433,21 @@ public class DistributionSetResource { * @return status OK if get request is successful with the value of the meta * data */ - @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/metadata/{metadataKey}", produces = { MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = MetadataRest.class, value = "Get a single meta data value", notes = " Get a single meta data value for a meta data key." - + " Required Permission: " + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Distribution Set or meta data key", response = ExceptionInfo.class)) - @Transactional + @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/metadata/{metadataKey}", produces = { + MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity getMetadataValue(@PathVariable final Long distributionSetId, @PathVariable final String metadataKey) { // check if distribution set exists otherwise throw exception // immediately final DistributionSet ds = findDistributionSetWithExceptionIfNotFound(distributionSetId); - final DistributionSetMetadata findOne = distributionSetManagement.findOne(new DsMetadataCompositeKey(ds, - metadataKey)); + final DistributionSetMetadata findOne = distributionSetManagement + .findOne(new DsMetadataCompositeKey(ds, metadataKey)); return ResponseEntity. ok(DistributionSetMapper.toResponseDsMetadata(findOne)); } /** * Updates a single meta data value of a distribution set. - * + * * @param distributionSetId * the ID of the distribution set to update the meta data entry * @param metadataKey @@ -534,10 +457,6 @@ public class DistributionSetResource { */ @RequestMapping(method = RequestMethod.PUT, value = "/{distributionSetId}/metadata/{metadataKey}", produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - @ApiOperation(response = MetadataRest.class, value = "Update a single meta data value", notes = " Update a single meta data value for speficic key." - + " Required Permission: " + SpPermission.UPDATE_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Distribution Set or meta data key", response = ExceptionInfo.class)) - @Transactional public ResponseEntity updateMetadata(@PathVariable final Long distributionSetId, @PathVariable final String metadataKey, @RequestBody final MetadataRest metadata) { // check if distribution set exists otherwise throw exception @@ -550,7 +469,7 @@ public class DistributionSetResource { /** * Deletes a single meta data entry from the distribution set. - * + * * @param distributionSetId * the ID of the distribution set to delete the meta data entry * @param metadataKey @@ -558,10 +477,6 @@ public class DistributionSetResource { * @return status OK if the delete request is successful */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetId}/metadata/{metadataKey}") - @ApiOperation(value = "Delete a single meta data", notes = " Delete a single meta data." + " Required Permission: " - + SpPermission.UPDATE_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Distribution Set or meta data key", response = ExceptionInfo.class)) - @Transactional public ResponseEntity deleteMetadata(@PathVariable final Long distributionSetId, @PathVariable final String metadataKey) { // check if distribution set exists otherwise throw exception @@ -573,7 +488,7 @@ public class DistributionSetResource { /** * Creates a list of meta data for a specific distribution set. - * + * * @param distributionSetId * the ID of the distribution set to create meta data for * @param metadataRest @@ -582,13 +497,8 @@ public class DistributionSetResource { * the created meta data */ @RequestMapping(method = RequestMethod.POST, value = "/{distributionSetId}/metadata", consumes = { - MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }, produces = { MediaType.APPLICATION_JSON_VALUE, - "application/hal+json" }) - @ApiOperation(response = MetadataRest.class, value = "Create a list of meta data entries", notes = "Create a list of meta data entries" - + " Required Permission: " + SpPermission.READ_REPOSITORY + " and " + SpPermission.UPDATE_TARGET) - @ApiResponses({ @ApiResponse(code = 409, message = "Conflict", response = ExceptionInfo.class), - @ApiResponse(code = 404, message = "Not Found Distribution Set", response = ExceptionInfo.class) }) - @Transactional + MediaType.APPLICATION_JSON_VALUE, + "application/hal+json" }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) public ResponseEntity> createMetadata(@PathVariable final Long distributionSetId, @RequestBody final List metadataRest) { // check if distribution set exists otherwise throw exception @@ -597,44 +507,33 @@ public class DistributionSetResource { final List created = distributionSetManagement .createDistributionSetMetadata(DistributionSetMapper.fromRequestDsMetadata(ds, metadataRest)); - - // we flush to ensure that entity is generated and we can return ID etc. - entityManager.flush(); - - return new ResponseEntity>(DistributionSetMapper.toResponseDsMetadata(created), - HttpStatus.CREATED); + return new ResponseEntity<>(DistributionSetMapper.toResponseDsMetadata(created), HttpStatus.CREATED); } /** * Assigns a list of software modules to a distribution set. - * + * * @param distributionSetId * the ID of the distribution set to assign software modules for * @param softwareModuleIDs * the list of software modules ids to assign * @return {@link HttpStatus#OK} - * + * * @throws EntityNotFoundException * in case no distribution set with the given * {@code distributionSetId} exists. */ @RequestMapping(method = RequestMethod.POST, value = "/{distributionSetId}/assignedSM", consumes = { - MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }, produces = { "application/hal+json", - MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = SoftwareModuleRest.class, value = "Assign Software Modules to Distribution Set", notes = "Handles the POST request for assigning multiple software modules to a distribution set.The request body must always be a list of software module IDs." - + " Required Permission: " + SpPermission.READ_REPOSITORY + " and " + SpPermission.UPDATE_REPOSITORY) - @ApiResponses({ - @ApiResponse(code = 423, message = "In use of Distribution Set by Target", response = ExceptionInfo.class), - @ApiResponse(code = 404, message = "Not Found Distribution Set key or Software Module IDs", response = ExceptionInfo.class) }) - @Transactional + MediaType.APPLICATION_JSON_VALUE, + "application/hal+json" }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity assignSoftwareModules(@PathVariable final Long distributionSetId, @RequestBody final List softwareModuleIDs) { // check if distribution set exists otherwise throw exception // immediately final DistributionSet ds = findDistributionSetWithExceptionIfNotFound(distributionSetId); - final Set softwareModuleToBeAssigned = new HashSet(); + final Set softwareModuleToBeAssigned = new HashSet<>(); for (final SoftwareModuleAssigmentRest sm : softwareModuleIDs) { final SoftwareModule softwareModule = softwareManagement.findSoftwareModuleById(sm.getId()); if (softwareModule != null) { @@ -650,7 +549,7 @@ public class DistributionSetResource { /** * Deletes the assignment of the software module form the distribution set. - * + * * @param distributionSetId * the ID of the distribution set to reject the software module * for @@ -663,12 +562,6 @@ public class DistributionSetResource { * {@code distributionSetId} exists. */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetId}/assignedSM/{softwareModuleId}") - @ApiOperation(value = "Delete assignment of Software Module", notes = " Delete a assignment." - + " Required Permission: " + SpPermission.UPDATE_REPOSITORY) - @ApiResponses({ - @ApiResponse(code = 423, message = "In use of Distribution Set by Target", response = ExceptionInfo.class), - @ApiResponse(code = 404, message = "Not Found Distribution Set key or Software Module key", response = ExceptionInfo.class) }) - @Transactional public ResponseEntity deleteAssignSoftwareModules(@PathVariable final Long distributionSetId, @PathVariable final Long softwareModuleId) { // check if distribution set and software module exist otherwise throw @@ -682,7 +575,7 @@ public class DistributionSetResource { /** * Handles the GET request for retrieving the assigned software modules of a * specific distribution set. - * + * * @param distributionSetId * the ID of the distribution to retrieve * @param pagingOffsetParam @@ -702,8 +595,6 @@ public class DistributionSetResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetId}/assignedSM", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = SoftwareModuleRest.class, value = "Get assigned Software Modules", notes = "Handles the GET request of retrieving a single distribution set within SP. Required Permission: " - + SpPermission.READ_REPOSITORY) public ResponseEntity getAssignedSoftwareModules( @PathVariable final Long distributionSetId, @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, @@ -718,8 +609,10 @@ public class DistributionSetResource { final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); final Page softwaremodules = softwareManagement.findSoftwareModuleByAssignedTo(pageable, foundDs); - return new ResponseEntity<>(new SoftwareModulePagedList(SoftwareModuleMapper.toResponse(softwaremodules - .getContent()), softwaremodules.getTotalElements()), HttpStatus.OK); + return new ResponseEntity<>( + new SoftwareModulePagedList(SoftwareModuleMapper.toResponse(softwaremodules.getContent()), + softwaremodules.getTotalElements()), + HttpStatus.OK); } private DistributionSet findDistributionSetWithExceptionIfNotFound(final Long distributionSetId) { diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTagResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTagResource.java new file mode 100644 index 000000000..43830e803 --- /dev/null +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTagResource.java @@ -0,0 +1,351 @@ +/** + * 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.rest.resource; + +import java.util.List; +import java.util.stream.Collectors; + +import javax.persistence.EntityManager; + +import org.eclipse.hawkbit.repository.DistributionSetManagement; +import org.eclipse.hawkbit.repository.TagFields; +import org.eclipse.hawkbit.repository.TagManagement; +import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; +import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.repository.model.DistributionSetTag; +import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult; +import org.eclipse.hawkbit.repository.rsql.RSQLUtility; +import org.eclipse.hawkbit.rest.resource.model.distributionset.DistributionSetsRest; +import org.eclipse.hawkbit.rest.resource.model.tag.AssignedDistributionSetRequestBody; +import org.eclipse.hawkbit.rest.resource.model.tag.DistributionSetTagAssigmentResultRest; +import org.eclipse.hawkbit.rest.resource.model.tag.TagPagedList; +import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut; +import org.eclipse.hawkbit.rest.resource.model.tag.TagRest; +import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; +import org.springframework.data.domain.Sort; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * REST Resource handling for {@link DistributionSetTag} CRUD operations. + * + */ +@RestController +@RequestMapping(RestConstants.DISTRIBUTIONSET_TAG_V1_REQUEST_MAPPING) +public class DistributionSetTagResource { + private static final Logger LOG = LoggerFactory.getLogger(DistributionSetTagResource.class); + + @Autowired + private TagManagement tagManagement; + + @Autowired + private DistributionSetManagement distributionSetManagement; + + @Autowired + private EntityManager entityManager; + + /** + * Handles the GET request of retrieving all DistributionSet tags. + * + * @param pagingOffsetParam + * the offset of list of DistributionSet tags for pagination, + * might not be present in the rest request then default value + * will be applied + * @param pagingLimitParam + * the limit of the paged request, might not be present in the + * rest request then default value will be applied + * @param sortParam + * the sorting parameter in the request URL, syntax + * {@code field:direction, field:direction} + * @param rsqlParam + * the search parameter in the request URL, syntax + * {@code q=name==abc} + * @return a list of all target tags for a defined or default page request + * with status OK. The response is always paged. In any failure the + * JsonResponseExceptionHandler is handling the response. + */ + @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) + public ResponseEntity getDistributionSetTags( + @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { + + final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); + final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); + final Sort sorting = PagingUtility.sanitizeTargetSortParam(sortParam); + + final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); + final Slice findTargetsAll; + final Long countTargetsAll; + if (rsqlParam == null) { + findTargetsAll = tagManagement.findAllDistributionSetTags(pageable); + countTargetsAll = tagManagement.countTargetTags(); + + } else { + final Page findTargetPage = tagManagement.findAllDistributionSetTags( + RSQLUtility.parse(rsqlParam, TagFields.class, entityManager), pageable); + countTargetsAll = findTargetPage.getTotalElements(); + findTargetsAll = findTargetPage; + + } + + final List rest = TagMapper.toResponseDistributionSetTag(findTargetsAll.getContent()); + return new ResponseEntity<>(new TagPagedList(rest, countTargetsAll), HttpStatus.OK); + } + + /** + * Handles the GET request of retrieving a single distribution set tag. + * + * @param distributionsetTagId + * the ID of the distribution set tag to retrieve + * + * @return a single distribution set tag with status OK. + * @throws EntityNotFoundException + * in case the given {@code distributionsetTagId} doesn't + * exists. + */ + @RequestMapping(method = RequestMethod.GET, value = "/{distributionsetTagId}", produces = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }) + public ResponseEntity getDistributionSetTag(@PathVariable final Long distributionsetTagId) { + final DistributionSetTag tag = findDistributionTagById(distributionsetTagId); + return new ResponseEntity<>(TagMapper.toResponse(tag), HttpStatus.OK); + } + + /** + * Handles the POST request of creating new distribution set tag. The + * request body must always be a list of tags. + * + * @param tags + * the distribution set tags to be created. + * @return In case all modules could successful created the ResponseEntity + * with status code 201 - Created. The Response Body are the created + * distribution set tags but without ResponseBody. + */ + @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { + "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) + public ResponseEntity createDistributionSetTags(@RequestBody final List tags) { + LOG.debug("creating {} ds tags", tags.size()); + + final List createdTags = tagManagement.createDistributionSetTags(TagMapper + .mapDistributionSetTagFromRequest(tags)); + + return new ResponseEntity<>(TagMapper.toResponseDistributionSetTag(createdTags), HttpStatus.CREATED); + } + + /** + * + * Handles the PUT request of updating a single distribution set tag. + * + * @param distributionsetTagId + * the ID of the distribution set tag + * @param restDSTagRest + * the the request body to be updated + * @return status OK if update is successful and the updated distribution + * set tag. + * @throws EntityNotFoundException + * in case the given {@code distributionsetTagId} doesn't + * exists. + */ + @RequestMapping(method = RequestMethod.PUT, value = "/{distributionsetTagId}", consumes = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) + public ResponseEntity updateDistributionSetTag(@PathVariable final Long distributionsetTagId, + @RequestBody final TagRequestBodyPut restDSTagRest) { + LOG.debug("update {} ds tag", restDSTagRest); + + final DistributionSetTag distributionSetTag = findDistributionTagById(distributionsetTagId); + TagMapper.updateTag(restDSTagRest, distributionSetTag); + final DistributionSetTag updateDistributionSetTag = tagManagement.updateDistributionSetTag(distributionSetTag); + + LOG.debug("ds tag updated"); + + return new ResponseEntity<>(TagMapper.toResponse(updateDistributionSetTag), HttpStatus.OK); + } + + /** + * Handles the DELETE request for a single distribution set tag. + * + * @param distributionsetTagId + * the ID of the distribution set tag + * @return status OK if delete as successfully. + * @throws EntityNotFoundException + * in case the given {@code distributionsetTagId} doesn't + * exists. + * + */ + @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionsetTagId}") + public ResponseEntity deleteDistributionSetTag(@PathVariable final Long distributionsetTagId) { + LOG.debug("Delete {} distribution set tag", distributionsetTagId); + final DistributionSetTag tag = findDistributionTagById(distributionsetTagId); + + tagManagement.deleteDistributionSetTag(tag.getName()); + + return new ResponseEntity<>(HttpStatus.OK); + } + + /** + * Handles the GET request of retrieving all assigned distribution sets by + * the given tag id. + * + * @param distributionsetTagId + * the ID of the distribution set tag + * + * @return the list of assigned distribution sets. + * @throws EntityNotFoundException + * in case the given {@code distributionsetTagId} doesn't + * exists. + */ + @RequestMapping(method = RequestMethod.GET, value = RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING) + public ResponseEntity getAssignedDistributionSets( + @PathVariable final Long distributionsetTagId) { + final DistributionSetTag tag = findDistributionTagById(distributionsetTagId); + return new ResponseEntity<>( + DistributionSetMapper.toResponseDistributionSets(tag.getAssignedToDistributionSet()), HttpStatus.OK); + } + + /** + * Handles the POST request to toggle the assignment of distribution sets by + * the given tag id. + * + * @param distributionsetTagIds + * the ID of the distribution set tag to retrieve + * @param assignedDSRequestBodies + * list of distribution set ids to be toggled + * + * @return the list of assigned distribution sets and unassigned + * distribution sets. + * @throws EntityNotFoundException + * in case the given {@code distributionsetTagId} doesn't + * exists. + */ + @RequestMapping(method = RequestMethod.POST, value = RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING + + "/toggleTagAssignment") + public ResponseEntity toggleTagAssignment( + @PathVariable final Long distributionsetTagId, + @RequestBody final List assignedDSRequestBodies) { + LOG.debug("Toggle distribution set assignment {} for ds tag {}", assignedDSRequestBodies.size(), + distributionsetTagId); + + final DistributionSetTag tag = findDistributionTagById(distributionsetTagId); + + final DistributionSetTagAssigmentResult assigmentResult = distributionSetManagement.toggleTagAssignment( + findDistributionSetIds(assignedDSRequestBodies), tag.getName()); + + final DistributionSetTagAssigmentResultRest tagAssigmentResultRest = new DistributionSetTagAssigmentResultRest(); + tagAssigmentResultRest.setAssignedDistributionSets(DistributionSetMapper + .toResponseDistributionSets(assigmentResult.getAssignedDs())); + tagAssigmentResultRest.setUnassignedDistributionSets(DistributionSetMapper + .toResponseDistributionSets(assigmentResult.getUnassignedDs())); + + LOG.debug("Toggled assignedDS {} and unassignedDS{}", assigmentResult.getAssigned(), + assigmentResult.getUnassigned()); + + return new ResponseEntity<>(tagAssigmentResultRest, HttpStatus.OK); + } + + /** + * Handles the POST request to assign distribution sets to the given tag id. + * + * @param distributionsetTagId + * the ID of the distribution set tag to retrieve + * @param assignedDSRequestBodies + * list of distribution sets ids to be assigned + * + * @return the list of assigned distribution set. + * @throws EntityNotFoundException + * in case the given {@code distributionsetTagId} doesn't + * exists. + */ + @RequestMapping(method = RequestMethod.POST, value = RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING) + public ResponseEntity assignDistributionSets(@PathVariable final Long distributionsetTagId, + @RequestBody final List assignedDSRequestBodies) { + LOG.debug("Assign DistributionSet {} for ds tag {}", assignedDSRequestBodies.size(), distributionsetTagId); + final DistributionSetTag tag = findDistributionTagById(distributionsetTagId); + + final List assignedDs = distributionSetManagement.assignTag( + findDistributionSetIds(assignedDSRequestBodies), tag); + LOG.debug("Assignd DistributionSet {}", assignedDs.size()); + return new ResponseEntity<>(DistributionSetMapper.toResponseDistributionSets(assignedDs), HttpStatus.OK); + } + + /** + * Handles the DELETE request to unassign all distribution set from the + * given tag id. + * + * @param distributionsetTagId + * the ID of the distribution set tag to retrieve + * @return http status code + * @throws EntityNotFoundException + * in case the given {@code distributionsetTagId} doesn't + * exists. + */ + @RequestMapping(method = RequestMethod.DELETE, value = RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING) + public ResponseEntity unassignDistributionSets(@PathVariable final Long distributionsetTagId) { + LOG.debug("Unassign all DS for ds tag {}", distributionsetTagId); + final DistributionSetTag tag = findDistributionTagById(distributionsetTagId); + if (tag.getAssignedToDistributionSet() == null) { + LOG.debug("No assigned ds founded"); + return new ResponseEntity<>(HttpStatus.OK); + } + + final List distributionSets = distributionSetManagement.unAssignAllDistributionSetsByTag(tag); + LOG.debug("Unassigned ds {}", distributionSets.size()); + return new ResponseEntity<>(HttpStatus.OK); + } + + /** + * Handles the DELETE request to unassign one distribution set from the + * given tag id. + * + * @param distributionsetTagId + * the ID of the distribution set tag + * @param distributionsetId + * the ID of the distribution set to unassign + * @return http status code + * @throws EntityNotFoundException + * in case the given {@code distributionsetTagId} doesn't + * exists. + */ + @RequestMapping(method = RequestMethod.DELETE, value = RestConstants.DISTRIBUTIONSET_REQUEST_MAPPING + + "/{distributionsetId}") + public ResponseEntity unassignDistributionSet(@PathVariable final Long distributionsetTagId, + @PathVariable final Long distributionsetId) { + LOG.debug("Unassign ds {} for ds tag {}", distributionsetId, distributionsetTagId); + final DistributionSetTag tag = findDistributionTagById(distributionsetTagId); + distributionSetManagement.unAssignTag(distributionsetId, tag); + return new ResponseEntity<>(HttpStatus.OK); + } + + private DistributionSetTag findDistributionTagById(final Long distributionsetTagId) { + final DistributionSetTag tag = tagManagement.findDistributionSetTagById(distributionsetTagId); + if (tag == null) { + throw new EntityNotFoundException("Distribution Tag with Id {" + distributionsetTagId + "} does not exist"); + } + return tag; + } + + private List findDistributionSetIds( + final List assignedDistributionSetRequestBodies) { + return assignedDistributionSetRequestBodies.stream().map(request -> request.getDistributionSetId()) + .collect(Collectors.toList()); + } +} diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeMapper.java old mode 100755 new mode 100644 index 0f28c57b5..0550e0fc5 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeMapper.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeMapper.java @@ -18,7 +18,7 @@ import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; -import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRequestBodyCreate; +import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRequestBodyPost; import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRest; import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypesRest; @@ -38,17 +38,17 @@ final class DistributionSetTypeMapper { } static List smFromRequest(final SoftwareManagement softwareManagement, - final Iterable smTypesRest) { + final Iterable smTypesRest) { final List mappedList = new ArrayList<>(); - for (final DistributionSetTypeRequestBodyCreate smRest : smTypesRest) { + for (final DistributionSetTypeRequestBodyPost smRest : smTypesRest) { mappedList.add(fromRequest(softwareManagement, smRest)); } return mappedList; } static DistributionSetType fromRequest(final SoftwareManagement softwareManagement, - final DistributionSetTypeRequestBodyCreate smsRest) { + final DistributionSetTypeRequestBodyPost smsRest) { final DistributionSetType result = new DistributionSetType(smsRest.getKey(), smsRest.getName(), smsRest.getDescription()); diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResource.java old mode 100755 new mode 100644 index ed054abf9..21c7bb956 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResource.java @@ -8,17 +8,10 @@ */ package org.eclipse.hawkbit.rest.resource; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - import java.util.List; import javax.persistence.EntityManager; -import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.repository.DistributionSetManagement; import org.eclipse.hawkbit.repository.DistributionSetTypeFields; import org.eclipse.hawkbit.repository.SoftwareManagement; @@ -28,12 +21,10 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.rsql.RSQLUtility; -import org.eclipse.hawkbit.rest.resource.model.ExceptionInfo; import org.eclipse.hawkbit.rest.resource.model.IdRest; -import org.eclipse.hawkbit.rest.resource.model.action.ActionPagedList; import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypePagedList; -import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRequestBodyCreate; -import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRequestBodyUpdate; +import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRequestBodyPost; +import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRequestBodyPut; import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypeRest; import org.eclipse.hawkbit.rest.resource.model.distributionsettype.DistributionSetTypesRest; import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRest; @@ -46,7 +37,6 @@ import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -63,9 +53,7 @@ import org.springframework.web.bind.annotation.RestController; * */ @RestController -@Transactional(readOnly = true) @RequestMapping(RestConstants.DISTRIBUTIONSETTYPE_V1_REQUEST_MAPPING) -@Api(value = "distributionsettypes", description = "Distribution Set Types Management API") public class DistributionSetTypeResource { @Autowired @@ -100,17 +88,12 @@ public class DistributionSetTypeResource { * handling the response. */ @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = DistributionSetTypePagedList.class, value = "Get distribution det types", notes = "Handles the GET request of retrieving all distribution set types within SP. Required Permission: " - + SpPermission.READ_REPOSITORY) - public ResponseEntity getTypes( + + public ResponseEntity getDistributionSetTypes( @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @ApiParam(required = false, value = "FIQL syntax search query" - + "" - + "" - + "" - + "
id=1,key=vhicletypex2015Distribution Set Types with id 1 or key vhicletypex2015
name=VehicleSeriesADistribution Set Types with name VehicleSeriesA
") @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { + @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); @@ -129,8 +112,8 @@ public class DistributionSetTypeResource { countModulesAll = distributionSetManagement.countDistributionSetTypesAll(); } - final List rest = DistributionSetTypeMapper.toListResponse(findModuleTypessAll - .getContent()); + final List rest = DistributionSetTypeMapper + .toListResponse(findModuleTypessAll.getContent()); return new ResponseEntity<>(new DistributionSetTypePagedList(rest, countModulesAll), HttpStatus.OK); } @@ -145,12 +128,10 @@ public class DistributionSetTypeResource { * @throws EntityNotFoundException * in case no with the given {@code softwareModuleId} exists. */ - @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}", produces = { - "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = DistributionSetTypeRest.class, value = "Get distribution set type", notes = "Handles the GET request of retrieving a single distribution set type within SP. Required Permission: " - + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not found distribution set type", response = ExceptionInfo.class)) - public ResponseEntity getDistributionSetType(@PathVariable final Long distributionSetTypeId) { + @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}", produces = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }) + public ResponseEntity getDistributionSetType( + @PathVariable final Long distributionSetTypeId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); return new ResponseEntity<>(DistributionSetTypeMapper.toResponse(foundType), HttpStatus.OK); @@ -165,10 +146,6 @@ public class DistributionSetTypeResource { * */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetTypeId}") - @ApiOperation(value = "Delete distribution set type", notes = "Handles the DELETE request for a single distribution set type within SP. Required Permission: " - + SpPermission.DELETE_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not found distribution set type", response = ExceptionInfo.class)) - @Transactional public ResponseEntity deleteDistributionSetType(@PathVariable final Long distributionSetTypeId) { final DistributionSetType module = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); @@ -186,16 +163,11 @@ public class DistributionSetTypeResource { * the module type to be updated. * @return status OK if update is successful */ - @RequestMapping(method = RequestMethod.PUT, value = "/{distributionSetTypeId}", consumes = { - "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", - MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(value = "Update distribution set type", notes = "Handles the PUT request for a single distribution set type within SP. Required Permission: " - + SpPermission.UPDATE_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found distribution set type", response = ExceptionInfo.class)) - @Transactional + @RequestMapping(method = RequestMethod.PUT, value = "/{distributionSetTypeId}", consumes = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity updateDistributionSetType( @PathVariable final Long distributionSetTypeId, - @RequestBody final DistributionSetTypeRequestBodyUpdate restDistributionSetType) { + @RequestBody final DistributionSetTypeRequestBodyPut restDistributionSetType) { final DistributionSetType type = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); // only description can be modified @@ -206,9 +178,6 @@ public class DistributionSetTypeResource { final DistributionSetType updatedDistributionSetType = distributionSetManagement .updateDistributionSetType(type); - // we flush to ensure that entity is generated and we can return ID etc. - entityManager.flush(); - return new ResponseEntity<>(DistributionSetTypeMapper.toResponse(updatedDistributionSetType), HttpStatus.OK); } @@ -223,23 +192,13 @@ public class DistributionSetTypeResource { * failure the JsonResponseExceptionHandler is handling the * response. */ - @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { - "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = DistributionSetTypesRest.class, value = "Create distribution set types", notes = "Handles the POST request for creating new distribution set types within SP. The request body must always be a list of types. Required Permission: " - + SpPermission.CREATE_REPOSITORY) - @ApiResponses({ - @ApiResponse(code = 404, message = "Not Found Distribution Set Type", response = ExceptionInfo.class), - @ApiResponse(code = 409, message = "Conflict Distribution Set Type already exists", response = ExceptionInfo.class) }) - @Transactional + @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity createDistributionSetTypes( - @RequestBody final List distributionSetTypes) { + @RequestBody final List distributionSetTypes) { - final List createdSoftwareModules = distributionSetManagement - .createDistributionSetTypes(DistributionSetTypeMapper.smFromRequest(softwareManagement, - distributionSetTypes)); - - // we flush to ensure that entity is generated and we can return ID etc. - entityManager.flush(); + final List createdSoftwareModules = distributionSetManagement.createDistributionSetTypes( + DistributionSetTypeMapper.smFromRequest(softwareManagement, distributionSetTypes)); return new ResponseEntity<>(DistributionSetTypeMapper.toTypesResponse(createdSoftwareModules), HttpStatus.CREATED); @@ -248,8 +207,8 @@ public class DistributionSetTypeResource { private DistributionSetType findDistributionSetTypeWithExceptionIfNotFound(final Long distributionSetTypeId) { final DistributionSetType module = distributionSetManagement.findDistributionSetTypeById(distributionSetTypeId); if (module == null) { - throw new EntityNotFoundException("DistributionSetType with Id {" + distributionSetTypeId - + "} does not exist"); + throw new EntityNotFoundException( + "DistributionSetType with Id {" + distributionSetTypeId + "} does not exist"); } return module; } @@ -264,10 +223,7 @@ public class DistributionSetTypeResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}/" + RestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES, produces = { "application/hal+json", - MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = ActionPagedList.class, value = "Lists all mandatory software module types", notes = "Handles the GET request of retrieving the list of mandatory software module types in that distribution set type. Required Permission: " - + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found distribution set type", response = ExceptionInfo.class)) + MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity getMandatoryModules(@PathVariable final Long distributionSetTypeId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); @@ -289,11 +245,8 @@ public class DistributionSetTypeResource { * @return Unpaged list of module types and OK in case of success. */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}/" - + RestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES + "/{softwareModuleTypeId}", produces = { - "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = ActionPagedList.class, value = "Retrieve mandatory software module type", notes = " Handles the GET request of retrieving the single mandatory software module type in that distribution set type. Required Permission: " - + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found distribution set type", response = ExceptionInfo.class)) + + RestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES + + "/{softwareModuleTypeId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity getMandatoryModule(@PathVariable final Long distributionSetTypeId, @PathVariable final Long softwareModuleTypeId) { @@ -306,8 +259,7 @@ public class DistributionSetTypeResource { "Software module with given ID is not part of this distribution set type!"); } - return new ResponseEntity(SoftwareModuleTypeMapper.toResponse(foundSmType), - HttpStatus.OK); + return new ResponseEntity<>(SoftwareModuleTypeMapper.toResponse(foundSmType), HttpStatus.OK); } /** @@ -321,11 +273,8 @@ public class DistributionSetTypeResource { * @return Unpaged list of module types and OK in case of success. */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}/" - + RestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES + "/{softwareModuleTypeId}", produces = { - "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = ActionPagedList.class, value = "Retrieve optional software module type", notes = " Handles the GET request of retrieving the single optional software module type in that distribution set type. Required Permission: " - + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found distribution set type", response = ExceptionInfo.class)) + + RestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES + + "/{softwareModuleTypeId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity getOptionalModule(@PathVariable final Long distributionSetTypeId, @PathVariable final Long softwareModuleTypeId) { @@ -338,8 +287,7 @@ public class DistributionSetTypeResource { "Software module with given ID is not part of this distribution set type!"); } - return new ResponseEntity(SoftwareModuleTypeMapper.toResponse(foundSmType), - HttpStatus.OK); + return new ResponseEntity<>(SoftwareModuleTypeMapper.toResponse(foundSmType), HttpStatus.OK); } /** @@ -352,10 +300,7 @@ public class DistributionSetTypeResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{distributionSetTypeId}/" + RestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES, produces = { "application/hal+json", - MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = ActionPagedList.class, value = "Lists all optional software module types", notes = "Handles the GET request of retrieving the list of optional software module types in that distribution set type. Required Permission: " - + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found distribution set type", response = ExceptionInfo.class)) + MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity getOptionalModules(@PathVariable final Long distributionSetTypeId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); @@ -378,18 +323,20 @@ public class DistributionSetTypeResource { * @return OK if the request was successful */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetTypeId}/" - + RestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES + "/{softwareModuleTypeId}", produces = { - "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = ActionPagedList.class, value = "Remove mandatory module from distribution set type", notes = "Handles the GET request of retrieving the list of software module types in that distribution set. " - + "Note that a DS type cannot be changed after it has been used by a DS. Required Permission: " - + SpPermission.UPDATE_REPOSITORY + " and " + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found distribution set type", response = ExceptionInfo.class)) - @Transactional + + RestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES + + "/{softwareModuleTypeId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity removeMandatoryModule(@PathVariable final Long distributionSetTypeId, @PathVariable final Long softwareModuleTypeId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); + final SoftwareModuleType foundSmType = findSoftwareModuleTypeWithExceptionIfNotFound(softwareModuleTypeId); + + if (!foundType.containsMandatoryModuleType(foundSmType)) { + throw new EntityNotFoundException( + "Software module with given ID is not mandatory part of this distribution set type!"); + } + foundType.removeModuleType(softwareModuleTypeId); distributionSetManagement.updateDistributionSetType(foundType); @@ -409,16 +356,24 @@ public class DistributionSetTypeResource { * @return OK if the request was successful */ @RequestMapping(method = RequestMethod.DELETE, value = "/{distributionSetTypeId}/" - + RestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES + "/{softwareModuleTypeId}", produces = { - "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = ActionPagedList.class, value = "Remove optional module from distribution set type", notes = "Handles DELETE request for removing an optional module from the distribution set type." - + "Note that a DS type cannot be changed after it has been used by a DS. Required Permission: " - + SpPermission.UPDATE_REPOSITORY + " and " + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found distribution set type", response = ExceptionInfo.class)) - @Transactional + + RestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES + + "/{softwareModuleTypeId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity removeOptionalModule(@PathVariable final Long distributionSetTypeId, @PathVariable final Long softwareModuleTypeId) { - return removeMandatoryModule(distributionSetTypeId, softwareModuleTypeId); + final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); + + final SoftwareModuleType foundSmType = findSoftwareModuleTypeWithExceptionIfNotFound(softwareModuleTypeId); + + if (!foundType.containsOptionalModuleType(foundSmType)) { + throw new EntityNotFoundException( + "Software module with given ID is not optional part of this distribution set type!"); + } + + foundType.removeModuleType(softwareModuleTypeId); + + distributionSetManagement.updateDistributionSetType(foundType); + + return new ResponseEntity<>(HttpStatus.OK); } /** @@ -434,14 +389,10 @@ public class DistributionSetTypeResource { */ @RequestMapping(method = RequestMethod.POST, value = "/{distributionSetTypeId}/" + RestConstants.DISTRIBUTIONSETTYPE_V1_MANDATORY_MODULE_TYPES, consumes = { "application/hal+json", - MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = Void.class, value = "Add mandatory software module type", notes = "Handles the POST request for adding a mandatory software module type to a distribution set type." - + "Note that a DS type cannot be changed after it has been used by a DS. Required Permission: " - + SpPermission.UPDATE_REPOSITORY + " and " + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found DS type or SP type", response = ExceptionInfo.class)) - @Transactional + MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity addMandatoryModule(@PathVariable final Long distributionSetTypeId, - @RequestBody @ApiParam(value = "Software module type ID", required = true) final IdRest smtId) { + @RequestBody final IdRest smtId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); @@ -449,6 +400,8 @@ public class DistributionSetTypeResource { foundType.addMandatoryModuleType(smType); + distributionSetManagement.updateDistributionSetType(foundType); + return new ResponseEntity<>(HttpStatus.OK); } @@ -465,14 +418,10 @@ public class DistributionSetTypeResource { */ @RequestMapping(method = RequestMethod.POST, value = "/{distributionSetTypeId}/" + RestConstants.DISTRIBUTIONSETTYPE_V1_OPTIONAL_MODULE_TYPES, consumes = { "application/hal+json", - MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = Void.class, value = "Add optional software module type", notes = "Handles the POST request for adding an optional software module type to a distribution set type." - + "Note that a DS type cannot be changed after it has been used by a DS. Required Permission: " - + SpPermission.UPDATE_REPOSITORY + " and " + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found DS type or SP type", response = ExceptionInfo.class)) - @Transactional + MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity addOptionalModule(@PathVariable final Long distributionSetTypeId, - @RequestBody @ApiParam(value = "Software module type ID", required = true) final IdRest smtId) { + @RequestBody final IdRest smtId) { final DistributionSetType foundType = findDistributionSetTypeWithExceptionIfNotFound(distributionSetTypeId); @@ -480,6 +429,8 @@ public class DistributionSetTypeResource { foundType.addOptionalModuleType(smType); + distributionSetManagement.updateDistributionSetType(foundType); + return new ResponseEntity<>(HttpStatus.OK); } @@ -487,8 +438,8 @@ public class DistributionSetTypeResource { private SoftwareModuleType findSoftwareModuleTypeWithExceptionIfNotFound(final Long softwareModuleTypeId) { final SoftwareModuleType module = softwareManagement.findSoftwareModuleTypeById(softwareModuleTypeId); if (module == null) { - throw new EntityNotFoundException("SoftwareModuleType with Id {" + softwareModuleTypeId - + "} does not exist"); + throw new EntityNotFoundException( + "SoftwareModuleType with Id {" + softwareModuleTypeId + "} does not exist"); } return module; } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DownloadResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/DownloadResource.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/EnableRestResources.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/EnableRestResources.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/MessageNotReadableException.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/MessageNotReadableException.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/OffsetBasedPageRequest.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/OffsetBasedPageRequest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/PagingUtility.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/PagingUtility.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/ResponseExceptionHandler.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/ResponseExceptionHandler.java old mode 100755 new mode 100644 index a6a9fd9d1..d222a96fd --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/ResponseExceptionHandler.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/ResponseExceptionHandler.java @@ -8,7 +8,7 @@ */ package org.eclipse.hawkbit.rest.resource; -import java.util.HashMap; +import java.util.EnumMap; import java.util.Map; import javax.servlet.http.HttpServletRequest; @@ -28,7 +28,7 @@ import org.springframework.web.multipart.MultipartException; /** * General controller advice for exception handling. - * + * * * * @@ -37,7 +37,7 @@ import org.springframework.web.multipart.MultipartException; public class ResponseExceptionHandler { private static final Logger LOG = LoggerFactory.getLogger(ResponseExceptionHandler.class); - private static final Map ERROR_TO_HTTP_STATUS = new HashMap<>(); + private static final Map ERROR_TO_HTTP_STATUS = new EnumMap<>(SpServerError.class); private static final HttpStatus DEFAULT_RESPONSE_STATUS = HttpStatus.INTERNAL_SERVER_ERROR; static { @@ -58,6 +58,7 @@ public class ResponseExceptionHandler { ERROR_TO_HTTP_STATUS.put(SpServerError.SP_ACTION_STATUS_TO_MANY_ENTRIES, HttpStatus.FORBIDDEN); ERROR_TO_HTTP_STATUS.put(SpServerError.SP_ATTRIBUTES_TO_MANY_ENTRIES, HttpStatus.FORBIDDEN); ERROR_TO_HTTP_STATUS.put(SpServerError.SP_ACTION_NOT_CANCELABLE, HttpStatus.METHOD_NOT_ALLOWED); + ERROR_TO_HTTP_STATUS.put(SpServerError.SP_ACTION_NOT_FORCE_QUITABLE, HttpStatus.METHOD_NOT_ALLOWED); ERROR_TO_HTTP_STATUS.put(SpServerError.SP_DS_CREATION_FAILED_MISSING_MODULE, HttpStatus.BAD_REQUEST); ERROR_TO_HTTP_STATUS.put(SpServerError.SP_DS_MODULE_UNSUPPORTED, HttpStatus.BAD_REQUEST); ERROR_TO_HTTP_STATUS.put(SpServerError.SP_DS_TYPE_UNDEFINED, HttpStatus.BAD_REQUEST); @@ -96,7 +97,7 @@ public class ResponseExceptionHandler { } else { responseStatus = DEFAULT_RESPONSE_STATUS; } - return new ResponseEntity(response, responseStatus); + return new ResponseEntity<>(response, responseStatus); } /** @@ -119,7 +120,7 @@ public class ResponseExceptionHandler { response.setErrorCode(SpServerError.SP_REST_BODY_NOT_READABLE.getKey()); response.setMessage(SpServerError.SP_REST_BODY_NOT_READABLE.getMessage()); response.setExceptionClass(MessageNotReadableException.class.getName()); - return new ResponseEntity(response, HttpStatus.BAD_REQUEST); + return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST); } /** @@ -151,7 +152,7 @@ public class ResponseExceptionHandler { response.setExceptionClass(MultipartException.class.getName()); } - return new ResponseEntity(response, HttpStatus.BAD_REQUEST); + return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST); } private static boolean searchForCause(final Throwable t, final Class lookFor) { diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/RestModelMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/RestModelMapper.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleMapper.java old mode 100755 new mode 100644 index 9bdf7c025..d8fc120fc --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleMapper.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleMapper.java @@ -37,7 +37,7 @@ import org.eclipse.hawkbit.rest.resource.model.softwaremodule.SoftwareModulesRes * * */ -final class SoftwareModuleMapper { +public final class SoftwareModuleMapper { private SoftwareModuleMapper() { // Utility class } @@ -60,8 +60,7 @@ final class SoftwareModuleMapper { smsRest.getName(), smsRest.getVersion(), smsRest.getDescription(), smsRest.getVendor()); } - static List fromRequestSwMetadata(final SoftwareModule sw, - final List metadata) { + static List fromRequestSwMetadata(final SoftwareModule sw, final List metadata) { final List mappedList = new ArrayList<>(metadata.size()); for (final MetadataRest metadataRest : metadata) { if (metadataRest.getKey() == null) { @@ -81,7 +80,14 @@ final class SoftwareModuleMapper { return mappedList; } - static List toResponse(final List baseSoftareModules) { + /** + * Create response for sw modules. + * + * @param baseSoftareModules + * the modules + * @return the response + */ + public static List toResponse(final List baseSoftareModules) { final List mappedList = new ArrayList<>(); if (baseSoftareModules != null) { for (final SoftwareModule target : baseSoftareModules) { @@ -116,7 +122,14 @@ final class SoftwareModuleMapper { return metadataRest; } - static SoftwareModuleRest toResponse(final SoftwareModule baseSofwareModule) { + /** + * Create response for one sw module. + * + * @param baseSofwareModule + * the sw module + * @return the response + */ + public static SoftwareModuleRest toResponse(final SoftwareModule baseSofwareModule) { if (baseSofwareModule == null) { return null; } @@ -128,15 +141,20 @@ final class SoftwareModuleMapper { response.setType(baseSofwareModule.getType().getKey()); response.setVendor(baseSofwareModule.getVendor()); - response.add(linkTo(methodOn(SoftwareModuleResource.class).getArtifacts(response.getModuleId())) - .withRel(RestConstants.SOFTWAREMODULE_V1_ARTIFACT)); - response.add(linkTo(methodOn(SoftwareModuleResource.class).getSoftwareModule(response.getModuleId())) - .withRel("self")); + response.add(linkTo(methodOn(SoftwareModuleResource.class).getArtifacts(response.getModuleId())).withRel( + RestConstants.SOFTWAREMODULE_V1_ARTIFACT)); + response.add(linkTo(methodOn(SoftwareModuleResource.class).getSoftwareModule(response.getModuleId())).withRel( + "self")); response.add(linkTo( methodOn(SoftwareModuleTypeResource.class).getSoftwareModuleType(baseSofwareModule.getType().getId())) - .withRel(RestConstants.SOFTWAREMODULE_V1_TYPE)); + .withRel(RestConstants.SOFTWAREMODULE_V1_TYPE)); + response.add(linkTo( + methodOn(SoftwareModuleResource.class).getMetadata(response.getModuleId(), + Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET), + Integer.parseInt(RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT), null, null)).withRel( + "metadata")); return response; } @@ -160,12 +178,13 @@ final class SoftwareModuleMapper { RestModelMapper.mapBaseToBase(artifactRest, artifact); - artifactRest.add(linkTo(methodOn(SoftwareModuleResource.class).getArtifact(artifact.getSoftwareModule().getId(), - artifact.getId())).withRel("self")); + artifactRest.add(linkTo( + methodOn(SoftwareModuleResource.class).getArtifact(artifact.getSoftwareModule().getId(), + artifact.getId())).withRel("self")); if (artifact instanceof LocalArtifact) { - artifactRest.add( - linkTo(methodOn(SoftwareModuleResource.class).downloadArtifact(artifact.getSoftwareModule().getId(), + artifactRest.add(linkTo( + methodOn(SoftwareModuleResource.class).downloadArtifact(artifact.getSoftwareModule().getId(), artifact.getId(), null, null)).withRel("download")); } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java old mode 100755 new mode 100644 index a56a733c7..fa95c0f5c --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResource.java @@ -8,12 +8,6 @@ */ package org.eclipse.hawkbit.rest.resource; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - import java.io.IOException; import java.util.List; @@ -22,7 +16,6 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.eclipse.hawkbit.artifact.repository.model.DbArtifact; -import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.repository.ArtifactManagement; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareModuleFields; @@ -35,7 +28,6 @@ import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata; import org.eclipse.hawkbit.repository.model.SwMetadataCompositeKey; import org.eclipse.hawkbit.repository.rsql.RSQLUtility; import org.eclipse.hawkbit.rest.resource.helper.RestResourceConversionHelper; -import org.eclipse.hawkbit.rest.resource.model.ExceptionInfo; import org.eclipse.hawkbit.rest.resource.model.MetadataRest; import org.eclipse.hawkbit.rest.resource.model.MetadataRestPageList; import org.eclipse.hawkbit.rest.resource.model.artifact.ArtifactRest; @@ -55,7 +47,6 @@ import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -74,9 +65,7 @@ import org.springframework.web.multipart.MultipartFile; * */ @RestController -@Transactional(readOnly = true) @RequestMapping(RestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING) -@Api(value = "softwaremodules", description = "Software Modules Management API") public class SoftwareModuleResource { private static final Logger LOG = LoggerFactory.getLogger(SoftwareModuleResource.class); @@ -108,17 +97,13 @@ public class SoftwareModuleResource { */ @RequestMapping(method = RequestMethod.POST, value = "/{softwareModuleId}/artifacts", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = ArtifactRest.class, value = "Upload Artifact", notes = "Handles POST request for artifact upload. Required Permission: " - + SpPermission.CREATE_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Software Module", response = ExceptionInfo.class)) - @Transactional public ResponseEntity uploadArtifact(@PathVariable final Long softwareModuleId, @RequestParam("file") final MultipartFile file, @RequestParam(value = "filename", required = false) final String optionalFileName, @RequestParam(value = "md5sum", required = false) final String md5Sum, @RequestParam(value = "sha1sum", required = false) final String sha1Sum) { - Artifact result = null; + Artifact result; if (!file.isEmpty()) { String fileName = optionalFileName; @@ -138,10 +123,7 @@ public class SoftwareModuleResource { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } - // we flush to ensure that entity is generated and we can return ID etc. - entityManager.flush(); - - return new ResponseEntity(SoftwareModuleMapper.toResponse(result), HttpStatus.CREATED); + return new ResponseEntity<>(SoftwareModuleMapper.toResponse(result), HttpStatus.CREATED); } @@ -157,15 +139,11 @@ public class SoftwareModuleResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/artifacts", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = ArtifactsRest.class, value = "List Artifacts Metadata", notes = "Handles the GET request of retrieving all meta data of artifacts assigned to a software module. Required Permission: " - + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Software Module", response = ExceptionInfo.class)) @ResponseBody public ResponseEntity getArtifacts(@PathVariable final Long softwareModuleId) { final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null); - return new ResponseEntity(SoftwareModuleMapper.artifactsToResponse(module.getArtifacts()), - HttpStatus.OK); + return new ResponseEntity<>(SoftwareModuleMapper.artifactsToResponse(module.getArtifacts()), HttpStatus.OK); } /** @@ -184,9 +162,6 @@ public class SoftwareModuleResource { * successful */ @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/artifacts/{artifactId}/download") - @ApiOperation(response = Void.class, value = "Download Artifact", notes = "Handles the GET request for downloading an artifact. Required Permission: " - + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Software Module or Artifact", response = ExceptionInfo.class)) @ResponseBody public ResponseEntity downloadArtifact(@PathVariable final Long softwareModuleId, @PathVariable final Long artifactId, final HttpServletResponse servletResponse, @@ -223,16 +198,13 @@ public class SoftwareModuleResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/artifacts/{artifactId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = ArtifactRest.class, value = "Get Artifact Metadata", notes = "Handles the GET request of retrieving a single Artifact meta data request. Required Permission: " - + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Software Module or Artifact", response = ExceptionInfo.class)) @ResponseBody public ResponseEntity getArtifact(@PathVariable final Long softwareModuleId, @PathVariable final Long artifactId) { final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, artifactId); - return new ResponseEntity(SoftwareModuleMapper.toResponse(module.getLocalArtifact(artifactId) - .get()), HttpStatus.OK); + return new ResponseEntity<>(SoftwareModuleMapper.toResponse(module.getLocalArtifact(artifactId).get()), + HttpStatus.OK); } /** @@ -246,11 +218,7 @@ public class SoftwareModuleResource { * @return status OK if delete as successful. */ @RequestMapping(method = RequestMethod.DELETE, value = "/{softwareModuleId}/artifacts/{artifactId}") - @ApiOperation(value = "Delete Artifact", notes = "Handles the DELETE request for a single SoftwareModule within SP. Required Permission: " - + SpPermission.DELETE_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Software Module or Artifact", response = ExceptionInfo.class)) @ResponseBody - @Transactional public ResponseEntity deleteArtifact(@PathVariable final Long softwareModuleId, @PathVariable final Long artifactId) { findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, artifactId); @@ -282,18 +250,11 @@ public class SoftwareModuleResource { * JsonResponseExceptionHandler is handling the response. */ @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = SoftwareModulePagedList.class, value = "Get Software Modules", notes = "Handles the GET request of retrieving all softwaremodules within SP. Required Permission: " - + SpPermission.READ_REPOSITORY) public ResponseEntity getSoftwareModules( @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @ApiParam(required = false, value = "FIQL syntax search query" - + "" - + "" - + "" - + "" - + "" + "
version==1.0.0softwaremodules with version 1.0.0
version=ge=2.0.0softwaremodules with version greater-equal 2.0.0
version==1.0.0;type=applicationsoftwaremodules with version 1.0.0 and type application
id=1,type=ossoftwaremodules with id 1 or type os
") @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { + @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); @@ -328,9 +289,6 @@ public class SoftwareModuleResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = SoftwareModuleRest.class, value = "Get Software Module", notes = "Handles the GET request of retrieving a single softwaremodule within SP. Required Permission: " - + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Software Module", response = ExceptionInfo.class)) public ResponseEntity getSoftwareModule(@PathVariable final Long softwareModuleId) { final SoftwareModule findBaseSoftareModule = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null); @@ -349,14 +307,8 @@ public class SoftwareModuleResource { * failure the JsonResponseExceptionHandler is handling the * response. */ - @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { - "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = SoftwareModulesRest.class, value = "Create Software Modules", notes = "Handles the POST request of creating new software modules within SP. The request body must always be a list of modules. Required Permission: " - + SpPermission.CREATE_REPOSITORY) - @ApiResponses({ - @ApiResponse(code = 404, message = "Not Found Software Module", response = ExceptionInfo.class), - @ApiResponse(code = 409, message = "Conflict Software Module already exists", response = ExceptionInfo.class) }) - @Transactional + @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity createSoftwareModules( @RequestBody final List softwareModules) { LOG.debug("creating {} softwareModules", softwareModules.size()); @@ -364,9 +316,6 @@ public class SoftwareModuleResource { .createSoftwareModule(SoftwareModuleMapper.smFromRequest(softwareModules, softwareManagement)); LOG.debug("{} softwareModules created, return status {}", softwareModules.size(), HttpStatus.CREATED); - // we flush to ensure that entity is generated and we can return ID etc. - entityManager.flush(); - return new ResponseEntity<>(SoftwareModuleMapper.toResponseSoftwareModules(createdSoftwareModules), HttpStatus.CREATED); } @@ -383,10 +332,6 @@ public class SoftwareModuleResource { */ @RequestMapping(method = RequestMethod.PUT, value = "/{softwareModuleId}", consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(value = "Update Software Module", notes = "Handles the PUT request for a single softwaremodule within SP. Required Permission: " - + SpPermission.UPDATE_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Software Module", response = ExceptionInfo.class)) - @Transactional public ResponseEntity updateSoftwareModule(@PathVariable final Long softwareModuleId, @RequestBody final SoftwareModuleRequestBodyPut restSoftwareModule) { final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null); @@ -400,10 +345,6 @@ public class SoftwareModuleResource { } final SoftwareModule updateSoftwareModule = softwareManagement.updateSoftwareModule(module); - - // we flush to ensure that entity is generated and we can return ID etc. - entityManager.flush(); - return new ResponseEntity<>(SoftwareModuleMapper.toResponse(updateSoftwareModule), HttpStatus.OK); } @@ -416,10 +357,6 @@ public class SoftwareModuleResource { * */ @RequestMapping(method = RequestMethod.DELETE, value = "/{softwareModuleId}") - @ApiOperation(value = "Delete Software Module", notes = "Handles the DELETE request for a single softwaremodule within SP. Required Permission: " - + SpPermission.DELETE_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Software Module", response = ExceptionInfo.class)) - @Transactional public ResponseEntity deleteSoftwareModule(@PathVariable final Long softwareModuleId) { final SoftwareModule module = findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null); @@ -430,7 +367,7 @@ public class SoftwareModuleResource { /** * Gets a paged list of meta data for a software module. - * + * * @param softwareModuleId * the ID of the software module for the meta data * @param pagingOffsetParam @@ -450,20 +387,11 @@ public class SoftwareModuleResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/metadata", produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - @ApiOperation(response = MetadataRestPageList.class, value = "Get a paged list of meta data", notes = " Get a paged list of meta data for a software module." - + " Required Permission: " + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Software Module", response = ExceptionInfo.class)) - @Transactional - public ResponseEntity getMetadata( - @PathVariable final Long softwareModuleId, + public ResponseEntity getMetadata(@PathVariable final Long softwareModuleId, @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @ApiParam(required = false, value = "FIQL syntax search query" - + "" - + "" - + "" - + "
key==aKey,key==bKeymetadata with the key 'aKey' or 'bKey'
value=li=%25someValue%25metadata which contains 'someValue' in the value ignore case
") @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { + @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { // check if software module exists otherwise throw exception immediately findSoftwareModuleWithExceptionIfNotFound(softwareModuleId, null); @@ -482,13 +410,15 @@ public class SoftwareModuleResource { metaDataPage = softwareManagement.findSoftwareModuleMetadataBySoftwareModuleId(softwareModuleId, pageable); } - return new ResponseEntity<>(new MetadataRestPageList(SoftwareModuleMapper.toResponseSwMetadata(metaDataPage - .getContent()), metaDataPage.getTotalElements()), HttpStatus.OK); + return new ResponseEntity<>( + new MetadataRestPageList(SoftwareModuleMapper.toResponseSwMetadata(metaDataPage.getContent()), + metaDataPage.getTotalElements()), + HttpStatus.OK); } /** * Gets a single meta data value for a specific key of a software module. - * + * * @param softwareModuleId * the ID of the software module to get the meta data from * @param metadataKey @@ -496,11 +426,8 @@ public class SoftwareModuleResource { * @return status OK if get request is successful with the value of the meta * data */ - @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/metadata/{metadataKey}", produces = { MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = MetadataRest.class, value = "Get a single meta data value", notes = " Get a single meta data value for a meta data key." - + " Required Permission: " + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Software Module or meta data key", response = ExceptionInfo.class)) - @Transactional + @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleId}/metadata/{metadataKey}", produces = { + MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity getMetadataValue(@PathVariable final Long softwareModuleId, @PathVariable final String metadataKey) { // check if distribution set exists otherwise throw exception @@ -512,7 +439,7 @@ public class SoftwareModuleResource { /** * Updates a single meta data value of a software module. - * + * * @param softwareModuleId * the ID of the software module to update the meta data entry * @param metadataKey @@ -522,10 +449,6 @@ public class SoftwareModuleResource { */ @RequestMapping(method = RequestMethod.PUT, value = "/{softwareModuleId}/metadata/{metadataKey}", produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) - @ApiOperation(response = MetadataRest.class, value = "Update a single meta data value", notes = " Update a single meta data value for speficic key." - + " Required Permission: " + SpPermission.UPDATE_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Software Module or meta data key", response = ExceptionInfo.class)) - @Transactional public ResponseEntity updateMetadata(@PathVariable final Long softwareModuleId, @PathVariable final String metadataKey, @RequestBody final MetadataRest metadata) { // check if software module exists otherwise throw exception immediately @@ -537,7 +460,7 @@ public class SoftwareModuleResource { /** * Deletes a single meta data entry from the software module. - * + * * @param softwareModuleId * the ID of the software module to delete the meta data entry * @param metadataKey @@ -545,10 +468,6 @@ public class SoftwareModuleResource { * @return status OK if the delete request is successful */ @RequestMapping(method = RequestMethod.DELETE, value = "/{softwareModuleId}/metadata/{metadataKey}") - @ApiOperation(value = "Delete a single meta data", notes = " Delete a single meta data." + " Required Permission: " - + SpPermission.UPDATE_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Software Module or meta data key", response = ExceptionInfo.class)) - @Transactional public ResponseEntity deleteMetadata(@PathVariable final Long softwareModuleId, @PathVariable final String metadataKey) { // check if software module exists otherwise throw exception immediately @@ -559,7 +478,7 @@ public class SoftwareModuleResource { /** * Creates a list of meta data for a specific software module. - * + * * @param softwareModuleId * the ID of the distribution set to create meta data for * @param metadataRest @@ -568,13 +487,8 @@ public class SoftwareModuleResource { * the created meta data */ @RequestMapping(method = RequestMethod.POST, value = "/{softwareModuleId}/metadata", consumes = { - MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }, produces = { MediaType.APPLICATION_JSON_VALUE, - "application/hal+json" }) - @ApiOperation(response = MetadataRest.class, value = "Create a list of meta data entries", notes = "Create a list of meta data entries" - + " Required Permission: " + SpPermission.READ_REPOSITORY + " and " + SpPermission.UPDATE_TARGET) - @ApiResponses({ @ApiResponse(code = 409, message = "Conflict", response = ExceptionInfo.class), - @ApiResponse(code = 404, message = "Not Found Distribution Set", response = ExceptionInfo.class) }) - @Transactional + MediaType.APPLICATION_JSON_VALUE, + "application/hal+json" }, produces = { MediaType.APPLICATION_JSON_VALUE, "application/hal+json" }) public ResponseEntity> createMetadata(@PathVariable final Long softwareModuleId, @RequestBody final List metadataRest) { // check if software module exists otherwise throw exception immediately @@ -583,15 +497,12 @@ public class SoftwareModuleResource { final List created = softwareManagement .createSoftwareModuleMetadata(SoftwareModuleMapper.fromRequestSwMetadata(sw, metadataRest)); - // we flush to ensure that entity is generated and we can return ID etc. - entityManager.flush(); - - return new ResponseEntity>(SoftwareModuleMapper.toResponseSwMetadata(created), - HttpStatus.CREATED); + return new ResponseEntity<>(SoftwareModuleMapper.toResponseSwMetadata(created), HttpStatus.CREATED); } - private SoftwareModule findSoftwareModuleWithExceptionIfNotFound(final Long softwareModuleId, final Long artifactId) { + private SoftwareModule findSoftwareModuleWithExceptionIfNotFound(final Long softwareModuleId, + final Long artifactId) { final SoftwareModule module = softwareManagement.findSoftwareModuleById(softwareModuleId); if (module == null) { throw new EntityNotFoundException("SoftwareModule with Id {" + softwareModuleId + "} does not exist"); diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeMapper.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResource.java old mode 100755 new mode 100644 index c023c9b3c..bef4b5ee4 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResource.java @@ -8,17 +8,10 @@ */ package org.eclipse.hawkbit.rest.resource; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - import java.util.List; import javax.persistence.EntityManager; -import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.repository.SoftwareManagement; import org.eclipse.hawkbit.repository.SoftwareModuleTypeFields; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; @@ -26,7 +19,6 @@ import org.eclipse.hawkbit.repository.model.Artifact; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; import org.eclipse.hawkbit.repository.rsql.RSQLUtility; -import org.eclipse.hawkbit.rest.resource.model.ExceptionInfo; import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypePagedList; import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRequestBodyPost; import org.eclipse.hawkbit.rest.resource.model.softwaremoduletype.SoftwareModuleTypeRequestBodyPut; @@ -40,7 +32,6 @@ import org.springframework.data.domain.Sort; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -57,9 +48,7 @@ import org.springframework.web.bind.annotation.RestController; * */ @RestController -@Transactional(readOnly = true) @RequestMapping(RestConstants.SOFTWAREMODULETYPE_V1_REQUEST_MAPPING) -@Api(value = "softwaremoduletypes", description = "Software Module Types Management API") public class SoftwareModuleTypeResource { @Autowired private SoftwareManagement softwareManagement; @@ -89,16 +78,11 @@ public class SoftwareModuleTypeResource { * JsonResponseExceptionHandler is handling the response. */ @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = SoftwareModuleTypePagedList.class, value = "Get Software Module Types", notes = "Handles the GET request of retrieving all software module types within SP. Required Permission: " - + SpPermission.READ_REPOSITORY) public ResponseEntity getTypes( @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @ApiParam(required = false, value = "FIQL syntax search query" + "" - + "" - + "" - + "
id=1,key=ossoftware module types with id 1 or key os
name=Applicationsoftware module types with name Application
") @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { + @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); @@ -117,8 +101,8 @@ public class SoftwareModuleTypeResource { countModulesAll = softwareManagement.countSoftwareModuleTypesAll(); } - final List rest = SoftwareModuleTypeMapper.toListResponse(findModuleTypessAll - .getContent()); + final List rest = SoftwareModuleTypeMapper + .toListResponse(findModuleTypessAll.getContent()); return new ResponseEntity<>(new SoftwareModuleTypePagedList(rest, countModulesAll), HttpStatus.OK); } @@ -135,9 +119,6 @@ public class SoftwareModuleTypeResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{softwareModuleTypeId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = SoftwareModuleTypeRest.class, value = "Get Software Module Type", notes = "Handles the GET request of retrieving a single software module type within SP. Required Permission: " - + SpPermission.READ_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Software Module Type", response = ExceptionInfo.class)) public ResponseEntity getSoftwareModuleType(@PathVariable final Long softwareModuleTypeId) { final SoftwareModuleType foundType = findSoftwareModuleTypeWithExceptionIfNotFound(softwareModuleTypeId); @@ -153,10 +134,6 @@ public class SoftwareModuleTypeResource { * */ @RequestMapping(method = RequestMethod.DELETE, value = "/{softwareModuleTypeId}") - @ApiOperation(value = "Delete Software Module Type", notes = "Handles the DELETE request for a single software module Type within SP. Required Permission: " - + SpPermission.DELETE_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Software Module Type", response = ExceptionInfo.class)) - @Transactional public ResponseEntity deleteSoftwareModuleType(@PathVariable final Long softwareModuleTypeId) { final SoftwareModuleType module = findSoftwareModuleTypeWithExceptionIfNotFound(softwareModuleTypeId); @@ -176,10 +153,6 @@ public class SoftwareModuleTypeResource { */ @RequestMapping(method = RequestMethod.PUT, value = "/{softwareModuleTypeId}", consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(value = "Updates Software Module Type", notes = "Handles the PUT request for a single software module type within SP. Required Permission: " - + SpPermission.UPDATE_REPOSITORY) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Software Module", response = ExceptionInfo.class)) - @Transactional public ResponseEntity updateSoftwareModuleType( @PathVariable final Long softwareModuleTypeId, @RequestBody final SoftwareModuleTypeRequestBodyPut restSoftwareModuleType) { @@ -191,10 +164,6 @@ public class SoftwareModuleTypeResource { } final SoftwareModuleType updatedSoftwareModuleType = softwareManagement.updateSoftwareModuleType(type); - - // we flush to ensure that entity is generated and we can return ID etc. - entityManager.flush(); - return new ResponseEntity<>(SoftwareModuleTypeMapper.toResponse(updatedSoftwareModuleType), HttpStatus.OK); } @@ -209,23 +178,14 @@ public class SoftwareModuleTypeResource { * failure the JsonResponseExceptionHandler is handling the * response. */ - @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { - "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = SoftwareModuleTypesRest.class, value = "Create Software Module Types", notes = "Handles the POST request of creating new software module types within SP. The request body must always be a list of module types. Required Permission: " - + SpPermission.CREATE_REPOSITORY) - @ApiResponses({ - @ApiResponse(code = 404, message = "Not Found Software Module Type", response = ExceptionInfo.class), - @ApiResponse(code = 409, message = "Conflict Software Module Type already exists", response = ExceptionInfo.class) }) - @Transactional + @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) public ResponseEntity createSoftwareModuleTypes( @RequestBody final List softwareModuleTypes) { final List createdSoftwareModules = softwareManagement .createSoftwareModuleTypes(SoftwareModuleTypeMapper.smFromRequest(softwareModuleTypes)); - // we flush to ensure that entity is generated and we can return ID etc. - entityManager.flush(); - return new ResponseEntity<>(SoftwareModuleTypeMapper.toTypesResponse(createdSoftwareModules), HttpStatus.CREATED); } @@ -233,8 +193,8 @@ public class SoftwareModuleTypeResource { private SoftwareModuleType findSoftwareModuleTypeWithExceptionIfNotFound(final Long softwareModuleTypeId) { final SoftwareModuleType module = softwareManagement.findSoftwareModuleTypeById(softwareModuleTypeId); if (module == null) { - throw new EntityNotFoundException("SoftwareModuleType with Id {" + softwareModuleTypeId - + "} does not exist"); + throw new EntityNotFoundException( + "SoftwareModuleType with Id {" + softwareModuleTypeId + "} does not exist"); } return module; } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortDirection.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortDirection.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterSyntaxErrorException.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterSyntaxErrorException.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterUnsupportedDirectionException.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterUnsupportedDirectionException.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterUnsupportedFieldException.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortParameterUnsupportedFieldException.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortUtility.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SortUtility.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemManagementResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemManagementResource.java old mode 100755 new mode 100644 index cd89efcbb..b083fe456 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemManagementResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/SystemManagementResource.java @@ -14,19 +14,23 @@ import java.util.List; import java.util.stream.Collectors; import org.eclipse.hawkbit.im.authentication.SpPermission.SpringEvalExpressions; +import org.eclipse.hawkbit.report.model.SystemUsageReport; +import org.eclipse.hawkbit.report.model.TenantUsage; import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.model.TenantConfiguration; import org.eclipse.hawkbit.rest.resource.model.system.CacheRest; +import org.eclipse.hawkbit.rest.resource.model.system.SystemStatisticsRest; import org.eclipse.hawkbit.rest.resource.model.system.TenantConfigurationRest; +import org.eclipse.hawkbit.rest.resource.model.system.TenantSystemUsageRest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -35,14 +39,13 @@ import org.springframework.web.bind.annotation.RestController; /** * {@link SystemManagement} capabilities by REST. - * + * * * * */ @RestController @RequestMapping(RestConstants.SYSTEM_ADMIN_MAPPING) -@Transactional(readOnly = true) public class SystemManagementResource { private static final Logger LOGGER = LoggerFactory.getLogger(SystemManagementResource.class); @@ -55,22 +58,53 @@ public class SystemManagementResource { /** * Deletes the tenant data of a given tenant. USE WITH CARE! - * + * * @param tenant * to delete * @return HttpStatus.OK */ @RequestMapping(method = RequestMethod.DELETE, value = "/tenants/{tenant}") - @Transactional public ResponseEntity deleteTenant(@PathVariable final String tenant) { systemManagement.deleteTenant(tenant); return new ResponseEntity<>(HttpStatus.OK); } + /** + * Collects and returns system usage statistics. It provides a system wide + * overview and tenant based stats. + * + * @return system usage statistics + */ + @RequestMapping(method = RequestMethod.GET, value = "/usage", produces = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }) + public ResponseEntity getSystemUsageStats() { + final SystemUsageReport report = systemManagement.getSystemUsageStatistics(); + + final SystemStatisticsRest result = new SystemStatisticsRest().setOverallActions(report.getOverallActions()) + .setOverallArtifacts(report.getOverallArtifacts()) + .setOverallArtifactVolumeInBytes(report.getOverallArtifactVolumeInBytes()) + .setOverallTargets(report.getOverallTargets()).setOverallTenants(report.getTenants().size()); + + result.setTenantStats(report.getTenants().stream().map(tenant -> convertTenant(tenant)) + .collect(Collectors.toList())); + + return ResponseEntity.ok(result); + } + + private static TenantSystemUsageRest convertTenant(final TenantUsage tenant) { + final TenantSystemUsageRest result = new TenantSystemUsageRest(tenant.getTenantName()); + result.setActions(tenant.getActions()); + result.setArtifacts(tenant.getArtifacts()); + result.setOverallArtifactVolumeInBytes(tenant.getOverallArtifactVolumeInBytes()); + result.setTargets(tenant.getTargets()); + + return result; + } + /** * Returns a list of all caches containing currently. - * + * * @return a list of caches for all tenants */ @RequestMapping(method = RequestMethod.GET, value = "/caches") @@ -83,7 +117,7 @@ public class SystemManagementResource { /** * Invalidates all caches for all tenants. - * + * * @return a list of cache names which has been invalidated */ @RequestMapping(method = RequestMethod.DELETE, value = "/caches") @@ -98,7 +132,7 @@ public class SystemManagementResource { /** * Adds or updates a configuration for a specific tenant to the tenant * configuration. - * + * * @param configuration * the configuration value to add or update * @param key diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TagMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TagMapper.java new file mode 100644 index 000000000..2f9e77090 --- /dev/null +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TagMapper.java @@ -0,0 +1,136 @@ +/** + * 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.rest.resource; + +import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; +import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.hawkbit.repository.model.DistributionSetTag; +import org.eclipse.hawkbit.repository.model.Tag; +import org.eclipse.hawkbit.repository.model.TargetTag; +import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut; +import org.eclipse.hawkbit.rest.resource.model.tag.TagRest; +import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest; + +/** + * A mapper which maps repository model to RESTful model representation and + * back. + * + */ +final class TagMapper { + private TagMapper() { + // Utility class + } + + static TagsRest toResponse(final List targetTags) { + final TagsRest tagsRest = new TagsRest(); + if (targetTags == null) { + return tagsRest; + } + + for (final TargetTag target : targetTags) { + final TagRest response = toResponse(target); + + tagsRest.add(response); + } + return tagsRest; + } + + static TagRest toResponse(final TargetTag targetTag) { + final TagRest response = new TagRest(); + if (targetTag == null) { + return response; + } + + mapTag(response, targetTag); + + response.add(linkTo(methodOn(TargetTagResource.class).getTargetTag(targetTag.getId())).withRel("self")); + + response.add(linkTo(methodOn(TargetTagResource.class).getAssignedTargets(targetTag.getId())).withRel( + "assignedTargets")); + + return response; + } + + static TagsRest toResponseDistributionSetTag(final List distributionSetTags) { + final TagsRest tagsRest = new TagsRest(); + if (distributionSetTags == null) { + return tagsRest; + } + + for (final DistributionSetTag distributionSetTag : distributionSetTags) { + final TagRest response = toResponse(distributionSetTag); + + tagsRest.add(response); + } + return tagsRest; + } + + static TagRest toResponse(final DistributionSetTag distributionSetTag) { + final TagRest response = new TagRest(); + if (distributionSetTag == null) { + return null; + } + + mapTag(response, distributionSetTag); + + response.add(linkTo( + methodOn(DistributionSetTagResource.class).getDistributionSetTag(distributionSetTag.getId())).withRel( + "self")); + + response.add(linkTo( + methodOn(DistributionSetTagResource.class).getAssignedDistributionSets(distributionSetTag.getId())) + .withRel("assignedDistributionSets")); + + return response; + } + + static List mapTargeTagFromRequest(final Iterable tags) { + final List mappedList = new ArrayList<>(); + for (final TagRequestBodyPut targetTagRest : tags) { + mappedList.add(new TargetTag(targetTagRest.getName(), targetTagRest.getDescription(), targetTagRest + .getColour())); + } + return mappedList; + } + + static List mapDistributionSetTagFromRequest(final Iterable tags) { + final List mappedList = new ArrayList<>(); + for (final TagRequestBodyPut targetTagRest : tags) { + mappedList.add(new DistributionSetTag(targetTagRest.getName(), targetTagRest.getDescription(), + targetTagRest.getColour())); + } + return mappedList; + } + + private static void mapTag(final TagRest response, final Tag tag) { + RestModelMapper.mapNamedToNamed(response, tag); + response.setTagId(tag.getId()); + response.setColour(tag.getColour()); + } + + static void updateTag(final TagRequestBodyPut response, final Tag tag) { + if (response.getDescription() != null) { + tag.setDescription(response.getDescription()); + } + + if (response.getColour() != null) { + tag.setColour(response.getColour()); + } + + if (response.getName() != null) { + tag.setName(response.getName()); + } + + } + +} diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetMapper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetMapper.java old mode 100755 new mode 100644 index 9d7eaaae6..f2234b2a9 --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetMapper.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetMapper.java @@ -17,6 +17,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; +import org.eclipse.hawkbit.repository.ActionFields; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.Target; @@ -35,17 +36,198 @@ import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest; * A mapper which maps repository model to RESTful model representation and * back. * - * - * - * */ -final class TargetMapper { +final public class TargetMapper { + private TargetMapper() { // Utility class } + /** + * Add links to a target response. + * + * @param response + * the target response + */ + public static void addTargetLinks(final TargetRest response) { + response.add(linkTo(methodOn(TargetResource.class).getAssignedDistributionSet(response.getControllerId())) + .withRel(RestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET)); + response.add(linkTo(methodOn(TargetResource.class).getInstalledDistributionSet(response.getControllerId())) + .withRel(RestConstants.TARGET_V1_INSTALLED_DISTRIBUTION_SET)); + response.add(linkTo(methodOn(TargetResource.class).getAttributes(response.getControllerId())).withRel( + RestConstants.TARGET_V1_ATTRIBUTES)); + response.add(linkTo( + methodOn(TargetResource.class).getActionHistory(response.getControllerId(), 0, + RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, + ActionFields.ID.getFieldName() + ":" + SortDirection.DESC, null)).withRel( + RestConstants.TARGET_V1_ACTIONS)); + } + + /** + * Add the pollstatus to a target response. + * + * @param target + * the target + * @param targetRest + * the response + */ + public static void addPollStatus(final Target target, final TargetRest targetRest) { + final PollStatus pollStatus = target.getTargetInfo().getPollStatus(); + if (pollStatus != null) { + final PollStatusRest pollStatusRest = new PollStatusRest(); + pollStatusRest.setLastRequestAt(Date.from( + pollStatus.getLastPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime()); + pollStatusRest.setNextExpectedRequestAt(Date.from( + pollStatus.getNextPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime()); + pollStatusRest.setOverdue(pollStatus.isOverdue()); + targetRest.setPollStatus(pollStatusRest); + } + } + + /** + * Create a response which includes links and pollstatus for all targets. + * + * @param targets + * the targets + * @return the response + */ + public static TargetsRest toResponseWithLinksAndPollStatus(final Iterable targets) { + final TargetsRest mappedList = new TargetsRest(); + if (targets != null) { + for (final Target target : targets) { + final TargetRest response = toResponse(target); + addPollStatus(target, response); + addTargetLinks(response); + mappedList.add(response); + } + } + return mappedList; + } + + /** + * Create a response for targets. + * + * @param targets + * list of targets + * @return the response + */ + public static TargetsRest toResponse(final Iterable targets) { + final TargetsRest mappedList = new TargetsRest(); + if (targets != null) { + for (final Target target : targets) { + final TargetRest response = toResponse(target); + mappedList.add(response); + } + } + return mappedList; + } + + /** + * Create a response for target. + * + * @param target + * the target + * @return the response + */ + public static TargetRest toResponse(final Target target) { + if (target == null) { + return null; + } + final TargetRest targetRest = new TargetRest(); + targetRest.setControllerId(target.getControllerId()); + targetRest.setDescription(target.getDescription()); + targetRest.setName(target.getName()); + targetRest.setUpdateStatus(getUpdateStatusName(target.getTargetInfo().getUpdateStatus())); + + final URI address = target.getTargetInfo().getAddress(); + if (address != null) { + targetRest.setIpAddress(address.getHost()); + targetRest.setAddress(address.toString()); + } + + targetRest.setCreatedBy(target.getCreatedBy()); + targetRest.setLastModifiedBy(target.getLastModifiedBy()); + + targetRest.setCreatedAt(target.getCreatedAt()); + targetRest.setLastModifiedAt(target.getLastModifiedAt()); + + targetRest.setSecurityToken(target.getSecurityToken()); + + // last target query is the last controller request date + final Long lastTargetQuery = target.getTargetInfo().getLastTargetQuery(); + final Long installationDate = target.getTargetInfo().getInstallationDate(); + + if (lastTargetQuery != null) { + targetRest.setLastControllerRequestAt(lastTargetQuery); + } + if (installationDate != null) { + targetRest.setInstalledAt(installationDate); + } + + targetRest.add(linkTo(methodOn(TargetResource.class).getTarget(target.getControllerId())).withRel("self")); + + return targetRest; + } + + static List fromRequest(final Iterable targetsRest) { + final List mappedList = new ArrayList<>(); + for (final TargetRequestBody targetRest : targetsRest) { + mappedList.add(fromRequest(targetRest)); + } + return mappedList; + } + + static Target fromRequest(final TargetRequestBody targetRest) { + final Target target = new Target(targetRest.getControllerId()); + target.setDescription(targetRest.getDescription()); + target.setName(targetRest.getName()); + return target; + } + + static ActionStatussRest toActionStatusRestResponse(final Action action, final List actionStatus) { + final ActionStatussRest mappedList = new ActionStatussRest(); + + if (actionStatus != null) { + for (final ActionStatus status : actionStatus) { + final ActionStatusRest response = toResponse(action, status); + mappedList.add(response); + } + } + + return mappedList; + } + + static ActionRest toResponse(final String targetId, final Action action, final boolean isActive) { + final ActionRest result = new ActionRest(); + + result.setActionId(action.getId()); + result.setType(getType(action)); + + if (isActive) { + result.setStatus(ActionRest.ACTION_PENDING); + } else { + result.setStatus(ActionRest.ACTION_FINISHED); + } + + RestModelMapper.mapBaseToBase(result, action); + + result.add(linkTo(methodOn(TargetResource.class).getAction(targetId, action.getId())).withRel("self")); + + return result; + } + + static ActionsRest toResponse(final String targetId, final List actions) { + final ActionsRest mappedList = new ActionsRest(); + + for (final Action action : actions) { + final ActionRest response = toResponse(targetId, action, action.isActive()); + mappedList.add(response); + } + return mappedList; + } + private static String getNameOfActionStatusType(final Action.Status type) { - String result = null; + String result; switch (type) { case CANCELED: @@ -86,7 +268,7 @@ final class TargetMapper { } private static String getUpdateStatusName(final TargetUpdateStatus updatestatus) { - String result = null; + String result; switch (updatestatus) { case ERROR: @@ -111,87 +293,6 @@ final class TargetMapper { return result; } - static ActionRest toResponse(final String targetId, final Action action, final boolean isActive) { - final ActionRest result = new ActionRest(); - - result.setActionId(action.getId()); - result.setType(getType(action)); - - if (isActive) { - result.setStatus(ActionRest.ACTION_PENDING); - } else { - result.setStatus(ActionRest.ACTION_FINISHED); - } - - RestModelMapper.mapBaseToBase(result, action); - - result.add(linkTo(methodOn(TargetResource.class).getAction(targetId, action.getId())).withRel("self")); - - return result; - } - - static ActionsRest toResponse(final String targetId, final List actions) { - final ActionsRest mappedList = new ActionsRest(); - - for (final Action action : actions) { - final ActionRest response = toResponse(targetId, action, action.isActive()); - mappedList.add(response); - } - return mappedList; - } - - static TargetRest toResponse(final Target target, final boolean includePollStatus) { - if (target == null) { - return null; - } - final TargetRest targetRest = new TargetRest(); - targetRest.setControllerId(target.getControllerId()); - targetRest.setDescription(target.getDescription()); - targetRest.setName(target.getName()); - targetRest.setUpdateStatus(getUpdateStatusName(target.getTargetInfo().getUpdateStatus())); - - final URI address = target.getTargetInfo().getAddress(); - if (address != null) { - targetRest.setIpAddress(address.getHost()); - targetRest.setAddress(address.toString()); - } - - targetRest.setCreatedBy(target.getCreatedBy()); - targetRest.setLastModifiedBy(target.getLastModifiedBy()); - - targetRest.setCreatedAt(target.getCreatedAt()); - targetRest.setLastModifiedAt(target.getLastModifiedAt()); - - targetRest.setSecurityToken(target.getSecurityToken()); - - // last target query is the last controller request date - final Long lastTargetQuery = target.getTargetInfo().getLastTargetQuery(); - final Long installationDate = target.getTargetInfo().getInstallationDate(); - - if (lastTargetQuery != null) { - targetRest.setLastControllerRequestAt(lastTargetQuery); - } - if (installationDate != null) { - targetRest.setInstalledAt(installationDate); - } - - if (includePollStatus) { - final PollStatus pollStatus = target.getTargetInfo().getPollStatus(); - if (pollStatus != null) { - final PollStatusRest pollStatusRest = new PollStatusRest(); - pollStatusRest.setLastRequestAt( - Date.from(pollStatus.getLastPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime()); - pollStatusRest.setNextExpectedRequestAt( - Date.from(pollStatus.getNextPollDate().atZone(ZoneId.systemDefault()).toInstant()).getTime()); - pollStatusRest.setOverdue(pollStatus.isOverdue()); - targetRest.setPollStatus(pollStatusRest); - } - } - targetRest.add(linkTo(methodOn(TargetResource.class).getTarget(target.getControllerId())).withRel("self")); - - return targetRest; - } - private static ActionStatusRest toResponse(final Action action, final ActionStatus actionStatus) { final ActionStatusRest result = new ActionStatusRest(); @@ -203,43 +304,4 @@ final class TargetMapper { return result; } - static List fromRequest(final Iterable targetsRest) { - final List mappedList = new ArrayList<>(); - for (final TargetRequestBody targetRest : targetsRest) { - mappedList.add(fromRequest(targetRest)); - } - return mappedList; - } - - static Target fromRequest(final TargetRequestBody targetRest) { - final Target target = new Target(targetRest.getControllerId()); - target.setDescription(targetRest.getDescription()); - target.setName(targetRest.getName()); - return target; - } - - static ActionStatussRest toActionStatusRestResponse(final Action action, final List actionStatus) { - final ActionStatussRest mappedList = new ActionStatussRest(); - - if (actionStatus != null) { - for (final ActionStatus status : actionStatus) { - final ActionStatusRest response = toResponse(action, status); - mappedList.add(response); - } - } - - return mappedList; - } - - static TargetsRest toResponse(final Iterable targets) { - final TargetsRest mappedList = new TargetsRest(); - if (targets != null) { - for (final Target target : targets) { - // to single response without pollstatus in the list - final TargetRest response = toResponse(target, false); - mappedList.add(response); - } - } - return mappedList; - } } diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java old mode 100755 new mode 100644 index 0715d5189..4c94ce36b --- a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetResource.java @@ -10,11 +10,6 @@ package org.eclipse.hawkbit.rest.resource; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.linkTo; import static org.springframework.hateoas.mvc.ControllerLinkBuilder.methodOn; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; import java.util.Iterator; import java.util.List; @@ -22,7 +17,6 @@ import java.util.Map; import javax.persistence.EntityManager; -import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.repository.ActionFields; import org.eclipse.hawkbit.repository.ActionStatusFields; import org.eclipse.hawkbit.repository.DeploymentManagement; @@ -36,7 +30,6 @@ import org.eclipse.hawkbit.repository.model.ActionStatus; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.rsql.RSQLUtility; import org.eclipse.hawkbit.rest.resource.helper.RestResourceConversionHelper; -import org.eclipse.hawkbit.rest.resource.model.ExceptionInfo; import org.eclipse.hawkbit.rest.resource.model.action.ActionPagedList; import org.eclipse.hawkbit.rest.resource.model.action.ActionRest; import org.eclipse.hawkbit.rest.resource.model.action.ActionStatusPagedList; @@ -58,7 +51,6 @@ import org.springframework.data.jpa.domain.Specification; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -74,9 +66,7 @@ import org.springframework.web.bind.annotation.RestController; * */ @RestController -@Transactional(readOnly = true) @RequestMapping(RestConstants.TARGET_V1_REQUEST_MAPPING) -@Api(value = "targets", description = "Provisioning Target Management API") public class TargetResource { private static final Logger LOG = LoggerFactory.getLogger(TargetResource.class); @@ -100,25 +90,12 @@ public class TargetResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = TargetRest.class, value = "Get single Target", notes = "Handles the GET request of retrieving a single target within SP. Required Permission: " - + SpPermission.READ_TARGET) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Target", response = ExceptionInfo.class)) public ResponseEntity getTarget(@PathVariable final String targetId) { final Target findTarget = findTargetWithExceptionIfNotFound(targetId); // to single response include poll status - final TargetRest response = TargetMapper.toResponse(findTarget, true); - // add links - response.add(linkTo(methodOn(TargetResource.class).getAssignedDistributionSet(response.getControllerId())) - .withRel(RestConstants.TARGET_V1_ASSIGNED_DISTRIBUTION_SET)); - response.add(linkTo(methodOn(TargetResource.class).getInstalledDistributionSet(response.getControllerId())) - .withRel(RestConstants.TARGET_V1_INSTALLED_DISTRIBUTION_SET)); - response.add(linkTo(methodOn(TargetResource.class).getAttributes(response.getControllerId())).withRel( - RestConstants.TARGET_V1_ATTRIBUTES)); - response.add(linkTo( - methodOn(TargetResource.class).getActionHistory(response.getControllerId(), 0, - RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT_VALUE, - ActionFields.ID.getFieldName() + ":" + SortDirection.DESC, null)).withRel( - RestConstants.TARGET_V1_ACTIONS)); + final TargetRest response = TargetMapper.toResponse(findTarget); + TargetMapper.addPollStatus(findTarget, response); + TargetMapper.addTargetLinks(response); return new ResponseEntity<>(response, HttpStatus.OK); } @@ -143,20 +120,11 @@ public class TargetResource { * JsonResponseExceptionHandler is handling the response. */ @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = TargetPagedList.class, value = "Get paged list of Targets", notes = "Handles the GET request of retrieving all targets within SP. Required Permission: " - + SpPermission.READ_TARGET) public ResponseEntity getTargets( @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @ApiParam(required = false, value = "FIQL syntax search query" - + "" - + "" - + "" - + "" - + "" - + "" - + "
updatestatus==unknown,updatestatus==errortargets with status 'unknown' or 'error'
installedAt=ge=1424699220targets which installation date later than 1424699220
name=li=%25ccu%25targets which contain 'ccu' in their name ingore case
controllerId==target0815target which has the ID 'target0815'
ipaddress=li=171.%25target which starts with IP address '171.'
") @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { + @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); @@ -193,19 +161,10 @@ public class TargetResource { */ @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = TargetsRest.class, value = "Create list of Targets", notes = "Handles the POST request of creating new targets within SP. The request body must always be a list of targets. Required Permission: " - + SpPermission.CREATE_TARGET) - @ApiResponses(@ApiResponse(code = 409, message = "Conflict", response = ExceptionInfo.class)) - @Transactional - public ResponseEntity createTargets( - @RequestBody @ApiParam(value = "List of targets", required = true) final List targets) { + public ResponseEntity createTargets(@RequestBody final List targets) { LOG.debug("creating {} targets", targets.size()); final Iterable createdTargets = targetManagement.createTargets(TargetMapper.fromRequest(targets)); LOG.debug("{} targets created, return status {}", targets.size(), HttpStatus.CREATED); - - // we flush to ensure that entity is generated and we can return ID etc. - entityManager.flush(); - return new ResponseEntity<>(TargetMapper.toResponse(createdTargets), HttpStatus.CREATED); } @@ -213,7 +172,7 @@ public class TargetResource { * Handles the PUT request of updating a target within SP. The ID is within * the URL path of the request. A given ID in the request body is ignored. * It's not possible to set fields to {@code null} values. - * + * * @param targetId * the path parameter which contains the ID of the target * @param targetRest @@ -225,12 +184,8 @@ public class TargetResource { */ @RequestMapping(method = RequestMethod.PUT, value = "/{targetId}", consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = TargetRest.class, value = "Updates a target", notes = "Handles the PUT request of updating a target within SP. Required Permission: " - + SpPermission.UPDATE_TARGET) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Target", response = ExceptionInfo.class)) - @Transactional public ResponseEntity updateTarget(@PathVariable final String targetId, - @RequestBody @ApiParam(value = "Target to be updated", required = true) final TargetRequestBody targetRest) { + @RequestBody final TargetRequestBody targetRest) { final Target existingTarget = findTargetWithExceptionIfNotFound(targetId); LOG.debug("updating target {}", existingTarget.getId()); if (targetRest.getDescription() != null) { @@ -240,17 +195,13 @@ public class TargetResource { existingTarget.setName(targetRest.getName()); } final Target updateTarget = targetManagement.updateTarget(existingTarget); - LOG.debug("target {} updated, return status {}", updateTarget.getId(), HttpStatus.OK); - // we flush to ensure that entity is generated and we can return ID etc. - entityManager.flush(); - - return new ResponseEntity<>(TargetMapper.toResponse(updateTarget, false), HttpStatus.OK); + return new ResponseEntity<>(TargetMapper.toResponse(updateTarget), HttpStatus.OK); } /** * Handles the DELETE request of deleting a target within SP. - * + * * @param targetId * the ID of the target to be deleted * @return If the given targetId could exists and could be deleted Http OK. @@ -259,10 +210,6 @@ public class TargetResource { */ @RequestMapping(method = RequestMethod.DELETE, value = "/{targetId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(value = "Deletes a target", notes = "Handles the DELETE request of deleting a single target within SP. Required Permission: " - + SpPermission.DELETE_TARGET) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Target", response = ExceptionInfo.class)) - @Transactional public ResponseEntity deleteTarget(@PathVariable final String targetId) { final Target target = findTargetWithExceptionIfNotFound(targetId); targetManagement.deleteTargets(target.getId()); @@ -282,9 +229,6 @@ public class TargetResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetId}/attributes", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = TargetAttributes.class, value = "Get attributes of Target", notes = "Handles the GET request of retrieving the attributes of a specific target. Reponse is a key/value list. Required Permission: " - + SpPermission.READ_TARGET) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Target", response = ExceptionInfo.class)) public ResponseEntity getAttributes(@PathVariable final String targetId) { final Target foundTarget = findTargetWithExceptionIfNotFound(targetId); final Map controllerAttributes = foundTarget.getTargetInfo().getControllerAttributes(); @@ -323,18 +267,12 @@ public class TargetResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = ActionPagedList.class, value = "List all actions of Target", notes = "Handles the GET request of retrieving the full action history of a specific target. Required Permission: " - + SpPermission.READ_TARGET) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Target", response = ExceptionInfo.class)) public ResponseEntity getActionHistory( @PathVariable final String targetId, @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, - @ApiParam(required = false, value = "FIQL syntax search query" + "" - + "" - + "" - + "
status==finishedactions which are already 'finished'
status==pendingactions which are currently in 'pending' state
") @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { + @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { final Target foundTarget = findTargetWithExceptionIfNotFound(targetId); @@ -354,8 +292,8 @@ public class TargetResource { totalActionCount = deploymentManagement.countActionsByTarget(foundTarget); } - return new ResponseEntity(new ActionPagedList(TargetMapper.toResponse(targetId, - activeActions.getContent()), totalActionCount), HttpStatus.OK); + return new ResponseEntity<>(new ActionPagedList(TargetMapper.toResponse(targetId, activeActions.getContent()), + totalActionCount), HttpStatus.OK); } /** @@ -370,9 +308,6 @@ public class TargetResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions/{actionId}", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = ActionRest.class, value = "Get assigned action of Target", notes = "Handles the GET request of retrieving a specific action on a specific target. Required Permission: " - + SpPermission.READ_TARGET) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Target or Action", response = ExceptionInfo.class)) public ResponseEntity getAction(@PathVariable final String targetId, @PathVariable final Long actionId) { final Target target = findTargetWithExceptionIfNotFound(targetId); @@ -399,17 +334,19 @@ public class TargetResource { ActionStatusFields.ID.getFieldName() + ":" + SortDirection.DESC)).withRel( RestConstants.TARGET_V1_ACTION_STATUS)); - return new ResponseEntity(result, HttpStatus.OK); + return new ResponseEntity<>(result, HttpStatus.OK); } /** * Handles the DELETE request of canceling an specific {@link Action}s of a * specific {@link Target}. - * + * * @param targetId * the ID of the target in the URL path parameter * @param actionId * the ID of the action in the URL path parameter + * @param force + * optional parameter, which indicates a force cancel * @return status no content in case cancellation was successful * @throws CancelActionNotAllowedException * if the given action is not active and cannot be canceled. @@ -417,20 +354,20 @@ public class TargetResource { * if the target or the action is not found */ @RequestMapping(method = RequestMethod.DELETE, value = "/{targetId}/actions/{actionId}") - @ApiOperation(value = "Cancels an active action", notes = "Cancels an active action, only active actions can be deleted. Required Permission: " - + SpPermission.UPDATE_TARGET) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Target or Action", response = ExceptionInfo.class)) - public ResponseEntity cancelAction(@PathVariable final String targetId, @PathVariable final Long actionId) { + public ResponseEntity cancelAction(@PathVariable final String targetId, @PathVariable final Long actionId, + @RequestParam(required = false, defaultValue = "false") final boolean force) { final Target target = findTargetWithExceptionIfNotFound(targetId); final Action action = findActionWithExceptionIfNotFound(actionId); - // cancel action will throw an exception if action cannot be canceled - // which is mapped by - // response exception handler. - deploymentManagement.cancelAction(action, target); - - return new ResponseEntity(HttpStatus.NO_CONTENT); + if (force) { + deploymentManagement.forceQuitAction(action, target); + } else { + deploymentManagement.cancelAction(action, target); + } + // both functions will throw an exception, when action is in wrong + // state, which is mapped by ResponseExceptionHandler. + return new ResponseEntity<>(HttpStatus.NO_CONTENT); } /** @@ -457,9 +394,6 @@ public class TargetResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetId}/actions/{actionId}/status", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = ActionStatusPagedList.class, value = "Get assigned action of Target", notes = "Handles the GET request of retrieving a specific action on a specific target. Required Permission: " - + SpPermission.READ_TARGET) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Target or Action", response = ExceptionInfo.class)) public ResponseEntity getActionStatusList( @PathVariable final String targetId, @PathVariable final Long actionId, @@ -500,9 +434,6 @@ public class TargetResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetId}/assignedDS", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = DistributionSetRest.class, value = "Get assigned Distribution Set of Target", notes = "Handles the GET request of retrieving the assigned distribution set of an specific target. Required Permission: " - + SpPermission.READ_TARGET) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Target", response = ExceptionInfo.class)) public ResponseEntity getAssignedDistributionSet(@PathVariable final String targetId) { final Target findTarget = findTargetWithExceptionIfNotFound(targetId); final DistributionSetRest distributionSetRest = DistributionSetMapper.toResponse(findTarget @@ -531,13 +462,8 @@ public class TargetResource { */ @RequestMapping(method = RequestMethod.POST, value = "/{targetId}/assignedDS", consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = Void.class, value = "Assigned Distribution Set to Target", notes = "Handles the POST request for assigning a distribution set to a specific target. Required Permission: " - + SpPermission.READ_REPOSITORY + " and " + SpPermission.UPDATE_TARGET) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Target", response = ExceptionInfo.class)) - @Transactional - public ResponseEntity postAssignedDistributionSet( - @PathVariable final String targetId, - @RequestBody @ApiParam(value = "Distribution Set ID", required = true) final DistributionSetAssigmentRest dsId) { + public ResponseEntity postAssignedDistributionSet(@PathVariable final String targetId, + @RequestBody final DistributionSetAssigmentRest dsId) { findTargetWithExceptionIfNotFound(targetId); final ActionType type = (dsId.getType() != null) ? RestResourceConversionHelper.convertActionType(dsId @@ -558,7 +484,7 @@ public class TargetResource { /** * Handles the GET request of retrieving the installed distribution set of * an specific target. - * + * * @param targetId * the ID of the target to retrieve * @return the assigned installed set with status OK, if none is installed @@ -568,9 +494,6 @@ public class TargetResource { */ @RequestMapping(method = RequestMethod.GET, value = "/{targetId}/installedDS", produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) - @ApiOperation(response = DistributionSetRest.class, value = "Get installed Distribution Set of Target", notes = "Handles the GET request of retrieving the installed distribution set of an specific target. Required Permission: " - + SpPermission.READ_TARGET) - @ApiResponses(@ApiResponse(code = 404, message = "Not Found Target", response = ExceptionInfo.class)) public ResponseEntity getInstalledDistributionSet(@PathVariable final String targetId) { final Target findTarget = findTargetWithExceptionIfNotFound(targetId); final DistributionSetRest distributionSetRest = DistributionSetMapper.toResponse(findTarget.getTargetInfo() diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetTagResource.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetTagResource.java new file mode 100644 index 000000000..2e5406d1e --- /dev/null +++ b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/TargetTagResource.java @@ -0,0 +1,320 @@ +/** + * 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.rest.resource; + +import java.util.List; +import java.util.stream.Collectors; + +import javax.persistence.EntityManager; + +import org.eclipse.hawkbit.repository.TagFields; +import org.eclipse.hawkbit.repository.TagManagement; +import org.eclipse.hawkbit.repository.TargetManagement; +import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; +import org.eclipse.hawkbit.repository.model.Target; +import org.eclipse.hawkbit.repository.model.TargetTag; +import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult; +import org.eclipse.hawkbit.repository.rsql.RSQLUtility; +import org.eclipse.hawkbit.rest.resource.model.tag.AssignedTargetRequestBody; +import org.eclipse.hawkbit.rest.resource.model.tag.TagPagedList; +import org.eclipse.hawkbit.rest.resource.model.tag.TagRequestBodyPut; +import org.eclipse.hawkbit.rest.resource.model.tag.TagRest; +import org.eclipse.hawkbit.rest.resource.model.tag.TagsRest; +import org.eclipse.hawkbit.rest.resource.model.tag.TargetTagAssigmentResultRest; +import org.eclipse.hawkbit.rest.resource.model.target.TargetsRest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import org.springframework.data.domain.Slice; +import org.springframework.data.domain.Sort; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +/** + * REST Resource handling for {@link Tag} CRUD operations. + * + */ +@RestController +@RequestMapping(RestConstants.TARGET_TAG_V1_REQUEST_MAPPING) +public class TargetTagResource { + private static final Logger LOG = LoggerFactory.getLogger(TargetTagResource.class); + private static final String TARGET_TAG_TAGERTS_REQUEST_MAPPING = RestConstants.TARGET_TAG_TAGERTS_REQUEST_MAPPING; + + @Autowired + private TagManagement tagManagement; + + @Autowired + private TargetManagement targetManagement; + + @Autowired + private EntityManager entityManager; + + /** + * Handles the GET request of retrieving all target tags. + * + * @param pagingOffsetParam + * the offset of list of target tags for pagination, might not be + * present in the rest request then default value will be applied + * @param pagingLimitParam + * the limit of the paged request, might not be present in the + * rest request then default value will be applied + * @param sortParam + * the sorting parameter in the request URL, syntax + * {@code field:direction, field:direction} + * @param rsqlParam + * the search parameter in the request URL, syntax + * {@code q=name==abc} + * @return a list of all target tags for a defined or default page request + * with status OK. The response is always paged. In any failure the + * JsonResponseExceptionHandler is handling the response. + */ + @RequestMapping(method = RequestMethod.GET, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) + public ResponseEntity getTargetTags( + @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_OFFSET) final int pagingOffsetParam, + @RequestParam(value = RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, defaultValue = RestConstants.REQUEST_PARAMETER_PAGING_DEFAULT_LIMIT) final int pagingLimitParam, + @RequestParam(value = RestConstants.REQUEST_PARAMETER_SORTING, required = false) final String sortParam, + @RequestParam(value = RestConstants.REQUEST_PARAMETER_SEARCH, required = false) final String rsqlParam) { + + final int sanitizedOffsetParam = PagingUtility.sanitizeOffsetParam(pagingOffsetParam); + final int sanitizedLimitParam = PagingUtility.sanitizePageLimitParam(pagingLimitParam); + final Sort sorting = PagingUtility.sanitizeTargetSortParam(sortParam); + + final Pageable pageable = new OffsetBasedPageRequest(sanitizedOffsetParam, sanitizedLimitParam, sorting); + final Slice findTargetsAll; + final Long countTargetsAll; + if (rsqlParam == null) { + findTargetsAll = tagManagement.findAllTargetTags(pageable); + countTargetsAll = tagManagement.countTargetTags(); + + } else { + final Page findTargetPage = tagManagement.findAllTargetTags( + RSQLUtility.parse(rsqlParam, TagFields.class, entityManager), pageable); + countTargetsAll = findTargetPage.getTotalElements(); + findTargetsAll = findTargetPage; + + } + + final List rest = TagMapper.toResponse(findTargetsAll.getContent()); + return new ResponseEntity<>(new TagPagedList(rest, countTargetsAll), HttpStatus.OK); + } + + /** + * Handles the GET request of retrieving a single target tag. + * + * @param targetTagId + * the ID of the target tag to retrieve + * + * @return a single target tag with status OK. + * @throws EntityNotFoundException + * in case the given {@code targetTagId} doesn't exists. + */ + @RequestMapping(method = RequestMethod.GET, value = "/{targetTagId}", produces = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }) + public ResponseEntity getTargetTag(@PathVariable final Long targetTagId) { + final TargetTag tag = findTargetTagById(targetTagId); + return new ResponseEntity<>(TagMapper.toResponse(tag), HttpStatus.OK); + } + + /** + * Handles the POST request of creating new target tag. The request body + * must always be a list of tags. + * + * @param tags + * the target tags to be created. + * @return In case all modules could successful created the ResponseEntity + * with status code 201 - Created. The Response Body are the created + * target tags but without ResponseBody. + */ + @RequestMapping(method = RequestMethod.POST, consumes = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }, produces = { + "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) + public ResponseEntity createTargetTags(@RequestBody final List tags) { + LOG.debug("creating {} target tags", tags.size()); + final List createdTargetTags = tagManagement + .createTargetTags(TagMapper.mapTargeTagFromRequest(tags)); + return new ResponseEntity<>(TagMapper.toResponse(createdTargetTags), HttpStatus.CREATED); + } + + /** + * + * Handles the PUT request of updating a single targetr tag. + * + * @param targetTagId + * the ID of the target tag + * @param restTargetTagRest + * the the request body to be updated + * @return status OK if update is successful and the updated target tag. + * @throws EntityNotFoundException + * in case the given {@code targetTagId} doesn't exists. + */ + @RequestMapping(method = RequestMethod.PUT, value = "/{targetTagId}", consumes = { "application/hal+json", + MediaType.APPLICATION_JSON_VALUE }, produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE }) + public ResponseEntity updateTagretTag(@PathVariable final Long targetTagId, + @RequestBody final TagRequestBodyPut restTargetTagRest) { + LOG.debug("update {} target tag", restTargetTagRest); + + final TargetTag targetTag = findTargetTagById(targetTagId); + TagMapper.updateTag(restTargetTagRest, targetTag); + final TargetTag updateTargetTag = tagManagement.updateTargetTag(targetTag); + + LOG.debug("target tag updated"); + + return new ResponseEntity<>(TagMapper.toResponse(updateTargetTag), HttpStatus.OK); + } + + /** + * Handles the DELETE request for a single target tag. + * + * @param targetTagId + * the ID of the target tag + * @return status OK if delete as successfully. + * @throws EntityNotFoundException + * in case the given {@code targetTagId} doesn't exists. + * + */ + @RequestMapping(method = RequestMethod.DELETE, value = "/{targetTagId}") + public ResponseEntity deleteTargetTag(@PathVariable final Long targetTagId) { + LOG.debug("Delete {} target tag", targetTagId); + final TargetTag targetTag = findTargetTagById(targetTagId); + + tagManagement.deleteTargetTag(targetTag.getName()); + + return new ResponseEntity<>(HttpStatus.OK); + } + + /** + * Handles the GET request of retrieving all assigned targets by the given + * tag id. + * + * @param targetTagId + * the ID of the target tag to retrieve + * + * @return the list of assigned targets. + * @throws EntityNotFoundException + * in case the given {@code targetTagId} doesn't exists. + */ + @RequestMapping(method = RequestMethod.GET, value = TARGET_TAG_TAGERTS_REQUEST_MAPPING) + public ResponseEntity getAssignedTargets(@PathVariable final Long targetTagId) { + final TargetTag targetTag = findTargetTagById(targetTagId); + return new ResponseEntity<>(TargetMapper.toResponseWithLinksAndPollStatus(targetTag.getAssignedToTargets()), + HttpStatus.OK); + } + + /** + * Handles the POST request to toggle the assignment of targets by the given + * tag id. + * + * @param targetTagId + * the ID of the target tag to retrieve + * @param assignedTargetRequestBodies + * list of target ids to be toggled + * + * @return the list of assigned targets and unassigned targets. + * @throws EntityNotFoundException + * in case the given {@code targetTagId} doesn't exists. + */ + @RequestMapping(method = RequestMethod.POST, value = TARGET_TAG_TAGERTS_REQUEST_MAPPING + "/toggleTagAssignment") + public ResponseEntity toggleTagAssignment(@PathVariable final Long targetTagId, + @RequestBody final List assignedTargetRequestBodies) { + LOG.debug("Toggle Target assignment {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId); + + final TargetTag targetTag = findTargetTagById(targetTagId); + final TargetTagAssigmentResult assigmentResult = targetManagement.toggleTagAssignment( + findTargetControllerIds(assignedTargetRequestBodies), targetTag.getName()); + + final TargetTagAssigmentResultRest tagAssigmentResultRest = new TargetTagAssigmentResultRest(); + tagAssigmentResultRest.setAssignedTargets(TargetMapper.toResponse(assigmentResult.getAssignedTargets())); + tagAssigmentResultRest.setUnassignedTargets(TargetMapper.toResponse(assigmentResult.getUnassignedTargets())); + return new ResponseEntity<>(tagAssigmentResultRest, HttpStatus.OK); + } + + /** + * Handles the POST request to assign targets to the given tag id. + * + * @param targetTagId + * the ID of the target tag to retrieve + * @param assignedTargetRequestBodies + * list of target ids to be assigned + * + * @return the list of assigned targets. + * @throws EntityNotFoundException + * in case the given {@code targetTagId} doesn't exists. + */ + @RequestMapping(method = RequestMethod.POST, value = TARGET_TAG_TAGERTS_REQUEST_MAPPING) + public ResponseEntity assignTargets(@PathVariable final Long targetTagId, + @RequestBody final List assignedTargetRequestBodies) { + LOG.debug("Assign Targets {} for target tag {}", assignedTargetRequestBodies.size(), targetTagId); + final TargetTag targetTag = findTargetTagById(targetTagId); + final List assignedTarget = targetManagement.assignTag( + findTargetControllerIds(assignedTargetRequestBodies), targetTag); + return new ResponseEntity<>(TargetMapper.toResponseWithLinksAndPollStatus(assignedTarget), HttpStatus.OK); + } + + /** + * Handles the DELETE request to unassign all targets from the given tag id. + * + * @param targetTagId + * the ID of the target tag to retrieve + * @return http status code + * @throws EntityNotFoundException + * in case the given {@code targetTagId} doesn't exists. + */ + @RequestMapping(method = RequestMethod.DELETE, value = TARGET_TAG_TAGERTS_REQUEST_MAPPING) + public ResponseEntity unassignTargets(@PathVariable final Long targetTagId) { + LOG.debug("Unassign all Targets for target tag {}", targetTagId); + final TargetTag targetTag = findTargetTagById(targetTagId); + if (targetTag.getAssignedToTargets() == null) { + LOG.debug("No assigned targets found"); + return new ResponseEntity<>(HttpStatus.OK); + } + targetManagement.unAssignAllTargetsByTag(targetTag); + return new ResponseEntity<>(HttpStatus.OK); + } + + /** + * Handles the DELETE request to unassign one target from the given tag id. + * + * @param targetTagId + * the ID of the target tag + * @param controllerId + * the ID of the target to unassign + * @return http status code + * @throws EntityNotFoundException + * in case the given {@code targetTagId} doesn't exists. + */ + @RequestMapping(method = RequestMethod.DELETE, value = TARGET_TAG_TAGERTS_REQUEST_MAPPING + "/{controllerId}") + public ResponseEntity unassignTarget(@PathVariable final Long targetTagId, + @PathVariable final String controllerId) { + LOG.debug("Unassign target {} for target tag {}", controllerId, targetTagId); + final TargetTag targetTag = findTargetTagById(targetTagId); + targetManagement.unAssignTag(controllerId, targetTag); + return new ResponseEntity<>(HttpStatus.OK); + } + + private TargetTag findTargetTagById(final Long targetTagId) { + final TargetTag tag = tagManagement.findTargetTagById(targetTagId); + if (tag == null) { + throw new EntityNotFoundException("Target Tag with Id {" + targetTagId + "} does not exist"); + } + return tag; + } + + private List findTargetControllerIds(final List assignedTargetRequestBodies) { + return assignedTargetRequestBodies.stream().map(request -> request.getControllerId()) + .collect(Collectors.toList()); + } +} diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/helper/ByteRange.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/helper/ByteRange.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/helper/RestResourceConversionHelper.java b/hawkbit-rest-resource/src/main/java/org/eclipse/hawkbit/rest/resource/helper/RestResourceConversionHelper.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/MockMvcResultPrinter.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/MockMvcResultPrinter.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ArtifactDownloadTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ArtifactDownloadTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/CancelActionTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/CancelActionTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ConfigDataTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/ConfigDataTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/DeploymentBaseTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/DeploymentBaseTest.java old mode 100755 new mode 100644 index cb3a684fb..e0a4b8e5c --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/DeploymentBaseTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/DeploymentBaseTest.java @@ -57,8 +57,8 @@ import ru.yandex.qatools.allure.annotations.Stories; public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB { @Test() - @Description("Ensures that artifact not found, when softare module not exists ") - public void testArtifactsNotFound() throws Exception { + @Description("Ensures that artifacts are not found, when softare module does not exists.") + public void artifactsNotFound() throws Exception { final Target target = TestDataUtil.createTarget(targetManagement); final Long softwareModuleIdNotExist = 1l; mvc.perform(get("/{tenant}/controller/v1/{targetNotExist}/softwaremodules/{softwareModuleId}/artifacts", @@ -67,8 +67,8 @@ public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB { } @Test() - @Description("Ensures that artifact are found, when softare module exists ") - public void testArtifactsExists() throws Exception { + @Description("Ensures that artifacts are found, when software module exists.") + public void artifactsExists() throws Exception { final Target target = TestDataUtil.createTarget(targetManagement); final DistributionSet distributionSet = TestDataUtil.generateDistributionSet("", softwareManagement, distributionSetManagement); @@ -91,24 +91,6 @@ public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB { } - @Test() - @Description("Ensures that software modules are found, when assigned distribution set exists with modules and atrifacts") - public void testAvailableSoftwareModulesWithArtifacts() throws Exception { - final Target target = TestDataUtil.createTarget(targetManagement); - final DistributionSet distributionSet = TestDataUtil.generateDistributionSet("", softwareManagement, - distributionSetManagement); - - deploymentManagement.assignDistributionSet(distributionSet.getId(), new String[] { target.getName() }); - final Long softwareModuleId = distributionSet.getModules().stream().findFirst().get().getId(); - TestDataUtil.generateArtifacts(artifactManagement, softwareModuleId); - - final int modulesSize = distributionSet.getModules().size(); - - mvc.perform(get("/{tenant}/controller/v1/{targetExist}/softwaremodules/", tenantAware.getCurrentTenant(), - target.getName())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("$", hasSize(modulesSize))); - } - @Test @Description("Forced deployment to a controller. Checks if the resource reponse payload for a given deployment is as expected.") public void deplomentForceAction() throws Exception { @@ -160,7 +142,6 @@ public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB { assertThat(actionStatusRepository.findAll()).hasSize(2); current = System.currentTimeMillis(); - Thread.sleep(1); final DistributionSet findDistributionSetByAction = distributionSetManagement .findDistributionSetByAction(action); @@ -284,7 +265,6 @@ public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB { assertThat(actionStatusRepository.findAll()).hasSize(2); current = System.currentTimeMillis(); - Thread.sleep(1); final DistributionSet findDistributionSetByAction = distributionSetManagement .findDistributionSetByAction(action); @@ -407,7 +387,6 @@ public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB { assertThat(actionStatusRepository.findAll()).hasSize(2); current = System.currentTimeMillis(); - Thread.sleep(1); final DistributionSet findDistributionSetByAction = distributionSetManagement .findDistributionSetByAction(action); @@ -584,17 +563,11 @@ public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB { long current = System.currentTimeMillis(); long lastModified = targetManagement.findTargetByControllerID("4712").getLastModifiedAt(); - Thread.sleep(1); // is required: otherwise processing the next line is - // often too fast and - // the following assert will fail mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + action1.getId() + "/feedback", tenantAware.getCurrentTenant()) .content(JsonBuilder.deploymentActionFeedback(action1.getId().toString(), "closed")) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); - Thread.sleep(1); // is required: otherwise processing the next line is - // often too fast and - // the following assert will fail myT = targetManagement.findTargetByControllerIDWithDetails("4712"); assertThat(myT.getTargetInfo().getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis()); assertThat(myT.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current); @@ -615,17 +588,11 @@ public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB { // action2 done current = System.currentTimeMillis(); lastModified = targetManagement.findTargetByControllerID("4712").getLastModifiedAt(); - Thread.sleep(1); // is required: otherwise processing the next line is - // often too fast and - // the following assert will fail mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + action2.getId() + "/feedback", tenantAware.getCurrentTenant()) .content(JsonBuilder.deploymentActionFeedback(action2.getId().toString(), "closed")) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); - Thread.sleep(1); // is required: otherwise processing the next line is - // often too fast and - // the following assert will fail myT = targetManagement.findTargetByControllerIDWithDetails("4712"); assertThat(myT.getTargetInfo().getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis()); assertThat(myT.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current); @@ -641,18 +608,11 @@ public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB { // action3 done current = System.currentTimeMillis(); lastModified = targetManagement.findTargetByControllerID("4712").getLastModifiedAt(); - Thread.sleep(1); // is required: otherwise processing the next line is - // often too fast and - // the following assert will fail mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + action3.getId() + "/feedback", tenantAware.getCurrentTenant()) .content(JsonBuilder.deploymentActionFeedback(action3.getId().toString(), "closed")) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); - Thread.sleep(1); // is required: otherwise processing the next line is - // often too fast and - // the following assert will fail - myT = targetManagement.findTargetByControllerID("4712"); assertThat(myT.getTargetInfo().getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis()); assertThat(myT.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current); @@ -684,17 +644,12 @@ public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB { long current = System.currentTimeMillis(); long lastModified = targetManagement.findTargetByControllerID("4712").getLastModifiedAt(); - Thread.sleep(1); // is required: otherwise processing the next line is - // often too fast and - // the following assert will fail mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + action.getId() + "/feedback", tenantAware.getCurrentTenant()) - .content(JsonBuilder.deploymentActionFeedback(action.getId().toString(), "closed", "failure")) + .content(JsonBuilder.deploymentActionFeedback(action.getId().toString(), "closed", "failure", + "error message")) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); - Thread.sleep(1); // is required: otherwise processing the next line is - // often too fast and - // the following assert will fail Target myT = targetManagement.findTargetByControllerID("4712"); assertThat(myT.getTargetInfo().getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis()); assertThat(myT.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current); @@ -720,17 +675,13 @@ public class DeploymentBaseTest extends AbstractIntegrationTestWithMongoDB { final Action action2 = deploymentManagement.findActiveActionsByTarget(myT).get(0); current = System.currentTimeMillis(); lastModified = targetManagement.findTargetByControllerID("4712").getLastModifiedAt(); - Thread.sleep(1); // is required: otherwise processing the next line is - // often too fast and - // the following assert will fail + mvc.perform(post("/{tenant}/controller/v1/4712/deploymentBase/" + action2.getId() + "/feedback", tenantAware.getCurrentTenant()) .content(JsonBuilder.deploymentActionFeedback(action2.getId().toString(), "closed", "success")) .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); - Thread.sleep(1); // is required: otherwise processing the next line is - // often too fast and - // the following assert will fail + myT = targetManagement.findTargetByControllerID("4712"); assertThat(myT.getTargetInfo().getLastTargetQuery()).isLessThanOrEqualTo(System.currentTimeMillis()); assertThat(myT.getTargetInfo().getLastTargetQuery()).isGreaterThanOrEqualTo(current); diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/RootControllerTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/RootControllerTest.java old mode 100755 new mode 100644 index 1ad71a42c..7dce6dc35 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/RootControllerTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/controller/RootControllerTest.java @@ -10,7 +10,6 @@ package org.eclipse.hawkbit.controller; import static org.fest.assertions.api.Assertions.assertThat; import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.startsWith; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; @@ -22,9 +21,8 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import java.util.ArrayList; import java.util.List; -import java.util.concurrent.Callable; -import org.eclipse.hawkbit.AbstractIntegrationTest; +import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB; import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.TestDataUtil; import org.eclipse.hawkbit.WithSpringAuthorityRule; @@ -51,40 +49,7 @@ import ru.yandex.qatools.allure.annotations.Stories; @Stories("Root Poll Resource") // TODO: fully document tests -> @Description for long text and reasonable // method name as short text -public class RootControllerTest extends AbstractIntegrationTest { - - @Test() - @Description("Ensures that software modules are not found, when target does not exists ") - public void testSoftwareModulesIfTargetNotExists() throws Exception { - final String targetNotExist = "targetNotExist"; - mvc.perform(get("/{tenant}/controller/v1/{targetNotExist}/softwaremodules/", tenantAware.getCurrentTenant(), - targetNotExist)).andDo(MockMvcResultPrinter.print()).andExpect(status().isNotFound()); - - } - - @Test() - @Description("Ensures that software modules are not found, when assigned distribution set exists with no modules") - public void testSoftwareModulesEmptyIfDistributionSetNotExists() throws Exception { - mvc.perform(get("/{tenant}/controller/v1/{targetExist}/softwaremodules/", tenantAware.getCurrentTenant(), - TestDataUtil.createTarget(targetManagement).getName())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(jsonPath("$", hasSize(0))); - } - - @Test() - @Description("Ensures that software modules are found, when assigned distribution set exists with modules") - public void testAvailableSoftwareModulesWithNoArtifacts() throws Exception { - final Target target = TestDataUtil.createTarget(targetManagement); - final DistributionSet distributionSet = TestDataUtil.generateDistributionSet("", softwareManagement, - distributionSetManagement); - - deploymentManagement.assignDistributionSet(distributionSet.getId(), new String[] { target.getName() }); - - final int modulesSize = distributionSet.getModules().size(); - - mvc.perform(get("/{tenant}/controller/v1/{targetExist}/softwaremodules/", tenantAware.getCurrentTenant(), - target.getName())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("$", hasSize(modulesSize))); - } +public class RootControllerTest extends AbstractIntegrationTestWithMongoDB { @Test() @Description("Ensures that targets cannot be created e.g. in plug'n play scenarios when tenant does not exists but can be created if the tenant exists.") @@ -105,7 +70,6 @@ public class RootControllerTest extends AbstractIntegrationTest { mvc.perform(get("/{}/controller/v1/aControllerId", tenantAware.getCurrentTenant())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()); - } @Test @@ -123,15 +87,11 @@ public class RootControllerTest extends AbstractIntegrationTest { // make a poll, audit information should not be changed, run as // controller principal! securityRule.runAs( - WithSpringAuthorityRule.withUser("controller", SpringEvalExpressions.CONTROLLER_ROLE_ANONYMOUS), - new Callable() { - @Override - public Void call() throws Exception { - mvc.perform(get("/{tenant}/controller/v1/" + knownTargetControllerId, - tenantAware.getCurrentTenant())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()); - return null; - } + WithSpringAuthorityRule.withUser("controller", SpringEvalExpressions.CONTROLLER_ROLE_ANONYMOUS), () -> { + mvc.perform( + get("/{tenant}/controller/v1/" + knownTargetControllerId, tenantAware.getCurrentTenant())) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + return null; }); // verify that audit information has not changed @@ -249,9 +209,6 @@ public class RootControllerTest extends AbstractIntegrationTest { .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaTypes.HAL_JSON)) .andExpect(jsonPath("$config.polling.sleep", equalTo("00:01:00"))); - Thread.sleep(1); // is required: otherwise processing the next line is - // often too fast and - // the following assert will fail assertThat(targetManagement.findTargetByControllerID("4711").getTargetInfo().getLastTargetQuery()) .isLessThanOrEqualTo(System.currentTimeMillis()); assertThat(targetManagement.findTargetByControllerID("4711").getTargetInfo().getLastTargetQuery()) diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetResourceTest.java old mode 100755 new mode 100644 index 72632afbf..7eccf7196 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetResourceTest.java @@ -30,6 +30,11 @@ import org.eclipse.hawkbit.AbstractIntegrationTest; import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.TestDataUtil; import org.eclipse.hawkbit.WithUser; +import org.eclipse.hawkbit.repository.ActionRepository; +import org.eclipse.hawkbit.repository.ControllerManagement; +import org.eclipse.hawkbit.repository.DistributionSetManagement; +import org.eclipse.hawkbit.repository.SoftwareManagement; +import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.exception.EntityNotFoundException; import org.eclipse.hawkbit.repository.model.Action; import org.eclipse.hawkbit.repository.model.Action.Status; @@ -48,12 +53,12 @@ import org.springframework.context.annotation.Description; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MvcResult; -import ru.yandex.qatools.allure.annotations.Features; -import ru.yandex.qatools.allure.annotations.Stories; - import com.google.common.collect.Lists; import com.jayway.jsonpath.JsonPath; +import ru.yandex.qatools.allure.annotations.Features; +import ru.yandex.qatools.allure.annotations.Stories; + /** * * @@ -78,7 +83,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { @Test @Description("This test verifies the deletion of a assigned Software Module of a Distribution Set can not be achieved when that Distribution Set has been assigned or installed to a target.") - public void testDeleteFailureWhenDistributionSetInUse() throws Exception { + public void deleteFailureWhenDistributionSetInUse() throws Exception { // create DisSet final DistributionSet disSet = TestDataUtil.generateDistributionSetWithNoSoftwareModules("Eris", "560a", @@ -92,10 +97,9 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { smList.put(new JSONObject().put("id", Long.valueOf(smID))); } // post assignment - mvc.perform( - post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") - .contentType(MediaType.APPLICATION_JSON).content(smList.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + mvc.perform(post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") + .contentType(MediaType.APPLICATION_JSON).content(smList.toString())).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); // create targets and assign DisSet to target final String[] knownTargetIds = new String[] { "1", "2" }; @@ -105,32 +109,29 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { list.put(new JSONObject().put("id", Long.valueOf(targetId))); } deploymentManagement.assignDistributionSet(disSet.getId(), knownTargetIds[0]); - mvc.perform( - post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets") - .contentType(MediaType.APPLICATION_JSON).content(list.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) + mvc.perform(post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets") + .contentType(MediaType.APPLICATION_JSON).content(list.toString())).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()).andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) .andExpect(jsonPath("$.total", equalTo(knownTargetIds.length))); - // try to delete the Software Module from DisSet that has been assigned + // try to delete the Software Module from DistSet that has been assigned // to the target. - mvc.perform( - delete( - RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM/" - + smIDs.get(0)).contentType(MediaType.APPLICATION_JSON)) + mvc.perform(delete( + RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM/" + smIDs.get(0)) + .contentType(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isLocked()) .andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.entitiylocked"))); } @Test @Description("This test verifies that the assignment of a Software Module to a Distribution Set can not be achieved when that Distribution Set has been assigned or installed to a target.") - public void testAssignmentFailureWhenAssigningToUsedDistributionSet() throws Exception { + public void assignmentFailureWhenAssigningToUsedDistributionSet() throws Exception { // create DisSet final DistributionSet disSet = TestDataUtil.generateDistributionSetWithNoSoftwareModules("Mars", "686,980", distributionSetManagement); - final List smIDs = new ArrayList(); + final List smIDs = new ArrayList<>(); SoftwareModule sm = new SoftwareModule(osType, "Phobos", "0,3189", null, null); sm = softwareManagement.createSoftwareModule(sm); smIDs.add(sm.getId()); @@ -139,10 +140,9 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { smList.put(new JSONObject().put("id", Long.valueOf(smID))); } // post assignment - mvc.perform( - post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") - .contentType(MediaType.APPLICATION_JSON).content(smList.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + mvc.perform(post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") + .contentType(MediaType.APPLICATION_JSON).content(smList.toString())).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); // create Targets final String[] knownTargetIds = new String[] { "1", "2" }; @@ -153,11 +153,9 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } // assign DisSet to target and test assignment deploymentManagement.assignDistributionSet(disSet.getId(), knownTargetIds[0]); - mvc.perform( - post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets") - .contentType(MediaType.APPLICATION_JSON).content(list.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) + mvc.perform(post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedTargets") + .contentType(MediaType.APPLICATION_JSON).content(list.toString())).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()).andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) .andExpect(jsonPath("$.total", equalTo(knownTargetIds.length))); @@ -171,9 +169,8 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { smList2.put(new JSONObject().put("id", Long.valueOf(smID))); } - mvc.perform( - post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") - .contentType(MediaType.APPLICATION_JSON).content(smList2.toString())) + mvc.perform(post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") + .contentType(MediaType.APPLICATION_JSON).content(smList2.toString())) .andDo(MockMvcResultPrinter.print()).andExpect(status().isLocked()) .andExpect(jsonPath("$.errorCode", equalTo("hawkbit.server.error.entitiylocked"))); } @@ -205,10 +202,9 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { list.put(new JSONObject().put("id", Long.valueOf(smID))); } // post assignment - mvc.perform( - post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") - .contentType(MediaType.APPLICATION_JSON).content(list.toString())) - .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); + mvc.perform(post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM") + .contentType(MediaType.APPLICATION_JSON).content(list.toString())).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()); // Test if size is 3 mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + disSet.getId() + "/assignedSM")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) @@ -216,7 +212,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test - @Description("This test verifies the rejection of Software Modules of a Distribution Set through the RESTful API.") + @Description("This test verifies the removal of Software Modules of a Distribution Set through the RESTful API.") public void unassignSoftwaremoduleFromDistributionSet() throws Exception { // Create DistributionSet with three software modules @@ -226,11 +222,11 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("$.size", equalTo(amountOfSM))); - // test the rejection of all assigned software modules one by one + // test the removal of all software modules one by one for (final Iterator iter = set.getModules().iterator(); iter.hasNext();) { final Long smId = iter.next().getId(); - mvc.perform( - delete(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM/" + smId)) + mvc.perform(delete( + RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM/" + smId)) .andExpect(status().isOk()); mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + set.getId() + "/assignedSM")) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) @@ -255,8 +251,8 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { mvc.perform( post(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets") - .contentType(MediaType.APPLICATION_JSON).content(list.toString())).andExpect(status().isOk()) - .andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) + .contentType(MediaType.APPLICATION_JSON).content(list.toString())) + .andExpect(status().isOk()).andExpect(jsonPath("$.assigned", equalTo(knownTargetIds.length - 1))) .andExpect(jsonPath("$.alreadyAssigned", equalTo(1))) .andExpect(jsonPath("$.total", equalTo(knownTargetIds.length))); } @@ -299,7 +295,8 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { // assign knownTargetId to distribution set deploymentManagement.assignDistributionSet(createdDs.getId(), knownTargetId); // make it in install state - sendUpdateActionStatusToTargets(createdDs, Lists.newArrayList(createTarget), Status.FINISHED, "some message"); + sendUpdateActionStatusToTargets(controllerManagament, targetManagement, actionRepository, createdDs, + Lists.newArrayList(createTarget), Status.FINISHED, "some message"); mvc.perform( get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/installedTargets")) @@ -308,7 +305,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test - public void testGetDistributionSetsWithoutAddtionalRequestParameters() throws Exception { + public void getDistributionSetsWithoutAddtionalRequestParameters() throws Exception { final int modules = 5; createDistributionSetsAlphabetical(modules); mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) @@ -319,13 +316,12 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test - public void testGetDistributionSetsWithPagingLimitRequestParameter() throws Exception { + public void getDistributionSetsWithPagingLimitRequestParameter() throws Exception { final int modules = 5; final int limitSize = 1; createDistributionSetsAlphabetical(modules); - mvc.perform( - get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).param( - RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) + mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) + .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(limitSize))) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(modules))) .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(limitSize))) @@ -333,15 +329,14 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test - public void testGetDistributionSetsWithPagingLimitAndOffsetRequestParameter() throws Exception { + public void getDistributionSetsWithPagingLimitAndOffsetRequestParameter() throws Exception { final int modules = 5; final int offsetParam = 2; final int expectedSize = modules - offsetParam; createDistributionSetsAlphabetical(modules); - mvc.perform( - get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING).param( - RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)).param( - RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(modules))) + mvc.perform(get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING) + .param(RestConstants.REQUEST_PARAMETER_PAGING_OFFSET, String.valueOf(offsetParam)) + .param(RestConstants.REQUEST_PARAMETER_PAGING_LIMIT, String.valueOf(modules))) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_TOTAL, equalTo(modules))) .andExpect(jsonPath(TargetResourceTest.JSON_PATH_PAGED_LIST_SIZE, equalTo(expectedSize))) @@ -350,12 +345,12 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { @Test @WithUser(principal = "uploadTester", allSpPermissions = true) - public void testGetDistributionSets() throws Exception { + public void getDistributionSets() throws Exception { // prepare test data assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0); - DistributionSet set = TestDataUtil - .generateDistributionSet("one", softwareManagement, distributionSetManagement); + DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement, + distributionSetManagement); set.setRequiredMigrationStep(set.isRequiredMigrationStep()); set = distributionSetManagement.updateDistributionSet(set); @@ -369,12 +364,10 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { // perform request mvc.perform(get("/rest/v1/distributionsets").accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andExpect( - jsonPath("$content.[0]._links.self.href", equalTo("http://localhost/rest/v1/distributionsets/" - + set.getId()))) + .andExpect(jsonPath("$content.[0]._links.self.href", + equalTo("http://localhost/rest/v1/distributionsets/" + set.getId()))) .andExpect(jsonPath("$content.[0].id", equalTo(set.getId().intValue()))) .andExpect(jsonPath("$content.[0].name", equalTo(set.getName()))) .andExpect(jsonPath("$content.[0].requiredMigrationStep", equalTo(set.isRequiredMigrationStep()))) @@ -386,41 +379,25 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { .andExpect(jsonPath("$content.[0].lastModifiedBy", equalTo(set.getLastModifiedBy()))) .andExpect(jsonPath("$content.[0].lastModifiedAt", equalTo(set.getLastModifiedAt()))) .andExpect(jsonPath("$content.[0].version", equalTo(set.getVersion()))) - .andExpect( - jsonPath("$content.[0].modules.[?(@.type==" + runtimeType.getKey() + ")][0].id", equalTo(set - .findFirstModuleByType(runtimeType).getId().intValue()))) - .andExpect( - jsonPath("$content.[0].modules.[?(@.type==" + appType.getKey() + ")][0].id", equalTo(set - .findFirstModuleByType(appType).getId().intValue()))) - .andExpect( - jsonPath("$content.[0].modules.[?(@.type==" + osType.getKey() + ")][0].id", equalTo(set - .findFirstModuleByType(osType).getId().intValue()))); + .andExpect(jsonPath("$content.[0].modules.[?(@.type==" + runtimeType.getKey() + ")][0].id", + equalTo(set.findFirstModuleByType(runtimeType).getId().intValue()))) + .andExpect(jsonPath("$content.[0].modules.[?(@.type==" + appType.getKey() + ")][0].id", + equalTo(set.findFirstModuleByType(appType).getId().intValue()))) + .andExpect(jsonPath("$content.[0].modules.[?(@.type==" + osType.getKey() + ")][0].id", + equalTo(set.findFirstModuleByType(osType).getId().intValue()))); } @Test @WithUser(principal = "uploadTester", allSpPermissions = true) - public void testGetDistributionSet() throws Exception { - // prepare test data - assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0); - - DistributionSet set = TestDataUtil - .generateDistributionSet("one", softwareManagement, distributionSetManagement); - set.setVersion("anotherVersion"); - set = distributionSetManagement.updateDistributionSet(set); - - // load also lazy stuff - set = distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()); - - assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(1); + public void getDistributionSet() throws Exception { + final DistributionSet set = createTestDistributionSet(softwareManagement, distributionSetManagement); // perform request mvc.perform(get("/rest/v1/distributionsets/{dsId}", set.getId()).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andExpect( - jsonPath("$_links.self.href", - equalTo("http://localhost/rest/v1/distributionsets/" + set.getId()))) + .andExpect(jsonPath("$_links.self.href", + equalTo("http://localhost/rest/v1/distributionsets/" + set.getId()))) .andExpect(jsonPath("$id", equalTo(set.getId().intValue()))) .andExpect(jsonPath("$name", equalTo(set.getName()))) .andExpect(jsonPath("$type", equalTo(set.getType().getKey()))) @@ -432,29 +409,26 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { .andExpect(jsonPath("$lastModifiedBy", equalTo(set.getLastModifiedBy()))) .andExpect(jsonPath("$lastModifiedAt", equalTo(set.getLastModifiedAt()))) .andExpect(jsonPath("$version", equalTo(set.getVersion()))) - .andExpect( - jsonPath("$modules.[?(@.type==" + runtimeType.getKey() + ")][0].id", equalTo(set - .findFirstModuleByType(runtimeType).getId().intValue()))) - .andExpect( - jsonPath("$modules.[?(@.type==" + appType.getKey() + ")][0].id", equalTo(set - .findFirstModuleByType(appType).getId().intValue()))) - .andExpect( - jsonPath("$modules.[?(@.type==" + osType.getKey() + ")][0].id", equalTo(set - .findFirstModuleByType(osType).getId().intValue()))); + .andExpect(jsonPath("$modules.[?(@.type==" + runtimeType.getKey() + ")][0].id", + equalTo(set.findFirstModuleByType(runtimeType).getId().intValue()))) + .andExpect(jsonPath("$modules.[?(@.type==" + appType.getKey() + ")][0].id", + equalTo(set.findFirstModuleByType(appType).getId().intValue()))) + .andExpect(jsonPath("$modules.[?(@.type==" + osType.getKey() + ")][0].id", + equalTo(set.findFirstModuleByType(osType).getId().intValue()))); } @Test @WithUser(principal = "uploadTester", allSpPermissions = true) - public void testCreateDistributionSets() throws JSONException, Exception { + public void createDistributionSets() throws JSONException, Exception { assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0); - final SoftwareModule ah = softwareManagement.createSoftwareModule(new SoftwareModule(appType, "agent-hub", - "1.0.1", null, "")); - final SoftwareModule jvm = softwareManagement.createSoftwareModule(new SoftwareModule(runtimeType, - "oracle-jre", "1.7.2", null, "")); - final SoftwareModule os = softwareManagement.createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2", - null, "")); + final SoftwareModule ah = softwareManagement + .createSoftwareModule(new SoftwareModule(appType, "agent-hub", "1.0.1", null, "")); + final SoftwareModule jvm = softwareManagement + .createSoftwareModule(new SoftwareModule(runtimeType, "oracle-jre", "1.7.2", null, "")); + final SoftwareModule os = softwareManagement + .createSoftwareModule(new SoftwareModule(osType, "poky", "3.0.2", null, "")); DistributionSet one = TestDataUtil.buildDistributionSet("one", "one", standardDsType, os, jvm, ah); DistributionSet two = TestDataUtil.buildDistributionSet("two", "two", standardDsType, os, jvm, ah); @@ -469,11 +443,9 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { final long current = System.currentTimeMillis(); final MvcResult mvcResult = mvc - .perform( - post("/rest/v1/distributionsets/").content(JsonBuilder.distributionSets(sets)) - .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) - .andDo(MockMvcResultPrinter.print()) - .andExpect(status().isCreated()) + .perform(post("/rest/v1/distributionsets/").content(JsonBuilder.distributionSets(sets)) + .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("[0]name", equalTo(one.getName()))) .andExpect(jsonPath("[0]description", equalTo(one.getDescription()))) @@ -482,30 +454,24 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { .andExpect(jsonPath("[0]version", equalTo(one.getVersion()))) .andExpect(jsonPath("[0]complete", equalTo(Boolean.TRUE))) .andExpect(jsonPath("[0]requiredMigrationStep", equalTo(one.isRequiredMigrationStep()))) - .andExpect( - jsonPath("[0].modules.[?(@.type==" + runtimeType.getKey() + ")][0].id", equalTo(one - .findFirstModuleByType(runtimeType).getId().intValue()))) - .andExpect( - jsonPath("[0].modules.[?(@.type==" + appType.getKey() + ")][0].id", equalTo(one - .findFirstModuleByType(appType).getId().intValue()))) - .andExpect( - jsonPath("[0].modules.[?(@.type==" + osType.getKey() + ")][0].id", equalTo(one - .findFirstModuleByType(osType).getId().intValue()))) + .andExpect(jsonPath("[0].modules.[?(@.type==" + runtimeType.getKey() + ")][0].id", + equalTo(one.findFirstModuleByType(runtimeType).getId().intValue()))) + .andExpect(jsonPath("[0].modules.[?(@.type==" + appType.getKey() + ")][0].id", + equalTo(one.findFirstModuleByType(appType).getId().intValue()))) + .andExpect(jsonPath("[0].modules.[?(@.type==" + osType.getKey() + ")][0].id", + equalTo(one.findFirstModuleByType(osType).getId().intValue()))) .andExpect(jsonPath("[1]name", equalTo(two.getName()))) .andExpect(jsonPath("[1]description", equalTo(two.getDescription()))) .andExpect(jsonPath("[1]complete", equalTo(Boolean.TRUE))) .andExpect(jsonPath("[1]type", equalTo(standardDsType.getKey()))) .andExpect(jsonPath("[1]createdBy", equalTo("uploadTester"))) .andExpect(jsonPath("[1]version", equalTo(two.getVersion()))) - .andExpect( - jsonPath("[1].modules.[?(@.type==" + runtimeType.getKey() + ")][0].id", equalTo(two - .findFirstModuleByType(runtimeType).getId().intValue()))) - .andExpect( - jsonPath("[1].modules.[?(@.type==" + appType.getKey() + ")][0].id", equalTo(two - .findFirstModuleByType(appType).getId().intValue()))) - .andExpect( - jsonPath("[1].modules.[?(@.type==" + osType.getKey() + ")][0].id", equalTo(two - .findFirstModuleByType(osType).getId().intValue()))) + .andExpect(jsonPath("[1].modules.[?(@.type==" + runtimeType.getKey() + ")][0].id", + equalTo(two.findFirstModuleByType(runtimeType).getId().intValue()))) + .andExpect(jsonPath("[1].modules.[?(@.type==" + appType.getKey() + ")][0].id", + equalTo(two.findFirstModuleByType(appType).getId().intValue()))) + .andExpect(jsonPath("[1].modules.[?(@.type==" + osType.getKey() + ")][0].id", + equalTo(two.findFirstModuleByType(osType).getId().intValue()))) .andExpect(jsonPath("[1]requiredMigrationStep", equalTo(two.isRequiredMigrationStep()))) .andExpect(jsonPath("[2]name", equalTo(three.getName()))) .andExpect(jsonPath("[2]description", equalTo(three.getDescription()))) @@ -513,51 +479,48 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { .andExpect(jsonPath("[2]type", equalTo(standardDsType.getKey()))) .andExpect(jsonPath("[2]createdBy", equalTo("uploadTester"))) .andExpect(jsonPath("[2]version", equalTo(three.getVersion()))) - .andExpect( - jsonPath("[2].modules.[?(@.type==" + runtimeType.getKey() + ")][0].id", equalTo(three - .findFirstModuleByType(runtimeType).getId().intValue()))) - .andExpect( - jsonPath("[2].modules.[?(@.type==" + appType.getKey() + ")][0].id", equalTo(three - .findFirstModuleByType(appType).getId().intValue()))) - .andExpect( - jsonPath("[2].modules.[?(@.type==" + osType.getKey() + ")][0].id", equalTo(three - .findFirstModuleByType(osType).getId().intValue()))) + .andExpect(jsonPath("[2].modules.[?(@.type==" + runtimeType.getKey() + ")][0].id", + equalTo(three.findFirstModuleByType(runtimeType).getId().intValue()))) + .andExpect(jsonPath("[2].modules.[?(@.type==" + appType.getKey() + ")][0].id", + equalTo(three.findFirstModuleByType(appType).getId().intValue()))) + .andExpect(jsonPath("[2].modules.[?(@.type==" + osType.getKey() + ")][0].id", + equalTo(three.findFirstModuleByType(osType).getId().intValue()))) .andExpect(jsonPath("[2]requiredMigrationStep", equalTo(three.isRequiredMigrationStep()))).andReturn(); - one = distributionSetManagement.findDistributionSetByIdWithDetails(distributionSetManagement - .findDistributionSetByNameAndVersion("one", "one").getId()); - two = distributionSetManagement.findDistributionSetByIdWithDetails(distributionSetManagement - .findDistributionSetByNameAndVersion("two", "two").getId()); - three = distributionSetManagement.findDistributionSetByIdWithDetails(distributionSetManagement - .findDistributionSetByNameAndVersion("three", "three").getId()); + one = distributionSetManagement.findDistributionSetByIdWithDetails( + distributionSetManagement.findDistributionSetByNameAndVersion("one", "one").getId()); + two = distributionSetManagement.findDistributionSetByIdWithDetails( + distributionSetManagement.findDistributionSetByNameAndVersion("two", "two").getId()); + three = distributionSetManagement.findDistributionSetByIdWithDetails( + distributionSetManagement.findDistributionSetByNameAndVersion("three", "three").getId()); assertThat( JsonPath.compile("[0]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString()) - .isEqualTo("http://localhost/rest/v1/distributionsets/" + one.getId()); + .isEqualTo("http://localhost/rest/v1/distributionsets/" + one.getId()); assertThat( JsonPath.compile("[0]_links.type.href").read(mvcResult.getResponse().getContentAsString()).toString()) - .isEqualTo("http://localhost/rest/v1/distributionsettypes/" + one.getType().getId()); + .isEqualTo("http://localhost/rest/v1/distributionsettypes/" + one.getType().getId()); - assertThat(JsonPath.compile("[0]id").read(mvcResult.getResponse().getContentAsString()).toString()).isEqualTo( - String.valueOf(one.getId())); + assertThat(JsonPath.compile("[0]id").read(mvcResult.getResponse().getContentAsString()).toString()) + .isEqualTo(String.valueOf(one.getId())); assertThat( JsonPath.compile("[1]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString()) - .isEqualTo("http://localhost/rest/v1/distributionsets/" + two.getId()); + .isEqualTo("http://localhost/rest/v1/distributionsets/" + two.getId()); assertThat( JsonPath.compile("[1]_links.type.href").read(mvcResult.getResponse().getContentAsString()).toString()) - .isEqualTo("http://localhost/rest/v1/distributionsettypes/" + two.getType().getId()); + .isEqualTo("http://localhost/rest/v1/distributionsettypes/" + two.getType().getId()); - assertThat(JsonPath.compile("[1]id").read(mvcResult.getResponse().getContentAsString()).toString()).isEqualTo( - String.valueOf(two.getId())); + assertThat(JsonPath.compile("[1]id").read(mvcResult.getResponse().getContentAsString()).toString()) + .isEqualTo(String.valueOf(two.getId())); assertThat( JsonPath.compile("[2]_links.self.href").read(mvcResult.getResponse().getContentAsString()).toString()) - .isEqualTo("http://localhost/rest/v1/distributionsets/" + three.getId()); + .isEqualTo("http://localhost/rest/v1/distributionsets/" + three.getId()); assertThat( JsonPath.compile("[2]_links.type.href").read(mvcResult.getResponse().getContentAsString()).toString()) - .isEqualTo("http://localhost/rest/v1/distributionsettypes/" + three.getType().getId()); + .isEqualTo("http://localhost/rest/v1/distributionsettypes/" + three.getType().getId()); - assertThat(JsonPath.compile("[2]id").read(mvcResult.getResponse().getContentAsString()).toString()).isEqualTo( - String.valueOf(three.getId())); + assertThat(JsonPath.compile("[2]id").read(mvcResult.getResponse().getContentAsString()).toString()) + .isEqualTo(String.valueOf(three.getId())); // check in database assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(3); @@ -611,7 +574,7 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { } @Test - public void testUpdateDistributionSet() throws Exception { + public void updateDistributionSet() throws Exception { // prepare test data assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(0); @@ -626,21 +589,19 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { update.setName(null); update.setType(standardDsType); - mvc.perform( - put("/rest/v1/distributionsets/{dsId}", set.getId()).content(JsonBuilder.distributionSet(update)) - .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) + mvc.perform(put("/rest/v1/distributionsets/{dsId}", set.getId()).content(JsonBuilder.distributionSet(update)) + .contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); - assertThat( - distributionSetManagement.findDistributionSetsAll(pageReq, false, true).getContent().get(0) - .getVersion()).isEqualTo("anotherVersion"); + assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true).getContent().get(0) + .getVersion()).isEqualTo("anotherVersion"); assertThat( distributionSetManagement.findDistributionSetsAll(pageReq, false, true).getContent().get(0).getName()) - .isEqualTo(set.getName()); + .isEqualTo(set.getName()); } @Test - public void testInvalidRequestsOnDistributionSetsResource() throws Exception { + public void invalidRequestsOnDistributionSetsResource() throws Exception { final DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement, distributionSetManagement); @@ -659,15 +620,13 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()); // bad request - bad content - mvc.perform( - post("/rest/v1/distributionsets").content("sdfjsdlkjfskdjf".getBytes()).contentType( - MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/distributionsets").content("sdfjsdlkjfskdjf".getBytes()) + .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isBadRequest()); // unsupported media type - mvc.perform( - post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(sets)).contentType( - MediaType.APPLICATION_OCTET_STREAM)).andDo(MockMvcResultPrinter.print()) + mvc.perform(post("/rest/v1/distributionsets").content(JsonBuilder.distributionSets(sets)) + .contentType(MediaType.APPLICATION_OCTET_STREAM)).andDo(MockMvcResultPrinter.print()) .andExpect(status().isUnsupportedMediaType()); // not allowed methods @@ -697,19 +656,18 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { jsonArray.put(new JSONObject().put("key", knownKey1).put("value", knownValue1)); jsonArray.put(new JSONObject().put("key", knownKey2).put("value", knownValue2)); - mvc.perform( - post("/rest/v1/distributionsets/{dsId}/metadata", testDS.getId()).contentType( - MediaType.APPLICATION_JSON).content(jsonArray.toString())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isCreated()).andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andExpect(jsonPath("[0]key", equalTo(knownKey1))) - .andExpect(jsonPath("[0]value", equalTo(knownValue1))) + mvc.perform(post("/rest/v1/distributionsets/{dsId}/metadata", testDS.getId()) + .contentType(MediaType.APPLICATION_JSON).content(jsonArray.toString())) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isCreated()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("[0]key", equalTo(knownKey1))).andExpect(jsonPath("[0]value", equalTo(knownValue1))) .andExpect(jsonPath("[1]key", equalTo(knownKey2))) .andExpect(jsonPath("[1]value", equalTo(knownValue2))); - final DistributionSetMetadata metaKey1 = distributionSetManagement.findOne(new DsMetadataCompositeKey(testDS, - knownKey1)); - final DistributionSetMetadata metaKey2 = distributionSetManagement.findOne(new DsMetadataCompositeKey(testDS, - knownKey2)); + final DistributionSetMetadata metaKey1 = distributionSetManagement + .findOne(new DsMetadataCompositeKey(testDS, knownKey1)); + final DistributionSetMetadata metaKey2 = distributionSetManagement + .findOne(new DsMetadataCompositeKey(testDS, knownKey2)); assertThat(metaKey1.getValue()).isEqualTo(knownValue1); assertThat(metaKey2.getValue()).isEqualTo(knownValue2); @@ -724,19 +682,19 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement, distributionSetManagement); - distributionSetManagement.createDistributionSetMetadata(new DistributionSetMetadata(knownKey, testDS, - knownValue)); + distributionSetManagement + .createDistributionSetMetadata(new DistributionSetMetadata(knownKey, testDS, knownValue)); final JSONObject jsonObject = new JSONObject().put("key", knownKey).put("value", updateValue); - mvc.perform( - put("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey).contentType( - MediaType.APPLICATION_JSON).content(jsonObject.toString())).andDo(MockMvcResultPrinter.print()) - .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)) + mvc.perform(put("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey) + .contentType(MediaType.APPLICATION_JSON).content(jsonObject.toString())) + .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("key", equalTo(knownKey))).andExpect(jsonPath("value", equalTo(updateValue))); - final DistributionSetMetadata assertDS = distributionSetManagement.findOne(new DsMetadataCompositeKey(testDS, - knownKey)); + final DistributionSetMetadata assertDS = distributionSetManagement + .findOne(new DsMetadataCompositeKey(testDS, knownKey)); assertThat(assertDS.getValue()).isEqualTo(updateValue); } @@ -749,8 +707,8 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement, distributionSetManagement); - distributionSetManagement.createDistributionSetMetadata(new DistributionSetMetadata(knownKey, testDS, - knownValue)); + distributionSetManagement + .createDistributionSetMetadata(new DistributionSetMetadata(knownKey, testDS, knownValue)); mvc.perform(delete("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); @@ -770,8 +728,8 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { final String knownValue = "knownValue"; final DistributionSet testDS = TestDataUtil.generateDistributionSet("one", softwareManagement, distributionSetManagement); - distributionSetManagement.createDistributionSetMetadata(new DistributionSetMetadata(knownKey, testDS, - knownValue)); + distributionSetManagement + .createDistributionSetMetadata(new DistributionSetMetadata(knownKey, testDS, knownValue)); mvc.perform(get("/rest/v1/distributionsets/{dsId}/metadata/{key}", testDS.getId(), knownKey)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) @@ -793,10 +751,12 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { distributionSetManagement.findDistributionSetById(testDS.getId()), knownValuePrefix + index)); } - mvc.perform( - get("/rest/v1/distributionsets/{dsId}/metadata?offset=" + offsetParam + "&limit=" + limitParam, - testDS.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) - .andExpect(jsonPath("size", equalTo(limitParam))).andExpect(jsonPath("total", equalTo(totalMetadata))); + mvc.perform(get("/rest/v1/distributionsets/{dsId}/metadata?offset=" + offsetParam + "&limit=" + limitParam, + testDS.getId())).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) + .andExpect(jsonPath("size", equalTo(limitParam))).andExpect(jsonPath("total", equalTo(totalMetadata))) + .andExpect(jsonPath("content[0].key", equalTo("knownKey0"))) + .andExpect(jsonPath("content[0].value", equalTo("knownValue0"))); + } @Test @@ -848,10 +808,9 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { final String rsqlFindTargetId1 = "controllerId==1"; mvc.perform( - get( - RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() - + "/assignedTargets?q=" + rsqlFindTargetId1).contentType(MediaType.APPLICATION_JSON) - .content(list.toString())).andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) + get(RestConstants.DISTRIBUTIONSET_V1_REQUEST_MAPPING + "/" + createdDs.getId() + "/assignedTargets?q=" + + rsqlFindTargetId1).contentType(MediaType.APPLICATION_JSON).content(list.toString())) + .andExpect(status().isOk()).andExpect(jsonPath("total", equalTo(1))) .andExpect(jsonPath("size", equalTo(1))).andExpect(jsonPath("content[0].controllerId", equalTo("1"))); } @@ -886,19 +845,22 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { return created; } - private List sendUpdateActionStatusToTargets(final DistributionSet dsA, final Iterable targs, - final Status status, final String... msgs) { + public static List sendUpdateActionStatusToTargets(final ControllerManagement controllerManagament, + final TargetManagement targetManagement, final ActionRepository actionRepository, final DistributionSet dsA, + final Iterable targs, final Status status, final String... msgs) { final List result = new ArrayList(); for (final Target t : targs) { final List findByTarget = actionRepository.findByTarget(t); for (final Action action : findByTarget) { - result.add(sendUpdateActionStatusToTarget(status, action, t, msgs)); + result.add(sendUpdateActionStatusToTarget(controllerManagament, targetManagement, status, action, t, + msgs)); } } return result; } - private Target sendUpdateActionStatusToTarget(final Status status, final Action updActA, final Target t, + private static Target sendUpdateActionStatusToTarget(final ControllerManagement controllerManagament, + final TargetManagement targetManagement, final Status status, final Action updActA, final Target t, final String... msgs) { updActA.setStatus(status); @@ -913,4 +875,24 @@ public class DistributionSetResourceTest extends AbstractIntegrationTest { return targetManagement.findTargetByControllerID(t.getControllerId()); } + public static DistributionSet createTestDistributionSet(final SoftwareManagement softwareManagement, + final DistributionSetManagement distributionSetManagement) { + + DistributionSet set = TestDataUtil.generateDistributionSet("one", softwareManagement, + distributionSetManagement); + set.setVersion("anotherVersion"); + set = distributionSetManagement.updateDistributionSet(set); + + set.getModules().forEach(module -> { + module.setDescription("updated description"); + softwareManagement.updateSoftwareModule(module); + }); + + // load also lazy stuff + set = distributionSetManagement.findDistributionSetByIdWithDetails(set.getId()); + + assertThat(distributionSetManagement.findDistributionSetsAll(pageReq, false, true)).hasSize(1); + return set; + } + } diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DistributionSetTypeResourceTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DownloadResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/DownloadResourceTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/JsonBuilder.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/JsonBuilder.java old mode 100755 new mode 100644 index 19728bcfa..bbed30c38 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/JsonBuilder.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/JsonBuilder.java @@ -58,6 +58,41 @@ public abstract class JsonBuilder { } + public static String softwareModulesCreatableFieldsOnly(final List modules) throws JSONException { + final StringBuilder builder = new StringBuilder(); + + builder.append("["); + int i = 0; + for (final SoftwareModule module : modules) { + try { + builder.append(new JSONObject().put("name", module.getName()) + .put("description", module.getDescription()).put("type", module.getType().getKey()) + .put("vendor", module.getVendor()).put("version", module.getVersion()).toString()); + } catch (final Exception e) { + e.printStackTrace(); + } + + if (++i < modules.size()) { + builder.append(","); + } + } + + builder.append("]"); + + return builder.toString(); + + } + + public static String softwareModuleUpdatableFieldsOnly(final SoftwareModule module) throws JSONException { + final StringBuilder builder = new StringBuilder(); + + builder.append(new JSONObject().put("description", module.getDescription()).put("vendor", module.getVendor()) + .toString()); + + return builder.toString(); + + } + public static String softwareModuleTypes(final List types) throws JSONException { final StringBuilder builder = new StringBuilder(); @@ -85,9 +120,35 @@ public abstract class JsonBuilder { } + public static String softwareModuleTypesCreatableFieldsOnly(final List types) + throws JSONException { + final StringBuilder builder = new StringBuilder(); + + builder.append("["); + int i = 0; + for (final SoftwareModuleType module : types) { + try { + builder.append(new JSONObject().put("name", module.getName()) + .put("description", module.getDescription()).put("key", module.getKey()) + .put("maxAssignments", module.getMaxAssignments()).toString()); + } catch (final Exception e) { + e.printStackTrace(); + } + + if (++i < types.size()) { + builder.append(","); + } + } + + builder.append("]"); + + return builder.toString(); + + } + /** * builds a json string for the feedback for the execution "proceeding". - * + * * @param id * of the Action feedback refers to * @return the built string @@ -99,7 +160,7 @@ public abstract class JsonBuilder { /** * builds a certain json string for a action feedback. - * + * * @param id * of the action the feedback refers to * @param execution @@ -108,14 +169,20 @@ public abstract class JsonBuilder { * @throws JSONException */ public static String deploymentActionFeedback(final String id, final String execution) throws JSONException { - return deploymentActionFeedback(id, execution, "none"); + return deploymentActionFeedback(id, execution, "none", RandomStringUtils.randomAscii(1000)); } - public static String deploymentActionFeedback(final String id, final String execution, final String finished) + public static String deploymentActionFeedback(final String id, final String execution, final String message) throws JSONException { + return deploymentActionFeedback(id, execution, "none", message); + + } + + public static String deploymentActionFeedback(final String id, final String execution, final String finished, + final String message) throws JSONException { final List messages = new ArrayList(); - messages.add(RandomStringUtils.randomAscii(1000)); + messages.add(message); return new JSONObject().put("id", id).put("time", "20140511T121314") .put("status", @@ -166,6 +233,38 @@ public abstract class JsonBuilder { return builder.toString(); } + public static String distributionSetTypesCreateValidFieldsOnly(final List types) { + final StringBuilder builder = new StringBuilder(); + + builder.append("["); + int i = 0; + for (final DistributionSetType module : types) { + + try { + + final JSONArray osmTypes = new JSONArray(); + module.getOptionalModuleTypes().forEach(smt -> osmTypes.put(new JSONObject().put("id", smt.getId()))); + + final JSONArray msmTypes = new JSONArray(); + module.getMandatoryModuleTypes().forEach(smt -> msmTypes.put(new JSONObject().put("id", smt.getId()))); + + builder.append(new JSONObject().put("name", module.getName()) + .put("description", module.getDescription()).put("key", module.getKey()) + .put("optionalmodules", osmTypes).put("mandatorymodules", msmTypes).toString()); + } catch (final Exception e) { + e.printStackTrace(); + } + + if (++i < types.size()) { + builder.append(","); + } + } + + builder.append("]"); + + return builder.toString(); + } + public static String distributionSets(final List sets) throws JSONException { final StringBuilder builder = new StringBuilder(); @@ -189,6 +288,64 @@ public abstract class JsonBuilder { } + public static String distributionSetsCreateValidFieldsOnly(final List sets) throws JSONException { + final StringBuilder builder = new StringBuilder(); + + builder.append("["); + int i = 0; + for (final DistributionSet set : sets) { + try { + builder.append(distributionSetCreateValidFieldsOnly(set)); + } catch (final Exception e) { + e.printStackTrace(); + } + + if (++i < sets.size()) { + builder.append(","); + } + } + + builder.append("]"); + + return builder.toString(); + + } + + public static String distributionSetCreateValidFieldsOnly(final DistributionSet set) throws JSONException { + + final List modules = set.getModules().stream().map(module -> { + try { + return new JSONObject().put("id", module.getId()); + } catch (final Exception e) { + e.printStackTrace(); + } + + return null; + }).collect(Collectors.toList()); + + return new JSONObject().put("name", set.getName()).put("description", set.getDescription()) + .put("type", set.getType() == null ? null : set.getType().getKey()).put("version", set.getVersion()) + .put("requiredMigrationStep", set.isRequiredMigrationStep()).put("modules", modules).toString(); + + } + + public static String distributionSetUpdateValidFieldsOnly(final DistributionSet set) throws JSONException { + + final List modules = set.getModules().stream().map(module -> { + try { + return new JSONObject().put("id", module.getId()); + } catch (final Exception e) { + e.printStackTrace(); + } + + return null; + }).collect(Collectors.toList()); + + return new JSONObject().put("name", set.getName()).put("description", set.getDescription()) + .put("version", set.getVersion()).toString(); + + } + public static String distributionSet(final DistributionSet set) throws JSONException { final List modules = set.getModules().stream().map(module -> { @@ -202,10 +359,10 @@ public abstract class JsonBuilder { }).collect(Collectors.toList()); return new JSONObject().put("name", set.getName()).put("description", set.getDescription()) - .put("type", set.getType().getKey()).put("id", Long.MAX_VALUE).put("version", set.getVersion()) - .put("createdAt", "0").put("updatedAt", "0").put("createdBy", "fghdfkjghdfkjh") - .put("updatedBy", "fghdfkjghdfkjh").put("requiredMigrationStep", set.isRequiredMigrationStep()) - .put("modules", modules).toString(); + .put("type", set.getType() == null ? null : set.getType().getKey()).put("id", Long.MAX_VALUE) + .put("version", set.getVersion()).put("createdAt", "0").put("updatedAt", "0") + .put("createdBy", "fghdfkjghdfkjh").put("updatedBy", "fghdfkjghdfkjh") + .put("requiredMigrationStep", set.isRequiredMigrationStep()).put("modules", modules).toString(); } @@ -239,8 +396,14 @@ public abstract class JsonBuilder { } public static String cancelActionFeedback(final String id, final String execution) throws JSONException { + return cancelActionFeedback(id, execution, RandomStringUtils.randomAscii(1000)); + + } + + public static String cancelActionFeedback(final String id, final String execution, final String message) + throws JSONException { final List messages = new ArrayList(); - messages.add(RandomStringUtils.randomAscii(1000)); + messages.add(message); return new JSONObject().put("id", id).put("time", "20140511T121314") .put("status", new JSONObject().put("execution", execution) diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RSQLUtilityTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/RSQLUtilityTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/ResourceUtility.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/ResourceUtility.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SMRessourceMisingMongoDbConnectionTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SMRessourceMisingMongoDbConnectionTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java old mode 100755 new mode 100644 index cfca895a6..8079b5d52 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleResourceTest.java @@ -64,16 +64,14 @@ import ru.yandex.qatools.allure.annotations.Stories; /** * Tests for {@link SoftwareModuleResource} {@link RestController}. * - * - * */ @Features("Component Tests - Management RESTful API") @Stories("Software Module Resource") -// TODO: fully document tests -> @Description for long text and reasonable -// method name as short text public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongoDB { @Test + @Description("Tests the update of software module metadata. It is verfied that only the selected fields for the update are really updated and the modification values are filled (i.e. updated by and at).") + @WithUser(principal = "smUpdateTester", allSpPermissions = true) public void updateSoftwareModuleOnlyDescriptionAndVendorNameUntouched() throws Exception { final String knownSWName = "name1"; final String knownSWVersion = "version1"; @@ -99,10 +97,16 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo final String body = new JSONObject().put("vendor", updateVendor).put("description", updateDescription) .put("name", "nameShouldNotBeChanged").toString(); + // ensures that we are not to fast so that last modified is not set + // correctly + Thread.sleep(1); + mvc.perform(put("/rest/v1/softwaremodules/{smId}", sm.getId()).content(body) .contentType(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()) .andExpect(jsonPath("$id", equalTo(sm.getId().intValue()))) .andExpect(jsonPath("$vendor", equalTo(updateVendor))) + .andExpect(jsonPath("$lastModifiedBy", equalTo("smUpdateTester"))) + .andExpect(jsonPath("$lastModifiedAt", not(equalTo(sm.getLastModifiedAt())))) .andExpect(jsonPath("$description", equalTo(updateDescription))) .andExpect(jsonPath("$name", equalTo(knownSWName))).andReturn(); @@ -112,12 +116,13 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo * Test method for * {@link org.eclipse.hawkbit.rest.resource.SoftwareModuleResource#uploadArtifact(java.lang.Long, org.springframework.web.multipart.MultipartFile)} * . - * + * * @throws Exception * if test fails */ @Test - public void testUploadArtifact() throws Exception { + @Description("Tests the uppload of an artifact binary. The upload is executed and the content checked in the repository for completenes.") + public void uploadArtifact() throws Exception { // prepare repo assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0); assertThat(artifactRepository.findAll()).hasSize(0); @@ -139,6 +144,7 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$type", equalTo("local"))).andExpect(jsonPath("$hashes.md5", equalTo(md5sum))) .andExpect(jsonPath("$hashes.sha1", equalTo(sha1sum))) + .andExpect(jsonPath("$size", equalTo(random.length))) .andExpect(jsonPath("$providedFilename", equalTo("origFilename"))).andReturn(); // check rest of response compared to DB @@ -179,7 +185,8 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test - public void testEmptyUploadArtifact() throws Exception { + @Description("Verfies that the system does not accept empty artifact uploads. Expected response: BAD REQUEST") + public void emptyUploadArtifact() throws Exception { assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0); assertThat(artifactRepository.findAll()).hasSize(0); @@ -194,7 +201,8 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test - public void testDuplicateUploadArtifact() throws Exception { + @Description("Verfies that the system does not accept identical artifacts uploads for the same software module. Expected response: CONFLICT") + public void duplicateUploadArtifact() throws Exception { assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0); assertThat(artifactRepository.findAll()).hasSize(0); @@ -218,7 +226,8 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test - public void testUploadArtifactWithCustomName() throws Exception { + @Description("verfies that option to upload artifacts with a custom defined by metadata, i.e. not the file name of the binary itself.") + public void uploadArtifactWithCustomName() throws Exception { // prepare repo assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0); assertThat(artifactRepository.findAll()).hasSize(0); @@ -247,7 +256,8 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test - public void testUploadArtifactWithHashCheck() throws Exception { + @Description("Verfies that the system refuses upload of an artifact where the provided hash sums do not match. Expected result: BAD REQUEST") + public void uploadArtifactWithHashCheck() throws Exception { // prepare repo assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0); assertThat(artifactRepository.findAll()).hasSize(0); @@ -310,16 +320,9 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } - /** - * Test method for - * {@link org.eclipse.hawkbit.rest.resource.SoftwareModuleResource#downloadArtifact(java.lang.Long, javax.servlet.http.HttpServletResponse)} - * . - * - * @throws Exception - * if test fails - */ @Test - public void testDownloadArtifact() throws Exception { + @Description("Tests binary download of an artifact including verfication that the downloaded binary is consistent and that the etag header is as expected identical to the SHA1 hash of the file.") + public void downloadArtifact() throws Exception { assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0); assertThat(artifactRepository.findAll()).hasSize(0); @@ -336,13 +339,16 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo final MvcResult result = mvc .perform( get("/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", sm.getId(), artifact.getId())) - .andExpect(header().string("ETag", artifact.getSha1Hash())).andReturn(); + .andExpect(header().string("ETag", artifact.getSha1Hash())) + .andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM)).andReturn(); assertTrue(Arrays.equals(result.getResponse().getContentAsByteArray(), random)); - final MvcResult result2 = mvc.perform( - get("/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", sm.getId(), artifact2.getId())) - .andExpect(header().string("ETag", artifact2.getSha1Hash())).andReturn(); + final MvcResult result2 = mvc + .perform(get("/rest/v1/softwaremodules/{smId}/artifacts/{artId}/download", sm.getId(), + artifact2.getId())) + .andExpect(header().string("ETag", artifact2.getSha1Hash())) + .andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM)).andReturn(); assertTrue(Arrays.equals(result2.getResponse().getContentAsByteArray(), random)); @@ -351,7 +357,8 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test - public void testGetArtifact() throws Exception { + @Description("Verifies the listing of one defined artifact assigned to a given software module. That includes the artifact metadata and download links.") + public void getArtifact() throws Exception { // check baseline assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0); assertThat(artifactRepository.findAll()).hasSize(0); @@ -381,7 +388,8 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test - public void testGetArtifacts() throws Exception { + @Description("Verifies the listing of all artifacts assigned to a software module. That includes the artifact metadata and download links.") + public void getArtifacts() throws Exception { SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null); sm = softwareManagement.createSoftwareModule(sm); @@ -420,7 +428,8 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test - public void testInvalidRequestsOnArtifactResource() throws Exception { + @Description("Verfies that the system refuses unsupported request types and answers as defined to them, e.g. NOT FOUND on a non existing resource. Or a HTTP POST for updating a resource results in METHOD NOT ALLOWED etc.") + public void invalidRequestsOnArtifactResource() throws Exception { final byte random[] = RandomStringUtils.random(5 * 1024).getBytes(); final MockMultipartFile file = new MockMultipartFile("file", "orig", null, random); @@ -455,7 +464,8 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test - public void testInvalidRequestsOnSoftwaremodulesResource() throws Exception { + @Description("Verfies that the system refuses unsupported request types and answers as defined to them, e.g. NOT FOUND on a non existing resource. Or a HTTP POST for updating a resource results in METHOD NOT ALLOWED etc.") + public void invalidRequestsOnSoftwaremodulesResource() throws Exception { SoftwareModule sm = new SoftwareModule(osType, "name 1", "version 1", null, null); sm = softwareManagement.createSoftwareModule(sm); @@ -493,7 +503,8 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test - public void testGetSoftwareModulesWithoutAddtionalRequestParameters() throws Exception { + @Description("Test of modules retrieval without any parameters. Will return all modules in the system as defined by standard page size.") + public void getSoftwareModulesWithoutAddtionalRequestParameters() throws Exception { final int modules = 5; createSoftwareModulesAlphabetical(modules); mvc.perform(get(RestConstants.SOFTWAREMODULE_V1_REQUEST_MAPPING)).andDo(MockMvcResultPrinter.print()) @@ -504,7 +515,8 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test - public void testGetSoftwareModulesWithPagingLimitRequestParameter() throws Exception { + @Description("Test of modules retrieval with paging limit parameter. Will return all modules in the system as defined by given page size.") + public void detSoftwareModulesWithPagingLimitRequestParameter() throws Exception { final int modules = 5; final int limitSize = 1; createSoftwareModulesAlphabetical(modules); @@ -517,7 +529,8 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test - public void testGetSoftwareModulesWithPagingLimitAndOffsetRequestParameter() throws Exception { + @Description("Test of modules retrieval with paging limit offset parameters. Will return all modules in the system as defined by given page size starting from given offset.") + public void getSoftwareModulesWithPagingLimitAndOffsetRequestParameter() throws Exception { final int modules = 5; final int offsetParam = 2; final int expectedSize = modules - offsetParam; @@ -533,7 +546,8 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo @Test @WithUser(principal = "uploadTester", allSpPermissions = true) - public void testGetSoftwareModules() throws Exception { + @Description("Test retrieval of all software modules the user has access to.") + public void getSoftwareModules() throws Exception { assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0); SoftwareModule os = new SoftwareModule(osType, "name1", "version1", "description1", "vendor1"); @@ -559,6 +573,11 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo equalTo("http://localhost/rest/v1/softwaremoduletypes/" + osType.getId()))) .andExpect(jsonPath("$content.[?(@.id==" + os.getId() + ")][0]._links.self.href", equalTo("http://localhost/rest/v1/softwaremodules/" + os.getId()))) + .andExpect(jsonPath("$content.[?(@.id==" + os.getId() + ")][0]._links.artifacts.href", + equalTo("http://localhost/rest/v1/softwaremodules/" + os.getId() + "/artifacts"))) + .andExpect(jsonPath("$content.[?(@.id==" + os.getId() + ")][0]._links.metadata.href", + equalTo("http://localhost/rest/v1/softwaremodules/" + os.getId() + + "/metadata?offset=0&limit=50"))) .andExpect(jsonPath("$content.[?(@.id==" + jvm.getId() + ")][0].name", equalTo("name1"))) .andExpect(jsonPath("$content.[?(@.id==" + jvm.getId() + ")][0].version", equalTo("version1"))) .andExpect(jsonPath("$content.[?(@.id==" + jvm.getId() + ")][0].description", equalTo("description1"))) @@ -571,6 +590,11 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo equalTo("http://localhost/rest/v1/softwaremoduletypes/" + runtimeType.getId()))) .andExpect(jsonPath("$content.[?(@.id==" + jvm.getId() + ")][0]._links.self.href", equalTo("http://localhost/rest/v1/softwaremodules/" + jvm.getId()))) + .andExpect(jsonPath("$content.[?(@.id==" + jvm.getId() + ")][0]._links.artifacts.href", + equalTo("http://localhost/rest/v1/softwaremodules/" + jvm.getId() + "/artifacts"))) + .andExpect(jsonPath("$content.[?(@.id==" + jvm.getId() + ")][0]._links.metadata.href", + equalTo("http://localhost/rest/v1/softwaremodules/" + jvm.getId() + + "/metadata?offset=0&limit=50"))) .andExpect(jsonPath("$content.[?(@.id==" + ah.getId() + ")][0].name", equalTo("name1"))) .andExpect(jsonPath("$content.[?(@.id==" + ah.getId() + ")][0].version", equalTo("version1"))) .andExpect(jsonPath("$content.[?(@.id==" + ah.getId() + ")][0].description", equalTo("description1"))) @@ -578,6 +602,11 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo .andExpect(jsonPath("$content.[?(@.id==" + ah.getId() + ")][0].type", equalTo("application"))) .andExpect(jsonPath("$content.[?(@.id==" + ah.getId() + ")][0].createdBy", equalTo("uploadTester"))) .andExpect(jsonPath("$content.[?(@.id==" + ah.getId() + ")][0].createdAt", equalTo(ah.getCreatedAt()))) + .andExpect(jsonPath("$content.[?(@.id==" + ah.getId() + ")][0]._links.artifacts.href", + equalTo("http://localhost/rest/v1/softwaremodules/" + ah.getId() + "/artifacts"))) + .andExpect(jsonPath("$content.[?(@.id==" + ah.getId() + ")][0]._links.metadata.href", + equalTo("http://localhost/rest/v1/softwaremodules/" + ah.getId() + + "/metadata?offset=0&limit=50"))) .andExpect(jsonPath("$content.[?(@.id==" + ah.getId() + ")][0]._links.type.href", equalTo("http://localhost/rest/v1/softwaremoduletypes/" + appType.getId()))) .andExpect(jsonPath("$content.[?(@.id==" + ah.getId() + ")][0]._links.self.href", @@ -587,7 +616,8 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test - public void testGetSoftwareModulesWithFilterParameters() throws Exception { + @Description("Test the various filter parameters, e.g. filter by name or type of the module.") + public void getSoftwareModulesWithFilterParameters() throws Exception { assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0); SoftwareModule os1 = new SoftwareModule(osType, "osName1", "1.0.0", "description1", "vendor1"); @@ -663,14 +693,16 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test - public void testGetSoftwareModulesWithSyntaxErrorFilterParameter() throws Exception { + @Description("Verfies that the system answers as defined in case of a wrong filter parameter syntax. Expected result: BAD REQUEST with error description.") + public void getSoftwareModulesWithSyntaxErrorFilterParameter() throws Exception { mvc.perform(get("/rest/v1/softwaremodules?q=wrongFIQLSyntax").accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()) .andExpect(jsonPath("$errorCode", equalTo("hawkbit.server.error.rest.param.rsqlParamSyntax"))); } @Test - public void testGetSoftwareModulesWithUnknownFieldErrorFilterParameter() throws Exception { + @Description("Verfies that the system answers as defined in case of a wnon extsing field used in filter. Expected result: BAD REQUEST with error description.") + public void getSoftwareModulesWithUnknownFieldErrorFilterParameter() throws Exception { mvc.perform(get("/rest/v1/softwaremodules?q=wrongField==abc").accept(MediaType.APPLICATION_JSON)) .andDo(MockMvcResultPrinter.print()).andExpect(status().isBadRequest()) .andExpect(jsonPath("$errorCode", equalTo("hawkbit.server.error.rest.param.rsqlInvalidField"))); @@ -693,6 +725,9 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo .andExpect(jsonPath("$vendor", equalTo("vendor1"))).andExpect(jsonPath("$type", equalTo("os"))) .andExpect(jsonPath("$createdBy", equalTo("uploadTester"))) .andExpect(jsonPath("$createdAt", equalTo(os.getCreatedAt()))) + .andExpect(jsonPath("$_links.metadata.href", + equalTo("http://localhost/rest/v1/softwaremodules/" + os.getId() + + "/metadata?offset=0&limit=50"))) .andExpect(jsonPath("$_links.type.href", equalTo("http://localhost/rest/v1/softwaremoduletypes/" + osType.getId()))) .andExpect(jsonPath("$_links.artifacts.href", @@ -709,6 +744,9 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo .andExpect(jsonPath("$vendor", equalTo("vendor1"))).andExpect(jsonPath("$type", equalTo("runtime"))) .andExpect(jsonPath("$createdBy", equalTo("uploadTester"))) .andExpect(jsonPath("$createdAt", equalTo(jvm.getCreatedAt()))) + .andExpect(jsonPath("$_links.metadata.href", + equalTo("http://localhost/rest/v1/softwaremodules/" + jvm.getId() + + "/metadata?offset=0&limit=50"))) .andExpect(jsonPath("$_links.type.href", equalTo("http://localhost/rest/v1/softwaremoduletypes/" + runtimeType.getId()))) .andExpect(jsonPath("$_links.artifacts.href", @@ -725,6 +763,9 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo .andExpect(jsonPath("$vendor", equalTo("vendor1"))).andExpect(jsonPath("$type", equalTo("application"))) .andExpect(jsonPath("$createdBy", equalTo("uploadTester"))) .andExpect(jsonPath("$createdAt", equalTo(ah.getCreatedAt()))) + .andExpect(jsonPath("$_links.metadata.href", + equalTo("http://localhost/rest/v1/softwaremodules/" + ah.getId() + + "/metadata?offset=0&limit=50"))) .andExpect(jsonPath("$_links.type.href", equalTo("http://localhost/rest/v1/softwaremoduletypes/" + appType.getId()))) .andExpect(jsonPath("$_links.artifacts.href", @@ -735,6 +776,7 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo @Test @WithUser(principal = "uploadTester", allSpPermissions = true) + @Description("Verfies that the create request actually results in the creation of the modules in the repository.") public void createSoftwareModules() throws JSONException, Exception { assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).hasSize(0); @@ -812,6 +854,7 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test + @Description("Verifies successfull deletion of software modules that are not in use, i.e. assigned to a DS.") public void deleteUnassignedSoftwareModule() throws Exception { assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).isEmpty(); assertThat(artifactRepository.findAll()).isEmpty(); @@ -837,6 +880,7 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test + @Description("Verifies successfull deletion of software modules that are in use, i.e. assigned to a DS which should result in movinf the module to the archive.") public void deleteAssignedSoftwareModule() throws Exception { // check baseline assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).isEmpty(); @@ -868,7 +912,8 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test - public void testDeleteArtifact() throws Exception { + @Description("Tests the deletion of an artifact including verfication that the artifact is actually erased in the repository and removed from the software module.") + public void deleteArtifact() throws Exception { assertThat(softwareManagement.findSoftwareModulesAll(pageReq)).isEmpty(); assertThat(artifactRepository.findAll()).isEmpty(); @@ -902,6 +947,7 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test + @Description("Verfies the successfull creation of metadata.") public void createMetadata() throws Exception { final String knownKey1 = "knownKey1"; @@ -931,6 +977,7 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test + @Description("Verfies the successfull update of metadata based on given key.") public void updateMetadata() throws Exception { // prepare and create metadata for update final String knownKey = "knownKey"; @@ -954,6 +1001,7 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test + @Description("Verfies the successfull deletion of metadata entry.") public void deleteMetadata() throws Exception { // prepare and create metadata for deletion final String knownKey = "knownKey"; @@ -975,6 +1023,7 @@ public class SoftwareModuleResourceTest extends AbstractIntegrationTestWithMongo } @Test + @Description("Verfies the successfull search of a metadata entry based on value.") public void searchSoftwareModuleMetadataRsql() throws Exception { final int totalMetadata = 10; final String knownKeyPrefix = "knownKey"; diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SoftwareModuleTypeResourceTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SortUtilityTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SortUtilityTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SystemManagementResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SystemManagementResourceTest.java old mode 100755 new mode 100644 index 4c94d03a7..8d8f9a2e4 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SystemManagementResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/SystemManagementResourceTest.java @@ -9,17 +9,28 @@ package org.eclipse.hawkbit.rest.resource; import static org.fest.assertions.api.Assertions.assertThat; +import static org.hamcrest.CoreMatchers.equalTo; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; -import org.eclipse.hawkbit.AbstractIntegrationTest; +import java.io.ByteArrayInputStream; +import java.util.List; +import java.util.Random; + +import org.eclipse.hawkbit.AbstractIntegrationTestWithMongoDB; import org.eclipse.hawkbit.MockMvcResultPrinter; import org.eclipse.hawkbit.TestDataUtil; +import org.eclipse.hawkbit.WithSpringAuthorityRule; import org.eclipse.hawkbit.WithUser; import org.eclipse.hawkbit.im.authentication.SpPermission; import org.eclipse.hawkbit.repository.model.DistributionSet; +import org.eclipse.hawkbit.repository.model.SoftwareModule; +import org.eclipse.hawkbit.repository.model.Target; import org.junit.Test; +import org.springframework.http.MediaType; import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; @@ -31,7 +42,37 @@ import ru.yandex.qatools.allure.annotations.Stories; */ @Features("Component Tests - System Management RESTful API") @Stories("System Management Resource") -public class SystemManagementResourceTest extends AbstractIntegrationTest { +public class SystemManagementResourceTest extends AbstractIntegrationTestWithMongoDB { + + @Test + @WithUser(tenantId = "mytenant", authorities = { SpPermission.SYSTEM_ADMIN }) + @Description("Tests that the system is able to collect statistics for the entire system.") + public void collectSystemStatistics() throws Exception { + createTestTenantsForSystemStatistics(2, 2000, 100, 2); + + mvc.perform(get("/system/admin/usage").accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(jsonPath("$tenantStats.[?(@.tenantName==tenant0)][0].targets", equalTo(100))) + .andExpect(jsonPath("$tenantStats.[?(@.tenantName==tenant0)][0].overallArtifactVolumeInBytes", + equalTo(2000))) + .andExpect(jsonPath("$tenantStats.[?(@.tenantName==tenant0)][0].artifacts", equalTo(1))) + .andExpect(jsonPath("$tenantStats.[?(@.tenantName==tenant0)][0].actions", equalTo(200))) + .andExpect(jsonPath("$overallTargets", equalTo(200))) + .andExpect(jsonPath("$overallArtifacts", equalTo(2))) + .andExpect(jsonPath("$overallArtifactVolumeInBytes", equalTo(4000))) + .andExpect(jsonPath("$overallActions", equalTo(400))) + .andExpect(jsonPath("$overallTenants", equalTo(4))); + } + + @Test + @WithUser(tenantId = "mytenant", authorities = { SpPermission.DELETE_TARGET, SpPermission.DELETE_REPOSITORY, + SpPermission.CREATE_REPOSITORY, SpPermission.READ_REPOSITORY }) + @Description("Tests that the system is not able to collect statistics for the entire system if the .") + public void collectSystemStatisticsWithMissingPermissionFails() throws Exception { + + mvc.perform(get("/system/admin/usage").accept(MediaType.APPLICATION_JSON)).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isForbidden()); + } @Test @WithUser(tenantId = "mytenant", allSpPermissions = true) @@ -76,4 +117,59 @@ public class SystemManagementResourceTest extends AbstractIntegrationTest { mvc.perform(delete("/system/admin/caches")).andDo(MockMvcResultPrinter.print()).andExpect(status().isOk()); } + private byte[] createTestTenantsForSystemStatistics(final int tenants, final int artifactSize, final int targets, + final int updates) throws Exception { + final Random randomgen = new Random(); + final byte random[] = new byte[artifactSize]; + randomgen.nextBytes(random); + + for (int i = 0; i < tenants; i++) { + final String tenantname = "tenant" + i; + securityRule.runAs(WithSpringAuthorityRule.withUserAndTenant("bumlux", tenantname), () -> { + systemManagement.getTenantMetadata(tenantname); + if (artifactSize > 0) { + createTestArtifact(random); + createDeletedTestArtifact(random); + } + if (targets > 0) { + final List createdTargets = createTestTargets(targets); + if (updates > 0) { + for (int x = 0; x < updates; x++) { + final DistributionSet ds = TestDataUtil.generateDistributionSet("to be deployed" + x, + softwareManagement, distributionSetManagement, true); + + deploymentManagement.assignDistributionSet(ds, createdTargets); + } + } + } + + return null; + }); + } + + return random; + } + + private List createTestTargets(final int targets) { + return targetManagement + .createTargets(TestDataUtil.buildTargetFixtures(targets, "testTargetOfTenant", "testTargetOfTenant")); + } + + private void createTestArtifact(final byte[] random) { + SoftwareModule sm = new SoftwareModule(softwareManagement.findSoftwareModuleTypeByKey("os"), "name 1", + "version 1", null, null); + sm = softwareModuleRepository.save(sm); + + artifactManagement.createLocalArtifact(new ByteArrayInputStream(random), sm.getId(), "file1", false); + } + + private void createDeletedTestArtifact(final byte[] random) { + final DistributionSet ds = TestDataUtil.generateDistributionSet("deleted garbage", softwareManagement, + distributionSetManagement, true); + ds.getModules().stream().forEach(module -> { + artifactManagement.createLocalArtifact(new ByteArrayInputStream(random), module.getId(), "file1", false); + softwareManagement.deleteSoftwareModule(module); + }); + } + } diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java old mode 100755 new mode 100644 index 0089769d0..9db578fe4 --- a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java +++ b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/TargetResourceTest.java @@ -61,6 +61,7 @@ import org.springframework.test.web.servlet.MvcResult; import com.google.common.collect.Lists; import com.jayway.jsonpath.JsonPath; +import ru.yandex.qatools.allure.annotations.Description; import ru.yandex.qatools.allure.annotations.Features; import ru.yandex.qatools.allure.annotations.Stories; @@ -228,24 +229,14 @@ public class TargetResourceTest extends AbstractIntegrationTest { @Test public void cancelActionOK() throws Exception { // prepare test - final DistributionSet dsA = TestDataUtil.generateDistributionSet("", softwareManagement, - distributionSetManagement); - ; - final Target tA = targetManagement - .createTarget(TestDataUtil.buildTargetFixture("target-id-A", "first description")); - // assign a distribution set so we get an active update action - deploymentManagement.assignDistributionSet(dsA, Lists.newArrayList(tA)); - - // verify active action - final Slice actionsByTarget = deploymentManagement.findActionsByTarget(new PageRequest(0, 100), tA); - assertThat(actionsByTarget.getContent()).hasSize(1); + Target tA = createTargetAndStartAction(); // test - cancel the active action mvc.perform(delete(RestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}", - tA.getControllerId(), actionsByTarget.getContent().get(0).getId())).andDo(MockMvcResultPrinter.print()) + tA.getControllerId(), tA.getActions().get(0).getId())).andDo(MockMvcResultPrinter.print()) .andExpect(status().isNoContent()); - final Action action = deploymentManagement.findAction(actionsByTarget.getContent().get(0).getId()); + final Action action = deploymentManagement.findAction(tA.getActions().get(0).getId()); // still active because in "canceling" state and waiting for controller // feedback assertThat(action.isActive()).isTrue(); @@ -261,18 +252,10 @@ public class TargetResourceTest extends AbstractIntegrationTest { @Test public void cancelAnCancelActionIsNotAllowed() throws Exception { // prepare test - final DistributionSet dsA = TestDataUtil.generateDistributionSet("", softwareManagement, - distributionSetManagement); - ; - Target tA = targetManagement.createTarget(TestDataUtil.buildTargetFixture("target-id-A", "first description")); - // assign a distribution set so we get an active update action - deploymentManagement.assignDistributionSet(dsA, Lists.newArrayList(tA)); - // verify active action - final Slice actionsByTarget = deploymentManagement.findActionsByTarget(new PageRequest(0, 100), tA); - assertThat(actionsByTarget.getContent()).hasSize(1); + Target tA = createTargetAndStartAction(); + // cancel the active action - tA = targetManagement.findTargetByControllerID(tA.getControllerId()); - deploymentManagement.cancelAction(actionsByTarget.getContent().get(0), tA); + deploymentManagement.cancelAction(tA.getActions().get(0), tA); // find the current active action final List cancelActions = deploymentManagement.findActionsByTarget(new PageRequest(0, 100), tA) @@ -285,6 +268,39 @@ public class TargetResourceTest extends AbstractIntegrationTest { .andExpect(status().isMethodNotAllowed()); } + @Test + @Description("Force Quit an Action, which is already canceled. Expected Result is an HTTP response code 204.") + public void forceQuitAnCanceledActionReturnsOk() throws Exception { + + Target tA = createTargetAndStartAction(); + + // cancel the active action + deploymentManagement.cancelAction(tA.getActions().get(0), tA); + + // find the current active action + final List cancelActions = deploymentManagement.findActionsByTarget(new PageRequest(0, 100), tA) + .getContent().stream().filter(action -> action.isCancelingOrCanceled()).collect(Collectors.toList()); + assertThat(cancelActions).hasSize(1); + assertThat(cancelActions.get(0).isCancelingOrCanceled()).isTrue(); + + // test - force quit an canceled action should return 204 + mvc.perform(delete(RestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}?force=true", + tA.getControllerId(), cancelActions.get(0).getId())).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isNoContent()); + } + + @Test + @Description("Force Quit an Action, which is not canceled. Expected Result is an HTTP response code 405.") + public void forceQuitAnNotCanceledActionReturnsMethodNotAllowed() throws Exception { + + Target tA = createTargetAndStartAction(); + + // test - cancel an cancel action returns forbidden + mvc.perform(delete(RestConstants.TARGET_V1_REQUEST_MAPPING + "/{targetId}/actions/{actionId}?force=true", + tA.getControllerId(), tA.getActions().get(0).getId())).andDo(MockMvcResultPrinter.print()) + .andExpect(status().isMethodNotAllowed()); + } + @Test public void deleteTargetReturnsOK() throws Exception { final String knownControllerId = "knownControllerIdDelete"; @@ -1206,4 +1222,22 @@ public class TargetResourceTest extends AbstractIntegrationTest { final ActionStatus actionStatus = new ActionStatus(action, Status.FINISHED, 0l); controllerManagement.addUpdateActionStatus(actionStatus, action); } + + /** + * helper method to create a target and start an action on it. + * + * @return The targetid of the created target. + */ + private Target createTargetAndStartAction() { + // prepare test + final DistributionSet dsA = TestDataUtil.generateDistributionSet("", softwareManagement, + distributionSetManagement); + Target tA = targetManagement.createTarget(TestDataUtil.buildTargetFixture("target-id-A", "first description")); + // assign a distribution set so we get an active update action + deploymentManagement.assignDistributionSet(dsA, Lists.newArrayList(tA)); + // verify active action + final Slice actionsByTarget = deploymentManagement.findActionsByTarget(new PageRequest(0, 100), tA); + assertThat(actionsByTarget.getContent()).hasSize(1); + return targetManagement.findTargetByControllerID(tA.getControllerId()); + } } diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/ExceptionInfoTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/PagedListTest.java b/hawkbit-rest-resource/src/test/java/org/eclipse/hawkbit/rest/resource/model/PagedListTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/test/resources/application-test.properties b/hawkbit-rest-resource/src/test/resources/application-test.properties old mode 100755 new mode 100644 diff --git a/hawkbit-rest-resource/src/test/resources/log4j2.xml b/hawkbit-rest-resource/src/test/resources/log4j2.xml new file mode 100644 index 000000000..26437af34 --- /dev/null +++ b/hawkbit-rest-resource/src/test/resources/log4j2.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/hawkbit-security-core/pom.xml b/hawkbit-security-core/pom.xml old mode 100755 new mode 100644 index 2c041260b..1b51b2de3 --- a/hawkbit-security-core/pom.xml +++ b/hawkbit-security-core/pom.xml @@ -42,7 +42,6 @@ com.google.guava guava - 18.0 org.slf4j diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/ExcludePathAwareShallowETagFilter.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/ExcludePathAwareShallowETagFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/MultitenancyIndicator.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/MultitenancyIndicator.java old mode 100755 new mode 100644 index fe5b0e6a5..53d5acfa2 --- a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/MultitenancyIndicator.java +++ b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/MultitenancyIndicator.java @@ -13,13 +13,13 @@ import org.springframework.security.authentication.AuthenticationProvider; /** * Indicates if the SP server runs in multi-tenancy mode. By means e.g. if a * login screen needs to allow to specifiy the tenant to login. - * + * * This can defere e.g. in case if the {@link AuthenticationProvider} allows * {@link TenantUserPasswordAuthenticationToken} tokens or not. - * * * */ +@FunctionalInterface public interface MultitenancyIndicator { /** diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/PermissionService.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/PermissionService.java old mode 100755 new mode 100644 index 63ec4479a..bad24e6c4 --- a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/PermissionService.java +++ b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/PermissionService.java @@ -25,7 +25,7 @@ public class PermissionService { /** * Checks if the given {@code permission} contains in the. In case no * {@code context} is available {@code false} will be returned. - * + * * @param permission * the permission to check against the * @return {@code true} if a is available and contains the given @@ -52,7 +52,7 @@ public class PermissionService { } public List getAllPermission() { - final List permissions = new ArrayList(); + final List permissions = new ArrayList<>(); final SecurityContext context = SecurityContextHolder.getContext(); if (context == null) { return permissions; @@ -71,7 +71,7 @@ public class PermissionService { * Checks if at least on permission of the given {@code permissions} * contains in the . In case no {@code context} is available {@code false} * will be returned. - * + * * @param permissions * the permissions to check against the * @return {@code true} if a is available and contains the given @@ -80,18 +80,23 @@ public class PermissionService { */ public boolean hasAtLeastOnePermission(final List permissions) { final SecurityContext context = SecurityContextHolder.getContext(); - if (context != null) { - final Authentication authentication = context.getAuthentication(); - if (authentication != null) { - for (final GrantedAuthority authority : authentication.getAuthorities()) { - for (final String permission : permissions) { - if (authority.getAuthority().equals(permission)) { - return true; - } - } + if (context == null) { + return false; + } + + final Authentication authentication = context.getAuthentication(); + if (authentication == null) { + return false; + } + + for (final GrantedAuthority authority : authentication.getAuthorities()) { + for (final String permission : permissions) { + if (authority.getAuthority().equals(permission)) { + return true; } } } + return false; } diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/SpPermission.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/SpPermission.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/TenantAwareAuthenticationDetails.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/TenantAwareAuthenticationDetails.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/TenantUserPasswordAuthenticationToken.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/TenantUserPasswordAuthenticationToken.java old mode 100755 new mode 100644 index de712ebb9..3bacfac6f --- a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/TenantUserPasswordAuthenticationToken.java +++ b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/TenantUserPasswordAuthenticationToken.java @@ -16,22 +16,19 @@ import org.springframework.security.core.GrantedAuthority; /** * The authentication token which transports the username, password and the * tenant information for authentication. - * - * - * * */ public class TenantUserPasswordAuthenticationToken extends UsernamePasswordAuthenticationToken { /** - * + * */ private static final long serialVersionUID = 1L; final Object tenant; /** - * + * * Creating a new {@link TenantUserPasswordAuthenticationToken} as * {@link #isAuthenticated()} will return {@code false}. * @@ -51,7 +48,7 @@ public class TenantUserPasswordAuthenticationToken extends UsernamePasswordAuthe /** * Creating a new {@link TenantUserPasswordAuthenticationToken} as * {@link #isAuthenticated()} will return {@code true}. - * + * * @param tenant * the tenant to authenticate against * @param principal diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/UserAuthenticationFilter.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/UserAuthenticationFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/UserPrincipal.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/im/authentication/UserPrincipal.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/DosFilter.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/DosFilter.java old mode 100755 new mode 100644 index 86b63cce4..f0d8f7d48 --- a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/DosFilter.java +++ b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/DosFilter.java @@ -98,7 +98,7 @@ public class DosFilter extends OncePerRequestFilter { /* * (non-Javadoc) - * + * * @see * org.springframework.web.filter.OncePerRequestFilter#doFilterInternal( * javax.servlet.http. HttpServletRequest, @@ -108,7 +108,7 @@ public class DosFilter extends OncePerRequestFilter { protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response, final FilterChain filterChain) throws ServletException, IOException { - boolean processChain = true; + boolean processChain; final String ip = IpUtil.getClientIpFromRequest(request, forwardHeader).getHost(); if (checkIpFails(ip)) { @@ -147,11 +147,11 @@ public class DosFilter extends OncePerRequestFilter { return true; } - private boolean checkIpFails(final String ip) { + private static boolean checkIpFails(final String ip) { return ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip); } - private boolean handleMissingIpAddress(final HttpServletResponse response) { + private static boolean handleMissingIpAddress(final HttpServletResponse response) { boolean processChain; LOG.error("Failed to get peer IP adress"); response.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value()); diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityContextTenantAware.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityContextTenantAware.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityProperties.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityProperties.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityTokenGenerator.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SecurityTokenGenerator.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SpringSecurityAuditorAware.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/security/SpringSecurityAuditorAware.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/util/IpUtil.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/util/IpUtil.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/util/SPInfo.java b/hawkbit-security-core/src/main/java/org/eclipse/hawkbit/util/SPInfo.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/ExcludePathAwareShallowETagFilterTest.java b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/ExcludePathAwareShallowETagFilterTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/security/SecurityTokenGeneratorTest.java b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/security/SecurityTokenGeneratorTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java b/hawkbit-security-core/src/test/java/org/eclipse/hawkbit/util/IpUtilTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-integration/pom.xml b/hawkbit-security-integration/pom.xml old mode 100755 new mode 100644 diff --git a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/AbstractControllerAuthenticationFilter.java b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/AbstractControllerAuthenticationFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/CoapAnonymousPreAuthenticatedFilter.java b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/CoapAnonymousPreAuthenticatedFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticateSecurityTokenFilter.java b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticateSecurityTokenFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedGatewaySecurityTokenFilter.java b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedGatewaySecurityTokenFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilter.java b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilter.java old mode 100755 new mode 100644 index 3e4b39949..066efca53 --- a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilter.java +++ b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/ControllerPreAuthenticatedSecurityHeaderFilter.java @@ -19,7 +19,7 @@ import org.slf4j.LoggerFactory; * An pre-authenticated processing filter which extracts the principal from a * request URI and the credential from a request header in a the * {@link TenantSecruityToken}. - * + * * * */ @@ -50,7 +50,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilter extends AbstractCont /** * Constructor. - * + * * @param caCommonNameHeader * the http-header which holds the common-name of the certificate * @param caAuthorityNameHeader @@ -118,7 +118,7 @@ public class ControllerPreAuthenticatedSecurityHeaderFilter extends AbstractCont private String getIssuerHashHeader(final TenantSecruityToken secruityToken, final String knownIssuerHash) { // iterate over the headers until we get a null header. int iHeader = 1; - String foundHash = null; + String foundHash; while ((foundHash = secruityToken.getHeader(String.format(sslIssuerHashBasicHeader, iHeader))) != null) { if (foundHash.equals(knownIssuerHash)) { if (LOGGER.isTraceEnabled()) { diff --git a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/HeaderAuthentication.java b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/HeaderAuthentication.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProvider.java b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/PreAuthTokenSourceTrustAuthenticationProvider.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/PreAuthenficationFilter.java b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/PreAuthenficationFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/TenantAwareWebAuthenticationDetails.java b/hawkbit-security-integration/src/main/java/org/eclipse/hawkbit/security/TenantAwareWebAuthenticationDetails.java old mode 100755 new mode 100644 diff --git a/hawkbit-test-report/placeholder.txt b/hawkbit-test-report/placeholder.txt old mode 100755 new mode 100644 diff --git a/hawkbit-test-report/pom.xml b/hawkbit-test-report/pom.xml old mode 100755 new mode 100644 diff --git a/hawkbit-test-report/src/main/assembly/test-report.xml b/hawkbit-test-report/src/main/assembly/test-report.xml old mode 100755 new mode 100644 diff --git a/hawkbit-ui/.gitignore b/hawkbit-ui/.gitignore old mode 100755 new mode 100644 diff --git a/hawkbit-ui/pom.xml b/hawkbit-ui/pom.xml old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/.gitignore b/hawkbit-ui/src/main/.gitignore old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/push/AsyncVaadinServletConfiguration.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/push/AsyncVaadinServletConfiguration.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/push/SpringSecurityAtmosphereInterceptor.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/push/SpringSecurityAtmosphereInterceptor.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/repository/OffsetBasedPageRequest.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/repository/OffsetBasedPageRequest.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/repository/SpPermissionChecker.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/repository/SpPermissionChecker.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/AppWidgetSet.gwt.xml b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/AppWidgetSet.gwt.xml old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/DefaultHawkbitUI.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/DefaultHawkbitUI.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/DispatcherRunnable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/DispatcherRunnable.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/ErrorView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/ErrorView.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/HawkbitUI.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactView.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactViewMenuItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/UploadArtifactViewMenuItem.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactBeanQuery.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java old mode 100755 new mode 100644 index f39f76b06..1dbf90e65 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/details/ArtifactDetailsLayout.java @@ -34,6 +34,7 @@ import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SpringContextHelper; +import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; @@ -96,6 +97,9 @@ public class ArtifactDetailsLayout extends VerticalLayout { @Autowired private ArtifactUploadState artifactUploadState; + @Autowired + private transient UINotification uINotification; + private Label titleOfArtifactDetails; private SPUIButton maxMinButton; @@ -121,8 +125,10 @@ public class ArtifactDetailsLayout extends VerticalLayout { ui = UI.getCurrent(); if (artifactUploadState.getSelectedBaseSoftwareModule().isPresent()) { final SoftwareModule selectedSoftwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get(); - populateArtifactDetails(selectedSoftwareModule.getId(), HawkbitCommonUtil - .getFormattedNameVersion(selectedSoftwareModule.getName(), selectedSoftwareModule.getVersion())); + populateArtifactDetails( + selectedSoftwareModule.getId(), + HawkbitCommonUtil.getFormattedNameVersion(selectedSoftwareModule.getName(), + selectedSoftwareModule.getVersion())); } if (isMaximized()) { maximizedArtifactDetailsView(); @@ -258,10 +264,10 @@ public class ArtifactDetailsLayout extends VerticalLayout { public Button generateCell(final Table source, final Object itemId, final Object columnId) { final String fileName = (String) table.getContainerDataSource().getItem(itemId) .getItemProperty(PROVIDED_FILE_NAME).getValue(); - final Button deleteIcon = SPUIComponentProvider.getButton( - fileName + "-" + SPUIComponetIdProvider.UPLOAD_FILE_DELETE_ICON, "", - SPUILabelDefinitions.DISCARD, ValoTheme.BUTTON_TINY + " " + "redicon", true, - FontAwesome.TRASH_O, SPUIButtonStyleSmallNoBorder.class); + final Button deleteIcon = SPUIComponentProvider.getButton(fileName + "-" + + SPUIComponetIdProvider.UPLOAD_FILE_DELETE_ICON, "", SPUILabelDefinitions.DISCARD, + ValoTheme.BUTTON_TINY + " " + "redicon", true, FontAwesome.TRASH_O, + SPUIButtonStyleSmallNoBorder.class); deleteIcon.setData(itemId); deleteIcon.addClickListener(event -> confirmAndDeleteArtifact((Long) itemId, fileName)); return deleteIcon; @@ -273,17 +279,22 @@ public class ArtifactDetailsLayout extends VerticalLayout { final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.delete.artifact.confirmbox"), i18n.get("message.delete.artifact", new Object[] { fileName }), i18n.get("button.ok"), - i18n.get("button.cancel"), ok -> { + i18n.get("button.cancel"), + ok -> { if (ok) { - final ArtifactManagement artifactManagement = SpringContextHelper .getBean(ArtifactManagement.class); artifactManagement.deleteLocalArtifact(id); - - populateArtifactDetails(artifactUploadState.getSelectedBaseSwModuleId().get(), - HawkbitCommonUtil.getFormattedNameVersion( - artifactUploadState.getSelectedBaseSoftwareModule().get().getName(), - artifactUploadState.getSelectedBaseSoftwareModule().get().getVersion())); + uINotification.displaySuccess(i18n.get("message.artifact.deleted", fileName)); + if (artifactUploadState.getSelectedBaseSwModuleId().isPresent()) { + populateArtifactDetails( + artifactUploadState.getSelectedBaseSwModuleId().get(), + HawkbitCommonUtil.getFormattedNameVersion(artifactUploadState + .getSelectedBaseSoftwareModule().get().getName(), artifactUploadState + .getSelectedBaseSoftwareModule().get().getVersion())); + } else { + populateArtifactDetails(null, null); + } } }); UI.getCurrent().addWindow(confirmDialog.getWindow()); @@ -458,8 +469,8 @@ public class ArtifactDetailsLayout extends VerticalLayout { if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE) { ui.access(() -> { if (softwareModuleEvent.getSoftwareModule() != null) { - populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(), - HawkbitCommonUtil.getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(), + populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(), HawkbitCommonUtil + .getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(), softwareModuleEvent.getSoftwareModule().getVersion())); } else { populateArtifactDetails(null, null); @@ -469,8 +480,8 @@ public class ArtifactDetailsLayout extends VerticalLayout { if (softwareModuleEvent.getSoftwareModuleEventType() == SoftwareModuleEventType.ARTIFACTS_CHANGED) { ui.access(() -> { if (softwareModuleEvent.getSoftwareModule() != null) { - populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(), - HawkbitCommonUtil.getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(), + populateArtifactDetails(softwareModuleEvent.getSoftwareModule().getId(), HawkbitCommonUtil + .getFormattedNameVersion(softwareModuleEvent.getSoftwareModule().getName(), softwareModuleEvent.getSoftwareModule().getVersion())); } else { populateArtifactDetails(null, null); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/ArtifactDetailsEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/ArtifactDetailsEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/SMFilterEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/SMFilterEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/SoftwareModuleEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/SoftwareModuleEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/SoftwareModuleTypeEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/SoftwareModuleTypeEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/UploadArtifactUIEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/UploadArtifactUIEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/UploadViewAcceptCriteria.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/event/UploadViewAcceptCriteria.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java old mode 100755 new mode 100644 index 42961a0fe..cfa7c2125 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/SMDeleteActionsLayout.java @@ -40,8 +40,6 @@ import com.vaadin.ui.UI; /** * Upload view footer layout implementation. * - * - * */ @SpringComponent @ViewScope @@ -72,7 +70,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { /* * (non-Javadoc) - * + * * @see * org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout#init() */ @@ -135,7 +133,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { /* * (non-Javadoc) - * + * * @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout# * hasDeletePermission() */ @@ -146,7 +144,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { /* * (non-Javadoc) - * + * * @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout# * hasUpdatePermission() */ @@ -157,7 +155,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { /* * (non-Javadoc) - * + * * @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout# * getDeleteAreaLabel() */ @@ -173,7 +171,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { /* * (non-Javadoc) - * + * * @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout# * getDeleteLayoutAcceptCriteria() */ @@ -184,7 +182,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { /* * (non-Javadoc) - * + * * @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout# * processDroppedComponent(com.vaadin .event.dd.DragAndDropEvent) */ @@ -198,13 +196,13 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { } if (sourceComponent.getId().startsWith(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX)) { - final String swModuleTypeName = sourceComponent.getId() - .replace(SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, ""); + final String swModuleTypeName = sourceComponent.getId().replace( + SPUIComponetIdProvider.UPLOAD_TYPE_BUTTON_PREFIX, ""); if (artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent() && artifactUploadState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName() .equalsIgnoreCase(swModuleTypeName)) { - notification.displayValidationError( - i18n.get("message.swmodule.type.check.delete", new Object[] { swModuleTypeName })); + notification.displayValidationError(i18n.get("message.swmodule.type.check.delete", + new Object[] { swModuleTypeName })); } else { deleteSWModuleType(swModuleTypeName); updateSWActionCount(); @@ -238,7 +236,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { /* * (non-Javadoc) - * + * * @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout# * getNoActionsButtonLabel() */ @@ -249,7 +247,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { /* * (non-Javadoc) - * + * * @see org.eclipse.hawkbit.server.ui.common.footer.DeleteActionsLayout# * getActionsButtonLabel() */ @@ -259,13 +257,13 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { } @Override - protected void reloadActionCount() { + protected void restoreActionCount() { updateSWActionCount(); } /* * (non-Javadoc) - * + * * @see * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# * getUnsavedActionsWindowCaption () @@ -277,7 +275,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { /* * (non-Javadoc) - * + * * @see * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# * unsavedActionsWindowClosed() @@ -292,7 +290,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { /* * (non-Javadoc) - * + * * @see * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# * getUnsavedActionsWindowContent () @@ -305,7 +303,7 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { /* * (non-Javadoc) - * + * * @see * org.eclipse.hawkbit.server.ui.common.footer.AbstractDeleteActionsLayout# * hasUnsavedActions() @@ -326,4 +324,52 @@ public class SMDeleteActionsLayout extends AbstractDeleteActionsLayout { return null; } + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# + * isBulkUploadAllowed() + */ + @Override + protected boolean hasBulkUploadPermission() { + return false; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# + * showBulkUploadWindow() + */ + @Override + protected void showBulkUploadWindow() { + /** + * Bulk upload not supported .No implementation required. + */ + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# + * restoreBulkUploadStatusCount() + */ + @Override + protected void restoreBulkUploadStatusCount() { + /** + * Bulk upload not supported .No implementation required. + */ + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# + * hasReadPermission() + */ + @Override + protected boolean hasReadPermission() { + return permChecker.hasReadDistributionPermission(); + } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/UploadViewConfirmationWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/footer/UploadViewConfirmationWindowLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/BaseSwModuleBeanQuery.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/ProxyBaseSoftwareModuleItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/ProxyBaseSoftwareModuleItem.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleDetails.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java old mode 100755 new mode 100644 index 5d63ed3ab..9c3c9bdbc --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTable.java @@ -100,19 +100,20 @@ public class SoftwareModuleTable extends AbstractTable { @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final SMFilterEvent filterEvent) { - UI.getCurrent().access(() -> { + UI.getCurrent().access( + () -> { - if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT - || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE - || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) { - refreshFilter(); - } - }); + if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT + || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE + || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) { + refreshFilter(); + } + }); } /* * (non-Javadoc) - * + * * @see org.eclipse.hawkbit.server.ui.common.table.SPTable#getTableId() */ @Override @@ -122,7 +123,7 @@ public class SoftwareModuleTable extends AbstractTable { /* * (non-Javadoc) - * + * * @see org.eclipse.hawkbit.server.ui.common.table.SPTable#createContainer() */ @Override @@ -138,8 +139,8 @@ public class SoftwareModuleTable extends AbstractTable { BaseSwModuleBeanQuery.class); swQF.setQueryConfiguration(queryConfiguration); - final LazyQueryContainer container = new LazyQueryContainer( - new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, "swId"), swQF); + final LazyQueryContainer container = new LazyQueryContainer(new LazyQueryDefinition(true, + SPUIDefinitions.PAGE_SIZE, "swId"), swQF); return container; } @@ -170,7 +171,7 @@ public class SoftwareModuleTable extends AbstractTable { /* * (non-Javadoc) - * + * * @see * org.eclipse.hawkbit.server.ui.common.table.SPTable#getItemIdToSelect() */ @@ -181,7 +182,7 @@ public class SoftwareModuleTable extends AbstractTable { /* * (non-Javadoc) - * + * * @see org.eclipse.hawkbit.server.ui.common.table.SPTable#isMaximized() */ @Override @@ -206,8 +207,8 @@ public class SoftwareModuleTable extends AbstractTable { final SoftwareModule baseSoftwareModule = softwareManagement.findSoftwareModuleById(value); artifactUploadState.setSelectedBaseSoftwareModule(baseSoftwareModule); artifactUploadState.setSelectedSoftwareModules(values); - eventBus.publish(this, - new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE, baseSoftwareModule)); + eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE, + baseSoftwareModule)); } } else { artifactUploadState.setSelectedBaseSwModuleId(null); @@ -255,15 +256,19 @@ public class SoftwareModuleTable extends AbstractTable { item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(swModule.getVendor()); item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).setValue(swModule.getCreatedBy()); item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue(swModule.getLastModifiedBy()); - item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE) - .setValue(SPDateTimeUtil.getFormattedDate(swModule.getCreatedAt())); - item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE) - .setValue(SPDateTimeUtil.getFormattedDate(swModule.getLastModifiedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE).setValue( + SPDateTimeUtil.getFormattedDate(swModule.getCreatedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE).setValue( + SPDateTimeUtil.getFormattedDate(swModule.getLastModifiedAt())); + if (!artifactUploadState.getSelectedSoftwareModules().isEmpty()) { + artifactUploadState.getSelectedSoftwareModules().stream().forEach(swmNameId -> unselect(swmNameId)); + } + select(swModule.getId()); } /* * (non-Javadoc) - * + * * @see * org.eclipse.hawkbit.server.ui.common.table.SPTable#getTableVisibleColumns * () @@ -272,20 +277,20 @@ public class SoftwareModuleTable extends AbstractTable { protected List getTableVisibleColumns() { final List columnList = new ArrayList(); if (isMaximized()) { - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.1f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VENDOR, i18n.get("header.vendor"), 0.1f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VENDOR, i18n.get("header.vendor"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F)); columnList - .add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1f)); - columnList.add( - new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), - 0.1f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2f)); + .add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), + 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, + i18n.get("header.modifiedDate"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2F)); } else { - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.8f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.2f)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.8F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.2F)); } return columnList; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTableHeader.java old mode 100755 new mode 100644 index 5725d9203..b08c4defb --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTableHeader.java @@ -368,4 +368,15 @@ public class SoftwareModuleTableHeader extends AbstractTableHeader { return Boolean.FALSE; } + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.common.table.AbstractTableHeader# + * isBulkUploadInProgress() + */ + @Override + protected boolean isBulkUploadInProgress() { + return false; + } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTableLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleTableLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/CreateUpdateSoftwareTypeLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterButtonClick.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterButtonClick.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterButtons.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterHeader.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtype/SMTypeFilterLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadState.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/ArtifactUploadState.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/CustomFile.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/CustomFile.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/SoftwareModuleFilters.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/state/SoftwareModuleFilters.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadConfirmationwindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadConfirmationwindow.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadHandler.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadResultWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadResultWindow.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadStatus.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadStatus.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadStatusInfoWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/upload/UploadStatusInfoWindow.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/AbstractAcceptCriteria.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/AbstractAcceptCriteria.java old mode 100755 new mode 100644 index 4b8d1e28a..a6df4f557 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/AbstractAcceptCriteria.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/AbstractAcceptCriteria.java @@ -8,6 +8,7 @@ */ package org.eclipse.hawkbit.ui.common; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -99,7 +100,12 @@ public abstract class AbstractAcceptCriteria extends ServerSideCriterion { */ protected void showRowCount(final DragAndDropEvent dragEvent, final Table compsource) { /* Show the number of rows that are dragging in the drag image */ - final Set targetSelectedList = (Set) compsource.getValue(); + final Set targetSelectedList = new HashSet<>((Set) compsource.getValue()); + /** + * Remove null value if any . + */ + targetSelectedList.remove(null); + if (previousRowCount != targetSelectedList.size()) { previousRowCount = targetSelectedList.size(); /* diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/ConfirmationDialog.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/ConfirmationDialog.java old mode 100755 new mode 100644 index 6a07ecb82..7ee6de97c --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/ConfirmationDialog.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/ConfirmationDialog.java @@ -13,6 +13,8 @@ import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny; import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; +import com.vaadin.server.Resource; +import com.vaadin.shared.ui.label.ContentMode; import com.vaadin.ui.Alignment; import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; @@ -25,7 +27,7 @@ import com.vaadin.ui.themes.ValoTheme; /** * - * module. + * module. * * * @@ -55,9 +57,34 @@ public class ConfirmationDialog implements Button.ClickListener { */ public ConfirmationDialog(final String caption, final String question, final String okLabel, final String cancelLabel, final ConfirmationDialogCallback callback) { + this(caption, question, okLabel, cancelLabel, callback, null); + } + + /** + * Constructor for configuring confirmation dialog. + * + * @param caption + * the dialog caption. + * @param question + * the question. + * @param okLabel + * the Ok button label. + * @param cancelLabel + * the cancel button label. + * @param callback + * the callback. + * @param icon + * the icon of the dialog + */ + public ConfirmationDialog(final String caption, final String question, final String okLabel, + final String cancelLabel, final ConfirmationDialogCallback callback, final Resource icon) { window = new Window(caption); window.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION); + if (icon != null) { + window.setIcon(icon); + } + okButton = SPUIComponentProvider.getButton(SPUIComponetIdProvider.OK_BUTTON, okLabel, "", ValoTheme.BUTTON_PRIMARY, false, null, SPUIButtonStyleTiny.class); okButton.addClickListener(this); @@ -73,10 +100,11 @@ public class ConfirmationDialog implements Button.ClickListener { final VerticalLayout vLayout = new VerticalLayout(); if (question != null) { - final Label questionLbl = new Label(); - questionLbl.setValue(question); + final Label questionLbl = new Label(String.format("

%s

", question.replaceAll("\n", "
")), + ContentMode.HTML); questionLbl.addStyleName(SPUIStyleDefinitions.CONFIRMBOX_QUESTION_LABEL); vLayout.addComponent(questionLbl); + } final HorizontalLayout hButtonLayout = new HorizontalLayout(); @@ -106,6 +134,11 @@ public class ConfirmationDialog implements Button.ClickListener { callback.response(event.getSource().equals(okButton)); } + /** + * Get the window which holds the confirmation dialog + * + * @return the window which holds the confirmation dialog + */ public Window getWindow() { return window; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/CoordinatesToColor.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/CoordinatesToColor.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/DistributionSetTypeBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/DistributionSetTypeBeanQuery.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/SoftwareModuleTypeBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/SoftwareModuleTypeBeanQuery.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/confirmwindow/layout/AbstractConfirmationWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/confirmwindow/layout/AbstractConfirmationWindowLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/confirmwindow/layout/ConfirmationTab.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/confirmwindow/layout/ConfirmationTab.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/confirmwindow/layout/ConfirmationWindowEvents.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/confirmwindow/layout/ConfirmationWindowEvents.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/AbstractTableDetailsLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java old mode 100755 new mode 100644 index 62c6e08e0..4ff06d57d --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/detailslayout/SoftwareModuleDetailsTable.java @@ -10,15 +10,32 @@ package org.eclipse.hawkbit.ui.common.detailslayout; import java.util.Set; +import org.eclipse.hawkbit.repository.DistributionSetManagement; +import org.eclipse.hawkbit.repository.SpPermissionChecker; +import org.eclipse.hawkbit.repository.exception.EntityLockedException; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; +import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; +import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; +import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent; +import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; +import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; +import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; +import org.eclipse.hawkbit.ui.utils.SpringContextHelper; +import org.eclipse.hawkbit.ui.utils.UINotification; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.vaadin.spring.events.EventBus.SessionEventBus; import com.vaadin.data.Item; import com.vaadin.data.util.IndexedContainer; +import com.vaadin.server.FontAwesome; +import com.vaadin.ui.Button; +import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.Table; import com.vaadin.ui.themes.ValoTheme; @@ -34,21 +51,58 @@ public class SoftwareModuleDetailsTable extends Table { private static final long serialVersionUID = 2913758200611837718L; + private static final Logger LOG = LoggerFactory.getLogger(SoftwareModuleDetailsTable.class); + private static final String SOFT_TYPE_NAME = "name"; private static final String SOFT_MODULE = "softwareModule"; private static final String SOFT_TYPE_MANDATORY = "mandatory"; + private static final String UNASSIGN_SOFT_MODULE = "unassignSoftModule"; + + private boolean isTargetAssigned; + + private boolean isUnassignSoftModAllowed; + private SpPermissionChecker permissionChecker; + + private transient DistributionSetManagement distributionSetManagement; + private I18N i18n; + private transient SessionEventBus eventBus; + + private transient ManageDistUIState manageDistUIState; + + private transient UINotification uiNotification; + /** * Initialize software module table- to be displayed in details layout. * * @param i18n + * I18N + * @param isUnassignSoftModAllowed + * boolean flag to check for unassign functionality allowed for + * the view. + * @param distributionSetManagement + * DistributionSetManagement + * @param permissionChecker + * SpPermissionChecker + * @param eventBus + * SessionEventBus + * @param manageDistUIState + * ManageDistUIState */ - public void init(final I18N i18n) { + public void init(final I18N i18n, final boolean isUnassignSoftModAllowed, + final SpPermissionChecker permissionChecker, final DistributionSetManagement distributionSetManagement, + final SessionEventBus eventBus, final ManageDistUIState manageDistUIState) { this.i18n = i18n; + this.isUnassignSoftModAllowed = isUnassignSoftModAllowed; + this.permissionChecker = permissionChecker; + this.distributionSetManagement = distributionSetManagement; + this.manageDistUIState = manageDistUIState; + this.eventBus = eventBus; + this.uiNotification = SpringContextHelper.getBean(UINotification.class); createSwModuleTable(); } @@ -69,13 +123,21 @@ public class SoftwareModuleDetailsTable extends Table { container.addContainerProperty(SOFT_TYPE_MANDATORY, Label.class, ""); container.addContainerProperty(SOFT_TYPE_NAME, Label.class, ""); container.addContainerProperty(SOFT_MODULE, Label.class, ""); + if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission()) { + container.addContainerProperty(UNASSIGN_SOFT_MODULE, Button.class, ""); + } setColumnExpandRatio(SOFT_TYPE_MANDATORY, 0.1f); - setColumnExpandRatio(SOFT_TYPE_NAME, 0.5f); - setColumnExpandRatio(SOFT_MODULE, 0.4f); + setColumnExpandRatio(SOFT_TYPE_NAME, 0.4f); + setColumnExpandRatio(SOFT_MODULE, 0.3f); + if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission()) { + setColumnExpandRatio(UNASSIGN_SOFT_MODULE, 0.2F); + } setColumnAlignment(SOFT_TYPE_MANDATORY, Align.RIGHT); setColumnAlignment(SOFT_TYPE_NAME, Align.LEFT); setColumnAlignment(SOFT_MODULE, Align.LEFT); - + if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission()) { + setColumnAlignment(UNASSIGN_SOFT_MODULE, Align.RIGHT); + } return container; } @@ -83,6 +145,10 @@ public class SoftwareModuleDetailsTable extends Table { setColumnHeader(SOFT_TYPE_MANDATORY, ""); setColumnHeader(SOFT_TYPE_NAME, i18n.get("header.caption.typename")); setColumnHeader(SOFT_MODULE, i18n.get("header.caption.softwaremodule")); + if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission()) { + setColumnHeader(UNASSIGN_SOFT_MODULE, i18n.get("header.caption.unassign")); + } + } /** @@ -93,29 +159,41 @@ public class SoftwareModuleDetailsTable extends Table { public void populateModule(final DistributionSet distributionSet) { removeAllItems(); if (null != distributionSet) { + if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission()) { + try { + distributionSetManagement.checkDistributionSetAlreadyUse(distributionSet); + isTargetAssigned = false; + } catch (final EntityLockedException exception) { + isTargetAssigned = true; + LOG.info("Target already assigned for the distribution set: " + distributionSet.getName(), + exception); + } + } final Set swModuleMandatoryTypes = distributionSet.getType().getMandatoryModuleTypes(); final Set swModuleOptionalTypes = distributionSet.getType().getOptionalModuleTypes(); if (null != swModuleMandatoryTypes && !swModuleMandatoryTypes.isEmpty()) { - swModuleMandatoryTypes - .forEach(swModule -> setSwModuleProperties(swModule, true, distributionSet.getModules())); + swModuleMandatoryTypes.forEach(swModule -> setSwModuleProperties(swModule, true, distributionSet)); } if (null != swModuleOptionalTypes && !swModuleOptionalTypes.isEmpty()) { - swModuleOptionalTypes - .forEach(swModule -> setSwModuleProperties(swModule, false, distributionSet.getModules())); + swModuleOptionalTypes.forEach(swModule -> setSwModuleProperties(swModule, false, distributionSet)); } } } private void setSwModuleProperties(final SoftwareModuleType swModType, final Boolean isMandatory, - final Set alreadyAssignedSwModules) { + final DistributionSet distributionSet) { + final Set alreadyAssignedSwModules = distributionSet.getModules(); final Item saveTblitem = getContainerDataSource().addItem(swModType.getName()); final Label mandatoryLabel = createMandatoryLabel(isMandatory); final Label typeName = HawkbitCommonUtil.getFormatedLabel(swModType.getName()); final Label softwareModule = HawkbitCommonUtil.getFormatedLabel(HawkbitCommonUtil.SP_STRING_EMPTY); + final Button reassignSoftModule = SPUIComponentProvider.getButton(swModType.getName(), "", "", "", true, + FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); + reassignSoftModule.addClickListener(event -> unassignSW(event, distributionSet, alreadyAssignedSwModules)); if (null != alreadyAssignedSwModules && !alreadyAssignedSwModules.isEmpty()) { final String swModuleName = getSwModuleName(alreadyAssignedSwModules, swModType); softwareModule.setValue(swModuleName); @@ -124,11 +202,57 @@ public class SoftwareModuleDetailsTable extends Table { saveTblitem.getItemProperty(SOFT_TYPE_MANDATORY).setValue(mandatoryLabel); saveTblitem.getItemProperty(SOFT_TYPE_NAME).setValue(typeName); saveTblitem.getItemProperty(SOFT_MODULE).setValue(softwareModule); + if (isUnassignSoftModAllowed && permissionChecker.hasUpdateDistributionPermission() && !isTargetAssigned + && (isSoftModAvaiableForSoftType(alreadyAssignedSwModules, swModType))) { + saveTblitem.getItemProperty(UNASSIGN_SOFT_MODULE).setValue(reassignSoftModule); + } + + } + + private void unassignSW(final ClickEvent event, final DistributionSet distributionSet, + final Set alreadyAssignedSwModules) { + final SoftwareModule unAssignedSw = getSoftwareModule( + (Label) getContainerDataSource().getItem(event.getButton().getId()).getItemProperty(SOFT_MODULE) + .getValue(), alreadyAssignedSwModules); + final DistributionSet newDistributionSet = distributionSetManagement.unassignSoftwareModule(distributionSet, + unAssignedSw); + manageDistUIState.setLastSelectedDistribution(newDistributionSet.getDistributionSetIdName()); + eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, + newDistributionSet)); + eventBus.publish(this, DistributionsUIEvent.ORDER_BY_DISTRIBUTION); + uiNotification.displaySuccess(i18n.get("message.sw.unassigned", unAssignedSw.getName())); + } + + private static boolean isSoftModAvaiableForSoftType(final Set swModulesSet, + final SoftwareModuleType swModType) { + for (final SoftwareModule sw : swModulesSet) { + if (swModType.getName().equals(sw.getType().getName())) { + return true; + } + } + + return false; + + } + + /** + * @param value + * @param alreadyAssignedSwModules + * @return + */ + protected SoftwareModule getSoftwareModule(final Label softwareModule, + final Set alreadyAssignedSwModules) { + for (final SoftwareModule sw : alreadyAssignedSwModules) { + if (softwareModule.getValue().contains(sw.getName())) { + return sw; + } + } + return null; } private Label createMandatoryLabel(final boolean mandatory) { - final Label mandatoryLable = mandatory ? HawkbitCommonUtil.getFormatedLabel(" * ") - : HawkbitCommonUtil.getFormatedLabel(" "); + final Label mandatoryLable = mandatory ? HawkbitCommonUtil.getFormatedLabel(" * ") : HawkbitCommonUtil + .getFormatedLabel(" "); if (mandatory) { mandatoryLable.setStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterButtonClickBehaviour.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterButtonClickBehaviour.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterButtons.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterHeader.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterMultiButtonClick.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterMultiButtonClick.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterSingleButtonClick.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/filterlayout/AbstractFilterSingleButtonClick.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/footer/AbstractDeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/footer/AbstractDeleteActionsLayout.java old mode 100755 new mode 100644 index 01bf2e540..f991a729c --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/footer/AbstractDeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/footer/AbstractDeleteActionsLayout.java @@ -48,11 +48,13 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme private Window unsavedActionsWindow; + private Button bulkUploadStatusButton; + /** * Initialize. */ protected void init() { - if (hasDeletePermission() || hasUpdatePermission()) { + if (hasReadPermission() || hasDeletePermission() || hasUpdatePermission() || hasBulkUploadPermission()) { createComponents(); buildLayout(); reload(); @@ -60,16 +62,20 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme } private void reload() { - reloadActionCount(); + restoreActionCount(); + restoreBulkUploadStatusCount(); } private void createComponents() { if (hasDeletePermission()) { deleteWrapper = createDeleteWrapperLayout(); } - if (hasUpdatePermission()) { + if (hasDeletePermission() || hasUpdatePermission()) { noActionBtn = createActionsButton(); } + if (hasBulkUploadPermission()) { + bulkUploadStatusButton = createBulkUploadStatusButton(); + } } private void buildLayout() { @@ -80,14 +86,18 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme final HorizontalLayout hLayout = new HorizontalLayout(); hLayout.setSpacing(true); hLayout.setSizeUndefined(); - if (hasDeletePermission()) { + if (null != deleteWrapper) { hLayout.addComponent(deleteWrapper); hLayout.setComponentAlignment(deleteWrapper, Alignment.BOTTOM_LEFT); } - if (hasUpdatePermission()) { + if (null != noActionBtn) { hLayout.addComponent(noActionBtn); hLayout.setComponentAlignment(noActionBtn, Alignment.BOTTOM_LEFT); } + if (null != bulkUploadStatusButton) { + hLayout.addComponent(bulkUploadStatusButton); + hLayout.setComponentAlignment(bulkUploadStatusButton, Alignment.BOTTOM_LEFT); + } addComponent(dropHintLayout); addComponent(hLayout); setComponentAlignment(dropHintLayout, Alignment.BOTTOM_CENTER); @@ -103,7 +113,7 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme dropToDelete.setIcon(FontAwesome.TRASH_O); dropToDelete.addStyleName(ValoTheme.BUTTON_BORDERLESS); dropToDelete.addStyleName("drop-to-delete-button"); - dropToDelete.addStyleName("action-button"); + dropToDelete.addStyleName(SPUIStyleDefinitions.ACTION_BUTTON); dropToDelete.addStyleName("del-action-button"); dropToDelete.addStyleName("delete-icon"); @@ -118,9 +128,8 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme private Button createActionsButton() { final Button button = SPUIComponentProvider.getButton(SPUIComponetIdProvider.PENDING_ACTION_BUTTON, - getNoActionsButtonLabel(), "", "", false, null, SPUIButtonStyleSmall.class); - button.setIcon(FontAwesome.BELL); - button.setStyleName("action-button"); + getNoActionsButtonLabel(), "", "", false, FontAwesome.BELL, SPUIButtonStyleSmall.class); + button.setStyleName(SPUIStyleDefinitions.ACTION_BUTTON); button.addStyleName("del-action-button"); button.addClickListener(event -> actionButtonClicked()); @@ -128,6 +137,41 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme return button; } + private Button createBulkUploadStatusButton() { + final Button button = SPUIComponentProvider.getButton(SPUIComponetIdProvider.BULK_UPLOAD_STATUS_BUTTON, "", "", + "", false, null, SPUIButtonStyleSmall.class); + button.setStyleName(SPUIStyleDefinitions.ACTION_BUTTON); + button.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE); + button.setWidth("100px"); + button.setHtmlContentAllowed(true); + button.addClickListener(event -> onClickBulkUploadNotificationButton()); + button.setVisible(false); + return button; + } + + private void onClickBulkUploadNotificationButton() { + hideBulkUploadStatusButton(); + showBulkUploadWindow(); + } + + protected void setUploadStatusButtonCaption(final Long count) { + bulkUploadStatusButton.setCaption("
" + count + "
"); + } + + protected void enableBulkUploadStatusButton() { + bulkUploadStatusButton.setVisible(true); + } + + protected void updateUploadBtnIconToComplete() { + bulkUploadStatusButton.removeStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE); + bulkUploadStatusButton.setIcon(FontAwesome.UPLOAD); + } + + protected void updateUploadBtnIconToProgressIndicator() { + bulkUploadStatusButton.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_PROGRESS_INDICATOR_STYLE); + bulkUploadStatusButton.setIcon(null); + } + protected void actionButtonClicked() { if (hasUnsavedActions()) { unsavedActionsWindow = SPUIComponentProvider.getWindow(getUnsavedActionsWindowCaption(), @@ -198,6 +242,11 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme } } + protected void hideBulkUploadStatusButton() { + bulkUploadStatusButton.setCaption(null); + bulkUploadStatusButton.setVisible(false); + } + /** * Check user has delete permission. * @@ -258,7 +307,12 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme /** * reload the count value. */ - protected abstract void reloadActionCount(); + protected abstract void restoreActionCount(); + + /** + * restore the upload status count. + */ + protected abstract void restoreBulkUploadStatusCount(); /** * Get caption of unsaved actions window. @@ -296,4 +350,14 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme protected abstract Label getCountMessageLabel(); + /** + * @return true if bulk upload is allowed and has required create + * permissions. + */ + protected abstract boolean hasBulkUploadPermission(); + + protected abstract void showBulkUploadWindow(); + + protected abstract boolean hasReadPermission(); + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTable.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTableHeader.java old mode 100755 new mode 100644 index 6763d43c7..0845f2c55 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTableHeader.java @@ -103,7 +103,7 @@ public abstract class AbstractTableHeader extends VerticalLayout { * If table is maximized display the minimize icon. */ showMinIcon(); - hideAddIcon(); + hideAddAndUploadIcon(); } if (onLoadIsShowFilterButtonDisplayed()) { @@ -113,15 +113,20 @@ public abstract class AbstractTableHeader extends VerticalLayout { */ setFilterButtonsIconVisible(true); } + if (isBulkUploadInProgress()) { + disableBulkUpload(); + } } - private void hideAddIcon() { + private void hideAddAndUploadIcon() { addIcon.setVisible(false); + bulkUploadIcon.setVisible(false); } - private void showAddIcon() { + private void showAddAndUploadIcon() { addIcon.setVisible(true); + bulkUploadIcon.setVisible(true); } private void buildLayout() { @@ -278,13 +283,13 @@ public abstract class AbstractTableHeader extends VerticalLayout { private void maximizedTableView() { showMinIcon(); - hideAddIcon(); + hideAddAndUploadIcon(); maximizeTable(); } private void minimizeTableView() { showMaxIcon(); - showAddIcon(); + showAddAndUploadIcon(); minimizeTable(); } @@ -322,6 +327,14 @@ public abstract class AbstractTableHeader extends VerticalLayout { return filterDroppedInfo; } + protected void enableBulkUpload() { + bulkUploadIcon.setEnabled(true); + } + + protected void disableBulkUpload() { + bulkUploadIcon.setEnabled(false); + } + /** * Resets search text and closed search field when complex filters are * applied. @@ -484,6 +497,8 @@ public abstract class AbstractTableHeader extends VerticalLayout { */ public abstract Boolean onLoadIsShowFilterButtonDisplayed(); + protected abstract boolean isBulkUploadInProgress(); + protected abstract void searchBy(String newSearchText); protected abstract void addNewItem(final Button.ClickEvent event); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTableLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/table/AbstractTableLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTagToken.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTagToken.java old mode 100755 new mode 100644 index 2fee264e2..50e28058b --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTagToken.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTagToken.java @@ -13,8 +13,10 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; +import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; +import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.tokenfield.TokenField; import org.vaadin.tokenfield.TokenField.InsertPosition; @@ -51,6 +53,9 @@ public abstract class AbstractTagToken implements Serializable { protected CssLayout tokenLayout = new CssLayout(); + @Autowired + protected ManagementUIState managementUIState; + protected void init() { createTokenField(); checkIfTagAssignedIsAllowed(); @@ -96,8 +101,12 @@ public abstract class AbstractTagToken implements Serializable { protected void setContainerPropertValues(final Long tagId, final String tagName, final String tagColor) { tagDetails.put(tagId, new TagData(tagId, tagName, tagColor)); final Item item = container.addItem(tagId); - item.getItemProperty("name").setValue(tagName); item.getItemProperty("id").setValue(tagId); + updateItem(tagName, tagColor, item); + } + + protected void updateItem(final String tagName, final String tagColor, final Item item) { + item.getItemProperty("name").setValue(tagName); item.getItemProperty(COLOR_PROPERTY).setValue(tagColor); } @@ -224,7 +233,11 @@ public abstract class AbstractTagToken implements Serializable { return tokenField; } - static class TagData { + /** + * Tag details. + * + */ + public static class TagData { private String name; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTargetTagToken.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTargetTagToken.java new file mode 100644 index 000000000..efedbe3bc --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/AbstractTargetTagToken.java @@ -0,0 +1,73 @@ +/** + * 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.ui.common.tagdetails; + +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; + +import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent; +import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent; +import org.eclipse.hawkbit.repository.SpPermissionChecker; +import org.eclipse.hawkbit.repository.TagManagement; +import org.eclipse.hawkbit.repository.model.TargetTag; +import org.eclipse.hawkbit.ui.utils.I18N; +import org.springframework.beans.factory.annotation.Autowired; +import org.vaadin.spring.events.EventBus; +import org.vaadin.spring.events.EventScope; +import org.vaadin.spring.events.annotation.EventBusListenerMethod; + +import com.vaadin.ui.UI; + +/** + * Abstract class for target tag token layout. + */ +public abstract class AbstractTargetTagToken extends AbstractTagToken { + + private static final long serialVersionUID = 7772876588903171201L; + protected UI ui; + + @Autowired + protected transient EventBus.SessionEventBus eventBus; + + @Autowired + protected I18N i18n; + + @Autowired + protected transient TagManagement tagManagement; + + @Autowired + protected SpPermissionChecker checker; + + @Override + @PostConstruct + protected void init() { + super.init(); + ui = UI.getCurrent(); + eventBus.subscribe(this); + } + + @PreDestroy + void destroy() { + eventBus.unsubscribe(this); + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEventTargetTagCreated(final TargetTagCreatedBulkEvent event) { + for (final TargetTag tag : event.getEntities()) { + setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour()); + } + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onTargetDeletedEvent(final TargetTagDeletedEvent event) { + final Long deletedTagId = getTagIdByTagName(event.getEntity().getName()); + removeTagFromCombo(deletedTagId); + } + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java old mode 100755 new mode 100644 index d16cb9fbc..b4fe3767d --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/DistributionTagToken.java @@ -12,19 +12,23 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; +import org.eclipse.hawkbit.eventbus.event.DistributionSetTagAssigmentResultEvent; +import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent; +import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent; +import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent; import org.eclipse.hawkbit.repository.DistributionSetManagement; -import org.eclipse.hawkbit.repository.DistributionSetTagAssigmentResult; import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetTag; +import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult; import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent; -import org.eclipse.hawkbit.ui.management.event.DistributionTagEvent; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.I18N; @@ -34,6 +38,7 @@ import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.annotation.EventBusListenerMethod; +import com.vaadin.data.Item; import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.ViewScope; import com.vaadin.ui.UI; @@ -126,8 +131,8 @@ public class DistributionTagToken extends AbstractTagToken { private DistributionSetTagAssigmentResult toggleAssignment(final String tagNameSelected) { final Set distributionList = new HashSet(); distributionList.add(selectedDS.getId()); - final DistributionSetTagAssigmentResult result = distributionSetManagement.toggleTagAssignment(distributionList, - tagNameSelected); + final DistributionSetTagAssigmentResult result = distributionSetManagement.toggleTagAssignment( + distributionList, tagNameSelected); uinotification.displaySuccess(HawkbitCommonUtil.getDistributionTagAssignmentMsg(tagNameSelected, result, i18n)); return result; } @@ -194,7 +199,7 @@ public class DistributionTagToken extends AbstractTagToken { @Override protected void populateContainer() { container.removeAllItems(); - for (final DistributionSetTag tag : tagManagement.findDistributionSetTagsAll()) { + for (final DistributionSetTag tag : tagManagement.findAllDistributionSetTags()) { setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour()); } } @@ -216,30 +221,64 @@ public class DistributionTagToken extends AbstractTagToken { } @EventBusListenerMethod(scope = EventScope.SESSION) - void onEvent(final DistributionTagEvent event) { - ui.access(() -> { - if (event.getDistTagComponentEvent() == DistributionTagEvent.DistTagComponentEvent.ADD_DIST_TAG) { - setContainerPropertValues(event.getDistributionTag().getId(), event.getDistributionTag().getName(), - event.getDistributionTag().getColour()); - } else if (event.getDistTagComponentEvent() == DistributionTagEvent.DistTagComponentEvent.DELETE_DIST_TAG) { - final Long deletedTagId = getTagIdByTagName(event.getDistributionTagName()); - removeTagFromCombo(deletedTagId); - } else if (event.getDistTagComponentEvent() == DistributionTagEvent.DistTagComponentEvent.ASSIGNED) { - final Long newlyAssignedTagId = getTagIdByTagName(event.getDistributionTagName()); - addNewToken(newlyAssignedTagId); - } else if (event.getDistTagComponentEvent() == DistributionTagEvent.DistTagComponentEvent.UNASSIGNED) { - final Long newlyUnAssignedTagId = getTagIdByTagName(event.getDistributionTagName()); - removeTokenItem(newlyUnAssignedTagId, event.getDistributionTagName()); + void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedBulkEvent event) { + for (final DistributionSetTag distributionSetTag : event.getEntities()) { + setContainerPropertValues(distributionSetTag.getId(), distributionSetTag.getName(), + distributionSetTag.getColour()); + } + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onDistributionSetTagDeletedEventBulkEvent(final DistributionSetTagDeletedEvent event) { + final Long deletedTagId = getTagIdByTagName(event.getEntity().getName()); + removeTagFromCombo(deletedTagId); + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdateEvent event) { + final DistributionSetTag entity = event.getEntity(); + final Item item = container.getItem(entity.getId()); + if (item != null) { + updateItem(entity.getName(), entity.getColour(), item); + } + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onTargetTagAssigmentResultEvent(final DistributionSetTagAssigmentResultEvent event) { + final DistributionSetTagAssigmentResult assignmentResult = event.getAssigmentResult(); + final DistributionSetTag tag = assignmentResult.getDistributionSetTag(); + if (isAssign(assignmentResult)) { + addNewToken(tag.getId()); + } else if (isUnassign(assignmentResult)) { + removeTokenItem(tag.getId(), tag.getName()); + } + + } + + protected boolean isAssign(final DistributionSetTagAssigmentResult assignmentResult) { + if (assignmentResult.getAssigned() > 0) { + final List assignedDsNames = assignmentResult.getAssignedDs().stream().map(t -> t.getId()) + .collect(Collectors.toList()); + if (assignedDsNames.contains(managementUIState.getLastSelectedDsIdName().getId())) { + return true; } - }); + } + return false; + } + + protected boolean isUnassign(final DistributionSetTagAssigmentResult assignmentResult) { + if (assignmentResult.getUnassigned() > 0) { + final List assignedDsNames = assignmentResult.getUnassignedDs().stream().map(t -> t.getId()) + .collect(Collectors.toList()); + if (assignedDsNames.contains(managementUIState.getLastSelectedDsIdName().getId())) { + return true; + } + } + return false; } @PreDestroy void destroy() { - /* - * It's good to do this, even though vaadin-spring will automatically - * unsubscribe . - */ eventBus.unsubscribe(this); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/TargetTagToken.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/TargetTagToken.java old mode 100755 new mode 100644 index 5d3e61769..1610a2de8 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/TargetTagToken.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/tagdetails/TargetTagToken.java @@ -12,31 +12,26 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; - -import org.eclipse.hawkbit.repository.SpPermissionChecker; -import org.eclipse.hawkbit.repository.TagManagement; +import org.eclipse.hawkbit.eventbus.event.TargetTagAssigmentResultEvent; +import org.eclipse.hawkbit.eventbus.event.TargetTagUpdateEvent; import org.eclipse.hawkbit.repository.TargetManagement; -import org.eclipse.hawkbit.repository.TargetTagAssigmentResult; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetTag; +import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent; -import org.eclipse.hawkbit.ui.management.event.TargetTagEvent; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.beans.factory.annotation.Autowired; -import org.vaadin.spring.events.EventBus; import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.annotation.EventBusListenerMethod; +import com.vaadin.data.Item; import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.ViewScope; -import com.vaadin.ui.UI; /** * Implementation of Target tag token. @@ -45,41 +40,21 @@ import com.vaadin.ui.UI; */ @SpringComponent @ViewScope -public class TargetTagToken extends AbstractTagToken { +public class TargetTagToken extends AbstractTargetTagToken { private static final long serialVersionUID = 7124887018280196721L; // To Be Done : have to set this value based on view??? private static final Boolean NOTAGS_SELECTED = Boolean.FALSE; - @Autowired - private SpPermissionChecker spChecker; - - @Autowired - private I18N i18n; @Autowired private UINotification uinotification; - @Autowired - private transient EventBus.SessionEventBus eventBus; - - @Autowired - private transient TagManagement tagManagement; - @Autowired private transient TargetManagement targetManagement; private Target selectedTarget; - private UI ui; - - @PostConstruct - protected void init() { - super.init(); - ui = UI.getCurrent(); - eventBus.subscribe(this); - } - @Override protected String getTagStyleName() { return "target-tag-"; @@ -132,7 +107,7 @@ public class TargetTagToken extends AbstractTagToken { @Override protected Boolean isToggleTagAssignmentAllowed() { - return spChecker.hasUpdateTargetPermission(); + return checker.hasUpdateTargetPermission(); } @Override @@ -153,6 +128,49 @@ public class TargetTagToken extends AbstractTagToken { } } + @EventBusListenerMethod(scope = EventScope.SESSION) + void onTargetTagUpdateEvent(final TargetTagUpdateEvent event) { + final TargetTag entity = event.getEntity(); + final Item item = container.getItem(entity.getId()); + if (item != null) { + updateItem(entity.getName(), entity.getColour(), item); + } + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onTargetTagAssigmentResultEvent(final TargetTagAssigmentResultEvent event) { + final TargetTagAssigmentResult assignmentResult = event.getAssigmentResult(); + final TargetTag targetTag = assignmentResult.getTargetTag(); + if (isAssign(assignmentResult)) { + addNewToken(targetTag.getId()); + } else if (isUnassign(assignmentResult)) { + removeTokenItem(targetTag.getId(), targetTag.getName()); + } + + } + + protected boolean isAssign(final TargetTagAssigmentResult assignmentResult) { + if (assignmentResult.getAssigned() > 0) { + final List assignedTargetNames = assignmentResult.getAssignedTargets().stream() + .map(t -> t.getControllerId()).collect(Collectors.toList()); + if (assignedTargetNames.contains(managementUIState.getLastSelectedTargetIdName().getControllerId())) { + return true; + } + } + return false; + } + + protected boolean isUnassign(final TargetTagAssigmentResult assignmentResult) { + if (assignmentResult.getUnassigned() > 0) { + final List unassignedTargetNamesList = assignmentResult.getUnassignedTargets().stream() + .map(t -> t.getControllerId()).collect(Collectors.toList()); + if (unassignedTargetNamesList.contains(managementUIState.getLastSelectedTargetIdName().getControllerId())) { + return true; + } + } + return false; + } + @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final TargetTableEvent targetTableEvent) { if (targetTableEvent.getTargetComponentEvent() == TargetComponentEvent.SELECTED_TARGET @@ -167,28 +185,4 @@ public class TargetTagToken extends AbstractTagToken { } } - @EventBusListenerMethod(scope = EventScope.SESSION) - void onEvent(final TargetTagEvent event) { - ui.access(() -> { - if (event.getTargetTagComponentEvent() == TargetTagEvent.TargetTagComponentEvent.ADD_TARGETTAG) { - setContainerPropertValues(event.getTargetTag().getId(), event.getTargetTag().getName(), - event.getTargetTag().getColour()); - } else if (event.getTargetTagComponentEvent() == TargetTagEvent.TargetTagComponentEvent.DELETE_TARGETTAG) { - final Long deletedTagId = getTagIdByTagName(event.getTargetTagName()); - removeTagFromCombo(deletedTagId); - } else if (event.getTargetTagComponentEvent() == TargetTagEvent.TargetTagComponentEvent.ASSIGNED) { - final Long newlyAssignedTagId = getTagIdByTagName(event.getTargetTagName()); - addNewToken(newlyAssignedTagId); - } else if (event.getTargetTagComponentEvent() == TargetTagEvent.TargetTagComponentEvent.UNASSIGNED) { - final Long newlyUnAssignedTagId = getTagIdByTagName(event.getTargetTagName()); - removeTokenItem(newlyUnAssignedTagId, event.getTargetTagName()); - } - }); - } - - @PreDestroy - void destroy() { - eventBus.unsubscribe(this); - } - } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/DistributionSetInfoPanel.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/DistributionSetInfoPanel.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyDistribution.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyDistribution.java old mode 100755 new mode 100644 index 0acb12b2a..64473706e --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyDistribution.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyDistribution.java @@ -9,13 +9,9 @@ package org.eclipse.hawkbit.ui.components; import org.eclipse.hawkbit.repository.model.DistributionSet; -import org.eclipse.hawkbit.repository.model.Target; /** - * Proxy for {@link Target}. - * - * - * + * Proxy for {@link DistributionSet}. * * */ @@ -35,6 +31,23 @@ public class ProxyDistribution extends DistributionSet { private Boolean isComplete; + private String nameVersion; + + /** + * @return the nameVersion + */ + public String getNameVersion() { + return nameVersion; + } + + /** + * @param nameVersion + * the nameVersion to set + */ + public void setNameVersion(final String nameVersion) { + this.nameVersion = nameVersion; + } + public Boolean getIsComplete() { return isComplete; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTarget.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTargetFilter.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/ProxyTargetFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPNotificationMessage.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPNotificationMessage.java old mode 100755 new mode 100644 index 300193ab2..2685d2097 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPNotificationMessage.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPNotificationMessage.java @@ -45,11 +45,13 @@ public class SPNotificationMessage extends Notification { * message description * @param autoClose * flag to indicate enable close option + * @param page + * current {@link Page} */ public void showNotification(final String styleName, final String caption, final String description, - final Boolean autoClose) { + final Boolean autoClose, final Page page) { decorate(styleName, caption, description, autoClose); - this.show(Page.getCurrent()); + this.show(page); } /** diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPTargetAttributesLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPTargetAttributesLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIButton.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIButton.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUICheckBox.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUICheckBox.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIComponentProvider.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIErrorHandler.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIErrorHandler.java old mode 100755 new mode 100644 index 542be98fd..13fd73818 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIErrorHandler.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIErrorHandler.java @@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory; import com.vaadin.server.DefaultErrorHandler; import com.vaadin.server.ErrorEvent; +import com.vaadin.ui.Component; import com.vaadin.ui.themes.ValoTheme; /** @@ -39,7 +40,7 @@ public class SPUIErrorHandler extends DefaultErrorHandler { private static final Logger LOG = LoggerFactory.getLogger(SPUIErrorHandler.class); @Override - public void error(ErrorEvent event) { + public void error(final ErrorEvent event) { final SPNotificationMessage notification = new SPNotificationMessage(); // Build error style final StringBuilder style = new StringBuilder(ValoTheme.NOTIFICATION_FAILURE); @@ -47,14 +48,18 @@ public class SPUIErrorHandler extends DefaultErrorHandler { style.append(ValoTheme.NOTIFICATION_SMALL); style.append(' '); style.append(ValoTheme.NOTIFICATION_CLOSABLE); - final I18N i18n = (I18N) SpringContextHelper.getBean(I18N.class); + final I18N i18n = SpringContextHelper.getBean(I18N.class); String exceptionName = null; // From the exception trace we get the expected exception class name for (Throwable error = event.getThrowable(); error != null; error = error.getCause()) { exceptionName = HawkbitCommonUtil.getLastSequenceBySplitByDot(error.getClass().getName()); LOG.error("Error in SP-UI:", error); } - notification.showNotification(style.toString(), i18n.get("caption.error"), - i18n.get("message.error.temp", new Object[] { exceptionName }), false); + final Component errorOrgin = findAbstractComponent(event); + if (null != errorOrgin && errorOrgin.getUI() != null) { + notification + .showNotification(style.toString(), i18n.get("caption.error"), i18n.get("message.error.temp", + new Object[] { exceptionName }), false, errorOrgin.getUI().getPage()); + } } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIHorizontalLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIHorizontalLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUINotifcation.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUINotifcation.java deleted file mode 100755 index 4c9c7907e..000000000 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUINotifcation.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * 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.ui.components; - -import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; - -import com.vaadin.server.FontAwesome; - -/** - * Common Util for Notifcation Message. - * - * - * - * - * - */ -public final class SPUINotifcation { - - /** - * private constructor. - */ - private SPUINotifcation() { - - } - - /** - * Display success type of notification message. - * - * @param notificationMessage - * as reference - * @param message - * is the message to displayed as success. - */ - public static void displaySuccess(final SPNotificationMessage notificationMessage, final String message) { - notificationMessage.showNotification(SPUILabelDefinitions.SP_NOTIFICATION_SUCCESS_MESSAGE_STYLE, null, message, - true); - } - - /** - * Display error type of notification message. - * - * @param notificationMessage - * as reference - * @param message - * as message. - */ - public static void displayValidationError(final SPNotificationMessage notificationMessage, final String message) { - final StringBuilder updatedMsg = new StringBuilder(FontAwesome.EXCLAMATION_TRIANGLE.getHtml()); - updatedMsg.append(' '); - updatedMsg.append(message); - notificationMessage.showNotification(SPUILabelDefinitions.SP_NOTIFICATION_ERROR_MESSAGE_STYLE, null, - updatedMsg.toString(), true); - } - -} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUITabSheet.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUITabSheet.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUITableHorizonatlLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUITableHorizonatlLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIUpdateLogLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/components/SPUIUpdateLogLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonDecorator.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonDecorator.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleLargeIconNoBorder.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleLargeIconNoBorder.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStylePrimarySmall.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStylePrimarySmall.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmall.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmall.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorder.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorder.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorderUH.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorderUH.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorderUHS.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleSmallNoBorderUHS.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleTiny.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIButtonStyleTiny.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIComboBoxDecorator.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIComboBoxDecorator.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIEmbedDecorator.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIEmbedDecorator.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIEmbedValue.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIEmbedValue.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIHeaderLayoutDecorator.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIHeaderLayoutDecorator.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUILabelDecorator.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUILabelDecorator.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUITagButtonStyle.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUITagButtonStyle.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUITextAreaDecorator.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUITextAreaDecorator.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUITextFieldDecorator.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUITextFieldDecorator.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIWindowDecorator.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIWindowDecorator.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsView.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsViewMenuItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/DistributionsViewMenuItem.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/CreateUpdateDistSetTypeLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterButtonClick.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterButtonClick.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterButtons.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterHeader.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/disttype/DSTypeFilterLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java old mode 100755 new mode 100644 index 47c23204a..5bb38f5f6 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetDetails.java @@ -28,6 +28,7 @@ import org.eclipse.hawkbit.ui.common.detailslayout.AbstractTableDetailsLayout; import org.eclipse.hawkbit.ui.common.detailslayout.SoftwareModuleDetailsTable; import org.eclipse.hawkbit.ui.common.tagdetails.DistributionTagToken; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; +import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent; import org.eclipse.hawkbit.ui.distributions.event.SoftwareModuleAssignmentDiscardEvent; import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState; @@ -43,8 +44,10 @@ import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.annotation.EventBusListenerMethod; import com.vaadin.data.Item; +import com.vaadin.server.FontAwesome; import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.ViewScope; +import com.vaadin.ui.Button; import com.vaadin.ui.Button.ClickEvent; import com.vaadin.ui.Label; import com.vaadin.ui.TabSheet; @@ -66,6 +69,8 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout { private static final String SOFT_MODULE = "softwareModule"; + private static final String UNASSIGN_SOFT_MODULE = "unassignSoftModule"; + @Autowired private I18N i18n; @@ -109,7 +114,7 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout { @PostConstruct protected void init() { softwareModuleTable = new SoftwareModuleDetailsTable(); - softwareModuleTable.init(i18n); + softwareModuleTable.init(i18n, true, permissionChecker, distributionSetManagement, eventBus, manageDistUIState); super.init(); ui = UI.getCurrent(); eventBus.subscribe(this); @@ -176,17 +181,36 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout { .append(getUnsavedAssigedSwModule(softwareModule.getName(), softwareModule.getVersion())).append("")); } + } for (final Map.Entry entry : assignedSWModule.entrySet()) { item = softwareModuleTable.getContainerDataSource().getItem(entry.getKey()); if (item != null) { item.getItemProperty(SOFT_MODULE).setValue( HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString())); + assignSoftModuleButton(item, entry); + } } } } + /** + * @param item + * @param entry + */ + private void assignSoftModuleButton(final Item item, final Map.Entry entry) { + if (permissionChecker.hasUpdateDistributionPermission() + && distributionSetManagement + .findDistributionSetById(manageDistUIState.getLastSelectedDistribution().get().getId()) + .getAssignedTargets().isEmpty()) { + final Button reassignSoftModule = SPUIComponentProvider.getButton(entry.getKey(), "", "", "", true, + FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); + reassignSoftModule.setEnabled(false); + item.getItemProperty(UNASSIGN_SOFT_MODULE).setValue(reassignSoftModule); + } + } + private String getUnsavedAssigedSwModule(final String name, final String version) { return HawkbitCommonUtil.getFormattedNameVersion(name, version); } @@ -201,6 +225,7 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout { * assigned to that type. Hence if multipe softwares belongs to same * type is drroped, then add to the list. */ + if (module.getType().getMaxAssignments() == Integer.MAX_VALUE) { assignedSWModule.get(module.getType().getName()).append("
").append("") .append(getUnsavedAssigedSwModule(module.getName(), module.getVersion())).append(""); @@ -231,6 +256,8 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout { if (item != null) { item.getItemProperty(SOFT_MODULE).setValue( HawkbitCommonUtil.getFormatedLabel(entry.getValue().toString())); + assignSoftModuleButton(item, entry); + } } } @@ -499,4 +526,5 @@ public class DistributionSetDetails extends AbstractTableDetailsLayout { protected String getDetailsHeaderCaptionId() { return SPUIComponetIdProvider.DISTRIBUTION_DETAILS_HEADER_LABEL_ID; } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java old mode 100755 new mode 100644 index 8663d3013..519c8f244 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTable.java @@ -162,16 +162,15 @@ public class DistributionSetTable extends AbstractTable { .ifPresent(value -> queryConfiguration.put(SPUIDefinitions.FILTER_BY_TEXT, value)); if (null != manageDistUIState.getManageDistFilters().getClickedDistSetType()) { - queryConfiguration.put(SPUIDefinitions.FILTER_BY_DISTRIBUTION_SET_TYPE, - manageDistUIState.getManageDistFilters().getClickedDistSetType()); + queryConfiguration.put(SPUIDefinitions.FILTER_BY_DISTRIBUTION_SET_TYPE, manageDistUIState + .getManageDistFilters().getClickedDistSetType()); } final BeanQueryFactory distributionQF = new BeanQueryFactory( ManageDistBeanQuery.class); distributionQF.setQueryConfiguration(queryConfiguration); - final LazyQueryContainer distContainer = new LazyQueryContainer( - new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME), - distributionQF); + final LazyQueryContainer distContainer = new LazyQueryContainer(new LazyQueryDefinition(true, + SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME), distributionQF); return distContainer; } @@ -255,8 +254,8 @@ public class DistributionSetTable extends AbstractTable { final DistributionSet lastSelectedDistSet = distributionSetManagement .findDistributionSetByIdWithDetails(value.getId()); - eventBus.publish(this, - new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, lastSelectedDistSet)); + eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, + lastSelectedDistSet)); } } else { manageDistUIState.setSelectedDistributions(null); @@ -395,8 +394,8 @@ public class DistributionSetTable extends AbstractTable { private void publishAssignEvent(final Long distId, final SoftwareModule softwareModule) { if (manageDistUIState.getLastSelectedDistribution().isPresent() && manageDistUIState.getLastSelectedDistribution().get().getId().equals(distId)) { - eventBus.publish(this, - new SoftwareModuleEvent(SoftwareModuleEventType.ASSIGN_SOFTWARE_MODULE, softwareModule)); + eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.ASSIGN_SOFTWARE_MODULE, + softwareModule)); } } @@ -405,8 +404,8 @@ public class DistributionSetTable extends AbstractTable { * @param softwareModule * @param softwareModuleIdName */ - private void handleFirmwareCase(final Map> map, final SoftwareModule softwareModule, - final SoftwareModuleIdName softwareModuleIdName) { + private void handleFirmwareCase(final Map> map, + final SoftwareModule softwareModule, final SoftwareModuleIdName softwareModuleIdName) { if (softwareModule.getType().getMaxAssignments() == 1) { if (!map.containsKey(softwareModule.getType().getId())) { map.put(softwareModule.getType().getId(), new HashSet()); @@ -423,8 +422,8 @@ public class DistributionSetTable extends AbstractTable { * @param softwareModule * @param softwareModuleIdName */ - private void handleSoftwareCase(final Map> map, final SoftwareModule softwareModule, - final SoftwareModuleIdName softwareModuleIdName) { + private void handleSoftwareCase(final Map> map, + final SoftwareModule softwareModule, final SoftwareModuleIdName softwareModuleIdName) { if (softwareModule.getType().getMaxAssignments() == Integer.MAX_VALUE) { if (!map.containsKey(softwareModule.getType().getId())) { map.put(softwareModule.getType().getId(), new HashSet()); @@ -548,15 +547,19 @@ public class DistributionSetTable extends AbstractTable { item.getItemProperty(SPUILabelDefinitions.VAR_ID).setValue(distributionSet.getId()); item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(distributionSet.getDescription()); item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(distributionSet.getVersion()); - item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY) - .setValue(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy())); - item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY) - .setValue(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy())); - item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE) - .setValue(SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt())); - item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE) - .setValue(SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).setValue( + HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy())); + item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue( + HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy())); + item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE).setValue( + SPDateTimeUtil.getFormattedDate(distributionSet.getCreatedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE).setValue( + SPDateTimeUtil.getFormattedDate(distributionSet.getLastModifiedAt())); item.getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).setValue(distributionSet.isComplete()); + if (manageDistUIState.getSelectedDistributions().isPresent()) { + manageDistUIState.getSelectedDistributions().get().stream().forEach(dsNameId -> unselect(dsNameId)); + } + select(distributionSet.getDistributionSetIdName()); } private void addTableStyleGenerator() { @@ -566,8 +569,8 @@ public class DistributionSetTable extends AbstractTable { if (propertyId == null) { // Styling for row final Item item = getItem(itemId); - final Boolean isComplete = (Boolean) item - .getItemProperty(SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).getValue(); + final Boolean isComplete = (Boolean) item.getItemProperty( + SPUILabelDefinitions.VAR_IS_DISTRIBUTION_COMPLETE).getValue(); if (!isComplete) { return SPUIDefinitions.DISABLE_DISTRIBUTION; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java old mode 100755 new mode 100644 index a970f60ce..d64f07ca0 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableHeader.java @@ -78,7 +78,7 @@ public class DistributionSetTableHeader extends AbstractTableHeader { /* * (non-Javadoc) - * + * * @see hawkbit.server.ui.common.table.AbstractTableHeader#getHeaderCaption( * ) */ @@ -89,7 +89,7 @@ public class DistributionSetTableHeader extends AbstractTableHeader { /* * (non-Javadoc) - * + * * @see hawkbit.server.ui.common.table.AbstractTableHeader#getSearchBoxId() */ @Override @@ -99,7 +99,7 @@ public class DistributionSetTableHeader extends AbstractTableHeader { /* * (non-Javadoc) - * + * * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# * getSearchRestIconId() */ @@ -110,7 +110,7 @@ public class DistributionSetTableHeader extends AbstractTableHeader { /* * (non-Javadoc) - * + * * @see hawkbit.server.ui.common.table.AbstractTableHeader#getAddIconId() */ @Override @@ -120,7 +120,7 @@ public class DistributionSetTableHeader extends AbstractTableHeader { /* * (non-Javadoc) - * + * * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# * onLoadSearchBoxValue() */ @@ -134,7 +134,7 @@ public class DistributionSetTableHeader extends AbstractTableHeader { /* * (non-Javadoc) - * + * * @see hawkbit.server.ui.common.table.AbstractTableHeader#getDropFilterId() */ @Override @@ -224,7 +224,7 @@ public class DistributionSetTableHeader extends AbstractTableHeader { /* * (non-Javadoc) - * + * * @see hawkbit.server.ui.common.table.AbstractTableHeader#canAddNewItem() */ @Override @@ -249,7 +249,7 @@ public class DistributionSetTableHeader extends AbstractTableHeader { /* * (non-Javadoc) - * + * * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# * getBulkUploadIconId() */ @@ -260,7 +260,7 @@ public class DistributionSetTableHeader extends AbstractTableHeader { /* * (non-Javadoc) - * + * * @see hawkbit.server.ui.common.table.AbstractTableHeader#bulkUpload(com. * vaadin.ui.Button.ClickEvent ) */ @@ -273,7 +273,7 @@ public class DistributionSetTableHeader extends AbstractTableHeader { /* * (non-Javadoc) - * + * * @see org.eclipse.hawkbit.server.ui.common.table.AbstractTableHeader# * isBulkUploadAllowed() */ @@ -281,4 +281,15 @@ public class DistributionSetTableHeader extends AbstractTableHeader { protected Boolean isBulkUploadAllowed() { return Boolean.FALSE; } + + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.common.table.AbstractTableHeader# + * isBulkUploadInProgress() + */ + @Override + protected boolean isBulkUploadInProgress() { + return false; + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/DistributionSetTableLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/dstable/ManageDistBeanQuery.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/DistributionSetTypeEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/DistributionSetTypeEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/DistributionsUIEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/DistributionsUIEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/DistributionsViewAcceptCriteria.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/DistributionsViewAcceptCriteria.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/DragEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/DragEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/SaveActionWindowEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/SaveActionWindowEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/SoftwareModuleAssignmentDiscardEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/SoftwareModuleAssignmentDiscardEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/SwModuleUIEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/event/SwModuleUIEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DSDeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DSDeleteActionsLayout.java old mode 100755 new mode 100644 index e511c3c24..cc89312b2 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DSDeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DSDeleteActionsLayout.java @@ -19,7 +19,9 @@ import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import org.eclipse.hawkbit.repository.SpPermissionChecker; +import org.eclipse.hawkbit.repository.SystemManagement; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; +import org.eclipse.hawkbit.repository.model.DistributionSetType; import org.eclipse.hawkbit.repository.model.SoftwareModuleIdName; import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout; import org.eclipse.hawkbit.ui.distributions.event.DistributionsUIEvent; @@ -59,9 +61,9 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout { private static final long serialVersionUID = 3494052985006132714L; - private static final List DISPLAY_DROP_HINT_EVENTS = new ArrayList<>( - Arrays.asList(DragEvent.DISTRIBUTION_TYPE_DRAG, DragEvent.DISTRIBUTION_DRAG, DragEvent.SOFTWAREMODULE_DRAG, - DragEvent.SOFTWAREMODULE_TYPE_DRAG)); + private static final List DISPLAY_DROP_HINT_EVENTS = new ArrayList<>(Arrays.asList( + DragEvent.DISTRIBUTION_TYPE_DRAG, DragEvent.DISTRIBUTION_DRAG, DragEvent.SOFTWAREMODULE_DRAG, + DragEvent.SOFTWAREMODULE_TYPE_DRAG)); @Autowired private I18N i18n; @@ -78,6 +80,9 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout { @Autowired private transient UINotification uiNotification; + @Autowired + private transient SystemManagement systemManagement; + @Autowired private ManageDistUIState manageDistUIState; @@ -230,16 +235,27 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout { private void processDeleteDitSetType(final String distTypeId) { final String distTypeName = HawkbitCommonUtil.removePrefix(distTypeId, SPUIDefinitions.DISTRIBUTION_SET_TYPE_ID_PREFIXS); - - if (null != manageDistUIState.getManageDistFilters().getClickedDistSetType() && manageDistUIState - .getManageDistFilters().getClickedDistSetType().getName().equalsIgnoreCase(distTypeName)) { - notification - .displayValidationError(i18n.get("message.dist.type.check.delete", new Object[] { distTypeName })); + if (isDsTypeSelected(distTypeName)) { + notification.displayValidationError(i18n.get("message.dist.type.check.delete", + new Object[] { distTypeName })); + } else if (isDefaultDsType(distTypeName)) { + notification.displayValidationError(i18n.get("message.cannot.delete.default.dstype")); } else { manageDistUIState.getSelectedDeleteDistSetTypes().add(distTypeName); updateDSActionCount(); } + } + /** + * Check if distribution set type is selected. + * + * @param distTypeName + * @return true if ds type is selected + */ + private boolean isDsTypeSelected(final String distTypeName) { + return null != manageDistUIState.getManageDistFilters().getClickedDistSetType() + && manageDistUIState.getManageDistFilters().getClickedDistSetType().getName() + .equalsIgnoreCase(distTypeName); } private void processDeleteSWType(final String swTypeId) { @@ -249,8 +265,8 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout { if (manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent() && manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName() .equalsIgnoreCase(swModuleTypeName)) { - notification.displayValidationError( - i18n.get("message.swmodule.type.check.delete", new Object[] { swModuleTypeName })); + notification.displayValidationError(i18n.get("message.swmodule.type.check.delete", + new Object[] { swModuleTypeName })); } else { manageDistUIState.getSelectedDeleteSWModuleTypes().add(swModuleTypeName); updateDSActionCount(); @@ -394,7 +410,7 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout { * reloadActionCount() */ @Override - protected void reloadActionCount() { + protected void restoreActionCount() { updateDSActionCount(); } @@ -473,4 +489,66 @@ public class DSDeleteActionsLayout extends AbstractDeleteActionsLayout { return null; } + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# + * hasBulkUploadPermission() + */ + @Override + protected boolean hasBulkUploadPermission() { + return false; + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# + * showBulkUploadWindow() + */ + @Override + protected void showBulkUploadWindow() { + /** + * Bulk upload not supported No implementation required. + */ + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# + * restoreBulkUploadStatusCount() + */ + @Override + protected void restoreBulkUploadStatusCount() { + /** + * No implementation required.As no bulk upload in Distribution view. + */ + } + + private DistributionSetType getCurrentDistributionSetType() { + return systemManagement.getTenantMetadata().getDefaultDsType(); + } + + /** + * Check if the distribution set type is default. + * + * @param dsTypeName + * distribution set name + * @return true if distribution set type is set default in configuration + */ + private boolean isDefaultDsType(final String dsTypeName) { + return getCurrentDistributionSetType() != null && getCurrentDistributionSetType().getName().equals(dsTypeName); + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# + * hasReadPermission() + */ + @Override + protected boolean hasReadPermission() { + return permChecker.hasReadDistributionPermission(); + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DistributionsConfirmationWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/footer/DistributionsConfirmationWindowLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/ProxyBaseSwModuleItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/ProxyBaseSwModuleItem.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleBeanQuery.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleDetails.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java old mode 100755 new mode 100644 index 1a2367ac4..fca9d8392 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTable.java @@ -119,15 +119,16 @@ public class SwModuleTable extends AbstractTable { @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final SMFilterEvent filterEvent) { - UI.getCurrent().access(() -> { + UI.getCurrent().access( + () -> { - if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT - || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE - || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) { - refreshFilter(); - styleTableOnDistSelection(); - } - }); + if (filterEvent == SMFilterEvent.FILTER_BY_TYPE || filterEvent == SMFilterEvent.FILTER_BY_TEXT + || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TYPE + || filterEvent == SMFilterEvent.REMOVER_FILTER_BY_TEXT) { + refreshFilter(); + styleTableOnDistSelection(); + } + }); } @EventBusListenerMethod(scope = EventScope.SESSION) @@ -191,8 +192,8 @@ public class SwModuleTable extends AbstractTable { SwModuleBeanQuery.class); swQF.setQueryConfiguration(queryConfiguration); - final LazyQueryContainer container = new LazyQueryContainer( - new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, "swId"), swQF); + final LazyQueryContainer container = new LazyQueryContainer(new LazyQueryDefinition(true, + SPUIDefinitions.PAGE_SIZE, "swId"), swQF); return container; } @@ -214,8 +215,8 @@ public class SwModuleTable extends AbstractTable { lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_BY, String.class, null, false, true); lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, true); lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false, true); - lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, - true); + lazyContainer + .addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, false, true); lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_COLOR, String.class, null, false, true); lazyContainer.addContainerProperty(SPUILabelDefinitions.VAR_SOFT_TYPE_ID, Long.class, null, false, true); } @@ -290,8 +291,8 @@ public class SwModuleTable extends AbstractTable { manageDistUIState.setSelectedBaseSwModuleId(value); final SoftwareModule baseSoftwareModule = softwareManagement.findSoftwareModuleById(value); manageDistUIState.setSelectedSoftwareModules(values); - eventBus.publish(this, - new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE, baseSoftwareModule)); + eventBus.publish(this, new SoftwareModuleEvent(SoftwareModuleEventType.SELECTED_SOFTWARE_MODULE, + baseSoftwareModule)); } } else { manageDistUIState.setSelectedBaseSwModuleId(null); @@ -311,21 +312,21 @@ public class SwModuleTable extends AbstractTable { protected List getTableVisibleColumns() { final List columnList = new ArrayList(); if (isMaximized()) { - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.1f)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.2F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.1F)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VENDOR, i18n.get("header.vendor"), 0.1f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1F)); columnList - .add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1f)); - columnList.add( - new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), - 0.1f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2f)); + .add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), + 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, + i18n.get("header.modifiedDate"), 0.1F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2F)); } else { - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.7f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.2f)); - columnList.add(new TableColumn(SPUILabelDefinitions.ARTIFACT_ICON, "", 0.1f)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get("header.name"), 0.7F)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_VERSION, i18n.get("header.version"), 0.2F)); + columnList.add(new TableColumn(SPUILabelDefinitions.ARTIFACT_ICON, "", 0.1F)); } return columnList; @@ -379,9 +380,9 @@ public class SwModuleTable extends AbstractTable { private void addTypeStyle(final Long tagId, final String color) { final JavaScript javaScript = UI.getCurrent().getPage().getJavaScript(); - UI.getCurrent() - .access(() -> javaScript.execute( - HawkbitCommonUtil.getScriptSMHighlightWithColor(".v-table-row-distribution-upload-type-" + tagId + UI.getCurrent().access( + () -> javaScript.execute(HawkbitCommonUtil + .getScriptSMHighlightWithColor(".v-table-row-distribution-upload-type-" + tagId + "{background-color:" + color + " !important;background-image:none !important }"))); } @@ -443,12 +444,16 @@ public class SwModuleTable extends AbstractTable { item.getItemProperty(SPUILabelDefinitions.VAR_VENDOR).setValue(swModule.getVendor()); item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).setValue(swModule.getCreatedBy()); item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue(swModule.getLastModifiedBy()); - item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE) - .setValue(SPDateTimeUtil.getFormattedDate(swModule.getCreatedAt())); - item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE) - .setValue(SPDateTimeUtil.getFormattedDate(swModule.getLastModifiedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE).setValue( + SPDateTimeUtil.getFormattedDate(swModule.getCreatedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE).setValue( + SPDateTimeUtil.getFormattedDate(swModule.getLastModifiedAt())); item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).setValue(swModule.getType().getColour()); + if (!manageDistUIState.getSelectedSoftwareModules().isEmpty()) { + manageDistUIState.getSelectedSoftwareModules().stream().forEach(swmNameId -> unselect(swmNameId)); + } + select(swModule.getId()); } /** diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTableHeader.java old mode 100755 new mode 100644 index dffdbb4ad..1eae1297b --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTableHeader.java @@ -362,4 +362,15 @@ public class SwModuleTableHeader extends AbstractTableHeader { protected Boolean isBulkUploadAllowed() { return Boolean.FALSE; } + + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.common.table.AbstractTableHeader# + * isBulkUploadInProgress() + */ + @Override + protected boolean isBulkUploadInProgress() { + return false; + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTableLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtable/SwModuleTableLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtonClick.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtonClick.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterButtons.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterHeader.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/smtype/DistSMTypeFilterLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageDistFilters.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageDistFilters.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageDistUIState.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageDistUIState.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageSoftwareModuleFilters.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/distributions/state/ManageSoftwareModuleFilters.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/documentation/DocumentationPageLink.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/documentation/DocumentationPageLink.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/documentation/DocumentationUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/documentation/DocumentationUtil.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/FilterExpression.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/FilterExpression.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/Filters.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/Filters.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/target/CustomTargetFilter.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/target/CustomTargetFilter.java new file mode 100644 index 000000000..b0aadc01d --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/target/CustomTargetFilter.java @@ -0,0 +1,48 @@ +/** + * 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.ui.filter.target; + +import java.util.Optional; + +import org.eclipse.hawkbit.repository.model.TargetFilterQuery; +import org.eclipse.hawkbit.ui.filter.FilterExpression; + +/** + * Checks if custom target filter is applied. + * + */ +public class CustomTargetFilter implements FilterExpression { + + private final Optional targetFilterQuery; + + /** + * Initialize. + * + * @param targetFilterQuery + * custom target filter applied + */ + public CustomTargetFilter(final Optional targetFilterQuery) { + this.targetFilterQuery = targetFilterQuery; + + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.filter.FilterExpression#doFilter() + */ + @Override + public boolean doFilter() { + if (!targetFilterQuery.isPresent()) { + return false; + } + return true; + } + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/target/TargetSearchTextFilter.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/target/TargetSearchTextFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/target/TargetStatusFilter.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/target/TargetStatusFilter.java old mode 100755 new mode 100644 index daea43786..eee7156e3 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/target/TargetStatusFilter.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/target/TargetStatusFilter.java @@ -5,7 +5,6 @@ package org.eclipse.hawkbit.ui.filter.target; import java.util.List; -import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.ui.filter.FilterExpression; @@ -16,7 +15,6 @@ import org.eclipse.hawkbit.ui.filter.FilterExpression; */ public class TargetStatusFilter implements FilterExpression { - private final Target target; private final List targetUpdateStatus; /** @@ -25,8 +23,7 @@ public class TargetStatusFilter implements FilterExpression { * @param updateStatus * the target update status to check against the given target */ - public TargetStatusFilter(final Target target, final List updateStatus) { - this.target = target; + public TargetStatusFilter(final List updateStatus) { this.targetUpdateStatus = updateStatus; } @@ -40,6 +37,6 @@ public class TargetStatusFilter implements FilterExpression { if (targetUpdateStatus.isEmpty()) { return false; } - return !targetUpdateStatus.contains(target.getTargetInfo().getUpdateStatus()); + return true; } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/target/TargetTagFilter.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filter/target/TargetTagFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterHeader.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CreateOrUpdateFilterTable.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/CustomTargetBeanQuery.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterManagementView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterManagementView.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterManagementViewMenuItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterManagementViewMenuItem.java old mode 100755 new mode 100644 index 2104e01bc..e0edf541e --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterManagementViewMenuItem.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterManagementViewMenuItem.java @@ -23,7 +23,6 @@ import com.vaadin.server.Resource; * * Menu item for target filter management view. * - * @author Venugopal Boodidadinne(RBEI BSO3). * */ @Component diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterQueryValidation.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/FilterQueryValidation.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterBeanQuery.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterHeader.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TargetFilterTable.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TokenDescription.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/TokenDescription.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/ValidationResult.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/ValidationResult.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/event/CustomFilterUIEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/event/CustomFilterUIEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/state/FilterManagementUIState.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/filtermanagement/state/FilterManagementUIState.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/login/HawkbitLoginUI.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/login/HawkbitLoginUI.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/login/LoginView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/login/LoginView.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentView.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentViewMenuItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/DeploymentViewMenuItem.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryComponent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryComponent.java old mode 100755 new mode 100644 index 3b7557c62..908c8c18f --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryComponent.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryComponent.java @@ -82,7 +82,8 @@ public class ActionHistoryComponent extends VerticalLayout { /** * populate action header and table for the target. * - * @param targetIdName + * @param target + * the target */ public void populateActionHistoryDetails(final Target target) { if (null != target) { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryHeader.java old mode 100755 new mode 100644 index c5f31e9a4..828b61d43 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryHeader.java @@ -103,6 +103,7 @@ public class ActionHistoryHeader extends VerticalLayout { * Populate Header Data for Target. * * @param targetName + * name of the target */ public void populateHeader(final String targetName) { updateActionHistoryHeader(targetName); @@ -135,6 +136,7 @@ public class ActionHistoryHeader extends VerticalLayout { * Updates header with target name. * * @param targetName + * name of the target */ public void updateActionHistoryHeader(final String targetName) { titleOfActionHistory.setValue(HawkbitCommonUtil.getActionHistoryLabelId(targetName)); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java old mode 100755 new mode 100644 index a33e69973..b857cc026 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/actionhistory/ActionHistoryTable.java @@ -97,6 +97,7 @@ public class ActionHistoryTable extends TreeTable implements Handler { com.vaadin.event.Action actionCancel; com.vaadin.event.Action actionForce; + com.vaadin.event.Action actionForceQuit; private static final Logger LOG = LoggerFactory.getLogger(ActionHistoryTable.class); private static final String STATUS_ICON_GREEN = "statusIconGreen"; @@ -106,6 +107,8 @@ public class ActionHistoryTable extends TreeTable implements Handler { @PostConstruct public void init() { actionCancel = new com.vaadin.event.Action(i18n.get("message.cancel.action")); + actionForceQuit = new com.vaadin.event.Action(i18n.get("message.forcequit.action")); + actionForceQuit.setIcon(FontAwesome.WARNING); actionForce = new com.vaadin.event.Action(i18n.get("message.force.action")); initializeTableSettings(); buildComponent(); @@ -253,7 +256,6 @@ public class ActionHistoryTable extends TreeTable implements Handler { * @param actionHistoryMode * as either {@link ActionHistoryMode.NORMAL} or * {@link ActionHistoryMode.MAXIMIZED} - * @return next index */ @SuppressWarnings("unchecked") private void addDetailsToContainer(final List actions) { @@ -263,14 +265,14 @@ public class ActionHistoryTable extends TreeTable implements Handler { final Item item = hierarchicalContainer.addItem(actionWithStatusCount.getActionId()); - item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).setValue( - actionWithStatusCount.getActionStatus()); + item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN) + .setValue(actionWithStatusCount.getActionStatus()); /* * add action id. */ - item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID).setValue( - actionWithStatusCount.getActionId().toString()); + item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID) + .setValue(actionWithStatusCount.getActionId().toString()); /* * add active/inactive status to the item which will be used in * Column generator to generate respective icon @@ -282,25 +284,24 @@ public class ActionHistoryTable extends TreeTable implements Handler { * add action Id to the item which will be used for fetching child * items ( previous action status ) during expand */ - item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN).setValue( - actionWithStatusCount.getActionId()); + item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTION_ID_HIDDEN) + .setValue(actionWithStatusCount.getActionId()); /* * add distribution name to the item which will be displayed in the * table. The name should not exceed certain limit. */ - item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).setValue( - HawkbitCommonUtil.getFormattedText(actionWithStatusCount.getDsName() + ":" - + actionWithStatusCount.getDsVersion())); + item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).setValue(HawkbitCommonUtil + .getFormattedText(actionWithStatusCount.getDsName() + ":" + actionWithStatusCount.getDsVersion())); item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).setValue(action); /* Default no child */ ((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), false); item.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME) - .setValue( - SPDateTimeUtil.getFormattedDate((actionWithStatusCount.getActionLastModifiedAt() != null) ? actionWithStatusCount - .getActionLastModifiedAt() : actionWithStatusCount.getActionCreatedAt())); + .setValue(SPDateTimeUtil.getFormattedDate((actionWithStatusCount.getActionLastModifiedAt() != null) + ? actionWithStatusCount.getActionLastModifiedAt() + : actionWithStatusCount.getActionCreatedAt())); if (actionWithStatusCount.getActionStatusCount() > 0) { ((Hierarchical) hierarchicalContainer).setChildrenAllowed(actionWithStatusCount.getActionId(), true); @@ -371,10 +372,10 @@ public class ActionHistoryTable extends TreeTable implements Handler { .getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).getValue(); final String distName = (String) hierarchicalContainer.getItem(itemId) .getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).getValue(); - final Label activeStatusIcon = createActiveStatusLabel( - activeValue, + final Label activeStatusIcon = createActiveStatusLabel(activeValue, (Action.Status) hierarchicalContainer.getItem(itemId) - .getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).getValue() == Action.Status.ERROR); + .getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN) + .getValue() == Action.Status.ERROR); activeStatusIcon.setId(new StringJoiner(".").add(distName).add(itemId.toString()) .add(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE).add(activeValue).toString()); return activeStatusIcon; @@ -428,14 +429,14 @@ public class ActionHistoryTable extends TreeTable implements Handler { */ childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_ACTIVE_HIDDEN).setValue(""); - childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST).setValue( - HawkbitCommonUtil.getFormattedText(action.getDistributionSet().getName() + ":" + childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DIST) + .setValue(HawkbitCommonUtil.getFormattedText(action.getDistributionSet().getName() + ":" + action.getDistributionSet().getVersion())); - childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME).setValue( - SPDateTimeUtil.getFormattedDate(actionStatus.getCreatedAt())); - childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN).setValue( - actionStatus.getStatus()); + childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_DATETIME) + .setValue(SPDateTimeUtil.getFormattedDate(actionStatus.getCreatedAt())); + childItem.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_STATUS_HIDDEN) + .setValue(actionStatus.getStatus()); showOrHideMessage(childItem, actionStatus); /* No further child items allowed for the child items */ ((Hierarchical) hierarchicalContainer).setChildrenAllowed(childId, false); @@ -538,13 +539,11 @@ public class ActionHistoryTable extends TreeTable implements Handler { if (actionWithActiveStatus.isHitAutoForceTime(currentTimeMillis)) { autoForceLabel.setDescription("autoforced"); autoForceLabel.setStyleName(STATUS_ICON_GREEN); - autoForceLabel.setDescription("auto forced since " - + SPDateTimeUtil.getDurationFormattedString(actionWithActiveStatus.getForcedTime(), - currentTimeMillis, i18n)); + autoForceLabel.setDescription("auto forced since " + SPDateTimeUtil + .getDurationFormattedString(actionWithActiveStatus.getForcedTime(), currentTimeMillis, i18n)); } else { - autoForceLabel.setDescription("auto forcing in " - + SPDateTimeUtil.getDurationFormattedString(currentTimeMillis, - actionWithActiveStatus.getForcedTime(), i18n)); + autoForceLabel.setDescription("auto forcing in " + SPDateTimeUtil + .getDurationFormattedString(currentTimeMillis, actionWithActiveStatus.getForcedTime(), i18n)); autoForceLabel.setStyleName("statusIconPending"); autoForceLabel.setValue(FontAwesome.HISTORY.getHtml()); } @@ -684,6 +683,8 @@ public class ActionHistoryTable extends TreeTable implements Handler { } } else if (action.equals(actionForce)) { confirmAndForceAction(actionId); + } else if (action.equals(actionForceQuit)) { + confirmAndForceQuitAction(actionId); } } @@ -702,7 +703,10 @@ public class ActionHistoryTable extends TreeTable implements Handler { } if (!actionWithActiveStatus.isCancelingOrCanceled()) { actions.add(actionCancel); + } else { + actions.add(actionForceQuit); } + } } return actions.toArray(new com.vaadin.event.Action[actions.size()]); @@ -736,6 +740,29 @@ public class ActionHistoryTable extends TreeTable implements Handler { confirmDialog.getWindow().bringToFront(); } + private void confirmAndForceQuitAction(final Long actionId) { + /* Display the confirmation */ + final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.get("caption.forcequit.action.confirmbox"), + i18n.get("message.forcequit.action.confirm"), i18n.get("button.ok"), i18n.get("button.cancel"), ok -> { + if (ok) { + final boolean cancelResult = forceQuitActiveAction(actionId); + if (cancelResult) { + /* + * Refresh the action history table to show latest + * change of the action cancellation and update the + * Target Details + */ + populateAndupdateTargetDetails(target); + notification.displaySuccess(i18n.get("message.forcequit.action.success")); + } else { + notification.displayValidationError(i18n.get("message.forcequit.action.failed")); + } + } + } , FontAwesome.WARNING); + UI.getCurrent().addWindow(confirmDialog.getWindow()); + confirmDialog.getWindow().bringToFront(); + } + /** * Show confirmation window and if ok then only, cancel the action. * @@ -786,6 +813,21 @@ public class ActionHistoryTable extends TreeTable implements Handler { return false; } + // service call to cancel the active action + private boolean forceQuitActiveAction(final Long actionId) { + if (actionId != null) { + final Action activeAction = deploymentManagement.findAction(actionId); + try { + deploymentManagement.forceQuitAction(activeAction, target); + return true; + } catch (final CancelActionNotAllowedException e) { + LOG.info("Force Cancel action not allowed exception :{}", e); + return false; + } + } + return false; + } + private void updateTargetAndDsTable() { /* * Update the target status in the Target table and update the color @@ -803,8 +845,8 @@ public class ActionHistoryTable extends TreeTable implements Handler { if (managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent() && null != managementUIState.getDistributionTableFilters().getPinnedTargetId().get()) { - final String alreadyPinnedControllerId = managementUIState.getDistributionTableFilters() - .getPinnedTargetId().get(); + final String alreadyPinnedControllerId = managementUIState.getDistributionTableFilters().getPinnedTargetId() + .get(); // if the current target is pinned publish a pin event again if (null != alreadyPinnedControllerId && alreadyPinnedControllerId.equals(target.getControllerId())) { eventBus.publish(this, PinUnpinEvent.PIN_TARGET); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java old mode 100755 new mode 100644 index bcfc6de4a..b7eb7d708 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java @@ -190,8 +190,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { saveDistribution.addClickListener(event -> saveDistribution()); /* close button */ - discardDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "", true, - FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); + discardDistribution = SPUIComponentProvider.getButton(SPUIComponetIdProvider.DIST_ADD_DISCARD, "", "", "", + true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); discardDistribution.addClickListener(event -> discardDistribution()); } @@ -206,8 +206,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { DistributionSetTypeBeanQuery.class); dtQF.setQueryConfiguration(queryConfig); - final LazyQueryContainer disttypeContainer = new LazyQueryContainer( - new LazyQueryDefinition(true, SPUIDefinitions.DIST_TYPE_SIZE, SPUILabelDefinitions.VAR_NAME), dtQF); + final LazyQueryContainer disttypeContainer = new LazyQueryContainer(new LazyQueryDefinition(true, + SPUIDefinitions.DIST_TYPE_SIZE, SPUILabelDefinitions.VAR_NAME), dtQF); disttypeContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", true, true); @@ -219,8 +219,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { } private DistributionSetType getDefaultDistributionSetType() { - final TenantMetaData tenantMetaData = tenantMetaDataRepository - .findByTenantIgnoreCase(systemManagement.currentTenant()); + final TenantMetaData tenantMetaData = tenantMetaDataRepository.findByTenantIgnoreCase(systemManagement + .currentTenant()); return tenantMetaData.getDefaultDsType(); } @@ -259,12 +259,12 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { notificationMessage.displaySuccess(i18n.get("message.new.dist.save.success", new Object[] { currentDS.getName(), currentDS.getVersion() })); // update table row+details layout - eventBus.publish(this, - new DistributionTableEvent(DistributionComponentEvent.EDIT_DISTRIBUTION, currentDS)); + eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.EDIT_DISTRIBUTION, + currentDS)); } catch (final EntityAlreadyExistsException entityAlreadyExistsException) { LOG.error("Update distribution failed {}", entityAlreadyExistsException); - notificationMessage.displayValidationError( - i18n.get("message.distribution.no.update", currentDS.getName() + ":" + currentDS.getVersion())); + notificationMessage.displayValidationError(i18n.get("message.distribution.no.update", + currentDS.getName() + ":" + currentDS.getVersion())); } closeThisWindow(); } @@ -361,8 +361,8 @@ public class DistributionAddUpdateWindowLayout extends VerticalLayout { if (existingDs != null && (!editDistribution || editDistribution && !existingDs.getId().equals(editDistId))) { distNameTextField.addStyleName("v-textfield-error"); distVersionTextField.addStyleName("v-textfield-error"); - notificationMessage.displayValidationError( - i18n.get("message.duplicate.dist", new Object[] { existingDs.getName(), existingDs.getVersion() })); + notificationMessage.displayValidationError(i18n.get("message.duplicate.dist", + new Object[] { existingDs.getName(), existingDs.getVersion() })); return false; } else { diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java old mode 100755 new mode 100644 index c0dc6964d..522f111c1 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionBeanQuery.java @@ -41,10 +41,6 @@ import com.google.common.base.Strings; * * * - * - * - * - * */ public class DistributionBeanQuery extends AbstractBeanQuery { @@ -88,8 +84,7 @@ public class DistributionBeanQuery extends AbstractBeanQuery sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]); // Add sort for (int distId = 1; distId < sortPropertyIds.length; distId++) { - sort.and(new Sort(sortStates[distId] ? Direction.ASC : Direction.DESC, - (String) sortPropertyIds[distId])); + sort.and(new Sort(sortStates[distId] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[distId])); } } } @@ -117,8 +112,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery pinnedControllerId); } else if (distributionTags.isEmpty() && Strings.isNullOrEmpty(searchText) && !noTagClicked) { // if no search filters available - distBeans = getDistributionSetManagement() - .findDistributionSetsAll(new OffsetBasedPageRequest(startIndex, count, sort), false, true); + distBeans = getDistributionSetManagement().findDistributionSetsAll( + new OffsetBasedPageRequest(startIndex, count, sort), false, true); } else { final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false) .setIsComplete(true).setSearchText(searchText).setSelectDSWithNoTag(noTagClicked) @@ -139,6 +134,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery proxyDistribution.setDescription(distributionSet.getDescription()); proxyDistribution.setCreatedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getCreatedBy())); proxyDistribution.setModifiedByUser(HawkbitCommonUtil.getIMUser(distributionSet.getLastModifiedBy())); + proxyDistribution.setNameVersion(HawkbitCommonUtil.getFormattedNameVersion(distributionSet.getName(), + distributionSet.getVersion())); proxyDistributions.add(proxyDistribution); } return proxyDistributions; @@ -157,8 +154,8 @@ public class DistributionBeanQuery extends AbstractBeanQuery pinnedControllerId); } else if (distributionTags.isEmpty() && Strings.isNullOrEmpty(searchText) && !noTagClicked) { // if no search filters available - firstPageDistributionSets = getDistributionSetManagement() - .findDistributionSetsAll(new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, true); + firstPageDistributionSets = getDistributionSetManagement().findDistributionSetsAll( + new PageRequest(0, SPUIDefinitions.PAGE_SIZE, sort), false, true); } else { final DistributionSetFilter distributionSetFilter = new DistributionSetFilterBuilder().setIsDeleted(false) .setIsComplete(true).setSearchText(searchText).setSelectDSWithNoTag(noTagClicked) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java old mode 100755 new mode 100644 index 59a0c7895..487282f75 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionDetails.java @@ -82,7 +82,7 @@ public class DistributionDetails extends AbstractTableDetailsLayout { protected void init() { eventBus.subscribe(this); softwareModuleTable = new SoftwareModuleDetailsTable(); - softwareModuleTable.init(i18n); + softwareModuleTable.init(i18n, false, permissionChecker, null, null, null); super.init(); ui = UI.getCurrent(); } @@ -95,8 +95,7 @@ public class DistributionDetails extends AbstractTableDetailsLayout { @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final DistributionTableEvent distributionTableEvent) { if (distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.ON_VALUE_CHANGE - || distributionTableEvent - .getDistributionComponentEvent() == DistributionComponentEvent.EDIT_DISTRIBUTION) { + || distributionTableEvent.getDistributionComponentEvent() == DistributionComponentEvent.EDIT_DISTRIBUTION) { ui.access(() -> { /** * distributionTableEvent.getDistributionSet() is null when @@ -118,7 +117,7 @@ public class DistributionDetails extends AbstractTableDetailsLayout { /* * (non-Javadoc) - * + * * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# * getDefaultCaption() */ @@ -129,7 +128,7 @@ public class DistributionDetails extends AbstractTableDetailsLayout { /* * (non-Javadoc) - * + * * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# * addTabs(com.vaadin. ui.TabSheet) */ @@ -144,7 +143,7 @@ public class DistributionDetails extends AbstractTableDetailsLayout { /* * (non-Javadoc) - * + * * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# * onEdit(com.vaadin.ui .Button.ClickEvent) */ @@ -159,7 +158,7 @@ public class DistributionDetails extends AbstractTableDetailsLayout { /* * (non-Javadoc) - * + * * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# * getEditButtonId() */ @@ -170,19 +169,19 @@ public class DistributionDetails extends AbstractTableDetailsLayout { /* * (non-Javadoc) - * + * * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# * onLoadIsTableRowSelected () */ @Override protected Boolean onLoadIsTableRowSelected() { - return !(managementUIState.getSelectedDsIdName().isPresent() - && managementUIState.getSelectedDsIdName().get().isEmpty()); + return !(managementUIState.getSelectedDsIdName().isPresent() && managementUIState.getSelectedDsIdName().get() + .isEmpty()); } /* * (non-Javadoc) - * + * * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# * onLoadIsTableMaximized () */ @@ -193,7 +192,7 @@ public class DistributionDetails extends AbstractTableDetailsLayout { /* * (non-Javadoc) - * + * * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# * populateDetailsWidget() */ @@ -204,7 +203,7 @@ public class DistributionDetails extends AbstractTableDetailsLayout { /* * (non-Javadoc) - * + * * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# * clearDetails() */ @@ -215,7 +214,7 @@ public class DistributionDetails extends AbstractTableDetailsLayout { /* * (non-Javadoc) - * + * * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# * hasEditPermission() */ @@ -226,7 +225,7 @@ public class DistributionDetails extends AbstractTableDetailsLayout { /* * (non-Javadoc) - * + * * @see hawkbit.server.ui.common.detailslayout.AbstractTableDetailsLayout# * getTabSheetId() */ @@ -290,9 +289,9 @@ public class DistributionDetails extends AbstractTableDetailsLayout { } if (isMigrationRequired != null) { - detailsTabLayout.addComponent( - SPUIComponentProvider.createNameValueLabel(i18n.get("checkbox.dist.migration.required"), - isMigrationRequired.equals(Boolean.TRUE) ? i18n.get("label.yes") : i18n.get("label.no"))); + detailsTabLayout.addComponent(SPUIComponentProvider.createNameValueLabel( + i18n.get("checkbox.dist.migration.required"), + isMigrationRequired.equals(Boolean.TRUE) ? i18n.get("label.yes") : i18n.get("label.no"))); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java old mode 100755 new mode 100644 index f69aa1b5a..588c61f75 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTable.java @@ -21,11 +21,11 @@ import javax.annotation.PostConstruct; import javax.annotation.PreDestroy; import org.eclipse.hawkbit.repository.DistributionSetManagement; -import org.eclipse.hawkbit.repository.DistributionSetTagAssigmentResult; import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.DistributionSet; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; +import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult; import org.eclipse.hawkbit.repository.model.Target; import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.ui.common.table.AbstractTable; @@ -33,8 +33,6 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent; import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent.DistributionComponentEvent; import org.eclipse.hawkbit.ui.management.event.DistributionTableFilterEvent; -import org.eclipse.hawkbit.ui.management.event.DistributionTagEvent; -import org.eclipse.hawkbit.ui.management.event.DistributionTagEvent.DistTagComponentEvent; import org.eclipse.hawkbit.ui.management.event.DragEvent; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria; @@ -50,8 +48,6 @@ import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.eclipse.hawkbit.ui.utils.TableColumn; import org.eclipse.hawkbit.ui.utils.UINotification; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; @@ -87,8 +83,6 @@ public class DistributionTable extends AbstractTable { private static final long serialVersionUID = -1928335256399519494L; - private static final Logger LOG = LoggerFactory.getLogger(DistributionTable.class); - @Autowired private I18N i18n; @@ -197,12 +191,13 @@ public class DistributionTable extends AbstractTable { @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final ManagementUIEvent managementUIEvent) { - UI.getCurrent().access(() -> { - if (managementUIEvent == ManagementUIEvent.UNASSIGN_DISTRIBUTION_TAG - || managementUIEvent == ManagementUIEvent.ASSIGN_DISTRIBUTION_TAG) { - refreshFilter(); - } - }); + UI.getCurrent().access( + () -> { + if (managementUIEvent == ManagementUIEvent.UNASSIGN_DISTRIBUTION_TAG + || managementUIEvent == ManagementUIEvent.ASSIGN_DISTRIBUTION_TAG) { + refreshFilter(); + } + }); } /* @@ -231,8 +226,8 @@ public class DistributionTable extends AbstractTable { managementUIState.getDistributionTableFilters().getPinnedTargetId() .ifPresent(value -> queryConfiguration.put(SPUIDefinitions.ORDER_BY_PINNED_TARGET, value)); final List list = new ArrayList(); - queryConfiguration.put(SPUIDefinitions.FILTER_BY_NO_TAG, - managementUIState.getDistributionTableFilters().isNoTagSelected()); + queryConfiguration.put(SPUIDefinitions.FILTER_BY_NO_TAG, managementUIState.getDistributionTableFilters() + .isNoTagSelected()); if (!managementUIState.getDistributionTableFilters().getDistSetTags().isEmpty()) { list.addAll(managementUIState.getDistributionTableFilters().getDistSetTags()); } @@ -240,9 +235,8 @@ public class DistributionTable extends AbstractTable { final BeanQueryFactory distributionQF = new BeanQueryFactory( DistributionBeanQuery.class); distributionQF.setQueryConfiguration(queryConfiguration); - final LazyQueryContainer distributionContainer = new LazyQueryContainer( - new LazyQueryDefinition(true, SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME), - distributionQF); + final LazyQueryContainer distributionContainer = new LazyQueryContainer(new LazyQueryDefinition(true, + SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME), distributionQF); return distributionContainer; } @@ -310,7 +304,7 @@ public class DistributionTable extends AbstractTable { protected void onValueChange() { eventBus.publish(this, DragEvent.HIDE_DROP_HINT); @SuppressWarnings("unchecked") - final Set values = (Set) getValue(); + final Set values = HawkbitCommonUtil.getSelectedDSDetails(this); DistributionSetIdName value = null; if (values != null && !values.isEmpty()) { final Iterator iterator = values.iterator(); @@ -327,8 +321,8 @@ public class DistributionTable extends AbstractTable { managementUIState.setLastSelectedDsIdName(value); final DistributionSet lastSelectedDistSet = distributionSetManagement .findDistributionSetByIdWithDetails(value.getId()); - eventBus.publish(this, - new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, lastSelectedDistSet)); + eventBus.publish(this, new DistributionTableEvent(DistributionComponentEvent.ON_VALUE_CHANGE, + lastSelectedDistSet)); } } else { managementUIState.setSelectedDsIdName(null); @@ -401,7 +395,7 @@ public class DistributionTable extends AbstractTable { private void assignDsTag(final DragAndDropEvent event) { final com.vaadin.event.dd.TargetDetails taregtDet = event.getTargetDetails(); final Table distTable = (Table) taregtDet.getTarget(); - final Set distsSelected = (Set) distTable.getValue(); + final Set distsSelected = HawkbitCommonUtil.getSelectedDSDetails(distTable); final Set distList = new HashSet(); final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails(); @@ -423,37 +417,20 @@ public class DistributionTable extends AbstractTable { if (result.getAssigned() >= 1 && managementUIState.getDistributionTableFilters().isNoTagSelected()) { refreshFilter(); } - updateTagLayoutInDetails(result, distTagName); - } - - private void updateTagLayoutInDetails(final DistributionSetTagAssigmentResult result, final String distTagName) { - if (result.getAssigned() > 0) { - final List assignedDsNames = result.getAssignedDs().stream().map(t -> t.getId()) - .collect(Collectors.toList()); - if (assignedDsNames.contains(managementUIState.getLastSelectedDsIdName().getId())) { - eventBus.publish(this, new DistributionTagEvent(DistTagComponentEvent.ASSIGNED, distTagName)); - } - } else if (result.getUnassigned() > 0) { - final List unassignedDsNames = result.getUnassignedDs().stream().map(t -> t.getId()) - .collect(Collectors.toList()); - if (unassignedDsNames.contains(managementUIState.getLastSelectedDsIdName().getId())) { - eventBus.publish(this, new DistributionTagEvent(DistTagComponentEvent.UNASSIGNED, distTagName)); - } - } } private void assignTargetTag(final DragAndDropEvent event) { final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails(); final Object distItemId = dropData.getItemIdOver(); - final String targetTagName = HawkbitCommonUtil.removePrefix( - event.getTransferable().getSourceComponent().getId(), SPUIDefinitions.TARGET_TAG_ID_PREFIXS); + final String targetTagName = HawkbitCommonUtil.removePrefix(event.getTransferable().getSourceComponent() + .getId(), SPUIDefinitions.TARGET_TAG_ID_PREFIXS); // get all the targets assigned to the tag // assign dist to those targets final List assignedTargets = targetService.findTargetsByTag(targetTagName); if (!assignedTargets.isEmpty()) { final Set targetDetailsList = new HashSet(); - assignedTargets.forEach(target -> targetDetailsList - .add(new TargetIdName(target.getId(), target.getControllerId(), target.getName()))); + assignedTargets.forEach(target -> targetDetailsList.add(new TargetIdName(target.getId(), target + .getControllerId(), target.getName()))); assignTargetToDs(getItem(distItemId), targetDetailsList); } else { notification.displaySuccess(i18n.get("message.no.targets.assiged.fortag", new Object[] { targetTagName })); @@ -463,7 +440,7 @@ public class DistributionTable extends AbstractTable { private void assignTargetToDs(final DragAndDropEvent event) { final TableTransferable transferable = (TableTransferable) event.getTransferable(); final Table source = transferable.getSourceComponent(); - final Set targetsSelected = (Set) source.getValue(); + final Set targetsSelected = HawkbitCommonUtil.getSelectedTargetDetails(source); final Set targetDetailsList = new HashSet(); if (!targetsSelected.contains(transferable.getData("itemId"))) { @@ -484,8 +461,7 @@ public class DistributionTable extends AbstractTable { final Long distId = (Long) item.getItemProperty("id").getValue(); final String distName = (String) item.getItemProperty("name").getValue(); final String distVersion = (String) item.getItemProperty("version").getValue(); - final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distId, distName, - distVersion); + final DistributionSetIdName distributionSetIdName = new DistributionSetIdName(distId, distName, distVersion); showOrHidePopupAndNotification(validate(targetDetailsList, distributionSetIdName)); } } @@ -537,14 +513,15 @@ public class DistributionTable extends AbstractTable { private Boolean isNoTagButton(final String tagData, final String targetNoTagData) { if (tagData.equals(targetNoTagData)) { - notification.displayValidationError( - i18n.get("message.tag.cannot.be.assigned", new Object[] { i18n.get("label.no.tag.assigned") })); + notification.displayValidationError(i18n.get("message.tag.cannot.be.assigned", + new Object[] { i18n.get("label.no.tag.assigned") })); return true; } return false; } /** + * Validate the assignment. * * @param targetDetailsList * @param source @@ -552,11 +529,9 @@ public class DistributionTable extends AbstractTable { * @param distName * @return String as indicator */ - private String validate(final Set targetDetailsList, - final DistributionSetIdName distributionSetIdName) { + private String validate(final Set targetDetailsList, final DistributionSetIdName distributionSetIdName) { String pendingActionMessage = null; for (final TargetIdName trgtNameId : targetDetailsList) { - LOG.debug("Adding a log to check if trgtNameId is null : {} ", trgtNameId); if (null != trgtNameId) { if (managementUIState.getAssignedList().keySet().contains(trgtNameId) && managementUIState.getAssignedList().get(trgtNameId).equals(distributionSetIdName)) { @@ -606,18 +581,18 @@ public class DistributionTable extends AbstractTable { } private void updateDistributionInTable(final DistributionSet editedDs) { - final Item item = getContainerDataSource() - .getItem(new DistributionSetIdName(editedDs.getId(), editedDs.getName(), editedDs.getVersion())); + final Item item = getContainerDataSource().getItem( + new DistributionSetIdName(editedDs.getId(), editedDs.getName(), editedDs.getVersion())); item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(editedDs.getName()); item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).setValue(editedDs.getVersion()); - item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY) - .setValue(HawkbitCommonUtil.getIMUser(editedDs.getCreatedBy())); - item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE) - .setValue(SPDateTimeUtil.getFormattedDate(editedDs.getCreatedAt())); - item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY) - .setValue(HawkbitCommonUtil.getIMUser(editedDs.getLastModifiedBy())); - item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE) - .setValue(SPDateTimeUtil.getFormattedDate(editedDs.getLastModifiedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_BY).setValue( + HawkbitCommonUtil.getIMUser(editedDs.getCreatedBy())); + item.getItemProperty(SPUILabelDefinitions.VAR_CREATED_DATE).setValue( + SPDateTimeUtil.getFormattedDate(editedDs.getCreatedAt())); + item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY).setValue( + HawkbitCommonUtil.getIMUser(editedDs.getLastModifiedBy())); + item.getItemProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE).setValue( + SPDateTimeUtil.getFormattedDate(editedDs.getLastModifiedAt())); item.getItemProperty(SPUILabelDefinitions.VAR_DESC).setValue(editedDs.getDescription()); } @@ -634,8 +609,8 @@ public class DistributionTable extends AbstractTable { } private void styleDistributionTableOnPinning() { - final Target targetObj = targetService.findTargetByControllerIDWithDetails( - managementUIState.getDistributionTableFilters().getPinnedTargetId().get()); + final Target targetObj = targetService.findTargetByControllerIDWithDetails(managementUIState + .getDistributionTableFilters().getPinnedTargetId().get()); if (targetObj != null) { final DistributionSet assignedDistribution = targetObj.getAssignedDistributionSet(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java old mode 100755 new mode 100644 index 16abe48c7..1f28293d2 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableHeader.java @@ -355,4 +355,15 @@ public class DistributionTableHeader extends AbstractTableHeader { protected Boolean isBulkUploadAllowed() { return Boolean.FALSE; } + + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.common.table.AbstractTableHeader# + * isBulkUploadInProgress() + */ + @Override + protected boolean isBulkUploadInProgress() { + return false; + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionTableLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java old mode 100755 new mode 100644 index 7fef8d3f3..f711ac7cd --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/CreateUpdateDistributionTagLayoutWindow.java @@ -11,21 +11,20 @@ package org.eclipse.hawkbit.ui.management.dstag; import java.util.ArrayList; import java.util.List; -import org.eclipse.hawkbit.repository.SpPermissionChecker; -import org.eclipse.hawkbit.repository.TagManagement; +import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent; +import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent; +import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; -import org.eclipse.hawkbit.ui.management.event.DistributionTagEvent; -import org.eclipse.hawkbit.ui.management.event.DistributionTagEvent.DistTagComponentEvent; import org.eclipse.hawkbit.ui.management.tag.CreateUpdateTagLayout; import org.eclipse.hawkbit.ui.management.tag.SpColorPickerPreview; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.beans.factory.annotation.Autowired; -import org.vaadin.spring.events.EventBus; +import org.vaadin.spring.events.EventScope; +import org.vaadin.spring.events.annotation.EventBusListenerMethod; import com.google.common.base.Strings; import com.vaadin.shared.ui.colorpicker.Color; @@ -50,33 +49,15 @@ public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayo */ private static final long serialVersionUID = 444276149954167545L; - @Autowired - private transient TagManagement tagManagementService; - @Autowired private transient UINotification uiNotification; - @Autowired - private I18N i18n; - - @Autowired - private transient EventBus.SessionEventBus eventBus; - - @Autowired - private SpPermissionChecker permChecker; private static final String MISSING_TAG_NAME = "message.error.missing.tagname"; private static final String TARGET_TAG_NAME_DYNAMIC_STYLE = "new-target-tag-name"; private static final String MSG_TEXTFIELD_NAME = "textfield.name"; private Window distTagWindow; - /** - * Initialize distribution Tag layout. - */ - public void initDistTagLayout() { - super.init(); - } - public Window getWindow() { reset(); distTagWindow = SPUIComponentProvider.getWindow(i18n.get("caption.add.tag"), null, @@ -89,7 +70,7 @@ public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayo @Override protected void populateTagNameCombo() { tagNameComboBox.removeAllItems(); - final List distTagNameList = tagManagementService.findDistributionSetTagsAll(); + final List distTagNameList = tagManagement.findAllDistributionSetTags(); distTagNameList.forEach(value -> tagNameComboBox.addItem(value.getName())); } @@ -99,7 +80,7 @@ public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayo @Override public void save(final ClickEvent event) { if (mandatoryValuesPresent()) { - final DistributionSetTag existingDistTag = tagManagementService.findDistributionSetTag(tagName.getValue()); + final DistributionSetTag existingDistTag = tagManagement.findDistributionSetTag(tagName.getValue()); if (optiongroup.getValue().equals(createTagNw)) { if (!checkIsDuplicate(existingDistTag)) { crateNewTag(); @@ -129,11 +110,8 @@ public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayo if (colorPicked != null) { newDistTag.setColour(colorPicked); } - newDistTag = tagManagementService.createDistributionSetTag(newDistTag); + newDistTag = tagManagement.createDistributionSetTag(newDistTag); uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { newDistTag.getName() })); - - eventBus.publish(this, new DistributionTagEvent(DistTagComponentEvent.ADD_DIST_TAG, newDistTag)); - resetDistTagValues(); } else { @@ -155,11 +133,9 @@ public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayo distObj.setDescription(null != descUpdateValue ? descUpdateValue : null); // update target tag with color selected distObj.setColour(getColorPickedSting()); - tagManagementService.updateDistributionSetTag(distObj); + tagManagement.updateDistributionSetTag(distObj); uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { distObj.getName() })); closeWindow(); - eventBus.publish(this, new DistributionTagEvent(DistTagComponentEvent.EDIT_DIST_TAG, distObj)); - } else { uiNotification.displayValidationError(i18n.get("message.tag.update.mandatory")); } @@ -276,7 +252,7 @@ public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayo @Override public void setTagDetails(final String distTagSelected) { tagName.setValue(distTagSelected); - final DistributionSetTag selectedDistTag = tagManagementService.findDistributionSetTag(distTagSelected); + final DistributionSetTag selectedDistTag = tagManagement.findDistributionSetTag(distTagSelected); if (null != selectedDistTag) { tagDesc.setValue(selectedDistTag.getDescription()); if (null == selectedDistTag.getColour()) { @@ -304,11 +280,26 @@ public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayo private Boolean checkIsDuplicate(final DistributionSetTag existingDistTag) { if (existingDistTag != null) { - uiNotification.displayValidationError( - i18n.get("message.tag.duplicate.check", new Object[] { existingDistTag.getName() })); + uiNotification.displayValidationError(i18n.get("message.tag.duplicate.check", + new Object[] { existingDistTag.getName() })); return Boolean.TRUE; } return Boolean.FALSE; } + @EventBusListenerMethod(scope = EventScope.SESSION) + void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedBulkEvent event) { + populateTagNameCombo(); + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEvent event) { + populateTagNameCombo(); + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdateEvent event) { + populateTagNameCombo(); + } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java old mode 100755 new mode 100644 index 8c2e5a250..133264a68 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagBeanQuery.java @@ -56,8 +56,8 @@ public class DistributionTagBeanQuery extends AbstractBeanQuery { @Override public int size() { - firstPageDsTag = getTagManagement() - .findDistributionSetTagsAll(new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort)); + firstPageDsTag = getTagManagement().findAllDistributionSetTags( + new OffsetBasedPageRequest(0, SPUIDefinitions.PAGE_SIZE, sort)); long size = firstPageDsTag.getTotalElements(); if (size > Integer.MAX_VALUE) { size = Integer.MAX_VALUE; @@ -79,8 +79,8 @@ public class DistributionTagBeanQuery extends AbstractBeanQuery { if (startIndex == 0 && firstPageDsTag != null) { dsTagBeans = firstPageDsTag; } else { - dsTagBeans = getTagManagement() - .findDistributionSetTagsAll(new OffsetBasedPageRequest(startIndex, count, sort)); + dsTagBeans = getTagManagement().findAllDistributionSetTags( + new OffsetBasedPageRequest(startIndex, count, sort)); } for (final DistributionSetTag tag : dsTagBeans) { final ProxyTag proxyTargetTag = new ProxyTag(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtonClick.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtonClick.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java old mode 100755 new mode 100644 index c9d062cd3..e4680a0c8 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagButtons.java @@ -13,12 +13,14 @@ import java.util.Map; import javax.annotation.PreDestroy; +import org.eclipse.hawkbit.eventbus.event.DistributionSetTagCreatedBulkEvent; +import org.eclipse.hawkbit.eventbus.event.DistributionSetTagDeletedEvent; +import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent; import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtonClickBehaviour; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons; import org.eclipse.hawkbit.ui.management.event.DistributionTagDropEvent; -import org.eclipse.hawkbit.ui.management.event.DistributionTagEvent; import org.eclipse.hawkbit.ui.management.event.DragEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.tag.TagIdName; @@ -80,12 +82,18 @@ public class DistributionTagButtons extends AbstractFilterButtons { } @EventBusListenerMethod(scope = EventScope.SESSION) - void onEvent(final DistributionTagEvent event) { - if (event.getDistTagComponentEvent() == DistributionTagEvent.DistTagComponentEvent.ADD_DIST_TAG - || event.getDistTagComponentEvent() == DistributionTagEvent.DistTagComponentEvent.EDIT_DIST_TAG - || event.getDistTagComponentEvent() == DistributionTagEvent.DistTagComponentEvent.DELETE_DIST_TAG) { - refreshTagTable(); - } + void onDistributionSetTagCreatedBulkEvent(final DistributionSetTagCreatedBulkEvent event) { + refreshTagTable(); + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onDistributionSetTagDeletedEvent(final DistributionSetTagDeletedEvent event) { + refreshTagTable(); + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onDistributionSetTagUpdateEvent(final DistributionSetTagUpdateEvent event) { + refreshTagTable(); } @EventBusListenerMethod(scope = EventScope.SESSION) @@ -123,8 +131,9 @@ public class DistributionTagButtons extends AbstractFilterButtons { final BeanQueryFactory tagQF = new BeanQueryFactory( DistributionTagBeanQuery.class); tagQF.setQueryConfiguration(queryConfig); - final LazyQueryContainer tagContainer = HawkbitCommonUtil.createDSLazyQueryContainer( - new BeanQueryFactory(DistributionTagBeanQuery.class)); + final LazyQueryContainer tagContainer = HawkbitCommonUtil + .createDSLazyQueryContainer(new BeanQueryFactory( + DistributionTagBeanQuery.class)); return tagContainer; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagHeader.java old mode 100755 new mode 100644 index 6ccccd2e4..5e19e05f8 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagHeader.java @@ -57,7 +57,7 @@ public class DistributionTagHeader extends AbstractFilterHeader { public void init() { super.init(); if (hasCreateUpdatePermission()) { - createORUpdateDistributionTagLayout.initDistTagLayout(); + createORUpdateDistributionTagLayout.init(); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstag/DistributionTagLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/BulkUploadPopupEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/BulkUploadPopupEvent.java new file mode 100644 index 000000000..778a5df9c --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/BulkUploadPopupEvent.java @@ -0,0 +1,18 @@ +/** + * 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.ui.management.event; + +/** + * Events related to target bulk upload popup window. + * + * + */ +public enum BulkUploadPopupEvent { + MINIMIZED, MAXIMIMIZED, CLOSED +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/BulkUploadValidationMessageEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/BulkUploadValidationMessageEvent.java new file mode 100644 index 000000000..a876e4720 --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/BulkUploadValidationMessageEvent.java @@ -0,0 +1,35 @@ +/** + * 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.ui.management.event; + +/** + * Holds error message on failure of tag or distribution set assignment in bulk + * targets upload. + * + */ +public class BulkUploadValidationMessageEvent { + + String validationErrorMessage; + + /** + * @param validationErrorMessage + * error message on validation failure. + */ + public BulkUploadValidationMessageEvent(final String validationErrorMessage) { + this.validationErrorMessage = validationErrorMessage; + } + + /** + * @return the validationErrorMessage + */ + public String getValidationErrorMessage() { + return validationErrorMessage; + } + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTableEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTableEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTableFilterEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTableFilterEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagDropEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagDropEvent.java old mode 100755 new mode 100644 index 8496a132d..3f05f14c1 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagDropEvent.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagDropEvent.java @@ -14,10 +14,9 @@ import java.util.Set; import java.util.stream.Collectors; import org.eclipse.hawkbit.repository.DistributionSetManagement; -import org.eclipse.hawkbit.repository.DistributionSetTagAssigmentResult; import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; -import org.eclipse.hawkbit.ui.management.event.DistributionTagEvent.DistTagComponentEvent; +import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult; import org.eclipse.hawkbit.ui.management.state.DistributionTableFilters; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; @@ -91,8 +90,8 @@ public class DistributionTagDropEvent implements DropHandler { private Boolean isNoTagAssigned(final DragAndDropEvent event) { final String tagName = ((DragAndDropWrapper) (event.getTargetDetails().getTarget())).getData().toString(); if (tagName.equals(SPUIDefinitions.DISTRIBUTION_TAG_BUTTON)) { - notification.displayValidationError( - i18n.get("message.tag.cannot.be.assigned", new Object[] { i18n.get("label.no.tag.assigned") })); + notification.displayValidationError(i18n.get("message.tag.cannot.be.assigned", + new Object[] { i18n.get("label.no.tag.assigned") })); return false; } return true; @@ -177,30 +176,13 @@ public class DistributionTagDropEvent implements DropHandler { SPUIDefinitions.DISTRIBUTION_TAG_ID_PREFIXS); final List tagsClickedList = distFilterParameters.getDistSetTags(); - final DistributionSetTagAssigmentResult result = distributionSetManagement.toggleTagAssignment(distributionList, - distTagName); + final DistributionSetTagAssigmentResult result = distributionSetManagement.toggleTagAssignment( + distributionList, distTagName); notification.displaySuccess(HawkbitCommonUtil.getDistributionTagAssignmentMsg(distTagName, result, i18n)); if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()) { eventBus.publish(this, TargetFilterEvent.FILTER_BY_TAG); } - updateTagLayoutInDetails(result, distTagName); - } - - private void updateTagLayoutInDetails(final DistributionSetTagAssigmentResult result, final String distTagName) { - if (result.getAssigned() > 0) { - final List assignedDsNames = result.getAssignedDs().stream().map(t -> t.getId()) - .collect(Collectors.toList()); - if (assignedDsNames.contains(managementUIState.getLastSelectedDsIdName().getId())) { - eventBus.publish(this, new DistributionTagEvent(DistTagComponentEvent.ASSIGNED, distTagName)); - } - } else if (result.getUnassigned() > 0) { - final List unassignedDsNames = result.getUnassignedDs().stream().map(t -> t.getId()) - .collect(Collectors.toList()); - if (unassignedDsNames.contains(managementUIState.getLastSelectedDsIdName().getId())) { - eventBus.publish(this, new DistributionTagEvent(DistTagComponentEvent.UNASSIGNED, distTagName)); - } - } } /** diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagEvent.java deleted file mode 100755 index 92e31ee77..000000000 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DistributionTagEvent.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * 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.ui.management.event; - -import org.eclipse.hawkbit.repository.model.DistributionSetTag; - -/** - * - * - * - */ -public class DistributionTagEvent { - - /** - * - * - */ - public enum DistTagComponentEvent { - - ADD_DIST_TAG, EDIT_DIST_TAG, DELETE_DIST_TAG, ASSIGNED, UNASSIGNED - } - - private DistTagComponentEvent distTagComponentEvent; - - private DistributionSetTag distributionTag; - - private String distributionTagName; - - /** - * @param distTagComponentEvent - * @param distributionTag - */ - public DistributionTagEvent(final DistTagComponentEvent distTagComponentEvent, - final DistributionSetTag distributionTag) { - this.distTagComponentEvent = distTagComponentEvent; - this.distributionTag = distributionTag; - - } - - /** - * @param distTagComponentEvent - * @param distributionTagName - */ - public DistributionTagEvent(final DistTagComponentEvent distTagComponentEvent, final String distributionTagName) { - this.distTagComponentEvent = distTagComponentEvent; - this.distributionTagName = distributionTagName; - - } - - public DistTagComponentEvent getDistTagComponentEvent() { - return distTagComponentEvent; - } - - public String getDistributionTagName() { - return distributionTagName; - } - - public void setDistTagComponentEvent(final DistTagComponentEvent distTagComponentEvent) { - this.distTagComponentEvent = distTagComponentEvent; - } - - public DistributionSetTag getDistributionTag() { - return distributionTag; - } - - public void setDistributionTag(final DistributionSetTag distributionTag) { - this.distributionTag = distributionTag; - } - -} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DragEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/DragEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/ManagementUIEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/ManagementUIEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/ManagementViewAcceptCriteria.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/ManagementViewAcceptCriteria.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/PinUnpinEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/PinUnpinEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/SaveActionWindowEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/SaveActionWindowEvent.java old mode 100755 new mode 100644 index b9ac97045..67a0c1476 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/SaveActionWindowEvent.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/SaveActionWindowEvent.java @@ -15,6 +15,6 @@ package org.eclipse.hawkbit.ui.management.event; */ public enum SaveActionWindowEvent { - SAVED_ASSIGNMENTS, DISCARD_ALL_ASSIGNMENTS, DISCARD_ASSIGNMENTS, DELETED_DISTRIBUTIONS, DISCARD_ALL_DISTRIBUTIONS, SHOW_HIDE_TAB, DELETED_TARGETS, DISCARD_ALL_TARGETS, DISCARD_ASSIGNMENT, DISCARD_DELETE_TARGET, DISCARD_DELETE_DS + SAVED_ASSIGNMENTS, DISCARD_ALL_ASSIGNMENTS, DISCARD_ASSIGNMENTS, DELETED_DISTRIBUTIONS, DISCARD_ALL_DISTRIBUTIONS, SHOW_HIDE_TAB, DISCARD_ALL_TARGETS, DISCARD_ASSIGNMENT, DISCARD_DELETE_TARGET, DISCARD_DELETE_DS, DELETED_TARGETS } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetAddUpdateWindowEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetAddUpdateWindowEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetFilterEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetFilterEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetTableEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetTableEvent.java old mode 100755 new mode 100644 index 7e49b1497..1706361f0 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetTableEvent.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetTableEvent.java @@ -21,11 +21,9 @@ public class TargetTableEvent { /** * Target table components events. * - * - * */ public enum TargetComponentEvent { - ADD_TARGET, EDIT_TARGET, DELETE_TARGET, SELECTED_TARGET, MAXIMIZED, MINIMIZED, SELLECT_ALL + REFRESH_TARGETS, EDIT_TARGET, DELETE_TARGET, SELECTED_TARGET, MAXIMIZED, MINIMIZED, SELLECT_ALL, BULK_TARGET_CREATED, BULK_UPLOAD_COMPLETED, BULK_TARGET_UPLOAD_STARTED, BULK_UPLOAD_PROCESS_STARTED } private TargetComponentEvent targetComponentEvent; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetTagEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetTagEvent.java deleted file mode 100755 index dbdb8c988..000000000 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/event/TargetTagEvent.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * 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.ui.management.event; - -import org.eclipse.hawkbit.repository.model.TargetTag; - -/** - * - * - * - */ -public class TargetTagEvent { - - private TargetTagComponentEvent targetTagComponentEvent; - - private TargetTag targetTag; - - private String targetTagName; - - /** - * - * - */ - public enum TargetTagComponentEvent { - - ADD_TARGETTAG, EDIT_TARGETTAG, DELETE_TARGETTAG, ASSIGNED, UNASSIGNED - } - - /** - * @param targetTagComponentEvent - * @param targetTag - */ - public TargetTagEvent(final TargetTagComponentEvent targetTagComponentEvent, final TargetTag targetTag) { - this.targetTagComponentEvent = targetTagComponentEvent; - this.targetTag = targetTag; - - } - - /** - * @param targetTagComponentEvent - * @param tagName - */ - public TargetTagEvent(final TargetTagComponentEvent targetTagComponentEvent, final String tagName) { - this.targetTagComponentEvent = targetTagComponentEvent; - this.targetTagName = tagName; - - } - - public TargetTag getTargetTag() { - return targetTag; - } - - public void setTargetTag(final TargetTag targetTag) { - this.targetTag = targetTag; - - } - - public TargetTagComponentEvent getTargetTagComponentEvent() { - return targetTagComponentEvent; - } - - public void setTargetTagComponentEvent(final TargetTagComponentEvent targetTagComponentEvent) { - this.targetTagComponentEvent = targetTagComponentEvent; - } - - public String getTargetTagName() { - return targetTagName; - } - -} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ActionTypeOptionGroupLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ActionTypeOptionGroupLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/CountMessageLabel.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/CountMessageLabel.java old mode 100755 new mode 100644 index f5c803223..574457c6b --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/CountMessageLabel.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/CountMessageLabel.java @@ -96,8 +96,7 @@ public class CountMessageLabel extends Label { @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final TargetTableEvent event) { if (event.getTargetComponentEvent() == TargetTableEvent.TargetComponentEvent.SELLECT_ALL - || event.getTargetComponentEvent() == TargetComponentEvent.ADD_TARGET - || event.getTargetComponentEvent() == TargetComponentEvent.DELETE_TARGET) { + || event.getTargetComponentEvent() == TargetComponentEvent.REFRESH_TARGETS) { displayTargetCountStatus(); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java old mode 100755 new mode 100644 index f99e6886a..fe1d5dd2b --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayout.java @@ -19,15 +19,16 @@ import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout; -import org.eclipse.hawkbit.ui.management.event.DistributionTagEvent; -import org.eclipse.hawkbit.ui.management.event.DistributionTagEvent.DistTagComponentEvent; +import org.eclipse.hawkbit.ui.management.dstable.DistributionTable; +import org.eclipse.hawkbit.ui.management.event.BulkUploadPopupEvent; import org.eclipse.hawkbit.ui.management.event.DragEvent; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria; import org.eclipse.hawkbit.ui.management.event.SaveActionWindowEvent; -import org.eclipse.hawkbit.ui.management.event.TargetTagEvent; -import org.eclipse.hawkbit.ui.management.event.TargetTagEvent.TargetTagComponentEvent; +import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; +import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; +import org.eclipse.hawkbit.ui.management.targettable.TargetTable; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider; @@ -43,7 +44,6 @@ import com.vaadin.event.dd.acceptcriteria.AcceptCriterion; import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.ViewScope; import com.vaadin.ui.Component; -import com.vaadin.ui.DragAndDropWrapper; import com.vaadin.ui.Label; import com.vaadin.ui.Table; import com.vaadin.ui.Table.TableTransferable; @@ -147,6 +147,31 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { } } + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEvent(final BulkUploadPopupEvent event) { + if (BulkUploadPopupEvent.MINIMIZED == event) { + UI.getCurrent().access(() -> enableBulkUploadStatusButton()); + } else if (BulkUploadPopupEvent.CLOSED == event) { + UI.getCurrent().access(() -> hideBulkUploadStatusButton()); + } + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEvent(final TargetTableEvent event) { + if (!managementUIState.isTargetTableMaximized()) { + if (TargetComponentEvent.BULK_TARGET_CREATED == event.getTargetComponentEvent()) { + this.getUI().access( + () -> setUploadStatusButtonCaption(managementUIState.getTargetTableFilters().getBulkUpload() + .getFailedUploadCount() + + managementUIState.getTargetTableFilters().getBulkUpload().getSucessfulUploadCount())); + } else if (TargetComponentEvent.BULK_UPLOAD_COMPLETED == event.getTargetComponentEvent()) { + this.getUI().access(() -> updateUploadBtnIconToComplete()); + } else if (TargetComponentEvent.BULK_TARGET_UPLOAD_STARTED == event.getTargetComponentEvent()) { + this.getUI().access(() -> updateUploadBtnIconToProgressIndicator()); + } + } + } + /* * (non-Javadoc) * @@ -216,36 +241,38 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { */ @Override protected void processDroppedComponent(final DragAndDropEvent event) { - /* Get the source component */ final Component source = event.getTransferable().getSourceComponent(); - /* - * Since this delete drop layout used only to drop target table, - * distribution table, Target tag and distribution tag to delete. - */ - if (!isComponentDeletable(source)) { + if (!DeleteActionsLayoutHelper.isComponentDeletable(source)) { notification.displayValidationError(i18n.get("message.cannot.delete")); } else { - if (isTargetTable(source) && canTargetBeDeleted()) { - addInDeleteTargetList((Table) source, (TableTransferable) event.getTransferable()); - updateActionCount(); - } else if (isDistributionTable(source) && canDSBeDeleted()) { - addInDeleteDistributionList((Table) source, (TableTransferable) event.getTransferable()); - updateActionCount(); - } else if (isTargetTag(source) && canTargetBeDeleted()) { - deleteTargetTag(source); - } else if (isDistributionTag(source) && canDSBeDeleted()) { - deleteDistributionTag(source); - } + processDeletion(event, source); } eventBus.publish(this, DragEvent.HIDE_DROP_HINT); hideDropHints(); } - private Boolean isComponentDeletable(final Component source) { - if (isTargetTable(source) || isDistributionTable(source) || isTargetTag(source) || isDistributionTag(source)) { - return Boolean.TRUE; + private void processDeletion(final DragAndDropEvent event, final Component source) { + if (DeleteActionsLayoutHelper.isTargetTable(source) && canTargetBeDeleted()) { + addInDeleteTargetList((Table) source, (TableTransferable) event.getTransferable()); + updateActionCount(); + } else if (DeleteActionsLayoutHelper.isDistributionTable(source) && canDSBeDeleted()) { + addInDeleteDistributionList((Table) source, (TableTransferable) event.getTransferable()); + updateActionCount(); + } else if (DeleteActionsLayoutHelper.isTargetTag(source) && canTargetBeDeleted() + && tagNotInUSeInBulkUpload(source)) { + deleteTargetTag(source); + } else if (DeleteActionsLayoutHelper.isDistributionTag(source) && canDSBeDeleted()) { + deleteDistributionTag(source); } - return Boolean.FALSE; + } + + private boolean tagNotInUSeInBulkUpload(final Component source) { + final String tagName = HawkbitCommonUtil.removePrefix(source.getId(), SPUIDefinitions.TARGET_TAG_ID_PREFIXS); + if (managementUIState.getTargetTableFilters().getBulkUpload().getAssignedTagNames().contains(tagName)) { + notification.displayValidationError(i18n.get("message.tag.use.bulk.upload", tagName)); + return false; + } + return true; } /* @@ -280,7 +307,7 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { * reloadActionCount() */ @Override - protected void reloadActionCount() { + protected void restoreActionCount() { updateActionCount(); } @@ -373,7 +400,6 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { } else { tagManagementService.deleteDistributionSetTag(tagName); notification.displaySuccess(i18n.get("message.delete.success", new Object[] { tagName })); - eventBus.publish(this, new DistributionTagEvent(DistTagComponentEvent.DELETE_DIST_TAG, tagName)); } } @@ -384,55 +410,85 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { } else { tagManagementService.deleteTargetTag(tagName); notification.displaySuccess(i18n.get("message.delete.success", new Object[] { tagName })); - eventBus.publish(this, new TargetTagEvent(TargetTagComponentEvent.DELETE_TARGETTAG, tagName)); } } /** - * @param source + * + * Prepare deleted distribution set . + * + * @param sourceTable + * {@link DistributionTable} + * @param transferable + * {@link TableTransferable} + * */ private void addInDeleteDistributionList(final Table sourceTable, final TableTransferable transferable) { - @SuppressWarnings("unchecked") - final Set distSelected = (Set) sourceTable.getValue(); + final Set distSelected = HawkbitCommonUtil.getSelectedDSDetails(sourceTable); final Set distributionIdNameSet = new HashSet(); + if (!distSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) { distributionIdNameSet.add((DistributionSetIdName) transferable.getData(SPUIDefinitions.ITEMID)); } else { distributionIdNameSet.addAll(distSelected); } - /* - * Flags to identify whether all dropped distributions are already in - * the deleted list (or) some distributions are already in the deleted - * distribution list. - */ - final int existingDeletedDistributionsSize = managementUIState.getDeletedDistributionList().size(); - managementUIState.getDeletedDistributionList().addAll(distributionIdNameSet); - final int newDeletedDistributionsSize = managementUIState.getDeletedDistributionList().size(); - if (newDeletedDistributionsSize == existingDeletedDistributionsSize) { + final DistributionSetIdName dsInBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload() + .getDsNameAndVersion(); + if (isDsInUseInBulkUpload(distributionIdNameSet, dsInBulkUpload)) { + distributionIdNameSet.remove(dsInBulkUpload); + } + + if (!distributionIdNameSet.isEmpty()) { + /* - * No new distributions are added, all distributions dropped now are - * already available in the delete list. Hence display warning - * message accordingly. + * Flags to identify whether all dropped distributions are already + * in the deleted list (or) some distributions are already in the + * deleted distribution list. */ - notification.displayValidationError(i18n.get("message.targets.already.deleted")); - } else if (newDeletedDistributionsSize - existingDeletedDistributionsSize != distributionIdNameSet.size()) { - /* - * Not the all distributions dropped now are added to the delete - * list. There are some distributions are already there in the - * delete list. Hence display warning message accordingly. - */ - notification.displayValidationError(i18n.get("message.dist.deleted.pending")); + final int existingDeletedDistributionsSize = managementUIState.getDeletedDistributionList().size(); + managementUIState.getDeletedDistributionList().addAll(distributionIdNameSet); + final int newDeletedDistributionsSize = managementUIState.getDeletedDistributionList().size(); + if (newDeletedDistributionsSize == existingDeletedDistributionsSize) { + /* + * No new distributions are added, all distributions dropped now + * are already available in the delete list. Hence display + * warning message accordingly. + */ + notification.displayValidationError(i18n.get("message.targets.already.deleted")); + } else if (newDeletedDistributionsSize - existingDeletedDistributionsSize != distributionIdNameSet.size()) { + /* + * Not the all distributions dropped now are added to the delete + * list. There are some distributions are already there in the + * delete list. Hence display warning message accordingly. + */ + notification.displayValidationError(i18n.get("message.dist.deleted.pending")); + } } } + private boolean isDsInUseInBulkUpload(final Set distributionIdNameSet, + final DistributionSetIdName dsInBulkUpload) { + if (distributionIdNameSet.contains(dsInBulkUpload)) { + notification.displayValidationError(i18n.get("message.tag.use.bulk.upload", + HawkbitCommonUtil.getFormattedNameVersion(dsInBulkUpload.getName(), dsInBulkUpload.getVersion()))); + return true; + } + return false; + } + /** - * @param source + * Prepare deleted target list. + * + * @param sourceTable + * {@link TargetTable} * @param transferable + * {@link TableTransferable} + * */ private void addInDeleteTargetList(final Table sourceTable, final TableTransferable transferable) { - @SuppressWarnings("unchecked") - final Set targetSelected = (Set) sourceTable.getValue(); + final Set targetSelected = HawkbitCommonUtil.getSelectedTargetDetails(sourceTable); + final Set targetIdNameSet = new HashSet<>(); if (!targetSelected.contains(transferable.getData(SPUIDefinitions.ITEMID))) { targetIdNameSet.add((TargetIdName) transferable.getData(SPUIDefinitions.ITEMID)); @@ -490,34 +546,52 @@ public class DeleteActionsLayout extends AbstractDeleteActionsLayout { return true; } - private boolean isTargetTable(final Component source) { - return HawkbitCommonUtil.bothSame(source.getId(), SPUIComponetIdProvider.TARGET_TABLE_ID); + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# + * hasBulkUploadPermission() + */ + @Override + protected boolean hasBulkUploadPermission() { + return permChecker.hasCreateTargetPermission(); } - private boolean isDistributionTable(final Component source) { - return HawkbitCommonUtil.bothSame(source.getId(), SPUIComponetIdProvider.DIST_TABLE_ID); + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# + * showBulkUploadWindow() + */ + @Override + protected void showBulkUploadWindow() { + eventBus.publish(this, BulkUploadPopupEvent.MAXIMIMIZED); } - private boolean isTargetTag(final Component source) { - if (source instanceof DragAndDropWrapper) { - final String wrapperData = ((DragAndDropWrapper) source).getData().toString(); - final String id = wrapperData.replace(SPUIDefinitions.TARGET_TAG_BUTTON, ""); - if (wrapperData.contains(SPUIDefinitions.TARGET_TAG_BUTTON) && !id.trim().isEmpty()) { - return true; + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.common.footer.AbstractDeleteActionsLayout# + * restoreBulkUploadStatusCount() + */ + @Override + protected void restoreBulkUploadStatusCount() { + final Long failedCount = managementUIState.getTargetTableFilters().getBulkUpload().getFailedUploadCount(); + final Long successCount = managementUIState.getTargetTableFilters().getBulkUpload().getSucessfulUploadCount(); + if (failedCount != 0 || successCount != 0) { + setUploadStatusButtonCaption(failedCount + successCount); + enableBulkUploadStatusButton(); + if (Math.abs(managementUIState.getTargetTableFilters().getBulkUpload().getProgressBarCurrentValue() - 1) < 0.00001) { + updateUploadBtnIconToComplete(); + } else { + updateUploadBtnIconToProgressIndicator(); } + } - return false; } - private boolean isDistributionTag(final Component source) { - if (source instanceof DragAndDropWrapper) { - final String wrapperData = ((DragAndDropWrapper) source).getData().toString(); - final String id = wrapperData.replace(SPUIDefinitions.DISTRIBUTION_TAG_BUTTON, ""); - if (wrapperData.contains(SPUIDefinitions.DISTRIBUTION_TAG_BUTTON) && !id.trim().isEmpty()) { - return true; - } - } - return false; + @Override + protected boolean hasReadPermission() { + return permChecker.hasTargetReadPermission(); } - } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayoutHelper.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayoutHelper.java new file mode 100644 index 000000000..063c9f655 --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/DeleteActionsLayoutHelper.java @@ -0,0 +1,100 @@ +/** + * 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.ui.management.footer; + +import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; +import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider; +import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; + +import com.vaadin.ui.Component; +import com.vaadin.ui.DragAndDropWrapper; + +/** + * Delete actions layout helper class. + * + */ +public final class DeleteActionsLayoutHelper { + + private DeleteActionsLayoutHelper() { + + } + + /** + * Checks if component is a target tag. + * + * @param source + * Component dropped + * @return true if it component is target tag + */ + public static boolean isTargetTag(final Component source) { + if (source instanceof DragAndDropWrapper) { + final String wrapperData = ((DragAndDropWrapper) source).getData().toString(); + final String id = wrapperData.replace(SPUIDefinitions.TARGET_TAG_BUTTON, ""); + if (wrapperData.contains(SPUIDefinitions.TARGET_TAG_BUTTON) && !id.trim().isEmpty()) { + return true; + } + } + return false; + } + + /** + * Checks if component is distribution tag. + * + * @param source + * component dropped + * @return true if it component is distribution tag + */ + public static boolean isDistributionTag(final Component source) { + if (source instanceof DragAndDropWrapper) { + final String wrapperData = ((DragAndDropWrapper) source).getData().toString(); + final String id = wrapperData.replace(SPUIDefinitions.DISTRIBUTION_TAG_BUTTON, ""); + if (wrapperData.contains(SPUIDefinitions.DISTRIBUTION_TAG_BUTTON) && !id.trim().isEmpty()) { + return true; + } + } + return false; + } + + /** + * Checks if component is target table. + * + * @param source + * component dropped + * @return true if it component is target table + */ + public static boolean isTargetTable(final Component source) { + return HawkbitCommonUtil.bothSame(source.getId(), SPUIComponetIdProvider.TARGET_TABLE_ID); + } + + /** + * Checks id component is distribution table. + * + * @param source + * component dropped + * @return true if it component is distribution table + */ + public static boolean isDistributionTable(final Component source) { + return HawkbitCommonUtil.bothSame(source.getId(), SPUIComponetIdProvider.DIST_TABLE_ID); + } + + /** + * Check if dropped component can be deleted. + * + * @param source + * component dropped + * @return true if component can be deleted + */ + public static Boolean isComponentDeletable(final Component source) { + if (isTargetTable(source) || isDistributionTable(source) || isTargetTag(source) || isDistributionTag(source)) { + return Boolean.TRUE; + } + return Boolean.FALSE; + } + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java old mode 100755 new mode 100644 index 8f91bf336..b3fd122fa --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/footer/ManangementConfirmationWindowLayout.java @@ -155,18 +155,20 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin assignmnetTab.getTable().setContainerDataSource(getAssignmentsTableContainer()); // Add the discard action column - assignmnetTab.getTable().addGeneratedColumn(DISCARD_CHANGES, (source, itemId, columnId) -> { - final StringBuilder style = new StringBuilder(ValoTheme.BUTTON_TINY); - style.append(' '); - style.append(SPUIStyleDefinitions.REDICON); - final Button deleteIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD, - style.toString(), true, FontAwesome.REPLY, SPUIButtonStyleSmallNoBorder.class); - deleteIcon.setData(itemId); - deleteIcon.setImmediate(true); - deleteIcon.addClickListener(event -> discardAssignment( - (TargetIdName) ((Button) event.getComponent()).getData(), assignmnetTab)); - return deleteIcon; - }); + assignmnetTab.getTable().addGeneratedColumn( + DISCARD_CHANGES, + (source, itemId, columnId) -> { + final StringBuilder style = new StringBuilder(ValoTheme.BUTTON_TINY); + style.append(' '); + style.append(SPUIStyleDefinitions.REDICON); + final Button deleteIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD, + style.toString(), true, FontAwesome.REPLY, SPUIButtonStyleSmallNoBorder.class); + deleteIcon.setData(itemId); + deleteIcon.setImmediate(true); + deleteIcon.addClickListener(event -> discardAssignment( + (TargetIdName) ((Button) event.getComponent()).getData(), assignmnetTab)); + return deleteIcon; + }); // set the visible columns final List visibleColumnIds = new ArrayList<>(); @@ -201,9 +203,8 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin final ActionType actionType = ((ActionTypeOptionGroupLayout.ActionTypeOption) actionTypeOptionGroupLayout .getActionTypeOptionGroup().getValue()).getActionType(); final long forcedTimeStamp = (((ActionTypeOptionGroupLayout.ActionTypeOption) actionTypeOptionGroupLayout - .getActionTypeOptionGroup().getValue()) == ActionTypeOption.AUTO_FORCED) - ? actionTypeOptionGroupLayout.getForcedTimeDateField().getValue().getTime() - : Action.NO_FORCE_TIME; + .getActionTypeOptionGroup().getValue()) == ActionTypeOption.AUTO_FORCED) ? actionTypeOptionGroupLayout + .getForcedTimeDateField().getValue().getTime() : Action.NO_FORCE_TIME; final Map> saveAssignedList = new HashMap>(); @@ -319,8 +320,9 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin saveTblitem.getItemProperty(TARGET_NAME).setValue(entry.getKey().getName()); - saveTblitem.getItemProperty(DISTRIBUTION_NAME).setValue(HawkbitCommonUtil - .getDistributionNameAndVersion(entry.getValue().getName(), entry.getValue().getVersion())); + saveTblitem.getItemProperty(DISTRIBUTION_NAME).setValue( + HawkbitCommonUtil.getDistributionNameAndVersion(entry.getValue().getName(), entry.getValue() + .getVersion())); saveTblitem.getItemProperty(TARGET_ID).setValue(entry.getKey().getControllerId()); saveTblitem.getItemProperty(DIST_ID).setValue(entry.getValue().getId()); @@ -344,16 +346,18 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin tab.getTable().setContainerDataSource(getTargetModuleTableContainer()); /* Add the discard action column */ - tab.getTable().addGeneratedColumn(DISCARD_CHANGES, (source, itemId, columnId) -> { - final Button deletestargetIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD, - ValoTheme.BUTTON_TINY + " " + SPUIStyleDefinitions.REDICON, true, FontAwesome.REPLY, - SPUIButtonStyleSmallNoBorder.class); - deletestargetIcon.setData(itemId); - deletestargetIcon.setImmediate(true); - deletestargetIcon.addClickListener(event -> discardTargetDelete( - (TargetIdName) ((Button) event.getComponent()).getData(), itemId, tab)); - return deletestargetIcon; - }); + tab.getTable().addGeneratedColumn( + DISCARD_CHANGES, + (source, itemId, columnId) -> { + final Button deletestargetIcon = SPUIComponentProvider.getButton("", "", + SPUILabelDefinitions.DISCARD, ValoTheme.BUTTON_TINY + " " + SPUIStyleDefinitions.REDICON, + true, FontAwesome.REPLY, SPUIButtonStyleSmallNoBorder.class); + deletestargetIcon.setData(itemId); + deletestargetIcon.setImmediate(true); + deletestargetIcon.addClickListener(event -> discardTargetDelete( + (TargetIdName) ((Button) event.getComponent()).getData(), itemId, tab)); + return deletestargetIcon; + }); /* set the visible columns */ final List visibleColumnIds = new ArrayList<>(); @@ -389,16 +393,18 @@ public class ManangementConfirmationWindowLayout extends AbstractConfirmationWin tab.getTable().setContainerDataSource(getDSModuleTableContainer()); /* Add the discard action column */ - tab.getTable().addGeneratedColumn(DISCARD_CHANGES, (source, itemId, columnId) -> { - final Button deletesDsIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD, - ValoTheme.BUTTON_TINY + " " + SPUIStyleDefinitions.REDICON, true, FontAwesome.REPLY, - SPUIButtonStyleSmallNoBorder.class); - deletesDsIcon.setData(itemId); - deletesDsIcon.setImmediate(true); - deletesDsIcon.addClickListener(event -> discardDSDelete( - (DistributionSetIdName) ((Button) event.getComponent()).getData(), itemId, tab)); - return deletesDsIcon; - }); + tab.getTable().addGeneratedColumn( + DISCARD_CHANGES, + (source, itemId, columnId) -> { + final Button deletesDsIcon = SPUIComponentProvider.getButton("", "", SPUILabelDefinitions.DISCARD, + ValoTheme.BUTTON_TINY + " " + SPUIStyleDefinitions.REDICON, true, FontAwesome.REPLY, + SPUIButtonStyleSmallNoBorder.class); + deletesDsIcon.setData(itemId); + deletesDsIcon.setImmediate(true); + deletesDsIcon.addClickListener(event -> discardDSDelete( + (DistributionSetIdName) ((Button) event.getComponent()).getData(), itemId, tab)); + return deletesDsIcon; + }); /* set the visible columns */ final List visibleColumnIds = new ArrayList<>(); diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/DistributionTableFilters.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/DistributionTableFilters.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/ManagementUIState.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/ManagementUIState.java old mode 100755 new mode 100644 index 247dff29a..4c32f88a4 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/ManagementUIState.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/ManagementUIState.java @@ -85,6 +85,23 @@ public class ManagementUIState implements Serializable { private boolean customFilterSelected; + private boolean bulkUploadWindowMinimised; + + /** + * @return the bulkUploadWindowMinimised + */ + public boolean isBulkUploadWindowMinimised() { + return bulkUploadWindowMinimised; + } + + /** + * @param bulkUploadWindowMinimised + * the bulkUploadWindowMinimised to set + */ + public void setBulkUploadWindowMinimised(final boolean bulkUploadWindowMinimised) { + this.bulkUploadWindowMinimised = bulkUploadWindowMinimised; + } + /** * @return the isCustomFilterSelected */ diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetBulkUpload.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetBulkUpload.java new file mode 100644 index 000000000..d69f91b64 --- /dev/null +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetBulkUpload.java @@ -0,0 +1,128 @@ +/** + * 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.ui.management.state; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.hawkbit.repository.model.DistributionSetIdName; + +/** + * Hold details for target bulk upload window. + * + */ +public class TargetBulkUpload implements Serializable { + + private static final long serialVersionUID = -7697723122460382323L; + + private DistributionSetIdName dsNameAndVersion; + + private String description; + + private long sucessfulUploadCount; + + private long failedUploadCount; + + private float progressBarCurrentValue; + + private final List assignedTagNames = new ArrayList<>(); + + private final List targetsCreated = new ArrayList<>(); + + /** + * @return the targetsCreated + */ + public List getTargetsCreated() { + return targetsCreated; + } + + /** + * @return the assignedTagIds + */ + public List getAssignedTagNames() { + return assignedTagNames; + } + + /** + * @return the dsNameAndVersion + */ + public DistributionSetIdName getDsNameAndVersion() { + return dsNameAndVersion; + } + + /** + * @return the progressBarCurrentValue + */ + public float getProgressBarCurrentValue() { + return progressBarCurrentValue; + } + + /** + * @param progressBarCurrentValue + * the progressBarCurrentValue to set + */ + public void setProgressBarCurrentValue(final float progressBarCurrentValue) { + this.progressBarCurrentValue = progressBarCurrentValue; + } + + /** + * @param dsNameAndVersion + * the dsNameAndVersion to set + */ + public void setDsNameAndVersion(final DistributionSetIdName dsNameAndVersion) { + this.dsNameAndVersion = dsNameAndVersion; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description + * the description to set + */ + public void setDescription(final String description) { + this.description = description; + } + + /** + * @return the sucessfulUploadCount + */ + public long getSucessfulUploadCount() { + return sucessfulUploadCount; + } + + /** + * @param sucessfulUploadCount + * the sucessfulUploadCount to set + */ + public void setSucessfulUploadCount(final long sucessfulUploadCount) { + this.sucessfulUploadCount = sucessfulUploadCount; + } + + /** + * @return the failedUploadCount + */ + public long getFailedUploadCount() { + return failedUploadCount; + } + + /** + * @param failedUploadCount + * the failedUploadCount to set + */ + public void setFailedUploadCount(final long failedUploadCount) { + this.failedUploadCount = failedUploadCount; + } + +} diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetFilterParameters.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetFilterParameters.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetTableFilters.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetTableFilters.java old mode 100755 new mode 100644 index cdd8bbd55..1e65caba9 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetTableFilters.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/state/TargetTableFilters.java @@ -37,15 +37,57 @@ public class TargetTableFilters implements Serializable { private String searchText; private DistributionSetIdName distributionSet; private Long pinnedDistId; + private Long targetsCreatedCount; + private Float progressBarCurrentValue; + + private final TargetBulkUpload bulkUpload = new TargetBulkUpload(); + /** * Custom target filter query use dto filter target table. */ private TargetFilterQuery targetFilterQuery; - /* + /** * Flag for NO TAG button status. */ private Boolean noTagSelected = Boolean.FALSE; + /** + * @return the bulkUpload + */ + public TargetBulkUpload getBulkUpload() { + return bulkUpload; + } + + /** + * @return the progressBarCurrentValue + */ + public Optional getProgressBarCurrentValue() { + return progressBarCurrentValue != null ? Optional.of(progressBarCurrentValue) : Optional.empty(); + } + + /** + * @param progressBarCurrentValue + * the progressBarCurrentValue to set + */ + public void setProgressBarCurrentValue(final Float progressBarCurrentValue) { + this.progressBarCurrentValue = progressBarCurrentValue; + } + + /** + * @return the targetsCreatedCount + */ + public Optional getTargetsCreatedCount() { + return targetsCreatedCount != null ? Optional.of(targetsCreatedCount) : Optional.empty(); + } + + /** + * @param targetsCreatedCount + * the targetsCreatedCount to set + */ + public void setTargetsCreatedCount(final Long targetsCreatedCount) { + this.targetsCreatedCount = targetsCreatedCount; + } + public void setNoTagSelected(final Boolean noTagSelected) { this.noTagSelected = noTagSelected; } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java old mode 100755 new mode 100644 index 5922d564d..b360757cb --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/CreateUpdateTagLayout.java @@ -11,6 +11,9 @@ package org.eclipse.hawkbit.ui.management.tag; import java.util.HashSet; import java.util.Set; +import javax.annotation.PreDestroy; + +import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.model.DistributionSetTag; import org.eclipse.hawkbit.repository.model.TargetTag; @@ -26,6 +29,7 @@ import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.vaadin.spring.events.EventBus; import com.vaadin.data.Property.ValueChangeEvent; import com.vaadin.data.Property.ValueChangeListener; @@ -71,10 +75,16 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C protected String updateTagNw; @Autowired - private I18N i18n; + protected I18N i18n; @Autowired - private TagManagement tagManagement; + protected TagManagement tagManagement; + + @Autowired + protected transient EventBus.SessionEventBus eventBus; + + @Autowired + protected SpPermissionChecker permChecker; /** * Local Instance of ColorPickerPreview. */ @@ -138,10 +148,19 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C protected abstract void setTagDetails(final String tagSelected); - protected void init() { + /** + * Init the layout. + */ + public void init() { createRequiredComponents(); addListeners(); buildLayout(); + eventBus.subscribe(this); + } + + @PreDestroy + void destroy() { + eventBus.unsubscribe(this); } private void createRequiredComponents() { @@ -269,16 +288,15 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C if (null != selectedOption && selectedOption.equalsIgnoreCase(updateTagNw)) { if (null != tagNameComboBox.getValue()) { - final TargetTag targetTagSelected = tagManagement - .findTargetTag(tagNameComboBox.getValue().toString()); + final TargetTag targetTagSelected = tagManagement.findTargetTag(tagNameComboBox.getValue() + .toString()); if (null != targetTagSelected) { - selectedColor = targetTagSelected.getColour() != null - ? rgbToColorConverter(targetTagSelected.getColour()) - : rgbToColorConverter(DEFAULT_COLOR); + selectedColor = targetTagSelected.getColour() != null ? rgbToColorConverter(targetTagSelected + .getColour()) : rgbToColorConverter(DEFAULT_COLOR); } else { - final DistributionSetTag distTag = tagManagement - .findDistributionSetTag(tagNameComboBox.getValue().toString()); + final DistributionSetTag distTag = tagManagement.findDistributionSetTag(tagNameComboBox + .getValue().toString()); selectedColor = distTag.getColour() != null ? rgbToColorConverter(distTag.getColour()) : rgbToColorConverter(DEFAULT_COLOR); } @@ -452,8 +470,9 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C final double greenColorValue = color.getGreen(); greenSlider.setValue(new Double(greenColorValue)); } catch (final ValueOutOfBoundsException e) { - LOG.error("Unable to set RGB color value to " + color.getRed() + "," + color.getGreen() + "," - + color.getBlue(), e); + LOG.error( + "Unable to set RGB color value to " + color.getRed() + "," + color.getGreen() + "," + + color.getBlue(), e); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/ProxyTag.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/ProxyTag.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/SpColorPickerPreview.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/SpColorPickerPreview.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/TagIdName.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/tag/TagIdName.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java old mode 100755 new mode 100644 index 530882a86..be026f1bb --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/BulkUploadHandler.java @@ -19,27 +19,30 @@ import java.io.OutputStream; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.concurrent.Executor; -import java.util.stream.Collectors; import org.eclipse.hawkbit.repository.DeploymentManagement; +import org.eclipse.hawkbit.repository.DistributionSetManagement; +import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.Action.ActionType; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.repository.model.Target; -import org.eclipse.hawkbit.repository.model.TargetIdName; +import org.eclipse.hawkbit.ui.common.tagdetails.AbstractTagToken.TagData; +import org.eclipse.hawkbit.ui.management.event.BulkUploadValidationMessageEvent; +import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; +import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; +import org.eclipse.hawkbit.ui.management.state.TargetBulkUpload; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.UINotification; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.vaadin.spring.events.EventBus; import com.vaadin.ui.Alignment; import com.vaadin.ui.ComboBox; @@ -52,6 +55,8 @@ import com.vaadin.ui.Upload; import com.vaadin.ui.Upload.FailedEvent; import com.vaadin.ui.Upload.FailedListener; import com.vaadin.ui.Upload.Receiver; +import com.vaadin.ui.Upload.StartedEvent; +import com.vaadin.ui.Upload.StartedListener; import com.vaadin.ui.Upload.SucceededEvent; import com.vaadin.ui.Upload.SucceededListener; @@ -61,23 +66,29 @@ import com.vaadin.ui.Upload.SucceededListener; * * */ -public class BulkUploadHandler extends CustomComponent implements SucceededListener, FailedListener, Receiver { +public class BulkUploadHandler extends CustomComponent implements SucceededListener, FailedListener, Receiver, + StartedListener { /** - * - */ + * * + */ private static final long serialVersionUID = -1273494705754674501L; private static final Logger LOG = LoggerFactory.getLogger(BulkUploadHandler.class); private final transient TargetManagement targetManagement; + private final transient TagManagement tagManagement; private final ComboBox comboBox; private final TextArea descTextArea; private final I18N i18n; private final transient DeploymentManagement deploymentManagement; + private final transient DistributionSetManagement distributionSetManagement; + private final UINotification uINotification; protected File tempFile = null; + private Upload upload; + private final ProgressBar progressBar; private final ManagementUIState managementUIState; private final TargetBulkTokenTags targetBulkTokenTags; @@ -85,9 +96,11 @@ public class BulkUploadHandler extends CustomComponent implements SucceededListe private final Label targetsCountLabel; private long failedTargetCount = 0; private long successfullTargetCount = 0; - private final Set targetIdNames = new HashSet<>(); private final transient Executor executor; + private transient EventBus.SessionEventBus eventBus; + + final TargetBulkUpdateWindowLayout targetBulkUpdateWindowLayout; /** * @@ -101,6 +114,7 @@ public class BulkUploadHandler extends CustomComponent implements SucceededListe public BulkUploadHandler(final TargetBulkUpdateWindowLayout targetBulkUpdateWindowLayout, final TargetManagement targetManagement, final ManagementUIState managementUIState, final DeploymentManagement deploymentManagement, final UINotification uINotification, final I18N i18n) { + this.targetBulkUpdateWindowLayout = targetBulkUpdateWindowLayout; this.comboBox = targetBulkUpdateWindowLayout.getDsNamecomboBox(); this.descTextArea = targetBulkUpdateWindowLayout.getDescTextArea(); this.targetManagement = targetManagement; @@ -112,6 +126,9 @@ public class BulkUploadHandler extends CustomComponent implements SucceededListe this.targetBulkTokenTags = targetBulkUpdateWindowLayout.getTargetBulkTokenTags(); this.i18n = i18n; executor = (Executor) SpringContextHelper.getBean("uiExecutor"); + this.eventBus = targetBulkUpdateWindowLayout.getEventBus(); + distributionSetManagement = SpringContextHelper.getBean(DistributionSetManagement.class); + tagManagement = SpringContextHelper.getBean(TagManagement.class); } /** @@ -119,13 +136,15 @@ public class BulkUploadHandler extends CustomComponent implements SucceededListe */ public void buildLayout() { final HorizontalLayout horizontalLayout = new HorizontalLayout(); - final Upload upload = new Upload(); + upload = new Upload(); + upload.setEnabled(false); upload.setButtonCaption("Bulk Upload"); upload.setReceiver(this); upload.setImmediate(true); upload.setWidthUndefined(); upload.addSucceededListener(this); upload.addFailedListener(this); + upload.addStartedListener(this); horizontalLayout.addComponent(upload); horizontalLayout.setComponentAlignment(upload, Alignment.BOTTOM_RIGHT); setCompositionRoot(horizontalLayout); @@ -139,19 +158,15 @@ public class BulkUploadHandler extends CustomComponent implements SucceededListe */ @Override public OutputStream receiveUpload(final String filename, final String mimeType) { - if (!filename.endsWith(".csv")) { - uINotification.displayError(i18n.get("bulk.targets.upload"), null, true); - } else { - try { - tempFile = File.createTempFile("temp", ".csv"); - progressBar.setVisible(false); - targetsCountLabel.setVisible(false); - return new FileOutputStream(tempFile); - } catch (final FileNotFoundException e) { - LOG.error("File was not found with file name {}", filename, e); - } catch (final IOException e) { - LOG.error("Error while reading file {}", filename, e); - } + try { + tempFile = File.createTempFile("temp", ".csv"); + progressBar.setVisible(false); + targetsCountLabel.setVisible(false); + return new FileOutputStream(tempFile); + } catch (final FileNotFoundException e) { + LOG.error("File was not found with file name {}", filename, e); + } catch (final IOException e) { + LOG.error("Error while reading file {}", filename, e); } return new NullOutputStream(); } @@ -198,26 +213,25 @@ public class BulkUploadHandler extends CustomComponent implements SucceededListe String line; if (tempFile != null) { try { - LOG.info("Charset {}", Charset.defaultCharset()); + LOG.info("Bulk file upload started"); final double totalFileSize = getTotalNumberOfLines(); reader = new BufferedReader(new InputStreamReader(new FileInputStream(tempFile), Charset.defaultCharset())); + /** + * Once control is in upload succeeded method automatically + * upload button is re-enabled. To disable the button firing + * below event. + */ + eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_PROCESS_STARTED)); while ((line = reader.readLine()) != null) { innerCounter++; - readEachLine(event, line, innerCounter, totalFileSize); + readEachLine(line, innerCounter, totalFileSize); } - if (!targetIdNames.isEmpty()) { - saveAllAssignments(); - assignTag(); - } - String targetCountLabel = ""; - if (successfullTargetCount != 0 || failedTargetCount != 0) { - targetCountLabel = new StringBuilder().append("Successful :").append(successfullTargetCount) - .append(" Failed :").append(failedTargetCount).append("") - .toString(); - } - final String count = targetCountLabel; - event.getComponent().getUI().access(() -> displayCount(count)); + doAssignments(); + eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_UPLOAD_COMPLETED)); + + // Clearing after assignments are done + managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated().clear(); } catch (final FileNotFoundException e) { LOG.error("File not found with name {}", tempFile.getName(), e); } catch (final IOException e) { @@ -237,6 +251,59 @@ public class BulkUploadHandler extends CustomComponent implements SucceededListe } + private void doAssignments() { + final StringBuilder errorMessage = new StringBuilder(); + String dsAssignmentFailedMsg = null; + String tagAssignmentFailedMsg = null; + if (ifTargetsCreatedSuccessfully()) { + if (ifTagsSelected()) { + tagAssignmentFailedMsg = tagAssignment(); + } + if (ifDsSelected()) { + dsAssignmentFailedMsg = saveAllAssignments(); + } + } + displayValidationMessage(errorMessage, dsAssignmentFailedMsg, tagAssignmentFailedMsg); + } + + private boolean ifTagsSelected() { + return targetBulkTokenTags.getTokenField().getValue() != null; + } + + /** + * @return + */ + private boolean ifDsSelected() { + return comboBox.getValue() != null; + } + + /** + * @return + */ + private boolean ifTargetsCreatedSuccessfully() { + return !managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated().isEmpty(); + } + + /** + * @param errorMessage + * @param dsAssignmentFailedMsg + * @param tagAssignmentFailedMsg + */ + private void displayValidationMessage(final StringBuilder errorMessage, final String dsAssignmentFailedMsg, + final String tagAssignmentFailedMsg) { + if (dsAssignmentFailedMsg != null) { + errorMessage.append(dsAssignmentFailedMsg); + } + if (errorMessage.length() > 0) { + errorMessage.append("
"); + } + if (tagAssignmentFailedMsg != null) { + errorMessage.append(tagAssignmentFailedMsg); + } + if (errorMessage.length() > 0) { + eventBus.publish(this, new BulkUploadValidationMessageEvent(errorMessage.toString())); + } + } } private double getTotalNumberOfLines() { @@ -276,41 +343,24 @@ public class BulkUploadHandler extends CustomComponent implements SucceededListe tempFile = null; } - private void readEachLine(final SucceededEvent event, final String line, final double innerCounter, - final double totalFileSize) { + private void readEachLine(final String line, final double innerCounter, final double totalFileSize) { final String csvDelimiter = ","; final String[] targets = line.split(csvDelimiter); if (targets.length == 2) { final String controllerId = targets[0]; final String targetName = targets[1]; addNewTarget(controllerId, targetName); - final float current = progressBar.getValue(); - final float next = (float) (innerCounter / totalFileSize); - if (Math.abs(next - 0.1) < 0.00001 || current - next >= 0 || next - current >= 0.3 - || Math.abs(next - 1) < 0.00001) { - event.getComponent().getUI().access(() -> updateProgressBar(next)); - } } else { failedTargetCount++; } - - } - - private void displayCount(final String targetCountLabel) { - targetsCountLabel.setVisible(true); - targetsCountLabel.setCaptionAsHtml(true); - targetsCountLabel.setCaption(targetCountLabel); - } - - void updateProgressBar(final float value) { - progressBar.setVisible(true); - progressBar.setValue(value); - progressBar.getUI().push(); - } - - private void assignTag() { - if (targetBulkTokenTags.getTokenField().getValue() != null) { - tagAssignment(); + final float current = managementUIState.getTargetTableFilters().getBulkUpload().getProgressBarCurrentValue(); + final float next = (float) (innerCounter / totalFileSize); + if (Math.abs(next - 0.1) < 0.00001 || current - next >= 0 || next - current >= 0.05 + || Math.abs(next - 1) < 0.00001) { + managementUIState.getTargetTableFilters().getBulkUpload().setProgressBarCurrentValue(next); + managementUIState.getTargetTableFilters().getBulkUpload().setSucessfulUploadCount(successfullTargetCount); + managementUIState.getTargetTableFilters().getBulkUpload().setFailedUploadCount(failedTargetCount); + eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_CREATED)); } } @@ -321,23 +371,15 @@ public class BulkUploadHandler extends CustomComponent implements SucceededListe final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue()); /* create new target entity */ - Target newTarget = new Target(newControllerId); + final Target newTarget = new Target(newControllerId); setTargetValues(newTarget, newName, newDesc); - newTarget = targetManagement.createTarget(newTarget); - if (comboBox.getValue() != null) { - dsToTargetAssignment(newTarget.getTargetIdName()); - } - targetIdNames.add(newTarget.getTargetIdName()); + targetManagement.createTarget(newTarget); + managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated().add(newControllerId); successfullTargetCount++; } } - private void dsToTargetAssignment(final TargetIdName targetId) { - managementUIState.getAssignedList().put(targetId, (DistributionSetIdName) comboBox.getValue()); - - } - private void setTargetValues(final Target target, final String name, final String description) { if (null == name) { target.setName(target.getControllerId()); @@ -367,44 +409,40 @@ public class BulkUploadHandler extends CustomComponent implements SucceededListe } } - private void saveAllAssignments() { - final Set itemIds = managementUIState.getAssignedList().keySet(); - Long distId; - List targetIdSetList; - List tempIdList; - - final long forcedTimeStamp = new Date().getTime(); + private String saveAllAssignments() { final ActionType actionType = ActionType.FORCED; - - final Map> saveAssignedList = new HashMap<>(); - for (final TargetIdName itemId : itemIds) { - final DistributionSetIdName distitem = managementUIState.getAssignedList().get(itemId); - distId = distitem.getId(); - - if (saveAssignedList.containsKey(distId)) { - targetIdSetList = saveAssignedList.get(distId); - } else { - targetIdSetList = new ArrayList<>(); - } - targetIdSetList.add(itemId); - saveAssignedList.put(distId, (ArrayList) targetIdSetList); + final long forcedTimeStamp = new Date().getTime(); + final TargetBulkUpload targetBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload(); + final List targetsList = targetBulkUpload.getTargetsCreated(); + final DistributionSetIdName dsSelected = (DistributionSetIdName) comboBox.getValue(); + if (distributionSetManagement.findDistributionSetById(dsSelected.getId()) == null) { + return i18n.get("message.bulk.upload.assignment.failed"); + } else { + deploymentManagement.assignDistributionSet(targetBulkUpload.getDsNameAndVersion().getId(), actionType, + forcedTimeStamp, targetsList.toArray(new String[targetsList.size()])); + return null; } - - for (final Map.Entry> mapEntry : saveAssignedList.entrySet()) { - tempIdList = saveAssignedList.get(mapEntry.getKey()); - final String[] ids = tempIdList.stream().map(t -> t.getControllerId()).toArray(size -> new String[size]); - deploymentManagement.assignDistributionSet(mapEntry.getKey(), actionType, forcedTimeStamp, ids); - } - - managementUIState.getAssignedList().clear(); } - private void tagAssignment() { - final Set targetList = new HashSet<>(); - targetList.addAll(targetIdNames.stream().map(t -> t.getControllerId()).collect(Collectors.toList())); - for (final String tagName : targetBulkTokenTags.getAssignedTagNames()) { - targetManagement.toggleTagAssignment(targetList, tagName); + private String tagAssignment() { + final Map tokensSelected = targetBulkTokenTags.getTokensAdded(); + final List deletedTags = new ArrayList<>(); + for (final TagData tagData : tokensSelected.values()) { + if (tagManagement.findTargetTagById(tagData.getId()) == null) { + deletedTags.add(tagData.getName()); + } else { + targetManagement.toggleTagAssignment(managementUIState.getTargetTableFilters().getBulkUpload() + .getTargetsCreated(), tagData.getName()); + } } + if (!deletedTags.isEmpty()) { + if (deletedTags.size() == 1) { + return i18n.get("message.bulk.upload.tag.assignment.failed", deletedTags.get(0)); + } else { + return i18n.get("message.bulk.upload.tag.assignments.failed"); + } + } + return null; } private static class NullOutputStream extends OutputStream { @@ -420,4 +458,28 @@ public class BulkUploadHandler extends CustomComponent implements SucceededListe } } + /** + * @return the upload + */ + public Upload getUpload() { + return upload; + } + + /* + * (non-Javadoc) + * + * @see + * com.vaadin.ui.Upload.StartedListener#uploadStarted(com.vaadin.ui.Upload + * .StartedEvent) + */ + @Override + public void uploadStarted(final StartedEvent event) { + if (!event.getFilename().endsWith(".csv")) { + uINotification.displayError(i18n.get("bulk.targets.upload"), null, true); + LOG.error("Wrong file format for file {}", event.getFilename()); + upload.interruptUpload(); + } else { + eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.BULK_TARGET_UPLOAD_STARTED)); + } + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java old mode 100755 new mode 100644 index 9b42ef1e2..48f0ad2bf --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java @@ -8,8 +8,12 @@ */ package org.eclipse.hawkbit.ui.management.targettable; +import java.util.HashSet; +import java.util.Set; + import org.eclipse.hawkbit.repository.TargetManagement; import org.eclipse.hawkbit.repository.model.Target; +import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.management.event.DragEvent; @@ -21,6 +25,7 @@ import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions; +import org.eclipse.hawkbit.ui.utils.SpringContextHelper; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.spring.events.EventBus; @@ -244,20 +249,19 @@ public class TargetAddUpdateWindowLayout extends CustomComponent { setTargetValues(newTarget, newName, newDesc); /* save new target */ newTarget = targetManagement.createTarget(newTarget); + final TargetTable targetTable = SpringContextHelper.getBean(TargetTable.class); + final Set s = new HashSet<>(); + s.add(newTarget.getTargetIdName()); + targetTable.setValue(s); + /* display success msg */ uINotification.displaySuccess(i18n.get("message.save.success", new Object[] { newTarget.getName() })); - // publishing through event bus - // eventBus.publish( this, new TargetAddUpdateWindowEvent( - // TargetComponentEvent.ADD_TARGET, - // newTarget ) ); /* close the window */ closeThisWindow(); } - } public Window getWindow() { - eventBus.publish(this, DragEvent.HIDE_DROP_HINT); addTargetWindow = SPUIComponentProvider.getWindow(i18n.get("caption.add.new.target"), null, SPUIDefinitions.CREATE_UPDATE_WINDOW); @@ -276,9 +280,7 @@ public class TargetAddUpdateWindowLayout extends CustomComponent { controllerIDTextField.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_ERROR); controllerIDTextField.clear(); descTextArea.clear(); - descTextArea.clear(); editTarget = Boolean.FALSE; - } private void closeThisWindow() { @@ -316,13 +318,13 @@ public class TargetAddUpdateWindowLayout extends CustomComponent { * @param controllerId */ public void populateValuesOfTarget(final String controllerId) { + resetComponents(); this.controllerId = controllerId; editTarget = Boolean.TRUE; final Target target = targetManagement.findTargetByControllerID(controllerId); controllerIDTextField.setValue(target.getControllerId()); controllerIDTextField.setReadOnly(Boolean.TRUE); nameTextField.setValue(target.getName()); - if (target.getDescription() != null) { descTextArea.setValue(target.getDescription()); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java old mode 100755 new mode 100644 index 4047ec442..226b0c27c --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBeanQuery.java @@ -46,7 +46,7 @@ import com.google.common.base.Strings; */ public class TargetBeanQuery extends AbstractBeanQuery { private static final long serialVersionUID = -5645680058303167558L; - private Sort sort = new Sort(Direction.ASC, "createdAt"); + private Sort sort = new Sort(SPUIDefinitions.TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt"); private Collection status = null; private String[] targetTags = null; private Long distributionId = null; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkTokenTags.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkTokenTags.java old mode 100755 new mode 100644 index 070ab31e4..1587951dd --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkTokenTags.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkTokenTags.java @@ -8,66 +8,22 @@ */ package org.eclipse.hawkbit.ui.management.targettable; -import java.util.ArrayList; -import java.util.List; +import java.util.Map; -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; - -import org.eclipse.hawkbit.repository.SpPermissionChecker; -import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.model.TargetTag; -import org.eclipse.hawkbit.ui.common.tagdetails.AbstractTagToken; -import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; -import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent; -import org.eclipse.hawkbit.ui.management.event.TargetTagEvent; -import org.eclipse.hawkbit.ui.utils.I18N; -import org.springframework.beans.factory.annotation.Autowired; -import org.vaadin.spring.events.EventBus; -import org.vaadin.spring.events.EventScope; -import org.vaadin.spring.events.annotation.EventBusListenerMethod; +import org.eclipse.hawkbit.ui.common.tagdetails.AbstractTargetTagToken; import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.ViewScope; -import com.vaadin.ui.UI; /** * Target tag layout in bulk upload popup. - * - * - * * */ @SpringComponent @ViewScope -public class TargetBulkTokenTags extends AbstractTagToken { - - /** - * - */ +public class TargetBulkTokenTags extends AbstractTargetTagToken { private static final long serialVersionUID = 4159616629565523717L; - @Autowired - private transient EventBus.SessionEventBus eventBus; - - @Autowired - private I18N i18n; - - @Autowired - private transient TagManagement tagManagement; - - @Autowired - private SpPermissionChecker checker; - - private UI ui; - - private final List assignedTagNames = new ArrayList<>(); - - @PostConstruct - protected void init() { - super.init(); - ui = UI.getCurrent(); - eventBus.subscribe(this); - } /* * (non-Javadoc) @@ -77,7 +33,8 @@ public class TargetBulkTokenTags extends AbstractTagToken { */ @Override protected void assignTag(final String tagNameSelected) { - assignedTagNames.add(tagNameSelected); + managementUIState.getTargetTableFilters().getBulkUpload().getAssignedTagNames().add(tagNameSelected); + } /* @@ -88,12 +45,7 @@ public class TargetBulkTokenTags extends AbstractTagToken { */ @Override protected void unassignTag(final String tagName) { - assignedTagNames.remove(tagName); - } - - @PreDestroy - void destroy() { - eventBus.unsubscribe(this); + managementUIState.getTargetTableFilters().getBulkUpload().getAssignedTagNames().remove(tagName); } /* @@ -123,50 +75,16 @@ public class TargetBulkTokenTags extends AbstractTagToken { return checker.hasCreateTargetPermission(); } - @EventBusListenerMethod(scope = EventScope.SESSION) - void onEvent(final TargetTableEvent targetTableEvent) { - if (targetTableEvent.getTargetComponentEvent() == TargetComponentEvent.SELECTED_TARGET - && targetTableEvent.getTarget() != null) { - ui.access(() -> - /** - * targetTableEvent.getTarget() is null when table has no data. - */ - repopulateToken()); - } - } - - @EventBusListenerMethod(scope = EventScope.SESSION) - void onEvent(final TargetTagEvent event) { - ui.access(() -> { - if (event.getTargetTagComponentEvent() == TargetTagEvent.TargetTagComponentEvent.ADD_TARGETTAG) { - setContainerPropertValues(event.getTargetTag().getId(), event.getTargetTag().getName(), event - .getTargetTag().getColour()); - } else if (event.getTargetTagComponentEvent() == TargetTagEvent.TargetTagComponentEvent.DELETE_TARGETTAG) { - final Long deletedTagId = getTagIdByTagName(event.getTargetTagName()); - removeTagFromCombo(deletedTagId); - } else if (event.getTargetTagComponentEvent() == TargetTagEvent.TargetTagComponentEvent.ASSIGNED) { - final Long newlyAssignedTagId = getTagIdByTagName(event.getTargetTagName()); - addNewToken(newlyAssignedTagId); - } else if (event.getTargetTagComponentEvent() == TargetTagEvent.TargetTagComponentEvent.UNASSIGNED) { - final Long newlyUnAssignedTagId = getTagIdByTagName(event.getTargetTagName()); - removeTokenItem(newlyUnAssignedTagId, event.getTargetTagName()); - } - }); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.hawkbit.server.ui.common.tagdetails.AbstractTagToken# - * displayAlreadyAssignedTags() - */ @Override - protected void displayAlreadyAssignedTags() { - container.removeAllItems(); - for (final TargetTag tag : tagManagement.findAllTargetTags()) { - setContainerPropertValues(tag.getId(), tag.getName(), tag.getColour()); - } + public void displayAlreadyAssignedTags() { + removePreviouslyAddedTokens(); + addAlreadySelectedTags(); + } + protected void addAlreadySelectedTags() { + for (final String tagName : managementUIState.getTargetTableFilters().getBulkUpload().getAssignedTagNames()) { + addNewToken(tagManagement.findTargetTag(tagName).getId()); + } } /* @@ -184,10 +102,7 @@ public class TargetBulkTokenTags extends AbstractTagToken { } - /** - * @return the assignedTagNames - */ - public List getAssignedTagNames() { - return assignedTagNames; + public Map getTokensAdded() { + return tokensAdded; } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java old mode 100755 new mode 100644 index 7716da871..abf552cb0 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetBulkUpdateWindowLayout.java @@ -13,12 +13,18 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import javax.annotation.PreDestroy; + import org.eclipse.hawkbit.repository.DeploymentManagement; import org.eclipse.hawkbit.repository.TargetManagement; +import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; +import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; import org.eclipse.hawkbit.ui.documentation.DocumentationPageLink; import org.eclipse.hawkbit.ui.management.dstable.DistributionBeanQuery; +import org.eclipse.hawkbit.ui.management.event.BulkUploadPopupEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; +import org.eclipse.hawkbit.ui.management.state.TargetBulkUpload; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider; @@ -30,13 +36,16 @@ import org.springframework.beans.factory.annotation.Autowired; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition; +import org.vaadin.spring.events.EventBus; import org.vaadin.tokenfield.TokenField; import com.vaadin.data.Container; +import com.vaadin.server.FontAwesome; import com.vaadin.shared.ui.combobox.FilteringMode; import com.vaadin.spring.annotation.SpringComponent; import com.vaadin.spring.annotation.ViewScope; import com.vaadin.ui.Alignment; +import com.vaadin.ui.Button; import com.vaadin.ui.ComboBox; import com.vaadin.ui.CustomComponent; import com.vaadin.ui.HorizontalLayout; @@ -46,8 +55,6 @@ import com.vaadin.ui.ProgressBar; import com.vaadin.ui.TextArea; import com.vaadin.ui.VerticalLayout; import com.vaadin.ui.Window; -import com.vaadin.ui.Window.CloseEvent; -import com.vaadin.ui.Window.CloseListener; import com.vaadin.ui.themes.ValoTheme; /** @@ -58,7 +65,7 @@ import com.vaadin.ui.themes.ValoTheme; */ @SpringComponent @ViewScope -public class TargetBulkUpdateWindowLayout extends CustomComponent implements CloseListener { +public class TargetBulkUpdateWindowLayout extends CustomComponent { @Autowired private I18N i18n; @@ -69,6 +76,9 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent implements Clo @Autowired private transient UINotification uINotification; + @Autowired + private transient EventBus.SessionEventBus eventBus; + @Autowired private TargetBulkTokenTags targetBulkTokenTags; @@ -87,6 +97,10 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent implements Clo private ProgressBar progressBar; private Label targetsCountLabel; private Link linkToSystemConfigHelp; + private Window bulkUploadWindow; + private Label windowCaption; + private Button minimizeButton; + private Button closeButton; /** * Initialize the Add Update Window Component for Target. @@ -94,55 +108,130 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent implements Clo public void init() { createRequiredComponents(); buildLayout(); + setImmediate(true); setCompositionRoot(mainLayout); + eventBus.subscribe(this); + } + + @PreDestroy + void destroy() { + eventBus.unsubscribe(this); + } + + protected void onStartOfUpload() { + final TargetBulkUpload targetBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload(); + targetBulkUpload.setDsNameAndVersion((DistributionSetIdName) dsNamecomboBox.getValue()); + targetBulkUpload.setDescription(descTextArea.getValue()); + targetBulkUpload.setProgressBarCurrentValue(0F); + targetBulkUpload.setFailedUploadCount(0L); + targetBulkUpload.setSucessfulUploadCount(0L); + closeButton.setEnabled(false); + minimizeButton.setEnabled(true); + } + + protected void setProgressBarValue(final Float value) { + progressBar.setValue(value); + progressBar.setVisible(true); } - /** - * - */ private void createRequiredComponents() { - - final TokenField tokenField = targetBulkTokenTags.getTokenField(); - tokenVerticalLayout = SPUIComponentProvider.getDetailTabLayout(); - tokenVerticalLayout.addStyleName("bulk-target-tags-layout"); - tokenVerticalLayout.addComponent(tokenField); - tokenVerticalLayout.setSpacing(false); - tokenVerticalLayout.setMargin(false); - tokenVerticalLayout.setWidth("185px"); - tokenVerticalLayout.setHeight("100px"); - tokenVerticalLayout.setId(SPUIComponetIdProvider.BULK_UPLOAD_TAG); - - final Container container = createContainer(); - dsNamecomboBox = SPUIComponentProvider.getComboBox("", "", null, null, false, "", - i18n.get("bulkupload.ds.name")); - dsNamecomboBox.addStyleName(SPUIDefinitions.BULK_UPLOD_DS_COMBO_STYLE); - dsNamecomboBox.setImmediate(true); - dsNamecomboBox.setFilteringMode(FilteringMode.STARTSWITH); - dsNamecomboBox.setPageLength(7); - dsNamecomboBox.setContainerDataSource(container); - dsNamecomboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME); - dsNamecomboBox.setId(SPUIComponetIdProvider.BULK_UPLOAD_DS_COMBO); - - descTextArea = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTFIELD_TINY, false, null, - i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH); - descTextArea.setId(SPUIComponetIdProvider.BULK_UPLOAD_DESC); - descTextArea.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY); - progressBar = new ProgressBar(0.5f); - progressBar.setWidth(185f, Unit.PIXELS); - progressBar.addStyleName("bulk-upload-label"); - - targetsCountLabel = new Label(); - targetsCountLabel.setImmediate(false); - targetsCountLabel.addStyleName("bulk-upload-label"); - targetsCountLabel.setVisible(false); - targetsCountLabel.setId(SPUIComponetIdProvider.BULK_UPLOAD_COUNT); - bulkUploader = new BulkUploadHandler(this, targetManagement, managementUIState, deploymentManagement, - uINotification, i18n); - bulkUploader.buildLayout(); - bulkUploader.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_BUTTON); - + tokenVerticalLayout = getTokenFieldLayout(); + dsNamecomboBox = getDsComboField(); + descTextArea = getDescriptionTextArea(); + progressBar = creatreProgressBar(); + targetsCountLabel = getStatusCountLabel(); + bulkUploader = getBulkUploadHandler(); linkToSystemConfigHelp = DocumentationPageLink.DEPLOYMENT_VIEW.getLink(); + windowCaption = new Label(i18n.get("caption.bulk.upload.targets")); + minimizeButton = getMinimizeButton(); + closeButton = getCloseButton(); + } + private ProgressBar creatreProgressBar() { + final ProgressBar progressBarIndicator = new ProgressBar(0F); + progressBarIndicator.addStyleName("bulk-upload-label"); + progressBarIndicator.setSizeFull(); + return progressBarIndicator; + } + + private Button getCloseButton() { + final Button closeBtn = SPUIComponentProvider.getButton(SPUIComponetIdProvider.BULK_UPLOAD_CLOSE_BUTTON_ID, "", + "", "", true, FontAwesome.TIMES, SPUIButtonStyleSmallNoBorder.class); + closeBtn.addStyleName(ValoTheme.BUTTON_BORDERLESS); + closeBtn.addClickListener(event -> closePopup()); + return closeBtn; + } + + private Button getMinimizeButton() { + final Button minimizeBtn = SPUIComponentProvider.getButton( + SPUIComponetIdProvider.BULK_UPLOAD_MINIMIZE_BUTTON_ID, "", "", "", true, FontAwesome.MINUS, + SPUIButtonStyleSmallNoBorder.class); + minimizeBtn.addStyleName(ValoTheme.BUTTON_BORDERLESS); + minimizeBtn.addClickListener(event -> minimizeWindow()); + minimizeBtn.setEnabled(false); + return minimizeBtn; + } + + private BulkUploadHandler getBulkUploadHandler() { + final BulkUploadHandler bulkUploadHandler = new BulkUploadHandler(this, targetManagement, managementUIState, + deploymentManagement, uINotification, i18n); + bulkUploadHandler.buildLayout(); + bulkUploadHandler.addStyleName(SPUIStyleDefinitions.BULK_UPLOAD_BUTTON); + return bulkUploadHandler; + } + + private Label getStatusCountLabel() { + final Label countLabel = new Label(); + countLabel.setImmediate(true); + countLabel.addStyleName("bulk-upload-label"); + countLabel.setVisible(false); + countLabel.setCaptionAsHtml(true); + countLabel.setId(SPUIComponetIdProvider.BULK_UPLOAD_COUNT); + return countLabel; + } + + private TextArea getDescriptionTextArea() { + final TextArea description = SPUIComponentProvider.getTextArea("text-area-style", ValoTheme.TEXTFIELD_TINY, + false, null, i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH); + description.setId(SPUIComponetIdProvider.BULK_UPLOAD_DESC); + description.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY); + description.setWidth("100%"); + return description; + } + + private ComboBox getDsComboField() { + final Container container = createContainer(); + final ComboBox dsComboBox = SPUIComponentProvider.getComboBox("", "", null, null, false, "", + i18n.get("bulkupload.ds.name")); + dsComboBox.setSizeUndefined(); + dsComboBox.addStyleName(SPUIDefinitions.BULK_UPLOD_DS_COMBO_STYLE); + dsComboBox.setImmediate(true); + dsComboBox.setFilteringMode(FilteringMode.STARTSWITH); + dsComboBox.setPageLength(7); + dsComboBox.setContainerDataSource(container); + dsComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME_VERSION); + dsComboBox.setId(SPUIComponetIdProvider.BULK_UPLOAD_DS_COMBO); + dsComboBox.setWidth("100%"); + return dsComboBox; + } + + private VerticalLayout getTokenFieldLayout() { + final TokenField tokenField = targetBulkTokenTags.getTokenField(); + final VerticalLayout tokenLayout = SPUIComponentProvider.getDetailTabLayout(); + tokenLayout.addStyleName("bulk-target-tags-layout"); + tokenLayout.addComponent(tokenField); + tokenLayout.setSpacing(false); + tokenLayout.setMargin(false); + tokenLayout.setSizeFull(); + tokenLayout.setHeight("100px"); + tokenLayout.setId(SPUIComponetIdProvider.BULK_UPLOAD_TAG); + return tokenLayout; + } + + private void closePopup() { + clearPreviousSessionData(); + bulkUploadWindow.close(); + eventBus.publish(this, BulkUploadPopupEvent.CLOSED); } /** @@ -165,7 +254,8 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent implements Clo DistributionBeanQuery.class); distributionQF.setQueryConfiguration(queryConfiguration); final LazyQueryContainer distributionContainer = new LazyQueryContainer(new LazyQueryDefinition(true, - Integer.MAX_VALUE, SPUILabelDefinitions.VAR_DIST_ID_NAME), distributionQF); + SPUIDefinitions.PAGE_SIZE, SPUILabelDefinitions.VAR_DIST_ID_NAME), distributionQF); + return distributionContainer; } @@ -174,14 +264,22 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent implements Clo mainLayout = new VerticalLayout(); mainLayout.setSpacing(Boolean.TRUE); mainLayout.setSizeUndefined(); + mainLayout.setWidth("200px"); + + final HorizontalLayout captionLayout = new HorizontalLayout(); + captionLayout.setSizeFull(); + captionLayout.addComponents(windowCaption, minimizeButton, closeButton); + captionLayout.setExpandRatio(windowCaption, 1.0F); + captionLayout.addStyleName("v-window-header"); + final HorizontalLayout uploaderLayout = new HorizontalLayout(); uploaderLayout.addComponent(bulkUploader); uploaderLayout.addComponent(linkToSystemConfigHelp); uploaderLayout.setComponentAlignment(linkToSystemConfigHelp, Alignment.BOTTOM_RIGHT); uploaderLayout.setExpandRatio(bulkUploader, 1.0F); uploaderLayout.setSizeFull(); - mainLayout.addComponents(dsNamecomboBox, descTextArea, tokenVerticalLayout, descTextArea, progressBar, - targetsCountLabel, uploaderLayout); + mainLayout.addComponents(captionLayout, dsNamecomboBox, descTextArea, tokenVerticalLayout, descTextArea, + progressBar, targetsCountLabel, uploaderLayout); } /** @@ -195,30 +293,85 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent implements Clo progressBar.setValue(0f); progressBar.setVisible(false); targetsCountLabel.setVisible(false); + } + private void clearPreviousSessionData() { + final TargetBulkUpload targetBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload(); + targetBulkUpload.setDescription(null); + targetBulkUpload.setDsNameAndVersion(null); + targetBulkUpload.setFailedUploadCount(0L); + targetBulkUpload.setSucessfulUploadCount(0L); + targetBulkUpload.getAssignedTagNames().clear(); + targetBulkUpload.getTargetsCreated().clear(); + } + + /** + * Restore the target bulk upload layout field values. + */ + public void restoreComponentsValue() { + targetBulkTokenTags.populateContainer(); + final TargetBulkUpload targetBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload(); + progressBar.setValue(targetBulkUpload.getProgressBarCurrentValue()); + dsNamecomboBox.setValue(targetBulkUpload.getDsNameAndVersion()); + descTextArea.setValue(targetBulkUpload.getDescription()); + targetBulkTokenTags.addAlreadySelectedTags(); + if (targetBulkUpload.getSucessfulUploadCount() > 0 || targetBulkUpload.getFailedUploadCount() > 0) { + targetsCountLabel.setVisible(true); + targetsCountLabel.setCaption(getFormattedCountLabelValue(targetBulkUpload.getSucessfulUploadCount(), + targetBulkUpload.getFailedUploadCount())); + } + if (targetBulkUpload.getProgressBarCurrentValue() < 1) { + bulkUploader.getUpload().setEnabled(false); + } + } + + /** + * Actions once bulk upload is completed. + */ + public void onUploadCompletion() { + final TargetBulkUpload targetBulkUpload = managementUIState.getTargetTableFilters().getBulkUpload(); + + final String targetCountLabel = getFormattedCountLabelValue(targetBulkUpload.getSucessfulUploadCount(), + targetBulkUpload.getFailedUploadCount()); + getTargetsCountLabel().setVisible(true); + getTargetsCountLabel().setCaption(targetCountLabel); + + getBulkUploader().getUpload().setEnabled(true); + + closeButton.setEnabled(true); + minimizeButton.setEnabled(false); + } + + private static String getFormattedCountLabelValue(final long succussfulUploadCount, final long failedUploadCount) { + return new StringBuilder().append("Successful :").append(succussfulUploadCount) + .append(" Failed :").append(failedUploadCount).append("").toString(); } /** * @return */ public Window getWindow() { - final Window bulkUploadWindow = SPUIComponentProvider.getWindow(i18n.get("caption.bulk.upload.targets"), null, - SPUIDefinitions.BULK_UPLOAD_WINDOW); + managementUIState.setBulkUploadWindowMinimised(false); + bulkUploadWindow = SPUIComponentProvider.getWindow("", null, SPUIDefinitions.CREATE_UPDATE_WINDOW); + bulkUploadWindow.addStyleName("bulk-upload-window"); + bulkUploadWindow.setImmediate(true); bulkUploadWindow.setContent(this); - bulkUploadWindow.addCloseListener(this); + if (isNoBulkUploadInProgress()) { + bulkUploader.getUpload().setEnabled(true); + } return bulkUploadWindow; } - /* - * (non-Javadoc) - * - * @see com.vaadin.ui.Window.CloseListener#windowClose(com.vaadin.ui.Window. - * CloseEvent) - */ - @Override - public void windowClose(final CloseEvent e) { - e.getWindow().close(); + private boolean isNoBulkUploadInProgress() { + final float progressBarCurrentValue = managementUIState.getTargetTableFilters().getBulkUpload() + .getProgressBarCurrentValue(); + return Math.abs(progressBarCurrentValue - 0) < 0.00001 || Math.abs(progressBarCurrentValue - 1) < 0.00001; + } + private void minimizeWindow() { + bulkUploadWindow.close(); + managementUIState.setBulkUploadWindowMinimised(true); + eventBus.publish(this, BulkUploadPopupEvent.MINIMIZED); } /** @@ -256,4 +409,18 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent implements Clo return targetsCountLabel; } + /** + * @return the eventBus + */ + public EventBus.SessionEventBus getEventBus() { + return eventBus; + } + + /** + * @return the bulkUploader + */ + public BulkUploadHandler getBulkUploader() { + return bulkUploader; + } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetDetails.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetDetails.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java old mode 100755 new mode 100644 index f718e7d40..59999a552 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTable.java @@ -9,10 +9,10 @@ package org.eclipse.hawkbit.ui.management.targettable; import java.util.ArrayList; -import java.util.Date; +import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -27,15 +27,17 @@ import org.eclipse.hawkbit.eventbus.event.TargetInfoUpdateEvent; import org.eclipse.hawkbit.repository.OffsetBasedPageRequest; import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.TargetManagement; -import org.eclipse.hawkbit.repository.TargetTagAssigmentResult; import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.repository.model.Target; +import org.eclipse.hawkbit.repository.model.TargetFilterQuery; import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.repository.model.TargetInfo; +import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult; import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; import org.eclipse.hawkbit.ui.common.table.AbstractTable; import org.eclipse.hawkbit.ui.filter.FilterExpression; import org.eclipse.hawkbit.ui.filter.Filters; +import org.eclipse.hawkbit.ui.filter.target.CustomTargetFilter; import org.eclipse.hawkbit.ui.filter.target.TargetSearchTextFilter; import org.eclipse.hawkbit.ui.filter.target.TargetStatusFilter; import org.eclipse.hawkbit.ui.filter.target.TargetTagFilter; @@ -48,8 +50,6 @@ import org.eclipse.hawkbit.ui.management.event.TargetAddUpdateWindowEvent; import org.eclipse.hawkbit.ui.management.event.TargetFilterEvent; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent; import org.eclipse.hawkbit.ui.management.event.TargetTableEvent.TargetComponentEvent; -import org.eclipse.hawkbit.ui.management.event.TargetTagEvent; -import org.eclipse.hawkbit.ui.management.event.TargetTagEvent.TargetTagComponentEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.state.TargetTableFilters; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; @@ -66,7 +66,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; -import org.springframework.data.domain.Sort.Direction; import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory; import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition; @@ -75,6 +74,7 @@ import org.vaadin.spring.events.EventScope; import org.vaadin.spring.events.annotation.EventBusListenerMethod; import com.google.common.base.Strings; +import com.google.common.collect.Iterables; import com.vaadin.data.Container; import com.vaadin.data.Item; import com.vaadin.event.Action; @@ -99,8 +99,6 @@ import com.vaadin.ui.themes.ValoTheme; /** * Concrete implementation of Target table. * - * - * */ @SpringComponent @ViewScope @@ -152,27 +150,27 @@ public class TargetTable extends AbstractTable implements Handler { setNoDataAvailable(); } + @PreDestroy + void destroy() { + eventBus.unsubscribe(this); + } + /** - * EventListener method which is called by the event bus to notify about a - * {@link TargetCreatedEvent}. + * EventListener method which is called when a list of events is published. + * Event types should not be mixed up. * - * @param targetCreatedEvent - * the target created event + * @param events + * list of events */ @EventBusListenerMethod(scope = EventScope.SESSION) - public void onEvent(final TargetCreatedEvent targetCreatedEvent) { - final Target createdTarget = targetCreatedEvent.getEntity(); - final TargetTableFilters targetTableFilters = managementUIState.getTargetTableFilters(); - final List filters = new ArrayList<>(); - if (targetTableFilters.getSearchText().isPresent()) { - filters.add(new TargetSearchTextFilter(createdTarget, targetTableFilters.getSearchText().get())); - } - filters.add(new TargetStatusFilter(createdTarget, targetTableFilters.getClickedStatusTargetTags())); - filters.add(new TargetTagFilter(createdTarget, targetTableFilters.getClickedTargetTags(), targetTableFilters - .isNoTagSelected())); - - if (!Filters.or(filters).doFilter()) { - addNewTarget(createdTarget); + public void onEvents(final List events) { + final Object firstEvent = events.get(0); + if (TargetCreatedEvent.class.isInstance(firstEvent)) { + onTargetCreatedEvents(); + } else if (TargetInfoUpdateEvent.class.isInstance(firstEvent)) { + onTargetInfoUpdateEvents((List) events); + } else if (TargetDeletedEvent.class.isInstance(firstEvent)) { + onTargetDeletedEvent((List) events); } } @@ -185,28 +183,6 @@ public class TargetTable extends AbstractTable implements Handler { } } - /** - * EventListener method which is called by the event bus to notify about a - * {@link TargetCreatedEvent}. - * - * @param event - * the target created event - */ - @EventBusListenerMethod(scope = EventScope.SESSION) - public void onEvent(final TargetDeletedEvent event) { - final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource(); - final TargetIdName targetIdName = new TargetIdName(event.getTargetId(), null, null); - if (getVisibleItemIds().contains(targetIdName)) { - targetContainer.removeItem(targetIdName); - targetContainer.commit(); - - } - if (managementUIState.getTargetsCountAll() > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) { - ((LazyQueryContainer) getContainerDataSource()).refresh(); - } - eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.DELETE_TARGET, targetIdName)); - } - @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final PinUnpinEvent pinUnpinEvent) { UI.getCurrent().access(() -> { @@ -222,11 +198,6 @@ public class TargetTable extends AbstractTable implements Handler { @EventBusListenerMethod(scope = EventScope.SESSION) void addOrEditEvent(final TargetAddUpdateWindowEvent targetUIEvent) { - if (targetUIEvent.getTargetComponentEvent() == TargetComponentEvent.ADD_TARGET) { - /** Below line to be removed when push is re-enable **/ - UI.getCurrent().access(() -> addNewTarget(targetUIEvent.getTarget())); - setData(SPUIDefinitions.DATA_AVAILABLE); - } if (targetUIEvent.getTargetComponentEvent() == TargetComponentEvent.EDIT_TARGET) { UI.getCurrent().access(() -> updateTarget(targetUIEvent.getTarget())); } @@ -237,10 +208,6 @@ public class TargetTable extends AbstractTable implements Handler { UI.getCurrent().access(() -> { if (checkFilterEvent(filterEvent)) { refreshFilter(); - /* - * TobeDone : remove explicit SHOW_COUNT_MESSAGE instead use - * TargetFilterEvent - */ eventBus.publish(this, ManagementUIEvent.TARGET_TABLE_FILTER); } }); @@ -260,13 +227,16 @@ public class TargetTable extends AbstractTable implements Handler { @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final SaveActionWindowEvent event) { if (event == SaveActionWindowEvent.SAVED_ASSIGNMENTS) { - refreshFilter(); - } - if (event == SaveActionWindowEvent.DELETED_TARGETS) { - eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.DELETE_TARGET, (Target) null)); + refreshTablecontainer(); } } + private void refreshTablecontainer() { + final LazyQueryContainer tableContainer = (LazyQueryContainer) getContainerDataSource(); + tableContainer.refresh(); + selectRow(); + } + @EventBusListenerMethod(scope = EventScope.SESSION) void onEvent(final TargetTableEvent event) { if (event.getTargetComponentEvent() == TargetComponentEvent.MINIMIZED) { @@ -313,31 +283,6 @@ public class TargetTable extends AbstractTable implements Handler { return targetTableContainer; } - private Map prepareQueryConfigFilters() { - final Map queryConfig = new HashMap(); - managementUIState.getTargetTableFilters().getSearchText() - .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value)); - managementUIState.getTargetTableFilters().getDistributionSet() - .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_DISTRIBUTION, value.getId())); - managementUIState.getTargetTableFilters().getPinnedDistId() - .ifPresent(value -> queryConfig.put(SPUIDefinitions.ORDER_BY_DISTRIBUTION, value)); - managementUIState.getTargetTableFilters().getTargetFilterQuery() - .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TARGET_FILTER_QUERY, value)); - queryConfig.put(SPUIDefinitions.FILTER_BY_NO_TAG, managementUIState.getTargetTableFilters().isNoTagSelected()); - - if (!managementUIState.getTargetTableFilters().getClickedTargetTags().isEmpty()) { - final List list = new ArrayList(); - list.addAll(managementUIState.getTargetTableFilters().getClickedTargetTags()); - queryConfig.put(SPUIDefinitions.FILTER_BY_TAG, list.toArray(new String[list.size()])); - } - if (!managementUIState.getTargetTableFilters().getClickedStatusTargetTags().isEmpty()) { - final List statusList = managementUIState.getTargetTableFilters() - .getClickedStatusTargetTags(); - queryConfig.put(SPUIDefinitions.FILTER_BY_STATUS, statusList); - } - return queryConfig; - } - /* * (non-Javadoc) * @@ -346,30 +291,23 @@ public class TargetTable extends AbstractTable implements Handler { */ @Override protected void addContainerProperties(final Container container) { - final LazyQueryContainer targetTableContainer = (LazyQueryContainer) container; - targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CONT_ID, String.class, "", false, false); - targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, true); - targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_TARGET_STATUS, TargetUpdateStatus.class, - TargetUpdateStatus.UNKNOWN, false, false); - targetTableContainer.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_ID, Long.class, null, - false, false); - targetTableContainer.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_ID, Long.class, null, - false, false); - targetTableContainer.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, - "", false, true); - targetTableContainer.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class, - "", false, true); - targetTableContainer.addContainerProperty(SPUILabelDefinitions.LAST_QUERY_DATE, Date.class, null, false, false); - targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_BY, String.class, null, false, true); - targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, - true); - targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false, - true); - targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, - false, true); - targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP, String.class, null, - false, true); - targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true); + HawkbitCommonUtil.addTargetTableContainerProperties(container); + } + + @Override + public Action[] getActions(final Object target, final Object sender) { + return new Action[] { actionSelectAll, actionUnSelectAll }; + } + + @Override + public void handleAction(final Action action, final Object sender, final Object target) { + if (actionSelectAll.equals(action)) { + selectAll(); + eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.SELLECT_ALL)); + } + if (actionUnSelectAll.equals(action)) { + unSelectAll(); + } } /* @@ -386,163 +324,6 @@ public class TargetTable extends AbstractTable implements Handler { (source, itemId, columnId) -> getTagetPollTime(itemId)); } - private Label getTagetPollTime(final Object itemId) { - final Label statusLabel = new Label(); - statusLabel.addStyleName(ValoTheme.LABEL_SMALL); - statusLabel.setHeightUndefined(); - statusLabel.setContentMode(ContentMode.HTML); - final String pollStatusToolTip = (String) getContainerDataSource().getItem(itemId) - .getItemProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP).getValue(); - if (HawkbitCommonUtil.trimAndNullIfEmpty(pollStatusToolTip) != null) { - statusLabel.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml()); - } else { - statusLabel.setValue(FontAwesome.CLOCK_O.getHtml()); - } - statusLabel.setDescription(pollStatusToolTip); - return statusLabel; - } - - private Button getTagetPinButton(final Object itemId) { - final Button pinBtn = new Button(); - final StringBuilder pinBtnStyle = new StringBuilder(ValoTheme.BUTTON_BORDERLESS_COLORED); - pinBtnStyle.append(' '); - pinBtnStyle.append(ValoTheme.BUTTON_SMALL); - pinBtnStyle.append(' '); - pinBtnStyle.append(ValoTheme.BUTTON_ICON_ONLY); - pinBtn.setStyleName(pinBtnStyle.toString()); - pinBtn.setHeightUndefined(); - pinBtn.setData(itemId); - pinBtn.setId(SPUIComponetIdProvider.TARGET_PIN_ICON + "." + itemId); - pinBtn.addClickListener(event -> addPinClickListener(event)); - if (isPinned(((TargetIdName) itemId).getControllerId())) { - stylePinnedButton(pinBtn); - isTargetPinned = Boolean.TRUE; - targetPinnedBtn = pinBtn; - eventBus.publish(this, PinUnpinEvent.PIN_TARGET); - } - pinBtn.addStyleName(SPUIStyleDefinitions.TARGET_STATUS_PIN_TOGGLE); - applyStatusLblStyle(pinBtn, itemId); - return pinBtn; - } - - private boolean isPinned(final String targetId) { - boolean result = false; - if (managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent() - && targetId.equals(managementUIState.getDistributionTableFilters().getPinnedTargetId().get())) { - result = true; - } else { - result = false; - } - return result; - } - - /** - * Add listener to pin. - * - * @param pinBtn - * as event - */ - private void addPinClickListener(final ClickEvent event) { - eventBus.publish(this, DragEvent.HIDE_DROP_HINT); - checkifAlreadyPinned(event.getButton()); - if (isTargetPinned) { - pinTarget(event.getButton()); - } else { - unPinTarget(event.getButton()); - } - - } - - /** - * Check already pinned. - * - * @param eventBtn - * as button - */ - private void checkifAlreadyPinned(final Button eventBtn) { - final String newPinnedTargetItemId = ((TargetIdName) eventBtn.getData()).getControllerId(); - String targetId = null; - if (managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()) { - targetId = managementUIState.getDistributionTableFilters().getPinnedTargetId().get(); - } - if (targetId == null) { - isTargetPinned = !isTargetPinned; - managementUIState.getDistributionTableFilters().setPinnedTargetId(newPinnedTargetItemId); - } else if (targetId.equals(newPinnedTargetItemId)) { - isTargetPinned = Boolean.FALSE; - } else { - isTargetPinned = true; - managementUIState.getDistributionTableFilters().setPinnedTargetId(newPinnedTargetItemId); - if (null != targetPinnedBtn) { - resetPinStyle(targetPinnedBtn); - } - } - targetPinnedBtn = eventBtn; - } - - private void pinTarget(final Button eventBtn) { - /* if distribution set is pinned ,unpin target if pinned */ - managementUIState.getTargetTableFilters().setPinnedDistId(null); - /* on unpin of target dist table should refresh Dist table restyle */ - eventBus.publish(this, PinUnpinEvent.PIN_TARGET); - /* change target table styling */ - styleTargetTable(); - stylePinnedButton(eventBtn); - isTargetPinned = Boolean.FALSE; - } - - private void unPinTarget(final Button eventBtn) { - managementUIState.getDistributionTableFilters().setPinnedTargetId(null); - eventBus.publish(this, PinUnpinEvent.UNPIN_TARGET); - resetPinStyle(eventBtn); - } - - private void resetPinStyle(final Button pinBtn) { - pinBtn.removeStyleName("targetPinned"); - pinBtn.addStyleName(SPUIStyleDefinitions.TARGET_STATUS_PIN_TOGGLE); - applyStatusLblStyle(pinBtn, pinBtn.getData()); - - } - - /** - * Set style of target table. - * - */ - @SuppressWarnings("serial") - private void styleTargetTable() { - setCellStyleGenerator((source, itemId, propertyId) -> null); - } - - private void stylePinnedButton(final Button eventBtn) { - eventBtn.addStyleName("targetPinned"); - } - - /** - * Status Label Style. - * - * @param pinBtn - * @param itemId - */ - private void applyStatusLblStyle(final Button pinBtn, final Object itemId) { - final Item item = getItem(itemId); - if (item != null) { - final TargetUpdateStatus updateStatus = (TargetUpdateStatus) item.getItemProperty( - SPUILabelDefinitions.VAR_TARGET_STATUS).getValue(); - pinBtn.removeStyleName("statusIconRed statusIconBlue statusIconGreen statusIconYellow statusIconLightBlue"); - if (updateStatus == TargetUpdateStatus.ERROR) { - pinBtn.addStyleName("statusIconRed"); - } else if (updateStatus == TargetUpdateStatus.UNKNOWN) { - pinBtn.addStyleName("statusIconBlue"); - } else if (updateStatus == TargetUpdateStatus.IN_SYNC) { - pinBtn.addStyleName("statusIconGreen"); - } else if (updateStatus == TargetUpdateStatus.PENDING) { - pinBtn.addStyleName("statusIconYellow"); - } else if (updateStatus == TargetUpdateStatus.REGISTERED) { - pinBtn.addStyleName("statusIconLightBlue"); - } - } - } - /* * (non-Javadoc) * @@ -563,6 +344,7 @@ public class TargetTable extends AbstractTable implements Handler { @Override protected Object getItemIdToSelect() { if (managementUIState.getSelectedTargetIdName().isPresent()) { + setCurrentPageFirstItemId(managementUIState.getLastSelectedTargetIdName()); return managementUIState.getSelectedTargetIdName().get(); } return null; @@ -578,24 +360,14 @@ public class TargetTable extends AbstractTable implements Handler { protected void onValueChange() { eventBus.publish(this, DragEvent.HIDE_DROP_HINT); @SuppressWarnings("unchecked") - final Set values = (Set) getValue(); - TargetIdName value = null; + final Set values = HawkbitCommonUtil.getSelectedTargetDetails(this); if (values != null && !values.isEmpty()) { - final Iterator iterator = values.iterator(); - - while (iterator.hasNext()) { - value = iterator.next(); - } - /** - * Adding null check to make to avoid NPE.Its weird that at times - * getValue returns null. - */ - if (null != value) { - managementUIState.setSelectedTargetIdName(values); - managementUIState.setLastSelectedTargetIdName(value); - final Target target = targetManagement.findTargetByControllerIDWithDetails(value.getControllerId()); - eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.SELECTED_TARGET, target)); - } + final TargetIdName lastSelectedItem = getLastSelectedItem(values); + managementUIState.setSelectedTargetIdName(values); + managementUIState.setLastSelectedTargetIdName(lastSelectedItem); + final Target target = targetManagement.findTargetByControllerIDWithDetails(lastSelectedItem + .getControllerId()); + eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.SELECTED_TARGET, target)); } else { managementUIState.setSelectedTargetIdName(null); managementUIState.setLastSelectedTargetIdName(null); @@ -665,6 +437,188 @@ public class TargetTable extends AbstractTable implements Handler { }; } + private void onTargetDeletedEvent(final List events) { + final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource(); + final List visibleItemIds = (List) getVisibleItemIds(); + boolean shouldRefreshTargets = false; + for (final TargetDeletedEvent deletedEvent : events) { + final TargetIdName targetIdName = new TargetIdName(deletedEvent.getTargetId(), null, null); + if (visibleItemIds.contains(targetIdName)) { + targetContainer.removeItem(targetIdName); + } else { + shouldRefreshTargets = true; + } + unselect(targetIdName); + } + if (shouldRefreshTargets) { + refreshOnDelete(); + } else { + targetContainer.commit(); + selectRow(); + } + } + + private void refreshOnDelete() { + final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource(); + final int size = targetContainer.size(); + refreshTablecontainer(); + if (size != 0) { + setData(SPUIDefinitions.DATA_AVAILABLE); + } + eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.REFRESH_TARGETS)); + } + + private Map prepareQueryConfigFilters() { + final Map queryConfig = new HashMap(); + managementUIState.getTargetTableFilters().getSearchText() + .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TEXT, value)); + managementUIState.getTargetTableFilters().getDistributionSet() + .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_DISTRIBUTION, value.getId())); + managementUIState.getTargetTableFilters().getPinnedDistId() + .ifPresent(value -> queryConfig.put(SPUIDefinitions.ORDER_BY_DISTRIBUTION, value)); + managementUIState.getTargetTableFilters().getTargetFilterQuery() + .ifPresent(value -> queryConfig.put(SPUIDefinitions.FILTER_BY_TARGET_FILTER_QUERY, value)); + queryConfig.put(SPUIDefinitions.FILTER_BY_NO_TAG, managementUIState.getTargetTableFilters().isNoTagSelected()); + + if (isFilteredByTags()) { + final List list = new ArrayList(); + list.addAll(managementUIState.getTargetTableFilters().getClickedTargetTags()); + queryConfig.put(SPUIDefinitions.FILTER_BY_TAG, list.toArray(new String[list.size()])); + } + if (isFilteredByStatus()) { + final List statusList = managementUIState.getTargetTableFilters() + .getClickedStatusTargetTags(); + queryConfig.put(SPUIDefinitions.FILTER_BY_STATUS, statusList); + } + return queryConfig; + } + + private Label getTagetPollTime(final Object itemId) { + final Label statusLabel = new Label(); + statusLabel.addStyleName(ValoTheme.LABEL_SMALL); + statusLabel.setHeightUndefined(); + statusLabel.setContentMode(ContentMode.HTML); + final String pollStatusToolTip = (String) getContainerDataSource().getItem(itemId) + .getItemProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP).getValue(); + if (HawkbitCommonUtil.trimAndNullIfEmpty(pollStatusToolTip) != null) { + statusLabel.setValue(FontAwesome.EXCLAMATION_CIRCLE.getHtml()); + } else { + statusLabel.setValue(FontAwesome.CLOCK_O.getHtml()); + } + statusLabel.setDescription(pollStatusToolTip); + return statusLabel; + } + + private Button getTagetPinButton(final Object itemId) { + final Button pinBtn = new Button(); + final StringBuilder pinBtnStyle = new StringBuilder(ValoTheme.BUTTON_BORDERLESS_COLORED); + pinBtnStyle.append(' '); + pinBtnStyle.append(ValoTheme.BUTTON_SMALL); + pinBtnStyle.append(' '); + pinBtnStyle.append(ValoTheme.BUTTON_ICON_ONLY); + pinBtn.setStyleName(pinBtnStyle.toString()); + pinBtn.setHeightUndefined(); + pinBtn.setData(itemId); + pinBtn.setId(SPUIComponetIdProvider.TARGET_PIN_ICON + "." + itemId); + pinBtn.addClickListener(event -> addPinClickListener(event)); + if (isPinned(((TargetIdName) itemId).getControllerId())) { + pinBtn.addStyleName("targetPinned"); + isTargetPinned = Boolean.TRUE; + targetPinnedBtn = pinBtn; + eventBus.publish(this, PinUnpinEvent.PIN_TARGET); + } + pinBtn.addStyleName(SPUIStyleDefinitions.TARGET_STATUS_PIN_TOGGLE); + HawkbitCommonUtil.applyStatusLblStyle(this, pinBtn, itemId); + return pinBtn; + } + + private boolean isPinned(final String targetId) { + boolean result = false; + if (managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent() + && targetId.equals(managementUIState.getDistributionTableFilters().getPinnedTargetId().get())) { + result = true; + } else { + result = false; + } + return result; + } + + /** + * Add listener to pin. + * + * @param pinBtn + * as event + */ + private void addPinClickListener(final ClickEvent event) { + eventBus.publish(this, DragEvent.HIDE_DROP_HINT); + checkifAlreadyPinned(event.getButton()); + if (isTargetPinned) { + pinTarget(event.getButton()); + } else { + unPinTarget(event.getButton()); + } + + } + + /** + * Check already pinned. + * + * @param eventBtn + * as button + */ + private void checkifAlreadyPinned(final Button eventBtn) { + final String newPinnedTargetItemId = ((TargetIdName) eventBtn.getData()).getControllerId(); + String targetId = null; + if (managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()) { + targetId = managementUIState.getDistributionTableFilters().getPinnedTargetId().get(); + } + if (targetId == null) { + isTargetPinned = !isTargetPinned; + managementUIState.getDistributionTableFilters().setPinnedTargetId(newPinnedTargetItemId); + } else if (targetId.equals(newPinnedTargetItemId)) { + isTargetPinned = Boolean.FALSE; + } else { + isTargetPinned = true; + managementUIState.getDistributionTableFilters().setPinnedTargetId(newPinnedTargetItemId); + if (null != targetPinnedBtn) { + resetPinStyle(targetPinnedBtn); + } + } + targetPinnedBtn = eventBtn; + } + + private void pinTarget(final Button eventBtn) { + /* if distribution set is pinned ,unpin target if pinned */ + managementUIState.getTargetTableFilters().setPinnedDistId(null); + /* on unpin of target dist table should refresh Dist table restyle */ + eventBus.publish(this, PinUnpinEvent.PIN_TARGET); + /* change target table styling */ + styleTargetTable(); + eventBtn.addStyleName("targetPinned"); + isTargetPinned = Boolean.FALSE; + } + + private void unPinTarget(final Button eventBtn) { + managementUIState.getDistributionTableFilters().setPinnedTargetId(null); + eventBus.publish(this, PinUnpinEvent.UNPIN_TARGET); + resetPinStyle(eventBtn); + } + + private void resetPinStyle(final Button pinBtn) { + pinBtn.removeStyleName("targetPinned"); + pinBtn.addStyleName(SPUIStyleDefinitions.TARGET_STATUS_PIN_TOGGLE); + HawkbitCommonUtil.applyStatusLblStyle(this, pinBtn, pinBtn.getData()); + } + + /** + * Set style of target table. + * + */ + @SuppressWarnings("serial") + private void styleTargetTable() { + setCellStyleGenerator((source, itemId, propertyId) -> null); + } + private void doAssignments(final DragAndDropEvent event) { if (event.getTransferable().getSourceComponent() instanceof Table) { dsToTargetAssignment(event); @@ -688,7 +642,7 @@ public class TargetTable extends AbstractTable implements Handler { private void tagAssignment(final DragAndDropEvent event) { final com.vaadin.event.dd.TargetDetails taregtDet = event.getTargetDetails(); final Table targetTable = (Table) taregtDet.getTarget(); - final Set targetSelected = (Set) targetTable.getValue(); + final Set targetSelected = HawkbitCommonUtil.getSelectedTargetDetails(targetTable); final Set targetList = new HashSet(); final AbstractSelectTargetDetails dropData = (AbstractSelectTargetDetails) event.getTargetDetails(); final Object targetItemId = dropData.getItemIdOver(); @@ -706,25 +660,6 @@ public class TargetTable extends AbstractTable implements Handler { if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty()) { refreshFilter(); } - updateTagLayoutInDetails(result, targTagName); - } - - private void updateTagLayoutInDetails(final TargetTagAssigmentResult result, final String targTagName) { - if (result.getAssigned() > 0) { - final List assignedTargetNames = result.getAssignedTargets().stream().map(t -> t.getControllerId()) - .collect(Collectors.toList()); - if (assignedTargetNames.contains(managementUIState.getLastSelectedTargetIdName().getControllerId())) { - eventBus.publish(this, new TargetTagEvent(TargetTagComponentEvent.ASSIGNED, targTagName)); - } - } else if (result.getUnassigned() > 0) { - - final List unassignedTargetNames = result.getUnassignedTargets().stream() - .map(t -> t.getControllerId()).collect(Collectors.toList()); - if (unassignedTargetNames.contains(managementUIState.getLastSelectedTargetIdName().getControllerId())) { - eventBus.publish(this, new TargetTagEvent(TargetTagComponentEvent.UNASSIGNED, targTagName)); - } - - } } /** @@ -763,10 +698,10 @@ public class TargetTable extends AbstractTable implements Handler { return true; } - private Set getDraggedDistributionSet(final TableTransferable transferable, + private static Set getDraggedDistributionSet(final TableTransferable transferable, final Table source) { @SuppressWarnings("unchecked") - final Set distSelected = (Set) source.getValue(); + final Set distSelected = HawkbitCommonUtil.getSelectedDSDetails(source); final Set distributionIdSet = new HashSet(); if (!distSelected.contains(transferable.getData(ITEMID))) { distributionIdSet.add((DistributionSetIdName) transferable.getData(ITEMID)); @@ -916,7 +851,6 @@ public class TargetTable extends AbstractTable implements Handler { return isFilterEvent; } - // Added by - Asha private String getTargetTableStyle(final Long assignedDistributionSetId, final Long installedDistributionSetId) { final Long distPinned = managementUIState.getTargetTableFilters().getPinnedDistId().isPresent() ? managementUIState .getTargetTableFilters().getPinnedDistId().get() @@ -977,77 +911,121 @@ public class TargetTable extends AbstractTable implements Handler { * @param newTarget * as reference */ - public void addNewTarget(final Target newTarget) { + private void refreshTargets() { final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource(); - targetContainer.refresh(); - eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.ADD_TARGET, newTarget)); + final int size = targetContainer.size(); + if (size < SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) { + refreshTablecontainer(); + } else { + // If table is not refreshed , explicitly target total count and + // truncated count has to be updated + resetTargetCountDetails(); + } + + if (size != 0) { + setData(SPUIDefinitions.DATA_AVAILABLE); + } + + eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.REFRESH_TARGETS)); } private void updateVisibleItemOnEvent(final TargetInfo targetInfo, final Target target, - final TargetIdName targetIdName, final LazyQueryContainer targetContainer) { + final TargetIdName targetIdName) { + final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource(); final Item item = targetContainer.getItem(targetIdName); item.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).setValue(targetInfo.getUpdateStatus()); item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(target.getName()); item.getItemProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP).setValue( HawkbitCommonUtil.getPollStatusToolTip(targetInfo.getPollStatus(), i18n)); + } - // workaround until push is available for action history, re-select the - // updated target so - // the action history gets refreshed. - if (isSelected(targetIdName)) { - unselect(targetIdName); - select(targetIdName); - } + private boolean isLastSelectedTarget(final TargetIdName targetIdName) { + return null != managementUIState.getLastSelectedTargetIdName() + && managementUIState.getLastSelectedTargetIdName().equals(targetIdName); } /** * EventListener method which is called by the event bus to notify about a - * {@link TargetInfoUpdateEvent}. + * list of {@link TargetInfoUpdateEvent}. * - * @param targetInfoUpdateEvent - * the target info update event + * @param targetInfoUpdateEvents + * list of target info update event */ - @EventBusListenerMethod(scope = EventScope.SESSION) - public void onEvent(final TargetInfoUpdateEvent targetInfoUpdateEvent) { - final TargetInfo targetInfo = targetInfoUpdateEvent.getEntity(); - final Target target = targetInfo.getTarget(); - final TargetIdName targetIdName = target.getTargetIdName(); - final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource(); - final TargetTableFilters targetTableFilters = managementUIState.getTargetTableFilters(); - - @SuppressWarnings("unchecked") + @SuppressWarnings("unchecked") + private void onTargetInfoUpdateEvents(final List targetInfoUpdateEvents) { final List visibleItemIds = (List) getVisibleItemIds(); - if (visibleItemIds.contains(targetIdName)) { - updateVisibleItemOnEvent(targetInfo, target, targetIdName, targetContainer); - } else { - final List filters = new ArrayList<>(); - if (targetTableFilters.getSearchText().isPresent()) { - filters.add(new TargetSearchTextFilter(target, targetTableFilters.getSearchText().get())); + boolean shoulTargetsUpdated = false; + Target lastSelectedTarget = null; + for (final TargetInfoUpdateEvent targetInfoUpdateEvent : targetInfoUpdateEvents) { + final TargetInfo targetInfo = targetInfoUpdateEvent.getEntity(); + final Target target = targetInfo.getTarget(); + final TargetIdName targetIdName = target.getTargetIdName(); + if (Filters.or(getTargetTableFilters(target)).doFilter()) { + shoulTargetsUpdated = true; + } else { + if (visibleItemIds.contains(targetIdName)) { + updateVisibleItemOnEvent(targetInfo, target, targetIdName); + } } - filters.add(new TargetStatusFilter(target, targetTableFilters.getClickedStatusTargetTags())); - filters.add(new TargetTagFilter(target, targetTableFilters.getClickedTargetTags(), targetTableFilters - .isNoTagSelected())); - - if (!Filters.or(filters).doFilter()) { - addNewTarget(target); + // workaround until push is available for action history, re-select + // the + // updated target so + // the action history gets refreshed. + if (isLastSelectedTarget(targetIdName)) { + lastSelectedTarget = target; } - addNewTarget(target); } + if (shoulTargetsUpdated) { + refreshTargets(); + } + if (lastSelectedTarget != null) { + eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.SELECTED_TARGET, lastSelectedTarget)); + } + } + + private void onTargetCreatedEvents() { + refreshTargets(); + } + + private List getTargetTableFilters(final Target target) { + final TargetTableFilters targetTableFilters = managementUIState.getTargetTableFilters(); + final List filters = new ArrayList<>(); + if (targetTableFilters.getSearchText().isPresent()) { + filters.add(new TargetSearchTextFilter(target, targetTableFilters.getSearchText().get())); + } + filters.add(new TargetStatusFilter(targetTableFilters.getClickedStatusTargetTags())); + filters.add(new TargetTagFilter(target, targetTableFilters.getClickedTargetTags(), targetTableFilters + .isNoTagSelected())); + filters.add(new CustomTargetFilter(targetTableFilters.getTargetFilterQuery())); + return filters; } /** * Select all rows in the table. */ public void selectAll() { + final PageRequest pageRequest = new OffsetBasedPageRequest(0, size(), new Sort( + SPUIDefinitions.TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt")); + List targetIdList; + // is custom filter selected + if (managementUIState.getTargetTableFilters().getTargetFilterQuery().isPresent()) { + targetIdList = getTargetIdsByCustomFilters(pageRequest); + } else { + targetIdList = getTargetIdsBySimpleFilters(pageRequest); + } + setValue(targetIdList); + } + + private List getTargetIdsBySimpleFilters(final PageRequest pageRequest) { final Long filterByDistId = managementUIState.getTargetTableFilters().getDistributionSet().isPresent() ? managementUIState .getTargetTableFilters().getDistributionSet().get().getId() : null; final List statusList = new ArrayList(); - if (!managementUIState.getTargetTableFilters().getClickedStatusTargetTags().isEmpty()) { + if (isFilteredByStatus()) { statusList.addAll(managementUIState.getTargetTableFilters().getClickedStatusTargetTags()); } final List tagList = new ArrayList(); - if (!managementUIState.getTargetTableFilters().getClickedTargetTags().isEmpty()) { + if (isFilteredByTags()) { tagList.addAll(managementUIState.getTargetTableFilters().getClickedTargetTags()); } String searchText = managementUIState.getTargetTableFilters().getSearchText().isPresent() ? managementUIState @@ -1059,43 +1037,29 @@ public class TargetTable extends AbstractTable implements Handler { final String[] tagArray = tagList.toArray(new String[tagList.size()]); - // limit the selection of all targets of the targets only currently - // showed in the list, so - // maxiumm the SP SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES - final PageRequest pageRequest = new OffsetBasedPageRequest(0, SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES, - new Sort(Direction.DESC, "createdAt")); - setValue(targetManagement.findAllTargetIdsByFilters(pageRequest, filterByDistId, statusList, searchText, - noTagSelected, tagList.toArray(tagArray))); + List targetIdList; + targetIdList = targetManagement.findAllTargetIdsByFilters(pageRequest, filterByDistId, statusList, searchText, + noTagSelected, tagList.toArray(tagArray)); + Collections.reverse(targetIdList); + return targetIdList; + } + + private List getTargetIdsByCustomFilters(final PageRequest pageRequest) { + List targetIdList; + final TargetFilterQuery targetFilterQuery = managementUIState.getTargetTableFilters().getTargetFilterQuery() + .isPresent() ? managementUIState.getTargetTableFilters().getTargetFilterQuery().get() : null; + targetIdList = targetManagement.findAllTargetIdsByTargetFilterQuery(pageRequest, targetFilterQuery); + Collections.reverse(targetIdList); + return targetIdList; } /** * Clear all selections in the table. */ - public void unSelectAll() { + private void unSelectAll() { setValue(null); } - @Override - public Action[] getActions(final Object target, final Object sender) { - return new Action[] { actionSelectAll, actionUnSelectAll }; - } - - @Override - public void handleAction(final Action action, final Object sender, final Object target) { - if (actionSelectAll.equals(action)) { - selectAll(); - eventBus.publish(this, new TargetTableEvent(TargetComponentEvent.SELLECT_ALL)); - } - if (actionUnSelectAll.equals(action)) { - unSelectAll(); - } - } - - @PreDestroy - void destroy() { - eventBus.unsubscribe(this); - } - private void setNoDataAvailable() { final int tableSize = getContainerDataSource().size(); if (tableSize == 0) { @@ -1105,4 +1069,90 @@ public class TargetTable extends AbstractTable implements Handler { } } + /** + * Set total target count and count of targets truncated in target table. + */ + private void resetTargetCountDetails() { + final long size; + final long totalTargetsCount = getTotalTargetsCount(); + managementUIState.setTargetsCountAll(totalTargetsCount); + + Collection status = null; + String[] targetTags = null; + Long distributionId = null; + String searchText = null; + Boolean noTagClicked = Boolean.FALSE; + Long pinnedDistId = null; + + if (isFilteredByTags()) { + targetTags = (String[]) managementUIState.getTargetTableFilters().getClickedTargetTags().toArray(); + } + if (isFilteredByStatus()) { + status = managementUIState.getTargetTableFilters().getClickedStatusTargetTags(); + } + if (managementUIState.getTargetTableFilters().getDistributionSet().isPresent()) { + distributionId = managementUIState.getTargetTableFilters().getDistributionSet().get().getId(); + } + if (isFilteredByText()) { + searchText = String.format("%%%s%%", managementUIState.getTargetTableFilters().getSearchText().get()); + } + noTagClicked = managementUIState.getTargetTableFilters().isNoTagSelected(); + if (managementUIState.getTargetTableFilters().getPinnedDistId().isPresent()) { + pinnedDistId = managementUIState.getTargetTableFilters().getPinnedDistId().get(); + } + + size = getTargetsCountWithFilter(totalTargetsCount, status, targetTags, distributionId, searchText, + noTagClicked, pinnedDistId); + + if (size > SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES) { + managementUIState.setTargetsTruncated(size - SPUIDefinitions.MAX_TARGET_TABLE_ENTRIES); + } + } + + private long getTargetsCountWithFilter(final long totalTargetsCount, final Collection status, + final String[] targetTags, final Long distributionId, final String searchText, final Boolean noTagClicked, + final Long pinnedDistId) { + final long size; + if (managementUIState.getTargetTableFilters().getTargetFilterQuery().isPresent()) { + size = targetManagement.countTargetByTargetFilterQuery(managementUIState.getTargetTableFilters() + .getTargetFilterQuery().get()); + } else if (!anyFilterSelected(status, pinnedDistId, noTagClicked, targetTags, searchText)) { + size = totalTargetsCount; + } else { + size = targetManagement.countTargetByFilters(status, searchText, distributionId, noTagClicked, targetTags); + } + return size; + } + + private boolean isFilteredByText() { + return managementUIState.getTargetTableFilters().getSearchText().isPresent() + && !Strings.isNullOrEmpty(managementUIState.getTargetTableFilters().getSearchText().get()); + } + + private Boolean anyFilterSelected(final Collection status, final Long distributionId, + final Boolean noTagClicked, final String[] targetTags, final String searchText) { + return status == null && distributionId == null && Strings.isNullOrEmpty(searchText) + && !isTagSelected(targetTags, noTagClicked); + } + + private Boolean isTagSelected(final String[] targetTags, final Boolean noTagClicked) { + return targetTags == null && !noTagClicked; + } + + private long getTotalTargetsCount() { + return targetManagement.countTargetsAll(); + } + + private static TargetIdName getLastSelectedItem(final Set values) { + return Iterables.getLast(values); + } + + private boolean isFilteredByStatus() { + return !managementUIState.getTargetTableFilters().getClickedStatusTargetTags().isEmpty(); + } + + private boolean isFilteredByTags() { + return !managementUIState.getTargetTableFilters().getClickedTargetTags().isEmpty(); + } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java old mode 100755 new mode 100644 index 43bdd0395..d1a49b899 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableHeader.java @@ -19,6 +19,8 @@ import org.eclipse.hawkbit.repository.model.DistributionSetIdName; import org.eclipse.hawkbit.ui.common.table.AbstractTableHeader; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder; +import org.eclipse.hawkbit.ui.management.event.BulkUploadPopupEvent; +import org.eclipse.hawkbit.ui.management.event.BulkUploadValidationMessageEvent; import org.eclipse.hawkbit.ui.management.event.DragEvent; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria; @@ -121,6 +123,41 @@ public class TargetTableHeader extends AbstractTableHeader { } } + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEvent(final BulkUploadPopupEvent event) { + if (BulkUploadPopupEvent.MAXIMIMIZED == event) { + targetBulkUpdateWindow.restoreComponentsValue(); + openBulkUploadWindow(); + } else if (BulkUploadPopupEvent.CLOSED == event) { + UI.getCurrent().access(() -> enableBulkUpload()); + } + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEvent(final BulkUploadValidationMessageEvent event) { + this.getUI().access(() -> notification.displayValidationError(event.getValidationErrorMessage())); + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEvent(final TargetTableEvent event) { + if (TargetComponentEvent.BULK_TARGET_CREATED == event.getTargetComponentEvent()) { + this.getUI().access( + () -> targetBulkUpdateWindow.setProgressBarValue(managementUIState.getTargetTableFilters() + .getBulkUpload().getProgressBarCurrentValue())); + } else if (TargetComponentEvent.BULK_UPLOAD_COMPLETED == event.getTargetComponentEvent()) { + this.getUI().access(() -> targetBulkUpdateWindow.onUploadCompletion()); + } else if (TargetComponentEvent.BULK_TARGET_UPLOAD_STARTED == event.getTargetComponentEvent()) { + this.getUI().access(() -> onStartOfBulkUpload()); + } else if (TargetComponentEvent.BULK_UPLOAD_PROCESS_STARTED == event.getTargetComponentEvent()) { + this.getUI().access(() -> targetBulkUpdateWindow.getBulkUploader().getUpload().setEnabled(false)); + } + } + + private void onStartOfBulkUpload() { + disableBulkUpload(); + targetBulkUpdateWindow.onStartOfUpload(); + } + private void onCustomFilterReset() { isComplexFilterViewDisplayed = Boolean.FALSE; reEnableSearch(); @@ -277,6 +314,10 @@ public class TargetTableHeader extends AbstractTableHeader { @Override protected void bulkUpload(final ClickEvent event) { targetBulkUpdateWindow.resetComponents(); + openBulkUploadWindow(); + } + + private void openBulkUploadWindow() { final Window bulkUploadTargetWindow = targetBulkUpdateWindow.getWindow(); UI.getCurrent().addWindow(bulkUploadTargetWindow); bulkUploadTargetWindow.setVisible(true); @@ -354,8 +395,8 @@ public class TargetTableHeader extends AbstractTableHeader { private Set getDropppedDistributionDetails(final TableTransferable transferable) { @SuppressWarnings("unchecked") - final Set distSelected = (Set) transferable.getSourceComponent() - .getValue(); + final Set distSelected = HawkbitCommonUtil.getSelectedDSDetails(transferable + .getSourceComponent()); final Set distributionIdSet = new HashSet(); if (!distSelected.contains(transferable.getData("itemId"))) { distributionIdSet.add((DistributionSetIdName) transferable.getData("itemId")); @@ -424,4 +465,16 @@ public class TargetTableHeader extends AbstractTableHeader { protected String getFilterIconStyle() { return null; } + + /* + * (non-Javadoc) + * + * @see org.eclipse.hawkbit.ui.common.table.AbstractTableHeader# + * isBulkUploadInProgress() + */ + @Override + protected boolean isBulkUploadInProgress() { + return managementUIState.getTargetTableFilters().getBulkUpload().getSucessfulUploadCount() != 0 + || managementUIState.getTargetTableFilters().getBulkUpload().getFailedUploadCount() != 0; + } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableLayout.java old mode 100755 new mode 100644 index 492141442..aaf5c6a9f --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetTableLayout.java @@ -43,10 +43,10 @@ public class TargetTableLayout extends AbstractTableLayout { private transient EventBus.SessionEventBus eventBus; @Autowired - private TargetTableHeader targetTableHeader; + private TargetDetails targetDetails; @Autowired - private TargetDetails targetDetails; + private TargetTableHeader targetTableHeader; @Autowired private TargetTable targetTable; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/AbstractTargetTagFilterLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/AbstractTargetTagFilterLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayout.java old mode 100755 new mode 100644 index 650943aa8..6b7562d17 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayout.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CreateUpdateTargetTagLayout.java @@ -11,21 +11,20 @@ package org.eclipse.hawkbit.ui.management.targettag; import java.util.ArrayList; import java.util.List; -import org.eclipse.hawkbit.repository.SpPermissionChecker; -import org.eclipse.hawkbit.repository.TagManagement; +import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent; +import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent; +import org.eclipse.hawkbit.eventbus.event.TargetTagUpdateEvent; import org.eclipse.hawkbit.repository.model.TargetTag; import org.eclipse.hawkbit.ui.components.SPUIComponentProvider; -import org.eclipse.hawkbit.ui.management.event.TargetTagEvent; -import org.eclipse.hawkbit.ui.management.event.TargetTagEvent.TargetTagComponentEvent; import org.eclipse.hawkbit.ui.management.tag.CreateUpdateTagLayout; import org.eclipse.hawkbit.ui.management.tag.SpColorPickerPreview; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; -import org.eclipse.hawkbit.ui.utils.I18N; import org.eclipse.hawkbit.ui.utils.SPUIDefinitions; import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions; import org.eclipse.hawkbit.ui.utils.UINotification; import org.springframework.beans.factory.annotation.Autowired; -import org.vaadin.spring.events.EventBus; +import org.vaadin.spring.events.EventScope; +import org.vaadin.spring.events.annotation.EventBusListenerMethod; import com.google.common.base.Strings; import com.vaadin.shared.ui.colorpicker.Color; @@ -47,30 +46,11 @@ public class CreateUpdateTargetTagLayout extends CreateUpdateTagLayout { private static final long serialVersionUID = 2446682350481560235L; - @Autowired - private SpPermissionChecker permChecker; - - @Autowired - private transient TagManagement tagManagementService; - @Autowired private transient UINotification uiNotification; - @Autowired - private I18N i18n; - - @Autowired - private transient EventBus.SessionEventBus eventBus; - private Window targetTagWindow; - /** - * Initialize the Target Tag Layout. - */ - public void initTargetTagLayout() { - super.init(); - } - @Override protected void createOptionGroup() { final List optionValues = new ArrayList<>(); @@ -104,13 +84,28 @@ public class CreateUpdateTargetTagLayout extends CreateUpdateTagLayout { } + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEventTargetTagCreated(final TargetTagCreatedBulkEvent event) { + populateTagNameCombo(); + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEventTargetDeletedEvent(final TargetTagDeletedEvent event) { + populateTagNameCombo(); + } + + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEventTargetTagUpdateEvent(final TargetTagUpdateEvent event) { + populateTagNameCombo(); + } + /** * Populate target name combo. */ @Override public void populateTagNameCombo() { tagNameComboBox.removeAllItems(); - final List trgTagNameList = tagManagementService.findAllTargetTags(); + final List trgTagNameList = tagManagement.findAllTargetTags(); trgTagNameList.forEach(value -> tagNameComboBox.addItem(value.getName())); } @@ -124,7 +119,7 @@ public class CreateUpdateTargetTagLayout extends CreateUpdateTagLayout { @Override public void setTagDetails(final String targetTagSelected) { tagName.setValue(targetTagSelected); - final TargetTag selectedTargetTag = tagManagementService.findTargetTag(targetTagSelected); + final TargetTag selectedTargetTag = tagManagement.findTargetTag(targetTagSelected); if (null != selectedTargetTag) { tagDesc.setValue(selectedTargetTag.getDescription()); if (null == selectedTargetTag.getColour()) { @@ -146,7 +141,7 @@ public class CreateUpdateTargetTagLayout extends CreateUpdateTagLayout { @Override public void save(final ClickEvent event) { if (mandatoryValuesPresent()) { - final TargetTag existingTag = tagManagementService.findTargetTag(tagName.getValue()); + final TargetTag existingTag = tagManagement.findTargetTag(tagName.getValue()); if (optiongroup.getValue().equals(createTagNw)) { if (!checkIsDuplicate(existingTag)) { crateNewTag(); @@ -160,8 +155,8 @@ public class CreateUpdateTargetTagLayout extends CreateUpdateTagLayout { private Boolean checkIsDuplicate(final TargetTag existingTag) { if (existingTag != null) { - uiNotification.displayValidationError( - i18n.get("message.tag.duplicate.check", new Object[] { existingTag.getName() })); + uiNotification.displayValidationError(i18n.get("message.tag.duplicate.check", + new Object[] { existingTag.getName() })); return Boolean.TRUE; } return Boolean.FALSE; @@ -200,10 +195,9 @@ public class CreateUpdateTargetTagLayout extends CreateUpdateTagLayout { if (colorPicked != null) { newTargetTag.setColour(colorPicked); } - newTargetTag = tagManagementService.createTargetTag(newTargetTag); + newTargetTag = tagManagement.createTargetTag(newTargetTag); uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { newTargetTag.getName() })); closeWindow(); - eventBus.publish(this, new TargetTagEvent(TargetTagComponentEvent.ADD_TARGETTAG, newTargetTag)); } else { uiNotification.displayValidationError(i18n.get("message.error.missing.tagname")); @@ -221,11 +215,9 @@ public class CreateUpdateTargetTagLayout extends CreateUpdateTagLayout { targetObj.setName(nameUpdateValue); targetObj.setDescription(null != descUpdateValue ? descUpdateValue : null); targetObj.setColour(getColorPickedSting()); - tagManagementService.updateTargetTag(targetObj); + tagManagement.updateTargetTag(targetObj); uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { targetObj.getName() })); closeWindow(); - eventBus.publish(this, new TargetTagEvent(TargetTagComponentEvent.EDIT_TARGETTAG, targetObj)); - } else { uiNotification.displayValidationError(i18n.get("message.tag.update.mandatory")); } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CustomTargetTagFilterButtonClick.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/CustomTargetTagFilterButtonClick.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/FilterByStatusLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/FilterByStatusLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/MultipleTargetFilter.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/MultipleTargetFilter.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetFilterQueryButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetFilterQueryButtons.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagBeanQuery.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagBeanQuery.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtonClick.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtonClick.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java old mode 100755 new mode 100644 index c4bfe25e4..d6876a0b6 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterButtons.java @@ -15,18 +15,19 @@ import java.util.stream.Collectors; import javax.annotation.PreDestroy; +import org.eclipse.hawkbit.eventbus.event.TargetTagCreatedBulkEvent; +import org.eclipse.hawkbit.eventbus.event.TargetTagDeletedEvent; +import org.eclipse.hawkbit.eventbus.event.TargetTagUpdateEvent; import org.eclipse.hawkbit.repository.SpPermissionChecker; import org.eclipse.hawkbit.repository.TagManagement; import org.eclipse.hawkbit.repository.TargetManagement; -import org.eclipse.hawkbit.repository.TargetTagAssigmentResult; import org.eclipse.hawkbit.repository.model.TargetIdName; import org.eclipse.hawkbit.repository.model.TargetTag; +import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult; import org.eclipse.hawkbit.ui.common.filterlayout.AbstractFilterButtons; import org.eclipse.hawkbit.ui.management.event.DragEvent; import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent; import org.eclipse.hawkbit.ui.management.event.ManagementViewAcceptCriteria; -import org.eclipse.hawkbit.ui.management.event.TargetTagEvent; -import org.eclipse.hawkbit.ui.management.event.TargetTagEvent.TargetTagComponentEvent; import org.eclipse.hawkbit.ui.management.state.ManagementUIState; import org.eclipse.hawkbit.ui.management.tag.TagIdName; import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil; @@ -280,49 +281,29 @@ public class TargetTagFilterButtons extends AbstractFilterButtons { final Table source = transferable.getSourceComponent(); @SuppressWarnings("unchecked") - final Set targetSelected = (Set) source.getValue(); + final Set targetSelected = HawkbitCommonUtil.getSelectedTargetDetails(source); final Set targetList = new HashSet(); - if (!targetSelected.contains(transferable.getData(ITEMID))) { - targetList.add(((TargetIdName) transferable.getData(ITEMID)).getControllerId()); - } else { - targetList.addAll(targetSelected.stream().map(t -> t.getControllerId()).collect(Collectors.toList())); - } - - final String targTagName = HawkbitCommonUtil.removePrefix(targetDetails.getTarget().getId(), - SPUIDefinitions.TARGET_TAG_ID_PREFIXS); - - final List tagsClickedList = managementUIState.getTargetTableFilters().getClickedTargetTags(); - - final TargetTagAssigmentResult result = targetManagement.toggleTagAssignment(targetList, targTagName); - notification.displaySuccess(HawkbitCommonUtil.getTargetTagAssigmentMsg(targTagName, result, i18n)); - - if (result.getAssigned() >= 1 && managementUIState.getTargetTableFilters().isNoTagSelected()) { - eventBus.publish(this, ManagementUIEvent.ASSIGN_TARGET_TAG); - } - if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty() && tagsClickedList.contains(targTagName)) { - eventBus.publish(this, ManagementUIEvent.UNASSIGN_TARGET_TAG); - } - - updateTargetTagLayoutInDetails(result, targTagName); - - } - - private void updateTargetTagLayoutInDetails(final TargetTagAssigmentResult assignmentResult, - final String targTagName) { - if (assignmentResult.getAssigned() > 0) { - final List assignedTargetNamesList = assignmentResult.getAssignedTargets().stream() - .map(t -> t.getControllerId()).collect(Collectors.toList()); - if (assignedTargetNamesList.contains(managementUIState.getLastSelectedTargetIdName().getControllerId())) { - eventBus.publish(this, new TargetTagEvent(TargetTagComponentEvent.ASSIGNED, targTagName)); - } - } else if (assignmentResult.getUnassigned() > 0) { - - final List unassignedTargetNamesList = assignmentResult.getUnassignedTargets().stream() - .map(t -> t.getControllerId()).collect(Collectors.toList()); - if (unassignedTargetNamesList.contains(managementUIState.getLastSelectedTargetIdName().getControllerId())) { - eventBus.publish(this, new TargetTagEvent(TargetTagComponentEvent.UNASSIGNED, targTagName)); + if (transferable.getData(ITEMID) != null) { + if (!targetSelected.contains(transferable.getData(ITEMID))) { + targetList.add(((TargetIdName) transferable.getData(ITEMID)).getControllerId()); + } else { + targetList.addAll(targetSelected.stream().map(t -> t.getControllerId()).collect(Collectors.toList())); } + final String targTagName = HawkbitCommonUtil.removePrefix(targetDetails.getTarget().getId(), + SPUIDefinitions.TARGET_TAG_ID_PREFIXS); + + final List tagsClickedList = managementUIState.getTargetTableFilters().getClickedTargetTags(); + + final TargetTagAssigmentResult result = targetManagement.toggleTagAssignment(targetList, targTagName); + notification.displaySuccess(HawkbitCommonUtil.getTargetTagAssigmentMsg(targTagName, result, i18n)); + + if (result.getAssigned() >= 1 && managementUIState.getTargetTableFilters().isNoTagSelected()) { + eventBus.publish(this, ManagementUIEvent.ASSIGN_TARGET_TAG); + } + if (result.getUnassigned() >= 1 && !tagsClickedList.isEmpty() && tagsClickedList.contains(targTagName)) { + eventBus.publish(this, ManagementUIEvent.UNASSIGN_TARGET_TAG); + } } } @@ -355,17 +336,25 @@ public class TargetTagFilterButtons extends AbstractFilterButtons { } @EventBusListenerMethod(scope = EventScope.SESSION) - void onEvent(final TargetTagEvent event) { - if (event.getTargetTagComponentEvent() == TargetTagEvent.TargetTagComponentEvent.ADD_TARGETTAG - || event.getTargetTagComponentEvent() == TargetTagEvent.TargetTagComponentEvent.EDIT_TARGETTAG - || event.getTargetTagComponentEvent() == TargetTagEvent.TargetTagComponentEvent.DELETE_TARGETTAG) { - removeGeneratedColumn(FILTER_BUTTON_COLUMN); - ((LazyQueryContainer) getContainerDataSource()).refresh(); - addNewTargetTag(new TargetTag("NO TAG")); - addColumn(); + void onEvent(final TargetTagUpdateEvent event) { + refreshContainer(); + } - } + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEventTargetTagCreated(final TargetTagCreatedBulkEvent event) { + refreshContainer(); + } + @EventBusListenerMethod(scope = EventScope.SESSION) + void onEventTargetDeletedEvent(final TargetTagDeletedEvent event) { + refreshContainer(); + } + + private void refreshContainer() { + removeGeneratedColumn(FILTER_BUTTON_COLUMN); + ((LazyQueryContainer) getContainerDataSource()).refresh(); + addNewTargetTag(new TargetTag("NO TAG")); + addColumn(); } @EventBusListenerMethod(scope = EventScope.SESSION) diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterHeader.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterHeader.java old mode 100755 new mode 100644 index da5b06c12..5175f5f60 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterHeader.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterHeader.java @@ -57,7 +57,7 @@ public class TargetTagFilterHeader extends AbstractFilterHeader { public void init() { super.init(); if (permChecker.hasCreateTargetPermission() || permChecker.hasUpdateTargetPermission()) { - createUpdateTargetTagLayout.initTargetTagLayout(); + createUpdateTargetTagLayout.init(); } } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettag/TargetTagFilterLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardEvent.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardEvent.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenu.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenuItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/menu/DashboardMenuItem.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/AuthenticationConfigurationView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/AuthenticationConfigurationView.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/ConfigurationGroup.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/ConfigurationGroup.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/DefaultDistributionSetTypeLayout.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/DefaultDistributionSetTypeLayout.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/TenantConfigurationDashboardView.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/TenantConfigurationDashboardView.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/TenantConfigurationDashboardViewMenuItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/TenantConfigurationDashboardViewMenuItem.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/AbstractAuthenticationTenantConfigurationItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/AbstractAuthenticationTenantConfigurationItem.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/CertificateAuthenticationConfigurationItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/CertificateAuthenticationConfigurationItem.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/GatewaySecurityTokenAuthenticationConfigurationItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/GatewaySecurityTokenAuthenticationConfigurationItem.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/TargetSecurityTokenAuthenticationConfigurationItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/TargetSecurityTokenAuthenticationConfigurationItem.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/TenantConfigurationItem.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/tenantconfiguration/authentication/TenantConfigurationItem.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/themes/HawkbitTheme.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/themes/HawkbitTheme.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java old mode 100755 new mode 100644 index 07d271ac9..49eb6498a --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java @@ -11,18 +11,26 @@ package org.eclipse.hawkbit.ui.utils; import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.Date; import java.util.HashMap; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.TimeZone; import org.eclipse.hawkbit.im.authentication.UserPrincipal; -import org.eclipse.hawkbit.repository.DistributionSetTagAssigmentResult; import org.eclipse.hawkbit.repository.SoftwareManagement; -import org.eclipse.hawkbit.repository.TargetTagAssigmentResult; +import org.eclipse.hawkbit.repository.model.DistributionSetIdName; +import org.eclipse.hawkbit.repository.model.DistributionSetTagAssigmentResult; import org.eclipse.hawkbit.repository.model.SoftwareModule; import org.eclipse.hawkbit.repository.model.SoftwareModuleType; +import org.eclipse.hawkbit.repository.model.TargetIdName; +import org.eclipse.hawkbit.repository.model.TargetTagAssigmentResult; import org.eclipse.hawkbit.repository.model.TargetInfo.PollStatus; +import org.eclipse.hawkbit.repository.model.TargetUpdateStatus; +import org.eclipse.hawkbit.ui.management.dstable.DistributionTable; +import org.eclipse.hawkbit.ui.management.targettable.TargetTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.security.core.userdetails.UserDetails; @@ -34,8 +42,10 @@ import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer; import org.vaadin.addons.lazyquerycontainer.LazyQueryDefinition; import com.vaadin.data.Container; +import com.vaadin.data.Item; import com.vaadin.server.Sizeable.Unit; import com.vaadin.shared.ui.label.ContentMode; +import com.vaadin.ui.Button; import com.vaadin.ui.Component; import com.vaadin.ui.Label; import com.vaadin.ui.Table; @@ -422,10 +432,12 @@ public final class HawkbitCommonUtil { public static String getPollStatusToolTip(final PollStatus pollStatus, final I18N i18N) { if (pollStatus != null && pollStatus.getLastPollDate() != null && pollStatus.isOverdue()) { final TimeZone tz = SPDateTimeUtil.getBrowserTimeZone(); - return "Overdue for " + SPDateTimeUtil.getDurationFormattedString( - pollStatus.getOverdueDate().atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant().toEpochMilli(), - pollStatus.getCurrentDate().atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant().toEpochMilli(), - i18N); + return "Overdue for " + + SPDateTimeUtil.getDurationFormattedString( + pollStatus.getOverdueDate().atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant() + .toEpochMilli(), + pollStatus.getCurrentDate().atZone(SPDateTimeUtil.getTimeZoneId(tz)).toInstant() + .toEpochMilli(), i18N); } return null; } @@ -467,8 +479,8 @@ public final class HawkbitCommonUtil { * @return extra height required to increase. */ public static float findRequiredExtraHeight(final float newBrowserHeight) { - return newBrowserHeight > SPUIDefinitions.REQ_MIN_BROWSER_HEIGHT - ? newBrowserHeight - SPUIDefinitions.REQ_MIN_BROWSER_HEIGHT : 0; + return newBrowserHeight > SPUIDefinitions.REQ_MIN_BROWSER_HEIGHT ? newBrowserHeight + - SPUIDefinitions.REQ_MIN_BROWSER_HEIGHT : 0; } /** @@ -479,8 +491,8 @@ public final class HawkbitCommonUtil { * @return float heigth of software module table */ public static float findRequiredSwModuleExtraHeight(final float newBrowserHeight) { - return newBrowserHeight > SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_HEIGHT - ? newBrowserHeight - SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_HEIGHT : 0; + return newBrowserHeight > SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_HEIGHT ? newBrowserHeight + - SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_HEIGHT : 0; } /** @@ -491,8 +503,8 @@ public final class HawkbitCommonUtil { * @return float width of software module table */ public static float findRequiredSwModuleExtraWidth(final float newBrowserWidth) { - return newBrowserWidth > SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_WIDTH - ? newBrowserWidth - SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_WIDTH : 0; + return newBrowserWidth > SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_WIDTH ? newBrowserWidth + - SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_WIDTH : 0; } /** @@ -554,8 +566,8 @@ public final class HawkbitCommonUtil { * @return extra width required to be increased. */ public static float findExtraWidth(final float newBrowserWidth) { - return newBrowserWidth > SPUIDefinitions.REQ_MIN_BROWSER_WIDTH - ? newBrowserWidth - SPUIDefinitions.REQ_MIN_BROWSER_WIDTH : 0; + return newBrowserWidth > SPUIDefinitions.REQ_MIN_BROWSER_WIDTH ? newBrowserWidth + - SPUIDefinitions.REQ_MIN_BROWSER_WIDTH : 0; } /** @@ -688,12 +700,12 @@ public final class HawkbitCommonUtil { final StringBuilder exeJS = new StringBuilder(DRAG_COUNT_ELEMENT).append(JS_DRAG_COUNT_REM_CHILD); final String currentTheme = UI.getCurrent().getTheme(); if (count > 1) { - exeJS.append(COUNT_STYLE).append(COUNT_STYLE_ID) + exeJS.append(COUNT_STYLE) + .append(COUNT_STYLE_ID) .append(" countStyle.innerHTML = '." + currentTheme + " tbody.v-drag-element tr:after { content:\"" + count + "\";top:-15px } ." + currentTheme + " tr.v-drag-element:after { content:\"" + count + CLOSE_BRACE_NOSEMICOLON + "." + currentTheme - + " table.v-drag-element:after{ content:\"" + count + CLOSE_BRACE) - .append(APPEND_CHILD); + + " table.v-drag-element:after{ content:\"" + count + CLOSE_BRACE).append(APPEND_CHILD); } return exeJS.toString(); } @@ -888,8 +900,9 @@ public final class HawkbitCommonUtil { final int unassignedCount = result.getUnassigned(); if (assignedCount == 1) { - formMsg.append(i18n.get("message.target.assigned.one", - new Object[] { result.getAssignedTargets().get(0).getName(), targTagName })).append("
"); + formMsg.append( + i18n.get("message.target.assigned.one", new Object[] { + result.getAssignedTargets().get(0).getName(), targTagName })).append("
"); } else if (assignedCount > 1) { formMsg.append(i18n.get("message.target.assigned.many", new Object[] { assignedCount, targTagName })) @@ -903,8 +916,9 @@ public final class HawkbitCommonUtil { } if (unassignedCount == 1) { - formMsg.append(i18n.get("message.target.unassigned.one", - new Object[] { result.getUnassignedTargets().get(0).getName(), targTagName })).append("
"); + formMsg.append( + i18n.get("message.target.unassigned.one", new Object[] { + result.getUnassignedTargets().get(0).getName(), targTagName })).append("
"); } else if (unassignedCount > 1) { formMsg.append(i18n.get("message.target.unassigned.many", new Object[] { unassignedCount, targTagName })) @@ -934,8 +948,9 @@ public final class HawkbitCommonUtil { final int unassignedCount = result.getUnassigned(); if (assignedCount == 1) { - formMsg.append(i18n.get("message.target.assigned.one", - new Object[] { result.getAssignedDs().get(0).getName(), targTagName })).append("
"); + formMsg.append( + i18n.get("message.target.assigned.one", new Object[] { result.getAssignedDs().get(0).getName(), + targTagName })).append("
"); } else if (assignedCount > 1) { formMsg.append(i18n.get("message.target.assigned.many", new Object[] { assignedCount, targTagName })) @@ -949,8 +964,9 @@ public final class HawkbitCommonUtil { } if (unassignedCount == 1) { - formMsg.append(i18n.get("message.target.unassigned.one", - new Object[] { result.getUnassignedDs().get(0).getName(), targTagName })).append("
"); + formMsg.append( + i18n.get("message.target.unassigned.one", new Object[] { result.getUnassignedDs().get(0).getName(), + targTagName })).append("
"); } else if (unassignedCount > 1) { formMsg.append(i18n.get("message.target.unassigned.many", new Object[] { unassignedCount, targTagName })) .append("
"); @@ -971,8 +987,8 @@ public final class HawkbitCommonUtil { final BeanQueryFactory queryFactory) { final Map queryConfig = new HashMap(); queryFactory.setQueryConfiguration(queryConfig); - final LazyQueryContainer typeContainer = new LazyQueryContainer( - new LazyQueryDefinition(true, 20, SPUILabelDefinitions.VAR_NAME), queryFactory); + final LazyQueryContainer typeContainer = new LazyQueryContainer(new LazyQueryDefinition(true, 20, + SPUILabelDefinitions.VAR_NAME), queryFactory); return typeContainer; } @@ -1030,10 +1046,10 @@ public final class HawkbitCommonUtil { columnList.add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_BY, i18n.get("header.createdBy"), 0.1f)); columnList .add(new TableColumn(SPUILabelDefinitions.VAR_CREATED_DATE, i18n.get("header.createdDate"), 0.1f)); - columnList.add( - new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1f)); - columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, i18n.get("header.modifiedDate"), + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, i18n.get("header.modifiedBy"), 0.1f)); + columnList.add(new TableColumn(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, + i18n.get("header.modifiedDate"), 0.1f)); columnList.add(new TableColumn(SPUILabelDefinitions.VAR_DESC, i18n.get("header.description"), 0.2f)); } else if (isShowPinColumn) { columnList.add(new TableColumn(SPUILabelDefinitions.VAR_NAME, i18n.get(HEADER_NAME), 0.7f)); @@ -1081,7 +1097,9 @@ public final class HawkbitCommonUtil { */ public static String changeToNewSelectedPreviewColor(final String colorPickedPreview) { final StringBuilder scriptBuilder = new StringBuilder(); - scriptBuilder.append(NEW_PREVIEW_COLOR_REMOVE_SCRIPT).append(NEW_PREVIEW_COLOR_CREATE_SCRIPT) + scriptBuilder + .append(NEW_PREVIEW_COLOR_REMOVE_SCRIPT) + .append(NEW_PREVIEW_COLOR_CREATE_SCRIPT) .append("var newColorPreviewStyle = \".v-app .new-tag-name{ border: solid 3px ") .append(colorPickedPreview) .append(" !important; width:138px; margin-left:2px !important; box-shadow:none !important; } \"; ") @@ -1101,7 +1119,9 @@ public final class HawkbitCommonUtil { */ public static String getPreviewButtonColorScript(final String color) { final StringBuilder scriptBuilder = new StringBuilder(); - scriptBuilder.append(PREVIEW_BUTTON_COLOR_REMOVE_SCRIPT).append(PREVIEW_BUTTON_COLOR_CREATE_SCRIPT) + scriptBuilder + .append(PREVIEW_BUTTON_COLOR_REMOVE_SCRIPT) + .append(PREVIEW_BUTTON_COLOR_CREATE_SCRIPT) .append("var tagColorPreviewStyle = \".v-app .tag-color-preview{ height: 15px !important; padding: 0 10px !important; border: 0px !important; margin-left:12px !important; margin-top: 4px !important; border-width: 0 !important; background: ") .append(color) .append(" } .v-app .tag-color-preview:after{ border-color: none !important; box-shadow:none !important;} \"; ") @@ -1152,4 +1172,100 @@ public final class HawkbitCommonUtil { public static String hideDeleteDropHintScript() { return DELETE_TAG_DROP_REMOVE_SCRIPT; } + + /** + * Get the details of selected rows of {@link TargetTable}. + * + * @param sourceTable + * @return set of {@link TargetIdName} + */ + public static Set getSelectedTargetDetails(final Table sourceTable) { + Set targetSelected = null; + if (sourceTable.getValue() != null) { + targetSelected = new LinkedHashSet<>((Set) sourceTable.getValue()); + targetSelected.remove(null); + } + return targetSelected; + } + + /** + * Get the details of selected rows of {@link DistributionTable}. + * + * @param sourceTable + * @return set of {@link DistributionSetIdName} + */ + public static Set getSelectedDSDetails(final Table sourceTable) { + Set distSelected = null; + if (sourceTable.getValue() != null) { + distSelected = new LinkedHashSet<>((Set) sourceTable.getValue()); + distSelected.remove(null); + } + return distSelected; + } + + /** + * + * Add target table container properties. + * + * @param container + * table container + */ + public static void addTargetTableContainerProperties(final Container container) { + final LazyQueryContainer targetTableContainer = (LazyQueryContainer) container; + targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CONT_ID, String.class, "", false, false); + targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", false, true); + targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_TARGET_STATUS, TargetUpdateStatus.class, + TargetUpdateStatus.UNKNOWN, false, false); + targetTableContainer.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_ID, Long.class, null, + false, false); + targetTableContainer.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_ID, Long.class, null, + false, false); + targetTableContainer.addContainerProperty(SPUILabelDefinitions.ASSIGNED_DISTRIBUTION_NAME_VER, String.class, + "", false, true); + targetTableContainer.addContainerProperty(SPUILabelDefinitions.INSTALLED_DISTRIBUTION_NAME_VER, String.class, + "", false, true); + targetTableContainer.addContainerProperty(SPUILabelDefinitions.LAST_QUERY_DATE, Date.class, null, false, false); + targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_BY, String.class, null, false, true); + targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_BY, String.class, null, false, + true); + targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_CREATED_DATE, String.class, null, false, + true); + targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_LAST_MODIFIED_DATE, String.class, null, + false, true); + targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP, String.class, null, + false, true); + targetTableContainer.addContainerProperty(SPUILabelDefinitions.VAR_DESC, String.class, "", false, true); + } + + /** + * + * Apply style for status label in target table. + * + * @param targetTable + * target table + * @param pinBtn + * pin button used for status display and pin on mouse over + * @param itemId + * id of the tabel row + */ + public static void applyStatusLblStyle(final Table targetTable, final Button pinBtn, final Object itemId) { + final Item item = targetTable.getItem(itemId); + if (item != null) { + final TargetUpdateStatus updateStatus = (TargetUpdateStatus) item.getItemProperty( + SPUILabelDefinitions.VAR_TARGET_STATUS).getValue(); + pinBtn.removeStyleName("statusIconRed statusIconBlue statusIconGreen statusIconYellow statusIconLightBlue"); + if (updateStatus == TargetUpdateStatus.ERROR) { + pinBtn.addStyleName("statusIconRed"); + } else if (updateStatus == TargetUpdateStatus.UNKNOWN) { + pinBtn.addStyleName("statusIconBlue"); + } else if (updateStatus == TargetUpdateStatus.IN_SYNC) { + pinBtn.addStyleName("statusIconGreen"); + } else if (updateStatus == TargetUpdateStatus.PENDING) { + pinBtn.addStyleName("statusIconYellow"); + } else if (updateStatus == TargetUpdateStatus.REGISTERED) { + pinBtn.addStyleName("statusIconLightBlue"); + } + } + } + } diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/I18N.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/I18N.java old mode 100755 new mode 100644 index b274e0f50..cef37085b --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/I18N.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/I18N.java @@ -18,9 +18,7 @@ /** * copied and adapted by Bosch Software Innovations GmbH, Germany. * - * @see https - * ://github.com/peholmst/vaadin4spring/blob/master/spring-vaadin-i18n/src/main/java/org/vaadin - * /spring/i18n/I18N.java + * @see https://github.com/peholmst/vaadin4spring/blob/master/addons/i18n/src/main/java/org/vaadin/spring/i18n/I18N.java */ package org.eclipse.hawkbit.ui.utils; diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/NamingThreadFactory.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/NamingThreadFactory.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/NotificationMessage.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/NotificationMessage.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPDateTimeUtil.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIButtonDefinitions.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIButtonDefinitions.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponetIdProvider.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponetIdProvider.java old mode 100755 new mode 100644 index 9a4bd2faf..170c7ab32 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponetIdProvider.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIComponetIdProvider.java @@ -701,6 +701,22 @@ public final class SPUIComponetIdProvider { */ public static final String CUSTOM_FILTER_TARGET_TABLE_ID = "custom.filter.target.table.id"; + /** + * Bulk upload notification button id. + */ + public static final String BULK_UPLOAD_STATUS_BUTTON = "bulk.upload.notification.id"; + + /** + * Target bulk upload minimize button id. + */ + public static final String BULK_UPLOAD_MINIMIZE_BUTTON_ID = "bulk.upload.minimize.button.id"; + + /** + * Target bulk upload minimize button id. + */ + + public static final String BULK_UPLOAD_CLOSE_BUTTON_ID = "bulk.upload.close.button.id"; + /** * /* Private Constructor. */ diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java old mode 100755 new mode 100644 index 1d9e8a516..4c5958ff1 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIDefinitions.java @@ -12,6 +12,8 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.springframework.data.domain.Sort.Direction; + /** * Class to provide the unchanged constants. * @@ -930,11 +932,6 @@ public final class SPUIDefinitions { */ public static final String BULK_UPLOD_DS_COMBO_STYLE = "bulk-upload-ds-combo"; - /** - * Bulk Targets upload window. - */ - public static final String BULK_UPLOAD_WINDOW = "bulk-update-window"; - /** * Filter by target filter query. */ @@ -945,6 +942,11 @@ public final class SPUIDefinitions { */ public static final String FILTER_BY_INVALID_QUERY = "FilterByInvalidFilterQueryText"; + /** + * Sort order of column - created at in target table. + */ + public static final Direction TARGET_TABLE_CREATE_AT_SORT_ORDER = Direction.ASC; + /** * /** Constructor. */ diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUILabelDefinitions.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUILabelDefinitions.java old mode 100755 new mode 100644 index 5e14b8df1..7a99ca031 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUILabelDefinitions.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUILabelDefinitions.java @@ -106,6 +106,10 @@ public final class SPUILabelDefinitions { * NAME. */ public static final String VAR_NAME = "name"; + /** + * NAME and VERSION. + */ + public static final String VAR_NAME_VERSION = "nameVersion"; /** * Color. */ diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIStyleDefinitions.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIStyleDefinitions.java old mode 100755 new mode 100644 index cffa726a9..ab6b93c39 --- a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIStyleDefinitions.java +++ b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUIStyleDefinitions.java @@ -226,6 +226,11 @@ public final class SPUIStyleDefinitions { */ public static final String ERROR_ICON = "error-icon"; + /** + * Bulk upload progress indicator style. + */ + public static final String BULK_UPLOAD_PROGRESS_INDICATOR_STYLE = "app-loading"; + /** * Constructor. */ diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUITargetDefinitions.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SPUITargetDefinitions.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SpringContextHelper.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/SpringContextHelper.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/TableColumn.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/TableColumn.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/UINotification.java b/hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/UINotification.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/.gitignore b/hawkbit-ui/src/main/resources/VAADIN/.gitignore old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/.gitignore b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/.gitignore old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/accordion.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/accordion.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/action-history.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/action-history.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/artifact-upload.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/artifact-upload.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/colorpicker.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/colorpicker.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/common.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/common.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/dashboardview.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/dashboardview.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/drop-hint.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/drop-hint.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/filter-layout-styles.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/filter-layout-styles.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/filter-status.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/filter-status.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/footer-common.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/footer-common.scss old mode 100755 new mode 100644 index b1944577a..1b58fb0c8 --- a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/footer-common.scss +++ b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/footer-common.scss @@ -28,8 +28,6 @@ .v-icon { color: $hawkbit-primary-color; } - - width: round($action-button-width-scale * $v-unit-size); height: round($action-button-height-scale * $v-unit-size) !important; font-size: $v-font-size--small !important; } @@ -45,7 +43,6 @@ //Upload button style .action-button .v-button { - width: round($action-button-width-scale * $v-unit-size); height: round($action-button-height-scale * $v-unit-size) !important; font-size: $v-font-size--small !important; } @@ -88,4 +85,35 @@ .drop-to-delete-button:active { opacity: 1 !important; } + + + .footer-layout{ + .app-loading { + background-position: bottom; + background-repeat: no-repeat; + } + + .app-loading:before { + background: none; + height: 20px !important; + width: 20px !important; + -webkit-box-sizing: border-box; + -moz-box-sizing: border-box; + box-sizing: border-box; + border: 2px solid rgba(0, 0, 0, 0); + border-top-color: $hawkbit-primary-color; + border-right-color: $hawkbit-primary-color; + border-radius: 100%; + -webkit-animation: v-rotate-360 500ms infinite linear; + -moz-animation: v-rotate-360 500ms infinite linear; + -ms-animation: v-rotate-360 500ms infinite linear; + -o-animation: v-rotate-360 500ms infinite linear; + animation: v-rotate-360 500ms infinite linear; + pointer-events: none; + position: fixed; + margin-top: 12px; + margin-left: -10px; + } + } + } diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/generic-styles.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/generic-styles.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/hawkbitvariables.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/hawkbitvariables.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/login.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/login.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/others.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/others.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/popup-common.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/popup-common.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/popup-window.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/popup-window.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/systemconfig.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/systemconfig.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-common.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-common.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-content.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-content.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-header-common.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table-header-common.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/table.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/tags.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/tags.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/target-filter-query.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/customstyles/target-filter-query.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss old mode 100755 new mode 100644 index 61def6523..87d84f588 --- a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss +++ b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/hawkbittheme.scss @@ -121,5 +121,4 @@ $v-included-components: remove($v-included-components, form); margin-left: -20px; } - } diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/images/lightCorner_selected1.png b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/images/lightCorner_selected1.png old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/images/lightCorner_top.png b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/images/lightCorner_top.png old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/images/profile-pic-300px.jpg b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/images/profile-pic-300px.jpg old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/images/profile-pic-57px.jpg b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/images/profile-pic-57px.jpg old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/layouts/footer.html b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/layouts/footer.html old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/styles.scss b/hawkbit-ui/src/main/resources/VAADIN/themes/hawkbit/styles.scss old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/main/resources/messages.properties b/hawkbit-ui/src/main/resources/messages.properties old mode 100755 new mode 100644 index 7e69f4db8..57b807b01 --- a/hawkbit-ui/src/main/resources/messages.properties +++ b/hawkbit-ui/src/main/resources/messages.properties @@ -8,7 +8,7 @@ # ######################################################################################### -# This is the messages_en.properties file +# This is the messages.properties file ######################################################################################### # Button names prefix with - button @@ -49,7 +49,6 @@ header.dist.twintable.available=Available header.target.installed = Installed header.target.assigned = Assigned - # Captions prefix with - caption caption.action.history = Action history for {0} caption.error = Error @@ -83,7 +82,8 @@ caption.attributes = Attributes caption.panel.dist.installed = Installed distribution set caption.panel.dist.assigned = Assigned distribution set caption.soft.delete.confirmbox = Confirm Software Module Delete Action -caption.cancel.action.confirmbox = Confirm action cancellation +caption.cancel.action.confirmbox = Confirm action cancel +caption.forcequit.action.confirmbox = Confirm force quit action caption.forced.datefield = Force update at time caption.force.action.confirmbox = Confirm Force Active Action @@ -151,7 +151,11 @@ label.target.security.token = Security token : label.filter.by.status = Filter by Status label.target.controller.attrs = Controller attributes label.target.lastpolldate = Last poll : +label.no.tag.assigned = NO TAG label.tag.name = Tag name +label.configuration.auth.header = Allow targets to authenticate via a certificate authenticated by an reverse proxy +label.configuration.auth.gatewaytoken = Allow a gateway to authenticate and manage multiple targets through a gateway security token +label.configuration.auth.targettoken = Allow targets to authenticate directly with their target security token label.unsupported.browser.ie=Sorry! current browser is not supported. Please use Internet Explorer 11 and above # Checkbox label prefix with - checkbox @@ -191,6 +195,7 @@ message.delete.success = {0} deleted successfully message.dist.installedorassigned = Target {targId} is already assigned/installed with distribution message.dist.pending.action = Target {0} is already assigned with distribution {1} . Pending for action message.empty.target.tags= No Tags Created +message.empty.disttype.tags = No Distribution type tags created message.select.row = Please select a row to drag message.error = Unknown error occured during the operation. Please contact administrator message.dist.assigned.one = {0} is assigned to {1} @@ -207,6 +212,7 @@ message.check.softwaremodule = Please provide both name and verion! message.duplicate.softwaremodule = {0} : {1} already exists! message.tag.delete = Please unclick the tag {0}, then try to delete message.dist.type.check.delete = Please unclick the distribution type {0}, then try to delete +message.cannot.delete.default.dstype = Default distribution set type cannot be deleted message.swmodule.type.check.delete = Please unclick the software module type {0}, then try to delete message.targets.already.deleted = Few Target(s) are already deleted.Pending for action message.dists.already.deleted = Few distribution(s) are already deleted.Pending for action @@ -253,7 +259,7 @@ message.sm.delete.confirm = Are you sure that you want to delete the selected {0 message.error.os.softmodule = Please select the OS to delete message.error.ah.softmodule = Please select the Application to delete message.error.softmodule.deleted = The selected software module is already deleted -message.cancel.action = Cancel +message.cancel.action = Cancel.. message.cancel.action.success = Action cancelled successfully ! message.cancel.action.failed = Unable to cancel the action ! message.cancel.action.confirm = Are you sure that you want to cancel this action? @@ -262,16 +268,21 @@ message.dist.alreadyAssigned = {0} Distribution Set(s) were already assigned message.force.action = Force message.force.action.confirm = Are you sure that you want to force this action? message.force.action.success = Action forced successfully ! +message.forcequit.action = Force Quit.. +message.forcequit.action.success = Action has been force quit successfully ! +message.forcequit.action.failed = Force Quitting the action is not possible ! +message.forcequit.action.confirm = Attention!\nForce quit should only be used when the assignment action is not working properly.\nForce quitting an action has no effect on the connected target. It is just resetting \nthe data stored on the SP update server. \nAre you absolutely sure that you want to force quit this action? message.distribution.no.update = distribution {0} set is already assigned to targets and cannot be changed message.action.not.allowed = Action not allowed message.onlyone.distribution.assigned = Only one distribution set can be assigned message.onlyone.distribution.dropallowed = Only one distribution set can be dropped message.error.missing.typename = Missing Type Name message.error.missing.typenameorkey = Missing Type Name or Key or software module type -message.error.missing.typenameorkey = Missing Type Name or Key message.tag.cannot.be.assigned = Target/DS cannot be assigned to {0} message.no.targets.assiged.fortag = No targets are assigned to tag {0} +message.error.missing.tagname = Please select tag name message.type.delete = Please unclick the distribution type {0}, then try to delete +message.error.dist.set.type.update= Distribution Set Type is already assigned to targets and cannot be changed message.target.ds.assign.success = Assignments saved successfully ! message.no.directory.upload = Directory upload is not supported message.delete.filter.confirm = Are you sure that you want to delete custom filter? @@ -280,6 +291,9 @@ message.create.filter.success = Custom filter {0} created Successfully! message.update.filter.success = Custom filter updated Successfully! message.target.filter.validation = Please enter name and query message.target.filter.duplicate = {0} already exists, please enter another value +message.tag.use.bulk.upload = {0} cannot be deleted .It is in use in targets bulk upload +message.bulk.upload.tag.assignment.failed = Tag {0} assignment failed as tag no longer exists +message.bulk.upload.tag.assignments.failed= Few tag assignments failed as tags no longer exists # action info action.target.table.selectall = Select all (Ctrl+A) @@ -302,6 +316,8 @@ message.swModule.deleted = {0} Software module(s) deleted message.upload.failed = Streaming Failed message.uploadedfile.size.exceeded = File size exceeded .Allowed size {0} bytes message.file.not.found = File not found +message.artifact.deleted =Artifact with file {0} deleted successfully + upload.swModuleTable.header = Software module upload.selectedfile.name = file selected for upload @@ -321,7 +337,7 @@ upload.reason = Reason upload.action = Action upload.result.status = Upload status upload.file = Upload File -upload.caption.update.swmodule = Update softwate module +upload.caption.update.swmodule = Update software module caption.tab.details = Details caption.tab.description = Description @@ -346,6 +362,7 @@ message.dist.type.discard.success = All Distribution Types are discarded success message.dist.discard.success = All Distributions are discarded successfully ! message.assign.discard.success = All assignments are discarded successfully ! message.target.ds.assign.success = Assignments saved successfully ! +message.bulk.upload.assignment.failed = Distribution set assignment failed as distribution set no longer exists! # Login view notification.login.title=Welcome to Bosch IoT Software Provisioning. @@ -389,7 +406,6 @@ calendar.minutes=minutes calendar.second=second calendar.seconds=seconds - header.name = Name header.vendor = Vendor header.version = Version @@ -404,14 +420,13 @@ header.installed.ds = Installed DS header.target.status = Status header.target.tags = Tags - - - distribution.details.header = Distribution set target.details.header = Target header.caption.mandatory = Mandatory header.caption.typename = SoftwareModuleType header.caption.softwaremodule = SoftwareModule +header.caption.unassign = Unassign +message.sw.unassigned = Software module {0} successfully unassigned header.caption.upload.details = Upload details combo.type.tag.name = Type tag name @@ -420,4 +435,3 @@ label.no = No #Menu menu.title = Software Provisioning - diff --git a/hawkbit-ui/src/main/resources/messages_de.properties b/hawkbit-ui/src/main/resources/messages_de.properties old mode 100755 new mode 100644 index 35c69240e..ffb753c58 --- a/hawkbit-ui/src/main/resources/messages_de.properties +++ b/hawkbit-ui/src/main/resources/messages_de.properties @@ -207,7 +207,9 @@ message.target.unassigned.many = {0} Targets are unassigned from {1} message.target.assigned.pending = Some target(s) are already assigned.Pending for action message.cannot.delete = Cannot be deleted message.check.softwaremodule = Please provide both name and verion! +message.cannot.delete.default.dstype = Default distribution set type cannot be deleted message.duplicate.softwaremodule = {0} : {1} already exists! +message.cannot.delete.default.dstype = Default distribution set type cannot be deleted message.tag.delete = Please unclick the tag {0}, then try to delete message.dist.type.check.delete = Please unclick the distribution type {0}, then try to delete message.swmodule.type.check.delete = Please unclick the software module type {0}, then try to delete @@ -285,6 +287,9 @@ message.create.filter.success = Custom filter {0} created Successfully! message.update.filter.success = Custom filter updated Successfully! message.target.filter.validation = Please enter name and query message.target.filter.duplicate = {0} already exists, please enter another value +message.tag.use.bulk.upload = {0} cannot be deleted .It is in use in targets bulk upload +message.bulk.upload.tag.assignment.failed = Tag {0} assignment failed as tag no longer exists +message.bulk.upload.tag.assignments.failed= Few tag assignments failed as tags no longer exists # action info action.target.table.selectall = Select all (Ctrl+A) @@ -308,6 +313,8 @@ message.error.missing.tagname = Please select tag name message.upload.failed = Streaming Failed message.uploadedfile.size.exceeded = File size exceeded .Allowed size {0} bytes message.file.not.found = File not found +message.artifact.deleted =Artifact with file {0} deleted successfully + upload.swModuleTable.header = Software module upload.selectedfile.name = file selected for upload @@ -346,6 +353,7 @@ message.sw.module.type.delete = {0} Software Module Type(s) deleted successfully message.dist.type.discard.success = All Distribution Types are discarded successfully ! message.dist.discard.success = All Distributions are discarded successfully ! message.assign.discard.success = All assignments are discarded successfully ! +message.bulk.upload.assignment.failed = Distribution set assignment failed as distribution set no longer exists! # Login view notification.login.title=Welcome to Bosch IoT Software Provisioning. @@ -403,6 +411,8 @@ target.details.header = Target header.caption.mandatory = Mandatory header.caption.typename = SoftwareModuleType header.caption.softwaremodule = SoftwareModule +header.caption.unassign = Unassign +message.sw.unassigned = Software module {0} successfully unassigned header.caption.upload.details = Upload details combo.type.tag.name = Type tag name diff --git a/hawkbit-ui/src/main/resources/messages_en.properties b/hawkbit-ui/src/main/resources/messages_en.properties old mode 100755 new mode 100644 index 678f2cf82..32e7cf0e2 --- a/hawkbit-ui/src/main/resources/messages_en.properties +++ b/hawkbit-ui/src/main/resources/messages_en.properties @@ -82,7 +82,8 @@ caption.attributes = Attributes caption.panel.dist.installed = Installed distribution set caption.panel.dist.assigned = Assigned distribution set caption.soft.delete.confirmbox = Confirm Software Module Delete Action -caption.cancel.action.confirmbox = Confirm action cancellation +caption.cancel.action.confirmbox = Confirm action cancel +caption.forcequit.action.confirmbox = Confirm force quit action caption.forced.datefield = Force update at time caption.force.action.confirmbox = Confirm Force Active Action @@ -126,12 +127,13 @@ label.filter = Filter: label.target.filter.count = Total Targets: label.filter.selected = Selected: label.filter.shown = Shown: +label.filter.targets = Filtered targets : label.filter.status = Status, label.filter.tags = Tags, label.filter.text = Search Text label.filter.dist = Distribution, label.filter.custom = Custom -label.target.filter.truncated={0} targets has been truncated in the list due the target size limit of {1}, use filters to reduce the targets to be shown +label.target.filter.truncated={0} targets has been truncated in the list due the target size limit of {1}, use filters to reduce the targets to be shown label.active =Active label.inactive = In-active label.finished = Finished @@ -142,6 +144,7 @@ label.cancelled = Cancelled label.cancelling = Canceling label.retrieved = Retrieved label.download = Downloading +label.unknown = Unknown label.target.id = Controller Id : label.target.ip = Controller IP : label.target.security.token = Security token : @@ -207,8 +210,10 @@ message.target.assigned.pending = Some target(s) are already assigned.Pending f message.cannot.delete = Cannot be deleted message.check.softwaremodule = Please provide both name and verion! message.duplicate.softwaremodule = {0} : {1} already exists! +message.cannot.delete.default.dstype = Default distribution set type cannot be deleted message.tag.delete = Please unclick the tag {0}, then try to delete message.dist.type.check.delete = Please unclick the distribution type {0}, then try to delete +message.cannot.delete.default.dstype = Default distribution set type cannot be deleted message.swmodule.type.check.delete = Please unclick the software module type {0}, then try to delete message.targets.already.deleted = Few Target(s) are already deleted.Pending for action message.dists.already.deleted = Few distribution(s) are already deleted.Pending for action @@ -255,7 +260,7 @@ message.sm.delete.confirm = Are you sure that you want to delete the selected {0 message.error.os.softmodule = Please select the OS to delete message.error.ah.softmodule = Please select the Application to delete message.error.softmodule.deleted = The selected software module is already deleted -message.cancel.action = Cancel +message.cancel.action = Cancel.. message.cancel.action.success = Action cancelled successfully ! message.cancel.action.failed = Unable to cancel the action ! message.cancel.action.confirm = Are you sure that you want to cancel this action? @@ -264,6 +269,10 @@ message.dist.alreadyAssigned = {0} Distribution Set(s) were already assigned message.force.action = Force message.force.action.confirm = Are you sure that you want to force this action? message.force.action.success = Action forced successfully ! +message.forcequit.action = Force Quit.. +message.forcequit.action.success = Action has been force quit successfully ! +message.forcequit.action.failed = Force Quitting the action is not possible ! +message.forcequit.action.confirm = Attention!\nForce quit should only be used when the assignment action is not working properly.\nForce quitting an action has no effect on the connected target. It is just resetting \nthe data stored on the SP update server. \nAre you absolutely sure that you want to force quit this action? message.distribution.no.update = distribution {0} set is already assigned to targets and cannot be changed message.action.not.allowed = Action not allowed message.onlyone.distribution.assigned = Only one distribution set can be assigned @@ -277,13 +286,15 @@ message.type.delete = Please unclick the distribution type {0}, then try to dele message.error.dist.set.type.update= Distribution Set Type is already assigned to targets and cannot be changed message.target.ds.assign.success = Assignments saved successfully ! message.no.directory.upload = Directory upload is not supported - message.delete.filter.confirm = Are you sure that you want to delete custom filter? message.delete.filter.success = Custom filter {0} deleted Successfully! message.create.filter.success = Custom filter {0} created Successfully! message.update.filter.success = Custom filter updated Successfully! message.target.filter.validation = Please enter name and query message.target.filter.duplicate = {0} already exists, please enter another value +message.tag.use.bulk.upload = {0} cannot be deleted .It is in use in targets bulk upload +message.bulk.upload.tag.assignment.failed = Tag {0} assignment failed as tag no longer exists +message.bulk.upload.tag.assignments.failed= Few tag assignments failed as tags no longer exists # action info action.target.table.selectall = Select all (Ctrl+A) @@ -306,6 +317,8 @@ message.swModule.deleted = {0} Software module(s) deleted message.upload.failed = Streaming Failed message.uploadedfile.size.exceeded = File size exceeded .Allowed size {0} bytes message.file.not.found = File not found +message.artifact.deleted =Artifact with file {0} deleted successfully + upload.swModuleTable.header = Software module upload.selectedfile.name = file selected for upload @@ -331,9 +344,13 @@ caption.tab.description = Description caption.delete.artifact.confirmbox = Confirm Artifact Delete Action +custom.filter.name = Filter Name +custom.filter.created.by = Created By +custom.created.date = Created Date #Manage distributions view label.drop.dist.delete.area = Drop here
to delete +label.no.tag.assigned = NO TAG caption.assign.software.dist.accordion.tab = Assign Software Modules message.software.assignment = {0} Software Module(s) Assignment(s) done message.dist.inuse = {0} Distribution is already assigned to target @@ -345,6 +362,8 @@ message.sw.module.type.delete = {0} Software Module Type(s) deleted successfully message.dist.type.discard.success = All Distribution Types are discarded successfully ! message.dist.discard.success = All Distributions are discarded successfully ! message.assign.discard.success = All assignments are discarded successfully ! +message.bulk.upload.assignment.failed = Distribution set assignment failed as distribution set no longer exists! +message.target.ds.assign.success = Assignments saved successfully ! # Login view notification.login.title=Welcome to Bosch IoT Software Provisioning. @@ -396,17 +415,24 @@ header.createdBy = Created By header.createdDate = Created Date header.modifiedBy = Modified By header.modifiedDate = Modified Date +header.delete = Delete +header.assigned.ds = Assigned DS +header.installed.ds = Installed DS +header.target.status = Status +header.target.tags = Tags distribution.details.header = Distribution set target.details.header = Target header.caption.mandatory = Mandatory header.caption.typename = SoftwareModuleType header.caption.softwaremodule = SoftwareModule +header.caption.unassign = Unassign +message.sw.unassigned = Software module {0} successfully unassigned header.caption.upload.details = Upload details combo.type.tag.name = Type tag name label.yes = Yes -label.no =No +label.no = No #Menu menu.title = Software Provisioning diff --git a/hawkbit-ui/src/test/java/org/eclipse/hawkbit/push/SpringSecurityAtmosphereInterceptorTest.java b/hawkbit-ui/src/test/java/org/eclipse/hawkbit/push/SpringSecurityAtmosphereInterceptorTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/NamingThreadFactoryTest.java b/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/NamingThreadFactoryTest.java old mode 100755 new mode 100644 diff --git a/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/SPUIComponentProviderTest.java b/hawkbit-ui/src/test/java/org/eclipse/hawkbit/ui/utils/SPUIComponentProviderTest.java old mode 100755 new mode 100644 diff --git a/pom.xml b/pom.xml old mode 100755 new mode 100644 index aa4807446..f29123763 --- a/pom.xml +++ b/pom.xml @@ -44,23 +44,11 @@ - scm:git:https://github.com/bsinno/hawkbit-update-server.git - scm:git:https://github.com/bsinno/hawkbit-update-server.git - https://github.com/bsinno/hawkbit-update-server.git + scm:git:https://github.com/eclipse/hawkbit.git + scm:git:https://github.com/eclipse/hawkbit.git + https://github.com/eclipse/hawkbit.git - - - sp-snapshots - false - https://repo.bosch-si.com/content/repositories/sp-snapshots - - - sp-releases - https://repo.bosch-si.com/content/repositories/sp-releases - - - vaadin-addons @@ -128,6 +116,7 @@ ${jacoco.outputDir}/${jacoco.out.it.file} + 19.0 @@ -354,10 +343,9 @@ vaadin-push ${vaadin.version} - + com.vaadin vaadin-client-compiler @@ -415,17 +403,6 @@ jlorem 1.1 - - - io.springfox - springfox-swagger2 - 2.0.3 - - - io.swagger - swagger-annotations - 1.5.0 - org.springframework.boot @@ -506,8 +483,7 @@ - + com.fasterxml classmate @@ -619,6 +595,11 @@ 1.2.3 test + + com.google.guava + guava + ${guava.version} + diff --git a/sonarCircleCi.sh b/sonarCircleCi.sh old mode 100755 new mode 100644 index 5167d1724..ec3f31f91 --- a/sonarCircleCi.sh +++ b/sonarCircleCi.sh @@ -15,7 +15,6 @@ if [ "$CIRCLE_BRANCH" = "master" ]; then else if [ -n "$CI_PULL_REQUEST" ]; then mvn org.jacoco:jacoco-maven-plugin:prepare-agent verify license:check sonar:sonar -B -e -V \ - -Dmaven.test.failure.ignore=true \ -Dclirr=true \ -Dsonar.analysis.mode=issues \ -Dsonar.github.pullRequest=`echo $CI_PULL_REQUEST| awk -F'/' '{print $7}'` \