-
Notifications
You must be signed in to change notification settings - Fork 477
/
EndpointService.java
295 lines (260 loc) · 8.59 KB
/
EndpointService.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
/*
* Copyright 2014-2016 CyberVision, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kaaproject.kaa.server.common.dao;
import org.kaaproject.kaa.common.dto.ChangeNotificationDto;
import org.kaaproject.kaa.common.dto.EndpointConfigurationDto;
import org.kaaproject.kaa.common.dto.EndpointGroupDto;
import org.kaaproject.kaa.common.dto.EndpointProfileBodyDto;
import org.kaaproject.kaa.common.dto.EndpointProfileDto;
import org.kaaproject.kaa.common.dto.EndpointProfilesBodyDto;
import org.kaaproject.kaa.common.dto.EndpointProfilesPageDto;
import org.kaaproject.kaa.common.dto.EndpointUserDto;
import org.kaaproject.kaa.common.dto.PageLinkDto;
import org.kaaproject.kaa.common.dto.TopicListEntryDto;
import org.kaaproject.kaa.common.dto.UpdateNotificationDto;
import org.kaaproject.kaa.server.common.dao.exception.KaaOptimisticLockingFailureException;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
import java.util.List;
/**
* The interface Endpoint service.
*/
public interface EndpointService {
/**
* Find endpoint profile by endpoint group id.
*
* @param pageLink the page link dto
* @return the endpoint profiles page dto
*/
EndpointProfilesPageDto findEndpointProfileByEndpointGroupId(PageLinkDto pageLink);
/**
* Find endpoint profile body by endpoint group id.
*
* @param pageLink the page link dto
* @return the endpoint profiles page dto
*/
EndpointProfilesBodyDto findEndpointProfileBodyByEndpointGroupId(PageLinkDto pageLink);
/**
* Find endpoint groups by application id.
*
* @param applicationId the application id
* @return the list
*/
List<EndpointGroupDto> findEndpointGroupsByAppId(String applicationId);
/**
* Find endpoint group by id.
*
* @param id the id
* @return the endpoint group dto
*/
EndpointGroupDto findEndpointGroupById(String id);
/**
* Remove endpoint group by application id.
*
* @param applicationId the application id
*/
void removeEndpointGroupByAppId(String applicationId);
/**
* Remove endpoint group by id.
*
* @param applicationId the application id
* @return the change notification dto
*/
ChangeNotificationDto removeEndpointGroupById(String applicationId);
/**
* Save endpoint group. Can't save endpoint group with same weight or update
* weight for default group. Application id and group weight is unique
*
* @param endpointGroupDto the endpoint group dto
* @return the endpoint group dto
*/
EndpointGroupDto saveEndpointGroup(EndpointGroupDto endpointGroupDto);
/**
* Removes the topic id from endpoint group.
*
* @param id the id
* @param topicId the topic id
* @return the update notification dto
*/
UpdateNotificationDto<EndpointGroupDto> removeTopicFromEndpointGroup(String id, String topicId);
/**
* Subscribe existing topic to existing group.
*
* @param id the endpoint group id
* @param topicId the topic id
* @return the update notification dto
*/
UpdateNotificationDto<EndpointGroupDto> addTopicToEndpointGroup(String id, String topicId);
/**
* Find endpoint configuration by hash.
*
* @param hash the hash
* @return the endpoint configuration dto
*/
EndpointConfigurationDto findEndpointConfigurationByHash(byte[] hash);
/**
* Save endpoint configuration.
*
* @param endpointConfigurationDto the endpoint configuration dto
* @return the endpoint configuration dto
*/
EndpointConfigurationDto saveEndpointConfiguration(
EndpointConfigurationDto endpointConfigurationDto);
/**
* Find endpoint profile by key hash.
*
* @param endpointProfileKeyHash the endpoint profile key hash
* @return the endpoint profile dto
*/
EndpointProfileDto findEndpointProfileByKeyHash(byte[] endpointProfileKeyHash);
/**
* Find endpoint profile by key hash.
*
* @param endpointProfileKeyHash the endpoint profile key hash
* @return the endpoint profile body dto
*/
EndpointProfileBodyDto findEndpointProfileBodyByKeyHash(byte[] endpointProfileKeyHash);
/**
* Find topic list entry by key hash.
*
* @param hash the hash
* @return the topic list entry dto
*/
TopicListEntryDto findTopicListEntryByHash(byte[] hash);
/**
* Save topic list entry.
*
* @param topicListEntryDto the endpoint list entry dto
* @return the topic list entry dto
*/
TopicListEntryDto saveTopicListEntry(TopicListEntryDto topicListEntryDto);
/**
* Remove endpoint profile by key hash.
*
* @param endpointProfileKeyHash the endpoint profile key hash
*/
void removeEndpointProfileByKeyHash(byte[] endpointProfileKeyHash);
/**
* Remove endpoint profile by application id.
*
* @param appId application id
*/
void removeEndpointProfileByAppId(String appId);
/**
* Save endpoint profile.
*
* @param endpointProfileDto the endpoint profile dto
* @return the endpoint profile dto
*/
EndpointProfileDto saveEndpointProfile(EndpointProfileDto endpointProfileDto);
/**
* Attach endpoint profile to user.
*
* @param userExternalId the user external id
* @param tenantId the tenant id
* @param profile the profile
* @return the endpoint profile dto
*/
EndpointProfileDto attachEndpointToUser(String userExternalId, String tenantId,
EndpointProfileDto profile);
/**
* Attach endpoint profile to user.
*
* @param endpointUserId the endpoint user id
* @param endpointAccessToken the endpoint access token
* @return the endpoint profile dto
*/
@Retryable(maxAttempts = 10,
backoff = @Backoff(delay = 100),
value = {KaaOptimisticLockingFailureException.class}
)
EndpointProfileDto attachEndpointToUser(String endpointUserId, String endpointAccessToken)
throws KaaOptimisticLockingFailureException;
/**
* Detach endpoint profile from user.
*
* @param detachEndpoint the detach endpoint
*/
@Retryable(maxAttempts = 10,
backoff = @Backoff(delay = 100),
value = {KaaOptimisticLockingFailureException.class})
void detachEndpointFromUser(EndpointProfileDto detachEndpoint);
/**
* Find all endpoint users.
*
* @return the list of endpoint user dto's.
*/
List<EndpointUserDto> findAllEndpointUsers();
/**
* Find endpoint user by id.
*
* @param id the id
* @return the endpoint user dto
*/
EndpointUserDto findEndpointUserById(String id);
/**
* Find endpoint user by id.
*
* @param externalId the external id
* @param tenantId the tenant id
* @return the endpoint user dto
*/
EndpointUserDto findEndpointUserByExternalIdAndTenantId(String externalId, String tenantId);
/**
* Generate endpoint user access token from external user id.
*
* @param externalUid the external user id
* @param tenantId the tenant id
* @return generated access token
*/
String generateEndpointUserAccessToken(String externalUid, String tenantId);
/**
* Find endpoint profiles by user id.
*
* @param endpointUserId the endpoint user id
* @return the list
*/
List<EndpointProfileDto> findEndpointProfilesByUserId(String endpointUserId);
/**
* Find endpoint profiles by user external id and tenant id.
*
* @param externalId the endpoint user external id
* @param tenantId the tenant id
* @return the list of endpoint profiles
*/
List<EndpointProfileDto> findEndpointProfilesByExternalIdAndTenantId(String externalId,
String tenantId);
/**
* Returns the default group for the given application.
*
* @param applicationId The application ID
* @return The default group for the given application.
*/
EndpointGroupDto findDefaultGroup(String applicationId);
/**
* Save endpoint user.
*
* @param endpointUserDto the endpoint user dto
* @return the endpoint user dto
*/
EndpointUserDto saveEndpointUser(EndpointUserDto endpointUserDto);
/**
* Remove endpoint user by id.
*
* @param id the endpoint user id
*/
void removeEndpointUserById(String id);
}