38 lines
1.3 KiB
Java
38 lines
1.3 KiB
Java
package eu.dnetlib.data.mdstore;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import eu.dnetlib.data.mdstore.hadoop.ZeppelinClient;
|
|
import eu.dnetlib.data.mdstore.model.MDStoreType;
|
|
import eu.dnetlib.data.mdstore.model.MDStoreVersion;
|
|
import eu.dnetlib.data.mdstore.model.MDStoreWithInfo;
|
|
import eu.dnetlib.errors.MDStoreManagerException;
|
|
|
|
@Controller
|
|
public class ZeppelinController {
|
|
|
|
@Autowired
|
|
private ZeppelinClient zeppelinClient;
|
|
|
|
@Autowired
|
|
private MDStoreService service;
|
|
|
|
@RequestMapping("/zeppelin/{mdId}/{note}")
|
|
public String goToZeppelin(@PathVariable final String mdId, final @PathVariable String note) throws MDStoreManagerException {
|
|
final MDStoreWithInfo mdstore = service.findMdStore(mdId);
|
|
if (mdstore.getType() == MDStoreType.HDFS) {
|
|
final String currentVersion = mdstore.getCurrentVersion();
|
|
final MDStoreVersion version = service.findVersion(currentVersion);
|
|
if (version.getParams().containsKey("hdfs_path")) {
|
|
final String path = version.getParams().get("hdfs_path") + "/store";
|
|
return "redirect:" + zeppelinClient.zeppelinNote(note, mdstore, path);
|
|
}
|
|
}
|
|
throw new MDStoreManagerException();
|
|
}
|
|
|
|
}
|