aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/model/Device.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/model/Device.java')
-rw-r--r--src/main/java/org/traccar/model/Device.java44
1 files changed, 21 insertions, 23 deletions
diff --git a/src/main/java/org/traccar/model/Device.java b/src/main/java/org/traccar/model/Device.java
index b8c87921d..a3088a613 100644
--- a/src/main/java/org/traccar/model/Device.java
+++ b/src/main/java/org/traccar/model/Device.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 - 2022 Anton Tananaev (anton@traccar.org)
+ * Copyright 2012 - 2023 Anton Tananaev (anton@traccar.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,16 +15,26 @@
*/
package org.traccar.model;
-import java.util.Date;
-import java.util.List;
-import java.util.stream.Collectors;
-
import com.fasterxml.jackson.annotation.JsonIgnore;
import org.traccar.storage.QueryIgnore;
import org.traccar.storage.StorageName;
+import java.util.Date;
+
@StorageName("tc_devices")
-public class Device extends GroupedModel implements Disableable {
+public class Device extends GroupedModel implements Disableable, Schedulable {
+
+ private long calendarId;
+
+ @Override
+ public long getCalendarId() {
+ return calendarId;
+ }
+
+ @Override
+ public void setCalendarId(long calendarId) {
+ this.calendarId = calendarId;
+ }
private String name;
@@ -43,7 +53,10 @@ public class Device extends GroupedModel implements Disableable {
}
public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
+ if (uniqueId.contains("../") || uniqueId.contains("..\\")) {
+ throw new IllegalArgumentException("Invalid unique id");
+ }
+ this.uniqueId = uniqueId.trim();
}
public static final String STATUS_UNKNOWN = "unknown";
@@ -83,21 +96,6 @@ public class Device extends GroupedModel implements Disableable {
this.positionId = positionId;
}
- private List<Long> geofenceIds;
-
- @QueryIgnore
- public List<Long> getGeofenceIds() {
- return geofenceIds;
- }
-
- public void setGeofenceIds(List<? extends Number> geofenceIds) {
- if (geofenceIds != null) {
- this.geofenceIds = geofenceIds.stream().map(Number::longValue).collect(Collectors.toList());
- } else {
- this.geofenceIds = null;
- }
- }
-
private String phone;
public String getPhone() {
@@ -105,7 +103,7 @@ public class Device extends GroupedModel implements Disableable {
}
public void setPhone(String phone) {
- this.phone = phone;
+ this.phone = phone != null ? phone.trim() : null;
}
private String model;