Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
Hebatu Allah Fahmy
Get journal article urlTitle from the URL
March 28, 2013 10:33 AM
Answer

Hebatu Allah Fahmy

Rank: Junior Member

Posts: 41

Join Date: August 6, 2012

Recent Posts

Hello all ,

I am trying to get The current rendered journal article from its urlTitle
I get the current url then split it to get urlTitle then send it to getArticleByUrlTitle method as following

 1
 2
 3    ThemeDisplay themeDisplayObject = (ThemeDisplay) request
 4            .getAttribute(WebKeys.THEME_DISPLAY);
 5    //long groupId = ParamUtil.getLong(request, "groupId", scopeGroupId);
 6    long groupId = themeDisplayObject.getScopeGroupId();
 7   
 8    String url = PortalUtil.getCurrentURL(request);
 9    String [] urlString = url.split("/");
10    String urlTitle = urlString[urlString.length - 1];
11   
12//    String articleId = "31575";
13    JournalArticle journal = JournalArticleLocalServiceUtil.getArticleByUrlTitle(groupId, urlTitle);


This throws the following exception
 1
 2Stacktrace:
 3        at org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
 4        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:455)
 5        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
 6        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
 7        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
 8        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
 9        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
10        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:72)
11        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:113)
12        at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:70)
13        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
14        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
15        at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
16        at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:593)
17        at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:530)
18        at com.liferay.portlet.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:316)
19        at com.liferay.portlet.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:105)
20        ... 173 more
21Caused by: javax.servlet.ServletException: com.liferay.portlet.journal.NoSuchArticleException: No JournalArticle exists with the key {groupId=10179, urlTitle=%
220%D9%85%D8%B9%D9%8A%D9%86%D8%A7%D8%AA-%D8%A7%D9%84%D9%85%D8%B3%D8%AA%D8%A8%D8%AF-, status=1}
23        at org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
24        at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
25        at com.liferay.portal.kernel.servlet.PageContextWrapper.handlePageException(PageContextWrapper.java:161)
26        at org.apache.jsp.view_jsp._jspService(view_jsp.java:317)
27        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
28        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
29        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
30        ... 188 more
31Caused by: com.liferay.portlet.journal.NoSuchArticleException: No JournalArticle exists with the key {groupId=10179, urlTitle=%20%D9%85%D8%B9%D9%8A%D9%86%D8%A7
32D8%AA-%D8%A7%D9%84%D9%85%D8%B3%D8%AA%D8%A8%D8%AF-, status=1}
33        at com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.getLatestArticleByUrlTitle(JournalArticleLocalServiceImpl.java:1444)
34        at com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.getArticleByUrlTitle(JournalArticleLocalServiceImpl.java:824)
35        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
36        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
37        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
38        at java.lang.reflect.Method.invoke(Method.java:597)
39        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:112)
40        at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:71)
41        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:108)
42        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:59)
43        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:108)
44        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:59)
45        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:108)
46        at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:211)
47        at $Proxy204.getArticleByUrlTitle(Unknown Source)
48        at com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil.getArticleByUrlTitle(JournalArticleLocalServiceUtil.java:480)
49        at org.apache.jsp.view_jsp._jspService(view_jsp.java:248)
50        ... 191 more
5117:25:51,451 ERROR [render_portlet_jsp:154] com.liferay.portlet.journal.NoSuchArticleException: No JournalArticle exists with the key {groupId=10179, urlTitle=
5220%D9%85%D8%B9%D9%8A%D9%86%D8%A7%D8%AA-%D8%A7%D9%84%D9%85%D8%B3%D8%AA%D8%A8%D8%AF-, status=1}
53        at com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.getLatestArticleByUrlTitle(JournalArticleLocalServiceImpl.java:1444)
54        at com.liferay.portlet.journal.service.impl.JournalArticleLocalServiceImpl.getArticleByUrlTitle(JournalArticleLocalServiceImpl.java:824)
55        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:112)
56        at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:71)
57        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:108)
58        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:59)
59        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:108)
60        at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:59)
61        at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:108)
62        at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:211)
63        at com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil.getArticleByUrlTitle(JournalArticleLocalServiceUtil.java:480)
64        at org.apache.jsp.view_jsp._jspService(view_jsp.java:248)
65        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
66        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
67        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
68        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
69        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
70        at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
71        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
72        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)


So , how can I get the current displayed journal article ?

All your feedback is highly appreciated .

Thanks in advance .
Parikshit Sharma
RE: Get journal article urlTitle from the URL
March 29, 2013 5:38 AM
Answer

Parikshit Sharma

Rank: New Member

Posts: 21

Join Date: January 16, 2013

Recent Posts

Hi,
after splitting you need to decode it to the normal form use HttpUtil.decode(urlTitle) .
Hebatu Allah Fahmy
RE: Get journal article urlTitle from the URL
March 31, 2013 1:15 AM
Answer

Hebatu Allah Fahmy

Rank: Junior Member

Posts: 41

Join Date: August 6, 2012

Recent Posts

Many thanks for your reply , it works