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

The following examples show how to use javax.portlet.ActionRequest#getAttribute() . 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: ComplexPortletApplicationContext.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public MultipartActionRequest resolveMultipart(ActionRequest request) throws MultipartException {
	if (request.getAttribute("fail") != null) {
		throw new MaxUploadSizeExceededException(1000);
	}
	if (request instanceof MultipartActionRequest) {
		throw new IllegalStateException("Already a multipart request");
	}
	if (request.getAttribute("resolved") != null) {
		throw new IllegalStateException("Already resolved");
	}
	request.setAttribute("resolved", Boolean.TRUE);
	MultiValueMap<String, MultipartFile> files = new LinkedMultiValueMap<String, MultipartFile>();
	files.set("someFile", new MockMultipartFile("someFile", "someContent".getBytes()));
	Map<String, String[]> params = new HashMap<String, String[]>();
	params.put("someParam", new String[] {"someParam"});
	return new DefaultMultipartActionRequest(request, files, params, Collections.<String, String>emptyMap());
}
 
Example 2
Source File: ContactGroupTerm.java    From opencps-v2 with GNU Affero General Public License v3.0 5 votes vote down vote up
public ContactGroupTerm(ActionRequest request) {
	ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);

	contactGroupId = ParamUtil.getLong(request, CONTACT_GROUP_ID);
	groupId = themeDisplay.getScopeGroupId();
	companyId = themeDisplay.getCompanyId();
	userId = themeDisplay.getUserId();
	createDate = ParamUtil.getDate(request, CREATE_DATE,
			DateTimeUtils.getDateTimeFormat(DateTimeUtils._VN_DATE_TIME_FORMAT));
	modifiedDate = ParamUtil.getDate(request, MODIFIED_DATE,
			DateTimeUtils.getDateTimeFormat(DateTimeUtils._VN_DATE_TIME_FORMAT));
	groupName = ParamUtil.getString(request, GROUP_NAME);
	contactList = ParamUtil.getString(request, CONTACT_LIST);
	shared = ParamUtil.getInteger(request, SHARED);
}
 
Example 3
Source File: LoginMVCActionCommand.java    From opencps-v2 with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void doProcessAction(
	ActionRequest actionRequest, ActionResponse actionResponse)
	throws Exception {
	
	ThemeDisplay themeDisplay =
		(ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

	HttpServletRequest request = PortalUtil.getOriginalServletRequest(
		PortalUtil.getHttpServletRequest(actionRequest));

	HttpServletResponse response =
		PortalUtil.getHttpServletResponse(actionResponse);

	String login = ParamUtil.getString(actionRequest, "login");
	String password = ParamUtil.getString(actionRequest, "password");
	String action = ParamUtil.getString(actionRequest, "action");
	boolean rememberMe = ParamUtil.getBoolean(actionRequest, "rememberMe");
	String authType = CompanyConstants.AUTH_TYPE_EA;
	
	if (!Validator.isEmailAddress(login)) {
		
		Applicant app = ApplicantLocalServiceUtil.fetchByAppId(login);
		
		if (Validator.isNotNull(app)) {
			login = app.getContactEmail();
		}
	}
	
	Applicant applicant = UserMgtUtils.getApplicant(login);

	login = applicant != null ? applicant.getContactEmail() : login;

	User user = UserLocalServiceUtil.getUserByEmailAddress(
		themeDisplay.getCompanyId(), login);

	hideDefaultSuccessMessage(actionRequest);

	if (user != null &&
		user.getStatus() == WorkflowConstants.STATUS_PENDING) {

		actionResponse.sendRedirect(themeDisplay.getURLHome() +
			"/register#/xac-thuc-tai-khoan?active_user_id=" + user.getUserId() +
				"&redirectURL=" + themeDisplay.getURLCurrent());
	}
	else {
		AuthenticatedSessionManagerUtil.login(
			request, response, login, password, rememberMe, authType);

		if (action != null && "confirm_account".equals(action)) {
			actionResponse.sendRedirect(
					themeDisplay.getURLHome() + "/profile");
		}
		else {
			actionResponse.sendRedirect(themeDisplay.getPathMain());
		}
	}

}
 
Example 4
Source File: AddlRequestTests_SPEC2_11_ActionAttr.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 {

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

  StringWriter writer = new StringWriter();

  JSR286SpecTestCaseDetails tcd = new JSR286SpecTestCaseDetails();

  // Create result objects for the tests

  /* TestCase: V2AddlRequestTests_SPEC2_11_ActionAttr_attributes1 */
  /* Details: "The portlet can access a map with user information */
  /* attributes via the request attribute PortletRequest.USER_INFO" */
  TestResult tr0 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONATTR_ATTRIBUTES1);
  if (portletReq.getAttribute(PortletRequest.USER_INFO) != null) {
    tr0.setTcSuccess(true);
  }
  tr0.writeTo(writer);

  /* TestCase: V2AddlRequestTests_SPEC2_11_ActionAttr_attributes2 */
  /* Details: "The PortletRequest.CCPP_PROFILE request attribute must */
  /* return a javax.ccpp.Profile based on the current portlet request" */
  TestResult tr1 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONATTR_ATTRIBUTES2);
  if (portletReq.getAttribute(PortletRequest.CCPP_PROFILE) != null) {
    tr1.setTcSuccess(true);
  }
  tr1.writeTo(writer);

  /* TestCase: V2AddlRequestTests_SPEC2_11_ActionAttr_attributes6 */
  /* Details: "During action processing, the LIFECYCLE_PHASE */
  /* (\"javax.portlet.lifecycle_phase\") attribute will contain the */
  /* string \"ACTION_PHASE\"" */
  TestResult tr2 = tcd.getTestResultFailed(V2ADDLREQUESTTESTS_SPEC2_11_ACTIONATTR_ATTRIBUTES6);
  if (portletReq.getAttribute(PortletRequest.LIFECYCLE_PHASE).equals("ACTION_PHASE")) {
    tr2.setTcSuccess(true);
  }
  tr2.writeTo(writer);

  portletReq.getPortletSession().setAttribute(
      RESULT_ATTR_PREFIX + "AddlRequestTests_SPEC2_11_ActionAttr", writer.toString(),
      APPLICATION_SCOPE);
}
 
Example 5
Source File: JoinSiteStatusTerm.java    From opencps-v2 with GNU Affero General Public License v3.0 3 votes vote down vote up
public JoinSiteStatusTerm(ActionRequest request) {

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

		JoinSiteStatusId = ParamUtil.getLong(request, JOIN_SITE_STATUS_ID);
		
		groupId = themeDisplay.getScopeGroupId();
		
		companyId = themeDisplay.getCompanyId();
		
		userId = themeDisplay.getUserId();
		
		userName = themeDisplay.getUser().getFullName();
		
		createDate = ParamUtil.getDate(request, CREATE_DATE,
				DateTimeUtils.getDateTimeFormat(DateTimeUtils._VN_DATE_TIME_FORMAT));
		
		modifiedDate = ParamUtil.getDate(request, MODIFIED_DATE,
				DateTimeUtils.getDateTimeFormat(DateTimeUtils._VN_DATE_TIME_FORMAT));
		
		employeeId = ParamUtil.getLong(request, EMPLOYEE_ID);
		
		joinSiteGroupId = ParamUtil.getLong(request, JOIN_SITE_GROUP_ID);
		
		status = ParamUtil.getInteger(request, STATUS);
		
	}