Skip to content

Commit b19540a

Browse files
committed
fix(inventory): fix inventory XML / JSON data
Signed-off-by: Teclib <skita@teclib.com>
1 parent 1be005c commit b19540a

File tree

7 files changed

+20
-24
lines changed

7 files changed

+20
-24
lines changed

inventory/src/main/java/org/flyve/inventory/Utils.java

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -159,18 +159,12 @@ protected static String createJSON(Context context, ArrayList<Categories> catego
159159
boolean isPrivate, String tag) throws FlyveException {
160160
try {
161161

162-
if(!tag.equals("")) {
163-
JSONObject accountInfo = new JSONObject();
164-
accountInfo.put("keyName", "TAG");
165-
accountInfo.put("keyValue", tag);
166-
}
167-
168162
JSONObject jsonAccessLog = new JSONObject();
169-
jsonAccessLog.put("logDate", DateFormat.format("yyyy-MM-dd H:mm:ss", new Date()).toString());
170-
jsonAccessLog.put("userId", "N/A");
163+
jsonAccessLog.put("logDate", DateFormat.format("yyyy-MM-dd HH:mm:ss", new Date()).toString());
164+
jsonAccessLog.put("userId", "");
171165

172166
jsonAccessLog.put("keyname", "TAG");
173-
jsonAccessLog.put("keyvalue", "N/A");
167+
jsonAccessLog.put("keyvalue", tag);
174168

175169
JSONObject content = new JSONObject();
176170
content.put("accessLog", jsonAccessLog);
@@ -263,7 +257,7 @@ protected static String createXML(Context context, ArrayList<Categories> categor
263257
serializer.startTag(null, "ACCESSLOG");
264258

265259
serializer.startTag(null, "LOGDATE");
266-
serializer.text(DateFormat.format("yyyy-MM-dd H:mm:ss", new Date()).toString());
260+
serializer.text(DateFormat.format("yyyy-MM-dd HH:mm:ss", new Date()).toString());
267261
serializer.endTag(null, "LOGDATE");
268262

269263
serializer.startTag(null, "USERID");
@@ -273,16 +267,6 @@ protected static String createXML(Context context, ArrayList<Categories> categor
273267
serializer.endTag(null, "ACCESSLOG");
274268
// End ACCESSLOG
275269

276-
if(!tag.equals("")) {
277-
serializer.startTag(null, "ACCOUNTINFO");
278-
serializer.startTag(null, "KEYNAME");
279-
serializer.text("TAG");
280-
serializer.endTag(null, "KEYNAME");
281-
serializer.startTag(null, "KEYVALUE");
282-
serializer.text(tag);
283-
serializer.endTag(null, "KEYVALUE");
284-
serializer.endTag(null, "ACCOUNTINFO");
285-
}
286270

287271
for (Categories cat : categories) {
288272
if(isPrivate) {

inventory/src/main/java/org/flyve/inventory/categories/Category.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ public CategoryValue put(String key, CategoryValue value) {
121121
if (value != null) {
122122
if (value.getCategory() == null) {
123123
String s = value.getValue();
124-
if (s != null && !s.equals("") && !s.equals(Build.UNKNOWN)){
124+
if (s != null && !s.equals(Build.UNKNOWN)){
125+
if(s.equalsIgnoreCase("N/A") || s.equalsIgnoreCase("N\\/A")){
126+
value.setValue("");
127+
}
125128
return super.put(key, value);
126129
} else if (value.getValues() != null && value.getValues().size() > 0) {
127130
return super.put(key, value);

inventory/src/main/java/org/flyve/inventory/categories/CategoryValue.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ public String getValue() {
141141
return value;
142142
}
143143

144+
public void setValue(String newValue) {
145+
this.value = newValue;
146+
}
147+
144148
public String getJsonName() {
145149
return jsonName;
146150
}

inventory/src/main/java/org/flyve/inventory/categories/Hardware.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public String getDateLastLoggedUser() {
150150
try {
151151
String lastLoggedIn = getUserTagValue("lastLoggedIn");
152152
if (!"N/A".equals(lastLoggedIn)) {
153-
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm", Locale.getDefault());
153+
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss", Locale.getDefault());
154154
Date resultDate = new Date(Long.parseLong(lastLoggedIn));
155155
value = sdf.format(resultDate);
156156
}

inventory/src/main/java/org/flyve/inventory/categories/Networks.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public class Networks extends Categories {
6767

6868
// Properties of this component
6969
private static final String TYPE = "WIFI";
70+
private static final String NO_DECSRIPTION_PROVIDED = "No description found";
7071
private DhcpInfo dhcp;
7172
private WifiInfo wifi;
7273
private final Context context;
@@ -341,6 +342,10 @@ public String getDescription() {
341342
} catch (Exception ex) {
342343
FlyveLog.e(FlyveLog.getMessage(context, CommonErrorType.NETWORKS_DESCRIPTION, ex.getMessage()));
343344
}
345+
346+
//change name
347+
name = NO_DECSRIPTION_PROVIDED;
348+
344349
return name;
345350
}
346351

inventory/src/main/java/org/flyve/inventory/categories/OperatingSystem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public String getBootTime() {
182182
String value = "N/A";
183183
try {
184184
long milliSeconds = System.currentTimeMillis() - SystemClock.elapsedRealtime();
185-
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm", Locale.getDefault());
185+
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss", Locale.getDefault());
186186
Date resultDate = new Date(milliSeconds);
187187
value = sdf.format(resultDate);
188188
} catch (Exception ex) {

inventory/src/main/java/org/flyve/inventory/categories/Sensors.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public Sensors(Context xCtx) {
7070
Category c = new Category("SENSORS", "sensors");
7171

7272
c.put("NAME", new CategoryValue(getName(s), "NAME", "name"));
73-
c.put("MANUFACTURER", new CategoryValue(getManufacturer(s), "NAME", "manufacturer"));
73+
c.put("MANUFACTURER", new CategoryValue(getManufacturer(s), "MANUFACTURER", "manufacturer"));
7474
c.put("TYPE", new CategoryValue(getType(s), "TYPE", "type"));
7575
c.put("POWER", new CategoryValue(getPower(s), "POWER", "power"));
7676
c.put("VERSION", new CategoryValue(getVersion(s), "VERSION", "version"));

0 commit comments

Comments
 (0)