private static String generateToken() {
   final StringBuilder builder = new StringBuilder(260);
   while (builder.length() < 256) {
     builder.append(Long.toHexString(TOKEN_GENERATOR.nextLong()));
   }
   return builder.substring(0, 256);
 }
 public void updateWorkout(
     final Long id,
     final User user,
     final Date date,
     final Long duration,
     final Double distance,
     final Long energy,
     final String discipline,
     final String debriefing,
     final String trackId)
     throws WorkoutNotFoundException, AccessDeniedException, TrackNotFoundException {
   final TrackImpl track =
       trackId != null && !trackId.isEmpty()
           ? fetchTrackForUpdate(user, Long.parseLong(trackId))
           : null;
   workoutStore.updateWorkout(
       id, user, date, duration, distance, energy, discipline, debriefing, track);
 }
 public void deleteTrack(final User user, final Long id)
     throws TrackNotFoundException, AccessDeniedException {
   entityManager.remove(fetchTrackForUpdate(user, id.longValue()));
 }