Java Code Examples for javax.portlet.ActionRequest#getPortletSession()

The following examples show how to use javax.portlet.ActionRequest#getPortletSession() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdapterPortlet.java    From Knowage-Server with GNU Affero General Public License v3.0 6 votes vote down vote up
public void processAction(
    ActionRequest request,
    ActionResponse response)
    throws PortletException, IOException {
   
	PortletTracer.info(Constants.NOME_MODULO, "AdapterPortlet", "action", "Invocato");
    // set into threadLocal variables the jsr 168 portlet object 
    PortletAccess.setPortletConfig(getPortletConfig());
    PortletAccess.setPortletRequest(request);
    PortletAccess.setPortletResponse(response);
    PortletSession portletSession = request.getPortletSession();
    portletSession.setAttribute("BrowserLocale", request.getLocale());
    
    
    processService(request, response);
}
 
Example 2
Source File: AbstractController.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public void handleActionRequest(ActionRequest request, ActionResponse response) throws Exception {
	// Delegate to PortletContentGenerator for checking and preparing.
	check(request, response);

	// Execute in synchronized block if required.
	if (this.synchronizeOnSession) {
		PortletSession session = request.getPortletSession(false);
		if (session != null) {
			Object mutex = PortletUtils.getSessionMutex(session);
			synchronized (mutex) {
				handleActionRequestInternal(request, response);
				return;
			}
		}
	}

	handleActionRequestInternal(request, response);
}
 
Example 3
Source File: FilterTests_PortletFilter_ApiActionFilter.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void processAction(ActionRequest portletReq, ActionResponse portletResp)
    throws PortletException, IOException {

  portletResp.setRenderParameters(portletReq.getParameterMap());
  long tid = Thread.currentThread().getId();
  portletReq.setAttribute(THREADID_ATTR, tid);

  StringWriter writer = new StringWriter();

  PortletSession ps = portletReq.getPortletSession();
  String msg =
      (String) ps.getAttribute(RESULT_ATTR_PREFIX + "FilterTests_PortletFilter_ApiActionFilter",
          APPLICATION_SCOPE);
  portletReq.getPortletSession().setAttribute(
      Constants.RESULT_ATTR_PREFIX + "FilterTests_PortletFilter_ApiActionFilter",
      msg + writer.toString(), APPLICATION_SCOPE);

}
 
Example 4
Source File: IMSBLTIPortlet.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public void processActionReset(String action,ActionRequest request, ActionResponse response)
throws PortletException, IOException {

	// TODO: Check Role
	log.debug("Removing preferences....");
	clearSession(request);
	PortletSession pSession = request.getPortletSession(true);
	PortletPreferences prefs = request.getPreferences();
	try {
		prefs.reset("sakai.descriptor");
		for (String element : fieldList) {
			prefs.reset("imsti."+element);
			prefs.reset("sakai:imsti."+element);
		}
		log.debug("Preference removed");
	} catch (ReadOnlyException e) {
		setErrorMessage(request, rb.getString("error.modify.prefs")) ;
		return;
	}
	prefs.store();

	// Go back to the main edit page
	pSession.setAttribute("sakai.view", "edit");
}
 
Example 5
Source File: URLTests_ActionURL.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@ActionMethod(portletName = "ActionURLTests")
public void processAction(ActionRequest portletReq,
      ActionResponse portletResp) throws PortletException, IOException {

   // evaluate results for test case
   // V3URLTests_ActionURL_setParameterB7
   {
      ModuleTestCaseDetails tcd = new ModuleTestCaseDetails();
      TestResult tr8 = tcd.getTestResultFailed(
          V3URLTESTS_ACTIONURL_SETPARAMETERB7);
      String tcval = portletReq.getParameter("tc");
      // let exception be thrown if tc parm isn't defined (test case error)
      if (tcval != null && tcval != null && tcval
          .equals("V3URLTests_ActionURL_setParameterB7")) {
         String[] aval = portletReq.getParameterValues("parm1");
         String[] eval = null;
         CompareUtils.arraysEqual("Request", aval, " expected: ", eval, tr8);
         PortletSession ps = portletReq.getPortletSession();
         ps.setAttribute(
             RESULT_ATTR_PREFIX
             + "V3URLTests_ActionURL_setParameterB7",
             tr8);
         portletResp.setRenderParameter("tc", tcval);
      }
   }
}
 
Example 6
Source File: RenderStateTests_SPEC2_12_MutableRenderState2.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void processAction(ActionRequest portletReq,
      ActionResponse portletResp) throws PortletException, IOException {
   
   ModuleTestCaseDetails tcd = new ModuleTestCaseDetails();
   StringWriter writer = new StringWriter();
   
   /*
    * TestCase:
    * V3RenderStateTests_SPEC2_12_MutableRenderState_getRenderParameters3
    */
   /*
    * Details:
    * "If no render parameters are available, the object will be empty."
    */
   TestResult result = tcd.getTestResultFailed(
         V3RENDERSTATETESTS_SPEC2_12_MUTABLERENDERSTATE_GETRENDERPARAMETERS3);
   if(portletResp.getRenderParameters().isEmpty()){
      result.setTcSuccess(true);
   }
   result.writeTo(writer);
   
   PortletSession ps = portletReq.getPortletSession();
   ps.setAttribute(Constants.RESULT_ATTR_PREFIX + "RenderStateTests_SPEC2_12_MutableRenderState2", writer.toString());
   
}
 
Example 7
Source File: IMSBLTIPortlet.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
public void processActionReset(String action,ActionRequest request, ActionResponse response)
throws PortletException, IOException {

	// TODO: Check Role
	log.debug("Removing preferences....");
	clearSession(request);
	PortletSession pSession = request.getPortletSession(true);
	PortletPreferences prefs = request.getPreferences();
	try {
		prefs.reset("sakai.descriptor");
		for (String element : fieldList) {
			prefs.reset("imsti."+element);
			prefs.reset("sakai:imsti."+element);
		}
		log.debug("Preference removed");
	} catch (ReadOnlyException e) {
		setErrorMessage(request, rb.getString("error.modify.prefs")) ;
		return;
	}
	prefs.store();

	// Go back to the main edit page
	pSession.setAttribute("sakai.view", "edit");
}
 
Example 8
Source File: SakaiIFrame.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {

	log.debug("==== processAction called ====");

	PortletSession pSession = request.getPortletSession(true);

	// Our first challenge is to figure out which action we want to take
	// The view selects the "next action" either as a URL parameter
	// or as a hidden field in the POST data - we check both

	String doCancel = request.getParameter("sakai.cancel");
	String doUpdate = request.getParameter("sakai.update");

	// Our next challenge is to pick which action the previous view
	// has told us to do.  Note that the view may place several actions
	// on the screen and the user may have an option to pick between
	// them.  Make sure we handle the "no action" fall-through.

	pSession.removeAttribute("error.message");

	if ( doCancel != null ) {
		response.setPortletMode(PortletMode.VIEW);
	} else if ( doUpdate != null ) {
		processActionEdit(request, response);
	} else {
		log.debug("Unknown action");
		response.setPortletMode(PortletMode.VIEW);
	}

	log.debug("==== End of ProcessAction  ====");
}
 
Example 9
Source File: FilterTests_FilterChain_ApiActionFilter.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public void processAction(ActionRequest portletReq, ActionResponse portletResp)
    throws PortletException, IOException {

  JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();

  portletResp.setRenderParameters(portletReq.getParameterMap());
  long tid = Thread.currentThread().getId();
  portletReq.setAttribute(THREADID_ATTR, tid);

  StringWriter writer = new StringWriter();

  /* TestCase: V2FilterTests_FilterChain_ApiActionFilter_invokeActionFilter2 */
  /* Details: "Invoking doFilter(ActionRequest, ActionResponse): causes */
  /* portlet action method to be invoked" */
  TestResult tr1 =
      tcd.getTestResultFailed(V2FILTERTESTS_FILTERCHAIN_APIACTIONFILTER_INVOKEACTIONFILTER2);
  if (FilterTests_FilterChain_ApiActionFilter_filter2.tr1_success) {
    tr1.setTcSuccess(true);
  }
  tr1.writeTo(writer);

  PortletSession ps = portletReq.getPortletSession();
  String msg =
      (String) ps.getAttribute(RESULT_ATTR_PREFIX + "FilterTests_FilterChain_ApiActionFilter",
          APPLICATION_SCOPE);
  portletReq.getPortletSession().setAttribute(
      Constants.RESULT_ATTR_PREFIX + "FilterTests_FilterChain_ApiActionFilter",
      msg + writer.toString(), APPLICATION_SCOPE);
}
 
Example 10
Source File: FilterTests_FilterChain_ApiActionFilter_filter2.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public void doFilter(ActionRequest portletReq, ActionResponse portletResp, FilterChain chain)
    throws IOException, PortletException {

  StringWriter writer = new StringWriter();

  // now do the tests and write output

  JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();

  // Create result objects for the tests

  /* TestCase: V2FilterTests_FilterChain_ApiActionFilter_invokeActionFilter */
  /* Details: "Invoking doFilter(ActionRequest, ActionResponse): causes */
  /* next filter to be invoked" */
  TestResult tr0 =
      tcd.getTestResultFailed(V2FILTERTESTS_FILTERCHAIN_APIACTIONFILTER_INVOKEACTIONFILTER);
  if (FilterTests_FilterChain_ApiActionFilter_filter.tr0_success) {
    tr0.setTcSuccess(true);
  }
  tr0.writeTo(writer);

  /* TestCase: V2FilterTests_FilterChain_ApiActionFilter_invokeActionFilter2 */
  /* Details: "Invoking doFilter(ActionRequest, ActionResponse): causes */
  /* portlet action method to be invoked" */
  FilterTests_FilterChain_ApiActionFilter_filter2.tr1_success = true;

  PortletSession ps = portletReq.getPortletSession();
  String msg =
      (String) ps.getAttribute(RESULT_ATTR_PREFIX + "FilterTests_FilterChain_ApiActionFilter",
          APPLICATION_SCOPE);
  portletReq.getPortletSession().setAttribute(
      Constants.RESULT_ATTR_PREFIX + "FilterTests_FilterChain_ApiActionFilter",
      msg + writer.toString(), APPLICATION_SCOPE);

  chain.doFilter(portletReq, portletResp);

}
 
Example 11
Source File: PortletIFrame.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {

	// log.info("==== processAction called ====");

	PortletSession pSession = request.getPortletSession(true);

	// Our first challenge is to figure out which action we want to take
	// The view selects the "next action" either as a URL parameter
	// or as a hidden field in the POST data - we check both

	String doCancel = request.getParameter("sakai.cancel");
	String doUpdate = request.getParameter("sakai.update");

	// Our next challenge is to pick which action the previous view
	// has told us to do.  Note that the view may place several actions
	// on the screen and the user may have an option to pick between
	// them.  Make sure we handle the "no action" fall-through.

	pSession.removeAttribute("error.message");

	if ( doCancel != null ) {
		response.setPortletMode(PortletMode.VIEW);
	} else if ( doUpdate != null ) {
		processActionEdit(request, response);
	} else {
		// log.info("Unknown action");
		response.setPortletMode(PortletMode.VIEW);
	}

	// log.info("==== End of ProcessAction  ====");
}
 
Example 12
Source File: AdapterPortlet.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException {

	PortletTracer.info(Constants.NOME_MODULO, "AdapterPortlet", "action", "Invocato");
	// set into threadLocal variables the jsr 168 portlet object
	PortletAccess.setPortletConfig(getPortletConfig());
	PortletAccess.setPortletRequest(request);
	PortletAccess.setPortletResponse(response);
	PortletSession portletSession = request.getPortletSession();
	portletSession.setAttribute("BrowserLocale", request.getLocale());

	processService(request, response);
}
 
Example 13
Source File: IMSBLTIPortlet.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {

	log.debug("==== processAction called ====");

	String action = request.getParameter("sakai.action");
	log.debug("sakai.action = {}", action);

	PortletSession pSession = request.getPortletSession(true);

	// Clear before Action
	clearErrorMessage(request);

	String view = (String) pSession.getAttribute("sakai.view");
	log.debug("sakai.view={}", view);

	if ( action == null ) {
		// Do nothing
	} else if ( action.equals("main") ) {
		response.setPortletMode(PortletMode.VIEW);
	} else if ( action.equals("edit") ) {
		pSession.setAttribute("sakai.view", "edit");
	} else if ( action.equals("edit.reset") ) {
		pSession.setAttribute("sakai.view","edit.reset");
	} else if (action.equals("edit.setup")){
		pSession.setAttribute("sakai.view","edit.setup");
	} else if ( action.equals("edit.clear") ) {
		clearSession(request);
		response.setPortletMode(PortletMode.VIEW);
		pSession.setAttribute("sakai.view", "main");
	} else if ( action.equals("edit.do.reset") ) {
		processActionReset(action,request, response);
	} else if ( action.equals("edit.save") ) {
		processActionSave(action,request, response);
	}
	log.debug("==== End of ProcessAction ====");
}
 
Example 14
Source File: SakaiIFrame.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {

	log.debug("==== processAction called ====");

	PortletSession pSession = request.getPortletSession(true);

	// Our first challenge is to figure out which action we want to take
	// The view selects the "next action" either as a URL parameter
	// or as a hidden field in the POST data - we check both

	String doCancel = request.getParameter("sakai.cancel");
	String doUpdate = request.getParameter("sakai.update");

	// Our next challenge is to pick which action the previous view
	// has told us to do.  Note that the view may place several actions
	// on the screen and the user may have an option to pick between
	// them.  Make sure we handle the "no action" fall-through.

	pSession.removeAttribute("error.message");

	if ( doCancel != null ) {
		response.setPortletMode(PortletMode.VIEW);
	} else if ( doUpdate != null ) {
		processActionEdit(request, response);
	} else {
		log.debug("Unknown action");
		response.setPortletMode(PortletMode.VIEW);
	}

	log.debug("==== End of ProcessAction  ====");
}
 
Example 15
Source File: PortletIFrame.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {

	// log.info("==== processAction called ====");

	PortletSession pSession = request.getPortletSession(true);

	// Our first challenge is to figure out which action we want to take
	// The view selects the "next action" either as a URL parameter
	// or as a hidden field in the POST data - we check both

	String doCancel = request.getParameter("sakai.cancel");
	String doUpdate = request.getParameter("sakai.update");

	// Our next challenge is to pick which action the previous view
	// has told us to do.  Note that the view may place several actions
	// on the screen and the user may have an option to pick between
	// them.  Make sure we handle the "no action" fall-through.

	pSession.removeAttribute("error.message");

	if ( doCancel != null ) {
		response.setPortletMode(PortletMode.VIEW);
	} else if ( doUpdate != null ) {
		processActionEdit(request, response);
	} else {
		// log.info("Unknown action");
		response.setPortletMode(PortletMode.VIEW);
	}

	// log.info("==== End of ProcessAction  ====");
}
 
Example 16
Source File: AdapterPortlet.java    From Knowage-Server with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException {

	PortletTracer.info(Constants.NOME_MODULO, "AdapterPortlet", "action", "Invocato");
	// set into threadLocal variables the jsr 168 portlet object
	PortletAccess.setPortletConfig(getPortletConfig());
	PortletAccess.setPortletRequest(request);
	PortletAccess.setPortletResponse(response);
	PortletSession portletSession = request.getPortletSession();
	portletSession.setAttribute("BrowserLocale", request.getLocale());

	processService(request, response);
}
 
Example 17
Source File: FilterTests_ActionFilter_ApiActionFilter_filter2.java    From portals-pluto with Apache License 2.0 4 votes vote down vote up
@Override
public void doFilter(ActionRequest portletReq, ActionResponse portletResp, FilterChain chain)
    throws IOException, PortletException {

  StringWriter writer = new StringWriter();

  // now do the tests and write output

  JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();

  // Create result objects for the tests

  /* TestCase: V2FilterTests_ActionFilter_ApiActionFilter_canBeConfigured2 */
  /* Details: "Multiple ActionFilter classes can be configured in the */
  /* portlet descriptor" */
  TestResult tr1 =
      tcd.getTestResultFailed(V2FILTERTESTS_ACTIONFILTER_APIACTIONFILTER_CANBECONFIGURED2);
  tr1.setTcSuccess(true);
  tr1.writeTo(writer);

  /* TestCase: V2FilterTests_ActionFilter_ApiActionFilter_doFilterIsCalled */
  /* Details: "The doFilter(ActionRequest, ActionResponse, */
  /* FilterChain): method is called before the processAction method for */
  /* the portlet" */
  tr2_success = true;

  /* TestCase: V2FilterTests_ActionFilter_ApiActionFilter_doFilterProcessAction1 */
  /* Details: "After the doFilter(ActionRequest, ActionResponse, */
  /* FilterChain): method has successfully completed and invokes the */
  /* next filter, the processActionMethod is called" */
  tr3_success = true;

  /* TestCase: V2FilterTests_ActionFilter_ApiActionFilter_doFilterProcessAction2 */
  /* Details: "After the doFilter(ActionRequest, ActionResponse, */
  /* FilterChain): method has successfully completed and invokes the */
  /* next filter, the next filter in the chain is called if multiple */
  /* filters are defined" */
  TestResult tr4 =
      tcd.getTestResultFailed(V2FILTERTESTS_ACTIONFILTER_APIACTIONFILTER_DOFILTERPROCESSACTION2);
  if (FilterTests_ActionFilter_ApiActionFilter_filter.tr4_success) {
    tr4.setTcSuccess(true);
  }
  tr4.writeTo(writer);

  PortletSession ps = portletReq.getPortletSession();
  String msg =
      (String) ps.getAttribute(RESULT_ATTR_PREFIX + "FilterTests_ActionFilter_ApiActionFilter",
          APPLICATION_SCOPE);
  portletReq.getPortletSession().setAttribute(
      RESULT_ATTR_PREFIX + "FilterTests_ActionFilter_ApiActionFilter", msg + writer.toString(),
      APPLICATION_SCOPE);

  chain.doFilter(portletReq, portletResp);
}
 
Example 18
Source File: SakaiIFrame.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
private void addAlert(ActionRequest request,String message) {
	PortletSession pSession = request.getPortletSession(true);
	pSession.setAttribute(ALERT_MESSAGE, message);
}
 
Example 19
Source File: FilterTests_ActionFilter_ApiActionFilter.java    From portals-pluto with Apache License 2.0 4 votes vote down vote up
@Override
public void processAction(ActionRequest portletReq, ActionResponse portletResp)
    throws PortletException, IOException {

  JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();

  portletResp.setRenderParameters(portletReq.getParameterMap());
  long tid = Thread.currentThread().getId();
  portletReq.setAttribute(THREADID_ATTR, tid);

  StringWriter writer = new StringWriter();

  /* TestCase: V2FilterTests_ActionFilter_ApiActionFilter_doFilterIsCalled */
  /* Details: "The doFilter(ActionRequest, ActionResponse, */
  /* FilterChain): method is called before the processAction method for */
  /* the portlet" */
  TestResult tr2 =
      tcd.getTestResultFailed(V2FILTERTESTS_ACTIONFILTER_APIACTIONFILTER_DOFILTERISCALLED);
  if (FilterTests_ActionFilter_ApiActionFilter_filter2.tr2_success) {
    tr2.setTcSuccess(true);
  }
  tr2.writeTo(writer);

  /* TestCase: V2FilterTests_ActionFilter_ApiActionFilter_doFilterProcessAction1 */
  /* Details: "After the doFilter(ActionRequest, ActionResponse, */
  /* FilterChain): method has successfully completed and invokes the */
  /* next filter, the processActionMethod is called" */
  TestResult tr3 =
      tcd.getTestResultFailed(V2FILTERTESTS_ACTIONFILTER_APIACTIONFILTER_DOFILTERPROCESSACTION1);
  if (FilterTests_ActionFilter_ApiActionFilter_filter2.tr3_success) {
    tr3.setTcSuccess(true);
  }
  tr3.writeTo(writer);

  PortletSession ps = portletReq.getPortletSession();
  String msg =
      (String) ps.getAttribute(RESULT_ATTR_PREFIX + "FilterTests_ActionFilter_ApiActionFilter",
          APPLICATION_SCOPE);
  portletReq.getPortletSession().setAttribute(
      Constants.RESULT_ATTR_PREFIX + "FilterTests_ActionFilter_ApiActionFilter",
      msg + writer.toString(), APPLICATION_SCOPE);

}
 
Example 20
Source File: PortletIFrame.java    From sakai with Educational Community License v2.0 4 votes vote down vote up
private void addAlert(ActionRequest request,String message) {
	PortletSession pSession = request.getPortletSession(true);
	pSession.setAttribute(ALERT_MESSAGE, message);
}