@POST
  @Path("entry")
  @Produces("application/json")
  @Consumes("application/json")
  public long addTimeEntry(TimeEntry entry)
  {
    Date currentTime = new Date();

    if(entry == null)
      throw new IllegalArgumentException("Time entry data not formatted correctly");

    if(em.contains(entry))
      throw new IllegalArgumentException("Time entry already added");

    if(entry.getUser() == null || entry.getUser().getId() == 0L)
      throw new IllegalArgumentException("Invalid user ID");

    if(entry.getAction() == null || entry.getAction().getId() == 0L)
      throw new IllegalArgumentException("Invalid action ID");

    if(entry.getStart() == null)
      entry.setStart(currentTime);

    //TODO: Think about adding back-dated entries

    //Automatically stop an active entry if it appears the new entry
    //starts after the active one
    TimeEntry activeEntry = getActiveUserEntry(entry.getUser());
    if(activeEntry != null && 
       activeEntry.getStart().getTime() < entry.getStart().getTime())
    {
      activeEntry.setEnd(currentTime);
      em.persist(activeEntry);
    }

    em.persist(entry);

    return entry.getId();
  }