|
|
|
@ -111,6 +111,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|
|
|
|
|
|
|
|
|
public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss";
|
|
|
|
|
private static final Log log = LogFactory.getLog(DeviceManagementServiceImpl.class);
|
|
|
|
|
private String message;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Validate group Id and group Id greater than 0 and exist.
|
|
|
|
@ -139,6 +140,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveResponseTimeToSpreadsheet(long startTime, long endTime, long responseTime, String message) throws IOException, GeneralSecurityException {
|
|
|
|
|
this.message = message;
|
|
|
|
|
// Load credentials from JSON file
|
|
|
|
|
GoogleCredential credential = GoogleCredential.fromStream(new FileInputStream("/home/entgra/MyProject/device-mgt-core/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/resources/apicall-382608-48aa6a62800d.json"))
|
|
|
|
|
.createScoped(Collections.singleton(SheetsScopes.SPREADSHEETS));
|
|
|
|
@ -509,18 +511,19 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|
|
|
|
Device persistedDevice = deviceManagementProviderService.getDevice(new DeviceIdentifier
|
|
|
|
|
(deviceId, deviceType), true);
|
|
|
|
|
persistedDevice.setName(device.getName());
|
|
|
|
|
System.out.println("This is rename device");
|
|
|
|
|
System.out.println("This is renamed device");
|
|
|
|
|
boolean responseOfmodifyEnrollment = deviceManagementProviderService.modifyEnrollment(persistedDevice);
|
|
|
|
|
boolean responseOfDeviceNameChanged = deviceManagementProviderService.sendDeviceNameChangedNotification(
|
|
|
|
|
persistedDevice);
|
|
|
|
|
boolean response = responseOfmodifyEnrollment && responseOfDeviceNameChanged;
|
|
|
|
|
System.out.println("Rename Device " + message);
|
|
|
|
|
|
|
|
|
|
// End measuring API call response time
|
|
|
|
|
long endTime = System.currentTimeMillis();
|
|
|
|
|
long responseTime = endTime - startTime;
|
|
|
|
|
|
|
|
|
|
// Save the response time, start time, and end time to Google Spreadsheet
|
|
|
|
|
saveResponseTimeToSpreadsheet(startTime, endTime, responseTime, "Rename Device");
|
|
|
|
|
saveResponseTimeToSpreadsheet(startTime, endTime, responseTime, message);
|
|
|
|
|
|
|
|
|
|
return Response.status(Response.Status.CREATED).entity(response).build();
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|