<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Intercept checkout of DLFileEntry with model listener</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=113000310" />
  <subtitle>Intercept checkout of DLFileEntry with model listener</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=113000310</id>
  <updated>2026-04-03T20:22:54Z</updated>
  <dc:date>2026-04-03T20:22:54Z</dc:date>
  <entry>
    <title>RE: Intercept checkout of DLFileEntry with model listener</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114405264" />
    <author>
      <name>Andrew Jardine</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114405264</id>
    <updated>2019-07-24T11:42:51Z</updated>
    <published>2019-07-24T11:42:51Z</published>
    <summary type="html">Hey David,If you are already using a service wrapper, then why can&amp;#39;t you continue to use it for this scenario? Perhaps I am missing something -- can you give me a little more detail (maybe the scenario and execution steps if it&amp;#39;s not too much to list out) so that I can better understand the problem you are trying to solve?</summary>
    <dc:creator>Andrew Jardine</dc:creator>
    <dc:date>2019-07-24T11:42:51Z</dc:date>
  </entry>
  <entry>
    <title>RE: Intercept checkout of DLFileEntry with model listener</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114401466" />
    <author>
      <name>David Bonomels Bonomels</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=114401466</id>
    <updated>2019-07-24T09:24:30Z</updated>
    <published>2019-07-24T09:24:30Z</published>
    <summary type="html">Hi Andrew, sorry about the late of my response. &lt;br /&gt;The problem is that I already use the methods of DLFileEntryLocalService, but for certain reason I need to use the listener for some updates. So when I receive this event I must be sure that is an update of the document  and not the creation of a PWC version from the checkout operations.</summary>
    <dc:creator>David Bonomels Bonomels</dc:creator>
    <dc:date>2019-07-24T09:24:30Z</dc:date>
  </entry>
  <entry>
    <title>RE: Intercept checkout of DLFileEntry with model listener</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113081098" />
    <author>
      <name>Andrew Jardine</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113081098</id>
    <updated>2019-04-09T02:44:45Z</updated>
    <published>2019-04-09T02:44:45Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hey David,&amp;nbsp;&lt;br&gt;&lt;br&gt;Not sure if you are stiull stuck on this or not so I thought I might reply all the same. Model listeners are among my favourite things to use, but sometimes it can be confusing to decide between a model listener or a service wrapper. The rule of thumb that I try to use is IF the thing I am changing has a cascading effect on other models in my system, then I use a model listener. If I am trying to intercept the thing that is itself changing then I try to intercept with either a Command override (if there is one) or a ServiceWrapper.&amp;nbsp;&lt;br&gt;&lt;br&gt;In your case, I can see that the DLFileEntryLocalService has several checkout methods --&lt;pre&gt;&lt;code&gt;public DLFileVersion cancelCheckOut(long userId, long fileEntryId)
   throws PortalException;

public void checkInFileEntry(long userId, long fileEntryId,
   boolean majorVersion, String changeLog, ServiceContext serviceContext)
   throws PortalException;

public void checkInFileEntry(long userId, long fileEntryId,
   String lockUuid, ServiceContext serviceContext)
   throws PortalException;

public DLFileEntry checkOutFileEntry(long userId, long fileEntryId,
   long fileEntryTypeId, ServiceContext serviceContext)
   throws PortalException;

public DLFileEntry checkOutFileEntry(long userId, long fileEntryId,
   long fileEntryTypeId, String owner, long expirationTime,
   ServiceContext serviceContext) throws PortalException;

public DLFileEntry checkOutFileEntry(long userId, long fileEntryId,
   ServiceContext serviceContext) throws PortalException;

public DLFileEntry checkOutFileEntry(long userId, long fileEntryId,
   String owner, long expirationTime, ServiceContext serviceContext)
   throws PortalException;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;.. I would be inclined therefor to define a CustomDLFileEntryLocalServiceOverride class that uses the wrapper class and then @Override the methods you need to "intercept".&amp;nbsp;&lt;br&gt;&lt;br&gt;The added benefit here in that, in some cases, you will also have the ServiceContext that will contain a lot of details that you don't readily have available in the ModelListeners. That may not be advantageous for you in this case, but it's something to keep in mind because you may encounter scenarios where it is helpful.&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Andrew Jardine</dc:creator>
    <dc:date>2019-04-09T02:44:45Z</dc:date>
  </entry>
  <entry>
    <title>Intercept checkout of DLFileEntry with model listener</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113000309" />
    <author>
      <name>David Bonomels Bonomels</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=113000309</id>
    <updated>2019-04-04T08:24:56Z</updated>
    <published>2019-04-04T08:24:56Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Hi to everybody,&lt;br&gt;&lt;br&gt;I need to intercept the checkOut/checkIn operation on a DLFIleEntry. &lt;br&gt;&lt;br&gt;I tought to use a Listener like this but when I checkout a file, with debug I get "false" instead of expected "true" value!&lt;pre&gt;&lt;code&gt;public MyListener extends BaseModelListener&amp;lt;dlfileentry&amp;gt; {

    @Override
    public void onAfterUpdate(DLFileEntry model) throws ModelListenerException {
        model.isCheckedOut(); // this is false
    }

}
&amp;lt;/dlfileentry&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;Anyoune can help me?&lt;br&gt;&lt;br&gt;Thanks in advance!&lt;br&gt;David&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>David Bonomels Bonomels</dc:creator>
    <dc:date>2019-04-04T08:24:56Z</dc:date>
  </entry>
</feed>
