掲示板
How to programmatically change the status of some document in liferay 7?
7年前 に Abhishek Jain によって更新されました。
How to programmatically change the status of some document in liferay 7?
Regular Member 投稿: 226 参加年月日: 16/08/20 最新の投稿
I want to change the status of some document to approved in the Documents and Media portlet in liferay 7. For that I am using the below function in some jsp file:-
But doing so I am getting the NullPointerException as follows:-
java.lang.NullPointerException
at com.liferay.portlet.documentlibrary.service.impl.DLAppHelperLocalServiceImpl.updateStatus(DLAppHelperLocalServiceImpl.java:1144)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:153)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:85)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:58)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
at com.liferay.portal.service.ServiceContextAdvice.invoke(ServiceContextAdvice.java:40)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:173)
at com.liferay.portlet.documentlibrary.service.impl.DLFileEntryLocalServiceImpl.updateStatus(DLFileEntryLocalServiceImpl.java:2028)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:153)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:85)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:58)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
at com.liferay.portal.service.ServiceContextAdvice.invoke(ServiceContextAdvice.java:40)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:173)
Here when I change the status of document to a non-zero value it is successfully updated but when I change the status to 0, I am getting the NPE. Can you tell me why and how to remove it? Thanx in advance..
DLFileEntryLocalServiceUtil.updateStatus(themeDisplay.getUserId(), fileEntry1.getFileVersion().getFileVersionId() ,0, null, null);
But doing so I am getting the NullPointerException as follows:-
java.lang.NullPointerException
at com.liferay.portlet.documentlibrary.service.impl.DLAppHelperLocalServiceImpl.updateStatus(DLAppHelperLocalServiceImpl.java:1144)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:153)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:85)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:58)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
at com.liferay.portal.service.ServiceContextAdvice.invoke(ServiceContextAdvice.java:40)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:173)
at com.liferay.portlet.documentlibrary.service.impl.DLFileEntryLocalServiceImpl.updateStatus(DLFileEntryLocalServiceImpl.java:2028)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:153)
at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:85)
at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:58)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
at com.liferay.portal.service.ServiceContextAdvice.invoke(ServiceContextAdvice.java:40)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56)
at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:127)
at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:173)
Here when I change the status of document to a non-zero value it is successfully updated but when I change the status to 0, I am getting the NPE. Can you tell me why and how to remove it? Thanx in advance..
7年前 に Anji E によって更新されました。
RE: How to programmatically change the status of some document in liferay 7
Junior Member 投稿: 49 参加年月日: 14/11/18 最新の投稿
Did you get any solution ??
Even i have same requirement .
Even i have same requirement .
7年前 に Abhishek Jain によって更新されました。
RE: How to programmatically change the status of some document in liferay 7 (回答)
Regular Member 投稿: 226 参加年月日: 16/08/20 最新の投稿
I just passed the value as non null for servicecontext and workflowcontext in updatestatus() . The reference for servicecontext is by the following code :-
whereas I got reference of workflowContext by the folowing code:-
And called the updateStatus() method as follows:-
Hope this helps..
serviceContext = ServiceContextFactory.getInstance(com.liferay.document.library.web.internal.portlet.DLAdminPortlet.class.getName(), renderRequest);
whereas I got reference of workflowContext by the folowing code:-
Map<string, serializable> workflowContext =
(Map<string, serializable>)serviceContext.removeAttribute(
"workflowContext");
if (workflowContext == null) {
workflowContext = Collections.emptyMap();
}</string,></string,>
And called the updateStatus() method as follows:-
DLFileEntryLocalServiceUtil.updateStatus(themeDisplay.getUserId(), fileEntry.getFileVersion().getFileVersionId() ,102, serviceContext, workflowContext);
Hope this helps..
6年前 に Anji E によって更新されました。
RE: How to programmatically change the status of some document in liferay 7
Junior Member 投稿: 49 参加年月日: 14/11/18 最新の投稿
Hi Abhishek ,
Thanks a lot for your suggestion . Its worked .
I have one more concern .
As soon document uploaded via Custom portlet , we are uploading document with status as "draft" .
draft records are not getting index , hence its not available for search ( we are retrieving documents using indexer ).
I have also tried do reindex as soon document uploaded still records are not getting indexing .
Thanks a lot for your suggestion . Its worked .
I have one more concern .
As soon document uploaded via Custom portlet , we are uploading document with status as "draft" .
draft records are not getting index , hence its not available for search ( we are retrieving documents using indexer ).
I have also tried do reindex as soon document uploaded still records are not getting indexing .
6年前 に Ravikant Sirswa によって更新されました。
RE: How to programmatically change the status of some document in liferay 7
New Member 投稿: 1 参加年月日: 17/05/30 最新の投稿
If You want to changes your document and media status programmatically from draft to Approved.Follow below code
long companyId = PortalUtil.getDefaultCompanyId();
Company companyObj = CompanyLocalServiceUtil.getCompany(companyId);
Group group = GroupLocalServiceUtil.getGroup(companyId, String.valueOf(companyId));
DLFolder folder = DLFolderLocalServiceUtil.getFolder(group.getGroupId(), PARENT_FOLDER_ID,
"SirswaPartnerDocuments");
int workFlowStatus = WorkflowConstants.STATUS_APPROVED;
dlFileEntry = DLFileEntryLocalServiceUtil.updateStatus(folder.getUserId(),dlFileEntry.getFileVersion().getFileVersionId(),workFlowStatus, serviceContext,new HashMap<String, Serializable>());
long companyId = PortalUtil.getDefaultCompanyId();
Company companyObj = CompanyLocalServiceUtil.getCompany(companyId);
Group group = GroupLocalServiceUtil.getGroup(companyId, String.valueOf(companyId));
DLFolder folder = DLFolderLocalServiceUtil.getFolder(group.getGroupId(), PARENT_FOLDER_ID,
"SirswaPartnerDocuments");
int workFlowStatus = WorkflowConstants.STATUS_APPROVED;
dlFileEntry = DLFileEntryLocalServiceUtil.updateStatus(folder.getUserId(),dlFileEntry.getFileVersion().getFileVersionId(),workFlowStatus, serviceContext,new HashMap<String, Serializable>());