|
|
|
@ -37,13 +37,32 @@ import io.entgra.device.mgt.core.application.mgt.common.exception.SubscriptionMa
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager;
|
|
|
|
|
import io.entgra.device.mgt.core.application.mgt.core.util.HelperUtil;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.*;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ApplicationList;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ApplicationUninstallation;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ComplianceDeviceList;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceCompliance;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceConfig;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.DeviceList;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.OperationList;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.OperationRequest;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.OperationStatusBean;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.DeviceManagementService;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.InputValidationException;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.*;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.Device;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.DeviceFilters;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.DeviceIdentifier;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.DeviceManagementConstants;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.EnrolmentInfo;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.Feature;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.FeatureManager;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.MDMAppConstants;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.OperationLogFilters;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.PaginationRequest;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.PaginationResult;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.app.mgt.Application;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.app.mgt.ApplicationManagementException;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.authorization.DeviceAccessAuthorizationException;
|
|
|
|
@ -53,7 +72,11 @@ import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceInfo;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceLocation;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.device.details.DeviceLocationHistorySnapshotWrapper;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.exceptions.BadRequestException;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.exceptions.*;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceManagementException;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.exceptions.DeviceTypeNotFoundException;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidConfigurationException;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.exceptions.InvalidDeviceException;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.exceptions.UnAuthorizedException;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.group.mgt.GroupManagementException;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Activity;
|
|
|
|
|
import io.entgra.device.mgt.core.device.mgt.common.operation.mgt.Operation;
|
|
|
|
@ -104,7 +127,6 @@ import java.io.IOException;
|
|
|
|
|
import java.security.GeneralSecurityException;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
@Path("/devices")
|
|
|
|
@ -140,7 +162,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void saveResponseTimeToSpreadsheet(LocalDateTime date, long startTime, long endTime, long responseTime, String message) throws IOException, GeneralSecurityException {
|
|
|
|
|
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"))
|
|
|
|
@ -154,10 +176,10 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|
|
|
|
|
|
|
|
|
// Define the spreadsheet ID and range
|
|
|
|
|
String spreadsheetId = "1OZCS5NRwwSum9ai3ra4lABtU0UGW-9yLYgZk-aQfxpw";
|
|
|
|
|
String range = "Sheet1!A:E";
|
|
|
|
|
String range = "Sheet1!A:D";
|
|
|
|
|
|
|
|
|
|
// Prepare the values to be written
|
|
|
|
|
List<Object> rowValues = Arrays.asList(date, startTime, endTime, responseTime, message);
|
|
|
|
|
List<Object> rowValues = Arrays.asList(startTime, endTime, responseTime, message);
|
|
|
|
|
List<List<Object>> values = Collections.singletonList(rowValues);
|
|
|
|
|
|
|
|
|
|
// Build the value range object
|
|
|
|
@ -483,13 +505,12 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|
|
|
|
return Response.status(Response.Status.NOT_FOUND).build();
|
|
|
|
|
}
|
|
|
|
|
boolean response = deviceManagementProviderService.disenrollDevice(deviceIdentifier);
|
|
|
|
|
LocalDateTime date = LocalDateTime.now();
|
|
|
|
|
String message = "Delete Device";
|
|
|
|
|
long endTime = System.currentTimeMillis(); //end measuring API call response time
|
|
|
|
|
long responseTime = endTime - startTime;
|
|
|
|
|
|
|
|
|
|
// save the start time, end time and response time to google sheet
|
|
|
|
|
saveResponseTimeToSpreadsheet(date, startTime, endTime, responseTime, message);
|
|
|
|
|
saveResponseTimeToSpreadsheet(startTime, endTime, responseTime, message);
|
|
|
|
|
return Response.status(Response.Status.OK).entity(response).build();
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|
String msg = "Error encountered while deleting requested device of type : " + deviceType;
|
|
|
|
@ -519,7 +540,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|
|
|
|
boolean responseOfDeviceNameChanged = deviceManagementProviderService.sendDeviceNameChangedNotification(
|
|
|
|
|
persistedDevice);
|
|
|
|
|
boolean response = responseOfmodifyEnrollment && responseOfDeviceNameChanged;
|
|
|
|
|
LocalDateTime date = LocalDateTime.now();
|
|
|
|
|
|
|
|
|
|
String message = "Rename Device";
|
|
|
|
|
|
|
|
|
|
// End measuring API call response time
|
|
|
|
@ -527,7 +548,7 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
|
|
|
|
|
long responseTime = endTime - startTime;
|
|
|
|
|
|
|
|
|
|
// Save the response time, start time, and end time to Google Spreadsheet
|
|
|
|
|
saveResponseTimeToSpreadsheet(date, startTime, endTime, responseTime, message);
|
|
|
|
|
saveResponseTimeToSpreadsheet(startTime, endTime, responseTime, message);
|
|
|
|
|
|
|
|
|
|
return Response.status(Response.Status.CREATED).entity(response).build();
|
|
|
|
|
} catch (DeviceManagementException e) {
|
|
|
|
|