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.poller.api.WsApiDelegate Maven / Gradle / Ivy
package org.lockss.laaws.poller.api;
import org.lockss.laaws.poller.model.ErrorResult;
import org.lockss.ws.entities.HasherWsParams;
import org.lockss.ws.entities.PeerWsResult;
import org.lockss.ws.entities.PollWsResult;
import org.lockss.ws.entities.RepositorySpaceWsResult;
import org.lockss.ws.entities.RepositoryWsResult;
import org.springframework.core.io.Resource;
import org.lockss.ws.entities.VoteWsResult;
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 WsApiController}}.
* Implement this interface with a {@link org.springframework.stereotype.Service} annotated class.
*/
public interface WsApiDelegate {
Logger log = LoggerFactory.getLogger(WsApi.class);
default Optional getObjectMapper(){
return Optional.empty();
}
default Optional getRequest(){
return Optional.empty();
}
default Optional getAcceptHeader() {
return getRequest().map(r -> r.getHeader("Accept"));
}
/**
* @see WsApi#deleteHash
*/
default ResponseEntity deleteHash( String requestId) {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
if (getAcceptHeader().get().contains("application/json")) {
try {
return new ResponseEntity<>(getObjectMapper().get().readValue("\"\"", String.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 WsApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
/**
* @see WsApi#getAllHashes
*/
default ResponseEntity getAllHashes() {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
if (getAcceptHeader().get().contains("application/json")) {
try {
return new ResponseEntity<>(getObjectMapper().get().readValue("\"\"", Resource.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 WsApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
/**
* @see WsApi#getHash
*/
default ResponseEntity getHash( String requestId) {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
if (getAcceptHeader().get().contains("application/json")) {
try {
return new ResponseEntity<>(getObjectMapper().get().readValue("\"\"", Resource.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 WsApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
/**
* @see WsApi#getPeers
*/
default ResponseEntity> getPeers( String peerQuery) {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
if (getAcceptHeader().get().contains("application/json")) {
try {
return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\n \"peerId\" : \"peerId\"\n}, {\n \"peerId\" : \"peerId\"\n} ]", List.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 WsApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
/**
* @see WsApi#getPolls
*/
default ResponseEntity> getPolls( String pollQuery) {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
if (getAcceptHeader().get().contains("application/json")) {
try {
return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\n \"auId\" : \"auId\",\n \"auName\" : \"auName\"\n}, {\n \"auId\" : \"auId\",\n \"auName\" : \"auName\"\n} ]", List.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 WsApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
/**
* @see WsApi#getRepositories
*/
default ResponseEntity> getRepositories( String repositoryQuery) {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
if (getAcceptHeader().get().contains("application/json")) {
try {
return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\n \"repositorySpaceId\" : \"repositorySpaceId\"\n}, {\n \"repositorySpaceId\" : \"repositorySpaceId\"\n} ]", List.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 WsApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
/**
* @see WsApi#getRepositorySpaces
*/
default ResponseEntity> getRepositorySpaces( String repositorySpaceQuery) {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
if (getAcceptHeader().get().contains("application/json")) {
try {
return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\n \"repositorySpaceId\" : \"repositorySpaceId\"\n}, {\n \"repositorySpaceId\" : \"repositorySpaceId\"\n} ]", List.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 WsApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
/**
* @see WsApi#getVotes
*/
default ResponseEntity> getVotes( String voteQuery) {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
if (getAcceptHeader().get().contains("application/json")) {
try {
return new ResponseEntity<>(getObjectMapper().get().readValue("[ {\n \"auId\" : \"auId\",\n \"auName\" : \"auName\"\n}, {\n \"auId\" : \"auId\",\n \"auName\" : \"auName\"\n} ]", List.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 WsApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
/**
* @see WsApi#putHash
*/
default ResponseEntity putHash( HasherWsParams body,
Boolean isAsynchronous) {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
if (getAcceptHeader().get().contains("application/json")) {
try {
return new ResponseEntity<>(getObjectMapper().get().readValue("\"\"", Resource.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 WsApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
/**
* @see WsApi#putImportFile
*/
default ResponseEntity putImportFile( String targetBaseUrlPath,
String targetUrl,
MultipartFile file,
List userProperties) {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
} else {
log.warn("ObjectMapper or HttpServletRequest not configured in default WsApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
}