Skip to content
Snippets Groups Projects
Commit c165aeab authored by Stefan E. Funk's avatar Stefan E. Funk
Browse files

Merge branch '73-record-ids-der-maya-artefakte-im-header-sind-nicht-korrekt' into 'develop'

Resolve "Record-IDs der Maya-Artefakte im Header sind nicht korrekt"

Closes #73

See merge request dariah-de/dariah-de-oai-pmh-services!70
parents 80bd8793 1c933c53
No related branches found
No related tags found
No related merge requests found
Pipeline #323334 passed
......@@ -216,19 +216,20 @@ public class IDIOMImages implements RecordDelivererInterface, RecordListDelivere
Document doc = builder.parse(new InputSource(new StringReader(immByTGObject.getXML())));
metadataMets.setAny(doc.getDocumentElement());
conedaKorRecord.setMetadata(metadataMets);
if (changedID.contains(".")) {
conedaKorRecord.setHeader(buildOAIPMHRecordHeader(
OAIPMHUtilities.datestampAsString(immByTGObject.getCreationDate()),
changedID.substring(0, changedID.indexOf("."))));
} else {
conedaKorRecord.setHeader(buildOAIPMHRecordHeader(
OAIPMHUtilities.datestampAsString(immByTGObject.getCreationDate()), changedID));
}
// Use base URI for IDIOM image delivery!
String tgBaseURI = OAIPMHUtilities.getTextGridBaseURI(changedID);
conedaKorRecord.setHeader(buildOAIPMHRecordHeader(
OAIPMHUtilities.datestampAsString(immByTGObject.getCreationDate()), tgBaseURI));
singleImageMetsMods.setRecord(conedaKorRecord);
} catch (ParserConfigurationException | SAXException | CrudClientException e) {
log.severe("error! " + e.getClass().getName() + ": " + e.getMessage());
String message =
"ERROR getting IDIOM METS record from TG-crud! Maybe renew Session ID in OAIPMH config?"
+ e.getClass().getName() + ": " + e.getMessage();
log.warning(message);
return null;
}
......
......@@ -24,7 +24,7 @@ import info.textgrid.middleware.oaipmh.RecordType;
/**
* @author Maximilian Brodhun, SUB Göttingen
* @author Stefan E. Funk, SUB Göttingen
* @version 2022-09-27
* @version 2022-10-04
* @since 2019-03-12
*/
@Component
......@@ -104,9 +104,9 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract {
} catch (JSONException | ParserConfigurationException | SAXException | IOException
| ParseException | NoSuchElementException e) {
log.severe("error! " + e.getClass().getName() + ": " + e.getMessage());
// TODO Auto-generated catch block
e.printStackTrace();
String message = "ERROR getting IDIOM METS record for ID " + id + "! "
+ e.getClass().getName() + ": " + e.getMessage();
log.warning(message);
}
}
......@@ -119,14 +119,19 @@ public class RecordDelivererIDIOM extends RecordDelivererAbstract {
// Fixes #64
if (idi != null) {
this.record = idi.getRecord();
} else {
String message = "ERROR getting IDIOM IMAGE record for ID " + id + "!";
log.warning(message);
}
}
// No setSpec needed here!
// TODO Why not??
String setSpec = "";
// We need to have the base URI here in header (and record), it is used as Record ID of Mayan
// artifacts here!
HeaderType header =
OAIPMHUtilities.computeResponseHeader(this.dateOfObjectCreation, textgridURI, setSpec);
OAIPMHUtilities.computeResponseHeader(this.dateOfObjectCreation, textgridBaseURI, setSpec);
this.record.setHeader(header);
grt.setRecord(this.record);
......
......@@ -21,6 +21,7 @@ import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
import org.apache.http.HttpStatus;
import info.textgrid.middleware.OAIPMHProducer;
import info.textgrid.middleware.OAIPMHUtilities;
import info.textgrid.middleware.test.online.dh.TestDHOAIPMHOnline;
/**
......@@ -45,8 +46,8 @@ public class OAIPMHUtilitiesOnline {
public static final String PROPERTIES_FILE = "oaipmh.test.textgridlab-org.properties";
// public static final String PROPERTIES_FILE = "oaipmh.test.dev-textgridlab-org.properties";
// public static final boolean TEST_ALL_PAGES = false;
public static final boolean TEST_ALL_PAGES = true;
public static final boolean TEST_ALL_PAGES = false;
// public static final boolean TEST_ALL_PAGES = true;
// ## CHANGE SETTINGS ABOVE FOR SETTING TEST SCOPE ---------------------------------------------
......@@ -323,8 +324,8 @@ public class OAIPMHUtilitiesOnline {
recordsExpectedPerRequest, loopCount, threadName);
// Test if the header identifiers are sound.
if (theVerb.equals(VERB_LIST_RECORDS)) {
examineTGHeader(responseString, recordsExpectedPerRequest);
if (theVerb.equals(VERB_LIST_RECORDS) || theVerb.equals(VERB_LIST_IDENTIFIERS)) {
examineTGHeaderIDs(responseString, theMetadataPrefix);
}
// Test general metadata content (if verb is listRecords!), must go conform with the metadata
......@@ -357,7 +358,7 @@ public class OAIPMHUtilitiesOnline {
// Test if the header identifiers are sound.
if (theVerb.equals(VERB_LIST_RECORDS)) {
examineTGHeader(responseString, recordsExpectedPerRequest);
examineTGHeaderIDs(responseString, theMetadataPrefix);
}
// Test general metadata content (if verb is listRecords!), must go conform with the
......@@ -529,23 +530,6 @@ public class OAIPMHUtilitiesOnline {
}
}
/**
* <p>
* Check for correct metadata content according to metadata prefix --> We do need to check if we
* have different identifiers in the response.
* </p>
*
* @param theResponseString
* @param recordsExpectedPerRequest
*/
private static void examineTGHeader(String theResponseString, int recordsExpectedPerRequest) {
boolean IDSUnique = examineTGHeaderIDs(theResponseString);
if (IDSUnique) {
String message = "Duplicate IDs in the response!";
assertTrue(message, false);
}
}
/**
* <p>
* Creates a hash set containing all the ID values from a certain tag. Used to count elements such
......@@ -554,11 +538,10 @@ public class OAIPMHUtilitiesOnline {
* </p>
*
* @param theResponseString
* @return
* @param theMetadataPrefix
*/
private static boolean examineTGHeaderIDs(String theResponseString) {
public static void examineTGHeaderIDs(String theResponseString, String theMetadataPrefix) {
boolean result = false;
HashSet<String> idHash = new HashSet<String>();
int startID = 0;
......@@ -585,7 +568,10 @@ public class OAIPMHUtilitiesOnline {
assertTrue(message, false);
}
return result;
// Check for revision URIs in IDIOM responses.
for (String u : idHash) {
examineTGIdentifiers(u, theMetadataPrefix);
}
}
// **
......@@ -848,4 +834,24 @@ public class OAIPMHUtilitiesOnline {
}
}
/**
* @param theIdentifier
* @param theMetadataPrefix
*/
private static void examineTGIdentifiers(String theIdentifier, String theMetadataPrefix) {
if (theMetadataPrefix.equals(OAI_IDIOMMETS_PREFIX)) {
if (!OAIPMHUtilities.getTextGridBaseURI(theIdentifier).equals(theIdentifier)) {
String message =
"ERROR IN OAIPMH RESPONSE: identifier " + theIdentifier + " is NOT a base URI!";
assertTrue(message, false);
}
} else {
if (OAIPMHUtilities.getTextGridBaseURI(theIdentifier).equals(theIdentifier)) {
String message =
"ERROR IN OAIPMH RESPONSE: identifier " + theIdentifier + " MUST NOT BE a base URI!";
assertTrue(message, false);
}
}
}
}
......@@ -173,6 +173,9 @@ public class TestTGGetRecordOnline {
assertTrue(message, false);
}
// Test OAI header.
OAIPMHUtilitiesOnline.examineTGHeaderIDs(response, OAIPMHUtilitiesOnline.OAI_IDIOMMETS_PREFIX);
System.out.println("\tresponse: " + response);
System.out.println(OAIPMHUtilitiesOnline.OK);
}
......@@ -201,6 +204,9 @@ public class TestTGGetRecordOnline {
assertTrue(message, false);
}
// Test OAI header.
OAIPMHUtilitiesOnline.examineTGHeaderIDs(response, OAIPMHUtilitiesOnline.OAI_IDIOMMETS_PREFIX);
System.out.println("\tresponse: " + response);
System.out.println(OAIPMHUtilitiesOnline.OK);
}
......
......@@ -333,7 +333,7 @@ public class TestTGListRecordsOnline {
System.out.println(OAIPMHUtilitiesOnline.OK);
} else {
System.out.println("..skipping");
System.out.println("...skipping");
}
}
......@@ -369,25 +369,36 @@ public class TestTGListRecordsOnline {
throws IOException, InterruptedException, ExecutionException {
System.out
.println(
OAIPMHUtilitiesOnline.TESTING + "testListRecordsConcurrentlyIDIOMMETSMorePages()");
.println(OAIPMHUtilitiesOnline.TESTING + "testListRecordsConcurrentlyIDIOMMETSMorePages()");
ExecutorService executor = Executors.newFixedThreadPool(3);
Future<Boolean> f1 = executor.submit(
new TGOAIPMHResumptionTokenThread(oaipmhWebClient, OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET, OAIPMHUtilitiesOnline.OAI_IDIOMMETS_PREFIX, 2, 30, "D1"));
new TGOAIPMHResumptionTokenThread(oaipmhWebClient,
OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET,
OAIPMHUtilitiesOnline.OAI_IDIOMMETS_PREFIX,
2, 30,
"IDIOM1"));
Future<Boolean> f2 = executor.submit(
new TGOAIPMHResumptionTokenThread(oaipmhWebClient, OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET, OAIPMHUtilitiesOnline.OAI_IDIOMMETS_PREFIX, 3, 30, "D2"));
new TGOAIPMHResumptionTokenThread(oaipmhWebClient,
OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET,
OAIPMHUtilitiesOnline.OAI_IDIOMMETS_PREFIX,
3, 30,
"IDIOM2"));
Future<Boolean> f3 = executor.submit(
new TGOAIPMHResumptionTokenThread(oaipmhWebClient, OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET, OAIPMHUtilitiesOnline.OAI_IDIOMMETS_PREFIX, 4, 30, "D3"));
new TGOAIPMHResumptionTokenThread(oaipmhWebClient,
OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET,
OAIPMHUtilitiesOnline.OAI_IDIOMMETS_PREFIX,
4, 30,
"IDIOM3"));
executor.shutdown();
System.out.println(OAIPMHUtilitiesOnline.OK + ": [D1]=" + f1.get() + ", [D2]=" + f2.get()
+ ", [D3]=" + f3.get());
System.out.println(OAIPMHUtilitiesOnline.OK + ": [IDIOM1]=" + f1.get() + ", [IDIOM2]="
+ f2.get() + ", [IDIOM3]=" + f3.get());
}
......@@ -404,17 +415,33 @@ public class TestTGListRecordsOnline {
ExecutorService executor = Executors.newFixedThreadPool(4);
Future<Boolean> f1 = executor.submit(
new TGOAIPMHResumptionTokenThread(oaipmhWebClient, OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET, OAIPMHUtilitiesOnline.OAI_DC_PREFIX, 44, 100, "DC1"));
new TGOAIPMHResumptionTokenThread(oaipmhWebClient,
OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET,
OAIPMHUtilitiesOnline.OAI_DC_PREFIX,
44, 100,
"DC1"));
Future<Boolean> f2 = executor.submit(
new TGOAIPMHResumptionTokenThread(oaipmhWebClient, OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET, OAIPMHUtilitiesOnline.OAI_DC_PREFIX, 33, 100, "DC2"));
new TGOAIPMHResumptionTokenThread(oaipmhWebClient,
OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET,
OAIPMHUtilitiesOnline.OAI_DC_PREFIX,
33, 100,
"DC2"));
Future<Boolean> f3 = executor.submit(
new TGOAIPMHResumptionTokenThread(oaipmhWebClient, OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET, OAIPMHUtilitiesOnline.OAI_DC_PREFIX, 66, 100, "DC3"));
new TGOAIPMHResumptionTokenThread(oaipmhWebClient,
OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET,
OAIPMHUtilitiesOnline.OAI_DC_PREFIX,
66, 100,
"DC3"));
Future<Boolean> f4 = executor.submit(
new TGOAIPMHResumptionTokenThread(oaipmhWebClient, OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET, OAIPMHUtilitiesOnline.OAI_DC_PREFIX, 28, 100, "DC4"));
new TGOAIPMHResumptionTokenThread(oaipmhWebClient,
OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET,
OAIPMHUtilitiesOnline.OAI_DC_PREFIX,
28, 100,
"DC4"));
executor.shutdown();
......@@ -436,17 +463,33 @@ public class TestTGListRecordsOnline {
ExecutorService executor = Executors.newFixedThreadPool(3);
Future<Boolean> f1 = executor.submit(
new TGOAIPMHResumptionTokenThread(oaipmhWebClient, OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET, OAIPMHUtilitiesOnline.OAI_DC_PREFIX, 6, 100, "B1"));
new TGOAIPMHResumptionTokenThread(oaipmhWebClient,
OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET,
OAIPMHUtilitiesOnline.OAI_DC_PREFIX,
6, 100,
"B1"));
Future<Boolean> f2 = executor.submit(
new TGOAIPMHResumptionTokenThread(oaipmhWebClient, OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET, OAIPMHUtilitiesOnline.OAI_DC_PREFIX, 7, 100, "B2"));
new TGOAIPMHResumptionTokenThread(oaipmhWebClient,
OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET,
OAIPMHUtilitiesOnline.OAI_DC_PREFIX,
7, 100,
"B2"));
Future<Boolean> f3 = executor.submit(
new TGOAIPMHResumptionTokenThread(oaipmhWebClient, OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET, OAIPMHUtilitiesOnline.OAI_DC_PREFIX, 8, 100, "B3"));
new TGOAIPMHResumptionTokenThread(oaipmhWebClient,
OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET,
OAIPMHUtilitiesOnline.OAI_DC_PREFIX,
8, 100,
"B3"));
Future<Boolean> f4 = executor.submit(
new TGOAIPMHResumptionTokenThread(oaipmhWebClient, OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET, OAIPMHUtilitiesOnline.OAI_DC_PREFIX, 9, 100, "B4"));
new TGOAIPMHResumptionTokenThread(oaipmhWebClient,
OAIPMHUtilitiesOnline.VERB_LIST_RECORDS,
OAIPMHUtilitiesOnline.NO_SET,
OAIPMHUtilitiesOnline.OAI_DC_PREFIX,
9, 100,
"B4"));
executor.shutdown();
......
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