/**
* =============================================================================
*
* ORCID (R) Open Source
* http://orcid.org
*
* Copyright (c) 2012-2014 ORCID, Inc.
* Licensed under an MIT-Style License (MIT)
* http://orcid.org/open-source-license
*
* This copyright and license information (including a link to the full license)
* shall be included in its entirety in all copies or substantial portion of
* the software.
*
* =============================================================================
*/
package org.orcid.api.publicV2.server;
import static org.orcid.core.api.OrcidApiConstants.ACTIVITIES;
import static org.orcid.core.api.OrcidApiConstants.ADDRESS;
import static org.orcid.core.api.OrcidApiConstants.BIOGRAPHY;
import static org.orcid.core.api.OrcidApiConstants.CLIENT_PATH;
import static org.orcid.core.api.OrcidApiConstants.EDUCATION;
import static org.orcid.core.api.OrcidApiConstants.EDUCATIONS;
import static org.orcid.core.api.OrcidApiConstants.EDUCATION_SUMMARY;
import static org.orcid.core.api.OrcidApiConstants.EMAIL;
import static org.orcid.core.api.OrcidApiConstants.EMPLOYMENT;
import static org.orcid.core.api.OrcidApiConstants.EMPLOYMENTS;
import static org.orcid.core.api.OrcidApiConstants.EMPLOYMENT_SUMMARY;
import static org.orcid.core.api.OrcidApiConstants.EXTERNAL_IDENTIFIERS;
import static org.orcid.core.api.OrcidApiConstants.FUNDING;
import static org.orcid.core.api.OrcidApiConstants.FUNDINGS;
import static org.orcid.core.api.OrcidApiConstants.FUNDING_SUMMARY;
import static org.orcid.core.api.OrcidApiConstants.KEYWORDS;
import static org.orcid.core.api.OrcidApiConstants.ORCID_JSON;
import static org.orcid.core.api.OrcidApiConstants.ORCID_XML;
import static org.orcid.core.api.OrcidApiConstants.OTHER_NAMES;
import static org.orcid.core.api.OrcidApiConstants.PEER_REVIEW;
import static org.orcid.core.api.OrcidApiConstants.PEER_REVIEWS;
import static org.orcid.core.api.OrcidApiConstants.PEER_REVIEW_SUMMARY;
import static org.orcid.core.api.OrcidApiConstants.PERSON;
import static org.orcid.core.api.OrcidApiConstants.PERSONAL_DETAILS;
import static org.orcid.core.api.OrcidApiConstants.PUTCODE;
import static org.orcid.core.api.OrcidApiConstants.RECORD;
import static org.orcid.core.api.OrcidApiConstants.RESEARCHER_URLS;
import static org.orcid.core.api.OrcidApiConstants.SEARCH_PATH;
import static org.orcid.core.api.OrcidApiConstants.STATUS_PATH;
import static org.orcid.core.api.OrcidApiConstants.VND_ORCID_JSON;
import static org.orcid.core.api.OrcidApiConstants.VND_ORCID_XML;
import static org.orcid.core.api.OrcidApiConstants.WORK;
import static org.orcid.core.api.OrcidApiConstants.WORKS;
import static org.orcid.core.api.OrcidApiConstants.WORK_SUMMARY;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import org.orcid.api.common.swagger.SwaggerUIBuilder;
import org.orcid.api.publicV2.server.delegator.PublicV2ApiServiceDelegator;
import org.orcid.core.api.OrcidApiConstants;
import org.orcid.jaxb.model.groupid_rc1.GroupIdRecord;
import org.orcid.jaxb.model.message.ScopeConstants;
import org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary;
import org.orcid.jaxb.model.record.summary_rc4.EducationSummary;
import org.orcid.jaxb.model.record.summary_rc4.Educations;
import org.orcid.jaxb.model.record.summary_rc4.EmploymentSummary;
import org.orcid.jaxb.model.record.summary_rc4.FundingSummary;
import org.orcid.jaxb.model.record.summary_rc4.Fundings;
import org.orcid.jaxb.model.record.summary_rc4.PeerReviewSummary;
import org.orcid.jaxb.model.record.summary_rc4.PeerReviews;
import org.orcid.jaxb.model.record.summary_rc4.WorkSummary;
import org.orcid.jaxb.model.record.summary_rc4.Works;
import org.orcid.jaxb.model.record_rc4.Education;
import org.orcid.jaxb.model.record_rc4.Employment;
import org.orcid.jaxb.model.record_rc4.Funding;
import org.orcid.jaxb.model.record_rc4.OtherName;
import org.orcid.jaxb.model.record_rc4.PeerReview;
import org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier;
import org.orcid.jaxb.model.record_rc4.ResearcherUrl;
import org.orcid.jaxb.model.record_rc4.Work;
import org.springframework.beans.factory.annotation.Value;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.Authorization;
import io.swagger.annotations.AuthorizationScope;
import io.swagger.annotations.ExternalDocs;
/**
*
* @author Angel Montenegro
*
*/
@Path("/v2.0_rc4")
public class PublicV2ApiServiceImplV2_0_rc4 {
protected PublicV2ApiServiceDelegator<Education, Employment, PersonExternalIdentifier, Funding, GroupIdRecord, OtherName, PeerReview, ResearcherUrl, Work> serviceDelegator;
@Value("${org.orcid.core.baseUri}")
protected String baseUri;
@Value("${org.orcid.core.pubBaseUri}")
protected String pubBaseUri;
public void setServiceDelegator(
PublicV2ApiServiceDelegator<Education, Employment, PersonExternalIdentifier, Funding, GroupIdRecord, OtherName, PeerReview, ResearcherUrl, Work> serviceDelegator) {
this.serviceDelegator = serviceDelegator;
}
/**
* Serves the Swagger UI HTML page
*
* @return a 200 response containing the HTML
*/
@GET
@Produces(value = { MediaType.TEXT_HTML })
@Path("/")
@ApiOperation(value = "Fetch the HTML swagger UI interface", hidden = true)
public Response viewSwagger() {
return new SwaggerUIBuilder().buildSwaggerHTML(baseUri, pubBaseUri, false);
}
@GET
@Produces(value = { MediaType.TEXT_PLAIN })
@Path(STATUS_PATH)
@ApiOperation(value = "Check the server status", response = String.class)
public Response viewStatusText() {
return serviceDelegator.viewStatusText();
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(ACTIVITIES)
@ApiOperation(value = "Fetch all Activities", response = ActivitiesSummary.class)
public Response viewActivities(@PathParam("orcid") String orcid, @Context HttpServletRequest httpRequest) {
return serviceDelegator.viewActivities(orcid);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON,
OrcidApiConstants.APPLICATION_CITEPROC })
@Path(WORK + PUTCODE)
@ApiOperation(value = "Fetch a Work", notes = "More notes about this method", response = Work.class)
public Response viewWork(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode, @Context HttpServletRequest httpRequest) {
if (OrcidApiConstants.APPLICATION_CITEPROC.equals(httpRequest.getHeader("Accept")))
return serviceDelegator.viewWorkCitation(orcid, putCode);
return serviceDelegator.viewWork(orcid, putCode);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(WORK_SUMMARY + PUTCODE)
@ApiOperation(value = "Fetch a Work Summary", response = WorkSummary.class)
public Response viewWorkSummary(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
return serviceDelegator.viewWorkSummary(orcid, putCode);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(WORKS)
@ApiOperation(value = "Fetch all works", response = Works.class)
public Response viewWorks(@PathParam("orcid") String orcid) {
return serviceDelegator.viewWorks(orcid);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(FUNDING + PUTCODE)
@ApiOperation(value = "Fetch a Funding", response = Funding.class)
public Response viewFunding(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
return serviceDelegator.viewFunding(orcid, putCode);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(FUNDING_SUMMARY + PUTCODE)
@ApiOperation(value = "Fetch a Funding Summary", response = FundingSummary.class)
public Response viewFundingSummary(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
return serviceDelegator.viewFundingSummary(orcid, putCode);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(FUNDINGS)
@ApiOperation(value = "Fetch all fundings", response = Fundings.class)
public Response viewFundings(@PathParam("orcid") String orcid) {
return serviceDelegator.viewFundings(orcid);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(EDUCATION + PUTCODE)
@ApiOperation(value = "Fetch an Education", response = Education.class)
public Response viewEducation(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
return serviceDelegator.viewEducation(orcid, putCode);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(EDUCATION_SUMMARY + PUTCODE)
@ApiOperation(value = "Fetch an Education Summary", response = EducationSummary.class)
public Response viewEducationSummary(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
return serviceDelegator.viewEducationSummary(orcid, putCode);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(EDUCATIONS)
@ApiOperation(value = "Fetch all educations", response = Educations.class)
public Response viewEducations(@PathParam("orcid") String orcid) {
return serviceDelegator.viewEducations(orcid);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(EMPLOYMENT + PUTCODE)
@ApiOperation(value = "Fetch an Employment", notes = "Retrive a specific education representation", response = Employment.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = "Employment found", response = Employment.class),
@ApiResponse(code = 404, message = "Employment not found") })
public Response viewEmployment(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
return serviceDelegator.viewEmployment(orcid, putCode);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(EMPLOYMENT_SUMMARY + PUTCODE)
@ApiOperation(value = "Fetch an Employment Summary", response = EmploymentSummary.class)
public Response viewEmploymentSummary(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
return serviceDelegator.viewEmploymentSummary(orcid, putCode);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(EMPLOYMENTS)
@ApiOperation(value = "Fetch all employments", response = Fundings.class)
public Response viewEmployments(@PathParam("orcid") String orcid) {
return serviceDelegator.viewEmployments(orcid);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(PEER_REVIEW + PUTCODE)
@ApiOperation(value = "Fetch a Peer Review", response = PeerReview.class)
public Response viewPeerReview(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
return serviceDelegator.viewPeerReview(orcid, putCode);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(PEER_REVIEW_SUMMARY + PUTCODE)
@ApiOperation(value = "Fetch a Peer Review Summary", response = PeerReviewSummary.class)
public Response viewPeerReviewSummary(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
return serviceDelegator.viewPeerReviewSummary(orcid, putCode);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(PEER_REVIEWS)
@ApiOperation(value = "Fetch all peer reviews", response = PeerReviews.class)
public Response viewPeerReviews(@PathParam("orcid") String orcid) {
return serviceDelegator.viewPeerReviews(orcid);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(RESEARCHER_URLS)
@ApiOperation(value = "Fetch all researcher urls for an ORCID ID")
public Response viewResearcherUrls(@PathParam("orcid") String orcid) {
return serviceDelegator.viewResearcherUrls(orcid);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(RESEARCHER_URLS + PUTCODE)
@ApiOperation(value = "Fetch one researcher url for an ORCID ID")
public Response viewResearcherUrl(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) {
return serviceDelegator.viewResearcherUrl(orcid, Long.valueOf(putCode));
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(EMAIL)
@ApiOperation(value = "Fetch all emails for an ORCID ID")
public Response viewEmails(@PathParam("orcid") String orcid) {
return serviceDelegator.viewEmails(orcid);
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(PERSONAL_DETAILS)
@ApiOperation(value = "Fetch personal details for an ORCID ID")
public Response viewPersonalDetails(@PathParam("orcid") String orcid) {
return serviceDelegator.viewPersonalDetails(orcid);
}
@GET
@Path(OTHER_NAMES)
@ApiOperation(value = "Fetch Other names")
public Response viewOtherNames(@PathParam("orcid") String orcid) {
return serviceDelegator.viewOtherNames(orcid);
}
@GET
@Path(OTHER_NAMES + PUTCODE)
@ApiOperation(value = "Fetch Other name")
public Response viewOtherName(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) {
return serviceDelegator.viewOtherName(orcid, Long.valueOf(putCode));
}
@GET
@Path(EXTERNAL_IDENTIFIERS)
@ApiOperation(value = "Fetch external identifiers", authorizations = {
@Authorization(value = "orcid_two_legs", scopes = { @AuthorizationScope(scope = ScopeConstants.PERSON_READ_LIMITED, description = "you need this") }) })
public Response viewExternalIdentifiers(@PathParam("orcid") String orcid) {
return serviceDelegator.viewExternalIdentifiers(orcid);
}
@GET
@Path(EXTERNAL_IDENTIFIERS + PUTCODE)
@ApiOperation(value = "Fetch external identifier")
public Response viewExternalIdentifier(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) {
return serviceDelegator.viewExternalIdentifier(orcid, Long.valueOf(putCode));
}
@GET
@Path(KEYWORDS)
@ApiOperation(value = "Fetch keywords")
public Response viewKeywords(@PathParam("orcid") String orcid) {
return serviceDelegator.viewKeywords(orcid);
}
@GET
@Path(KEYWORDS + PUTCODE)
@ApiOperation(value = "Fetch keyword")
public Response viewKeyword(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) {
return serviceDelegator.viewKeyword(orcid, Long.valueOf(putCode));
}
@GET
@Path(ADDRESS)
@ApiOperation(value = "Fetch all addresses")
public Response viewAddresses(@PathParam("orcid") String orcid) {
return serviceDelegator.viewAddresses(orcid);
}
@GET
@Path(ADDRESS + PUTCODE)
@ApiOperation(value = "Fetch an address")
public Response viewAddress(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) {
return serviceDelegator.viewAddress(orcid, Long.valueOf(putCode));
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(BIOGRAPHY)
@ApiOperation(value = "Get biography details")
public Response viewBiography(@PathParam("orcid") String orcid) {
return serviceDelegator.viewBiography(orcid);
}
@GET
@Path(PERSON)
@ApiOperation(value = "Fetch person details")
public Response viewPerson(@PathParam("orcid") String orcid) {
return serviceDelegator.viewPerson(orcid);
}
//Record
@GET
@Path(RECORD)
@ApiOperation(value = "Fetch record details")
@ExternalDocs(value = "Record XML Schema", url = "https://raw.githubusercontent.com/ORCID/ORCID-Source/master/orcid-model/src/main/resources/record_2.0_rc4/record-2.0_rc4.xsd")
public Response viewRecord(@PathParam("orcid") String orcid) {
return serviceDelegator.viewRecord(orcid);
}
@GET
@Produces(value = { VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(SEARCH_PATH)
@ApiOperation(value = "Search records")
@ExternalDocs(value = "Record XML Schema", url = "https://raw.githubusercontent.com/ORCID/ORCID-Source/master/orcid-model/src/main/resources/record_2.0_rc4/search-2.0_rc4.xsd")
public Response searchByQueryJSON(@QueryParam("q") @DefaultValue("") String query, @Context UriInfo uriInfo) {
Map<String, List<String>> solrParams = uriInfo.getQueryParameters();
Response jsonQueryResults = serviceDelegator.searchByQuery(solrParams);
return jsonQueryResults;
}
@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML })
@Path(SEARCH_PATH)
@ApiOperation(value = "Search records")
@ExternalDocs(value = "Record XML Schema", url = "https://raw.githubusercontent.com/ORCID/ORCID-Source/master/orcid-model/src/main/resources/record_2.0_rc4/search-2.0_rc4.xsd")
public Response searchByQueryXML(@QueryParam("q") @DefaultValue("") String query, @Context UriInfo uriInfo) {
Map<String, List<String>> solrParams = uriInfo.getQueryParameters();
Response xmlQueryResults = serviceDelegator.searchByQuery(solrParams);
return xmlQueryResults;
}
@GET
@Path(CLIENT_PATH)
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@ApiOperation(value = "Fetch client details")
@ExternalDocs(value = "Record XML Schema", url = "https://raw.githubusercontent.com/ORCID/ORCID-Source/master/orcid-model/src/main/resources/record_2.0_rc4/client-2.0_rc4.xsd")
public Response viewClient(@PathParam("client_id") String clientId) {
return serviceDelegator.viewClient(clientId);
}
}