fixes for sonarqube

This commit is contained in:
Jörg Prante 2016-11-10 15:32:39 +01:00
parent 3d79ba0650
commit cd31542138
30 changed files with 147 additions and 237 deletions

View file

@ -11,12 +11,16 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Client OAI request
*/
public class ClientOAIRequest implements OAIRequest {
private static final Logger logger = Logger.getLogger(ClientOAIRequest.class.getName());
private URIBuilder uriBuilder;
private DateTimeFormatter dateTimeFormatter;
@ -44,6 +48,7 @@ public class ClientOAIRequest implements OAIRequest {
.authority(uri.getAuthority())
.path(uri.getPath());
} catch (URISyntaxException e) {
logger.log(Level.WARNING, e.getMessage(), e);
throw new IllegalArgumentException("invalid URI " + url);
}
}
@ -108,15 +113,16 @@ public class ClientOAIRequest implements OAIRequest {
return until;
}
@Override
public void setResumptionToken(ResumptionToken<?> token) {
this.token = token;
if (token != null && token.toString() != null) {
// resumption token may have characters that are illegal in URIs like '|'
//String tokenStr = URIFormatter.encode(token.toString(), StandardCharsets.UTF_8);
addParameter(OAIConstants.RESUMPTION_TOKEN_PARAMETER, token.toString());
}
}
@Override
public ResumptionToken<?> getResumptionToken() {
return token;
}

View file

@ -109,9 +109,9 @@ public class DefaultOAIClient implements OAIClient {
if (token == null) {
return null;
}
request = newIdentifyRequest();
request.setResumptionToken(token);
return request;
IdentifyRequest nextRequest = newIdentifyRequest();
nextRequest.setResumptionToken(token);
return nextRequest;
}
@Override
@ -123,9 +123,9 @@ public class DefaultOAIClient implements OAIClient {
if (token == null) {
return null;
}
request = newListRecordsRequest();
request.setResumptionToken(token);
return request;
ListRecordsRequest nextRequest = newListRecordsRequest();
nextRequest.setResumptionToken(token);
return nextRequest;
}
@Override
@ -137,9 +137,9 @@ public class DefaultOAIClient implements OAIClient {
if (token == null) {
return null;
}
request = newListIdentifiersRequest();
request.setResumptionToken(token);
return request;
ListIdentifiersRequest nextRequest = newListIdentifiersRequest();
nextRequest.setResumptionToken(token);
return nextRequest;
}
@Override
@ -151,9 +151,9 @@ public class DefaultOAIClient implements OAIClient {
if (token == null) {
return null;
}
request = newListMetadataFormatsRequest();
request.setResumptionToken(token);
return request;
ListMetadataFormatsRequest nextRequest = newListMetadataFormatsRequest();
nextRequest.setResumptionToken(token);
return nextRequest;
}
@Override
@ -165,9 +165,9 @@ public class DefaultOAIClient implements OAIClient {
if (token == null) {
return null;
}
request = newListSetsRequest();
request.setResumptionToken(token);
return request;
ListSetsRequest nextRequest = newListSetsRequest();
nextRequest.setResumptionToken(token);
return nextRequest;
}
@Override
@ -179,13 +179,13 @@ public class DefaultOAIClient implements OAIClient {
if (token == null) {
return null;
}
request = newGetRecordRequest();
request.setResumptionToken(token);
return request;
GetRecordRequest nextRequest = newGetRecordRequest();
nextRequest.setResumptionToken(token);
return nextRequest;
}
@Override
public void close() throws IOException {
// nothing to close
}
}

View file

@ -1,58 +0,0 @@
package org.xbib.oai.client;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;
/**
* Factory for OAI clients
*
*/
public class OAIClientFactory {
private final static OAIClientFactory instance = new OAIClientFactory();
private OAIClientFactory() {
}
public static OAIClientFactory getInstance() {
return instance;
}
public static OAIClient newClient() {
return new DefaultOAIClient();
}
public static OAIClient newClient(String spec) {
return newClient(spec, false);
}
public static OAIClient newClient(String spec, boolean trustAll) {
Properties properties = new Properties();
InputStream in = instance.getClass().getResourceAsStream("/org/xbib/oai/client/" + spec + ".properties");
if (in != null) {
try {
properties.load(in);
} catch (IOException ex) {
// ignore
}
DefaultOAIClient client = new DefaultOAIClient();
try {
client.setURL(new URL(properties.getProperty("uri")), trustAll);
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
return client;
} else {
DefaultOAIClient client = new DefaultOAIClient();
try {
client.setURL(new URL(spec));
} catch (Exception e) {
throw new IllegalArgumentException(e);
}
return client;
}
}
}

View file

@ -11,13 +11,8 @@ import java.io.Writer;
*/
public class GetRecordResponse implements ClientOAIResponse {
@Override
public void to(Writer writer) throws IOException {
}
@Override
public void receivedResponse(AggregatedHttpMessage message, Writer writer) throws IOException {
// not implemented yet
}
}

View file

@ -53,10 +53,6 @@ public class IdentifyResponse implements ClientOAIResponse {
}
}
@Override
public void to(Writer writer) throws IOException {
}
public void setRepositoryName(String repositoryName) {
this.repositoryName = repositoryName;
}

View file

@ -11,13 +11,8 @@ import java.io.Writer;
*/
public class ListIdentifiersResponse implements ClientOAIResponse {
@Override
public void to(Writer writer) throws IOException {
}
@Override
public void receivedResponse(AggregatedHttpMessage message, Writer writer) throws IOException {
// not implemented yet
}
}

View file

@ -11,13 +11,8 @@ import java.io.Writer;
*/
public class ListMetadataFormatsResponse implements ClientOAIResponse {
@Override
public void to(Writer writer) throws IOException {
}
@Override
public void receivedResponse(AggregatedHttpMessage message, Writer writer) throws IOException {
// not implemented yet
}
}

View file

@ -9,7 +9,7 @@ import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.logging.Level;
@ -95,9 +95,12 @@ public class ListRecordsFilterReader extends XMLFilterReader {
request.setResumptionToken(token);
}
} catch (Exception e) {
logger.log(Level.FINE, e.getMessage(), e);
throw new SAXException(e);
}
break;
default:
break;
}
return;
}
@ -148,17 +151,25 @@ public class ListRecordsFilterReader extends XMLFilterReader {
break;
case "datestamp":
if (header != null && content != null && content.length() > 0) {
String s = content.toString().trim();
try {
header.setDate(Instant.parse(content.toString().trim()));
header.setDate(Instant.parse(s));
} catch (DateTimeParseException e) {
// not "seconds ISO"
}
try {
LocalDateTime ldt = LocalDateTime.parse(content.toString().trim(),
DateTimeFormatter.ofPattern("yyyy-MM-dd"));
header.setDate(Instant.from(ldt));
} catch (DateTimeParseException e) {
// not "day ISO"
logger.log(Level.FINEST, e.getMessage(), e);
try {
ZonedDateTime zonedDateTime = ZonedDateTime.parse(s,
DateTimeFormatter.ISO_DATE_TIME);
header.setDate(Instant.from(zonedDateTime));
} catch (DateTimeParseException e1) {
logger.log(Level.FINEST, e1.getMessage(), e1);
try {
ZonedDateTime zonedDateTime = ZonedDateTime.parse(s,
DateTimeFormatter.ofPattern("yyyy-MM-dd"));
header.setDate(Instant.from(zonedDateTime));
} catch (DateTimeParseException e2) {
logger.log(Level.FINEST, e2.getMessage(), e2);
}
}
}
}
break;
@ -167,6 +178,8 @@ public class ListRecordsFilterReader extends XMLFilterReader {
header.setSetspec(content.toString().trim());
}
break;
default:
break;
}
if (content != null) {
content.setLength(0);

View file

@ -51,7 +51,7 @@ public class ListRecordsResponse implements ClientOAIResponse {
public ListRecordsResponse(ListRecordsRequest request) {
this.request = request;
this.retryAfterMillis = 20 * 1000; // 20 seconds by default
this.retryAfterMillis = 20L * 1000L; // 20 seconds by default
}
public ListRecordsResponse setRetryAfter(long millis) {
@ -143,10 +143,6 @@ public class ListRecordsResponse implements ClientOAIResponse {
}
}
@Override
public void to(Writer writer) throws IOException {
}
private boolean isDigits(String str) {
for (int i = 0; i < str.length(); i++) {
if (!Character.isDigit(str.charAt(i))) {

View file

@ -11,13 +11,8 @@ import java.io.Writer;
*/
public class ListSetsResponse implements ClientOAIResponse {
@Override
public void to(Writer writer) throws IOException {
}
@Override
public void receivedResponse(AggregatedHttpMessage message, Writer writer) throws IOException {
// not implemented yet
}
}

View file

@ -23,6 +23,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.net.ConnectException;
import java.net.URL;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
@ -39,7 +40,7 @@ public class ArxivClientTest {
@Test
public void testListRecordsArxiv() throws Exception {
try {
OAIClient client = OAIClientFactory.newClient("http://export.arxiv.org/oai2");
OAIClient client = new DefaultOAIClient().setURL(new URL("http://export.arxiv.org/oai2"));
IdentifyRequest identifyRequest = client.newIdentifyRequest();
HttpClient httpClient = client.getHttpClient();
AggregatedHttpMessage response = httpClient.execute(HttpHeaders.of(HttpMethod.GET, identifyRequest.getPath())

View file

@ -4,6 +4,7 @@ import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.net.ConnectException;
import java.net.URL;
import java.time.Instant;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicLong;
@ -34,7 +35,7 @@ public class DNBClientTest {
@Test
public void testIdentify() throws Exception {
OAIClient client = OAIClientFactory.newClient("http://services.dnb.de/oai/repository");
OAIClient client = new DefaultOAIClient().setURL(new URL("http://services.dnb.de/oai/repository"));
IdentifyRequest request = client.newIdentifyRequest();
HttpClient httpClient = client.getHttpClient();
assertEquals("/oai/repository?verb=Identify", request.getPath());
@ -45,7 +46,7 @@ public class DNBClientTest {
@Test
public void testListRecordsDNB() throws Exception {
try {
OAIClient client = OAIClientFactory.newClient("http://services.dnb.de/oai/repository");
OAIClient client = new DefaultOAIClient().setURL(new URL("http://services.dnb.de/oai/repository"));
ListRecordsRequest listRecordsRequest = client.newListRecordsRequest();
listRecordsRequest.setFrom(Instant.parse("2016-01-01T00:00:00Z"));
listRecordsRequest.setUntil(Instant.parse("2016-01-10T00:00:00Z"));

View file

@ -23,6 +23,7 @@ import java.io.IOException;
import java.io.StringWriter;
import java.net.ConnectException;
import java.net.URI;
import java.net.URL;
import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
@ -40,10 +41,10 @@ public class DOAJClientTest {
private static final Logger logger = LogManager.getLogger(DOAJClientTest.class.getName());
@Test
public void testListRecordsDOAJ() throws InterruptedException, TimeoutException, IOException {
public void testListRecordsDOAJ() throws Exception {
try {
// will redirect to https://doaj.org/oai
OAIClient oaiClient = OAIClientFactory.newClient("http://doaj.org/oai", true);
OAIClient oaiClient = new DefaultOAIClient().setURL(new URL("http://doaj.org/oai"), true);
IdentifyRequest identifyRequest = oaiClient.newIdentifyRequest();
HttpClient client = oaiClient.getHttpClient();
AggregatedHttpMessage response = client.execute(HttpHeaders.of(HttpMethod.GET, identifyRequest.getPath())

View file

@ -1 +0,0 @@
uri=http://services.dnb.de/oai/repository

View file

@ -1 +0,0 @@
uri=http://doaj.org/oai

View file

@ -1 +0,0 @@
uri=http://services.dnb.de/oai/repository

View file

@ -1,13 +0,0 @@
package org.xbib.oai;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @param <R> response type parameter
*/
public abstract class DefaultOAIResponseListener<R extends OAIResponse> {
}

View file

@ -1,12 +1,7 @@
package org.xbib.oai;
import java.io.IOException;
import java.io.Writer;
/**
* OAI response.
*/
public interface OAIResponse {
void to(Writer writer) throws IOException;
}

View file

@ -25,9 +25,8 @@ public class RdfResourceHandler extends AbstractXmlResourceHandler<RdfContentPar
@Override
public boolean isResourceDelimiter(QName name) {
boolean b = OAIDC_NS_URI.equals(name.getNamespaceURI())
return OAIDC_NS_URI.equals(name.getNamespaceURI())
&& DC_PREFIX.equals(name.getLocalPart());
return b;
}
@Override
@ -43,6 +42,7 @@ public class RdfResourceHandler extends AbstractXmlResourceHandler<RdfContentPar
// do nothing
}
@Override
public Object toObject(QName parent, String content) {
return content;
}

View file

@ -27,13 +27,6 @@ public class RdfSimpleMetadataHandler extends SimpleMetadataHandler implements O
private RdfContentParams params;
public static IRINamespaceContext getDefaultContext() {
IRINamespaceContext context = IRINamespaceContext.newInstance();
context.addNamespace(DC_PREFIX, DC_NS_URI);
context.addNamespace(OAIDC_NS_PREFIX, OAIDC_NS_URI);
return context;
}
public RdfSimpleMetadataHandler() {
this(RdfSimpleMetadataHandler::getDefaultContext);
}
@ -46,6 +39,13 @@ public class RdfSimpleMetadataHandler extends SimpleMetadataHandler implements O
handler.setDefaultNamespace(NS_PREFIX, NS_URI);
}
public static IRINamespaceContext getDefaultContext() {
IRINamespaceContext context = IRINamespaceContext.newInstance();
context.addNamespace(DC_PREFIX, DC_NS_URI);
context.addNamespace(OAIDC_NS_PREFIX, OAIDC_NS_URI);
return context;
}
public IRINamespaceContext getContext() {
return params.getNamespaceContext();
}

View file

@ -123,8 +123,8 @@ public class URIFormatter {
* @return true or false
*/
private static boolean isSafe(char c) {
return (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))
|| ((c >= '0') && (c <= '9')) || (c == '-') || (c == '_') || (c == '.') || (c == '*'));
return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))
|| ((c >= '0') && (c <= '9')) || (c == '-') || (c == '_') || (c == '.') || (c == '*');
}
/**

View file

@ -10,11 +10,13 @@ public class SimpleMetadataHandler extends XMLFilterReader implements MetadataHa
private RecordHeader header;
@Override
public SimpleMetadataHandler setHeader(RecordHeader header) {
this.header = header;
return this;
}
@Override
public RecordHeader getHeader() {
return header;
}

View file

@ -6,14 +6,17 @@ import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import java.io.Writer;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Deque;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Stack;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.stream.Location;
import javax.xml.stream.XMLEventFactory;
import javax.xml.stream.XMLEventWriter;
@ -27,13 +30,15 @@ import javax.xml.stream.events.Namespace;
*/
public class XmlSimpleMetadataHandler extends SimpleMetadataHandler implements OAIConstants {
private final XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
private static final Logger logger = Logger.getLogger(XmlSimpleMetadataHandler.class.getName());
private final XMLEventFactory eventFactory = XMLEventFactory.newInstance();
private static final XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
private static final XMLEventFactory eventFactory = XMLEventFactory.newInstance();
private List<String> namespaces = new ArrayList<>();
private Stack<Collection<?>> nsStack = new Stack<>();
private Deque<Collection<?>> nsStack = new ArrayDeque<>();
private Locator locator;
@ -51,7 +56,7 @@ public class XmlSimpleMetadataHandler extends SimpleMetadataHandler implements O
outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.TRUE);
this.eventWriter = outputFactory.createXMLEventWriter(writer);
} catch (XMLStreamException e) {
// ignore
logger.log(Level.FINE, e.getMessage(), e);
}
return this;
}
@ -118,20 +123,23 @@ public class XmlSimpleMetadataHandler extends SimpleMetadataHandler implements O
if (eventWriter == null) {
return;
}
if (prefix == null) {
prefix = "";
} else if (prefix.equals("xml")) {
return;
}
if (namespaces == null) {
namespaces = new ArrayList<>();
}
if (prefix == null) {
namespaces.add("");
namespaces.add(namespaceURI);
return;
} else if ("xml".equals(prefix)) {
return;
}
namespaces.add(prefix);
namespaces.add(namespaceURI);
}
@Override
public void endPrefixMapping(String string) throws SAXException {
// not used
}
@Override
@ -143,8 +151,7 @@ public class XmlSimpleMetadataHandler extends SimpleMetadataHandler implements O
try {
eventWriter.add(eventFactory.createStartDocument());
} catch (XMLStreamException e) {
// is thrown because of document encoding - commented out
//throw new SAXException(e);
logger.log(Level.FINE, e.getMessage(), e);
}
needToCallStartDocument = false;
}
@ -169,7 +176,7 @@ public class XmlSimpleMetadataHandler extends SimpleMetadataHandler implements O
}
String[] q = {null, null};
parseQName(qname, q);
Collection<?> nsList = nsStack.remove(nsStack.size() - 1);
Collection<?> nsList = nsStack.getLast();
Iterator<?> nsIter = nsList.iterator();
try {
eventFactory.setLocation(getCurrentLocation());
@ -234,12 +241,13 @@ public class XmlSimpleMetadataHandler extends SimpleMetadataHandler implements O
attrs.add(attribute);
}
}
events[0] = nsMap == null ? Collections.EMPTY_LIST : nsMap.values();
events[1] = attrs == null ? Collections.EMPTY_LIST : attrs;
events[0] = nsMap == null ? Collections.emptyList() : nsMap.values();
events[1] = attrs == null ? Collections.emptyList() : attrs;
}
private void parseQName(String qName, String[] results) {
String prefix, local;
String prefix;
String local;
int idx = qName.indexOf(':');
if (idx >= 0) {
prefix = qName.substring(0, idx);
@ -273,22 +281,27 @@ public class XmlSimpleMetadataHandler extends SimpleMetadataHandler implements O
systemId = locator.getSystemId();
}
@Override
public int getLineNumber() {
return lineNumber;
}
@Override
public int getColumnNumber() {
return columnNumber;
}
@Override
public int getCharacterOffset() {
return -1;
}
@Override
public String getPublicId() {
return publicId;
}
@Override
public String getSystemId() {
return systemId;
}

View file

@ -2,26 +2,36 @@ package org.xbib.oai.server;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.ServiceLoader;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
*/
public class OAIServiceFactory {
private static final Map<URL, OAIServer> services = new HashMap<>();
private static final Logger logger = Logger.getLogger(OAIServiceFactory.class.getName());
private static final Map<URI, OAIServer> services = new HashMap<>();
private static final OAIServiceFactory instance = new OAIServiceFactory();
private OAIServiceFactory() {
ServiceLoader<OAIServer> loader = ServiceLoader.load(OAIServer.class);
for (OAIServer service : loader) {
if (!services.containsKey(service.getURL())) {
services.put(service.getURL(), service);
try {
URI uri = service.getURL().toURI();
if (!services.containsKey(uri)) {
services.put(uri, service);
}
} catch (URISyntaxException e) {
logger.log(Level.FINE, e.getMessage(), e);
}
}
}
@ -34,11 +44,11 @@ public class OAIServiceFactory {
return services.isEmpty() ? null : services.entrySet().iterator().next().getValue();
}
public static OAIServer getService(URL url) {
if (services.containsKey(url)) {
return services.get(url);
public static OAIServer getService(URI uri) {
if (services.containsKey(uri)) {
return services.get(uri);
}
throw new IllegalArgumentException("OAI service " + url + " not found in " + services);
throw new IllegalArgumentException("OAI service " + uri + " not found in " + services);
}
public static OAIServer getService(String name) {
@ -47,8 +57,8 @@ public class OAIServiceFactory {
if (in != null) {
try {
properties.load(in);
} catch (IOException ex) {
// ignore
} catch (IOException e) {
logger.log(Level.FINE, e.getMessage(), e);
}
} else {
throw new IllegalArgumentException("service " + name + " not found");

View file

@ -25,23 +25,23 @@ import java.util.Properties;
*/
public class PropertiesOAIServer implements OAIServer {
public static final String ADAPTER_URI = "uri";
private static final String ADAPTER_URI = "uri";
public static final String STYLESHEET = "stylesheet";
private static final String STYLESHEET = "stylesheet";
public static final String REPOSITORY_NAME = "identify.repositoryName";
private static final String REPOSITORY_NAME = "identify.repositoryName";
public static final String BASE_URL = "identify.baseURL";
private static final String BASE_URL = "identify.baseURL";
public static final String PROTOCOL_VERSION = "identify.protocolVersion";
private static final String PROTOCOL_VERSION = "identify.protocolVersion";
public static final String ADMIN_EMAIL = "identify.adminEmail";
private static final String ADMIN_EMAIL = "identify.adminEmail";
public static final String EARLIEST_DATESTAMP = "identify.earliestDatestamp";
private static final String EARLIEST_DATESTAMP = "identify.earliestDatestamp";
public static final String DELETED_RECORD = "identify.deletedRecord";
private static final String DELETED_RECORD = "identify.deletedRecord";
public static final String GRANULARITY = "identify.granularity";
private static final String GRANULARITY = "identify.granularity";
private Properties properties;
@ -115,30 +115,36 @@ public class PropertiesOAIServer implements OAIServer {
@Override
public void identify(IdentifyServerRequest request, IdentifyServerResponse response)
throws OAIException {
// not implemented yet
}
@Override
public void listMetadataFormats(ListMetadataFormatsServerRequest request, ListMetadataFormatsServerResponse response)
throws OAIException {
// not implemented yet
}
@Override
public void listSets(ListSetsServerRequest request, ListSetsServerResponse response)
throws OAIException {
// not implemented yet
}
@Override
public void listIdentifiers(ListIdentifiersServerRequest request, ListIdentifiersServerResponse response)
throws OAIException {
// not implemented yet
}
@Override
public void listRecords(ListRecordsServerRequest request, ListRecordsServerResponse response)
throws OAIException {
// not implemented yet
}
@Override
public void getRecord(GetRecordServerRequest request, GetRecordServerResponse response)
throws OAIException {
// not implemented yet
}
}

View file

@ -2,8 +2,6 @@ package org.xbib.oai.server;
import org.xbib.oai.OAIResponse;
import java.io.IOException;
import java.io.Writer;
import javax.xml.stream.util.XMLEventConsumer;
/**
@ -11,19 +9,8 @@ import javax.xml.stream.util.XMLEventConsumer;
*/
public class ServerOAIResponse implements OAIResponse {
private String format;
private XMLEventConsumer consumer;
public String getOutputFormat() {
return format;
}
@Override
public void to(Writer writer) throws IOException {
}
public ServerOAIResponse setConsumer(XMLEventConsumer consumer) {
this.consumer = consumer;
return this;

View file

@ -2,8 +2,6 @@ package org.xbib.oai.server.identify;
import org.xbib.oai.server.ServerOAIResponse;
import java.io.IOException;
import java.io.Writer;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
@ -30,10 +28,6 @@ public class IdentifyServerResponse extends ServerOAIResponse {
private String compression;
@Override
public void to(Writer writer) throws IOException {
}
public void setRepositoryName(String repositoryName) {
this.repositoryName = repositoryName;
}

View file

@ -2,19 +2,13 @@ package org.xbib.oai.server.listrecords;
import org.xbib.oai.server.ServerOAIResponse;
import java.io.IOException;
import java.io.Writer;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
*/
public class ListRecordsServerResponse extends ServerOAIResponse {
private static final Logger logger = Logger.getLogger(ListRecordsServerResponse.class.getName());
private String error;
private Date date;
@ -41,18 +35,8 @@ public class ListRecordsServerResponse extends ServerOAIResponse {
this.expire = expire;
}
@Override
public void to(Writer writer) throws IOException {
try {
if (this.expire > 0L) {
logger.log(Level.INFO, "waiting for {} seconds (retry-after)", expire);
Thread.sleep(1000 * expire);
this.expire = 0L;
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
logger.log(Level.WARNING, "interrupted");
}
public long getExpire() {
return expire;
}
}

View file

@ -23,14 +23,16 @@ public abstract class AbstractVerb {
private static final XMLEventFactory eventFactory = XMLEventFactory.newInstance();
protected final ServerOAIRequest request;
protected final ServerOAIResponse response;
private static final TimeZone tz = TimeZone.getTimeZone("GMT");
private static final String NS_URI = "http://www.w3.org/2001/XMLSchema-instance";
private static final String NS_PREFIX = "xsi";
private final ServerOAIRequest request;
private final ServerOAIResponse response;
public AbstractVerb(ServerOAIRequest request, ServerOAIResponse response) {
this.request = request;
this.response = response;
@ -102,8 +104,6 @@ public abstract class AbstractVerb {
}
}
private final TimeZone tz = TimeZone.getTimeZone("GMT");
private String formatDate(Date date) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
format.setTimeZone(tz);

View file

@ -21,7 +21,6 @@ public class SimpleServiceTest {
IdentifyServerResponse response = new IdentifyServerResponse();
response.setConsumer(factory.createXMLEventWriter(sw));
service.identify(request, response);
response.to(sw);
}
}