Uploaded image for project: 'Hippo CMS'
  1. Hippo CMS
  2. CMS-13188

Extract getting hold of CmsSessionContext into static helper method

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • 14.2.0, 100.2.0
    • site-toolkit
    • None
    • Quasar
    • Puma Sprint 231

    Description

      There are now two places that have something like:

      Object token = request.getAttribute(PREVIEW_ACCESS_TOKEN_REQUEST_ATTRIBUTE);
              if (token == null) {
                  final HttpSession session = request.getSession(false);
                  if (session == null) {
                      return null;
                  }
      
                  return CmsSessionContext.getContext(session);
              } else {
                  // token based rendering for preview
                  if (token instanceof AccessToken) {
                      return ((AccessToken) token).getCmsSessionContext();
                  } else {
                      throw new IllegalStateException(String.format("For attribute '%s' only an object of type '%s' " +
                              "is allowed", PREVIEW_ACCESS_TOKEN_REQUEST_ATTRIBUTE, AccessToken.class.getName()));
                  }
              }
      

      However, downstream projects will require similar checks to get hold of the session context. Hence we should create a static helper utility method for it

      Attachments

        Activity

          People

            Unassigned Unassigned
            aschrijvers Ard Schrijvers
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: