aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar/api/resource/CalendarResource.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/traccar/api/resource/CalendarResource.java')
-rw-r--r--src/org/traccar/api/resource/CalendarResource.java20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/org/traccar/api/resource/CalendarResource.java b/src/org/traccar/api/resource/CalendarResource.java
index 641d3b4b5..be675fc79 100644
--- a/src/org/traccar/api/resource/CalendarResource.java
+++ b/src/org/traccar/api/resource/CalendarResource.java
@@ -33,6 +33,7 @@ import javax.ws.rs.core.Response;
import org.traccar.Context;
import org.traccar.api.BaseResource;
+import org.traccar.database.CalendarManager;
import org.traccar.model.Calendar;
@Path("calendars")
@@ -44,28 +45,29 @@ public class CalendarResource extends BaseResource {
public Collection<Calendar> get(
@QueryParam("all") boolean all, @QueryParam("userId") long userId) throws SQLException {
+ CalendarManager calendarManager = Context.getCalendarManager();
if (all) {
if (Context.getPermissionsManager().isAdmin(getUserId())) {
- return Context.getCalendarManager().getAllCalendars();
+ return calendarManager.getItems(Calendar.class, calendarManager.getAllItems());
} else {
Context.getPermissionsManager().checkManager(getUserId());
- return Context.getCalendarManager().getManagedCalendars(getUserId());
+ return calendarManager.getItems(Calendar.class, calendarManager.getManagedItems(getUserId()));
}
} else {
if (userId == 0) {
userId = getUserId();
}
Context.getPermissionsManager().checkUser(getUserId(), userId);
- return Context.getCalendarManager().getUserCalendars(userId);
+ return calendarManager.getItems(Calendar.class, calendarManager.getUserItems(userId));
}
}
@POST
public Response add(Calendar entity) throws SQLException {
Context.getPermissionsManager().checkReadonly(getUserId());
- Context.getCalendarManager().addCalendar(entity);
+ Context.getCalendarManager().addItem(entity);
Context.getDataManager().linkCalendar(getUserId(), entity.getId());
- Context.getCalendarManager().refreshUserCalendars();
+ Context.getCalendarManager().refreshUserItems();
return Response.ok(entity).build();
}
@@ -73,8 +75,8 @@ public class CalendarResource extends BaseResource {
@PUT
public Response update(Calendar entity) throws SQLException {
Context.getPermissionsManager().checkReadonly(getUserId());
- Context.getPermissionsManager().checkCalendar(getUserId(), entity.getId());
- Context.getCalendarManager().updateCalendar(entity);
+ Context.getPermissionsManager().checkPermission("calendar", getUserId(), entity.getId());
+ Context.getCalendarManager().updateItem(entity);
return Response.ok(entity).build();
}
@@ -82,8 +84,8 @@ public class CalendarResource extends BaseResource {
@DELETE
public Response remove(@PathParam("id") long id) throws SQLException {
Context.getPermissionsManager().checkReadonly(getUserId());
- Context.getPermissionsManager().checkCalendar(getUserId(), id);
- Context.getCalendarManager().removeCalendar(id);
+ Context.getPermissionsManager().checkPermission("calendar", getUserId(), id);
+ Context.getCalendarManager().removeItem(id);
return Response.noContent().build();
}
}