Ejemplo n.º 1
0
          public HandlerResult findHandlerResult(
              HttpServletRequest request, HttpServletResponse response) {
            User user = AuthFilter.getUser(request);
            HandlerResult result = new HandlerResult();

            if (isBlank(user)) {
              result.content = result.page = AppPageKeys.UnAuthenticatedLanding.getPage();
            } else {

              result.content = user;
              result.page = AppPageKeys.AuthenticatedHome.getPage();
            }
            result.stopHandlerChain = true;

            return result;
          }
Ejemplo n.º 2
0
          public HandlerResult findHandlerResult(
              HttpServletRequest request, HttpServletResponse response) {
            String servletPath = request.getServletPath();
            String[] pathParts = servletPath.split("/");
            String sportPath = pathParts.length > 2 ? pathParts[2] : null;

            HandlerResult result = new HandlerResult();
            Template template = Query.from(Template.class).where("name ~= ?", "Ranking").first();
            Ranking ranking = null;
            String sportAttribute = null;
            Sport sport = null;
            SportGender gender = null;

            if ("football".equals(sportPath)) {
              sportAttribute = "FOOTBALL-BOYS";
              sport = Sport.FOOTBALL;
              gender = SportGender.BOYS;
            } else if ("gbasketball".equals(sportPath)) {
              sportAttribute = "BASKETBALL-GIRLS";
              sport = Sport.BASKETBALL;
              gender = SportGender.GIRLS;
            } else if ("bbasketball".equals(sportPath)) {
              sportAttribute = "BASKETBALL-BOYS";
              sport = Sport.BASKETBALL;
              gender = SportGender.BOYS;
            } else if ("baseball".equals(sportPath)) {
              sportAttribute = "BASEBALL-BOYS";
              sport = Sport.BASEBALL;
              gender = SportGender.BOYS;
            } else if ("softball".equals(sportPath)) {
              sportAttribute = "SOFTBALL-GIRLS";
              sport = Sport.SOFTBALL;
              gender = SportGender.GIRLS;
            } else {
              sportAttribute = "FOOTBALL-BOYS";
              sport = Sport.FOOTBALL;
              gender = SportGender.BOYS;
            }

            ranking =
                Query.from(Ranking.class).where("sport = ? && gender = ?", sport, gender).first();
            result.page = template;
            result.content = ranking;
            request.setAttribute(MASSEY_SPORT_REQUEST_ATTRIBUTE, sportAttribute);

            result.stopHandlerChain = true;

            return result;
          }
Ejemplo n.º 3
0
          public HandlerResult findHandlerResult(
              HttpServletRequest request, HttpServletResponse response) {
            String servletPath = request.getServletPath();
            String[] pathParts = servletPath.split("/");
            String UsStateOrSportName = pathParts.length > 2 ? pathParts[2] : null;

            int sportPathIndex = 2;
            String sportName = pathParts.length > sportPathIndex ? pathParts[sportPathIndex] : null;
            int pathIndex = 2;

            String action = null;
            String usState = null;
            if ("state".equals(sportName)) {
              action = sportName;
              sportPathIndex++;
              usState = pathParts.length > sportPathIndex ? pathParts[sportPathIndex] : null;

              USState stateKey = null;
              if (!isBlank(usState)) {
                USState usStateEnum = null;
                try {
                  usStateEnum = USState.valueOf(usState.replaceAll(" ", "_").toUpperCase());
                } catch (Exception e) {
                  logger.debug("failed to get USState for " + usState, e);
                }
                if (isBlank(usStateEnum)) usStateEnum = USState.getEnumValueByString(usState);

                if (isBlank(usStateEnum)) usStateEnum = USState.getEnumValueByAbbreviation(usState);

                if (!isBlank(usStateEnum)) {
                  request.setAttribute(US_STATE_REQUEST_ATTRIBUTE, usStateEnum.getAbbreviation());
                }
              }

              sportPathIndex++;
              sportName = pathParts.length > sportPathIndex ? pathParts[sportPathIndex] : null;
            } else if ("playoffs".equals(sportName)) {
              action = sportName;
              sportPathIndex++;

              sportName = pathParts.length > sportPathIndex ? pathParts[sportPathIndex] : null;
            } else if ("ratings".equals(sportName)) {
              action = sportName;
              sportPathIndex++;

              sportName = pathParts.length > sportPathIndex ? pathParts[sportPathIndex] : null;
            }

            Sport sport = Sport.FOOTBALL;

            try {
              if (!isBlank(sportName)) sport = Sport.valueOf(sportName.toUpperCase());
            } catch (Exception e) {
              logger.debug("failed to get sport", e);
            }

            String levelName =
                pathParts.length > (sportPathIndex + 1) ? pathParts[(sportPathIndex + 1)] : null;
            String genderName =
                pathParts.length > (sportPathIndex + 2) ? pathParts[(sportPathIndex + 2)] : null;
            String seasonNumber =
                pathParts.length > (sportPathIndex + 3) ? pathParts[(sportPathIndex + 3)] : null;
            String schoolName =
                pathParts.length > (sportPathIndex + 4) ? pathParts[(sportPathIndex + 4)] : null;

            HandlerResult result = new HandlerResult();

            String sportAttribute = null;

            SportGender gender = SportGender.BOYS;
            if (!isBlank(genderName)) {
              gender = SportGender.valueOf(genderName.toUpperCase());
              sportAttribute = sportName.toUpperCase() + "-" + genderName.toUpperCase();
            }

            Content content = null;
            Page page = null;

            if (!isBlank(schoolName)) {
              School school = School.findSchoolByKey(schoolName);
              if (null != school) {

                Query<Team> teamQuery =
                    Query.from(Team.class)
                        .where(
                            "sport = ? && gender = ? && level = ? && school = ?",
                            sport,
                            gender,
                            SportLevel.VARSITY,
                            school);
                getDisplayQuery(teamQuery);

                Team team = teamQuery.first();
                if (null == team) {
                  content = school;
                  page = AppPageKeys.School.getPage();
                } else {
                  content = team;
                  page = AppPageKeys.Team.getPage();
                }
              }

            } else {
              Ranking ranking =
                  Query.from(Ranking.class).where("sport = ? && gender = ?", sport, gender).first();
              if (null == ranking) {
                ranking = Query.from(Ranking.class).first();
              }

              Template template = Query.from(Template.class).where("name ~= ?", "Ranking").first();

              content = ranking;
              page = template;
            }

            result.page = page;
            result.content = content;
            request.setAttribute(MASSEY_SPORT_REQUEST_ATTRIBUTE, sportAttribute);

            result.stopHandlerChain = true;

            return result;
          }
Ejemplo n.º 4
0
          public HandlerResult findHandlerResult(
              HttpServletRequest request, HttpServletResponse response) {
            String servletPath = request.getServletPath();
            String[] pathParts = servletPath.split("/");
            String schoolKey = pathParts.length > 2 ? pathParts[2] : null;
            String athleteKey = pathParts.length > 3 ? pathParts[3] : null;
            String unknownMarker = pathParts.length > 4 ? pathParts[4] : null;
            String sportName = pathParts.length > 5 ? pathParts[5] : null;
            String levelName = pathParts.length > 6 ? pathParts[6] : null;
            String genderName = pathParts.length > 7 ? pathParts[7] : null;
            HandlerResult result = new HandlerResult();
            School school = null;
            if (!isBlank(schoolKey)) {
              school = School.findSchoolByKey(schoolKey.toLowerCase());
            }

            if (isBlank(school)) {
              result.content = null;
              result.page = null;
              result.stopHandlerChain = false;
              result.stopFilterChain = false;

              return result;
            } else if (isBlank(athleteKey)) {
              result.content = school;
              result.page = AppPageKeys.School.getPage();
              result.stopHandlerChain = true;
              result.stopFilterChain = false;

              try {
                Sport sport = Sport.valueOf(sportName.toUpperCase());
                SportLevel level = SportLevel.valueOf(levelName.toUpperCase());
                SportGender gender = SportGender.valueOf(genderName.toUpperCase());

                Query<Team> teamQuery =
                    Query.from(Team.class)
                        .where(
                            "sport = ? && gender = ? && level = ? && school = ?",
                            sport,
                            gender,
                            level,
                            school);
                getDisplayQuery(teamQuery);

                Team team = teamQuery.first();

                if (null != team) {
                  result.content = team;
                  result.page = AppPageKeys.Team.getPage();
                }
              } catch (Exception e) {
                logger.debug("failed to get team from request: " + servletPath, e);
              }

              return result;

            } else {

              try {
                Athlete athlete = Athlete.findAthleteByKey(athleteKey);

                if (null != athlete) {
                  setSchool(request, school);
                  result.content = athlete;
                  result.page = AppPageKeys.Athlete.getPage();
                  result.stopHandlerChain = true;
                  result.stopFilterChain = false;
                }

                return result;
              } catch (Exception e) {
                logger.debug("failed to get athlete from school request: " + servletPath, e);
              }
            }

            return result;
          }