├── .env ├── .gitignore ├── APIChanges.md ├── CHANGELOG.md ├── Jenkinsfile ├── LICENSE ├── README.md ├── devicehive-auth ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── devicehive │ │ │ ├── application │ │ │ ├── AuthProxyClientConfig.java │ │ │ ├── AuthRpcClientConfig.java │ │ │ ├── DeviceHiveAuthApplication.java │ │ │ ├── JerseyConfig.java │ │ │ ├── filter │ │ │ │ ├── ContentTypeFilter.java │ │ │ │ └── SwaggerFilter.java │ │ │ └── security │ │ │ │ ├── MethodSecurityConfig.java │ │ │ │ └── WebSecurityConfig.java │ │ │ ├── proxy │ │ │ └── AuthProxyClient.java │ │ │ ├── resource │ │ │ ├── AuthApiInfoResource.java │ │ │ ├── JwtTokenResource.java │ │ │ └── impl │ │ │ │ ├── AuthApiInfoResourceImpl.java │ │ │ │ └── JwtTokenResourceImpl.java │ │ │ └── service │ │ │ └── security │ │ │ └── jwt │ │ │ ├── JwtClientService.java │ │ │ └── JwtTokenService.java │ └── resources │ │ ├── application.properties │ │ ├── logback.xml │ │ ├── messages.properties │ │ ├── messages_en_EN.properties │ │ └── public │ │ └── swagger.html │ └── test │ ├── java │ └── com │ │ └── devicehive │ │ ├── base │ │ └── AuthAbstractResourceTest.java │ │ ├── resource │ │ └── JwtTokenResourceTest.java │ │ └── service │ │ └── JwtClientServiceTest.java │ └── resources │ ├── application-test.properties │ ├── initial_data.sql │ └── logback.xml ├── devicehive-backend ├── LICENSE ├── missing-license.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── devicehive │ │ │ ├── application │ │ │ ├── BackendConfig.java │ │ │ ├── DeviceHiveBackendApplication.java │ │ │ ├── RedisConfiguration.java │ │ │ └── RequestHandlersMapper.java │ │ │ ├── eventbus │ │ │ └── EventBus.java │ │ │ ├── messages │ │ │ └── handler │ │ │ │ ├── DeviceDeleteHandler.java │ │ │ │ ├── PluginSubscribeRequestHandler.java │ │ │ │ ├── PluginUnsubscribeRequestHandler.java │ │ │ │ ├── RequestDispatcher.java │ │ │ │ ├── command │ │ │ │ ├── CommandInsertHandler.java │ │ │ │ ├── CommandSearchHandler.java │ │ │ │ ├── CommandSubscribeRequestHandler.java │ │ │ │ ├── CommandUnsubscribeRequestHandler.java │ │ │ │ ├── CommandUpdateHandler.java │ │ │ │ ├── CommandUpdateSubscribeRequestHandler.java │ │ │ │ └── CommandsUpdateHandler.java │ │ │ │ ├── dao │ │ │ │ ├── count │ │ │ │ │ ├── CountDeviceHandler.java │ │ │ │ │ ├── CountDeviceTypeHandler.java │ │ │ │ │ ├── CountNetworkHandler.java │ │ │ │ │ ├── CountPluginHandler.java │ │ │ │ │ └── CountUserHandler.java │ │ │ │ └── list │ │ │ │ │ ├── ListDeviceHandler.java │ │ │ │ │ ├── ListDeviceTypeHandler.java │ │ │ │ │ ├── ListNetworkHandler.java │ │ │ │ │ ├── ListPluginHandler.java │ │ │ │ │ └── ListUserHandler.java │ │ │ │ └── notification │ │ │ │ ├── NotificationInsertHandler.java │ │ │ │ ├── NotificationSearchHandler.java │ │ │ │ ├── NotificationSubscribeRequestHandler.java │ │ │ │ └── NotificationUnsubscribeRequestHandler.java │ │ │ └── service │ │ │ ├── cache │ │ │ ├── CacheService.java │ │ │ ├── command │ │ │ │ ├── CommandCacheService.java │ │ │ │ └── CommandRedisCacheService.java │ │ │ └── notification │ │ │ │ ├── NotificationCacheService.java │ │ │ │ └── NotificationRedisCacheService.java │ │ │ └── helpers │ │ │ └── CommandResponseFilterAndSort.java │ └── resources │ │ ├── application.properties │ │ ├── logback.xml │ │ ├── messages.properties │ │ └── messages_en_EN.properties │ └── test │ ├── java │ └── com │ │ └── devicehive │ │ ├── BackendSmokeTest.java │ │ └── base │ │ ├── AbstractSpringTest.java │ │ ├── CommandTestUtils.java │ │ └── NotificationTestUtils.java │ └── resources │ ├── application-test.properties │ └── logback.xml ├── devicehive-common-dao ├── LICENSE ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── devicehive │ ├── dao │ ├── ConfigurationDao.java │ ├── DeviceDao.java │ ├── DeviceTypeDao.java │ ├── NetworkDao.java │ ├── PluginDao.java │ └── UserDao.java │ └── exceptions │ └── HivePersistenceLayerException.java ├── devicehive-common-service ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── devicehive │ ├── auth │ ├── HiveAuthentication.java │ ├── JwtCheckPermissionsHelper.java │ ├── JwtPermissionEvaluator.java │ └── rest │ │ ├── HttpAuthenticationFilter.java │ │ ├── SimpleCORSFilter.java │ │ └── providers │ │ ├── HiveAnonymousAuthenticationProvider.java │ │ └── JwtTokenAuthenticationProvider.java │ ├── model │ └── ErrorResponse.java │ ├── resource │ ├── BaseApiInfoResource.java │ ├── converters │ │ ├── CollectionProvider.java │ │ ├── HiveEntityProvider.java │ │ ├── JsonPolicyProvider.java │ │ └── JsonRawProvider.java │ ├── exceptions │ │ ├── AccessDeniedExceptionMapper.java │ │ ├── ActionNotAllowedExceptionMapper.java │ │ ├── AllExceptionMapper.java │ │ ├── BadCredentialsExceptionMapper.java │ │ ├── ConstraintViolationExceptionMapper.java │ │ ├── ExpiredTokenException.java │ │ ├── HibernateConstraintViolationsMapper.java │ │ ├── HiveExceptionMapper.java │ │ ├── IllegalParametersExceptionMapper.java │ │ ├── InvalidPrincipalExceptionMapper.java │ │ ├── JsonParseExceptionMapper.java │ │ ├── NoSuchElementExceptionMapper.java │ │ ├── OptimisticLockExceptionMapper.java │ │ └── PersistenceExceptionMapper.java │ ├── filter │ │ └── ReplacePostMethodFilter.java │ ├── impl │ │ └── BaseApiInfoResourceImpl.java │ └── util │ │ └── ResponseFactory.java │ ├── security │ └── util │ │ ├── JwtPluginTokenGenerator.java │ │ ├── JwtSecretService.java │ │ └── JwtTokenGenerator.java │ ├── service │ ├── BaseDeviceService.java │ ├── BaseDeviceTypeService.java │ ├── BaseFilterService.java │ ├── BaseNetworkService.java │ ├── BaseUserService.java │ ├── PluginService.java │ ├── configuration │ │ └── ConfigurationService.java │ ├── exception │ │ └── BackendException.java │ ├── helpers │ │ ├── DefaultPasswordProcessor.java │ │ ├── HttpRestHelper.java │ │ ├── LongIdGenerator.java │ │ ├── PasswordProcessor.java │ │ ├── ResponseConsumer.java │ │ └── TimestampLongIdGenerator.java │ ├── security │ │ └── jwt │ │ │ └── BaseJwtClientService.java │ └── time │ │ ├── LocalTimestampService.java │ │ └── TimestampService.java │ ├── util │ ├── HiveMessageFormatter.java │ └── HiveValidator.java │ └── vo │ ├── ApiInfoVO.java │ ├── JwtAccessTokenVO.java │ ├── JwtRefreshTokenVO.java │ ├── JwtRequestVO.java │ └── JwtTokenVO.java ├── devicehive-common ├── LICENSE ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── devicehive │ ├── ApplicationContextHolder.java │ ├── api │ ├── HandlersMapper.java │ └── RequestResponseMatcher.java │ ├── auth │ ├── HiveAction.java │ ├── HivePrincipal.java │ └── HiveRoles.java │ ├── configuration │ ├── Constants.java │ └── Messages.java │ ├── exceptions │ ├── ActionNotAllowedException.java │ ├── HiveException.java │ ├── IllegalParametersException.java │ └── InvalidPrincipalException.java │ ├── json │ ├── GsonFactory.java │ ├── adapters │ │ ├── JsonDbObjectAdapter.java │ │ ├── JsonStringWrapperAdapterFactory.java │ │ ├── OptionalAdapterFactory.java │ │ ├── RuntimeTypeAdapterFactory.java │ │ ├── TimestampAdapter.java │ │ ├── UserRoleAdapter.java │ │ └── UserStatusAdapter.java │ └── strategies │ │ ├── AnnotatedStrategy.java │ │ ├── JsonPolicyApply.java │ │ └── JsonPolicyDef.java │ ├── model │ ├── CacheEntity.java │ ├── DeviceCommand.java │ ├── DeviceNotification.java │ ├── HiveEntity.java │ ├── JsonStringWrapper.java │ ├── ServerEvent.java │ ├── SubscriptionInfo.java │ ├── converters │ │ ├── SetHelper.java │ │ └── TimestampQueryParamParser.java │ ├── enums │ │ ├── PluginStatus.java │ │ ├── SearchableField.java │ │ ├── SortOrder.java │ │ ├── UserRole.java │ │ └── UserStatus.java │ ├── eventbus │ │ ├── Filter.java │ │ ├── FilterRegistry.java │ │ ├── SubscribeAction.java │ │ ├── SubscribeMessage.java │ │ ├── Subscriber.java │ │ └── events │ │ │ ├── CommandEvent.java │ │ │ ├── CommandUpdateEvent.java │ │ │ ├── CommandsUpdateEvent.java │ │ │ ├── Event.java │ │ │ └── NotificationEvent.java │ ├── response │ │ ├── EntityCountResponse.java │ │ ├── UserDeviceTypeResponse.java │ │ ├── UserNetworkResponse.java │ │ └── UserResponse.java │ ├── rpc │ │ ├── BasePluginRequest.java │ │ ├── CommandInsertRequest.java │ │ ├── CommandInsertResponse.java │ │ ├── CommandSearchRequest.java │ │ ├── CommandSearchResponse.java │ │ ├── CommandSubscribeRequest.java │ │ ├── CommandSubscribeResponse.java │ │ ├── CommandUnsubscribeRequest.java │ │ ├── CommandUnsubscribeResponse.java │ │ ├── CommandUpdateRequest.java │ │ ├── CommandUpdateSubscribeRequest.java │ │ ├── CommandUpdateSubscribeResponse.java │ │ ├── CommandsUpdateRequest.java │ │ ├── CountDeviceRequest.java │ │ ├── CountDeviceTypeRequest.java │ │ ├── CountNetworkRequest.java │ │ ├── CountPluginRequest.java │ │ ├── CountResponse.java │ │ ├── CountUserRequest.java │ │ ├── DeviceDeleteRequest.java │ │ ├── DeviceDeleteResponse.java │ │ ├── ErrorResponse.java │ │ ├── ListDeviceRequest.java │ │ ├── ListDeviceResponse.java │ │ ├── ListDeviceTypeRequest.java │ │ ├── ListDeviceTypeResponse.java │ │ ├── ListNetworkRequest.java │ │ ├── ListNetworkResponse.java │ │ ├── ListPluginRequest.java │ │ ├── ListPluginResponse.java │ │ ├── ListUserRequest.java │ │ ├── ListUserResponse.java │ │ ├── NotificationInsertRequest.java │ │ ├── NotificationInsertResponse.java │ │ ├── NotificationSearchRequest.java │ │ ├── NotificationSearchResponse.java │ │ ├── NotificationSubscribeRequest.java │ │ ├── NotificationSubscribeResponse.java │ │ ├── NotificationUnsubscribeRequest.java │ │ ├── NotificationUnsubscribeResponse.java │ │ ├── PluginSubscribeRequest.java │ │ ├── PluginSubscribeResponse.java │ │ ├── PluginUnsubscribeRequest.java │ │ └── PluginUnsubscribeResponse.java │ └── updates │ │ ├── ConfigurationUpdate.java │ │ ├── DeviceCommandUpdate.java │ │ ├── DeviceTypeUpdate.java │ │ ├── DeviceUpdate.java │ │ ├── NetworkUpdate.java │ │ ├── PluginUpdate.java │ │ └── UserUpdate.java │ ├── security │ └── jwt │ │ ├── JwtPayload.java │ │ ├── JwtPluginPayload.java │ │ ├── JwtUserPayload.java │ │ ├── JwtUserPayloadView.java │ │ └── TokenType.java │ └── vo │ ├── ConfigurationVO.java │ ├── DeviceTypeVO.java │ ├── DeviceTypeWithUsersAndDevicesVO.java │ ├── DeviceVO.java │ ├── NetworkVO.java │ ├── NetworkWithUsersAndDevicesVO.java │ ├── PluginVO.java │ ├── UserVO.java │ ├── UserWithDeviceTypeVO.java │ └── UserWithNetworkVO.java ├── devicehive-frontend ├── LICENSE ├── missing-license.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── devicehive │ │ │ ├── application │ │ │ ├── DeviceHiveFrontendApplication.java │ │ │ ├── JerseyConfig.java │ │ │ ├── WebSocketConfig.java │ │ │ ├── filter │ │ │ │ ├── ContentTypeFilter.java │ │ │ │ └── SwaggerFilter.java │ │ │ └── security │ │ │ │ ├── MethodSecurityConfig.java │ │ │ │ └── WebSecurityConfig.java │ │ │ ├── auth │ │ │ └── websockets │ │ │ │ ├── HiveWebsocketAuth.java │ │ │ │ └── WebSocketActionAuthenticationAspect.java │ │ │ ├── messages │ │ │ └── handler │ │ │ │ ├── AsyncResponseClientHandler.java │ │ │ │ ├── ClientHandler.java │ │ │ │ └── WebSocketClientHandler.java │ │ │ ├── model │ │ │ ├── SpecialNotifications.java │ │ │ ├── websockets │ │ │ │ ├── InsertCommand.java │ │ │ │ └── InsertNotification.java │ │ │ └── wrappers │ │ │ │ ├── DeviceCommandWrapper.java │ │ │ │ └── DeviceNotificationWrapper.java │ │ │ ├── resource │ │ │ ├── ApiInfoResource.java │ │ │ ├── ConfigurationResource.java │ │ │ ├── DeviceCommandResource.java │ │ │ ├── DeviceNotificationResource.java │ │ │ ├── DeviceResource.java │ │ │ ├── DeviceTypeResource.java │ │ │ ├── NetworkResource.java │ │ │ ├── UserResource.java │ │ │ ├── WelcomeResource.java │ │ │ ├── impl │ │ │ │ ├── ApiInfoResourceImpl.java │ │ │ │ ├── ConfigurationResourceImpl.java │ │ │ │ ├── DeviceCommandResourceImpl.java │ │ │ │ ├── DeviceNotificationResourceImpl.java │ │ │ │ ├── DeviceResourceImpl.java │ │ │ │ ├── DeviceTypeResourceImpl.java │ │ │ │ ├── NetworkResourceImpl.java │ │ │ │ ├── UserResourceImpl.java │ │ │ │ └── WelcomeResourceImpl.java │ │ │ └── util │ │ │ │ └── JsonTypes.java │ │ │ ├── service │ │ │ ├── DeviceCommandService.java │ │ │ ├── DeviceNotificationService.java │ │ │ ├── DeviceService.java │ │ │ ├── DeviceTypeService.java │ │ │ ├── NetworkService.java │ │ │ ├── SubscriptionService.java │ │ │ └── UserService.java │ │ │ ├── util │ │ │ ├── ServerResponsesFactory.java │ │ │ └── ThreadLocalVariablesKeeper.java │ │ │ ├── vo │ │ │ ├── CacheInfoVO.java │ │ │ └── ClusterConfigVO.java │ │ │ └── websockets │ │ │ ├── DeviceHiveWebSocketHandler.java │ │ │ ├── HiveWebsocketSessionState.java │ │ │ ├── WebSocketAuthenticationManager.java │ │ │ ├── WebSocketRequestProcessor.java │ │ │ ├── converters │ │ │ ├── JsonMessageBuilder.java │ │ │ └── WebSocketResponse.java │ │ │ ├── events │ │ │ └── WSMessageEvent.java │ │ │ ├── handlers │ │ │ ├── ApiInfoHandlers.java │ │ │ ├── CommandHandlers.java │ │ │ ├── CommonHandlers.java │ │ │ ├── ConfigurationHandlers.java │ │ │ ├── DeviceHandlers.java │ │ │ ├── DeviceTypeHandlers.java │ │ │ ├── NetworkHandlers.java │ │ │ ├── NotificationHandlers.java │ │ │ ├── SubscriptionHandlers.java │ │ │ └── UserHandlers.java │ │ │ └── util │ │ │ └── SessionMonitor.java │ └── resources │ │ ├── application.properties │ │ ├── logback.xml │ │ ├── messages.properties │ │ ├── messages_en_EN.properties │ │ └── public │ │ └── swagger.html │ └── test │ ├── java │ └── com │ │ └── devicehive │ │ ├── FrontendSmokeTest.java │ │ └── base │ │ ├── AbstractResourceTest.java │ │ ├── AbstractSpringKafkaTest.java │ │ ├── RequestDispatcherProxy.java │ │ ├── fixture │ │ └── DeviceFixture.java │ │ └── matcher │ │ └── HiveExceptionMatcher.java │ └── resources │ ├── application-test.properties │ ├── initial_data.sql │ └── logback.xml ├── devicehive-plugin ├── LICENSE ├── missing-license.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── devicehive │ │ │ ├── application │ │ │ ├── DeviceHivePluginApplication.java │ │ │ ├── JerseyConfig.java │ │ │ ├── PluginProxyClientConfig.java │ │ │ ├── PluginRpcClientConfig.java │ │ │ ├── filter │ │ │ │ ├── ContentTypeFilter.java │ │ │ │ └── SwaggerFilter.java │ │ │ └── security │ │ │ │ ├── MethodSecurityConfig.java │ │ │ │ └── WebSecurityConfig.java │ │ │ ├── model │ │ │ ├── FilterEntity.java │ │ │ └── query │ │ │ │ ├── PluginReqisterQuery.java │ │ │ │ └── PluginUpdateQuery.java │ │ │ ├── proxy │ │ │ ├── PluginProxyClient.java │ │ │ └── ProxyResponseHandler.java │ │ │ ├── resource │ │ │ ├── PluginApiInfoResource.java │ │ │ ├── PluginResource.java │ │ │ ├── impl │ │ │ │ ├── PluginApiInfoResourceImpl.java │ │ │ │ └── PluginResourceImpl.java │ │ │ └── util │ │ │ │ └── JsonTypes.java │ │ │ ├── service │ │ │ ├── FilterService.java │ │ │ ├── KafkaWsTopicService.java │ │ │ └── PluginRegisterService.java │ │ │ └── util │ │ │ ├── ServerResponsesFactory.java │ │ │ └── ThreadLocalVariablesKeeper.java │ └── resources │ │ ├── application.properties │ │ ├── logback.xml │ │ ├── messages.properties │ │ ├── messages_en_EN.properties │ │ └── public │ │ └── swagger.html │ └── test │ ├── java │ └── com │ │ └── devicehive │ │ └── service │ │ └── PluginRegisterServiceTest.java │ └── resources │ ├── logback.xml │ └── mockito-extensions │ └── org.mockito.plugins.MockMaker ├── devicehive-proxy-api ├── LICENSE ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── devicehive │ └── proxy │ └── api │ ├── NotificationHandler.java │ ├── ProxyClient.java │ ├── ProxyMessage.java │ ├── ProxyMessageBuilder.java │ └── payload │ ├── HealthPayload.java │ ├── MessagePayload.java │ ├── NotificationCreatePayload.java │ ├── Payload.java │ ├── SubscribePayload.java │ └── TopicsPayload.java ├── devicehive-proxy-ws-kafka-impl ├── LICENSE ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── devicehive │ │ └── proxy │ │ ├── FrontendProxyClient.java │ │ ├── ProxyMessageDispatcher.java │ │ ├── ProxyRequestHandler.java │ │ ├── ProxyResponseHandler.java │ │ ├── ProxyServerEventHandler.java │ │ ├── WebSocketApplication.java │ │ ├── client │ │ ├── GsonProxyMessageDecoder.java │ │ ├── GsonProxyMessageEncoder.java │ │ └── WebSocketKafkaProxyClient.java │ │ ├── config │ │ ├── BackendProxyClientConfig.java │ │ ├── FrontendProxyClientConfig.java │ │ └── WebSocketKafkaProxyConfig.java │ │ └── eventbus │ │ └── DistributedProxyFilterRegistry.java │ └── resources │ └── kafka-ws-proxy.properties ├── devicehive-rdbms-dao ├── LICENSE ├── missing-license.properties ├── pom.xml └── src │ └── main │ ├── java │ └── com │ │ └── devicehive │ │ ├── application │ │ └── RdbmsPersistenceConfig.java │ │ ├── dao │ │ └── rdbms │ │ │ ├── CacheConfig.java │ │ │ ├── CacheHelper.java │ │ │ ├── ConfigurationDaoRdbmsImpl.java │ │ │ ├── CriteriaHelper.java │ │ │ ├── DeviceDaoRdbmsImpl.java │ │ │ ├── DeviceTypeDaoRdbmsImpl.java │ │ │ ├── NetworkDaoRdbmsImpl.java │ │ │ ├── PluginDaoRdbmsImpl.java │ │ │ ├── RdbmsGenericDao.java │ │ │ └── UserDaoRdbmsImpl.java │ │ └── model │ │ ├── Configuration.java │ │ ├── Device.java │ │ ├── DeviceType.java │ │ ├── Network.java │ │ ├── Plugin.java │ │ └── User.java │ └── resources │ ├── application-persistence.properties │ ├── application-test-configuration.properties │ ├── db │ └── migration │ │ ├── V1_3__schema.sql │ │ ├── V1__initial_schema.sql │ │ ├── V2_0_10__drop_oauth_server_tables.sql │ │ ├── V2_0_11__drop_access_key_tables.sql │ │ ├── V2_0_2__delete_db_timestamp.sql │ │ ├── V2_0_3__102_make_key_nullable.sql │ │ ├── V2_0_4__remove_device_key.sql │ │ ├── V2_0_5__configuration_table_changes.sql │ │ ├── V2_0_6__identity_provider_name_as_key.sql │ │ ├── V2_0_7__device_class_version_remove.sql │ │ ├── V2_0_8__set_allow_network_autrocreate_and_add_default_user_to_network.sql │ │ ├── V2_0_9__update_facebook_api_endpoint.sql │ │ ├── V3_0_10__drop_network_auto_creation.sql │ │ ├── V3_0_11__drop_user_anonymous_create_configuration.sql │ │ ├── V3_0_12__drop_network_key.sql │ │ ├── V3_0_13__rename_device_guid_into_id.sql │ │ ├── V3_0_14__drop_deleted_user_status.sql │ │ ├── V3_0_1__drop_device_status_and_device_class_offline_timeout.sql │ │ ├── V3_0_2__set_user_anonymous_create_configuration.sql │ │ ├── V3_0_3__delete_oauth_columns.sql │ │ ├── V3_0_4__drop_device_equipment_table.sql │ │ ├── V3_0_5__drop_equipment_table.sql │ │ ├── V3_0_6__configuration_table_update.sql │ │ ├── V3_0_7__drop_identity_provider.sql │ │ ├── V3_0_8__drop_device_class.sql │ │ ├── V3_0_9__add_intro_reviewed_column.sql │ │ ├── V3_1_1__update_default_network_device.sql │ │ ├── V3_1_2__alter_user_table_name.sql │ │ ├── V3_4_10__alter_plugin_table_constraints.sql │ │ ├── V3_4_11__alter_plugin_table_name_constraint.sql │ │ ├── V3_4_12__recreate_configuration_table_id_added.sql │ │ ├── V3_4_1__create_plugin_table.sql │ │ ├── V3_4_3__delete_plugin_health_check_url_column.sql │ │ ├── V3_4_4__add_device_type_table.sql │ │ ├── V3_4_5__add_all_device_types_available_column.sql │ │ ├── V3_4_6__add_default_device_type_to_devices.sql │ │ ├── V3_4_7__add_filter_column.sql │ │ ├── V3_4_8__add_default_device_types.sql │ │ └── V3_4_9__alter_plugin_table_column_types.sql │ └── redisson.yaml ├── devicehive-shim-api ├── LICENSE ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── devicehive │ └── shim │ └── api │ ├── Action.java │ ├── Body.java │ ├── Request.java │ ├── RequestType.java │ ├── Response.java │ ├── client │ └── RpcClient.java │ └── server │ ├── MessageDispatcher.java │ ├── RequestHandler.java │ └── RpcServer.java ├── devicehive-shim-kafka-impl ├── LICENSE ├── missing-license.properties ├── pom.xml └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── devicehive │ │ │ └── shim │ │ │ ├── config │ │ │ ├── KafkaRpcConfig.java │ │ │ ├── client │ │ │ │ └── KafkaRpcClientConfig.java │ │ │ └── server │ │ │ │ └── KafkaRpcServerConfig.java │ │ │ └── kafka │ │ │ ├── ConsumerWorker.java │ │ │ ├── KafkaMessageHandler.java │ │ │ ├── builder │ │ │ ├── ClientBuilder.java │ │ │ └── ServerBuilder.java │ │ │ ├── client │ │ │ ├── KafkaRpcClient.java │ │ │ ├── ResponseConsumerWorker.java │ │ │ └── ServerResponseListener.java │ │ │ ├── eventbus │ │ │ └── DistributedRpcFilterRegistry.java │ │ │ ├── serializer │ │ │ ├── RequestSerializer.java │ │ │ └── ResponseSerializer.java │ │ │ ├── server │ │ │ ├── KafkaRpcServer.java │ │ │ ├── RequestConsumer.java │ │ │ ├── RequestConsumerWorker.java │ │ │ └── ServerEventHandler.java │ │ │ └── topic │ │ │ ├── KafkaRpcTopicService.java │ │ │ └── KafkaTopicService.java │ └── resources │ │ └── kafka.properties │ └── test │ ├── java │ └── com │ │ └── devicehive │ │ └── shim │ │ └── kafka │ │ ├── fixture │ │ ├── RequestHandlerWrapper.java │ │ ├── TestRequestBody.java │ │ └── TestResponseBody.java │ │ └── test │ │ └── KafkaRpcClientServerCommunicationTest.java │ └── resources │ └── logback.xml ├── devicehive-test-utils ├── LICENSE ├── missing-license.properties ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── devicehive │ └── test │ ├── dialect │ └── HsqlDialectReplacement.java │ └── rule │ └── KafkaEmbeddedRule.java ├── dockerfiles ├── devicehive-auth.Dockerfile ├── devicehive-auth │ └── devicehive-start.sh ├── devicehive-backend.Dockerfile ├── devicehive-backend │ └── devicehive-start.sh ├── devicehive-frontend.Dockerfile ├── devicehive-frontend │ └── devicehive-start.sh ├── devicehive-kafka.Dockerfile ├── devicehive-plugin.Dockerfile └── devicehive-plugin │ └── devicehive-start.sh └── pom.xml /.env: -------------------------------------------------------------------------------- 1 | REDIS_MASTER_HOST=localhost 2 | REDIS_MASTER_PORT=6379 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | target/ 3 | *.iml 4 | .settings/ 5 | .classpath 6 | .project 7 | *.DS_Store 8 | *.log 9 | -------------------------------------------------------------------------------- /APIChanges.md: -------------------------------------------------------------------------------- 1 | This document tracks changes to the API between versions. 2 | 3 | # 3.0.0 4 | 5 | ## RESTful API 6 | * Removed OAuth server (permanently deleted `/oauth/client`, `/user/{userId}/oauth/grant` and `/oauth2/token` endpoints) 7 | * OAuth providers (Github, Facebook, Google, etc) now support JWT instead of Access Key (`/auth/accesskey` endpoint renamed to `/oauth/token` and it returns JWT) 8 | * Added JWT authentication support: 9 | - `/token` endpoint for JWT access and refresh token request with JWT payload; 10 | - `/token/refresh` endpoint for JWT access token request with refresh token. 11 | 12 | See [DeviceHive API Swagger](http://playground.devicehive.com/api/swagger?url=http%3A%2F%2Fplayground.devicehive.com%2Fapi%2Frest%2Fswagger.json) for more details. 13 | 14 | 15 | ## WebSocket API 16 | * Added JWT authentication support (`accessKey` request parameter renamed to `token`) 17 | * Added `token/refresh` action (takes `refreshToken` parameter and responses new access token in `accessToken` parameter) -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | ## v3.0.0 - 2017-02-06 3 | * Security is now done via JSON Web Tokens (JWT) - details here https://jwt.io/introduction/ 4 | * DH is no longer a monolith application - it has been refactored into a number of microservices. This allows for better horizontal scalability and flexibility in deployment options 5 | * Added support for the Riak database (we used to only support PostgreSQL) 6 | -------------------------------------------------------------------------------- /devicehive-auth/src/main/java/com/devicehive/application/filter/ContentTypeFilter.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.application.filter; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.springframework.http.HttpHeaders; 24 | 25 | import javax.ws.rs.container.ContainerRequestContext; 26 | import javax.ws.rs.container.ContainerRequestFilter; 27 | import javax.ws.rs.container.PreMatching; 28 | import javax.ws.rs.core.MediaType; 29 | import javax.ws.rs.ext.Provider; 30 | import java.io.IOException; 31 | 32 | @Provider 33 | @PreMatching 34 | public class ContentTypeFilter implements ContainerRequestFilter { 35 | 36 | @Override 37 | public void filter(ContainerRequestContext containerRequestContext) throws IOException { 38 | if(!containerRequestContext.getHeaders().containsKey(HttpHeaders.CONTENT_TYPE)){ 39 | containerRequestContext.getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /devicehive-auth/src/main/java/com/devicehive/resource/impl/AuthApiInfoResourceImpl.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource.impl; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Auth Logic 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | import com.devicehive.resource.AuthApiInfoResource; 25 | import com.devicehive.resource.BaseApiInfoResource; 26 | import org.springframework.beans.factory.annotation.Autowired; 27 | import org.springframework.stereotype.Service; 28 | 29 | import javax.ws.rs.core.Response; 30 | import javax.ws.rs.core.UriInfo; 31 | 32 | @Service 33 | public class AuthApiInfoResourceImpl implements AuthApiInfoResource { 34 | 35 | private final BaseApiInfoResource baseApiInfoResource; 36 | 37 | @Autowired 38 | public AuthApiInfoResourceImpl(BaseApiInfoResource baseApiInfoResource) { 39 | this.baseApiInfoResource = baseApiInfoResource; 40 | } 41 | 42 | @Override 43 | public Response getApiInfo(UriInfo uriInfo, String protocol) { 44 | return baseApiInfoResource.getApiInfo(uriInfo, protocol); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /devicehive-auth/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # DeviceHive Frontend Logic 4 | # %% 5 | # Copyright (C) 2016 DataArt 6 | # %% 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # #L% 19 | ### 20 | spring.profiles.active=ws-kafka-proxy 21 | 22 | server.port=8090 23 | server.servlet.context-path=/dh 24 | server.servlet.session.timeout=60 25 | 26 | spring.jersey.type=filter 27 | spring.jersey.application-path=/rest 28 | 29 | logging.level.org.springframework.security=INFO 30 | logging.level.com.devicehive=INFO 31 | 32 | # HTTP message conversion 33 | spring.mvc.converters.preferred-json-mapper=gson 34 | 35 | build.version=${project.version} 36 | build.timestamp=${build.timestamp} 37 | swagger.protocol=http 38 | swagger.port=80 39 | 40 | # Kafka properties 41 | response.topic.perfix=response_topic_auth_ 42 | 43 | # Custom configuration properties 44 | app.executor.size=20 45 | 46 | management.context-path=/app 47 | management.security.enabled=true 48 | management.security.sessions=STATELESS 49 | 50 | # a half of year age in ms 51 | jwt.refresh-token-max-age=15724800000 52 | jwt.access-token-max-age=1800000 53 | 54 | 55 | spring.flyway.baselineOnMigrate=false 56 | spring.flyway.table=schema_version 57 | #spring.flyway.baseline-version=3.4.12 -------------------------------------------------------------------------------- /devicehive-auth/src/main/resources/messages_en_EN.properties: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # DeviceHive Frontend Logic 4 | # %% 5 | # Copyright (C) 2016 DataArt 6 | # %% 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # #L% 19 | ### 20 | -------------------------------------------------------------------------------- /devicehive-auth/src/test/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # DeviceHive Frontend Logic 4 | # %% 5 | # Copyright (C) 2016 DataArt 6 | # %% 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # #L% 19 | ### 20 | 21 | # HTTP message conversion 22 | spring.mvc.converters.preferred-json-mapper=gson 23 | 24 | # Kafka properties 25 | bootstrap.servers=127.0.0.1:9092 26 | zookeeper.connect=127.0.0.1:2181 27 | 28 | flyway.enabled=false 29 | -------------------------------------------------------------------------------- /devicehive-backend/missing-license.properties: -------------------------------------------------------------------------------- 1 | # Please fill the missing licenses for dependencies : 2 | 3 | org.apache.zookeeper--zookeeper--3.4.6=Apache 2.0 4 | dom4j--dom4j--1.6.1=BSD style -------------------------------------------------------------------------------- /devicehive-backend/src/main/java/com/devicehive/application/BackendConfig.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.application; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Backend Logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.eventbus.EventBus; 24 | import com.devicehive.json.GsonFactory; 25 | import com.devicehive.model.eventbus.FilterRegistry; 26 | import com.devicehive.shim.api.server.MessageDispatcher; 27 | import com.google.gson.Gson; 28 | import org.springframework.context.annotation.Bean; 29 | import org.springframework.context.annotation.Configuration; 30 | import org.springframework.context.annotation.DependsOn; 31 | 32 | @Configuration 33 | public class BackendConfig { 34 | 35 | @Bean 36 | public Gson gson() { 37 | return GsonFactory.createGson(); 38 | } 39 | 40 | @Bean 41 | @DependsOn("filterRegistry") 42 | public EventBus eventBus(MessageDispatcher dispatcher, FilterRegistry filterRegistry) { 43 | return new EventBus(dispatcher, filterRegistry); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /devicehive-backend/src/main/java/com/devicehive/application/DeviceHiveBackendApplication.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.application; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Backend Logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.springframework.boot.WebApplicationType; 24 | import org.springframework.boot.builder.SpringApplicationBuilder; 25 | import org.springframework.context.ConfigurableApplicationContext; 26 | import org.springframework.context.annotation.ComponentScan; 27 | import org.springframework.context.annotation.FilterType; 28 | import org.springframework.stereotype.Component; 29 | 30 | @Component 31 | @ComponentScan(value = "com.devicehive", excludeFilters = {@ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.springframework.transaction.*")}) 32 | public class DeviceHiveBackendApplication { 33 | 34 | public static void main(String... args) { 35 | ConfigurableApplicationContext context = new SpringApplicationBuilder() 36 | .sources(DeviceHiveBackendApplication.class) 37 | .web(WebApplicationType.SERVLET) 38 | .run(args); 39 | 40 | context.registerShutdownHook(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /devicehive-backend/src/main/java/com/devicehive/service/cache/CacheService.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.service.cache; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.CacheEntity; 24 | 25 | import java.util.Optional; 26 | 27 | public interface CacheService { 28 | 29 | Optional find(Long id, String deviceId); 30 | 31 | void store(final T entity); 32 | } 33 | -------------------------------------------------------------------------------- /devicehive-backend/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # DeviceHive Backend Logic 4 | # %% 5 | # Copyright (C) 2016 DataArt 6 | # %% 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # #L% 19 | ### 20 | #spring.profiles.active=rpc-server 21 | spring.profiles.active=ws-kafka-proxy-backend 22 | 23 | spring.mvc.converters.preferred-json-mapper=gson 24 | 25 | server.port=8000 26 | 27 | devicehive.cache.notifications.ttl.seconds=120 28 | devicehive.cache.commands.ttl.seconds=120 29 | 30 | logging.level.com.devicehive=info 31 | 32 | bootstrap.servers=127.0.0.1:9092 33 | zookeeper.connect=127.0.0.1:2181 34 | num.partitions=3 35 | replication.factor=1 36 | 37 | lmax.wait.strategy=blocking 38 | lmax.buffer-size=1024 39 | 40 | spring.flyway.baselineOnMigrate=false 41 | spring.flyway.table=schema_version 42 | #spring.flyway.baseline-version=3.4.12 -------------------------------------------------------------------------------- /devicehive-backend/src/main/resources/messages_en_EN.properties: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # DeviceHive Backend Logic 4 | # %% 5 | # Copyright (C) 2016 DataArt 6 | # %% 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # #L% 19 | ### 20 | -------------------------------------------------------------------------------- /devicehive-backend/src/test/java/com/devicehive/base/CommandTestUtils.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.base; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Backend Logic 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.DeviceCommand; 24 | 25 | import java.util.Date; 26 | import java.util.UUID; 27 | 28 | public class CommandTestUtils { 29 | 30 | public static DeviceCommand generateCommand() { 31 | DeviceCommand command = new DeviceCommand(); 32 | command.setId(System.currentTimeMillis()); 33 | command.setCommand("do_work"); 34 | command.setDeviceId(UUID.randomUUID().toString()); 35 | command.setNetworkId(0L); 36 | command.setDeviceTypeId(0L); 37 | command.setTimestamp(new Date(0)); 38 | command.setLastUpdated(new Date(0)); 39 | command.setUserId(0L); 40 | command.setIsUpdated(false); 41 | command.setLifetime(0); 42 | return command; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /devicehive-backend/src/test/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # DeviceHive Backend Logic 4 | # %% 5 | # Copyright (C) 2016 DataArt 6 | # %% 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # #L% 19 | ### 20 | spring.profiles.include=rpc-server,rpc-client 21 | 22 | response.topic.perfix=response_topic_ 23 | 24 | bootstrap.servers=127.0.0.1:9092 25 | 26 | flyway.enabled=false 27 | -------------------------------------------------------------------------------- /devicehive-common-dao/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | com.devicehive 9 | devicehive-server 10 | 4.1.0 11 | 12 | 13 | devicehive-common-dao 14 | jar 15 | DeviceHive Common Dao interfaces 16 | 17 | 18 | ${project.parent.basedir} 19 | 20 | 21 | 22 | 23 | com.devicehive 24 | devicehive-common 25 | ${project.parent.version} 26 | 27 | 28 | -------------------------------------------------------------------------------- /devicehive-common-dao/src/main/java/com/devicehive/dao/ConfigurationDao.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.dao; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Dao Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.vo.ConfigurationVO; 24 | 25 | import java.util.Optional; 26 | 27 | public interface ConfigurationDao { 28 | 29 | Optional getByName(String name); 30 | 31 | int delete(String name); 32 | 33 | void persist(ConfigurationVO configuration); 34 | 35 | ConfigurationVO merge(ConfigurationVO existing); 36 | } 37 | -------------------------------------------------------------------------------- /devicehive-common-dao/src/main/java/com/devicehive/dao/DeviceDao.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.dao; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Dao Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | import com.devicehive.auth.HivePrincipal; 25 | import com.devicehive.vo.DeviceVO; 26 | 27 | import java.util.List; 28 | 29 | /** 30 | * Created by Gleb on 07.07.2016. 31 | */ 32 | public interface DeviceDao { 33 | 34 | DeviceVO findById(String id); 35 | 36 | void persist(DeviceVO device); 37 | 38 | DeviceVO merge(DeviceVO device); 39 | 40 | int deleteById(String id); 41 | 42 | List getDeviceList(List ids, HivePrincipal principal); 43 | 44 | List list(String name, String namePattern, Long networkId, String networkName, 45 | String sortField, boolean sortOrderAsc, Integer take, Integer skip, HivePrincipal principal); 46 | 47 | long count(String name, String namePattern, Long networkId, String networkName, HivePrincipal principal); 48 | } 49 | -------------------------------------------------------------------------------- /devicehive-common-dao/src/main/java/com/devicehive/dao/PluginDao.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.dao; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Dao Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.auth.HivePrincipal; 24 | import com.devicehive.model.enums.PluginStatus; 25 | import com.devicehive.vo.PluginVO; 26 | 27 | import java.util.List; 28 | 29 | public interface PluginDao { 30 | 31 | PluginVO find(Long id); 32 | 33 | List findByStatus(PluginStatus status); 34 | 35 | PluginVO findByTopic(String topicName); 36 | 37 | PluginVO findByName(String pluginName); 38 | 39 | void persist(PluginVO pluginVO); 40 | 41 | PluginVO merge(PluginVO existing); 42 | 43 | int deleteById(long id); 44 | 45 | List list(String name, String namePattern, String topicName, Integer status, Long userId, 46 | String sortField, boolean sortOrderAsc, Integer take, Integer skip, HivePrincipal principal); 47 | 48 | long count(String name, String namePattern, String topicName, Integer status, Long userId, HivePrincipal principal); 49 | } 50 | -------------------------------------------------------------------------------- /devicehive-common-dao/src/main/java/com/devicehive/exceptions/HivePersistenceLayerException.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.exceptions; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Dao Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | public class HivePersistenceLayerException extends HiveException { 24 | private static final long serialVersionUID = 2084328743134451009L; 25 | 26 | public HivePersistenceLayerException(String message, Throwable cause) { 27 | super(message, cause); 28 | } 29 | 30 | public HivePersistenceLayerException(String message) { 31 | super(message); 32 | } 33 | 34 | public HivePersistenceLayerException(String message, Integer code) { 35 | super(message, code); 36 | } 37 | 38 | public HivePersistenceLayerException(String message, Throwable cause, Integer code) { 39 | super(message, cause, code); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/auth/rest/providers/HiveAnonymousAuthenticationProvider.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.auth.rest.providers; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.auth.HiveAuthentication; 24 | import com.devicehive.auth.HivePrincipal; 25 | import org.springframework.security.authentication.AnonymousAuthenticationToken; 26 | import org.springframework.security.authentication.AuthenticationProvider; 27 | import org.springframework.security.core.Authentication; 28 | import org.springframework.security.core.AuthenticationException; 29 | 30 | public class HiveAnonymousAuthenticationProvider implements AuthenticationProvider { 31 | 32 | @Override 33 | public Authentication authenticate(Authentication authentication) throws AuthenticationException { 34 | return new HiveAuthentication(new HivePrincipal(), authentication.getAuthorities()); 35 | } 36 | 37 | @Override 38 | public boolean supports(Class authentication) { 39 | return AnonymousAuthenticationToken.class.equals(authentication); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/model/ErrorResponse.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Implements response object for error requests 25 | */ 26 | public class ErrorResponse implements HiveEntity { 27 | 28 | private static final long serialVersionUID = 286844689037405279L; 29 | 30 | private Integer error = null; 31 | 32 | private String message = null; 33 | 34 | public Integer getError() { 35 | return error; 36 | } 37 | 38 | public ErrorResponse(Integer errorCode, String messageString) { 39 | error = errorCode; 40 | message = messageString; 41 | } 42 | 43 | public ErrorResponse(String messageString) { 44 | message = messageString; 45 | } 46 | 47 | public void setError(Integer error) { 48 | this.error = error; 49 | } 50 | 51 | public String getMessage() { 52 | return message; 53 | } 54 | 55 | public void setMessage(String message) { 56 | this.message = message; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/resource/BaseApiInfoResource.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import javax.ws.rs.core.Context; 24 | import javax.ws.rs.core.Response; 25 | import javax.ws.rs.core.UriInfo; 26 | 27 | public interface BaseApiInfoResource { 28 | 29 | Response getApiInfo(@Context UriInfo uriInfo, String protocol); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/resource/converters/CollectionProvider.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource.converters; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.HiveEntity; 24 | 25 | import javax.ws.rs.ext.Provider; 26 | import java.util.Collection; 27 | 28 | @Provider 29 | public class CollectionProvider extends JsonPolicyProvider> { 30 | } 31 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/resource/converters/HiveEntityProvider.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource.converters; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.HiveEntity; 24 | 25 | import javax.ws.rs.ext.Provider; 26 | 27 | @Provider 28 | public class HiveEntityProvider extends JsonPolicyProvider { 29 | } 30 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/resource/exceptions/ActionNotAllowedExceptionMapper.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource.exceptions; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.exceptions.ActionNotAllowedException; 24 | import com.devicehive.model.ErrorResponse; 25 | import com.devicehive.resource.util.ResponseFactory; 26 | 27 | import javax.ws.rs.core.Response; 28 | import javax.ws.rs.ext.ExceptionMapper; 29 | import javax.ws.rs.ext.Provider; 30 | 31 | import static javax.ws.rs.core.Response.Status.FORBIDDEN; 32 | 33 | @Provider 34 | public class ActionNotAllowedExceptionMapper implements ExceptionMapper { 35 | 36 | @Override 37 | public Response toResponse(ActionNotAllowedException exception) { 38 | return ResponseFactory.response(FORBIDDEN, new ErrorResponse(FORBIDDEN.getStatusCode(), exception.getMessage())); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/resource/exceptions/ExpiredTokenException.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource.exceptions; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.springframework.security.core.AuthenticationException; 24 | 25 | public class ExpiredTokenException extends AuthenticationException { 26 | private static final long serialVersionUID = -7505827097648274298L; 27 | 28 | public ExpiredTokenException(String message) { 29 | super(message); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/resource/exceptions/HibernateConstraintViolationsMapper.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource.exceptions; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | import com.devicehive.model.ErrorResponse; 25 | import com.devicehive.resource.util.ResponseFactory; 26 | import org.hibernate.exception.ConstraintViolationException; 27 | 28 | import javax.ws.rs.core.Response; 29 | import javax.ws.rs.ext.ExceptionMapper; 30 | import javax.ws.rs.ext.Provider; 31 | 32 | @Provider 33 | public class HibernateConstraintViolationsMapper implements ExceptionMapper { 34 | 35 | @Override 36 | public Response toResponse(ConstraintViolationException exception) { 37 | return ResponseFactory.response(Response.Status.CONFLICT, new ErrorResponse(exception.getMessage())); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/resource/exceptions/HiveExceptionMapper.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource.exceptions; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | import com.devicehive.exceptions.HiveException; 25 | import com.devicehive.model.ErrorResponse; 26 | import com.devicehive.resource.util.ResponseFactory; 27 | 28 | import javax.ws.rs.core.Response; 29 | import javax.ws.rs.ext.ExceptionMapper; 30 | import javax.ws.rs.ext.Provider; 31 | 32 | @Provider 33 | public class HiveExceptionMapper implements ExceptionMapper { 34 | 35 | @Override 36 | public Response toResponse(HiveException exception) { 37 | Response.Status responseCode = (exception.getCode() != null) 38 | ? Response.Status.fromStatusCode(exception.getCode()) 39 | : Response.Status.BAD_REQUEST; 40 | return ResponseFactory 41 | .response(responseCode, new ErrorResponse(responseCode.getStatusCode(), exception.getMessage())); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/resource/exceptions/IllegalParametersExceptionMapper.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource.exceptions; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.exceptions.IllegalParametersException; 24 | import com.devicehive.model.ErrorResponse; 25 | import com.devicehive.resource.util.ResponseFactory; 26 | 27 | import javax.ws.rs.core.Response; 28 | import javax.ws.rs.ext.ExceptionMapper; 29 | import javax.ws.rs.ext.Provider; 30 | 31 | import static javax.ws.rs.core.Response.Status.BAD_REQUEST; 32 | 33 | @Provider 34 | public class IllegalParametersExceptionMapper implements ExceptionMapper { 35 | 36 | @Override 37 | public Response toResponse(IllegalParametersException exception) { 38 | return ResponseFactory.response(BAD_REQUEST, new ErrorResponse(BAD_REQUEST.getStatusCode(), exception.getMessage())); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/resource/exceptions/JsonParseExceptionMapper.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource.exceptions; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | import com.devicehive.configuration.Messages; 25 | import com.devicehive.model.ErrorResponse; 26 | import com.google.gson.JsonParseException; 27 | 28 | import javax.ws.rs.core.MediaType; 29 | import javax.ws.rs.core.Response; 30 | import javax.ws.rs.ext.ExceptionMapper; 31 | import javax.ws.rs.ext.Provider; 32 | 33 | @Provider 34 | public class JsonParseExceptionMapper implements ExceptionMapper { 35 | 36 | @Override 37 | public Response toResponse(JsonParseException exception) { 38 | return Response.status(Response.Status.BAD_REQUEST) 39 | .type(MediaType.APPLICATION_JSON_TYPE) 40 | .entity(new ErrorResponse(Response.Status.BAD_REQUEST.getStatusCode(), Messages.INVALID_REQUEST_PARAMETERS)) 41 | .build(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/resource/exceptions/NoSuchElementExceptionMapper.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource.exceptions; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.ErrorResponse; 24 | import com.devicehive.resource.util.ResponseFactory; 25 | 26 | import javax.ws.rs.core.Response; 27 | import javax.ws.rs.ext.ExceptionMapper; 28 | import javax.ws.rs.ext.Provider; 29 | import java.util.NoSuchElementException; 30 | 31 | import static javax.ws.rs.core.Response.Status.NOT_FOUND; 32 | 33 | @Provider 34 | public class NoSuchElementExceptionMapper implements ExceptionMapper { 35 | 36 | @Override 37 | public Response toResponse(NoSuchElementException exception) { 38 | return ResponseFactory.response(NOT_FOUND, new ErrorResponse(NOT_FOUND.getStatusCode(), exception.getMessage())); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/resource/exceptions/OptimisticLockExceptionMapper.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource.exceptions; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | import com.devicehive.configuration.Messages; 25 | import com.devicehive.model.ErrorResponse; 26 | import com.devicehive.resource.util.ResponseFactory; 27 | 28 | import javax.persistence.OptimisticLockException; 29 | import javax.ws.rs.core.Response; 30 | import javax.ws.rs.ext.ExceptionMapper; 31 | import javax.ws.rs.ext.Provider; 32 | 33 | @Provider 34 | public class OptimisticLockExceptionMapper implements ExceptionMapper { 35 | 36 | @Override 37 | public Response toResponse(OptimisticLockException exception) { 38 | return ResponseFactory.response(Response.Status.CONFLICT, new ErrorResponse(Response.Status.CONFLICT.getStatusCode(), Messages.CONFLICT_MESSAGE)); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/service/helpers/LongIdGenerator.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.service.helpers; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Frontend Logic 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | public interface LongIdGenerator { 25 | 26 | long generate(); 27 | } 28 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/service/helpers/PasswordProcessor.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.service.helpers; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | public interface PasswordProcessor { 25 | 26 | String generateSalt(); 27 | 28 | String hashPassword(String password, String salt); 29 | 30 | boolean checkPassword(String password, String salt, String hash); 31 | } 32 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/service/helpers/TimestampLongIdGenerator.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.service.helpers; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Frontend Logic 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.springframework.stereotype.Component; 24 | 25 | @Component 26 | public class TimestampLongIdGenerator implements LongIdGenerator { 27 | 28 | private final static int MAX_VALUE = 999; 29 | private int inc = 0; 30 | 31 | @Override 32 | public long generate() { 33 | if (inc > MAX_VALUE) { 34 | inc = 0; 35 | } 36 | 37 | return System.currentTimeMillis() * 1000 + inc++; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/service/time/LocalTimestampService.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.service.time; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Frontend Logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.springframework.stereotype.Component; 24 | 25 | import java.text.SimpleDateFormat; 26 | import java.util.Date; 27 | import java.util.SimpleTimeZone; 28 | 29 | @Component 30 | public class LocalTimestampService implements TimestampService { 31 | 32 | private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); 33 | 34 | @Override 35 | public Date getDate() { 36 | return new Date(); 37 | } 38 | 39 | @Override 40 | public Date getDate(long ms) { 41 | return new Date(ms); 42 | } 43 | 44 | @Override 45 | public String getDateAsString() { 46 | DATE_FORMAT.setTimeZone(new SimpleTimeZone(SimpleTimeZone.UTC_TIME, "UTC")); 47 | return DATE_FORMAT.format(getDate()); 48 | } 49 | 50 | @Override 51 | public long getTimestamp() { 52 | return getDate().getTime(); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/service/time/TimestampService.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.service.time; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.util.Date; 24 | 25 | public interface TimestampService { 26 | 27 | Date getDate(); 28 | 29 | Date getDate(long ms); 30 | 31 | String getDateAsString(); 32 | 33 | long getTimestamp(); 34 | } 35 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/util/HiveMessageFormatter.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.util; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.slf4j.helpers.MessageFormatter; 24 | 25 | public class HiveMessageFormatter { 26 | 27 | public static String format(String pattern, Object... params) { 28 | return MessageFormatter.arrayFormat(pattern, params).getMessage(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/vo/JwtAccessTokenVO.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.vo; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import io.swagger.annotations.ApiModelProperty; 24 | 25 | /** 26 | * JWT access token response entity 27 | */ 28 | public class JwtAccessTokenVO extends JwtTokenVO { 29 | private static final long serialVersionUID = -1202086382725243574L; 30 | 31 | @Override 32 | @ApiModelProperty(hidden = true) 33 | public String getRefreshToken() { 34 | return super.getRefreshToken(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/vo/JwtRefreshTokenVO.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.vo; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import io.swagger.annotations.ApiModelProperty; 24 | 25 | /** 26 | * JWT refresh token response entity 27 | */ 28 | public class JwtRefreshTokenVO extends JwtTokenVO { 29 | private static final long serialVersionUID = -8138388371972886591L; 30 | 31 | @Override 32 | @ApiModelProperty(hidden = true) 33 | public String getAccessToken() { 34 | return super.getAccessToken(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /devicehive-common-service/src/main/java/com/devicehive/vo/JwtRequestVO.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.vo; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.HiveEntity; 24 | 25 | /** 26 | * Created by tmatvienko on 1/13/15. 27 | */ 28 | public class JwtRequestVO implements HiveEntity { 29 | 30 | private static final long serialVersionUID = -3876398635939615946L; 31 | 32 | private String login; 33 | 34 | private String password; 35 | 36 | public JwtRequestVO() { 37 | } 38 | 39 | public String getLogin() { 40 | return login; 41 | } 42 | 43 | public void setLogin(String login) { 44 | this.login = login; 45 | } 46 | 47 | public String getPassword() { 48 | return password; 49 | } 50 | 51 | public void setPassword(String password) { 52 | this.password = password; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/ApplicationContextHolder.java: -------------------------------------------------------------------------------- 1 | package com.devicehive; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.springframework.beans.BeansException; 24 | import org.springframework.context.ApplicationContext; 25 | import org.springframework.context.ApplicationContextAware; 26 | import org.springframework.stereotype.Component; 27 | 28 | @Component("simpleApplicationContextHolder") 29 | public class ApplicationContextHolder implements ApplicationContextAware { 30 | 31 | private static ApplicationContext applicationContext; 32 | 33 | @Override 34 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { 35 | ApplicationContextHolder.applicationContext = applicationContext; 36 | } 37 | 38 | public static ApplicationContext getApplicationContext() { 39 | return applicationContext; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/api/HandlersMapper.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.api; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Backend Logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Action; 24 | import com.devicehive.shim.api.server.RequestHandler; 25 | 26 | import java.util.Map; 27 | 28 | public interface HandlersMapper { 29 | Map requestHandlerMap(); 30 | } 31 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/auth/HiveRoles.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.auth; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Dao Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Set of String constants to be used for @RolesAllowed annotation 25 | */ 26 | public class HiveRoles { 27 | 28 | public static final String CLIENT = "CLIENT"; 29 | public static final String ADMIN = "ADMIN"; 30 | public static final String KEY = "KEY"; 31 | public static final String JWT = "JWT"; 32 | } 33 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/exceptions/ActionNotAllowedException.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.exceptions; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Dao Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | public class ActionNotAllowedException extends RuntimeException { 24 | private static final long serialVersionUID = 4098344778590417014L; 25 | 26 | public ActionNotAllowedException(String message) { 27 | super(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/exceptions/IllegalParametersException.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.exceptions; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Dao Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | public class IllegalParametersException extends RuntimeException { 24 | private static final long serialVersionUID = -8707307258258265121L; 25 | 26 | public IllegalParametersException(String message) { 27 | super(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/exceptions/InvalidPrincipalException.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.exceptions; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | public class InvalidPrincipalException extends RuntimeException { 24 | private static final long serialVersionUID = -5500378251126985840L; 25 | 26 | public InvalidPrincipalException(String message) { 27 | super(message); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/json/strategies/JsonPolicyApply.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.json.strategies; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Dao Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | import javax.enterprise.util.AnnotationLiteral; 25 | import java.lang.annotation.Inherited; 26 | import java.lang.annotation.Retention; 27 | import java.lang.annotation.RetentionPolicy; 28 | 29 | @Inherited 30 | @Retention(RetentionPolicy.RUNTIME) 31 | public @interface JsonPolicyApply { 32 | 33 | JsonPolicyDef.Policy value(); 34 | 35 | class JsonPolicyApplyLiteral extends AnnotationLiteral 36 | implements JsonPolicyApply { 37 | 38 | 39 | private static final long serialVersionUID = 7838737655418173629L; 40 | private JsonPolicyDef.Policy policy; 41 | 42 | public JsonPolicyApplyLiteral(JsonPolicyDef.Policy policy) { 43 | this.policy = policy; 44 | } 45 | 46 | @Override 47 | public JsonPolicyDef.Policy value() { 48 | return policy; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/CacheEntity.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | public interface CacheEntity { 24 | 25 | String getCacheKey(); 26 | } 27 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/HiveEntity.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Dao Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.io.Serializable; 24 | 25 | public interface HiveEntity extends Serializable { 26 | 27 | long INITIAL_ENTITY_VERSION = 0L; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/ServerEvent.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Shim Kafka Implementation 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Request; 24 | 25 | public class ServerEvent { 26 | 27 | private Request request; 28 | 29 | public void set(Request request) { 30 | this.request = request; 31 | } 32 | 33 | public Request get() { 34 | return request; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/converters/SetHelper.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.converters; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | import org.apache.commons.lang3.StringUtils; 25 | 26 | import java.util.*; 27 | import java.util.stream.Collectors; 28 | 29 | public class SetHelper { 30 | 31 | public static Set toStringSet(String stringCsv) { 32 | return Optional.ofNullable(StringUtils.split(stringCsv, ',')) 33 | .map(Arrays::asList) 34 | .map(HashSet::new) 35 | .orElse(null); 36 | } 37 | 38 | public static Set toLongSet(String stringCsv) { 39 | return Optional.ofNullable(StringUtils.split(stringCsv, ',')) 40 | .map(Arrays::asList) 41 | .map(list -> list.stream().map(Long::valueOf).collect(Collectors.toSet())) 42 | .orElse(null); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/converters/TimestampQueryParamParser.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.converters; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.configuration.Messages; 24 | import com.devicehive.exceptions.HiveException; 25 | import com.devicehive.json.adapters.TimestampAdapter; 26 | 27 | import java.util.Date; 28 | 29 | import static javax.ws.rs.core.Response.Status.BAD_REQUEST; 30 | 31 | public class TimestampQueryParamParser { 32 | 33 | public static Date parse(String value) { 34 | try { 35 | return TimestampAdapter.parseTimestamp(value); 36 | } catch (IllegalArgumentException | UnsupportedOperationException e) { 37 | throw new HiveException(Messages.UNPARSEABLE_TIMESTAMP, e, BAD_REQUEST.getStatusCode()); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/enums/PluginStatus.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.enums; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Dao Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | public enum PluginStatus { 25 | ACTIVE(0), 26 | INACTIVE(1), 27 | CREATED(2); 28 | 29 | private int value; 30 | 31 | PluginStatus(int value) { 32 | this.value = value; 33 | } 34 | 35 | public int getValue() { 36 | return this.value; 37 | } 38 | 39 | public static PluginStatus getValueForIndex(int index){ 40 | return values()[index]; 41 | } 42 | 43 | public static PluginStatus fromString(final String s) { 44 | return PluginStatus.valueOf(s.toUpperCase()); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/enums/SearchableField.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.enums; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Dao Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | public enum SearchableField { 24 | ID("id"), 25 | DEVICE_ID("deviceId"), 26 | TIMESTAMP("timestamp"), 27 | LAST_UPDATED("lastUpdated"), 28 | DEVICE_IDS("deviceId"), //need this duplication to separate cases of single and multiple deviceId usage 29 | NETWORK_IDS("networkId"), 30 | DEVICE_TYPE_IDS("deviceTypeId"), 31 | NOTIFICATION("notification"), 32 | COMMAND("command"), 33 | STATUS("status"), 34 | IS_UPDATED("isUpdated"); 35 | 36 | private String field; 37 | 38 | SearchableField(String field) { 39 | this.field = field; 40 | } 41 | 42 | public String getField() { 43 | return field; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/enums/UserRole.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.enums; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Dao Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | /** 24 | * Enum for User roles in the system. 25 | */ 26 | public enum UserRole { 27 | ADMIN(0), 28 | CLIENT(1); 29 | 30 | private final int value; 31 | 32 | UserRole(int value) { 33 | this.value = value; 34 | } 35 | 36 | public int getValue() { 37 | return value; 38 | } 39 | 40 | @Override 41 | public String toString() { 42 | return this.name(); 43 | } 44 | 45 | public static UserRole getValueForIndex(int index){ 46 | return values()[index]; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/enums/UserStatus.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.enums; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Dao Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | public enum UserStatus { 25 | ACTIVE(0), 26 | LOCKED_OUT(1), 27 | DISABLED(2); 28 | 29 | private int value; 30 | 31 | UserStatus(int value) { 32 | this.value = value; 33 | } 34 | 35 | public int getValue() { 36 | return this.value; 37 | } 38 | 39 | 40 | public static UserStatus getValueForIndex(int index){ 41 | return values()[index]; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/eventbus/SubscribeAction.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.eventbus; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Backend Logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | public enum SubscribeAction { 24 | REGISTER(0), 25 | UNREGISTER(1); 26 | 27 | private int value; 28 | 29 | SubscribeAction(int value) { 30 | this.value = value; 31 | } 32 | 33 | public int getValue() { 34 | return this.value; 35 | } 36 | 37 | public static SubscribeAction getValueForIndex(int index){ 38 | return values()[index]; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/eventbus/events/Event.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.eventbus.events; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.eventbus.Filter; 24 | import com.devicehive.shim.api.Action; 25 | import com.devicehive.shim.api.Body; 26 | 27 | import java.util.Collection; 28 | 29 | public abstract class Event extends Body { 30 | 31 | public Event(Action action) { 32 | super(action); 33 | } 34 | 35 | /** 36 | * Returns applicable to this event filter. 37 | * For example, if event is device_notification { deviceId = a, notificationName = b }, 38 | * then subscriptions on { deviceId = a, name = null } and { deviceId = a, name = b } will be returned, 39 | * but not { deviceId = a, name = c }, cause it is not applicable to this event. 40 | * 41 | * @return valid filter, for which this event can be routed. 42 | */ 43 | public abstract Collection getApplicableFilters(); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/BasePluginRequest.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Action; 24 | import com.devicehive.shim.api.Body; 25 | 26 | public abstract class BasePluginRequest extends Body { 27 | 28 | protected Long subscriptionId; 29 | 30 | protected BasePluginRequest(Action action) { 31 | super(action); 32 | } 33 | 34 | public Long getSubscriptionId() { 35 | return subscriptionId; 36 | } 37 | 38 | public void setSubscriptionId(Long subscriptionId) { 39 | this.subscriptionId = subscriptionId; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/CommandInsertRequest.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.DeviceCommand; 24 | import com.devicehive.shim.api.Action; 25 | import com.devicehive.shim.api.Body; 26 | 27 | public class CommandInsertRequest extends Body { 28 | 29 | private DeviceCommand deviceCommand; 30 | 31 | public CommandInsertRequest(DeviceCommand deviceCommand) { 32 | super(Action.COMMAND_INSERT_REQUEST); 33 | this.deviceCommand = deviceCommand; 34 | } 35 | 36 | public DeviceCommand getDeviceCommand() { 37 | return deviceCommand; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/CommandInsertResponse.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.DeviceCommand; 24 | import com.devicehive.shim.api.Action; 25 | import com.devicehive.shim.api.Body; 26 | 27 | public class CommandInsertResponse extends Body { 28 | 29 | private DeviceCommand deviceCommand; 30 | 31 | public CommandInsertResponse(DeviceCommand deviceCommand) { 32 | super(Action.COMMAND_INSERT_RESPONSE); 33 | this.deviceCommand = deviceCommand; 34 | } 35 | 36 | public DeviceCommand getDeviceCommand() { 37 | return deviceCommand; 38 | } 39 | 40 | public void setDeviceCommand(DeviceCommand deviceCommand) { 41 | this.deviceCommand = deviceCommand; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/CommandSearchResponse.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.DeviceCommand; 24 | import com.devicehive.shim.api.Action; 25 | import com.devicehive.shim.api.Body; 26 | 27 | import java.util.Collections; 28 | import java.util.List; 29 | 30 | public class CommandSearchResponse extends Body { 31 | 32 | private List commands; 33 | 34 | public CommandSearchResponse() { 35 | super(Action.COMMAND_SEARCH_RESPONSE); 36 | this.commands = Collections.emptyList(); 37 | } 38 | 39 | public List getCommands() { 40 | return commands; 41 | } 42 | 43 | public void setCommands(List commands) { 44 | this.commands = commands; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/CommandUpdateRequest.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.DeviceCommand; 24 | import com.devicehive.shim.api.Action; 25 | import com.devicehive.shim.api.Body; 26 | 27 | public class CommandUpdateRequest extends Body { 28 | 29 | private DeviceCommand deviceCommand; 30 | 31 | public CommandUpdateRequest(DeviceCommand deviceCommand) { 32 | super(Action.COMMAND_UPDATE_REQUEST); 33 | this.deviceCommand = deviceCommand; 34 | } 35 | 36 | public DeviceCommand getDeviceCommand() { 37 | return deviceCommand; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/CommandUpdateSubscribeResponse.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.DeviceCommand; 24 | import com.devicehive.shim.api.Action; 25 | import com.devicehive.shim.api.Body; 26 | 27 | public class CommandUpdateSubscribeResponse extends Body { 28 | 29 | private Long subscriptionId; 30 | private DeviceCommand deviceCommand; 31 | 32 | public CommandUpdateSubscribeResponse(Long subscriptionId, DeviceCommand deviceCommand) { 33 | super(Action.COMMAND_UPDATE_SUBSCRIBE_RESPONSE); 34 | this.subscriptionId = subscriptionId; 35 | this.deviceCommand = deviceCommand; 36 | } 37 | 38 | public Long getSubscriptionId() { 39 | return subscriptionId; 40 | } 41 | 42 | public DeviceCommand getDeviceCommand() { 43 | return deviceCommand; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/CommandsUpdateRequest.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.DeviceCommand; 24 | import com.devicehive.shim.api.Action; 25 | import com.devicehive.shim.api.Body; 26 | 27 | public class CommandsUpdateRequest extends Body { 28 | 29 | private DeviceCommand deviceCommand; 30 | 31 | public CommandsUpdateRequest(DeviceCommand deviceCommand) { 32 | super(Action.COMMANDS_UPDATE_REQUEST); 33 | this.deviceCommand = deviceCommand; 34 | } 35 | 36 | public DeviceCommand getDeviceCommand() { 37 | return deviceCommand; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/CountResponse.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Backend Logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Action; 24 | import com.devicehive.shim.api.Body; 25 | 26 | public class CountResponse extends Body { 27 | 28 | private long count; 29 | 30 | public CountResponse(long count) { 31 | super(Action.COUNT_RESPONSE); 32 | this.count = count; 33 | } 34 | 35 | public long getCount() { 36 | return count; 37 | } 38 | 39 | public void setCount(long count) { 40 | this.count = count; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/DeviceDeleteRequest.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Action; 24 | import com.devicehive.shim.api.Body; 25 | import com.devicehive.vo.DeviceVO; 26 | 27 | public class DeviceDeleteRequest extends Body { 28 | 29 | private DeviceVO device; 30 | 31 | public DeviceDeleteRequest(DeviceVO device) { 32 | super(Action.DEVICE_DELETE_REQUEST); 33 | this.device = device; 34 | } 35 | 36 | public DeviceVO getDevice() { 37 | return device; 38 | } 39 | 40 | public void setDevice(DeviceVO device) { 41 | this.device = device; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return "DeviceDeleteRequest{" + 47 | "device=" + device + 48 | '}'; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/DeviceDeleteResponse.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Action; 24 | import com.devicehive.shim.api.Body; 25 | 26 | public class DeviceDeleteResponse extends Body { 27 | 28 | public DeviceDeleteResponse() { 29 | super(Action.DEVICE_DELETE_RESPONSE); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/ErrorResponse.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Action; 24 | import com.devicehive.shim.api.Body; 25 | 26 | public class ErrorResponse extends Body { 27 | 28 | private String message; 29 | 30 | public ErrorResponse(String message) { 31 | super(Action.ERROR_RESPONSE); 32 | this.message = message; 33 | } 34 | 35 | public String getMessage() { 36 | return message; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/ListDeviceResponse.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Action; 24 | import com.devicehive.shim.api.Body; 25 | import com.devicehive.vo.DeviceVO; 26 | 27 | import java.util.List; 28 | 29 | public class ListDeviceResponse extends Body { 30 | 31 | private List devices; 32 | 33 | public ListDeviceResponse(List devices) { 34 | super(Action.LIST_DEVICE_RESPONSE); 35 | this.devices = devices; 36 | } 37 | 38 | public List getDevices() { 39 | return devices; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/ListDeviceTypeResponse.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Action; 24 | import com.devicehive.shim.api.Body; 25 | import com.devicehive.vo.DeviceTypeVO; 26 | 27 | import java.util.List; 28 | 29 | public class ListDeviceTypeResponse extends Body { 30 | 31 | private List deviceTypes; 32 | 33 | public ListDeviceTypeResponse(List networks) { 34 | super(Action.LIST_DEVICE_TYPE_RESPONSE); 35 | this.deviceTypes = networks; 36 | } 37 | 38 | public List getDeviceTypes() { 39 | return deviceTypes; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/ListNetworkResponse.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Action; 24 | import com.devicehive.shim.api.Body; 25 | import com.devicehive.vo.NetworkVO; 26 | 27 | import java.util.List; 28 | 29 | public class ListNetworkResponse extends Body { 30 | 31 | private List networks; 32 | 33 | public ListNetworkResponse(List networks) { 34 | super(Action.LIST_NETWORK_RESPONSE); 35 | this.networks = networks; 36 | } 37 | 38 | public List getNetworks() { 39 | return networks; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/ListPluginResponse.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Action; 24 | import com.devicehive.shim.api.Body; 25 | import com.devicehive.vo.PluginVO; 26 | 27 | import java.util.List; 28 | 29 | public class ListPluginResponse extends Body { 30 | 31 | private List plugins; 32 | 33 | public ListPluginResponse(List plugins) { 34 | super(Action.LIST_PLUGIN_RESPONSE); 35 | this.plugins = plugins; 36 | } 37 | 38 | public List getPlugins() { 39 | return plugins; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/ListUserResponse.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Action; 24 | import com.devicehive.shim.api.Body; 25 | import com.devicehive.vo.UserVO; 26 | import java.util.List; 27 | 28 | public class ListUserResponse extends Body { 29 | 30 | private List users; 31 | 32 | public ListUserResponse(List users) { 33 | super(Action.LIST_USER_RESPONSE); 34 | this.users = users; 35 | } 36 | 37 | public List getUsers() { 38 | return users; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/NotificationInsertRequest.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.DeviceNotification; 24 | import com.devicehive.shim.api.Action; 25 | import com.devicehive.shim.api.Body; 26 | 27 | public class NotificationInsertRequest extends Body { 28 | 29 | private DeviceNotification deviceNotification; 30 | 31 | public NotificationInsertRequest(DeviceNotification deviceNotification) { 32 | super(Action.NOTIFICATION_INSERT_REQUEST); 33 | this.deviceNotification = deviceNotification; 34 | } 35 | 36 | public DeviceNotification getDeviceNotification() { 37 | return deviceNotification; 38 | } 39 | 40 | public void setDeviceNotification(DeviceNotification deviceNotification) { 41 | this.deviceNotification = deviceNotification; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/NotificationInsertResponse.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.DeviceNotification; 24 | import com.devicehive.shim.api.Action; 25 | import com.devicehive.shim.api.Body; 26 | 27 | public class NotificationInsertResponse extends Body { 28 | 29 | private DeviceNotification deviceNotification; 30 | 31 | public NotificationInsertResponse(DeviceNotification deviceNotification) { 32 | super(Action.NOTIFICATION_INSERT_RESPONSE); 33 | this.deviceNotification = deviceNotification; 34 | } 35 | 36 | public DeviceNotification getDeviceNotification() { 37 | return deviceNotification; 38 | } 39 | 40 | public void setDeviceNotification(DeviceNotification deviceNotification) { 41 | this.deviceNotification = deviceNotification; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/NotificationSearchResponse.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.DeviceNotification; 24 | import com.devicehive.shim.api.Action; 25 | import com.devicehive.shim.api.Body; 26 | 27 | import java.util.List; 28 | 29 | public class NotificationSearchResponse extends Body { 30 | 31 | private final List notifications; 32 | 33 | public NotificationSearchResponse(List notifications) { 34 | super(Action.NOTIFICATION_SEARCH_RESPONSE); 35 | this.notifications = notifications; 36 | } 37 | 38 | public List getNotifications() { 39 | return notifications; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/rpc/PluginUnsubscribeRequest.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.rpc; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Action; 24 | import com.devicehive.shim.api.Body; 25 | 26 | 27 | public class PluginUnsubscribeRequest extends BasePluginRequest { 28 | 29 | private String topicName; 30 | 31 | public PluginUnsubscribeRequest(Long subscriptionId, String topicName) { 32 | super(Action.PLUGIN_UNSUBSCRIBE_REQUEST); 33 | this.subscriptionId = subscriptionId; 34 | this.topicName = topicName; 35 | } 36 | 37 | public String getTopicName() { 38 | return topicName; 39 | } 40 | 41 | public void setTopicName(String topicName) { 42 | this.topicName = topicName; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/model/updates/ConfigurationUpdate.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model.updates; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Dao Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | import com.devicehive.model.HiveEntity; 25 | import com.google.gson.annotations.SerializedName; 26 | 27 | import javax.validation.constraints.NotNull; 28 | import javax.validation.constraints.Size; 29 | 30 | public class ConfigurationUpdate implements HiveEntity { 31 | 32 | private static final long serialVersionUID = 6639933879739273532L; 33 | 34 | @NotNull(message = "value field cannot be null.") 35 | @Size(min = 1, max = 128, message = "Field cannot be empty. The length of value should not be more than " + 36 | "128 symbols.") 37 | @SerializedName("value") 38 | private String value; 39 | 40 | public String getValue() { 41 | return value; 42 | } 43 | 44 | public void setValue(String value) { 45 | this.value = value; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /devicehive-common/src/main/java/com/devicehive/security/jwt/TokenType.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.security.jwt; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Common Module 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.exceptions.HiveException; 24 | 25 | import java.util.Arrays; 26 | 27 | public enum TokenType { 28 | REFRESH(0, "REFRESH"), 29 | ACCESS(1, "ACCESS"); 30 | 31 | private Integer id; 32 | private String name; 33 | 34 | TokenType(Integer id, String name) { 35 | this.id = id; 36 | this.name = name; 37 | } 38 | 39 | public Integer getId() { 40 | return id; 41 | } 42 | 43 | public String getName() { 44 | return name; 45 | } 46 | 47 | public static TokenType getById(Integer id) { 48 | return Arrays.stream(values()) 49 | .filter(tokenType -> tokenType.getId().equals(id)) 50 | .findFirst() 51 | .orElseThrow(() -> new HiveException("No such a token type")); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /devicehive-frontend/missing-license.properties: -------------------------------------------------------------------------------- 1 | # Please fill the missing licenses for dependencies : 2 | 3 | org.apache.zookeeper--zookeeper--3.4.6=Apache 2.0 4 | dom4j--dom4j--1.6.1=BSD style 5 | org.jvnet--tiger-types--1.4=CDDL 1.0 -------------------------------------------------------------------------------- /devicehive-frontend/src/main/java/com/devicehive/application/filter/ContentTypeFilter.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.application.filter; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.springframework.http.HttpHeaders; 24 | 25 | import javax.ws.rs.container.ContainerRequestContext; 26 | import javax.ws.rs.container.ContainerRequestFilter; 27 | import javax.ws.rs.container.PreMatching; 28 | import javax.ws.rs.core.MediaType; 29 | import javax.ws.rs.ext.Provider; 30 | import java.io.IOException; 31 | 32 | @Provider 33 | @PreMatching 34 | public class ContentTypeFilter implements ContainerRequestFilter { 35 | 36 | @Override 37 | public void filter(ContainerRequestContext containerRequestContext) throws IOException { 38 | if(!containerRequestContext.getHeaders().containsKey(HttpHeaders.CONTENT_TYPE)){ 39 | containerRequestContext.getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /devicehive-frontend/src/main/java/com/devicehive/auth/websockets/HiveWebsocketAuth.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.auth.websockets; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Frontend Logic 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.lang.annotation.ElementType; 24 | import java.lang.annotation.Retention; 25 | import java.lang.annotation.RetentionPolicy; 26 | import java.lang.annotation.Target; 27 | 28 | /** 29 | * Annotation for specifying a method that should be secured with {@link WebSocketActionAuthenticationAspect} 30 | * Last argument of annotated method must be of type {@link org.springframework.web.socket.WebSocketSession} 31 | */ 32 | @Target(ElementType.METHOD) 33 | @Retention(RetentionPolicy.RUNTIME) 34 | public @interface HiveWebsocketAuth { 35 | 36 | } 37 | -------------------------------------------------------------------------------- /devicehive-frontend/src/main/java/com/devicehive/messages/handler/AsyncResponseClientHandler.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.messages.handler; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Frontend Logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.google.gson.JsonObject; 24 | 25 | import javax.ws.rs.container.AsyncResponse; 26 | 27 | public class AsyncResponseClientHandler implements ClientHandler { 28 | 29 | private AsyncResponse asyncResponse; 30 | 31 | public AsyncResponseClientHandler(AsyncResponse asyncResponse) { 32 | this.asyncResponse = asyncResponse; 33 | } 34 | 35 | @Override 36 | public void sendMessage(JsonObject json) { 37 | asyncResponse.resume(json); 38 | } 39 | 40 | } 41 | -------------------------------------------------------------------------------- /devicehive-frontend/src/main/java/com/devicehive/messages/handler/ClientHandler.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.messages.handler; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Frontend Logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.google.gson.JsonObject; 24 | 25 | public interface ClientHandler { 26 | 27 | void sendMessage(JsonObject json); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /devicehive-frontend/src/main/java/com/devicehive/model/SpecialNotifications.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.model; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | public final class SpecialNotifications { 25 | 26 | /** 27 | * Server-originated notification about new device registration 28 | */ 29 | public static final String DEVICE_ADD = "$device-add"; 30 | /** 31 | * Server-originated notification about device changes 32 | */ 33 | public static final String DEVICE_UPDATE = "$device-update"; 34 | } 35 | -------------------------------------------------------------------------------- /devicehive-frontend/src/main/java/com/devicehive/resource/WelcomeResource.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Frontend Logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.springframework.security.access.prepost.PreAuthorize; 24 | 25 | import javax.ws.rs.GET; 26 | import javax.ws.rs.Path; 27 | import javax.ws.rs.Produces; 28 | import javax.ws.rs.core.Response; 29 | 30 | @Path("/") 31 | @Produces({"text/plain"}) 32 | public interface WelcomeResource { 33 | 34 | @GET 35 | @PreAuthorize("permitAll") 36 | Response getWelcomeInfo(); 37 | } 38 | -------------------------------------------------------------------------------- /devicehive-frontend/src/main/java/com/devicehive/resource/impl/WelcomeResourceImpl.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource.impl; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Frontend Logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.configuration.Constants; 24 | import com.devicehive.json.strategies.JsonPolicyDef; 25 | import com.devicehive.resource.WelcomeResource; 26 | import com.devicehive.resource.util.ResponseFactory; 27 | import org.springframework.stereotype.Service; 28 | 29 | import javax.ws.rs.core.Response; 30 | 31 | @Service 32 | public class WelcomeResourceImpl implements WelcomeResource { 33 | 34 | @Override 35 | public Response getWelcomeInfo() { 36 | return ResponseFactory.response(Response.Status.OK, Constants.WELCOME_MESSAGE, 37 | JsonPolicyDef.Policy.REST_SERVER_INFO); 38 | } 39 | } 40 | 41 | -------------------------------------------------------------------------------- /devicehive-frontend/src/main/java/com/devicehive/resource/util/JsonTypes.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource.util; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Frontend Logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.google.gson.reflect.TypeToken; 24 | 25 | import java.lang.reflect.Type; 26 | import java.util.HashSet; 27 | 28 | public interface JsonTypes { 29 | Type STRING_SET_TYPE = new TypeToken>() {}.getType(); 30 | Type LONG_SET_TYPE = new TypeToken>() {}.getType(); 31 | } 32 | -------------------------------------------------------------------------------- /devicehive-frontend/src/main/java/com/devicehive/util/ThreadLocalVariablesKeeper.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.util; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | import com.google.gson.JsonObject; 25 | import org.springframework.web.socket.WebSocketSession; 26 | 27 | public final class ThreadLocalVariablesKeeper { 28 | 29 | private static ThreadLocal REQUEST = new ThreadLocal<>(); 30 | private static ThreadLocal SESSION = new ThreadLocal<>(); 31 | 32 | public static JsonObject getRequest() { 33 | return REQUEST.get(); 34 | } 35 | 36 | public static void setRequest(JsonObject request) { 37 | REQUEST.set(request); 38 | } 39 | 40 | public static WebSocketSession getSession() { 41 | return SESSION.get(); 42 | } 43 | 44 | public static void setSession(WebSocketSession session) { 45 | SESSION.set(session); 46 | } 47 | 48 | 49 | public static void clean() { 50 | REQUEST.set(null); 51 | SESSION.set(null); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /devicehive-frontend/src/main/java/com/devicehive/websockets/HiveWebsocketSessionState.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.websockets; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Frontend Logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | import com.devicehive.auth.HivePrincipal; 25 | import org.springframework.web.socket.WebSocketSession; 26 | 27 | public class HiveWebsocketSessionState { 28 | 29 | public static final String KEY = HiveWebsocketSessionState.class.getName(); 30 | private HivePrincipal hivePrincipal; 31 | 32 | public static HiveWebsocketSessionState get(WebSocketSession session) { 33 | return (HiveWebsocketSessionState) session.getAttributes().get(HiveWebsocketSessionState.KEY); 34 | } 35 | 36 | public HivePrincipal getHivePrincipal() { 37 | return hivePrincipal; 38 | } 39 | 40 | public void setHivePrincipal(HivePrincipal hivePrincipal) { 41 | this.hivePrincipal = hivePrincipal; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /devicehive-frontend/src/main/java/com/devicehive/websockets/events/WSMessageEvent.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.websockets.events; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Frontend Logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.google.gson.JsonElement; 24 | import org.springframework.web.socket.WebSocketSession; 25 | 26 | public class WSMessageEvent { 27 | 28 | private JsonElement message; 29 | private WebSocketSession session; 30 | 31 | public JsonElement getMessage() { 32 | return message; 33 | } 34 | 35 | public WebSocketSession getSession() { 36 | return session; 37 | } 38 | 39 | public void setMessage(JsonElement message) { 40 | this.message = message; 41 | } 42 | 43 | public void setSession(WebSocketSession session) { 44 | this.session = session; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /devicehive-frontend/src/main/resources/messages_en_EN.properties: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # DeviceHive Frontend Logic 4 | # %% 5 | # Copyright (C) 2016 DataArt 6 | # %% 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # #L% 19 | ### 20 | -------------------------------------------------------------------------------- /devicehive-frontend/src/test/java/com/devicehive/base/fixture/DeviceFixture.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.base.fixture; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.model.JsonStringWrapper; 24 | import com.devicehive.model.updates.DeviceUpdate; 25 | import com.devicehive.vo.DeviceVO; 26 | import com.devicehive.vo.NetworkVO; 27 | 28 | import java.util.UUID; 29 | 30 | public class DeviceFixture { 31 | 32 | public static DeviceUpdate createDevice(String deviceId) { 33 | DeviceUpdate device = new DeviceUpdate(); 34 | device.setName("device-" + deviceId); 35 | device.setData(new JsonStringWrapper(String.format("{\"data\": \"device_data-%s\"}", deviceId))); 36 | return device; 37 | } 38 | 39 | public static DeviceVO createDeviceVO() { 40 | final UUID uuid = UUID.randomUUID(); 41 | final DeviceVO device = new DeviceVO(); 42 | device.setDeviceId(uuid.toString()); 43 | device.setName("name-" + uuid.toString()); 44 | return device; 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /devicehive-frontend/src/test/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # DeviceHive Frontend Logic 4 | # %% 5 | # Copyright (C) 2016 DataArt 6 | # %% 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # #L% 19 | ### 20 | spring.profiles.include=rpc-client,rpc-server 21 | 22 | # HTTP message conversion 23 | spring.mvc.converters.preferred-json-mapper=gson 24 | 25 | # Kafka properties 26 | bootstrap.servers=127.0.0.1:9092 27 | zookeeper.connect=127.0.0.1:2181 28 | 29 | flyway.enabled=false 30 | -------------------------------------------------------------------------------- /devicehive-frontend/src/test/resources/initial_data.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Frontend Logic 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | -- 1. Default users 21 | -- admin -> test_admin : admin_pass 22 | INSERT INTO "dh_user" (login, password_hash, password_salt, role, status, login_attempts) VALUES ('test_admin', '+IC4w+NeByiymEWlI5H1xbtNe4YKmPlLRZ7j3xaireg=', '9KynX3ShWnFym4y8Dla039py', 0, 0, 0); 23 | 24 | INSERT INTO configuration (name, value, entity_version) VALUES ('session.timeout', '1200000', 0); 25 | INSERT INTO configuration (name, value, entity_version) VALUES ('allowNetworkAutoCreate', 'true', 0); 26 | INSERT INTO configuration (name, value, entity_version) VALUES ('user.login.lastTimeout', '1000', 0); 27 | INSERT INTO configuration (name, value, entity_version) VALUES ('jwt.secret', 'devicehive', 0); 28 | 29 | -- 2. Default networks 30 | INSERT INTO network (name, description) VALUES ('VirtualLed Sample Network', 'A DeviceHive network for VirtualLed sample'); 31 | 32 | -- 3. Default devices 33 | INSERT INTO device (device_id, name, network_id, blocked) VALUES ('E50D6085-2ABA-48E9-B1C3-73C673E414BE', 'Sample VirtualLed Device', 1, FALSE); 34 | -------------------------------------------------------------------------------- /devicehive-plugin/missing-license.properties: -------------------------------------------------------------------------------- 1 | # Please fill the missing licenses for dependencies : 2 | 3 | org.apache.zookeeper--zookeeper--3.4.6=Apache 2.0 4 | dom4j--dom4j--1.6.1=BSD style 5 | org.jvnet--tiger-types--1.4=CDDL 1.0 -------------------------------------------------------------------------------- /devicehive-plugin/src/main/java/com/devicehive/application/filter/ContentTypeFilter.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.application.filter; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import org.springframework.http.HttpHeaders; 24 | 25 | import javax.ws.rs.container.ContainerRequestContext; 26 | import javax.ws.rs.container.ContainerRequestFilter; 27 | import javax.ws.rs.container.PreMatching; 28 | import javax.ws.rs.core.MediaType; 29 | import javax.ws.rs.ext.Provider; 30 | import java.io.IOException; 31 | 32 | @Provider 33 | @PreMatching 34 | public class ContentTypeFilter implements ContainerRequestFilter { 35 | 36 | @Override 37 | public void filter(ContainerRequestContext containerRequestContext) throws IOException { 38 | if(!containerRequestContext.getHeaders().containsKey(HttpHeaders.CONTENT_TYPE)){ 39 | containerRequestContext.getHeaders().add(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /devicehive-plugin/src/main/java/com/devicehive/resource/impl/PluginApiInfoResourceImpl.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource.impl; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | import com.devicehive.resource.BaseApiInfoResource; 25 | import com.devicehive.resource.PluginApiInfoResource; 26 | import org.springframework.beans.factory.annotation.Autowired; 27 | import org.springframework.stereotype.Service; 28 | 29 | import javax.ws.rs.core.Response; 30 | import javax.ws.rs.core.UriInfo; 31 | 32 | /** 33 | * Provide API information 34 | */ 35 | @Service 36 | public class PluginApiInfoResourceImpl implements PluginApiInfoResource { 37 | 38 | private final BaseApiInfoResource baseApiInfoResource; 39 | 40 | @Autowired 41 | public PluginApiInfoResourceImpl(BaseApiInfoResource baseApiInfoResource) { 42 | this.baseApiInfoResource = baseApiInfoResource; 43 | } 44 | 45 | @Override 46 | public Response getApiInfo(UriInfo uriInfo, String protocol) { 47 | return baseApiInfoResource.getApiInfo(uriInfo, protocol); 48 | } 49 | } 50 | 51 | -------------------------------------------------------------------------------- /devicehive-plugin/src/main/java/com/devicehive/resource/util/JsonTypes.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.resource.util; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Frontend Logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.google.gson.reflect.TypeToken; 24 | 25 | import java.lang.reflect.Type; 26 | import java.util.HashSet; 27 | 28 | public interface JsonTypes { 29 | Type STRING_SET_TYPE = new TypeToken>() {}.getType(); 30 | Type LONG_SET_TYPE = new TypeToken>() {}.getType(); 31 | } 32 | -------------------------------------------------------------------------------- /devicehive-plugin/src/main/java/com/devicehive/service/KafkaWsTopicService.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.service; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Frontend Logic 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.proxy.PluginProxyClient; 24 | import com.devicehive.shim.kafka.topic.KafkaTopicService; 25 | import org.springframework.beans.factory.annotation.Autowired; 26 | import org.springframework.context.annotation.Profile; 27 | import org.springframework.stereotype.Component; 28 | 29 | import java.util.Arrays; 30 | 31 | @Component 32 | @Profile("ws-kafka-proxy") 33 | public class KafkaWsTopicService implements KafkaTopicService { 34 | 35 | private final PluginProxyClient pluginProxyClient; 36 | 37 | @Autowired 38 | public KafkaWsTopicService(PluginProxyClient pluginProxyClient) { 39 | this.pluginProxyClient = pluginProxyClient; 40 | } 41 | 42 | @Override 43 | public void createTopic(String topic) { 44 | pluginProxyClient.createTopic(Arrays.asList(topic)); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /devicehive-plugin/src/main/java/com/devicehive/util/ThreadLocalVariablesKeeper.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.util; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | import com.google.gson.JsonObject; 25 | import org.springframework.web.socket.WebSocketSession; 26 | 27 | public final class ThreadLocalVariablesKeeper { 28 | 29 | private static ThreadLocal REQUEST = new ThreadLocal<>(); 30 | private static ThreadLocal SESSION = new ThreadLocal<>(); 31 | 32 | public static JsonObject getRequest() { 33 | return REQUEST.get(); 34 | } 35 | 36 | public static void setRequest(JsonObject request) { 37 | REQUEST.set(request); 38 | } 39 | 40 | public static WebSocketSession getSession() { 41 | return SESSION.get(); 42 | } 43 | 44 | public static void setSession(WebSocketSession session) { 45 | SESSION.set(session); 46 | } 47 | 48 | 49 | public static void clean() { 50 | REQUEST.set(null); 51 | SESSION.set(null); 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /devicehive-plugin/src/main/resources/messages_en_EN.properties: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # DeviceHive Frontend Logic 4 | # %% 5 | # Copyright (C) 2016 DataArt 6 | # %% 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # #L% 19 | ### 20 | -------------------------------------------------------------------------------- /devicehive-plugin/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker: -------------------------------------------------------------------------------- 1 | mock-maker-inline -------------------------------------------------------------------------------- /devicehive-proxy-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | com.devicehive 9 | devicehive-server 10 | 4.1.0 11 | 12 | devicehive-proxy-api 13 | jar 14 | DeviceHive Proxy API Interfaces 15 | 16 | 17 | ${project.parent.basedir} 18 | 19 | 20 | 21 | 22 | com.google.code.gson 23 | gson 24 | 25 | 26 | -------------------------------------------------------------------------------- /devicehive-proxy-api/src/main/java/com/devicehive/proxy/api/NotificationHandler.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.proxy.api; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Proxy WebSocket Kafka Implementation 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | public interface NotificationHandler { 24 | 25 | void handle(String message, ProxyClient client); 26 | } 27 | -------------------------------------------------------------------------------- /devicehive-proxy-api/src/main/java/com/devicehive/proxy/api/ProxyClient.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.proxy.api; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Proxy API Interfaces 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import java.util.concurrent.CompletableFuture; 24 | 25 | public abstract class ProxyClient { 26 | 27 | protected NotificationHandler notificationHandler; 28 | 29 | public ProxyClient(NotificationHandler notificationHandler) { 30 | this.notificationHandler = notificationHandler; 31 | } 32 | 33 | public abstract void start(); 34 | 35 | public abstract void shutdown(); 36 | 37 | public abstract CompletableFuture push(ProxyMessage message); 38 | } 39 | -------------------------------------------------------------------------------- /devicehive-proxy-api/src/main/java/com/devicehive/proxy/api/payload/MessagePayload.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.proxy.api.payload; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Proxy WebSocket Kafka Implementation 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.google.gson.annotations.SerializedName; 24 | 25 | public class MessagePayload implements Payload { 26 | 27 | @SerializedName("m") 28 | protected String message; 29 | 30 | public MessagePayload(String message) { 31 | this.message = message; 32 | } 33 | 34 | public String getMessage() { 35 | return message; 36 | } 37 | 38 | public void setMessage(String message) { 39 | this.message = message; 40 | } 41 | 42 | @Override 43 | public String toString() { 44 | return "Payload{" + 45 | "message='" + message + '\'' + 46 | '}'; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /devicehive-proxy-api/src/main/java/com/devicehive/proxy/api/payload/Payload.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.proxy.api.payload; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Proxy API Interfaces 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | public interface Payload { 24 | } 25 | -------------------------------------------------------------------------------- /devicehive-proxy-api/src/main/java/com/devicehive/proxy/api/payload/TopicsPayload.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.proxy.api.payload; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Proxy WebSocket Kafka Implementation 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.google.gson.annotations.SerializedName; 24 | 25 | import java.util.Collections; 26 | import java.util.List; 27 | 28 | public class TopicsPayload implements Payload { 29 | 30 | @SerializedName("t") 31 | private List topics; 32 | 33 | public TopicsPayload(List topics) { 34 | this.topics = topics; 35 | } 36 | 37 | public TopicsPayload(String topic) { 38 | this.topics = Collections.singletonList(topic); 39 | } 40 | 41 | public List getTopics() { 42 | return topics; 43 | } 44 | 45 | public void setTopics(List topics) { 46 | this.topics = topics; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return "TopicsPayload{" + 52 | "topics=" + topics + 53 | '}'; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /devicehive-proxy-ws-kafka-impl/src/main/java/com/devicehive/proxy/client/GsonProxyMessageEncoder.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.proxy.client; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Proxy WebSocket Kafka Implementation 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.proxy.api.ProxyMessage; 24 | import com.google.gson.Gson; 25 | 26 | import javax.websocket.EncodeException; 27 | import javax.websocket.Encoder; 28 | import javax.websocket.EndpointConfig; 29 | 30 | public class GsonProxyMessageEncoder implements Encoder.Text { 31 | 32 | private static Gson gson = new Gson(); 33 | 34 | public GsonProxyMessageEncoder() { 35 | } 36 | 37 | @Override 38 | public String encode(ProxyMessage message) throws EncodeException { 39 | return gson.toJson(message); 40 | } 41 | 42 | @Override 43 | public void init(EndpointConfig config) { 44 | 45 | } 46 | 47 | @Override 48 | public void destroy() { 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /devicehive-proxy-ws-kafka-impl/src/main/resources/kafka-ws-proxy.properties: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # DeviceHive Shim Kafka Implementation 4 | # %% 5 | # Copyright (C) 2016 DataArt 6 | # %% 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # #L% 19 | ### 20 | 21 | # toDo: change default 22 | proxy.connect=localhost:3000 23 | proxy.request-consumer.group=ws-proxy-consumer-group 24 | 25 | proxy.worker.threads=3 26 | lmax.buffer-size=1024 27 | lmax.wait.strategy=blocking -------------------------------------------------------------------------------- /devicehive-rdbms-dao/missing-license.properties: -------------------------------------------------------------------------------- 1 | # Please fill the missing licenses for dependencies : 2 | 3 | org.apache.zookeeper--zookeeper--3.4.6=Apache 2.0 4 | dom4j--dom4j--1.6.1=BSD style -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/java/com/devicehive/dao/rdbms/CacheHelper.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.dao.rdbms; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Dao RDBMS Implementation 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import javax.persistence.CacheRetrieveMode; 24 | import javax.persistence.CacheStoreMode; 25 | import javax.persistence.Query; 26 | 27 | public class CacheHelper { 28 | 29 | public static final String CACHEBLE = "org.hibernate.cacheable"; 30 | public static final String RETRIEVE_MODE = "javax.persistence.cache.retrieveMode"; 31 | public static final String STORE_MODE = "javax.persistence.cache.storeMode"; 32 | 33 | public static void cacheable(Query query) { 34 | query.setHint(CACHEBLE, true); 35 | query.setHint(RETRIEVE_MODE, CacheRetrieveMode.USE); 36 | query.setHint(STORE_MODE, CacheStoreMode.USE); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/application-persistence.properties: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # DeviceHive Dao RDBMS Implementation 4 | # %% 5 | # Copyright (C) 2016 DataArt 6 | # %% 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # #L% 19 | ### 20 | # DATASOURCE 21 | spring.datasource.driver-class-name=org.postgresql.Driver 22 | spring.datasource.url=jdbc:postgresql://127.0.0.1:5432/devicehive 23 | spring.datasource.username=postgres 24 | spring.datasource.password=12345 25 | 26 | # JPA 27 | spring.data.jpa.repositories.enabled=false 28 | 29 | spring.jpa.hibernate.ddl-auto=none 30 | spring.jpa.show-sql=false 31 | spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQL10Dialect 32 | spring.jpa.properties.hibernate.format_sql=true 33 | spring.jpa.properties.hibernate.id.new_generator_mappings=true 34 | spring.jpa.properties.hibernate.cache.use_second_level_cache=true 35 | spring.jpa.properties.hibernate.cache.use_query_cache=true 36 | spring.jpa.properties.hibernate.generate_statistics=true 37 | spring.jpa.properties.hibernate.cache.use_structured_entries=true 38 | spring.jpa.properties.hibernate.cache.region.factory_class=org.redisson.hibernate.RedissonRegionFactory 39 | spring.redis.redisson.file=classpath:redisson.yaml 40 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/application-test-configuration.properties: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # DeviceHive Dao RDBMS Implementation 4 | # %% 5 | # Copyright (C) 2016 DataArt 6 | # %% 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # #L% 19 | ### 20 | 21 | # DATASOURCE 22 | spring.datasource.driver-class-name=org.hsqldb.jdbcDriver 23 | spring.datasource.url=jdbc:hsqldb:mem:testdb 24 | spring.datasource.username=sa 25 | spring.datasource.password= 26 | 27 | # JPA 28 | spring.jpa.hibernate.ddl-auto=create-drop 29 | spring.jpa.show-sql=false 30 | spring.jpa.properties.hibernate.dialect=com.devicehive.test.dialect.HsqlDialectReplacement 31 | spring.jpa.properties.hibernate.format_sql=true 32 | spring.jpa.properties.hibernate.id.new_generator_mappings=true 33 | spring.jpa.properties.hibernate.cache.use_second_level_cache=false 34 | spring.jpa.properties.hibernate.cache.use_query_cache=false 35 | spring.jpa.properties.hibernate.cache.use_minimal_puts=true 36 | spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true 37 | spring.jpa.properties.hibernate.hbm2ddl.import_files=initial_data.sql -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V2_0_10__drop_oauth_server_tables.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | DROP TABLE IF EXISTS oauth_grant; 21 | DROP TABLE IF EXISTS oauth_client; 22 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V2_0_11__drop_access_key_tables.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | DROP TABLE IF EXISTS access_key_permission; 21 | DROP TABLE IF EXISTS access_key; 22 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V2_0_2__delete_db_timestamp.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | DROP VIEW IF EXISTS get_timestamp; -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V2_0_3__102_make_key_nullable.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | alter table device alter column key drop not null; 21 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V2_0_4__remove_device_key.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | ALTER TABLE device DROP COLUMN IF EXISTS KEY; -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V2_0_5__configuration_table_changes.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | --- create separate table to keep all the 21 | create temp table configuration_temp_migration as select name, value, entity_version from configuration; 22 | 23 | drop table configuration; 24 | 25 | create table configuration ( 26 | name varchar(32) not null, 27 | value varchar(128) not null, 28 | entity_version bigint not null default 0 29 | ); 30 | 31 | -- add primary key 32 | alter table configuration add constraint configuration_pk primary key (name); 33 | 34 | -- copy values back into the provider table 35 | insert into configuration (name, value, entity_version) 36 | select name, value, entity_version from configuration_temp_migration; 37 | 38 | -- done -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V2_0_6__identity_provider_name_as_key.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | --- create separate table to keep all the 21 | create temp table identity_temp_migration as 22 | select name, api_endpoint, verification_endpoint, token_endpoint 23 | from identity_provider; 24 | 25 | drop table identity_provider; 26 | 27 | create table identity_provider ( 28 | name varchar(64) NOT NULL, 29 | api_endpoint varchar(128), 30 | verification_endpoint varchar(128), 31 | token_endpoint varchar(128) 32 | ); 33 | 34 | -- add primary key 35 | alter table identity_provider add constraint identity_provider_pk primary key (name); 36 | 37 | -- copy values back into the provider table 38 | insert into identity_provider (name, api_endpoint, verification_endpoint, token_endpoint) 39 | select name, api_endpoint, verification_endpoint, token_endpoint from identity_temp_migration; 40 | 41 | -- done -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V2_0_7__device_class_version_remove.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | DROP INDEX device_class_name_version_idx; 21 | ALTER TABLE device_class DROP CONSTRAINT device_class_name_version_unique; 22 | ALTER TABLE device_class DROP COLUMN IF EXISTS version; -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V2_0_8__set_allow_network_autrocreate_and_add_default_user_to_network.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | INSERT INTO user_network (user_id, network_id) VALUES (1, 1); 21 | 22 | INSERT INTO configuration (name, value) VALUES ('allowNetworkAutoCreate', true); 23 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V2_0_9__update_facebook_api_endpoint.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | UPDATE identity_provider SET api_endpoint = 'https://graph.facebook.com/me?fields=email' WHERE name = 'facebook'; 21 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_0_10__drop_network_auto_creation.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016-2017 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | DELETE FROM configuration 21 | WHERE name = 'allowNetworkAutoCreate'; -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_0_11__drop_user_anonymous_create_configuration.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | DELETE FROM configuration WHERE name = 'user.anonymous_creation'; 21 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_0_12__drop_network_key.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | ALTER TABLE network DROP COLUMN IF EXISTS key; 21 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_0_13__rename_device_guid_into_id.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | ALTER TABLE device RENAME guid TO device_id; 21 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_0_14__drop_deleted_user_status.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | UPDATE "user" SET status = 2 WHERE status = 3; 21 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_0_1__drop_device_status_and_device_class_offline_timeout.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | ALTER TABLE "device" DROP COLUMN IF EXISTS "status" CASCADE; 21 | ALTER TABLE "device_class" DROP COLUMN IF EXISTS "offline_timeout" CASCADE; -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_0_2__set_user_anonymous_create_configuration.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | INSERT INTO configuration (name, value) VALUES ('user.anonymous_creation', true); 21 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_0_3__delete_oauth_columns.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | 21 | ALTER TABLE "user" DROP COLUMN IF EXISTS "google_login"; 22 | ALTER TABLE "user" DROP COLUMN IF EXISTS "facebook_login"; 23 | ALTER TABLE "user" DROP COLUMN IF EXISTS "github_login"; -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_0_4__drop_device_equipment_table.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | DROP TABLE IF EXISTS device_equipment; 21 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_0_5__drop_equipment_table.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | DROP TABLE IF EXISTS equipment; 21 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_0_6__configuration_table_update.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | 21 | DELETE FROM configuration c where c.name = 'debugMode'; 22 | DELETE FROM configuration c where c.name = 'google.identity.allowed'; 23 | DELETE FROM configuration c where c.name = 'facebook.identity.allowed'; 24 | DELETE FROM configuration c where c.name = 'github.identity.allowed'; 25 | DELETE FROM configuration c where c.name = 'session.timeout'; 26 | DELETE FROM configuration c where c.name = 'websocket.ping.timeout'; 27 | DELETE FROM configuration c where c.name = 'cassandra.rest.endpoint'; -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_0_7__drop_identity_provider.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | DROP TABLE IF EXISTS identity_provider; -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_0_8__drop_device_class.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | ALTER TABLE device DROP COLUMN IF EXISTS device_class_id; 21 | DROP TABLE IF EXISTS device_class; -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_0_9__add_intro_reviewed_column.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | ALTER TABLE "user" ADD COLUMN intro_reviewed bool DEFAULT FALSE; -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_1_1__update_default_network_device.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 - 2017 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | UPDATE device 21 | SET name = 'Sample Device' 22 | WHERE name = 'Sample VirtualLed Device'; 23 | 24 | UPDATE network 25 | SET name = 'Sample Network', description = 'A DeviceHive Sample Network' 26 | WHERE name = 'VirtualLed Sample Network'; 27 | 28 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_1_2__alter_user_table_name.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 - 2017 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | 21 | ALTER TABLE "user" RENAME TO "dh_user"; 22 | 23 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_4_10__alter_plugin_table_constraints.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | 21 | ALTER TABLE plugin ALTER COLUMN subscription_id DROP NOT NULL; -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_4_11__alter_plugin_table_name_constraint.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | 21 | ALTER TABLE plugin DROP CONSTRAINT plugin_name_unique; -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_4_12__recreate_configuration_table_id_added.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 - 2017 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | 21 | --DROP TABLE configuration; 22 | -- 23 | --CREATE TABLE configuration ( 24 | -- id serial PRIMARY KEY, 25 | -- name VARCHAR ( 32 ) UNIQUE NOT NULL, 26 | -- value VARCHAR ( 128 ) NOT NULL, 27 | -- entity_version bigint 28 | --); 29 | 30 | 31 | ALTER TABLE configuration DROP CONSTRAINT configuration_pk; 32 | ALTER TABLE configuration ADD COLUMN id serial PRIMARY KEY; 33 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_4_1__create_plugin_table.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2017 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | -- PostgreSQL database creation script for DeviceHive 21 | CREATE TABLE plugin ( 22 | id BIGSERIAL NOT NULL, 23 | name VARCHAR(128) NOT NULL, 24 | description VARCHAR(128) NULL, 25 | topic_name VARCHAR(128) NOT NULL, 26 | health_check_url VARCHAR(128) NOT NULL, 27 | status INT NOT NULL, 28 | subscription_id BIGSERIAL NOT NULL, 29 | user_id BIGSERIAL NOT NULL, 30 | parameters TEXT NULL, 31 | entity_version BIGINT NOT NULL DEFAULT 0 32 | ); 33 | 34 | ALTER TABLE plugin ADD CONSTRAINT plugin_pk PRIMARY KEY (id); 35 | ALTER TABLE plugin ADD CONSTRAINT plugin_name_unique UNIQUE (name); 36 | ALTER TABLE plugin ADD CONSTRAINT plugin_topic_unique UNIQUE (topic_name); 37 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_4_3__delete_plugin_health_check_url_column.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2017 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | -- PostgreSQL database creation script for DeviceHive 21 | ALTER TABLE "plugin" DROP COLUMN IF EXISTS "health_check_url"; -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_4_5__add_all_device_types_available_column.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | 21 | -- Add allDeviceTypesAvailable column to users 22 | ALTER TABLE dh_user ADD COLUMN all_device_types_available BOOLEAN DEFAULT TRUE; 23 | 24 | -- Set allDeviceTypesAvailable to true if it is null 25 | UPDATE dh_user SET all_device_types_available = TRUE WHERE all_device_types_available IS NULL; -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_4_6__add_default_device_type_to_devices.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | UPDATE device SET device_type_id = 1 WHERE device_type_id IS NULL; -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_4_7__add_filter_column.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | 21 | -- Add filter column to plugin 22 | ALTER TABLE plugin ADD COLUMN filter VARCHAR(256); -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/db/migration/V3_4_9__alter_plugin_table_column_types.sql: -------------------------------------------------------------------------------- 1 | --- 2 | -- #%L 3 | -- DeviceHive Dao RDBMS Implementation 4 | -- %% 5 | -- Copyright (C) 2016 - 2017 DataArt 6 | -- %% 7 | -- Licensed under the Apache License, Version 2.0 (the "License"); 8 | -- you may not use this file except in compliance with the License. 9 | -- You may obtain a copy of the License at 10 | -- 11 | -- http://www.apache.org/licenses/LICENSE-2.0 12 | -- 13 | -- Unless required by applicable law or agreed to in writing, software 14 | -- distributed under the License is distributed on an "AS IS" BASIS, 15 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | -- See the License for the specific language governing permissions and 17 | -- limitations under the License. 18 | -- #L% 19 | --- 20 | 21 | alter table plugin 22 | alter column subscription_id drop default; 23 | drop sequence plugin_subscription_id_seq; 24 | 25 | alter table plugin 26 | alter column user_id drop default; 27 | drop sequence plugin_user_id_seq; 28 | -------------------------------------------------------------------------------- /devicehive-rdbms-dao/src/main/resources/redisson.yaml: -------------------------------------------------------------------------------- 1 | codec: 2 | class: org.redisson.codec.SerializationCodec 3 | singleServerConfig: 4 | address: "redis://${REDIS_MASTER_HOST}:${REDIS_MASTER_PORT}" 5 | idleConnectionTimeout: 10000 6 | connectTimeout: 10000 7 | timeout: 3000 8 | retryAttempts: 3 9 | retryInterval: 1500 10 | subscriptionsPerConnection: 5 -------------------------------------------------------------------------------- /devicehive-shim-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | 8 | com.devicehive 9 | devicehive-server 10 | 4.1.0 11 | 12 | 13 | devicehive-shim-api 14 | jar 15 | DeviceHive Shim API Interfaces 16 | 17 | 18 | ${project.parent.basedir} 19 | 20 | 21 | 22 | 23 | org.apache.commons 24 | commons-lang3 25 | 26 | 27 | com.google.code.gson 28 | gson 29 | 30 | 31 | -------------------------------------------------------------------------------- /devicehive-shim-api/src/main/java/com/devicehive/shim/api/RequestType.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.shim.api; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Shim API Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | public enum RequestType { 24 | clientRequest, ping 25 | } 26 | -------------------------------------------------------------------------------- /devicehive-shim-api/src/main/java/com/devicehive/shim/api/client/RpcClient.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.shim.api.client; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Shim API Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Request; 24 | import com.devicehive.shim.api.Response; 25 | import com.google.gson.Gson; 26 | 27 | import java.util.function.Consumer; 28 | 29 | public interface RpcClient { 30 | 31 | void call(Request request, Consumer callback); 32 | 33 | void push(Request request); 34 | 35 | default void start() { } 36 | 37 | default void shutdown() { } 38 | } 39 | -------------------------------------------------------------------------------- /devicehive-shim-api/src/main/java/com/devicehive/shim/api/server/MessageDispatcher.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.shim.api.server; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Shim API Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Response; 24 | 25 | public interface MessageDispatcher { 26 | 27 | void send(String to, Response response); 28 | 29 | } 30 | -------------------------------------------------------------------------------- /devicehive-shim-api/src/main/java/com/devicehive/shim/api/server/RequestHandler.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.shim.api.server; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Shim API Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Request; 24 | import com.devicehive.shim.api.Response; 25 | 26 | public interface RequestHandler { 27 | 28 | Response handle(Request request); 29 | 30 | } 31 | -------------------------------------------------------------------------------- /devicehive-shim-api/src/main/java/com/devicehive/shim/api/server/RpcServer.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.shim.api.server; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Shim API Interfaces 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | public interface RpcServer { 24 | 25 | void start(); 26 | 27 | void shutdown(); 28 | 29 | MessageDispatcher getDispatcher(); 30 | } 31 | -------------------------------------------------------------------------------- /devicehive-shim-kafka-impl/missing-license.properties: -------------------------------------------------------------------------------- 1 | # Please fill the missing licenses for dependencies : 2 | 3 | org.apache.zookeeper--zookeeper--3.4.6=Apache 2.0 4 | dom4j--dom4j--1.6.1=BSD style -------------------------------------------------------------------------------- /devicehive-shim-kafka-impl/src/main/java/com/devicehive/shim/kafka/topic/KafkaTopicService.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.shim.kafka.topic; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Frontend Logic 6 | * %% 7 | * Copyright (C) 2016 - 2017 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | public interface KafkaTopicService { 24 | void createTopic(String topic); 25 | } 26 | -------------------------------------------------------------------------------- /devicehive-shim-kafka-impl/src/main/resources/kafka.properties: -------------------------------------------------------------------------------- 1 | ### 2 | # #%L 3 | # DeviceHive Shim Kafka Implementation 4 | # %% 5 | # Copyright (C) 2016 DataArt 6 | # %% 7 | # Licensed under the Apache License, Version 2.0 (the "License"); 8 | # you may not use this file except in compliance with the License. 9 | # You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, software 14 | # distributed under the License is distributed on an "AS IS" BASIS, 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | # See the License for the specific language governing permissions and 17 | # limitations under the License. 18 | # #L% 19 | ### 20 | 21 | rpc.client.response-consumer.threads=3 22 | 23 | rpc.server.request-consumer.threads=3 24 | rpc.server.request-consumer.group=ws-proxy-consumer-group 25 | rpc.server.worker.threads=3 26 | 27 | rpc.handler.threads=1 28 | 29 | replication.factor=1 30 | acks=1 31 | enable.auto.commit=true 32 | auto.commit.interval.ms=5000 33 | fetch.max.wait.ms=100 34 | fetch.min.bytes=1 35 | batch.size=16384 36 | max.block.ms=60000 37 | buffer.memory=33554432 38 | retention.ms=120000 39 | linger.ms=0 40 | 41 | zookeeper.sessionTimeout=10000 42 | zookeeper.connectionTimeout=8000 43 | -------------------------------------------------------------------------------- /devicehive-shim-kafka-impl/src/test/java/com/devicehive/shim/kafka/fixture/RequestHandlerWrapper.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.shim.kafka.fixture; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Shim Kafka Implementation 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Request; 24 | import com.devicehive.shim.api.Response; 25 | import com.devicehive.shim.api.server.RequestHandler; 26 | 27 | public class RequestHandlerWrapper implements RequestHandler { 28 | private RequestHandler delegate; 29 | 30 | @Override 31 | public Response handle(Request request) { 32 | if (delegate == null) { 33 | throw new IllegalStateException("Request handler wasn't initialized"); 34 | } 35 | 36 | return delegate.handle(request); 37 | } 38 | 39 | public void setDelegate(RequestHandler delegate) { 40 | this.delegate = delegate; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /devicehive-shim-kafka-impl/src/test/java/com/devicehive/shim/kafka/fixture/TestRequestBody.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.shim.kafka.fixture; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Shim Kafka Implementation 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Action; 24 | import com.devicehive.shim.api.Body; 25 | 26 | public class TestRequestBody extends Body { 27 | 28 | private String body; 29 | 30 | public TestRequestBody() { 31 | super(Action.EMPTY); 32 | } 33 | 34 | public TestRequestBody(String body) { 35 | super(Action.EMPTY); 36 | this.body = body; 37 | } 38 | 39 | public String getBody() { 40 | return body; 41 | } 42 | 43 | public void setBody(String body) { 44 | this.body = body; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /devicehive-shim-kafka-impl/src/test/java/com/devicehive/shim/kafka/fixture/TestResponseBody.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.shim.kafka.fixture; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Shim Kafka Implementation 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | import com.devicehive.shim.api.Action; 24 | import com.devicehive.shim.api.Body; 25 | 26 | public class TestResponseBody extends Body { 27 | 28 | private String responseBody; 29 | 30 | public TestResponseBody(String responseBody) { 31 | super(Action.EMPTY); 32 | this.responseBody = responseBody; 33 | } 34 | 35 | public String getResponseBody() { 36 | return responseBody; 37 | } 38 | 39 | public void setResponseBody(String responseBody) { 40 | this.responseBody = responseBody; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /devicehive-test-utils/missing-license.properties: -------------------------------------------------------------------------------- 1 | # Please fill the missing licenses for dependencies : 2 | 3 | org.apache.zookeeper--zookeeper--3.4.6=Apache 2.0 4 | dom4j--dom4j--1.6.1=BSD style -------------------------------------------------------------------------------- /devicehive-test-utils/src/main/java/com/devicehive/test/dialect/HsqlDialectReplacement.java: -------------------------------------------------------------------------------- 1 | package com.devicehive.test.dialect; 2 | 3 | /* 4 | * #%L 5 | * DeviceHive Java Server Common business logic 6 | * %% 7 | * Copyright (C) 2016 DataArt 8 | * %% 9 | * Licensed under the Apache License, Version 2.0 (the "License"); 10 | * you may not use this file except in compliance with the License. 11 | * You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * #L% 21 | */ 22 | 23 | 24 | import org.hibernate.dialect.HSQLDialect; 25 | 26 | /** 27 | * Fixes errors 28 | * ERROR o.h.tool.hbm2ddl.SchemaExport - HHH000389: 29 | * Unsuccessful: alter table access_key drop constraint FK_g41dixkcu4ku5xqxvr9vujke1 30 | */ 31 | public class HsqlDialectReplacement extends HSQLDialect { 32 | @Override 33 | public String getDropTableString( String tableName ) { 34 | // Append CASCADE to formatted DROP TABLE string 35 | final String superDrop = super.getDropTableString( tableName ); 36 | return superDrop + " cascade"; 37 | } 38 | @Override 39 | public boolean dropConstraints() { 40 | // Do not explicitly drop constraints, use DROP TABLE ... CASCADE 41 | return false; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /dockerfiles/devicehive-auth.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:17.0.2-slim 2 | 3 | MAINTAINER devicehive 4 | 5 | ENV DH_VERSION="4.1.0" 6 | 7 | LABEL org.label-schema.url="https://devicehive.com" \ 8 | org.label-schema.vendor="DeviceHive" \ 9 | org.label-schema.vcs-url="https://github.com/devicehive/devicehive-java-server" \ 10 | org.label-schema.name="devicehive-auth" \ 11 | org.label-schema.version="$DH_VERSION" 12 | 13 | RUN apt-get update \ 14 | && apt-get install -y netcat-openbsd \ 15 | && rm -rf /var/lib/apt/lists/* 16 | 17 | ADD devicehive-auth/target/devicehive-auth-${DH_VERSION}-boot.jar /opt/devicehive/ 18 | #start script 19 | ADD dockerfiles/devicehive-auth/devicehive-start.sh /opt/devicehive/ 20 | 21 | VOLUME ["/var/log/devicehive"] 22 | 23 | WORKDIR /opt/devicehive/ 24 | 25 | ENTRYPOINT ["/bin/sh"] 26 | 27 | CMD ["./devicehive-start.sh"] 28 | 29 | EXPOSE 8090 30 | -------------------------------------------------------------------------------- /dockerfiles/devicehive-backend.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:17.0.2-slim 2 | 3 | MAINTAINER devicehive 4 | 5 | ENV DH_VERSION="4.1.0" 6 | 7 | LABEL org.label-schema.url="https://devicehive.com" \ 8 | org.label-schema.vendor="DeviceHive" \ 9 | org.label-schema.vcs-url="https://github.com/devicehive/devicehive-java-server" \ 10 | org.label-schema.name="devicehive-backend" \ 11 | org.label-schema.version="$DH_VERSION" 12 | 13 | RUN apt-get update \ 14 | && apt-get install -y netcat-openbsd \ 15 | && rm -rf /var/lib/apt/lists/* 16 | 17 | ADD devicehive-backend/target/devicehive-backend-${DH_VERSION}-boot.jar /opt/devicehive/ 18 | #start script 19 | ADD dockerfiles/devicehive-backend/devicehive-start.sh /opt/devicehive/ 20 | 21 | VOLUME ["/var/log/devicehive"] 22 | 23 | WORKDIR /opt/devicehive/ 24 | 25 | ENTRYPOINT ["/bin/sh"] 26 | 27 | CMD ["./devicehive-start.sh"] 28 | -------------------------------------------------------------------------------- /dockerfiles/devicehive-frontend.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:17.0.2-slim 2 | 3 | MAINTAINER devicehive 4 | 5 | ENV DH_VERSION="4.1.0" 6 | 7 | LABEL org.label-schema.url="https://devicehive.com" \ 8 | org.label-schema.vendor="DeviceHive" \ 9 | org.label-schema.vcs-url="https://github.com/devicehive/devicehive-java-server" \ 10 | org.label-schema.name="devicehive-frontend" \ 11 | org.label-schema.version="$DH_VERSION" 12 | 13 | RUN apt-get update \ 14 | && apt-get install -y netcat-openbsd \ 15 | && rm -rf /var/lib/apt/lists/* 16 | 17 | ADD devicehive-frontend/target/devicehive-frontend-${DH_VERSION}-boot.jar /opt/devicehive/ 18 | #start script 19 | ADD dockerfiles/devicehive-frontend/devicehive-start.sh /opt/devicehive/ 20 | 21 | VOLUME ["/var/log/devicehive"] 22 | 23 | WORKDIR /opt/devicehive/ 24 | 25 | ENTRYPOINT ["/bin/sh"] 26 | 27 | CMD ["./devicehive-start.sh"] 28 | 29 | EXPOSE 8080 30 | -------------------------------------------------------------------------------- /dockerfiles/devicehive-kafka.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM docker.io/bitnami/kafka:3.1 2 | 3 | MAINTAINER devicehive 4 | 5 | ENV DH_VERSION="4.1.0" 6 | 7 | LABEL org.label-schema.url="https://devicehive.com" \ 8 | org.label-schema.vendor="DeviceHive" \ 9 | org.label-schema.vcs-url="https://github.com/devicehive/devicehive-ws-proxy" \ 10 | org.label-schema.name="devicehive-kafka" \ 11 | org.label-schema.version="$DH_VERSION" 12 | 13 | ENV KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP=CLIENT:PLAINTEXT,EXTERNAL:PLAINTEXT 14 | ENV KAFKA_CFG_LISTENERS=CLIENT://:9092 15 | ENV KAFKA_CFG_ADVERTISED_LISTENERS=CLIENT://kafka:9092 16 | ENV KAFKA_CFG_INTER_BROKER_LISTENER_NAME=CLIENT 17 | ENV KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181 18 | ENV ALLOW_PLAINTEXT_LISTENER=yes 19 | 20 | USER root 21 | RUN apt update && apt upgrade -y && apt install netcat -y 22 | 23 | EXPOSE 9092 24 | -------------------------------------------------------------------------------- /dockerfiles/devicehive-plugin.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:17.0.2-slim 2 | 3 | MAINTAINER devicehive 4 | 5 | ENV DH_VERSION="4.1.0" 6 | 7 | LABEL org.label-schema.url="https://devicehive.com" \ 8 | org.label-schema.vendor="DeviceHive" \ 9 | org.label-schema.vcs-url="https://github.com/devicehive/devicehive-java-server" \ 10 | org.label-schema.name="devicehive-plugin" \ 11 | org.label-schema.version="$DH_VERSION" 12 | 13 | RUN apt-get update \ 14 | && apt-get install -y netcat-openbsd \ 15 | && rm -rf /var/lib/apt/lists/* 16 | 17 | ADD devicehive-plugin/target/devicehive-plugin-${DH_VERSION}-boot.jar /opt/devicehive/ 18 | #start script 19 | ADD dockerfiles/devicehive-plugin/devicehive-start.sh /opt/devicehive/ 20 | 21 | VOLUME ["/var/log/devicehive"] 22 | 23 | WORKDIR /opt/devicehive/ 24 | 25 | ENTRYPOINT ["/bin/sh"] 26 | 27 | CMD ["./devicehive-start.sh"] 28 | 29 | EXPOSE 8110 30 | --------------------------------------------------------------------------------