Skip to content
Snippets Groups Projects
Commit 2b923ddc authored by mbrodhu's avatar mbrodhu
Browse files

added missing classes

parent ba6977e9
No related branches found
No related tags found
No related merge requests found
package info.textgrid.middleware;
import java.util.ArrayList;
import java.util.List;
import info.textgrid.middleware.oaipmh.ListIdentifiersType;
import info.textgrid.middleware.oaipmh.RequestType;
public abstract class IdentifierListDelivererAbstract implements IdentifierListDelivererInterface {
protected boolean textgrid;
protected boolean dariah;
public IdentifierListDelivererAbstract(boolean textgrid, boolean dariah) {
this.textgrid = textgrid;
this.dariah = dariah;
}
@Override
public ListIdentifiersType processIdentifierList(String from, String to, String set, String resumptionToken) {
// TODO Auto-generated method stub
return null;
}
public static ErrorHandler requestChecker(RequestType request) {
ErrorHandler result = new ErrorHandler();
// Check if metadata prefix is existing and valid.
if (request.getMetadataPrefix() != null
&& !request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX)
&& !request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) {
result.setError(TGConstants.OAI_METADATA_FORMAT_ERROR,
"The value of the metadataPrefix: " + request.getMetadataPrefix()
+ " is not supported by the item identified by the value of: "
+ request.getIdentifier());
}
// Check if other params are existing, they shouldn't!
else {
List<String> errorValues = new ArrayList<String>();
if (request.getResumptionToken() != null) {
errorValues.add("resumptionToken");
}
if (request.getMetadataPrefix() == null) {
errorValues.add("metadataPrefix");
}
if (request.getIdentifier() != null) {
errorValues.add("identifier");
}
if(errorValues.size()>0) {
result.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal arguments "
+ "or is missing required arguments: " + errorValues);
}
}
return result;
}
}
package info.textgrid.middleware;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.classicmayan.tools.Queries;
import info.textgrid.middleware.oaipmh.ListIdentifiersType;
import info.textgrid.middleware.oaipmh.ResumptionTokenType;
public class IdentifierListDelivererIDIOM extends IdentifierListDelivererAbstract{
static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>();
public IdentifierListDelivererIDIOM(boolean textgrid, boolean dariah) {
super(textgrid, dariah);
}
public ListIdentifiersType processIdentifierList(String from, String to, String set, String resumptionToken) {
ListIdentifiersType lit = new ListIdentifiersType();
List<String> artefactURIs;
if(resumptionToken==null) {
artefactURIs = Queries.getArtefactList(0);
}else {
artefactURIs = Queries.getArtefactList(cursorCollector.get(resumptionToken));
}
long listSize = Queries.getAmountOfArtefacts();
int i=0;
UUID uuid = UUID.randomUUID();
String resTokenValue = uuid.toString();
resumptionToken = uuid.toString();
for(String artefactURI : artefactURIs) {
RecordDelivererIDIOM idiomRecord = new RecordDelivererIDIOM(true, false);
lit.getHeader().add(idiomRecord.getRecordById(artefactURI).getRecord().getHeader());
}
// Check the need for a resumption token!
ResumptionTokenType resTokenForResponse = OAIPMHUtillities.getResumptionToken(
listSize, resumptionToken, cursorCollector, resTokenValue, 100, i);
if (resTokenForResponse != null) {
lit.setResumptionToken(resTokenForResponse);
}
return lit;
}
}
package info.textgrid.middleware;
import java.text.ParseException;
import info.textgrid.middleware.oaipmh.ListIdentifiersType;
public interface IdentifierListDelivererInterface {
public ListIdentifiersType processIdentifierList(String from, String to, String set, String resumptionToken) throws ParseException;
}
package info.textgrid.middleware;
import java.util.ArrayList;
import java.util.List;
import info.textgrid.middleware.oaipmh.RequestType;
public abstract class RecordListDelivererAbstract implements RecordListDelivererInterface{
protected boolean textgrid;
protected boolean dariah;
/**
* @param textgrid
* @param dariah
*/
public RecordListDelivererAbstract(boolean textgrid, boolean dariah) {
this.textgrid = textgrid;
this.dariah = dariah;
}
public static ErrorHandler requestChecker(RequestType request) {
ErrorHandler result = new ErrorHandler();
// Check if metadata prefix is existing and valid.
if (request.getMetadataPrefix() != null
&& !request.getMetadataPrefix().equals(TGConstants.METADATA_DC_PREFIX)
&& !request.getMetadataPrefix().equals(TGConstants.METADATA_IDIOM_PREFIX)) {
result.setError(TGConstants.OAI_METADATA_FORMAT_ERROR,
"The value of the metadataPrefix: " + request.getMetadataPrefix()
+ " is not supported by the item identified by the value of: "
+ request.getIdentifier());
}
// Check if other params are existing, they shouldn't!
else {
List<String> errorValues = new ArrayList<String>();
if (request.getMetadataPrefix() == null) {
errorValues.add("metadataPrefix");
}
if (request.getIdentifier() != null) {
errorValues.add("identifier");
}
if(errorValues.size()>0) {
result.setError(TGConstants.OAI_BAD_ARGUMENT, "The request includes illegal arguments "
+ "or is missing required arguments: " + errorValues);
}
}
return result;
}
}
package info.textgrid.middleware;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.commons.logging.LogFactory;
import org.apache.jena.atlas.logging.Log;
import org.classicmayan.tools.Queries;
import info.textgrid.middleware.oaipmh.HeaderType;
import info.textgrid.middleware.oaipmh.ListRecordsType;
import info.textgrid.middleware.oaipmh.MetadataType;
import info.textgrid.middleware.oaipmh.RecordType;
import info.textgrid.middleware.oaipmh.ResumptionTokenType;
public class RecordListDelivererIDIOM extends RecordListDelivererAbstract{
private static org.apache.commons.logging.Log log = LogFactory.getLog(OAIPMHImpl.class);
static Map<String, Integer> cursorCollector = new Hashtable<String, Integer>();
//private int searchResponseSize;
private OAI_ESClient oaiEsClient;
public RecordListDelivererIDIOM(boolean textgrid, boolean dariah) {
super(textgrid, dariah);
// TODO Auto-generated constructor stub
}
@Override
public RecordType buildRecord(ListRecordsType recordList, String set, String headerIdentifier) {
MetadataType metadata = new MetadataType();
RecordType record = new RecordType();
record.setMetadata(metadata);
recordList.getRecord().add(record);
return null;
}
@Override
public ListRecordsType getRecords(String from, String to, String set, String resumptionToken) {
ListRecordsType recordList = new ListRecordsType();
List<String> artefactURIs;
if(resumptionToken==null) {
artefactURIs = Queries.getArtefactList(0);
}else {
artefactURIs = Queries.getArtefactList(cursorCollector.get(resumptionToken));
}
long listSize = Queries.getAmountOfArtefacts();
int i=0;
UUID uuid = UUID.randomUUID();
String resTokenValue = uuid.toString();
resumptionToken = uuid.toString();
for(String artefactURI : artefactURIs) {
RecordDelivererIDIOM idiomRecord = new RecordDelivererIDIOM(true, false);
recordList.getRecord().add(idiomRecord.getRecordById(artefactURI).getRecord());
i++;
}
// Check the need for a resumption token!
ResumptionTokenType resTokenForResponse = OAIPMHUtillities.getResumptionToken(
listSize, resumptionToken, cursorCollector, resTokenValue, 100, i);
if (resTokenForResponse != null) {
recordList.setResumptionToken(resTokenForResponse);
}
return recordList;
}
@Override
public HeaderType setHeader(String set, String headerIdentifier) {
// TODO Auto-generated method stub
return null;
}
public OAI_ESClient getOaiEsClient() {
return oaiEsClient;
}
public void setOaiEsClient(OAI_ESClient oaiEsClient) {
this.oaiEsClient = oaiEsClient;
}
}
package info.textgrid.middleware;
import info.textgrid.middleware.oaipmh.HeaderType;
import info.textgrid.middleware.oaipmh.ListRecordsType;
import info.textgrid.middleware.oaipmh.RecordType;
public interface RecordListDelivererInterface {
public RecordType buildRecord(ListRecordsType recordList, String set, String headerIdentifier);
public ListRecordsType getRecords(String from, String to, String set, String resumptionToken);
public HeaderType setHeader(String set, String headerIdentifier);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment