|
|
|
@ -23,13 +23,7 @@ import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport;
|
|
|
|
|
import com.google.api.client.json.jackson2.JacksonFactory;
|
|
|
|
|
import com.google.api.services.sheets.v4.Sheets;
|
|
|
|
|
import com.google.api.services.sheets.v4.SheetsScopes;
|
|
|
|
|
import com.google.api.services.sheets.v4.model.*;
|
|
|
|
|
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.security.GeneralSecurityException;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import com.google.api.services.sheets.v4.model.ValueRange;
|
|
|
|
|
import com.google.gson.Gson;
|
|
|
|
|
import com.google.gson.JsonArray;
|
|
|
|
|
import com.google.gson.JsonElement;
|
|
|
|
@ -66,21 +60,19 @@ import org.wso2.carbon.policy.mgt.common.PolicyManagementException;
|
|
|
|
|
import org.wso2.carbon.user.api.UserStoreException;
|
|
|
|
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
import javax.ws.rs.DELETE;
|
|
|
|
|
import javax.ws.rs.GET;
|
|
|
|
|
import javax.ws.rs.POST;
|
|
|
|
|
import javax.ws.rs.PUT;
|
|
|
|
|
import javax.ws.rs.Path;
|
|
|
|
|
import javax.ws.rs.PathParam;
|
|
|
|
|
import javax.ws.rs.QueryParam;
|
|
|
|
|
import javax.ws.rs.*;
|
|
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.rmi.RemoteException;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.security.GeneralSecurityException;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
@Path("/device/agent")
|
|
|
|
|
public class DeviceAgentServiceImpl implements DeviceAgentService {
|
|
|
|
|
static final Log log = LogFactory.getLog(DeviceAgentServiceImpl.class);
|
|
|
|
|
private static final String POLICY_MONITOR = "POLICY_MONITOR";
|
|
|
|
|
|
|
|
|
|
@POST
|
|
|
|
|
@Path("/enroll")
|
|
|
|
|
@Override
|
|
|
|
@ -247,7 +239,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
|
|
|
|
|
return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Object metaData[] = new Object[1];
|
|
|
|
|
Object[] metaData = new Object[1];
|
|
|
|
|
metaData[0] = deviceId;
|
|
|
|
|
EventAttributeList eventAttributeList = DeviceMgtAPIUtils.getDynamicEventCache().get(type);
|
|
|
|
|
if (eventAttributeList == null) {
|
|
|
|
@ -347,7 +339,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
|
|
|
|
|
return Response.status(Response.Status.UNAUTHORIZED).entity(msg).build();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Object metaData[] = new Object[1];
|
|
|
|
|
Object[] metaData = new Object[1];
|
|
|
|
|
metaData[0] = deviceId;
|
|
|
|
|
EventAttributeList eventAttributeList = DeviceMgtAPIUtils.getDynamicEventCache().get(type);
|
|
|
|
|
if (eventAttributeList == null) {
|
|
|
|
@ -459,7 +451,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
|
|
|
|
|
String spreadsheetId = "1OZCS5NRwwSum9ai3ra4lABtU0UGW-9yLYgZk-aQfxpw"; // Replace with the actual spreadsheet ID
|
|
|
|
|
|
|
|
|
|
// Create the values to be written
|
|
|
|
|
List<List<Object>> values = Arrays.asList(
|
|
|
|
|
List<List<Object>> values = Collections.singletonList(
|
|
|
|
|
Arrays.asList(deviceId, String.valueOf(responseTime))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -487,6 +479,7 @@ public class DeviceAgentServiceImpl implements DeviceAgentService {
|
|
|
|
|
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorMessage).build();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Sheets createSheetsService() throws IOException {
|
|
|
|
|
GoogleCredential credential = GoogleCredential.fromStream(new FileInputStream("components/device-mgt/org.wso2.carbon.device.mgt.api/target/apicall-382608-48aa6a62800d.json"))
|
|
|
|
|
.createScoped(Collections.singleton(SheetsScopes.SPREADSHEETS));
|
|
|
|
|