Package org.fluxtream.core.domain

Examples of org.fluxtream.core.domain.Guest


            javax.servlet.http.HttpServletRequest request,
            javax.servlet.http.HttpServletResponse response)
            throws AuthenticationException {
        final String autoLoginToken = request.getParameter("autoLoginToken");
        if (autoLoginToken !=null) {
            final Guest one = jpaDaoService.findOne("guest.byAutoLoginToken", Guest.class, autoLoginToken);

            if (one!=null) {
                if ((System.currentTimeMillis()-one.autoLoginTokenTimestamp)>60000) {
                    throw new RuntimeException("Token is too old!");
                }
View Full Code Here


    public Authentication attemptAuthenticationWithEmailAddress(HttpServletRequest request) throws AuthenticationException {

        String email = obtainUsername(request);
        String password = obtainPassword(request);

        final Guest guest = guestService.getGuestByEmail(email);
        String username = null;
        if (guest!=null) {
            username = guest.username;
        }
View Full Code Here

        try {
            String tokenValue = parseToken(request);
            if (tokenValue!=null) {
                AuthorizationToken authToken = oAuth2MgmtService.getTokenFromAccessToken(tokenValue);
                if (authToken!=null&&authToken.getExpirationIn()>0) {
                    final Guest guest = guestService.getGuestById(authToken.guestId);
                    final FlxUserDetails userDetails = new FlxUserDetails(guest);
                    PreAuthenticatedAuthenticationToken authentication = new PreAuthenticatedAuthenticationToken(userDetails, authToken,
                            getAuthorities(guest));
                    authentication.setDetails(userDetails);
                    authentication.setAuthenticated(true);
View Full Code Here

            @ApiResponse(code=401, message="The user is no longer logged in"),
            @ApiResponse(code=403, message="Buddy-to-access authorization has been revoked")
    })
    @ApiOperation(value = "Retrieve the avatar (gravatar) of the currently logged in's guest", response = AvatarImageModel.class)
    public Response getAvatarImage(@ApiParam(value="Buddy to access username parameter (" + BuddiesService.BUDDY_TO_ACCESS_PARAM + ")", required=false) @QueryParam(BuddiesService.BUDDY_TO_ACCESS_PARAM) String buddyToAccessParameter) {
        Guest guest = AuthHelper.getGuest();
        AvatarImageModel avatarImage = getAvatarImageModel(buddyToAccessParameter, guest);
        return Response.ok(avatarImage).build();
    }
View Full Code Here

    @Path("/coachees")
    @Produces({MediaType.APPLICATION_JSON})
    @ApiOperation(value = "Retrieve the currently logged in guest's list of coachees", responseContainer = "Array",
            response = GuestModel.class)
    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

public class TestsUtils {

  @SuppressWarnings("serial")
  public static void asGuest(String username) {
    Guest guest = new Guest();
    guest.username = username;
    final FlxUserDetails loggedUser = new FlxUserDetails(guest);
//    loggedUser.setDaylightSaving(false);
//    loggedUser.setTzOffset(1.0f);
    Authentication authToken = new Authentication() {
View Full Code Here

* Time: 12:05
*/
public class ApiHelper {

    static Guest getBuddyToAccess(GuestService guestService, CoachingBuddy coachee) {
        Guest guest = AuthHelper.getGuest();
        if (guest==null)
            return null;
        if (coachee!=null)
            return guestService.getGuestById(coachee.guestId);
        return guest;
View Full Code Here

    @GET
    @Path(value = "/model")
    @Produces({ MediaType.APPLICATION_JSON } )
    public String getModel(@QueryParam("state") String state) throws IOException {
        long guestId;
        Guest guest = AuthHelper.getGuest();
        guestId = guest.getId();
        StringBuilder sb = new StringBuilder("module=API component=calendarController action=getModel")
                .append(" guestId=").append(guestId);
        logger.info(sb.toString());
        CalendarModel calendarModel = CalendarModel.fromState(guestId, metadataService, state);
        return calendarModel.toJSONString(env);
View Full Code Here

        return weather;
    }

    @Override
    public void rebuildMetadata(final String username) {
        Guest guest = null;
        // Accept guest ID as well as username
        try {
            guest = guestService.getGuest(username);
            if(guest==null) {
                // Try to treat arg as guestId
                Long guestId = Long.valueOf(username);
                if(guestId!=null) {
                    guest = guestService.getGuestById(guestId);
                }
            }
        }
        catch (Exception e) {
            // Might get exception if username doesn't exist and non-numeric
            guest=null;
        }
        // Check if we succeeded, return.  This isn't really right because we don't get
        // error reporting, but would take to long to fix error reporting right now.
        // TODO: fix error reporting
        if(guest==null) {
            return;
        }

        String entityName = JPAUtils.getEntityName(LocationFacet.class);
        final Query nativeQuery = em.createNativeQuery(String.format("SELECT DISTINCT apiKeyId FROM %s WHERE guestId=%s", entityName, guest.getId()));
        final List<BigInteger> resultList = nativeQuery.getResultList();
        for (BigInteger apiKeyId : resultList) {
            if(apiKeyId!=null && apiKeyId.longValue()>0) {
                rebuildMetadata(guest.username, apiKeyId.longValue());
            }
View Full Code Here

            }
        }
    }

    private void rebuildMetadata(final String username, long apiKeyId) {
        final Guest guest = guestService.getGuest(username);
        String entityName = JPAUtils.getEntityName(LocationFacet.class);
        int i=0;
        final Query facetsQuery = em.createQuery(String.format("SELECT facet FROM %s facet WHERE facet.apiKeyId=? ORDER BY facet.start ASC", entityName));
        facetsQuery.setParameter(1, apiKeyId);
        while(true) {
            facetsQuery.setFirstResult(i);
            facetsQuery.setMaxResults(1000);
            final List<LocationFacet> rawLocations = facetsQuery.getResultList();
            //System.out.println(username + ": retrieved " + rawLocations.size() + " location datapoints (offset is " + i + ")");
            if (rawLocations.size()==0)
                break;
            //System.out.println(username + ":   " + AbstractLocalTimeFacet.timeStorageFormat.withZoneUTC().print(rawLocations.get(0).start));

            long then = System.currentTimeMillis();
            // Loop over the points to see if they're already included in visited cities entries
            // it's important that the location points in the locations list are for a single apiKeyId
            // and are in forward chronological order.  Only add locations that aren't already contained
            // within a VisitedCity item to the newLocations list
            List<LocationFacet> newLocations=new ArrayList<LocationFacet>();
            VisitedCity existingVisitedCityRecord = null;

            for (LocationFacet locationFacet : rawLocations) {
                // Check to see if this location is in the current existingVisitedCityRecord (if any)
                if(existingVisitedCityRecord !=null && locationFacet.start <=existingVisitedCityRecord.end) {
                    // This location falls within the last fetched visited cities record, skip it
                    continue;
                }
                // This location doesn't fall within the last fetched visited cities record (if any).
                // See if it fits in a new one.  Note that this really assumes that locationFacet.start
                // and locationFacet.end are the same and VisitedCity records are non-overlapping.
                // It returns null if there are no visited city
                // records overlapping the current point and non-null if there is one.
                existingVisitedCityRecord = JPAUtils.findUnique(em, VisitedCity.class,
                                                              "visitedCities.byApiAndTime",
                                                              locationFacet.apiKeyId,
                                                              locationFacet.start,
                                                              locationFacet.end);
                if(existingVisitedCityRecord == null) {
                    // This is a new point, add it
                    newLocations.add(locationFacet);
                }
                else {
                    // This point is already covered, skip it
                }
            }

            if(newLocations.size()>0) {
                long start = newLocations.get(0).start;
                System.out.println(username + ": processing " + newLocations.size() + " new " + entityName +
                                   " datapoints (offset is " + i + ", start is " + start +
                                   " = " + AbstractLocalTimeFacet.timeStorageFormat.withZoneUTC().print(start) + " UTC)");
                updateLocationMetadata(guest.getId(), newLocations);
            }
            else {
                System.out.println(username + ": no new " + entityName + " location datapoints (offset is " + i + ")");
            }
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.