« Back

Import and export Knowledge based articles

Community Blogs March 19, 2010 By Jonas Yuan

What’s knowledge base or knowledge management (KM)? The portlet Knowledge Base allows authoring articles and organize them in a hierarchy of navigable categories. It leverages Web Content articles, structures, and templates; allows rating on articles; allows commenting on articles; allows adding hierarchy of categories; allows adding tags on articles; exports articles to PDF and other formats; supports workflow; allows adding custom attributes (called custom fields); supports indexing and advanced search; allows using rule engine; search by keyword – look-ahead typing; multiple-language support; import and export as XML file like DocBook; etc.

In general, the portlet Knowledge Base provides two pieces inside: Articles – managing knowledge base articles - and Article Aggregator - publishing knowledge base articles.

Abstracted from the book: Liferay Portal 6 Enterprise Intranets (coming out soon)

We have discussed main features of Knowledge base articles in both Liferay portal 5.2 EE SP1 (or SP2 or SP3) and 6.0 like

Multiple-language support for Knowledge Base articles

Taxonomies and Folksonomies - Increasing search and retrieve capabilities in Knowledge Base Articles

Sharing Content - Knowledge base - across Organizations and Communities

Search by keyword - look-ahead typing – based on Knowledge Base articles in Liferay portal 6

This article will share one more feature: import and export Knowledge Base articles in Liferay portal 6 and 5.2 EE SP1 (or SP2 or SP3).

Introduction

As you can see, Liferay portal 6 provides features - archive portlet preferences, backup data as LAR. Knowledge base portlet can leverage same frameworks - configuration-action-class and portlet-data-handler-class as shown in following screenshot.

Meanwhile, capabilities in Knowledge based portlet are expected to import XML -based articles from third party systems and to export KB articles as XML files.

Archive, Export and Import as LAR

Abstracted from the book: Liferay Portal 6 Enterprise Intranets (coming out soon)

It would be nice that you could save these settings, and moreover, to revert these changes back to the original later. This feature can be achieved through Archive Setup In liferay portal 6. How to archive setup? You can do it in following steps.

  • Locate the portlet Message Boards in a page;
  • Go to More->Configuration->Setup->Archived;
  • Input archive name for current setup, e.g., “My MB”, and click on the Save button as shown in following screenshot.

Archive Setup

After creating an archive, you would be able to see archives with columns Name, User, Modified Date, and the icon Actions within Restore and Delete sub icons. Obviously, you can restore the setup via an archive or delete an archive.

Note that this feature is available for portlets which have the tab setup visible, since the portal specifies this function at portlet configuration archived_setup_action.jsp and edit_archived_setups.jsp under $TOMCAT_AS_DIR/webapps/ROOTPORTAL_ROOT_HOME/html/portlet/portlet_configuration. More details, archives are stored in portlet preferences of the portal instance. Thus you shouldn’t use it for backup from one portal instance to another portal instance. 

What’s happening? A portlet will have the setup tab under More->Configuration if the tag configuration-action-class is specified as follows in $TOMCAT_AS_DIR/webapps/ROOTPORTAL_ROOT_HOME/WEB-INF/liferay-portlet.xml.

<configuration-action-class>com.liferay.portlet.messageboards.action.ConfigurationActionImpl</configuration-action-class>

Fortunately you can use Export / Import feature for backup functions. The portal provides capability to export and import portlet specific data to a Liferay Archive file (LAR). As shown in following screenshot, you can export portlet Message Boards specific data to a LAR file.

Import and Export as LAR

Why does a portlet like Message Boards have Export / Import capability?  But other portlet like Hello World doesn’t have Export / Import capability.  The reason is that the portlet Message Boards has following setting what the portlet Hello World doesn’t have.

<portlet-data-handler-class>com.liferay.portlet.messageboards.lar.MBPortletDataHandlerImpl</portlet-data-handler-class>

The above code shows that the content could be backed up as a LAR file via the tag portlet-data-handler-class.

Note that in order to export / import data properly, versions of source portal instance and target portal instance should be completely same. Otherwise, you may meet migration issues.

What’re differences between archives and Export / Import? By the feature of Export / Import, you could export LAR from one portal server and import it into another portal server, as long as the two portal servers are running the same version; by the feature Archive, only one portal instance is involved.  The main difference is: Archives backup setup configuration whereas LAR contains data.  

Export and Import as XML files

You may have thousands of articles like Questions & Answers in third party systems. Now you are planning to import these articles into Liferay portal Knowledge base portlets. You could take following steps as shown in following figure.

  • Transform XML file using XSL into DocBook format.
  • Import articles in DocBook format into Knowledge base portlets;
  • Add multiple-language info in these articles.

Import articles

Similarly, you may have thousands of KB articles. Now you are planning to export these articles into third party systems like XML files. You could take following steps as shown in following figure.

  • Transform KB Articles into DocBook format.
  • Export articles in DocBook format in XML file;
  • Add multiple-language info in XML files.

Export articles

Examples

 For instance, you have an article Question & Answer like following:

<?xml version="1.0" encoding="utf-8" ?>
<Report>
  <Field>Infoco Answer Export Tool</Field>
 <Row>
  <Item />
  <Item>Id</Item>
  <Item>Summary</Item>
  <Item>Question</Item>
  <Item>Answer</Item>
  <Item>Product</Item>
  <Item>Sub-Product</Item>
  <Item>Language-Locale</Item>
  </Row
<Row>
  <Item>1</Item>
  <Item>17</Item>
  <Item>Panagon Password Resets</Item>
  <Item><font face="Arial, Helvetica" size="2">Panagon Password Resets</font></Item>
  <Item><font face="Arial, Helvetica" size="2">Jill Parsons or John Stirrup can reset Panagon Passwords.<br />They recommend emailing both of them to ensure that the request is picked up as quickly as possible.</font></Item>
  <Item>Unilever Applications</Item>
  <Item>Other</Item>
  </Row>
</Report>

Using importing mechanism, you can transform above article into DocBook format as follows. 

<?xml version='1.0' ?>
<book>
  <bookinfo>
    <chapter>
      <title>Answer ID: 17</title>
      <section>
        <title>Summary</title>
        <para>Panagon Password Resets</para>
      </section>
      <section>
        <title>Question</title>
        <para>Panagon Password Resets</para>
      </section>
      <section>
        <title>Answer</title>
        <para>Jill Parsons or John Stirrup can reset Panagon Passwords.<br />They recommend emailing both of them to ensure that the request is picked up as quickly as possible.</para>
      </section>
      <section>
        <title>Product</title>
        <para>Unilever Applications</para>
      </section>
      <section>
        <title>Sub-Product</title>
        <para>Other</para>
      </section>
      <section>
        <title>Language-Locale</title>
        <para>en_US</para>
      </section>
    </chapter>
  </bookinfo>
</book>

Then map DocBook into KB articles as follows

DocBook <-> KB Article Metadata

  • Summary <-> Description
  • Question <-> Title
  • Answer <-> Content
  • Products <-> Categories
  • Sub-Product <-> Categories

Using exporting mechanism, you can export KB articles into DocBook and moreover save them as XML files.

Screenshot - Import and Export in Liferay 5.2 EE (SP1 and SP2 and SP3):

 

Summary

As you can see, importing and exporting Knowledge Base articles are useful. Isn't it? That is, you can import articles from third party systems into Liferay portal as Knowledge base articles; or you can export any Knowledge base articles in Liferay portal to third party systems.

Last but not least, I'd like to send special thanks to Robert Chen and Frank Yu who did an amazing job to make importing and exporting Knowledge base articles a reality.

Threaded Replies Author Date
I always enjoy your posts. Thank you. I am... Steve Wallace March 20, 2010 5:46 PM
Hi Steve, thank you. As planned, the new book... Jonas Yuan March 23, 2010 4:33 PM
Dear Jonas, I need a little help regarding KB... Mazhar Anwar March 22, 2010 3:13 AM
Hi Mazhar, Thanks. Which version of liferay... Jonas Yuan March 23, 2010 4:36 PM
[...] import to knowledge base ... seems like... Anonymous July 25, 2012 5:30 AM
what happened with the screenshots?? Marina Ra August 8, 2012 3:57 AM
Hi Marina, Thanks. The server with the... Jonas Yuan August 27, 2012 12:36 PM
Once again screenshots not showing. Does... yoeri smets February 28, 2013 7:39 AM
Hi Yoeri, have you solved this issue? I'm... Juanjo Hernández Cánovas September 30, 2013 7:12 AM
Hi Juanjo, If applicable, you may drop me an... Jonas Yuan September 30, 2013 9:23 AM
Thank you Jonas for this nice post. Somehow I... Gopal Agrawal February 28, 2014 4:20 AM

I always enjoy your posts. Thank you. I am looking forward to purchasing your new book. When do you think it will be out?
Posted on 3/20/10 5:46 PM.
Dear Jonas,

I need a little help regarding KB Portlet service classes(Service classes generated by Liferay service builder in plugins-sdk).
I want to use KB Portlet’s service API in another portlet. How can I use those classes and methods?

As per Liferay implementation, portal-service.jar and ext-service.jar are globally available to all the application.
And portlets developed in plugins-sdk are deployed as different application context, and service classes are not globally available.

What will be the best way to achieve it? Do we have to generate service classes again in new portlet pointing to same database(tables)?

I am sorry for posting this question here, but since it is very specific to KB portlet am posting this question here.

Regards,
Mazhar
Posted on 3/22/10 3:13 AM.
Hi Steve, thank you. As planned, the new book Liferay Portal 6 Enterprise Intranets would be released at April.
Posted on 3/23/10 4:33 PM in reply to Steve Wallace.
Hi Mazhar, Thanks. Which version of liferay portal are you using? You may use KB directly or customize it as you expected.
Posted on 3/23/10 4:36 PM in reply to Mazhar Anwar.
[...] import to knowledge base ... seems like this is exactly what I was looking for. but how do I actually import an .xml or docbook file forma? Liferay won´t accept anything other than .lar files ... is... [...] Read More
Posted on 7/25/12 5:30 AM.
what happened with the screenshots??
Posted on 8/8/12 3:57 AM in reply to .
Hi Marina,

Thanks. The server with the screenshots was down.
Posted on 8/27/12 12:36 PM in reply to Marina Ra.
Once again screenshots not showing.

Does anyone knows if thos lar's are compatible version wise ?
I want to import a 6.0.6 lar into a 6.1.1 version but it goes wrong (unexpected error has occred, not showing anything in the stacktrace of the glassfish server).....
Posted on 2/28/13 7:39 AM.
Hi Yoeri, have you solved this issue? I'm facing the same problem in a project.

Thanks in advanced,

Juanjo.
Posted on 9/30/13 7:12 AM in reply to yoeri smets.
Hi Juanjo,

If applicable, you may drop me an email jonasliferay@gmail.com for detailed requirements.
Posted on 9/30/13 9:23 AM in reply to Juanjo Hernández Cánovas.
Thank you Jonas for this nice post. Somehow I am not able to see the screenshots in the article. Could you please take a look?
Posted on 2/28/14 4:20 AM.