Package org.fluxtream.core.domain

Examples of org.fluxtream.core.domain.Guest


  @PersistenceContext
  EntityManager em;
 
  public UserDetails loadUserByUsername(String username)
      throws UsernameNotFoundException {
    final Guest guest = JPAUtils.findUnique(em, Guest.class,
        "guest.byUsername", username);
    if (guest == null)
      throw new UsernameNotFoundException(username + " Not Found");
    FlxUserDetails user = new FlxUserDetails(guest);
    return user;
View Full Code Here


    @Produces({MediaType.APPLICATION_JSON})
    @ApiOperation(value = "Get the user's photos for a specific date", responseContainer = "Array", response = PhotoModel.class)
    public Response getPhotosForDate(@ApiParam(value="Username (must be currently logged in user's username)", required=true) @PathParam("username") String username,
                                     @ApiParam(value="Date (yyyy-mm-dd)", required=true) @PathParam("date") String date){
        try{
            Guest guest = guestService.getGuest(username);
            if (AuthHelper.getGuest().getId()!=guest.getId())
                throw new RuntimeException("Attempt to access another user's photos");
            DayMetadata dayMeta = metadataService.getDayMetadata(guest.getId(), date);
            return Response.ok(gson.toJson(getPhotos(guest, dayMeta.getTimeInterval()))).build();
        } catch (Exception e){
            return Response.serverError().entity("Could not get guest addresses: " + e.getMessage()).build();
        }
    }
View Full Code Here

        try{
            Calendar c = Calendar.getInstance();
            c.set(Calendar.YEAR,year);
            c.set(Calendar.WEEK_OF_YEAR,week);
            c.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
            Guest guest = guestService.getGuest(username);
            if (AuthHelper.getGuest().getId()!=guest.getId())
                throw new RuntimeException("Attempt to access another user's photos");
            DecimalFormat datePartFormat = new DecimalFormat("00");
            DayMetadata dayMetaStart = metadataService.getDayMetadata(guest.getId(), year + "-" + datePartFormat.format(c.get(Calendar.MONTH) + 1) +
                                                                                          "-" + datePartFormat.format(c.get(Calendar.DAY_OF_MONTH)));
            int newDay = c.get(Calendar.DAY_OF_YEAR) + 6;
            if (newDay > (isLeapYear(year) ? 366 : 365)){
                newDay -= isLeapYear(year) ? 366 : 365;
                year += 1;
                c.set(Calendar.YEAR,year);
            }
            c.set(Calendar.DAY_OF_YEAR,newDay);
            DayMetadata dayMetaEnd = metadataService.getDayMetadata(guest.getId(), year + "-" + datePartFormat.format(c.get(Calendar.MONTH) + 1) +
                                                                                          "-" + datePartFormat.format(c.get(Calendar.DAY_OF_MONTH)));
            return Response.ok(gson.toJson(getPhotos(guest, new SimpleTimeInterval(dayMetaStart.start,dayMetaEnd.end,TimeUnit.WEEK,dayMetaStart.getTimeInterval().getMainTimeZone())))).build();
        } catch (Exception e){
            return Response.serverError().entity("Could not get photos: " + e.getMessage()).build();
        }
View Full Code Here

    @ApiOperation(value = "Get the user's photos for an entire year", responseContainer = "Array", response = PhotoModel.class)
    public Response getPhotosForYear(@ApiParam(value="Username (must be currently logged in user's username)", required=true) @PathParam("username") String username,
                                   @ApiParam(value="Year", required=true) @PathParam("year") int year){
        try{

            Guest guest = guestService.getGuest(username);
            if (AuthHelper.getGuest().getId()!=guest.getId())
                throw new RuntimeException("Attempt to access another user's photos");
            DayMetadata dayMetaStart = metadataService.getDayMetadata(guest.getId(), year + "-01-01");

            DayMetadata dayMetaEnd = metadataService.getDayMetadata(guest.getId(), year + "-12-31");
            return Response.ok(gson.toJson(getPhotos(guest, new SimpleTimeInterval(dayMetaStart.start,dayMetaEnd.end,TimeUnit.YEAR,dayMetaStart.getTimeInterval().getMainTimeZone())))).build();
        } catch (Exception e){
            return Response.serverError().entity("Could not get photos: " + e.getMessage()).build();
        }
View Full Code Here

        if (!parse.isInParseGuestList(event.updateInfo.getGuestId()))
            return;
        final StringBuilder msgAtts = new StringBuilder("module=events component=DataReceivedEventListener action=handleEvent");
        final Connector connector = event.updateInfo.apiKey.getConnector();
        final String connectorName = connector.getName();
        final Guest guest = guestService.getGuestById(event.updateInfo.getGuestId());
        final StringBuilder sb = new StringBuilder(msgAtts)
                .append(" connector=").append(connectorName)
                .append(" eventType=").append(event.objectTypes)
                .append(" date=").append(event.date)
                .append(" guestId=").append(event.updateInfo.getGuestId());
View Full Code Here

      IllegalAccessException, ClassNotFoundException {
        try{
            CoachingBuddy coachee;
            try { coachee = AuthHelper.getCoachee(buddyToAccessParameter, buddiesService);
            } catch (CoachRevokedException e) {return Response.status(403).entity("Sorry, permission to access this data has been revoked. Please reload your browser window").build();}
            Guest guest = ApiHelper.getBuddyToAccess(guestService, coachee);
            if (guest==null)
                return Response.status(401).entity("You are no longer logged in").build();
            GuestModel guestModel = new GuestModel(guest, coachee!=null);
            if (includeAvatar)
                guestModel.avatar = getAvatarImageModel(buddyToAccessParameter, guest);
View Full Code Here

  public Object getCurrentGuest() throws InstantiationException,
      IllegalAccessException, ClassNotFoundException {
        try{
            long guestId = AuthHelper.getGuestId();

            Guest guest = guestService.getGuestById(guestId);
            GuestModel guestModel = new GuestModel(guest, false);

            return guestModel;
        }
        catch (Exception e){
View Full Code Here

    @Path("/avatarImage")
    @Produces({MediaType.APPLICATION_JSON})
    @ApiOperation(value = "Retrieve the avatar (gravatar) of the currently logged in's guest", response = String.class)
    @Deprecated
    public String getAvatarImage() {
        Guest guest = AuthHelper.getGuest();
        JSONObject json = new JSONObject();
        String type = "none";
        String url;
        try {
            final CoachingBuddy coachee = AuthHelper.getCoachee();
View Full Code Here

    @Produces({MediaType.APPLICATION_JSON})
    @ApiOperation(value = "Retrieve the currently logged in guest's list of coachees", responseContainer = "Array",
            response = GuestModel.class)
    @Deprecated
    public List<GuestModel> getCoachees() {
        Guest guest = AuthHelper.getGuest();
        final List<Guest> coachees = buddiesService.getTrustedBuddies(guest.getId());
        final List<GuestModel> coacheeModels = new ArrayList<GuestModel>();
        for (Guest coachee : coachees)
            coacheeModels.add(new GuestModel(coachee, true));
        return coacheeModels;
    }
View Full Code Here

    if (auth==null)
      return null;
        final Object authPrincipal = auth.getPrincipal();
        if (authPrincipal instanceof FlxUserDetails) {
            final FlxUserDetails principal = (FlxUserDetails) authPrincipal;
            Guest guest = principal.getGuest();
            // set the guest's ID in case we got an instance that was deserialized from
            // disk (in which case it will be null)
            guest.setId(principal.guestId);
            return guest;
        } else return null;
  }
View Full Code Here

TOP

Related Classes of org.fluxtream.core.domain.Guest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.