Message Boards

Need to update an artifact version in Document media Portlet

Kevin Matthews, modified 2 Years ago.

Need to update an artifact version in Document media Portlet

Expert Posts: 253 Join Date: 1/25/16 Recent Posts

hello, I would like to update document version in the document and media portlet. My documents store in the db using the dbstore configuration in my portal-exr.properties file. I have  the following code below. The version gets updated correctlly in the version tab in the document portlet but if I try to prgamatically _dLFileEntryLocalService.getFileAsStream(fe.getFileEntryId(), fe.getVersion()); fetch that same document I get an exception 

"com.liferay.document.library.kernel.exception.NoSuchFileException: {companyId=20102, repositoryId=20125, fileName=2897, version=2.0, cause=com.liferay.document.library.content.exception.NoSuchContentException: No DLContent exists with the key {companyId=20102, repositoryId=20125, path=2897, version=2.0}}" 

The reason I get this acception it seems the documents that are stored in the DLContent table doesnt get the updated version number. Can someone tell me proper way to programmatically update a list of assets versions in the document portlet and also updating the version column of the DLContent table? It seems I can not autowire or inject DLContentLocalService interface as its not in the Liferay 7.2 com.liferay.document.library.kernel.service package

 

fe = _dLFileEntryLocalService.getFileEntry(groupId, folderId, searchAssetName(title, fl_list));
                fev = _dLFileVersionLocalService.getFileVersion(fe.getFileEntryId(), fe.getVersion());
           
                if (fe.getVersion() != version) {
                    fe.setVersion(version);
                    fev.setVersion(version);
                    _dLFileEntryLocalService.updateDLFileEntry(fe);
                    _dLFileVersionLocalService.updateDLFileVersion(fev);
                
                    
                    
                }