com.ibm.openpages.ext.rest

Class BaseExtController

  • java.lang.Object
    • com.ibm.openpages.ext.rest.BaseExtController


  • public abstract class BaseExtController
    extends java.lang.Object
    Abstract base RestController class for custom REST service controllers to extend.

    Example getting the API IServiceFactory using getServiceFactory(HttpServletRequest):

     @RequestMapping(value = "hello", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
     @ResponseBody
     public String helloUser(Model model, HttpServletRequest request, HttpServletResponse response) throws Exception {
    
         // sample way to get the API ServiceFactor
         IServiceFactory factory = super.getServiceFactory(request);
         ISecurityService ss = factory.createSecurityService();
    
         IUser currentUser = ss.getCurrentUser();
         return "Hello " + currentUser.getFirstName();
     }
     

    Example getting SDK OpenpagesSession from the GRC API Context using getContext(HttpServletRequest)

     //sample way to get the SDK Session
     Context context = super.getContext(request);
     OpenpagesSession sdkSession = (OpenpagesSession) context.get(Context.SERVICE_SESSION);
     
    Since:
    8.0.0.2
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      Context getContext(HttpServletRequest request)
      Attempts to retrieve or initialize a new GRC API Context using the Http Request object.
      IServiceFactory getServiceFactory(HttpServletRequest request)
      Attempts to retrieve or initialize a new GRC API IServiceFactory using the Http Request object.
      org.slf4j.Logger getSimpleLogger(java.lang.Class clazz)
      Gets a SLF4J logger which can be used to log to aurora logging framework.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BaseExtController

        public BaseExtController()
    • Method Detail

      • getContext

        public Context getContext(HttpServletRequest request)
        Attempts to retrieve or initialize a new GRC API Context using the Http Request object. If a current session has been created and the request contains session id cookies, it will be returned.
        Parameters:
        request -
        Returns:
        Context for the current request user's session
      • getServiceFactory

        public IServiceFactory getServiceFactory(HttpServletRequest request)
        Attempts to retrieve or initialize a new GRC API IServiceFactory using the Http Request object. If a current session has been created and the request contains session id cookies, it will be returned.
        Parameters:
        request -
        Returns:
        IServiceFactory for the current request user's session
      • getSimpleLogger

        public org.slf4j.Logger getSimpleLogger(java.lang.Class clazz)
        Gets a SLF4J logger which can be used to log to aurora logging framework.
        Parameters:
        clazz - - class for your RestController
        Returns:
        Logger using the class name

Licensed Materials - Property of IBM
OpenPages with Watson (PID: 5725-D51)
© Copyright IBM Corporation 2013, 2020. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.