Java Code Examples for javax.portlet.RenderRequest#setAttribute()

The following examples show how to use javax.portlet.RenderRequest#setAttribute() . 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: DispatcherTests4_SPEC2_19_ForwardServletRender.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {

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

   portletResp.getWriter();

   // Prereq for: V2DispatcherTests4_SPEC2_19_ForwardServletRender_invoke3
   portletReq = new RenderRequestWrapper(portletReq);
   portletResp = new RenderResponseWrapper(portletResp);

   // Now do the actual dispatch
   String target = SERVLET_PREFIX + "DispatcherTests4_SPEC2_19_ForwardServletRender_servlet" + SERVLET_SUFFIX + "?"
         + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext().getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);
}
 
Example 2
Source File: DispatcherTests5_SPEC2_19_IncThenForwardServletRender.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {

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

   portletResp.getWriter();

   // Multilevel forward / include
   portletReq.setAttribute(ATTR_DISPATCH_ACTION, "forward");
   String targ = SERVLET_PREFIX + "DispatcherTests5_SPEC2_19_IncThenForwardServletRender_servlet" + EXTRA_PATH + "?"
         + QUERY_STRING;
   portletReq.setAttribute(ATTR_DISPATCH_TARGET, targ);

   // Now do the actual dispatch
   String target = SERVLET_INCFWD + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext().getRequestDispatcher(target);
   rd.include(portletReq, portletResp);
}
 
Example 3
Source File: AddlRequestTests_SPEC2_11_ResourceReq.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
    throws PortletException, IOException {

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

  PrintWriter writer = portletResp.getWriter();

  writer.write("<div id=\"AddlRequestTests_SPEC2_11_ResourceReq\">no resource output.</div>\n");
  ResourceURL resurl = portletResp.createResourceURL();
  resurl.setCacheability(PAGE);
  writer.write("<script>\n");
  writer.write("(function () {\n");
  writer.write("   var xhr = new XMLHttpRequest();\n");
  writer.write("   xhr.onreadystatechange=function() {\n");
  writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
  writer.write(
      "         document.getElementById(\"AddlRequestTests_SPEC2_11_ResourceReq\").innerHTML=xhr.responseText;\n");
  writer.write("      }\n");
  writer.write("   };\n");
  writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
  writer.write("   xhr.send();\n");
  writer.write("})();\n");
  writer.write("</script>\n");
}
 
Example 4
Source File: DispatcherTests4_SPEC2_19_ForwardJSPResource.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {

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

   PrintWriter writer = portletResp.getWriter();

   writer.write("<div id=\"DispatcherTests4_SPEC2_19_ForwardJSPResource\">no resource output.</div>\n");
   ResourceURL resurl = portletResp.createResourceURL();
   resurl.setCacheability(PAGE);
   writer.write("<script>\n");
   writer.write("(function () {\n");
   writer.write("   var xhr = new XMLHttpRequest();\n");
   writer.write("   xhr.onreadystatechange=function() {\n");
   writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
   writer.write("         document.getElementById(\"DispatcherTests4_SPEC2_19_ForwardJSPResource\").innerHTML=xhr.responseText;\n");
   writer.write("      }\n");
   writer.write("   };\n");
   writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
   writer.write("   xhr.send();\n");
   writer.write("})();\n");
   writer.write("</script>\n");
}
 
Example 5
Source File: DispatcherReqRespTests4_SPEC2_19_IncludeServletRenderRequest.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {

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

   // Prereq for: V2DispatcherReqRespTests4_SPEC2_19_IncludeServletRenderRequest_getAttribute
   portletReq.setAttribute(ATTR_PREFIX +"V2DispatcherReqRespTests4_SPEC2_19_IncludeServletRenderRequest_getAttribute", "Value1");

   // Prereq for: V2DispatcherReqRespTests4_SPEC2_19_IncludeServletRenderRequest_getAttributeNames
   portletReq.setAttribute(ATTR_PREFIX + "V2DispatcherReqRespTests4_SPEC2_19_IncludeServletRenderRequest_getAttributeNames", "Value1");

   // Now do the actual dispatch
   String target = SERVLET_PREFIX + "DispatcherReqRespTests4_SPEC2_19_IncludeServletRenderRequest_servlet" + SERVLET_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.include(portletReq, portletResp);
}
 
Example 6
Source File: DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {

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

   // Prereq for: V2DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest_getAttribute
   portletReq.setAttribute(ATTR_PREFIX +"V2DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest_getAttribute", "Value1");

   // Prereq for: V2DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest_getAttributeNames
   portletReq.setAttribute(ATTR_PREFIX + "V2DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest_getAttributeNames", "Value1");

   // Now do the actual dispatch
   String target = SERVLET_PREFIX + "DispatcherReqRespTests2_SPEC2_19_ForwardServletRenderRequest_servlet" + SERVLET_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);
}
 
Example 7
Source File: RequestTests_ResourceRequest_ApiResource.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {
   LOGGER.trace("main portlet render entry");

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

   PrintWriter writer = portletResp.getWriter();

   writer.write("<div id=\"RequestTests_ResourceRequest_ApiResource\">no resource output.</div>\n");
   ResourceURL resurl = portletResp.createResourceURL();
   resurl.setCacheability(PAGE);
   writer.write("<script>\n");
   writer.write("(function () {\n");
   writer.write("   var xhr = new XMLHttpRequest();\n");
   writer.write("   xhr.onreadystatechange=function() {\n");
   writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
   writer.write("         document.getElementById(\"RequestTests_ResourceRequest_ApiResource\").innerHTML=xhr.responseText;\n");
   writer.write("      }\n");
   writer.write("   };\n");
   writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
   writer.write("   xhr.send();\n");
   writer.write("})();\n");
   writer.write("</script>\n");
}
 
Example 8
Source File: DispatcherReqRespTests5S_SPEC2_19_ForwardJSPResourceRequest.java    From portals-pluto with Apache License 2.0 6 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {

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

   PrintWriter writer = portletResp.getWriter();

   writer.write("<div id=\"DispatcherReqRespTests5S_SPEC2_19_ForwardJSPResourceRequest\">no resource output.</div>\n");
   ResourceURL resurl = portletResp.createResourceURL();
   resurl.setCacheability(PAGE);
   writer.write("<script>\n");
   writer.write("(function () {\n");
   writer.write("   var xhr = new XMLHttpRequest();\n");
   writer.write("   xhr.onreadystatechange=function() {\n");
   writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
   writer.write("         document.getElementById(\"DispatcherReqRespTests5S_SPEC2_19_ForwardJSPResourceRequest\").innerHTML=xhr.responseText;\n");
   writer.write("      }\n");
   writer.write("   };\n");
   writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
   writer.write("   xhr.send();\n");
   writer.write("})();\n");
   writer.write("</script>\n");
}
 
Example 9
Source File: SigTestsResource_ClientDataRequest_SIGResource.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
    throws PortletException, IOException {

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

  PrintWriter writer = portletResp.getWriter();

  writer.write(
      "<div id=\"SigTestsResource_ClientDataRequest_SIGResource\">no resource output.</div>\n");
  ResourceURL resurl = portletResp.createResourceURL();
  resurl.setCacheability(PAGE);
  writer.write("<script>\n");
  writer.write("(function () {\n");
  writer.write("   var xhr = new XMLHttpRequest();\n");
  writer.write("   xhr.onreadystatechange=function() {\n");
  writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
  writer.write(
      "         document.getElementById(\"SigTestsResource_ClientDataRequest_SIGResource\").innerHTML=xhr.responseText;\n");
  writer.write("      }\n");
  writer.write("   };\n");
  writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
  writer.write("   xhr.send();\n");
  writer.write("})();\n");
  writer.write("</script>\n");
}
 
Example 10
Source File: AddlEnvironmentTests_SPEC2_17_ResourcePreferences.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
    throws PortletException, IOException {

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

  PrintWriter writer = portletResp.getWriter();

  writer.write(
      "<div id=\"AddlEnvironmentTests_SPEC2_17_ResourcePreferences\">no resource output.</div>\n");
  ResourceURL resurl = portletResp.createResourceURL();
  resurl.setCacheability(PAGE);
  writer.write("<script>\n");
  writer.write("(function () {\n");
  writer.write("   var xhr = new XMLHttpRequest();\n");
  writer.write("   xhr.onreadystatechange=function() {\n");
  writer.write("      if (xhr.readyState==4 && xhr.status==200) {\n");
  writer.write(
      "         document.getElementById(\"AddlEnvironmentTests_SPEC2_17_ResourcePreferences\").innerHTML=xhr.responseText;\n");
  writer.write("      }\n");
  writer.write("   };\n");
  writer.write("   xhr.open(\"GET\",\"" + resurl.toString() + "\",true);\n");
  writer.write("   xhr.send();\n");
  writer.write("})();\n");
  writer.write("</script>\n");
}
 
Example 11
Source File: DispatcherTests2_SPEC2_19_ForwardJSPRender.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {

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

   portletResp.getWriter();

   // Now do the actual dispatch
   String target = JSP_PREFIX + "DispatcherTests2_SPEC2_19_ForwardJSPRender" + JSP_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext().getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);
}
 
Example 12
Source File: SimpleRSSPortlet.java    From sakai with Educational Community License v2.0 5 votes vote down vote up
/**
 * Custom mode handler for EDIT view
 */
protected void doEdit(RenderRequest request, RenderResponse response) throws PortletException, IOException {
	log.debug("Simple RSS doEdit()");

	//if we have an error message, replay the form
	String errorMessage = request.getParameter("errorMessage");

	if(StringUtils.isNotBlank(errorMessage)) {
		//PORT-672 replay data from the request so it is preserved
		request.setAttribute("portletTitle", request.getParameter("portletTitle"));
		request.setAttribute("feedUrl", request.getParameter("feedUrl"));
		request.setAttribute("maxItems", request.getParameter("maxItems"));
	} else {
		//get it from the preferences
		request.setAttribute("portletTitle", getConfiguredPortletTitle(request));
		request.setAttribute("feedUrl", getConfiguredFeedUrl(request));
		request.setAttribute("maxItems", getConfiguredMaxItems(request));
	}

	//check permissions
	request.setAttribute("feedUrlIsLocked", isPrefLocked(request, PREF_FEED_URL));
	request.setAttribute("portletTitleIsLocked", isPrefLocked(request, PREF_PORTLET_TITLE));

	//cancel url
	request.setAttribute("cancelUrl", getPortletModeUrl(response, PortletMode.VIEW));
	
	//get any error message that is in the request and pass it on
	request.setAttribute("errorMessage", request.getParameter("errorMessage"));
	
	dispatch(request, response, editUrl);
}
 
Example 13
Source File: DispatcherReqRespTests1_SPEC2_19_ForwardJSPRenderResponse.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {

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

   // Now do the actual dispatch
   String target = JSP_PREFIX + "DispatcherReqRespTests1_SPEC2_19_ForwardJSPRenderResponse" + JSP_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.forward(portletReq, portletResp);
}
 
Example 14
Source File: DispatcherTests4_SPEC2_19_ForwardJSPAction.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp) throws PortletException, IOException {

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

   PrintWriter writer = portletResp.getWriter();

   PortletSession ps = portletReq.getPortletSession();
   String msg = (String) ps.getAttribute(RESULT_ATTR_PREFIX + "DispatcherTests4_SPEC2_19_ForwardJSPAction",
         APPLICATION_SCOPE);
   if (msg != null) {
      writer.write("<p>" + msg + "</p><br/>\n");
      ps.removeAttribute(RESULT_ATTR_PREFIX + "DispatcherTests4_SPEC2_19_ForwardJSPAction", APPLICATION_SCOPE);
   }

   /* TestCase: V2DispatcherTests4_SPEC2_19_ForwardJSPAction_invoke3 */
   /* Details: "Parameters to the forward method for a target servlet */
   /* can be wrapped request and response classes from the portlet */
   /* lifecyle method initiating the include" */
   {
      PortletURL aurl = portletResp.createActionURL();
      aurl.setParameters(portletReq.getPrivateParameterMap());
      TestButton tb = new TestButton(V2DISPATCHERTESTS4_SPEC2_19_FORWARDJSPACTION_INVOKE3, aurl);
      tb.writeTo(writer);
   }

}
 
Example 15
Source File: FilterTests_RenderFilter_ApiRenderFilter.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
    throws PortletException, IOException {

  JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();

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

  PrintWriter writer = portletResp.getWriter();
  /* TestCase: V2FilterTests_RenderFilter_ApiRenderFilter_doFilterIsCalled */
  /* Details: "The doFilter(RenderRequest, RenderResponse, */
  /* FilterChain): method is called before the processRender method for */
  /* the portlet" */
  TestResult tr2 =
      tcd.getTestResultFailed(V2FILTERTESTS_RENDERFILTER_APIRENDERFILTER_DOFILTERISCALLED);
  if (FilterTests_RenderFilter_ApiRenderFilter_filter2.tr2_success) {
    tr2.setTcSuccess(true);
  }
  tr2.writeTo(writer);

  /* TestCase: V2FilterTests_RenderFilter_ApiRenderFilter_doFilterProcessRender1 */
  /* Details: "After the doFilter(RenderRequest, RenderResponse, */
  /* FilterChain): method has sucessfully completed and invokes the */
  /* next filter, the processRenderMethod is called" */
  TestResult tr3 =
      tcd.getTestResultFailed(V2FILTERTESTS_RENDERFILTER_APIRENDERFILTER_DOFILTERPROCESSRENDER1);
  if (FilterTests_RenderFilter_ApiRenderFilter_filter2.tr3_success) {
    tr3.setTcSuccess(true);
  }
  tr3.writeTo(writer);

}
 
Example 16
Source File: DispatcherReqRespTests4_SPEC2_19_IncludeServletRenderResponse.java    From portals-pluto with Apache License 2.0 5 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
      throws PortletException, IOException {

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

   // Now do the actual dispatch
   String target = SERVLET_PREFIX + "DispatcherReqRespTests4_SPEC2_19_IncludeServletRenderResponse_servlet" + SERVLET_SUFFIX + "?" + QUERY_STRING;
   PortletRequestDispatcher rd = portletConfig.getPortletContext()
         .getRequestDispatcher(target);
   rd.include(portletReq, portletResp);
}
 
Example 17
Source File: ProfilePorlet.java    From opencps-v2 with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void render(
	RenderRequest renderRequest, RenderResponse renderResponse)
	throws IOException, PortletException {

	ThemeDisplay themeDisplay =
		(ThemeDisplay) renderRequest.getAttribute(WebKeys.THEME_DISPLAY);

	JSONObject urlObject = JSONFactoryUtil.createJSONObject();
	JSONObject apiObject = JSONFactoryUtil.createJSONObject();

	try {
		Applicant applicant = UserMgtUtils.getApplicant(
			themeDisplay.getUser().getEmailAddress());
		
		Employee employee = EmployeeLocalServiceUtil.fetchByF_mappingUserId( themeDisplay.getScopeGroupId(), themeDisplay.getUserId());
		String layoutFriendlyUrl = themeDisplay.getScopeGroup().getFriendlyURL();
		_log.info("layoutFriendlyUrl=======" + layoutFriendlyUrl);
		renderRequest.setAttribute("layoutFriendlyUrl", layoutFriendlyUrl);
		if(employee != null){
			JSONObject employeeObj;
			String employeeStr = JSONFactoryUtil.looseSerialize(employee);
			employeeObj = JSONFactoryUtil.createJSONObject(employeeStr);
			_log.info("employee===========>"+employeeObj);
			renderRequest.setAttribute("employee", employeeObj);
			renderRequest.setAttribute("userType", "employee");
		}else {
			
			renderRequest.setAttribute("userType", "applicant");
			JSONObject applicantObj;
			String jsonObj = JSONFactoryUtil.looseSerialize(applicant);
			applicantObj = JSONFactoryUtil.createJSONObject(jsonObj);
			if(applicantObj != null){
				renderRequest.setAttribute("applicant", applicantObj);
				renderRequest.setAttribute("applicantIdType", applicantObj.get("applicantIdType").toString());
				_log.info("applicantIdType===========>"+applicantObj.get("applicantIdType").toString());
			}
		}
		
		
	}
	catch (Exception e) {
		_log.error(e);
		_log.info(e.getMessage());
	}
	
	long userId = themeDisplay.getUser().getUserId();

	// api
	apiObject.put("server", themeDisplay.getPortalURL() + "/o/rest/v2");
	apiObject.put(
		"portletNamespace",
		themeDisplay.getPortletDisplay().getNamespace());

	// set varible
	renderRequest.setAttribute("ajax", urlObject);
	renderRequest.setAttribute("api", apiObject);
	renderRequest.setAttribute("userId", userId);

	super.render(renderRequest, renderResponse);

}
 
Example 18
Source File: ExceptionTests_ValidatorException_ApiRender.java    From portals-pluto with Apache License 2.0 4 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
    throws PortletException, IOException {

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

  PrintWriter writer = portletResp.getWriter();

  JSR286ApiTestCaseDetails tcd = new JSR286ApiTestCaseDetails();

  // Create result objects for the tests

  /* TestCase: V2ExceptionTests_ValidatorException_ApiRender_constructor2 */
  /* Details: "For ValidatorException(java.lang.String, */
  /* java.util.Collection&lt;java.lang.String&gt;), the failedKeys */
  /* parameter may be null" */
  TestResult tr0 =
      tcd.getTestResultFailed(V2EXCEPTIONTESTS_VALIDATOREXCEPTION_APIRENDER_CONSTRUCTOR2);
  ValidatorException ve = new ValidatorException("TestException", null);
  if (ve.getMessage().equals("TestException")) {
    tr0.setTcSuccess(true);
  }
  tr0.writeTo(writer);

  /* TestCase: V2ExceptionTests_ValidatorException_ApiRender_constructor4 */
  /* Details: "For ValidatorException(java.lang.String, */
  /* java.lang.Throwable, */
  /* java.util.Collection&lt;java.lang.String&gt;), the failedKeys */
  /* parameter may be null" */
  TestResult tr1 =
      tcd.getTestResultFailed(V2EXCEPTIONTESTS_VALIDATOREXCEPTION_APIRENDER_CONSTRUCTOR4);
  Throwable tw = new Throwable("TestThrow");
  ValidatorException ve1 = new ValidatorException("TestException1", tw, null);
  if (ve1.getMessage().equals("TestException1")) {
    tr1.setTcSuccess(true);
  }
  tr1.writeTo(writer);

  /* TestCase: V2ExceptionTests_ValidatorException_ApiRender_constructor6 */
  /* Details: "For ValidatorException(java.lang.Throwable, */
  /* java.util.Collection&lt;java.lang.String&gt;), the failedKeys */
  /* parameter may be null" */
  TestResult tr2 =
      tcd.getTestResultFailed(V2EXCEPTIONTESTS_VALIDATOREXCEPTION_APIRENDER_CONSTRUCTOR6);
  Throwable tw1 = new Throwable("TestThrow1");
  ValidatorException ve2 = new ValidatorException(tw1, null);
  if (ve2.getMessage().contains("TestThrow1")) {
    tr2.setTcSuccess(true);
  }
  tr2.writeTo(writer);

  /* TestCase: V2ExceptionTests_ValidatorException_ApiRender_getFailedKeys1 */
  /* Details: "Method getFailedKeys(): Returns a */
  /* java.util.Enumeration&lt;java.lang.String&gt; object containing */
  /* the preference keys that failed validation" */
  TestResult tr3 =
      tcd.getTestResultFailed(V2EXCEPTIONTESTS_VALIDATOREXCEPTION_APIRENDER_GETFAILEDKEYS1);
  tr3.setTcSuccess(true);
  tr3.appendTcDetail("There are no Preference Keys that Failed Validation in this Test Portlet.");
  tr3.writeTo(writer);

  /* TestCase: V2ExceptionTests_ValidatorException_ApiRender_getFailedKeys2 */
  /* Details: "Method getFailedKeys(): Returns an empty enmueration if */
  /* no failed keys are available" */
  TestResult tr4 =
      tcd.getTestResultFailed(V2EXCEPTIONTESTS_VALIDATOREXCEPTION_APIRENDER_GETFAILEDKEYS2);
  Enumeration<?> eu = ve1.getFailedKeys();
  List<?> li = Collections.list(eu);
  if (li.isEmpty()) {
    tr4.setTcSuccess(true);
  }
  tr4.writeTo(writer);
}
 
Example 19
Source File: AddlEnvironmentTests_SPEC2_17_RenderPreferences.java    From portals-pluto with Apache License 2.0 4 votes vote down vote up
@Override
public void render(RenderRequest portletReq, RenderResponse portletResp)
    throws PortletException, IOException {

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

  PrintWriter writer = portletResp.getWriter();

  JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails();

  PortletPreferences portletPrefs = portletReq.getPreferences();

  // Create result objects for the tests

  /* TestCase: V2AddlEnvironmentTests_SPEC2_17_RenderPreferences_deployment1 */
  /* Details: "The portlet definition may define the preference */
  /* attributes a portlet uses" */
  TestResult tr0 =
      tcd.getTestResultFailed(V2ADDLENVIRONMENTTESTS_SPEC2_17_RENDERPREFERENCES_DEPLOYMENT1);
  try {
    portletPrefs.setValue("tr0", "true");
    tr0.setTcSuccess(true);
  } catch (ReadOnlyException e) {
    tr0.appendTcDetail(e.toString());
  }
  tr0.writeTo(writer);

  /* TestCase: V2AddlEnvironmentTests_SPEC2_17_RenderPreferences_deployment2 */
  /* Details: "A preference attribute definition may include initial */
  /* default values" */
  TestResult tr1 =
      tcd.getTestResultFailed(V2ADDLENVIRONMENTTESTS_SPEC2_17_RENDERPREFERENCES_DEPLOYMENT2);
  if (portletPrefs.getValue("tr1", null).equals("true")) {
    tr1.setTcSuccess(true);
  } else {
    tr1.appendTcDetail(
        "Failed because tr1 default value is not true but " + portletPrefs.getValue("tr1", null));
  }
  tr1.writeTo(writer);

}
 
Example 20
Source File: EnvironmentTests_PortletRequestDispatcher_ApiRender.java    From portals-pluto with Apache License 2.0 4 votes vote down vote up
@Override
public void render(RenderRequest renderReq, RenderResponse renderResp)
    throws PortletException, IOException {

  long tid = Thread.currentThread().getId();
  renderReq.setAttribute(THREADID_ATTR, tid);

  PrintWriter writer = renderResp.getWriter();

  PortletSession ps = renderReq.getPortletSession();
  String msg = (String) ps.getAttribute(
      RESULT_ATTR_PREFIX + "V2EnvironmentTests_PortletRequestDispatcher_ApiRender_forward1",
      APPLICATION_SCOPE);
  if (msg != null) {
    writer.write("<p>" + msg + "</p><br/>\n");
    ps.removeAttribute(
        RESULT_ATTR_PREFIX + "V2EnvironmentTests_PortletRequestDispatcher_ApiRender_forward1",
        APPLICATION_SCOPE);
  }

  // Create result objects for the tests

  PortletRequest portletReq = renderReq;
  PortletResponse portletResp = renderResp;

  /* TestCase: V2EnvironmentTests_PortletRequestDispatcher_ApiRender_includeA1 */
  /* Details: "Method include(PortletRequest, PortletResponse): */
  /* Includes the content of a JSP page in the response" */
  String target_tr0 =
      JSP_PREFIX + "V2EnvironmentTests_PortletRequestDispatcher_ApiRender_includeA1" + JSP_SUFFIX
          + "?" + QUERY_STRING;
  PortletRequestDispatcher rd_tr0 =
      portletConfig.getPortletContext().getRequestDispatcher(target_tr0);
  rd_tr0.include(portletReq, portletResp);

  /* TestCase: V2EnvironmentTests_PortletRequestDispatcher_ApiRender_includeA2 */
  /* Details: "Method include(PortletRequest, PortletResponse): */
  /* Includes the content of a HTML Page in the response" */
  String target_tr1 = HTML_PREFIX
      + "V2EnvironmentTests_PortletRequestDispatcher_ApiRender_includeA2" + HTML_SUFFIX;
  PortletRequestDispatcher rd_tr1 =
      portletConfig.getPortletContext().getRequestDispatcher(target_tr1);
  rd_tr1.include(portletReq, portletResp);

  /* TestCase: V2EnvironmentTests_PortletRequestDispatcher_ApiRender_includeA3 */
  /* Details: "Method include(PortletRequest, PortletResponse): The */
  /* included servlet cannot change the status code. The attempt is */
  /* ignored" */
  String target_tr2 = SERVLET_PREFIX
      + "V2EnvironmentTests_PortletRequestDispatcher_ApiRender_PortletRequest_Include"
      + SERVLET_SUFFIX;
  PortletRequestDispatcher rd_tr2 =
      portletConfig.getPortletContext().getRequestDispatcher(target_tr2);
  rd_tr2.include(portletReq, portletResp);

  /* TestCase: V2EnvironmentTests_PortletRequestDispatcher_ApiRender_includeB1 */
  /* Details: "Method include(RenderRequest, RenderResponse): Includes */
  /* the content of a JSP page in the response" */
  String target_tr3 =
      JSP_PREFIX + "V2EnvironmentTests_PortletRequestDispatcher_ApiRender_includeB1" + JSP_SUFFIX
          + "?" + QUERY_STRING;
  PortletRequestDispatcher rd_tr3 =
      portletConfig.getPortletContext().getRequestDispatcher(target_tr3);
  rd_tr3.include(portletReq, portletResp);

  /* TestCase: V2EnvironmentTests_PortletRequestDispatcher_ApiRender_includeB2 */
  /* Details: "Method include(RenderRequest, RenderResponse): Includes */
  /* the content of a HTML Page in the response" */
  String target_tr4 = HTML_PREFIX
      + "V2EnvironmentTests_PortletRequestDispatcher_ApiRender_includeB2" + HTML_SUFFIX;
  PortletRequestDispatcher rd_tr4 =
      portletConfig.getPortletContext().getRequestDispatcher(target_tr4);
  rd_tr4.include(portletReq, portletResp);

  /* TestCase: V2EnvironmentTests_PortletRequestDispatcher_ApiRender_includeB3 */
  /* Details: "Method include(RenderRequest, RenderResponse): The */
  /* included servlet cannot change the status code. The attempt is */
  /* ignored" */
  String target_tr5 = SERVLET_PREFIX
      + "V2EnvironmentTests_PortletRequestDispatcher_ApiRender_RenderRequest_Include"
      + SERVLET_SUFFIX;
  PortletRequestDispatcher rd_tr5 =
      portletConfig.getPortletContext().getRequestDispatcher(target_tr5);
  rd_tr5.include(portletReq, portletResp);



}