Zimlet and server http handler extension

Interested in talking about Mash-up's? This is the place.
Dinamots
Posts: 10
Joined: Wed May 29, 2019 8:03 am

Zimlet and server http handler extension

Postby Dinamots » Tue Jun 04, 2019 9:06 am

Hi,

I'm trying to use a zimlet that will send an http request to my server extension.

But, I don't know the endpoint !

Can someone explain me how I'm gonna call this endpoint ?
I know that it will be something like com_objectifpi_tasks/Tasks because of getName in TasksExtension and the getPath in the HttpHandler.

And can I have access to the server console to debug with System.out.println ?

Here is my code :

Code: Select all

public class TasksExtension implements ZimbraExtension {

    public void init() throws ServiceException {
        ExtensionDispatcherServlet.register(this, new HttpHandler());
    }

    public void destroy() {
        ExtensionDispatcherServlet.unregister(this);
    }

    public String getName() {
        return "com_objectifpi_tasks";
    }
}


Code: Select all

public class HttpHandler extends ExtensionHttpHandler {

    // the path under which MyHandler is registered
    public String getPath() {
        return super.getPath() + "/Tasks";
    }

    // override doGet or doPost or both as needed
    // it's your responsibility to authenticate/authorize the requests
    // sent to the handler

    public void init(ZimbraExtension ext) throws ServiceException {
        super.init(ext);    // make sure you call superclass's init method.
        // your initialization
    }

    @Override
    public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException {
        resp.sendError(200);
        resp.getWriter().write("it works :) ");
        resp.getWriter().flush();
        resp.getWriter().close();
    }
}


I followed the extensions.md in my server files

Thx for your help.


Dinamots
Posts: 10
Joined: Wed May 29, 2019 8:03 am

Re: Zimlet and server http handler extension

Postby Dinamots » Wed Jun 05, 2019 1:17 pm

I found that any endpoint created with a zimbra extension will have /service/extension at the beggining of the path

Return to “Zimlets”

Who is online

Users browsing this forum: No registered users and 1 guest