Skip to content

Commit 0bb2abe

Browse files
Release 1.0.32
1 parent 9b21127 commit 0bb2abe

File tree

10 files changed

+361
-130
lines changed

10 files changed

+361
-130
lines changed

LICENSE.md

Lines changed: 40 additions & 35 deletions
Large diffs are not rendered by default.

manifest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
applications:
33
- name: {your-name}-kit-service
44
buildpack: java_buildpack
5-
path: target/kit-service-1.0.26.jar
5+
path: target/kit-service-1.0.32.jar
66
memory: 512M
77
timeout : 180
88
services:

manifest.yml.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
applications:
33
- name: {your-name}-kit-service
44
buildpack: java_buildpack
5-
path: target/kit-service-1.0.26.jar
5+
path: target/kit-service-1.0.32.jar
66
memory: 512M
77
timeout : 180
88
services:

pom.xml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.ge.predix.solsvc</groupId>
77
<artifactId>kit-service</artifactId>
8-
<version>1.0.26</version>
8+
<version>1.0.32</version>
99

1010
<parent>
1111
<groupId>org.springframework.boot</groupId>
@@ -15,8 +15,10 @@
1515
</parent>
1616

1717
<properties>
18-
<fdh-asset-handler.version>2.0.35</fdh-asset-handler.version>
19-
<timeseries-bootstrap.version>2.1.34</timeseries-bootstrap.version>
18+
19+
<asset-bootstrap-client.version>2.0.54</asset-bootstrap-client.version>
20+
<fdh-asset-handler.version>2.0.64</fdh-asset-handler.version>
21+
<timeseries-bootstrap.version>2.1.67</timeseries-bootstrap.version>
2022
<uaa-lib.version>3.2.2</uaa-lib.version>
2123

2224
<jetty.version>8.1.7.v20120910</jetty.version>
@@ -106,6 +108,12 @@
106108
<artifactId>timeseries-bootstrap</artifactId>
107109
<version>${timeseries-bootstrap.version}</version>
108110
</dependency>
111+
112+
<dependency>
113+
<groupId>com.ge.predix.solsvc</groupId>
114+
<artifactId>asset-bootstrap-client</artifactId>
115+
<version>${asset-bootstrap-client.version}</version>
116+
</dependency>
109117

110118
<dependency>
111119
<groupId>org.freemarker</groupId>
@@ -305,6 +313,18 @@
305313
<groupId>org.apache.maven.plugins</groupId>
306314
<artifactId>maven-javadoc-plugin</artifactId>
307315
<version>${maven-javadoc-plugin.version}</version>
316+
<executions>
317+
<execution>
318+
<id>attach-javadocs</id>
319+
<goals>
320+
<goal>jar</goal>
321+
</goals>
322+
<configuration> <!-- add this to disable checking -->
323+
<additionalparam>-Xdoclint:none</additionalparam>
324+
</configuration>
325+
</execution>
326+
</executions>
327+
308328
</plugin>
309329
<plugin>
310330
<groupId>org.apache.maven.plugins</groupId>

src/main/java/com/ge/predix/solsvc/kitservice/boot/utils/CSVWriter.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ public void activate() {
8282
}
8383

8484
/**
85-
* @param device
86-
* -
85+
* gets the asset file name
86+
* @param device : is a registered Device
87+
*
8788
* @return -
88-
* @throws IOException
89-
* -
89+
*
9090
*/
9191
public String getAssetCSV(RegisterDevice device) {
9292
Map<String, Object> root = new HashMap<>();
@@ -142,11 +142,10 @@ public String getAssetCSV(RegisterDevice device) {
142142
}
143143

144144
/**
145-
* @param devices
146-
* -
145+
* @param devices : list of registered devices
146+
*
147147
* @return -
148-
* @throws IOException
149-
* -
148+
*
150149
*/
151150
public String getAssetCSV(List<RegisterDevice> devices) {
152151
Map<String, Object> root = new HashMap<>();

src/main/java/com/ge/predix/solsvc/kitservice/boot/utils/FdhUtils.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,7 @@ private static PutFieldDataCriteria getFieldCriteria(String dataString) {
8585
* -
8686
* @param expectedDataType
8787
* -
88-
* @param deviceIdentifier
89-
* -
90-
* @param string
91-
* -
88+
*
9289
* @param userId
9390
* -
9491
* @param deviceAddress
@@ -136,13 +133,13 @@ public static GetFieldDataRequest createGetUserDeviceRequest(String filterFieldV
136133
}
137134

138135
/**
136+
* Method that creates a get request for getting device groups of a device
139137
*
140138
* @param groupRef
141139
* -
142140
* @param expectedDataType
143141
* -
144-
* @param userId
145-
* -
142+
*
146143
* @return -
147144
*/
148145
public static GetFieldDataRequest createGetGroupRequest(String groupRef, String expectedDataType) {
@@ -172,10 +169,10 @@ public static GetFieldDataRequest createGetGroupRequest(String groupRef, String
172169
}
173170

174171
/**
172+
* Method that creates a get request for getting userGroups
173+
*
175174
* @param userGroupRef
176175
* -
177-
* @param deviceGroupRef
178-
* -
179176
* @param expectedDataType
180177
* -
181178
* @param userId

src/main/java/com/ge/predix/solsvc/kitservice/controller/KitController.java

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import java.io.File;
44
import java.io.FileInputStream;
55
import java.io.FileNotFoundException;
6+
import java.io.IOException;
7+
import java.time.Instant;
68
import java.util.ArrayList;
79
import java.util.HashMap;
810
import java.util.List;
@@ -12,6 +14,8 @@
1214
import javax.servlet.http.HttpServletRequest;
1315

1416
import org.apache.commons.collections.CollectionUtils;
17+
import org.apache.commons.lang3.StringUtils;
18+
import org.apache.http.Header;
1519
import org.slf4j.Logger;
1620
import org.slf4j.LoggerFactory;
1721
import org.springframework.beans.factory.annotation.Autowired;
@@ -28,6 +32,7 @@
2832
import org.springframework.web.bind.annotation.RequestHeader;
2933
import org.springframework.web.bind.annotation.RequestMapping;
3034
import org.springframework.web.bind.annotation.RequestMethod;
35+
import org.springframework.web.bind.annotation.RequestParam;
3136
import org.springframework.web.bind.annotation.RestController;
3237

3338
import com.fasterxml.jackson.core.type.TypeReference;
@@ -67,31 +72,30 @@ public KitController() {
6772
}
6873

6974
/**
70-
* Sample End point which returns a Welcome Message
75+
* Method that returns the devices for an admin or for a user if userId is
76+
* passed
7177
*
7278
* @param request
7379
* -
7480
* @param authorization
7581
* -
76-
*
77-
* @param echo
78-
* - the string to echo back
7982
* @return -
8083
*/
8184
@SuppressWarnings({ "resource" })
8285
@RequestMapping(value = "/device", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE,
8386
MediaType.APPLICATION_XHTML_XML_VALUE })
8487
public ResponseEntity<?> getDevices(HttpServletRequest request,
8588
@RequestHeader("Authorization") String authorization) {
89+
// log.info("calling /device method API call");
8690
List<RegisterDevice> devices = null;
8791
String userId = getUserId(request);
8892
Boolean isAdmin = (Boolean) request.getAttribute("isAdmin"); //$NON-NLS-1$
8993

9094
if (isAdmin) {
9195
devices = this.deviceManager.getAllAdminDevices();
92-
} else {
96+
} else
9397
devices = this.deviceManager.getDevices(userId);
94-
}
98+
9599
String contentType = request.getHeader("Content-Type"); //$NON-NLS-1$
96100

97101
if (contentType != null && MediaType.APPLICATION_OCTET_STREAM_VALUE.equals(contentType)) {
@@ -137,13 +141,15 @@ public ResponseEntity<?> registerDevice(@RequestBody RegisterDevice device, Http
137141
return new ResponseEntity<>(errors, HttpStatus.BAD_REQUEST);
138142
}
139143
// continue to register device
140-
// RegisterDevice originalDevice = this.deviceManager.getDevice("device", userId, device.getDeviceAddress());//$NON-NLS-1$
144+
// RegisterDevice originalDevice =
145+
// this.deviceManager.getDevice("device",
146+
// userId, device.getDeviceAddress());//$NON-NLS-1$
141147
// removing the user check adding check per deviceIdentifer
142148
RegisterDevice originalDevice = this.deviceManager.getDevice("device", null, device.getDeviceAddress());//$NON-NLS-1$
143149
try {
144150
if (originalDevice == null) {
145151
// device not found. register it.
146-
log.info("Registrating device with address " + device.getDeviceAddress()); //$NON-NLS-1$
152+
log.info("Registering device with address " + device.getDeviceAddress()); //$NON-NLS-1$
147153
this.deviceManager.registerDevice(device, userId);
148154
} else {
149155
log.info("This is a registered device with address " + device.getDeviceAddress()); //$NON-NLS-1$
@@ -308,23 +314,15 @@ private String getUserId(HttpServletRequest request) {
308314
return this.deviceManager.getUserId(accessToken);
309315
}
310316

311-
312-
313317
/**
314318
* Details about each Device
315319
*
316320
* @param deviceId
317321
* -
318-
* @param model
319-
* -
320322
* @param request
321323
* -
322324
* @param authorization
323325
* -
324-
* @param result
325-
* -
326-
* @param echo
327-
* -
328326
* @return -
329327
*/
330328
@RequestMapping(value = "/device/{deviceId}", method = RequestMethod.GET)
@@ -383,24 +381,20 @@ public ResponseEntity<?> getDevice(@PathVariable String deviceId, HttpServletReq
383381
file.delete();
384382
}
385383
}
386-
return new ResponseEntity<RegisterDevice>(device, HttpStatus.OK); }
387-
388-
384+
return new ResponseEntity<RegisterDevice>(device, HttpStatus.OK);
385+
}
389386

390387
/**
391388
* This method resets the Device settings.
392389
*
393390
* @param deviceId
394391
* -
395-
* @param device
396-
* -
397392
* @param request
398393
* -
399-
* @param result
400-
* -
401394
* @param authorization
402395
* -
403396
* @return -
397+
*
404398
*/
405399
@RequestMapping(value = "/device/reset/{deviceId}", method = RequestMethod.PUT)
406400
public ResponseEntity<?> resetRegisterDevice(@PathVariable String deviceId, HttpServletRequest request,
@@ -428,8 +422,17 @@ public ResponseEntity<?> resetRegisterDevice(@PathVariable String deviceId, Http
428422
// continue with get device without user
429423
RegisterDevice device = this.deviceManager.getDevice(deviceId, null);
430424
if (device != null) {
425+
431426
Boolean isAdmin = (Boolean) request.getAttribute("isAdmin"); //$NON-NLS-1$
432-
this.deviceManager.resetDeviceActivation(device, isAdmin, userId);
427+
428+
try {
429+
this.deviceManager.resetDeviceActivation(device, isAdmin, userId);
430+
} catch (IOException e) {
431+
log.error("KitController: Asset model could not be reset. ", e);
432+
throw new RuntimeException("KitController: Exception when resetting the device", e);
433+
// return new ResponseEntity<>(eventErrors, HttpStatus.);
434+
}
435+
433436
}
434437

435438
} catch (DeviceRegistrationError e) {

0 commit comments

Comments
 (0)