I am trying to make a hook for the Liferay announcements portlet using the following code:
package com.ahc.hook.service.impl;
import com.liferay.portlet.announcements.*;
public class MyAnnouncementsEntryLocalServiceImpl
extends AnnouncementsEntryLocalServiceBaseImpl {
protected void validate(String title, String content, String url) {
if (Validator.isNull(title)) {
throw new EntryTitleException();
}
if (Validator.isNull(content)) {
throw new EntryContentException();
}
if ((url.length() > 0) && !Validator.isUrl(url)) {
throw new EntryURLException();
}
}
}
but I keep getting the following error:
[javac] Compiling 1 source file to /home/AHC/darryl.pinto/liferay/plugins/hooks/ahc-announcements-hook/docroot/WEB-INF/classes
[javac] /home/AHC/darryl.pinto/liferay/plugins/hooks/ahc-announcements-hook/docroot/WEB-INF/src/com/ahc/hook/service/impl/MyAnnouncementsEntryLocalServiceImpl.java:25: cannot find symbol
[javac] symbol: class AnnouncementsEntryLocalServiceBaseImpl extends AnnouncementsEntryLocalServiceBaseImpl {
[javac] ^
I have a feeling I’m missing something for the extends section but I can’t figure out what
I’m using Liferay 6.0.5
Anyone got any ideas?
The *LocalServiceBaseImpl is not available to any hook as it’s part of the implementation. Instead, what you want is to inherit from a *Wrapper. See the documentation for overriding a service on what to do. This also contains some reasoning and explanation what’s available to you in the classloader your implementation is loaded in.