2020-09-29 11:34:31 +02:00
|
|
|
package eu.dnetlib.organizations.controller;
|
|
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
import org.apache.commons.logging.Log;
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import eu.dnetlib.organizations.utils.DatabaseUtils;
|
|
|
|
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/oa_api")
|
|
|
|
public class OpenaireInternalApiController {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private DatabaseUtils databaseUtils;
|
|
|
|
|
|
|
|
@Value("${openaire.api.https.proxy}")
|
|
|
|
private String httpsProxy;
|
|
|
|
|
|
|
|
private static final Log log = LogFactory.getLog(OpenaireInternalApiController.class);
|
|
|
|
|
2020-10-09 16:00:12 +02:00
|
|
|
@GetMapping("/import/dedupEvents")
|
|
|
|
public List<String> importDedupEvents(final HttpServletRequest req) {
|
2020-09-29 11:34:31 +02:00
|
|
|
if (req.getRemoteAddr().equals(httpsProxy)) {
|
|
|
|
log.warn("Call received by blaklisted ip (https proxy): " + req.getRemoteAddr());
|
|
|
|
throw new RuntimeException("Call received by blaklisted ip (https proxy): " + req.getRemoteAddr());
|
|
|
|
}
|
2020-10-14 16:28:00 +02:00
|
|
|
new Thread(databaseUtils::importDedupEvents).start();
|
|
|
|
|
2020-09-29 11:34:31 +02:00
|
|
|
return Arrays.asList("Importing simrels (request from " + req.getRemoteAddr() + ") ...");
|
|
|
|
}
|
|
|
|
}
|