Skip to content

Commit 2d021a2

Browse files
authored
Merge pull request #445 from devicehive/development
Development
2 parents 9a1a5ce + 1a1541e commit 2d021a2

File tree

79 files changed

+453
-155
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+453
-155
lines changed

Jenkinsfile

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ node('docker') {
2323
stage('Build and publish Docker images in CI repository') {
2424
echo 'Building images ...'
2525
unstash 'jars'
26-
def auth = docker.build('devicehiveci/devicehive-auth-rdbms:${BRANCH_NAME}', '-f dockerfiles/devicehive-auth-rdbms.Dockerfile .')
27-
def plugin = docker.build('devicehiveci/devicehive-plugin-rdbms:${BRANCH_NAME}', '-f dockerfiles/devicehive-plugin-rdbms.Dockerfile .')
28-
def frontend = docker.build('devicehiveci/devicehive-frontend-rdbms:${BRANCH_NAME}', '-f dockerfiles/devicehive-frontend-rdbms.Dockerfile .')
29-
def backend = docker.build('devicehiveci/devicehive-backend-rdbms:${BRANCH_NAME}', '-f dockerfiles/devicehive-backend-rdbms.Dockerfile .')
26+
def auth = docker.build('devicehiveci/devicehive-auth:${BRANCH_NAME}', '-f dockerfiles/devicehive-auth.Dockerfile .')
27+
def plugin = docker.build('devicehiveci/devicehive-plugin:${BRANCH_NAME}', '-f dockerfiles/devicehive-plugin.Dockerfile .')
28+
def frontend = docker.build('devicehiveci/devicehive-frontend:${BRANCH_NAME}', '-f dockerfiles/devicehive-frontend.Dockerfile .')
29+
def backend = docker.build('devicehiveci/devicehive-backend:${BRANCH_NAME}', '-f dockerfiles/devicehive-backend.Dockerfile .')
3030
def hazelcast = docker.build('devicehiveci/devicehive-hazelcast:${BRANCH_NAME}', '-f dockerfiles/devicehive-hazelcast.Dockerfile .')
3131

3232
echo 'Pushing images to CI repository ...'
@@ -63,9 +63,9 @@ if (publishable_branches.contains(env.BRANCH_NAME)) {
6363
}
6464

6565
echo("Wait for devicehive")
66-
timeout(time:2, unit: 'MINUTES') {
66+
timeout(time:5, unit: 'MINUTES') {
6767
waitUntil{
68-
def fe_status = sh script: 'curl --output /dev/null --silent --head --fail "http://127.0.0.1:8080/api/rest/info"', returnStatus: true
68+
def fe_status = sh script: 'curl --output /dev/null --silent --head --fail "http://127.0.0.1/api/rest/info"', returnStatus: true
6969
return (fe_status == 0)
7070
}
7171
}
@@ -84,11 +84,11 @@ if (publishable_branches.contains(env.BRANCH_NAME)) {
8484
sh '''
8585
cp config.json config.json.orig
8686
cat config.json.orig | \\
87-
jq ".server.wsUrl = \\"ws://127.0.0.1:8080/api/websocket\\"" | \\
87+
jq ".server.wsUrl = \\"ws://127.0.0.1/api/websocket\\"" | \\
8888
jq ".server.ip = \\"127.0.0.1\\"" | \\
89-
jq ".server.port = \\"8080\\"" | \\
90-
jq ".server.restUrl = \\"http://127.0.0.1:8080/api/rest\\"" | \\
91-
jq ".server.authRestUrl = \\"http://127.0.0.1:8090/api/rest\\"" > config.json
89+
jq ".server.port = \\"80\\"" | \\
90+
jq ".server.restUrl = \\"http://127.0.0.1/api/rest\\"" | \\
91+
jq ".server.authRestUrl = \\"http://127.0.0.1/auth/rest\\"" > config.json
9292
'''
9393

9494
timeout(time:10, unit: 'MINUTES') {
@@ -117,17 +117,17 @@ if (publishable_branches.contains(env.BRANCH_NAME)) {
117117

118118
docker.withRegistry('https://registry.hub.docker.com', 'devicehiveci_dockerhub'){
119119
sh """
120-
docker tag devicehiveci/devicehive-auth-rdbms:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-auth-rdbms:${IMAGE_TAG}
121-
docker tag devicehiveci/devicehive-frontend-rdbms:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-frontend-rdbms:${IMAGE_TAG}
122-
docker tag devicehiveci/devicehive-backend-rdbms:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-backend-rdbms:${IMAGE_TAG}
120+
docker tag devicehiveci/devicehive-auth:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-auth:${IMAGE_TAG}
121+
docker tag devicehiveci/devicehive-frontend:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-frontend:${IMAGE_TAG}
122+
docker tag devicehiveci/devicehive-backend:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-backend:${IMAGE_TAG}
123123
docker tag devicehiveci/devicehive-hazelcast:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-hazelcast:${IMAGE_TAG}
124-
docker tag devicehiveci/devicehive-plugin-rdbms:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-plugin-rdbms:${IMAGE_TAG}
124+
docker tag devicehiveci/devicehive-plugin:${BRANCH_NAME} registry.hub.docker.com/devicehive/devicehive-plugin:${IMAGE_TAG}
125125
126-
docker push registry.hub.docker.com/devicehive/devicehive-auth-rdbms:${IMAGE_TAG}
127-
docker push registry.hub.docker.com/devicehive/devicehive-frontend-rdbms:${IMAGE_TAG}
128-
docker push registry.hub.docker.com/devicehive/devicehive-backend-rdbms:${IMAGE_TAG}
126+
docker push registry.hub.docker.com/devicehive/devicehive-auth:${IMAGE_TAG}
127+
docker push registry.hub.docker.com/devicehive/devicehive-frontend:${IMAGE_TAG}
128+
docker push registry.hub.docker.com/devicehive/devicehive-backend:${IMAGE_TAG}
129129
docker push registry.hub.docker.com/devicehive/devicehive-hazelcast:${IMAGE_TAG}
130-
docker push registry.hub.docker.com/devicehive/devicehive-plugin-rdbms:${IMAGE_TAG}
130+
docker push registry.hub.docker.com/devicehive/devicehive-plugin:${IMAGE_TAG}
131131
"""
132132
}
133133
}

devicehive-auth/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>devicehive-server</artifactId>
77
<groupId>com.devicehive</groupId>
8-
<version>3.4.1</version>
8+
<version>3.4.2</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111
<packaging>jar</packaging>

devicehive-auth/src/main/java/com/devicehive/resource/AuthApiInfoResource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public interface AuthApiInfoResource {
4747
response = ApiInfoVO.class),
4848
})
4949
Response getApiInfo(@Context UriInfo uriInfo,
50-
@HeaderParam("X-DH-wss-enabled")
51-
@DefaultValue("false")
52-
Boolean wssEnabled);
50+
@HeaderParam("X-Forwarded-Proto")
51+
@DefaultValue("http")
52+
String protocol);
5353

5454
}

devicehive-auth/src/main/java/com/devicehive/resource/impl/AuthApiInfoResourceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public AuthApiInfoResourceImpl(BaseApiInfoResource baseApiInfoResource) {
4040
}
4141

4242
@Override
43-
public Response getApiInfo(UriInfo uriInfo, Boolean wssEnabled) {
44-
return baseApiInfoResource.getApiInfo(uriInfo, wssEnabled);
43+
public Response getApiInfo(UriInfo uriInfo, String protocol) {
44+
return baseApiInfoResource.getApiInfo(uriInfo, protocol);
4545
}
4646
}

devicehive-auth/src/main/java/com/devicehive/resource/impl/JwtTokenResourceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ private Response getRefreshResponse(JwtUserPayload payload) {
172172

173173
JwtTokenVO responseTokenVO = new JwtTokenVO();
174174
responseTokenVO.setAccessToken(tokenService.generateJwtAccessToken(payload, false));
175+
userService.refreshUserLoginData(user);
175176
logger.debug("JwtToken: access token successfully generated with refresh token");
176177
return ResponseFactory.response(CREATED, responseTokenVO, JsonPolicyDef.Policy.JWT_ACCESS_TOKEN_SUBMITTED);
177178
}

devicehive-backend/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>devicehive-server</artifactId>
77
<groupId>com.devicehive</groupId>
8-
<version>3.4.1</version>
8+
<version>3.4.2</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

@@ -72,7 +72,7 @@
7272
<profile>
7373
<id>proxy-ws-kafka</id>
7474
<activation>
75-
<activeByDefault>true</activeByDefault>
75+
<activeByDefault>false</activeByDefault>
7676
</activation>
7777
<dependencies>
7878
<dependency>

devicehive-backend/src/main/java/com/devicehive/application/RequestHandlersMapper.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
* #L%
2121
*/
2222

23+
import com.devicehive.api.HandlersMapper;
2324
import com.devicehive.messages.handler.DeviceCreateHandler;
25+
import com.devicehive.messages.handler.DeviceDeleteHandler;
2426
import com.devicehive.messages.handler.PluginSubscribeRequestHandler;
2527
import com.devicehive.messages.handler.PluginUnsubscribeRequestHandler;
2628
import com.devicehive.messages.handler.command.CommandGetSubscriptionRequestHandler;
@@ -46,11 +48,10 @@
4648
import org.springframework.stereotype.Component;
4749

4850
import javax.annotation.PostConstruct;
49-
import java.util.HashMap;
5051
import java.util.Map;
5152

5253
@Component
53-
public class RequestHandlersMapper {
54+
public class RequestHandlersMapper implements HandlersMapper {
5455

5556
private final NotificationSearchHandler notificationSearchHandler;
5657
private final NotificationInsertHandler notificationInsertHandler;
@@ -69,6 +70,7 @@ public class RequestHandlersMapper {
6970
private final ListDeviceHandler listDeviceHandler;
7071
private final ListSubscribeHandler listSubscribeHandler;
7172
private final DeviceCreateHandler deviceCreateHandler;
73+
private final DeviceDeleteHandler deviceDeleteHandler;
7274
private final PluginSubscribeRequestHandler pluginSubscribeRequestHandler;
7375
private final PluginUnsubscribeRequestHandler pluginUnsubscribeRequestHandler;
7476

@@ -90,6 +92,7 @@ public RequestHandlersMapper(CommandUpdateHandler commandUpdateHandler,
9092
ListNetworkHandler listNetworkHandler,
9193
ListSubscribeHandler listSubscribeHandler,
9294
DeviceCreateHandler deviceCreateHandler,
95+
DeviceDeleteHandler deviceDeleteHandler,
9396
CommandSubscribeRequestHandler commandSubscribeRequestHandler,
9497
CommandUnsubscribeRequestHandler commandUnsubscribeRequestHandler,
9598
CommandUpdateSubscribeRequestHandler commandUpdateSubscribeRequestHandler,
@@ -109,11 +112,13 @@ public RequestHandlersMapper(CommandUpdateHandler commandUpdateHandler,
109112
this.listNetworkHandler = listNetworkHandler;
110113
this.listSubscribeHandler = listSubscribeHandler;
111114
this.deviceCreateHandler = deviceCreateHandler;
115+
this.deviceDeleteHandler = deviceDeleteHandler;
112116
this.commandSubscribeRequestHandler = commandSubscribeRequestHandler;
113117
this.commandUnsubscribeRequestHandler = commandUnsubscribeRequestHandler;
114118
this.commandUpdateSubscribeRequestHandler = commandUpdateSubscribeRequestHandler;
115119
this.pluginSubscribeRequestHandler = pluginSubscribeRequestHandler;
116120
this.pluginUnsubscribeRequestHandler = pluginUnsubscribeRequestHandler;
121+
117122
}
118123

119124
@PostConstruct
@@ -138,9 +143,11 @@ public void init() {
138143
.put(Action.LIST_DEVICE_REQUEST, listDeviceHandler)
139144
.put(Action.LIST_SUBSCRIBE_REQUEST, listSubscribeHandler)
140145
.put(Action.DEVICE_CREATE_REQUEST, deviceCreateHandler)
146+
.put(Action.DEVICE_DELETE_REQUEST, deviceDeleteHandler)
141147
.build();
142148
}
143149

150+
@Override
144151
public Map<Action, RequestHandler> requestHandlerMap() {
145152
return requestHandlerMap;
146153
}

devicehive-backend/src/main/java/com/devicehive/eventbus/EventBus.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
import com.devicehive.model.eventbus.events.Event;
2626
import com.devicehive.shim.api.Response;
2727
import com.devicehive.shim.api.server.MessageDispatcher;
28-
import org.springframework.beans.factory.annotation.Autowired;
29-
import org.springframework.stereotype.Component;
3028

3129
import java.util.Collection;
3230

@@ -85,4 +83,8 @@ public void publish(Event event) {
8583
dispatcher.send(subscriber.getReplyTo(), response);
8684
});
8785
}
86+
87+
public void unsubscribeDevice(String deviceId) {
88+
registry.unregisterDevice(deviceId);
89+
}
8890
}

devicehive-backend/src/main/java/com/devicehive/eventbus/FilterRegistry.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,18 @@ public Set<Pair<Long, Filter>> getSubscriptions(Long networkId) {
7575
});
7676
return subs;
7777
}
78+
79+
public void unregisterDevice(String deviceId) {
80+
filterSubscriptionsMap.keySet().stream()
81+
.filter(key ->
82+
key.getDeviceIds().contains(deviceId))
83+
.forEach(key -> {
84+
Collection<Long> subscriptionsIds = filterSubscriptionsMap.get(key);
85+
subscriptionsIds.forEach(this::unregister);
86+
key.deleteDeviceId(deviceId);
87+
if (!(key.getDeviceIds().isEmpty() && key.getNetworkIds().isEmpty())) {
88+
subscriptionsIds.forEach(id -> register(key, id));
89+
}
90+
});
91+
}
7892
}

devicehive-backend/src/main/java/com/devicehive/eventbus/SubscriberRegistry.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,13 @@ Collection<Subscription> getSubscriptions(@NotNull Subscriber subscriber) {
131131
Collection<Subscription> getAllSubscriptions() {
132132
return subscriptions.keySet();
133133
}
134+
135+
synchronized void unregisterDevice(String deviceId) {
136+
subscriptions.keySet().stream()
137+
.filter(key -> key.getEntityId().equals(deviceId))
138+
.forEach(this::unregister);
139+
subscriberSubscriptions.values().stream()
140+
.filter(value -> value.getEntityId().equals(deviceId))
141+
.forEach(this::unregister);
142+
}
134143
}

0 commit comments

Comments
 (0)