Document processing on the Liferay portal

I have been using Liferay for the past two years for many years, but I have never required extensive document management.

Now I have a portlet where users upload documents (MS Office OLE2 documents, ODS documents, PDF, etc.) and I have to save them with all available metadata.

I know how to do this without using Liferay, I would probably use Apache solr with Apache Tika ( UpdateRichDocuments and ExtractingRequestHandler ) or Apache Jackrabbit, which use Apache Tika under the hood (org.apache.jackrabbit.extractor. *).

The problem is that if I look at the Liferay torso, there are several key classes:

Hooks (JCRHook, FileSystemHook, CMISHook, s3Hook) that are used directly inside DLLocalServiceImpl directly

Another alternative is to use DLAppLocalServiceImpl , which uses DLRepositoryLocalServiceImpl , and the files are saved in the repository also through Hooks, but there are many other things.

  • Liferay does not have a library for drawing with jabrabbit-text-extractors, so I suppose that if I wanted the metadata to be extracted from PDF, DOC, ODS documents, I would have very hard times ... because the level of service DL does not accept additional properties

    • I think I will have to avoid using DL and JCR services, as well as directly access Jackrabbit ... But I would lose compatibility and the ability to migrate my repository, etc.

Can anyone collaborate on this, please? thank you

+4
source share
4 answers

the two services DLLocalServiceImpl and DLAppLocalServiceImpl are both and will be, I suppose, important. The first, if for direct access to the repository. Please note: when adding a file through this service, you need to save the corresponding DlFileEntry in the database, and not reference addFile (...., fileEntryId, ...).

The latter service does additional things for you, mainly asset management and workflow.

As for your use case, I would avoid using a document library because no metadata can get into the JCR repository. In fact, only the metadata / user properties that you could save would be the custom properties AKA Expando function of the Liferay portal.

The best way for you, it seems, is to implement your own image capture hook for storing data in the repository and let the Liferay document library use this repository.

+1
source

SOLR for indexing; Jackrabbit for document storage. Managing the Liferay document library in your code is pretty simple, just look at the DL * LocalServiceUtil classes, namely DLFolderLocalServiceUtil and DLFileLocalServiceUtil . By default, Liferay only creates the appropriate folder / file structure on the hard drive (with changed names), so you will need to write code or use Jackrabbit if you want more than that, since Liferay allows you to download and view from a window through the control panel and various portlets.

I did not use JackRabbit with Liferay, but after setting everything should be controlled under the covers, and you do not need to worry about it on the front panel.

When you say β€œwith all available metadata,” I’m not sure what is saved, but apart from renaming the file so that it can be tracked, there should be no other changes. You need to quickly and easily test it by uploading a file of each type and checking the entries in the LIFERAY/data/document_library directory and subdirectories. Again, this would be different if Jackrabbit were used.

+2
source

I think Edgar is right. If you check the current highway through http://svn.liferay.com/repos/public/portal/trunk/portal-service/src/com/liferay/documentlibrary/service/DLLocalService.java (enter username and password), you You will no longer find the DLFolderLocalServiceUtil class. We also use the existing DLFolderLocalServiceUtil class. Thanks for the heads. We will reorganize our code, so when 6.1 appears, we can still use the DocumentLibrary services.

0
source

You always need to use DLAppServiceUtil (as Liferay specifically points out). Here is my working code that saves the file in CMS:

 public static void saveFileToCMS(ActionRequest aReq, long groupId, String fileName, File filenameWithPath) { try { ServiceContext serviceContext = ServiceContextFactory.getInstance( Group.class.getName(), aReq); // prevents duplicate entries based on unique title name Random rand = new Random(); Integer suffix = new Integer(rand.nextInt(10000)); DLAppServiceUtil.addFileEntry(groupId, 0, fileName, "application/vnd.ms-excel", fileName + suffix.toString(), "description goes here", "changelogname", filenameWithPath, serviceContext); //log.info("Successfully added the new file"); } catch (PortalException pe) { log.error("Portal Exception occurred while saving file to CMS"); pe.printStackTrace(); } catch (SystemException e) { log.error("System Exception occurred while saving file to CMS"); e.printStackTrace(); } } 
0
source

Source: https://habr.com/ru/post/1341559/


All Articles