All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.lockss.laaws.rs.api.AusApiDelegate Maven / Gradle / Ivy
package org.lockss.laaws.rs.api;
import org.lockss.util.rest.repo.model.ArtifactPageInfo;
import org.lockss.util.rest.repo.model.AuSize;
import org.lockss.util.rest.repo.model.AuidPageInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
* A delegate to be called by the {@link AusApiController}}.
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
*/
public interface AusApiDelegate {
Logger log = LoggerFactory.getLogger(AusApi.class);
default Optional getObjectMapper(){
return Optional.empty();
}
default Optional getRequest(){
return Optional.empty();
}
default Optional getAcceptHeader() {
return getRequest().map(r -> r.getHeader("Accept"));
}
/**
* @see AusApi#getArtifacts
*/
default ResponseEntity getArtifacts( String auid,
String namespace,
String url,
String urlPrefix,
String version,
Boolean includeUncommitted,
Integer limit,
String continuationToken) {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
if (getAcceptHeader().get().contains("application/json")) {
try {
return new ResponseEntity<>(getObjectMapper().get().readValue("{\n \"pageInfo\" : {\n \"curLink\" : \"curLink\",\n \"resultsPerPage\" : 5,\n \"totalCount\" : 5,\n \"continuationToken\" : \"continuationToken\",\n \"nextLink\" : \"nextLink\"\n },\n \"artifacts\" : [ {\n \"committed\" : true,\n \"auid\" : \"auid\",\n \"namespace\" : \"lockss\",\n \"contentLength\" : 6,\n \"storageUrl\" : \"storageUrl\",\n \"uuid\" : \"uuid\",\n \"uri\" : \"uri\",\n \"version\" : 0,\n \"collectionDate\" : 1,\n \"contentDigest\" : \"contentDigest\"\n }, {\n \"committed\" : true,\n \"auid\" : \"auid\",\n \"namespace\" : \"lockss\",\n \"contentLength\" : 6,\n \"storageUrl\" : \"storageUrl\",\n \"uuid\" : \"uuid\",\n \"uri\" : \"uri\",\n \"version\" : 0,\n \"collectionDate\" : 1,\n \"contentDigest\" : \"contentDigest\"\n } ]\n}", ArtifactPageInfo.class), HttpStatus.NOT_IMPLEMENTED);
} catch (IOException e) {
log.error("Couldn't serialize response for content type application/json", e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
} else {
log.warn("ObjectMapper or HttpServletRequest not configured in default AusApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
/**
* @see AusApi#getArtifactsSize
*/
default ResponseEntity getArtifactsSize( String auid,
String namespace) {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
if (getAcceptHeader().get().contains("application/json")) {
try {
return new ResponseEntity<>(getObjectMapper().get().readValue("{\n \"totalLatestVersions\" : 0,\n \"totalWarcSize\" : 1,\n \"totalAllVersions\" : 6\n}", AuSize.class), HttpStatus.NOT_IMPLEMENTED);
} catch (IOException e) {
log.error("Couldn't serialize response for content type application/json", e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
} else {
log.warn("ObjectMapper or HttpServletRequest not configured in default AusApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
/**
* @see AusApi#getAus
*/
default ResponseEntity getAus( String namespace,
Integer limit,
String continuationToken) {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
if (getAcceptHeader().get().contains("application/json")) {
try {
return new ResponseEntity<>(getObjectMapper().get().readValue("{\n \"pageInfo\" : {\n \"curLink\" : \"curLink\",\n \"resultsPerPage\" : 5,\n \"totalCount\" : 5,\n \"continuationToken\" : \"continuationToken\",\n \"nextLink\" : \"nextLink\"\n },\n \"auids\" : [ \"auids\", \"auids\" ]\n}", AuidPageInfo.class), HttpStatus.NOT_IMPLEMENTED);
} catch (IOException e) {
log.error("Couldn't serialize response for content type application/json", e);
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
}
} else {
log.warn("ObjectMapper or HttpServletRequest not configured in default AusApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
/**
* @see AusApi#handleBulkAuOp
*/
default ResponseEntity handleBulkAuOp( String auid,
String op,
String namespace) {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
} else {
log.warn("ObjectMapper or HttpServletRequest not configured in default AusApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
}