diff options
Diffstat (limited to 'src/main/java/org/traccar/api')
-rw-r--r-- | src/main/java/org/traccar/api/BaseResource.java | 3 | ||||
-rw-r--r-- | src/main/java/org/traccar/api/resource/ServerResource.java | 17 |
2 files changed, 12 insertions, 8 deletions
diff --git a/src/main/java/org/traccar/api/BaseResource.java b/src/main/java/org/traccar/api/BaseResource.java index cc272df9c..56bf70cf0 100644 --- a/src/main/java/org/traccar/api/BaseResource.java +++ b/src/main/java/org/traccar/api/BaseResource.java @@ -15,11 +15,12 @@ */ package org.traccar.api; +import javax.ws.rs.core.Context; import javax.ws.rs.core.SecurityContext; public class BaseResource { - @javax.ws.rs.core.Context + @Context private SecurityContext securityContext; protected long getUserId() { diff --git a/src/main/java/org/traccar/api/resource/ServerResource.java b/src/main/java/org/traccar/api/resource/ServerResource.java index 8096c66fa..2d17d5e47 100644 --- a/src/main/java/org/traccar/api/resource/ServerResource.java +++ b/src/main/java/org/traccar/api/resource/ServerResource.java @@ -1,5 +1,5 @@ /* - * Copyright 2015 - 2020 Anton Tananaev (anton@traccar.org) + * Copyright 2015 - 2022 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. @@ -19,9 +19,13 @@ import org.traccar.Context; import org.traccar.api.BaseResource; import org.traccar.helper.LogAction; import org.traccar.model.Server; +import org.traccar.storage.Storage; import org.traccar.storage.StorageException; +import org.traccar.storage.query.Columns; +import org.traccar.storage.query.Request; import javax.annotation.security.PermitAll; +import javax.inject.Inject; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.PUT; @@ -36,14 +40,13 @@ import javax.ws.rs.core.Response; @Consumes(MediaType.APPLICATION_JSON) public class ServerResource extends BaseResource { + @Inject + private Storage storage; + @PermitAll @GET - public Server get(@QueryParam("force") boolean force) throws StorageException { - if (force) { - return Context.getDataManager().getServer(); - } else { - return Context.getPermissionsManager().getServer(); - } + public Server get() throws StorageException { + return storage.getObject(Server.class, new Request(new Columns.All())); } @PUT |