Newer
Older
IrisServer / src / main / java / com / ntlab / irisserver / resources / KeywordsRest.java
package com.ntlab.irisserver.resources;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import com.ntlab.irisserver.models.KeywordManager;


import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.io.IOException;


@Component
@Path("/keywords")

public class KeywordsRest implements ApplicationContextAware {

    private ApplicationContext applicationContext;

    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public String[] getKeywords() throws IOException {

        String path;
        path = applicationContext.getResource("file:").getFile().getAbsolutePath()+"/apache-tomcat-9.0.10/webapps/irisdata/keywords.txt";
        KeywordManager km = KeywordManager.getInstance();

        return km.getKeywords(path);
    }

}