Fórum
How to programmatically change the status of some document in liferay 7?
Abhishek Jain, modificado 7 Anos atrás.
How to programmatically change the status of some document in liferay 7?
Regular Member Postagens: 226 Data de Entrada: 20/08/16 Postagens Recentes
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..
Anji E, modificado 7 Anos atrás.
RE: How to programmatically change the status of some document in liferay 7
Junior Member Postagens: 49 Data de Entrada: 18/11/14 Postagens Recentes
Did you get any solution ??
Even i have same requirement .
Even i have same requirement .
Abhishek Jain, modificado 7 Anos atrás.
RE: How to programmatically change the status of some document in liferay 7 (Resposta)
Regular Member Postagens: 226 Data de Entrada: 20/08/16 Postagens Recentes
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..
Anji E, modificado 6 Anos atrás.
RE: How to programmatically change the status of some document in liferay 7
Junior Member Postagens: 49 Data de Entrada: 18/11/14 Postagens Recentes
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 .
Ravikant Sirswa, modificado 6 Anos atrás.
RE: How to programmatically change the status of some document in liferay 7
New Member Mensagem: 1 Data de Entrada: 30/05/17 Postagens Recentes
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>());