use of javax.portlet.ResourceURL in project index-checker by jorgediaz-lr.
the class IndexCheckerPortlet method doView.
public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
PortletConfig portletConfig = (PortletConfig) renderRequest.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);
renderRequest.setAttribute("updateMessage", getUpdateMessage(portletConfig));
List<String> outputList = IndexCheckerOutput.generateCSVOutput(portletConfig, renderRequest);
String portletId = portletConfig.getPortletName();
String outputContent = OutputUtils.listStringToString(outputList);
FileEntry exportCsvFileEntry = OutputUtils.addPortletOutputFileEntry(portletId, PortalUtil.getUserId(renderRequest), outputContent);
if (exportCsvFileEntry != null) {
ResourceURL exportCsvResourceURL = renderResponse.createResourceURL();
exportCsvResourceURL.setResourceID(exportCsvFileEntry.getTitle());
renderRequest.setAttribute("exportCsvResourceURL", exportCsvResourceURL.toString());
}
try {
List<Long> siteGroupIds = getSiteGroupIds();
renderRequest.setAttribute("groupIdList", siteGroupIds);
List<String> groupDescriptionList = getSiteGroupDescriptions(siteGroupIds, renderRequest.getLocale());
renderRequest.setAttribute("groupDescriptionList", groupDescriptionList);
} catch (Exception e) {
throw new PortletException(e);
}
try {
renderRequest.setAttribute("modelList", getModelList());
} catch (SystemException se) {
throw new PortletException(se);
}
long filterModifiedDate = ParamUtil.getLong(renderRequest, "filterModifiedDate");
renderRequest.setAttribute("filterModifiedDate", filterModifiedDate);
super.doView(renderRequest, renderResponse);
}
use of javax.portlet.ResourceURL in project liferay-faces-bridge-impl by liferay.
the class EncodeActionURLResourceTests method encodeActionURLPortletResourceTest.
// Test is SingleRequest -- Render only
// Test #6.102
@BridgeTest(test = "encodeActionURLPortletResourceTest")
public String encodeActionURLPortletResourceTest(TestBean testBean) {
testBean.setTestComplete(true);
final String PORTLET_RENDER_TEST_STRING = "portlet:resource?_jsfBridgeViewId=/tests/singleRequestTest.xhtml¶m1=value1¶m2=value2";
final String PORTLET_RENDER_TEST_STRING_XMLENCODED = "portlet:resource?_jsfBridgeViewId=/tests/singleRequestTest.xhtml&param1=value1&param2=value2";
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
MimeResponse response = (MimeResponse) externalContext.getResponse();
ResourceURL portletURL = response.createResourceURL();
portletURL.setParameter("_jsfBridgeViewId", "/tests/singleRequestTest.xhtml");
portletURL.setParameter("param1", "value1");
portletURL.setParameter("param2", "value2");
StringWriter sw = new StringWriter(50);
String portletEncoded = null;
try {
portletURL.write(sw, true);
portletEncoded = sw.toString();
} catch (Exception e) {
portletEncoded = portletURL.toString();
}
// PortletContainers can return "URLs" with strict XML encoding -- as the bridge
// encoding depends on what is past in to it -- make sure we send in a string
// with the same encoding as compare string.
String bridgeEncoded = null;
if (EncodeURLTestUtil.isStrictXhtmlEncoded(portletEncoded)) {
bridgeEncoded = externalContext.encodeActionURL(PORTLET_RENDER_TEST_STRING_XMLENCODED);
} else {
bridgeEncoded = externalContext.encodeActionURL(PORTLET_RENDER_TEST_STRING);
}
if (bridgeEncoded.equals(portletEncoded)) {
testBean.setTestResult(true, "encodeActionURL correctly encoded a portlet resource URL as an actionURL using the portlet: syntax.");
return Constants.TEST_SUCCESS;
} else {
testBean.setTestResult(false, "encodeActionURL incorrectly encoded a portlet resource URL as an actionURL using the portlet: syntax. In encoding: " + PORTLET_RENDER_TEST_STRING + " the bridge returned: " + bridgeEncoded + " but the corresponding portletURL encoding returned: " + portletEncoded);
return Constants.TEST_FAILED;
}
}
use of javax.portlet.ResourceURL in project liferay-faces-bridge-ext by liferay.
the class LiferayURLFactoryImpl method getLiferayResourceURL.
@Override
public LiferayResourceURL getLiferayResourceURL(PortletRequest portletRequest, MimeResponse mimeResponse, boolean friendlyURLMapperEnabled) {
if (friendlyURLMapperEnabled) {
ResourceURL resourceURL = mimeResponse.createResourceURL();
return new LiferayResourceURLFriendlyImpl(resourceURL, mimeResponse.getNamespace(), mimeResponse.getCharacterEncoding());
} else {
LiferayURLGenerator liferayURLGenerator = (LiferayURLGenerator) portletRequest.getAttribute(RESOURCE_URL_GENERATOR);
if (liferayURLGenerator == null) {
ResourceURL resourceURL = mimeResponse.createResourceURL();
liferayURLGenerator = new LiferayURLGeneratorResourceImpl(resourceURL.toString(), mimeResponse.getNamespace(), mimeResponse.getCharacterEncoding());
portletRequest.setAttribute(RESOURCE_URL_GENERATOR, liferayURLGenerator);
}
return new LiferayResourceURLImpl(liferayURLGenerator);
}
}
use of javax.portlet.ResourceURL in project social by Meeds-io.
the class UISpacesToolBarPortlet method toJSON.
protected JSONObject toJSON(UserNode node, String navId, MimeResponse res) throws Exception {
JSONObject json = new JSONObject();
String nodeId = node.getId();
json.put("label", node.getEncodedResolvedLabel());
json.put("hasChild", node.getChildrenCount() > 0);
json.put("isSelected", nodeId.equals(getSelectedNode().getId()));
json.put("icon", node.getIcon());
ResourceURL rsURL = res.createResourceURL();
rsURL.setResourceID(res.encodeURL(getResourceIdFromNode(node, navId)));
json.put("getNodeURL", rsURL.toString());
json.put("actionLink", Utils.getSpaceURL(node));
JSONArray childs = new JSONArray();
for (UserNode child : node.getChildren()) {
childs.put(toJSON(child, navId, res));
}
json.put("childs", childs);
return json;
}
use of javax.portlet.ResourceURL in project acs-community-packaging by Alfresco.
the class AlfrescoFacesPortlet method getResourceURL.
/**
* Creates a resource URL from the given faces context.
*
* @param context
* the faces context
* @return the resource URL
*/
public static String getResourceURL(FacesContext context, String path) {
MimeResponse portletResponse = (MimeResponse) context.getExternalContext().getResponse();
ResourceURL resourceURL = portletResponse.createResourceURL();
resourceURL.setResourceID(path);
return resourceURL.toString();
}
Aggregations