Update config file

pull/140/head
Akeela Azhar 1 year ago
parent 3a4738c3f6
commit 378095dbf3

@ -120,14 +120,28 @@ import org.wso2.carbon.utils.multitenancy.MultitenantUtils;
import javax.validation.Valid;
import javax.validation.constraints.Size;
import javax.ws.rs.*;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
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.core.Response;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Properties;
@Path("/devices")
public class DeviceManagementServiceImpl implements DeviceManagementService {
@ -164,8 +178,20 @@ public class DeviceManagementServiceImpl implements DeviceManagementService {
private void saveResponseTimeToSpreadsheet(long startTime, long endTime, long responseTime, String message) throws IOException, GeneralSecurityException {
this.message = message;
// Load the configuration file
Properties config = new Properties();
try (FileInputStream configFile = new FileInputStream("config.json")) {
config.load(configFile);
} catch (IOException e) {
e.printStackTrace();
}
// Get the file path from the configuration file
String filePath = config.getProperty("file.path");
// 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"))
GoogleCredential credential = GoogleCredential.fromStream(new FileInputStream(filePath))
.createScoped(Collections.singleton(SheetsScopes.SPREADSHEETS));
// Build Google Sheets service

@ -170,5 +170,8 @@
"backendRestEndpoints": {
"deviceMgt": "/api/device-mgt/v1.0",
"appMgt": "/api/application-mgt-store/v1.0"
},
"Googlesheetcredentials": {
"file.path" : "/home/entgra/MyProject/device-mgt-core/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/test/resources/apicall-382608-48aa6a62800d.json"
}
}

Loading…
Cancel
Save