46 lines
1.7 KiB
Java
46 lines
1.7 KiB
Java
package eu.dnetlib.data.mdstore.manager.controller;
|
|
|
|
import java.io.IOException;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
import eu.dnetlib.data.mdstore.manager.exceptions.MDStoreManagerException;
|
|
import eu.dnetlib.data.mdstore.manager.utils.ControllerUtils;
|
|
import eu.dnetlib.data.mdstore.manager.utils.ZeppelinClient;
|
|
import eu.dnetlib.data.mdstore.manager.utils.zeppelin.Note;
|
|
|
|
@Controller
|
|
@RequestMapping("/zeppelin")
|
|
public class ZeppelinController {
|
|
|
|
@Autowired
|
|
private ZeppelinClient zeppelinClient;
|
|
|
|
@RequestMapping("/{mdId}/go")
|
|
public String goToZeppelin(@PathVariable final String mdId) throws IOException, MDStoreManagerException {
|
|
final Note note = zeppelinClient.generateNote(mdId);
|
|
final String url = zeppelinClient.submitNode(note);
|
|
return "redirect:" + url;
|
|
}
|
|
|
|
@RequestMapping("/{mdId}/note")
|
|
public @ResponseBody Note showNote(@PathVariable final String mdId) throws IOException, MDStoreManagerException {
|
|
return zeppelinClient.generateNote(mdId);
|
|
}
|
|
|
|
@ExceptionHandler(Exception.class)
|
|
@ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
|
|
public ModelAndView handleException(final Exception e) {
|
|
return ControllerUtils.errorPage("Metadata Store Manager - Zeppelin Client", e);
|
|
}
|
|
|
|
}
|