Customizing portlet export

thumbnail
Steve Weiss, modified 10 Months ago. Regular Member Posts: 112 Join Date: 9/20/11 Recent Posts

I need to execute some code in a custom portlet when a user exports the portlet. I've added the following to liferay-portlet.xml:

  <!-- For export/import -->
  <portlet>
    <portlet-name>gov_nasa_hq_sqlreporter_portlet_SqlReporterPortlet</portlet-name>
    <portlet-data-handler-class>gov.nasa.hq.sqlreporter.portlet.SqlReporterExportImportLifecycleListener</portlet-data-handler-class>
  </portlet>

And I've create this class:

package gov.nasa.hq.sqlreporter.portlet;

import java.io.Serializable;
import java.util.List;

import com.liferay.exportimport.kernel.lifecycle.ExportImportLifecycleEvent;
import com.liferay.exportimport.kernel.lifecycle.ExportImportLifecycleListener;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;

public class SqlReporterExportImportLifecycleListener implements ExportImportLifecycleListener {

    protected static Log _log = LogFactoryUtil.getLog(SqlReporterExportImportLifecycleListener.class);

    @Override
    public boolean isParallel() {
        // TODO Auto-generated method stub
        return false;
    }

    @Override
    public void onExportImportLifecycleEvent(ExportImportLifecycleEvent exportImportLifecycleEvent) throws Exception {

        String ID = "onExportImportLifecycleEvent: ";
        _log.info(ID + "ENTER");
        List<Serializable> attrlist = exportImportLifecycleEvent.getAttributes();
        for (Serializable attr : attrlist) {
            _log.info(ID + "attribute = " + attr.toString());
        }
    }

}

However, nothing is printed to the log when I do the export so I assume this isn't the correct way to implement this functionality. Can someone point me in the right direction? Thanks.

 

-Steve