예제 #1
0
 @Path("{id}")
 @PUT
 public Response update(Geofence entity) throws SQLException {
   Context.getPermissionsManager().checkReadonly(getUserId());
   Context.getPermissionsManager().checkGeofence(getUserId(), entity.getId());
   Context.getGeofenceManager().updateGeofence(entity);
   return Response.ok(entity).build();
 }
예제 #2
0
 @POST
 public Response add(Geofence entity) throws SQLException {
   Context.getPermissionsManager().checkReadonly(getUserId());
   Context.getDataManager().addGeofence(entity);
   Context.getDataManager().linkGeofence(getUserId(), entity.getId());
   Context.getGeofenceManager().refreshGeofences();
   return Response.ok(entity).build();
 }
예제 #3
0
 public final void updateGeofence(Geofence geofence) {
   geofencesLock.writeLock().lock();
   try {
     geofences.put(geofence.getId(), geofence);
   } finally {
     geofencesLock.writeLock().unlock();
   }
   try {
     dataManager.updateGeofence(geofence);
   } catch (SQLException error) {
     Log.warning(error);
   }
 }
예제 #4
0
 public final void refreshGeofences() {
   if (dataManager != null) {
     try {
       geofencesLock.writeLock().lock();
       try {
         geofences.clear();
         for (Geofence geofence : dataManager.getGeofences()) {
           geofences.put(geofence.getId(), geofence);
         }
       } finally {
         geofencesLock.writeLock().unlock();
       }
     } catch (SQLException error) {
       Log.warning(error);
     }
   }
   refreshUserGeofences();
   refresh();
 }