« Zurück

Hook for Remote Live Publishing History of web content

General Blogs 11. Mai 2018 Von Neha Goyal

 
portal.properties
-----------------------
journal.article.form.default.values=content,abstract,categorization,display-page,related-assets,permissions,custom-fields,Publish History
journal.article.form.update=content,abstract,categorization,schedule,display-page,related-assets,custom-fields,Publish History
 
 
create Publish History.jsp inside html/portlet/journal/article and put below code
<%--
/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */
--%>
 
<%@ include file="/html/portlet/journal/init.jsp" %>
 
<%@ page import="com.liferay.portal.model.BackgroundTask" %>
<%@ page import="com.liferay.portal.service.BackgroundTaskLocalServiceUtil" %>
<%@ page import="com.liferay.portal.kernel.dao.orm.DynamicQuery" %>
<%@ page import="com.liferay.portal.kernel.dao.orm.DynamicQueryFactoryUtil" %>
<%@ page import="com.liferay.portal.kernel.util.PortalClassLoaderUtil" %>
<%@ page import="com.liferay.portal.kernel.dao.orm.RestrictionsFactoryUtil"%>
<%@ page import="com.liferay.portal.kernel.dao.orm.Criterion"%>
<%@ page import="com.liferay.portal.kernel.dao.orm.OrderFactoryUtil" %>
<%@ page import="com.liferay.portal.kernel.backgroundtask.BackgroundTaskConstants" %>
 
<div><h4>Remote Live Publishing History</h4></div>
<%
JournalArticle article = (JournalArticle)request.getAttribute(WebKeys.JOURNAL_ARTICLE);
String articleId = article.getArticleId();
try{
DynamicQuery dynamicQuery = DynamicQueryFactoryUtil.forClass(
BackgroundTask.class, PortalClassLoaderUtil.getClassLoader());
Criterion criterion1=RestrictionsFactoryUtil.like("taskContext","%##########% "+articleId+",%##########%");
        Criterion criterion2 =RestrictionsFactoryUtil.eq("completed", true);
        
        dynamicQuery.add(RestrictionsFactoryUtil.and(criterion1, criterion2));
        dynamicQuery.addOrder(OrderFactoryUtil.desc("createDate"));
List<Object> list = BackgroundTaskLocalServiceUtil.dynamicQuery(dynamicQuery);
if(list!=null && list.size()>0){%>
<div style="max-height:400px; overflow-x:auto">
<table class="table table-bordered table-striped">
<thead class="table-columns">
<tr>
<th>#</th>
<th>Published On</th>
<th>Published By</th>
<th>Status</th>
<!-- <th>BackgroundTaskId</th> -->
</tr>
</thead>
<tbody class="table-data">
<%for(int j=0;j<list.size();j++){%>
<tr>
<td class="table-cell"><%=j+1%></td>
<td class="table-cell"><%=((BackgroundTask)list.get(j)).getCreateDate()%></td>
<td class="table-cell"><%=((BackgroundTask)list.get(j)).getUserName()%></td>
<td class="table-cell"><%=BackgroundTaskConstants.getStatusLabel(((BackgroundTask)list.get(j)).getStatus())%></td>
<%-- <td class="table-cell"><%=((BackgroundTask)list.get(j)).getBackgroundTaskId()%></td> --%>
</tr>
<% }%>
</tbody>
</table>
</div>
<%
}
else{%>
<div>Either this has not been published or no history available</div>
<%}
}
catch(Exception ex){
ex.printStackTrace();
}
 
 
%>
 
Noch keine Anmerkungen Fangen Sie an