sshoc-citationservice/src/main/java/eu/sshoc/citation/service/services/CitationHarvester.java

98 lines
4.2 KiB
Java

package eu.sshoc.citation.service.services;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import java.util.Properties;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import eu.sshoc.citation.service.wfconfigurator.impl.CitationHarvesterImpl;
import io.swagger.annotations.ApiOperation;
/**
*
* @author Cesare
*
*/
@RestController
public class CitationHarvester {
Properties property = new Properties();
CitationHarvesterImpl wfc= new CitationHarvesterImpl();
public CitationHarvester() {
super();
/*InputStream in;
try {
in = this.getClass().getClassLoader()
.getResourceAsStream("Settings.properties");
property.load(in);
in.close();
} catch (FileNotFoundException e) {
} catch (IOException e) {
}*/
}
@ApiOperation(value = "Returns a list of citations from specific citation source (implementation in progress)",
notes = "A client with a valid identifier can invoke this web service to obtain a list of citations from a specified source",
response = String.class)
@RequestMapping(value="/citharvester/getcitationlist", method=RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public String getCitationList(@RequestParam(value="sourceid") String sourceid, @RequestParam(value="token") String token) {
return wfc.getCitationList(sourceid, token);
}
@ApiOperation(value = "Retrieves the metadata of a citation via the API of the specified DOI Registration Agency",
notes = "A client with a valid identifier can invoke this web service to retrieve the citation metadata using the API provided by the DOI Registration Agency",
response = String.class)
@RequestMapping(value="/citharvester/getmetadataapi", method=RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public String getCitation(@RequestParam(value="doira") String sourceid, @RequestParam(value="pid") String pid, @RequestParam(value="token") String token) {
return wfc.getCitation(sourceid, pid, token).toString();
}
@ApiOperation(value = "Returns a metadata record of a citation via Content Negotiated requests",
notes = "A client with a valid identifier can invoke this web service to to retrieve the citation metadata using DOI content negotiated requests",
response = String.class)
@RequestMapping(value="/citharvester/getmetadatacn", method=RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public String getCitationMD(@RequestParam(value="pid") String pid, @RequestParam(value="token") String token) {
return wfc.getCitationMetadata(pid, token).toString();
}
@ApiOperation(value = "Returns formatted citation using content negotiated requests",
notes = "A client with a valid identifier can invoke this web service to obtain a formatted citation, the text/bibliography content type is used ",
response = String.class)
@RequestMapping(value="/citharvester/getformcit", method=RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public String getCitationCSL(@RequestParam(value="pid") String pid, @RequestParam(value="token") String token) {
return wfc.getCitationCSL(pid, token).toString();
}
@ApiOperation(value = "Returns a metadata record for a citation searching in the landing page and on metadata repositories",
notes = "A client with a valid identifier can invoke this web service to obtain metadata of a citation by searching in metadata repositories and in landing pages",
response = String.class)
@RequestMapping(value="/citharvester/getcitationmetadata", method=RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public String getCitationMetadata(@RequestParam(value="pid") String pid, @RequestParam(value="token") String token) {
return wfc.getCitationMetadataFromHTML(pid, token).toString();
}
}