Package org.fluxtream.core.domain

Examples of org.fluxtream.core.domain.Guest


            @ApiResponse(code=200, message = "Settings updated")
    })
    public Response saveSettings(@ApiParam(value="First name", required=true) @FormParam("guest_firstname") String firstName,
                               @ApiParam(value="Last name", required=true) @FormParam("guest_lastname") String lastName) {
        try {
            Guest guest = AuthHelper.getGuest();

            settingsService.setFirstname(guest.getId(), firstName);
            settingsService.setLastname(guest.getId(), lastName);

            return Response.ok("settings updated!").build();
        }
        catch (Exception e){
            return Response.serverError().entity("Failed to save settings: " + e.getMessage()).build();
View Full Code Here


                               @ApiParam(value="Distance measure unit", allowableValues = "SI, MILES_YARDS", required=true) @FormParam("distance_measure_unit") String distanceUnit,
                               @ApiParam(value="Weight measure unit", allowableValues = "SI, POUNDS, STONES", required=true) @FormParam("weight_measure_unit") String weightUnit,
                               @ApiParam(value="Temperature unit", allowableValues = "CELSIUS, FAHRENHEIT", required=true) @FormParam("temperature_unit") String temperatureUnit) {
        try{

            Guest guest = AuthHelper.getGuest();
            GuestSettings.LengthMeasureUnit lngUnt = Enum.valueOf(
                    GuestSettings.LengthMeasureUnit.class, lengthUnit);
            GuestSettings.DistanceMeasureUnit dstUnt = Enum.valueOf(
                    GuestSettings.DistanceMeasureUnit.class, distanceUnit);
            GuestSettings.WeightMeasureUnit whtUnt = Enum.valueOf(
                    GuestSettings.WeightMeasureUnit.class, weightUnit);
            GuestSettings.TemperatureUnit tempUnt = Enum.valueOf(
                    GuestSettings.TemperatureUnit.class, temperatureUnit);
            settingsService.setLengthMeasureUnit(guest.getId(), lngUnt);
            settingsService.setDistanceMeasureUnit(guest.getId(), dstUnt);
            settingsService.setWeightMeasureUnit(guest.getId(), whtUnt);
            settingsService.setTemperatureUnit(guest.getId(), tempUnt);

            return Response.ok("settings updated!").build();
        }
        catch (Exception e){
            return Response.serverError().entity("Failed to save settings: " + e.getMessage()).build();
View Full Code Here

    public Response saveSettings(@ApiParam(value="Current password", required=true) @FormParam("currentPassword") String currentPassword,
                               @ApiParam(value="New password", required=true) @FormParam("password1") String password1,
                               @ApiParam(value="New password (repeat)", required=true) @FormParam("password2") String password2)
            throws IOException {
        try{
            Guest guest = AuthHelper.getGuest();

            if (currentPassword!=null) {
                boolean passwordMatched = guestService.checkPassword(guest.getId(), currentPassword);
                if (!passwordMatched) {
                    return Response.ok(gson.toJson(new StatusModel(false, "Wrong Password"))).build();
                }
            }

            if (password1.length()==0 || password2.length()==0)
                return Response.ok(gson.toJson(new StatusModel(false, "Please fill in both password fields"))).build();
            else {
                if (!password1.equals(password2)) {
                    return Response.ok(gson.toJson(new StatusModel(false, "Passwords don't match"))).build();
                }
                if (password1.length()<8) {
                    return Response.ok(gson.toJson(new StatusModel(false, "Your password should be at least 8 characters long"))).build();
                } else {
                    guestService.setPassword(guest.getId(), password1);
                }
            }

            return Response.ok(new StatusModel(true, "settings updated!")).build();
        }
View Full Code Here

                               @QueryParam("att") String attValue) throws IOException {
        // check that we're running locally
        if (!RequestUtils.isDev(request)) {
            response.setStatus(403);
        }
        final Guest guest = guestService.getGuest(username);
        ApiKey apiKey = guestService.getApiKey(guest.getId(), Connector.getConnector("fluxtream_capture"));
        if (apiKey == null) {
            apiKey = guestService.createApiKey(guest.getId(), Connector.getConnector("fluxtream_capture"));
        }
        guestService.setApiKeyAttribute(apiKey, "test", attValue);
        return "attribute was set";
    }
View Full Code Here

                                      @PathParam("connectorName") String connectorName) throws IOException {
        // check that we're running locally
        if (!RequestUtils.isDev(request)) {
            response.setStatus(403);
        }
        final Guest guest = guestService.getGuest(username);
        final Connector connector = Connector.getConnector(connectorName);
        ApiKey apiKey = guestService.getApiKey(guest.getId(), connector);
        connectorUpdateService.updateConnector(apiKey, true);
        return "updating connector " + connectorName + " for guest " + guest.username;
    }
View Full Code Here

                                       @PathParam("username") String username) throws IOException {
        // check that we're running locally
        if (!RequestUtils.isDev(request)) {
            response.setStatus(403);
        }
        final Guest guest = guestService.getGuest(username);
        connectorUpdateService.updateAllConnectors(guest.getId(), true);
        return "updating all connectors for guest " + guest.username;
    }
View Full Code Here

                me = gson.toJson(user);
            } catch (Exception e) {
                e.printStackTrace();
            }

            Guest guest = guestService.getGuest(user.getUsername());
            final String autoLoginToken = generateSecureRandomString();
            if (guest==null) {
                FacebookClient.AccessToken accessToken =
                        new DefaultFacebookClient().obtainExtendedAccessToken(appId, appSecret, access_token);
                String firstname = user.getFirstName();
                String lastname = user.getLastName();
                guest = guestService.createGuest(user.getUsername(), firstname!=null?firstname:"",
                                                 lastname!=null?lastname:"",
                                                 null, user.getEmail(),
                                                 Guest.RegistrationMethod.REGISTRATION_METHOD_FACEBOOK, null);
                final ApiKey apiKey = guestService.createApiKey(guest.getId(), Connector.getConnector("facebook"));

                guestService.setApiKeyAttribute(apiKey, "accessToken", accessToken.getAccessToken());
                guestService.setApiKeyAttribute(apiKey, "expires", String.valueOf(accessToken.getExpires().getTime()));
                guestService.setApiKeyAttribute(apiKey, "me", me);
View Full Code Here

            @ApiResponse(code=400, message="The user is already trusted by the calling guest"),
            @ApiResponse(code=404, message="No such user was found")
    })
    @Produces({MediaType.APPLICATION_JSON})
    public Response findCoach(@ApiParam(value="The buddy's username", required=true) @FormParam("username") String username) {
        final Guest guest = guestService.getGuest(username);
        final List<Guest> coaches = buddiesService.getTrustedBuddies(AuthHelper.getGuestId());
        if (coaches.contains(guest))
            return Response.status(Response.Status.BAD_REQUEST).entity(username + " is already in you coaching buddies list").build();
        if (guest!=null) {
            return Response.ok(new GuestModel(guest)).build();
View Full Code Here

            if (SharedConnectorSettingsAwareUpdater.class.isAssignableFrom(apiKey.getConnector().getUpdaterClass()))
                connector.hasSettings = true;
            connectors.add(connector);
        }
        coach.sharedConnectors  = connectors;
        Guest buddyGuest = guestService.getGuest(username);
        coach.username = buddyGuest.username;
        coach.fullname = buddyGuest.getGuestName();
        return coach;
    }
View Full Code Here

    @Path("/trusted")
    @ApiOperation(value = "Retrieve the list of buddies whose data we may have access to",
            response = GuestModel.class, responseContainer = "Array")
    @Produces({MediaType.APPLICATION_JSON})
    public List<GuestModel> getCoachees(){
        Guest guest = AuthHelper.getGuest();
        final List<Guest> coachees = buddiesService.getTrustedBuddies(guest.getId());
        final List<GuestModel> guestModels = toGuestModels(coachees);
        return guestModels;
    }
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.