| 12291 |
manish.sha |
1 |
package com.google.api.services.content.utils;
|
|
|
2 |
|
|
|
3 |
import com.google.api.client.json.GenericJson;
|
|
|
4 |
import com.google.api.client.json.JsonString;
|
|
|
5 |
import com.google.api.client.json.jackson2.JacksonFactory;
|
|
|
6 |
import com.google.api.client.util.Key;
|
|
|
7 |
|
|
|
8 |
import java.io.File;
|
|
|
9 |
import java.io.FileInputStream;
|
|
|
10 |
import java.io.IOException;
|
|
|
11 |
import java.io.InputStream;
|
|
|
12 |
import java.math.BigInteger;
|
|
|
13 |
|
|
|
14 |
/**
|
|
|
15 |
* Wrapper for the JSON configuration file used to keep user specific details like authentication
|
|
|
16 |
* information and Merchant Center account ID.
|
|
|
17 |
*/
|
|
|
18 |
public class Config extends GenericJson {
|
|
|
19 |
private static final String FILE_NAME = "config.json";
|
| 12294 |
manish.sha |
20 |
private static final File CONFIG_FILE = new File("/root/code/trunk/SaholicProductFeeds/src/main/resources/config.json");
|
| 12291 |
manish.sha |
21 |
|
|
|
22 |
@Key
|
|
|
23 |
private String clientId = "";
|
|
|
24 |
|
|
|
25 |
@Key
|
|
|
26 |
private String clientSecret = "";
|
|
|
27 |
|
|
|
28 |
@Key
|
|
|
29 |
@JsonString
|
|
|
30 |
private BigInteger merchantId;
|
|
|
31 |
|
|
|
32 |
@Key
|
|
|
33 |
private String applicationName = "";
|
|
|
34 |
|
|
|
35 |
@Key
|
|
|
36 |
private String refreshToken = "";
|
|
|
37 |
|
|
|
38 |
public static Config load() throws IOException {
|
|
|
39 |
return Config.load(CONFIG_FILE);
|
|
|
40 |
}
|
|
|
41 |
|
|
|
42 |
public static Config load(File configFile) throws IOException {
|
|
|
43 |
InputStream inputStream = null;
|
|
|
44 |
try {
|
|
|
45 |
inputStream = new FileInputStream(configFile);
|
|
|
46 |
return new JacksonFactory().fromInputStream(inputStream, Config.class);
|
|
|
47 |
} catch (IOException e) {
|
|
|
48 |
throw new IOException("Could not find or read the config file at "
|
|
|
49 |
+ configFile.getCanonicalPath() + ". You can use the config.json file in the samples "
|
|
|
50 |
+ "root as a template.");
|
|
|
51 |
} finally {
|
|
|
52 |
if (inputStream != null) {
|
|
|
53 |
inputStream.close();
|
|
|
54 |
}
|
|
|
55 |
}
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
public String getClientId() {
|
|
|
59 |
return clientId;
|
|
|
60 |
}
|
|
|
61 |
|
|
|
62 |
public void setClientId(String clientId) {
|
|
|
63 |
this.clientId = clientId;
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
public String getClientSecret() {
|
|
|
67 |
return clientSecret;
|
|
|
68 |
}
|
|
|
69 |
|
|
|
70 |
public void setClientSecret(String clientSecret) {
|
|
|
71 |
this.clientSecret = clientSecret;
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
public BigInteger getMerchantId() {
|
|
|
75 |
return merchantId;
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
public void setMerchantId(BigInteger merchantId) {
|
|
|
79 |
this.merchantId = merchantId;
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
public String getApplicationName() {
|
|
|
83 |
return applicationName;
|
|
|
84 |
}
|
|
|
85 |
|
|
|
86 |
public void setApplicationName(String applicationName) {
|
|
|
87 |
this.applicationName = applicationName;
|
|
|
88 |
}
|
|
|
89 |
|
|
|
90 |
public String getRefreshToken() {
|
|
|
91 |
return refreshToken;
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
public void setRefreshToken(String refreshToken) {
|
|
|
95 |
this.refreshToken = refreshToken;
|
|
|
96 |
}
|
|
|
97 |
}
|