New Rest API in Rest Extender not working in Liferay

180 Views Asked by At

I have Create one module of type rest in Liferay7 Community Edition. The one application class created with some predefined rest-api.I have written my own api.but the api written by me are not working only predefined api are working. Please find my code below:

package com.codemaster.application;

import java.util.Collections;
import java.util.Set;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Application;

import org.osgi.service.component.annotations.Component;


@ApplicationPath("/greetings")
@Component(immediate = true, service = Application.class)
public class ClickRestApplication extends Application {

    public Set<Object> getSingletons() {
        return Collections.<Object>singleton(this);
    }

    @GET
    @Produces("text/plain")
    public String working() {
        return "It works!";
    }

    @GET
    @Path("/morning")
    @Produces("text/plain")
    public String hello() {
        return "Good morning!";
    }

    @GET
    @Path("/morning/{name}")
    @Produces("text/plain")
    public String morning(
        @PathParam("name") String name,
        @QueryParam("drink") String drink) {

        String greeting = "Good Morning " + name;

        if (drink != null) {
            greeting += ". Would you like some " + drink + "?";
        }

        return greeting;
    }
    
    @GET
    @Path("/demo")
    @Produces("text/plain")
    public String verify() {
        return "Verify User!";
    }

    @GET
    @Path("/dummy")
    @Produces("text/plain")
    public String dummy()
    {
        return "Dummy Response";
    }
}

What is the issue in my code?

0

There are 0 best solutions below