List of usage examples for com.liferay.portal.kernel.util JavaConstants JAVAX_PORTLET_CONFIG
String JAVAX_PORTLET_CONFIG
To view the source code for com.liferay.portal.kernel.util JavaConstants JAVAX_PORTLET_CONFIG.
Click Source Link
From source file:com.liferay.alloy.mvc.AlloyPortlet.java
License:Open Source License
protected String getPath(PortletRequest portletRequest) { LiferayPortletConfig liferayPortletConfig = (LiferayPortletConfig) portletRequest .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); Portlet portlet = liferayPortletConfig.getPortlet(); String controllerPath = getControllerPath(portletRequest); StringBundler sb = new StringBundler(5); sb.append("/WEB-INF/jsp/"); sb.append(portlet.getFriendlyURLMapping()); sb.append("/controllers/"); sb.append(controllerPath);//from w ww. j a v a 2s. c om sb.append("_controller.jsp"); return sb.toString(); }
From source file:com.liferay.alloy.mvc.BaseAlloyControllerImpl.java
License:Open Source License
protected void initPortletVariables() { liferayPortletConfig = (LiferayPortletConfig) request.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); portletContext = liferayPortletConfig.getPortletContext(); portlet = liferayPortletConfig.getPortlet(); alloyPortlet = (AlloyPortlet) request.getAttribute(JavaConstants.JAVAX_PORTLET_PORTLET); portletRequest = (PortletRequest) request.getAttribute(JavaConstants.JAVAX_PORTLET_REQUEST); portletResponse = (PortletResponse) request.getAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE); liferayPortletResponse = (LiferayPortletResponse) portletResponse; lifecycle = GetterUtil.getString((String) request.getAttribute(PortletRequest.LIFECYCLE_PHASE)); if (log.isDebugEnabled()) { log.debug("Lifecycle " + lifecycle); }//w ww. j a v a2 s . co m if (lifecycle.equals(PortletRequest.ACTION_PHASE)) { actionRequest = (ActionRequest) portletRequest; actionResponse = (ActionResponse) portletResponse; } else if (lifecycle.equals(PortletRequest.EVENT_PHASE)) { eventRequest = (EventRequest) portletRequest; eventResponse = (EventResponse) portletResponse; } else if (lifecycle.equals(PortletRequest.RENDER_PHASE)) { mimeResponse = (MimeResponse) portletResponse; renderRequest = (RenderRequest) portletRequest; renderResponse = (RenderResponse) portletResponse; } else if (lifecycle.equals(PortletRequest.RESOURCE_PHASE)) { mimeResponse = (MimeResponse) portletResponse; resourceRequest = (ResourceRequest) portletRequest; resourceResponse = (ResourceResponse) portletResponse; } }
From source file:com.liferay.alloy.mvc.jsonwebservice.BaseAlloyControllerInvokerImpl.java
License:Open Source License
protected DynamicServletRequest createRequest(String lifecycle, Object... parameters) throws Exception { if ((parameters.length % 2) != 0) { throw new IllegalArgumentException("Parameters length is not an even number"); }/*w ww .j a v a2 s .co m*/ HttpServletRequestWrapper requestWrapper = new HttpServletRequestWrapper( new AlloyMockUtil.MockHttpServletRequest()); DynamicServletRequest request = new DynamicServletRequest(requestWrapper, false); for (int i = 0; i < parameters.length; i += 2) { request.appendParameter(String.valueOf(parameters[i]), String.valueOf(parameters[i + 1])); } request.appendParameter("controller", _controller); request.appendParameter("format", "json"); ThemeDisplay themeDisplay = (ThemeDisplay) _themeDisplay.clone(); PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker(); User user = UserLocalServiceUtil.getUser(permissionChecker.getUserId()); themeDisplay.setUser(user); request.setAttribute(WebKeys.THEME_DISPLAY, themeDisplay); request.setAttribute(WebKeys.LAYOUT, themeDisplay.getLayout()); LiferayPortletConfig liferayPortletConfig = (LiferayPortletConfig) PortletConfigFactoryUtil.create(_portlet, null); request.setAttribute(JavaConstants.JAVAX_PORTLET_CONFIG, liferayPortletConfig); request.setAttribute(JavaConstants.JAVAX_PORTLET_PORTLET, _alloyPortlet); PortletRequest portletRequest = null; PortletResponse portletResponse = null; if (lifecycle.equals(PortletRequest.ACTION_PHASE)) { portletRequest = createActionRequest(); portletResponse = createActionResponse(); } else { portletRequest = createRenderRequest(); portletResponse = createRenderResponse(request, _portlet.getRootPortletId(), themeDisplay.getPlid(), lifecycle); } request.setAttribute(JavaConstants.JAVAX_PORTLET_REQUEST, portletRequest); request.setAttribute(JavaConstants.JAVAX_PORTLET_RESPONSE, portletResponse); request.setAttribute(PortletRequest.LIFECYCLE_PHASE, lifecycle); request.setAttribute(BaseAlloyControllerImpl.VIEW_PATH, StringPool.BLANK); return request; }
From source file:com.liferay.asset.publisher.web.display.context.AssetPublisherDisplayContext.java
License:Open Source License
public String getPortletName() { PortletConfig portletConfig = (PortletConfig) _request.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); if (portletConfig == null) { return StringPool.BLANK; }/*from w w w . j a v a 2 s .co m*/ return portletConfig.getPortletName(); }
From source file:com.liferay.asset.publisher.web.util.DefaultAssetPublisherCustomizer.java
License:Open Source License
protected String getPortletName(HttpServletRequest request) { PortletConfig portletConfig = (PortletConfig) request.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); if (portletConfig == null) { return StringPool.BLANK; }/* w w w .j av a2 s . com*/ return portletConfig.getPortletName(); }
From source file:com.liferay.blogs.web.internal.portlet.action.EditEntryMVCActionCommand.java
License:Open Source License
protected String getSaveAndContinueRedirect(ActionRequest actionRequest, BlogsEntry entry, String redirect) throws Exception { PortletConfig portletConfig = (PortletConfig) actionRequest .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); LiferayPortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, portletConfig.getPortletName(), PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/blogs/edit_entry"); portletURL.setParameter(Constants.CMD, Constants.UPDATE, false); portletURL.setParameter("redirect", redirect, false); portletURL.setParameter("groupId", String.valueOf(entry.getGroupId()), false); portletURL.setParameter("entryId", String.valueOf(entry.getEntryId()), false); portletURL.setWindowState(actionRequest.getWindowState()); return portletURL.toString(); }
From source file:com.liferay.content.targeting.portlet.ContentTargetingPortlet.java
License:Open Source License
protected void populateViewContext(String path, PortletRequest portletRequest, PortletResponse portletResponse, Template template, TemplateHashModel staticModels) throws Exception { HttpServletRequest request = PortalUtil.getHttpServletRequest(portletRequest); ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); if (Validator.isNull(path) || path.equals(ContentTargetingPath.VIEW) || path.equals(ContentTargetingPath.VIEW_CAMPAIGNS_RESOURCES) || path.equals(ContentTargetingPath.VIEW_USER_SEGMENTS_RESOURCES)) { template.put("actionKeys", staticModels.get(ActionKeys.class.getName())); template.put("campaignPermission", staticModels.get(CampaignPermission.class.getName())); template.put("contentTargetingPermission", staticModels.get(ContentTargetingPermission.class.getName())); template.put("userSegmentPermission", staticModels.get(UserSegmentPermission.class.getName())); PermissionChecker permissionChecker = (PermissionChecker) template.get("permissionChecker"); long scopeGroupId = (Long) template.get("scopeGroupId"); if (UserSegmentPermission.contains(permissionChecker, scopeGroupId, scopeGroupId, ActionKeys.DELETE)) { template.put("userSegmentsRowChecker", new RowChecker(portletResponse)); }// w w w . j a v a 2 s. c om if (CampaignPermission.contains(permissionChecker, scopeGroupId, scopeGroupId, ActionKeys.DELETE)) { template.put("campaignsRowChecker", new RowChecker(portletResponse)); } String keywords = ParamUtil.getString(portletRequest, "keywords"); template.put("campaignSearchContainerIterator", new CampaignSearchContainerIterator(scopeGroupId, keywords)); template.put("userSegmentSearchContainerIterator", new UserSegmentSearchContainerIterator(scopeGroupId, keywords)); } else if (path.equals(ContentTargetingPath.EDIT_CAMPAIGN)) { long campaignId = ParamUtil.getLong(portletRequest, "campaignId"); template.put("campaignId", campaignId); int priority = 1; long userSegmentId = -1; Calendar endDate = Calendar.getInstance(); Calendar startDate = Calendar.getInstance(); if (campaignId > 0) { Campaign campaign = _campaignLocalService.getCampaign(campaignId); template.put("campaign", campaign); List<UserSegment> campaignUserSegments = _userSegmentLocalService .getCampaignUserSegments(campaignId); priority = campaign.getPriority(); // Initially, only one user segment per campaign is supported if ((campaignUserSegments != null) && !campaignUserSegments.isEmpty()) { UserSegment campaignUserSegment = campaignUserSegments.get(0); userSegmentId = campaignUserSegment.getUserSegmentId(); } endDate.setTime(campaign.getEndDate()); startDate.setTime(campaign.getStartDate()); } else { Date now = new Date(); endDate.setTime(now); endDate.add(Calendar.DATE, 1); startDate.setTime(now); } template.put("endDate", endDate); template.put("priority", priority); template.put("startDate", startDate); template.put("userSegmentId", userSegmentId); long[] groupIds = ContentTargetingUtil.getAncestorsAndCurrentGroupIds(themeDisplay.getScopeGroupId()); List<UserSegment> userSegments = _userSegmentService.getUserSegments(groupIds); template.put("userSegments", userSegments); template.put("trackingActionsRegistry", _trackingActionsRegistry); Map<String, TrackingAction> trackingActions = _trackingActionsRegistry.getTrackingActions(); boolean isolated = themeDisplay.isIsolated(); try { themeDisplay.setIsolated(true); template.put("trackingActions", trackingActions.values()); List<TrackingActionInstance> trackingActionInstances = getTrackingActionsFromRequest(portletRequest, portletResponse); if (trackingActionInstances.isEmpty() && (campaignId > 0)) { trackingActionInstances = _trackingActionInstanceService.getTrackingActionInstances(campaignId); } List<TrackingActionTemplate> addedTrackingActionTemplates = new ArrayList<TrackingActionTemplate>(); if (!trackingActionInstances.isEmpty()) { template.put("trackingActionInstances", trackingActionInstances); InvalidTrackingActionsException itae = getInvalidTrackingActionsException(portletRequest); for (TrackingActionInstance instance : trackingActionInstances) { TrackingAction trackingAction = _trackingActionsRegistry .getTrackingAction(instance.getTrackingActionKey()); if (trackingAction == null) { continue; } TrackingActionTemplate trackingActionTemplate = new TrackingActionTemplate(); if (instance.getTrackingActionInstanceId() > 0) { trackingActionTemplate .setInstanceId(String.valueOf(instance.getTrackingActionInstanceId())); } else { trackingActionTemplate.setInstanceId(instance.getTrackingActionGuid()); } trackingActionTemplate.setTrackingAction(trackingAction); String html = getTrackingActionHtml(trackingAction, instance, template, instance.getValues(), itae.getExceptions(instance.getTrackingActionGuid())); trackingActionTemplate.setTemplate(HtmlUtil.escapeAttribute(html)); addedTrackingActionTemplates.add(trackingActionTemplate); } } template.put("addedTrackingActionTemplates", addedTrackingActionTemplates); List<TrackingActionTemplate> trackingActionTemplates = new ArrayList<TrackingActionTemplate>(); for (TrackingAction trackingAction : trackingActions.values()) { TrackingActionTemplate trackingActionTemplate = new TrackingActionTemplate(); trackingActionTemplate.setTrackingAction(trackingAction); String html = getTrackingActionHtml(trackingAction, null, template, null, null); trackingActionTemplate.setTemplate(HtmlUtil.escapeAttribute(html)); trackingActionTemplates.add(trackingActionTemplate); } template.put("trackingActionTemplates", trackingActionTemplates); } finally { themeDisplay.setIsolated(isolated); } } else if (path.equals(ContentTargetingPath.EDIT_USER_SEGMENT)) { long userSegmentId = ParamUtil.getLong(portletRequest, "userSegmentId"); template.put("ruleCategoriesRegistry", _ruleCategoriesRegistry); template.put("rulesRegistry", _rulesRegistry); template.put("userSegmentId", userSegmentId); Map<String, Rule> rules = _rulesRegistry.getRules(); boolean isolated = themeDisplay.isIsolated(); try { themeDisplay.setIsolated(true); template.put("rules", rules.values()); List<RuleInstance> ruleInstances = getRulesFromRequest(portletRequest, portletResponse); if (ruleInstances.isEmpty() && (userSegmentId > 0)) { ruleInstances = _ruleInstanceService.getRuleInstances(userSegmentId); } List<RuleTemplate> addedRuleTemplates = new ArrayList<RuleTemplate>(); if (!ruleInstances.isEmpty()) { template.put("ruleInstances", ruleInstances); InvalidRulesException ire = getInvalidRulesException(portletRequest); for (RuleInstance ruleInstance : ruleInstances) { Rule rule = _rulesRegistry.getRule(ruleInstance.getRuleKey()); if (rule == null) { continue; } RuleTemplate ruleTemplate = new RuleTemplate(); if (ruleInstance.getRuleInstanceId() > 0) { ruleTemplate.setInstanceId(String.valueOf(ruleInstance.getRuleInstanceId())); } else { ruleTemplate.setInstanceId(ruleInstance.getRuleGuid()); } ruleTemplate.setRule(rule); String html = getRuleHtml(rule, ruleInstance, template, ruleInstance.getValues(), ire.getRuleExceptions(ruleInstance.getRuleGuid())); ruleTemplate.setTemplate(HtmlUtil.escapeAttribute(html)); addedRuleTemplates.add(ruleTemplate); } } template.put("addedRuleTemplates", addedRuleTemplates); if (userSegmentId > 0) { UserSegment userSegment = _userSegmentLocalService.getUserSegment(userSegmentId); template.put("userSegment", userSegment); } List<RuleTemplate> ruleTemplates = new ArrayList<RuleTemplate>(); for (Rule rule : rules.values()) { RuleTemplate ruleTemplate = new RuleTemplate(); ruleTemplate.setRule(rule); String html = getRuleHtml(rule, null, template, null, null); ruleTemplate.setTemplate(HtmlUtil.escapeAttribute(html)); ruleTemplates.add(ruleTemplate); } template.put("ruleTemplates", ruleTemplates); } finally { themeDisplay.setIsolated(isolated); } } else if (path.equals(ContentTargetingPath.VIEW_REPORT) || path.equals(ContentTargetingPath.VIEW_REPORTS)) { String className = ParamUtil.getString(portletRequest, "className"); long classPK = ParamUtil.getLong(portletRequest, "classPK"); template.put("className", className); template.put("classPK", classPK); template.put("reportInstanceService", _reportInstanceService); String name = StringPool.BLANK; if (className.equals(Campaign.class.getName())) { Campaign campaign = _campaignLocalService.getCampaign(classPK); name = campaign.getName(themeDisplay.getLocale()); BreadcrumbUtil.addPortletBreadcrumbEntries(request, (RenderResponse) portletResponse, campaign); } else if (className.equals(UserSegment.class.getName())) { UserSegment userSegment = _userSegmentLocalService.getUserSegment(classPK); name = userSegment.getName(themeDisplay.getLocale()); BreadcrumbUtil.addPortletBreadcrumbEntries(request, (RenderResponse) portletResponse, userSegment); } if (path.equals(ContentTargetingPath.VIEW_REPORT)) { template.put("name", name); String reportKey = ParamUtil.getString(portletRequest, "reportKey"); Report report = _reportsRegistry.getReport(reportKey); template.put("report", report); template.put("reportHtml", report.getHTML(cloneTemplateContext(template))); BreadcrumbUtil.addPortletBreadcrumbEntries(request, (RenderResponse) portletResponse, report); } if (path.equals(ContentTargetingPath.VIEW_REPORTS)) { PortletConfig portletConfig = (PortletConfig) portletRequest .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); String title = LanguageUtil.format(portletConfig, themeDisplay.getLocale(), "reports-for-the-x-x", new Object[] { ResourceActionsUtil.getModelResource(themeDisplay.getLocale(), className), name }); template.put("title", title); template.put("reportSearchContainerIterator", new ReportSearchContainerIterator(themeDisplay.getScopeGroupId(), null, className)); } } }
From source file:com.liferay.faces.bridge.ext.scope.internal.RequestAttributeInspectorLiferayImpl.java
License:Open Source License
/** * This is a method-override that provides specific behavior for Liferay Portal. Specifically, since Liferay Portal * does not implement the POST-REDIRECT-GET design pattern, not all instance types listed in Section 5.1.2 of the * Spec can be candidates for exclusion. *///from www .j a v a 2 s . c o m @Override public boolean isExcludedByType(String name, Object value) { boolean excluded = false; if (value != null) { if ((value instanceof ExternalContext) || (value instanceof FacesContext)) { // Always safe to exclude when running under Liferay Portal. excluded = true; } else if (value instanceof PortletConfig) { // Liferay Portal includes request attribute named "javax.portlet.config" that must not be excluded. It // also includes an attribute named "javax.portlet.portlet" that is the current GenericFacesPortlet // (which extends GenericPortlet). But since GenericPortlet implements the PortletConfig interface, need // to prevent it from being excluded as well. if (!JavaConstants.JAVAX_PORTLET_CONFIG.equals(name) && !JavaConstants.JAVAX_PORTLET_PORTLET.equals(name)) { excluded = true; } } else if (value instanceof PortletRequest) { // Liferay Portal includes request attribute named "javax.portlet.request" that must not be excluded. if (!JavaConstants.JAVAX_PORTLET_REQUEST.equals(name)) { excluded = true; } } else if (value instanceof PortletResponse) { // Liferay Portal includes request attribute named "javax.portlet.response" that must not be excluded. if (!JavaConstants.JAVAX_PORTLET_RESPONSE.equals(name)) { excluded = true; } } else if ((value instanceof PortalContext) || (value instanceof PortletContext) || (value instanceof PortletPreferences) || (value instanceof PortletSession)) { excluded = true; } else if ((value instanceof HttpSession) || (value instanceof ServletConfig) || (value instanceof ServletContext) || (value instanceof ServletRequest) || (value instanceof ServletResponse)) { // Can only exclude attributes that are not Liferay objects. For example, Liferay Portal includes // a request attribute named "com.liferay.portal.kernel.servlet.PortletServletRequest" that must not be // excluded. if (!value.getClass().getName().startsWith("com.liferay")) { excluded = true; } } } return excluded; }
From source file:com.liferay.faces.bridge.scope.BridgeRequestScopeLiferayImpl.java
License:Open Source License
/** * This is a method-override that provides specific behavior for Liferay Portal. Specifically, since Liferay Portal * does not implement the POST-REDIRECT-GET design pattern, not all instance types listed in Section 5.1.2 of the * Spec can be candidates for exclusion. *///from w w w .j av a2 s . co m @Override protected boolean isExcludedRequestAttributeByInstance(String attributeName, Object attributeValue) { boolean excluded = false; if (attributeValue != null) { if ((attributeValue instanceof ExternalContext) || (attributeValue instanceof FacesContext)) { // Always safe to exclude when running under Liferay Portal. excluded = true; } else if (attributeValue instanceof PortletConfig) { // Liferay Portal includes request attribute named "javax.portlet.config" that must not be excluded. It // also includes an attribute named "javax.portlet.portlet" that is the current GenericFacesPortlet // (which extends GenericPortlet). But since GenericPortlet implements the PortletConfig interface, need // to prevent it from being excluded as well. if (!JavaConstants.JAVAX_PORTLET_CONFIG.equals(attributeName) && !JavaConstants.JAVAX_PORTLET_PORTLET.equals(attributeName)) { excluded = true; } } else if (attributeValue instanceof PortletRequest) { // Liferay Portal includes request attribute named "javax.portlet.request" that must not be excluded. if (!JavaConstants.JAVAX_PORTLET_REQUEST.equals(attributeName)) { excluded = true; } } else if (attributeValue instanceof PortletResponse) { // Liferay Portal includes request attribute named "javax.portlet.response" that must not be excluded. if (!JavaConstants.JAVAX_PORTLET_RESPONSE.equals(attributeName)) { excluded = true; } } else if ((attributeValue instanceof PortalContext) || (attributeValue instanceof PortletContext) || (attributeValue instanceof PortletPreferences) || (attributeValue instanceof PortletSession)) { excluded = true; } else if ((attributeValue instanceof HttpSession) || (attributeValue instanceof ServletConfig) || (attributeValue instanceof ServletContext) || (attributeValue instanceof ServletRequest) || (attributeValue instanceof ServletResponse)) { // Can only exclude attributes that are not Liferay objects. For example, Liferay Portal includes // a request attribute named "com.liferay.portal.kernel.servlet.PortletServletRequest" that must not be // excluded. if (!attributeValue.getClass().getName().startsWith(LiferayConstants.PACKAGE_NAMESPACE)) { excluded = true; } } } return excluded; }
From source file:com.liferay.faces.bridge.scope.internal.BridgeRequestScopeLiferayImpl.java
License:Open Source License
/** * This is a method-override that provides specific behavior for Liferay Portal. Specifically, since Liferay Portal * does not implement the POST-REDIRECT-GET design pattern, not all instance types listed in Section 5.1.2 of the * Spec can be candidates for exclusion. */// w w w . j a va 2 s .c o m @Override protected boolean isExcludedRequestAttributeByInstance(String attributeName, Object attributeValue) { boolean excluded = false; if (attributeValue != null) { if ((attributeValue instanceof ExternalContext) || (attributeValue instanceof FacesContext)) { // Always safe to exclude when running under Liferay Portal. excluded = true; } else if (attributeValue instanceof PortletConfig) { // Liferay Portal includes request attribute named "javax.portlet.config" that must not be excluded. It // also includes an attribute named "javax.portlet.portlet" that is the current GenericFacesPortlet // (which extends GenericPortlet). But since GenericPortlet implements the PortletConfig interface, need // to prevent it from being excluded as well. if (!JavaConstants.JAVAX_PORTLET_CONFIG.equals(attributeName) && !JavaConstants.JAVAX_PORTLET_PORTLET.equals(attributeName)) { excluded = true; } } else if (attributeValue instanceof PortletRequest) { // Liferay Portal includes request attribute named "javax.portlet.request" that must not be excluded. if (!JavaConstants.JAVAX_PORTLET_REQUEST.equals(attributeName)) { excluded = true; } } else if (attributeValue instanceof PortletResponse) { // Liferay Portal includes request attribute named "javax.portlet.response" that must not be excluded. if (!JavaConstants.JAVAX_PORTLET_RESPONSE.equals(attributeName)) { excluded = true; } } else if ((attributeValue instanceof PortalContext) || (attributeValue instanceof PortletContext) || (attributeValue instanceof PortletPreferences) || (attributeValue instanceof PortletSession)) { excluded = true; } else if ((attributeValue instanceof HttpSession) || (attributeValue instanceof ServletConfig) || (attributeValue instanceof ServletContext) || (attributeValue instanceof ServletRequest) || (attributeValue instanceof ServletResponse)) { // Can only exclude attributes that are not Liferay objects. For example, Liferay Portal includes // a request attribute named "com.liferay.portal.kernel.servlet.PortletServletRequest" that must not be // excluded. if (!attributeValue.getClass().getName().startsWith("com.liferay")) { excluded = true; } } } return excluded; }