Project

General

Profile

« Previous | Next » 

Revision 35341

feeding with UNACKNOWLEDGE write concern.
The feed action also take the optional parameter oai_alwaysNewRecord so that the OAI store can assume there is no another record with the same id in the oai store.

View differences:

MongoPublisherStore.java
21 21
import com.mongodb.DBCollection;
22 22
import com.mongodb.DBCursor;
23 23
import com.mongodb.DBObject;
24
import com.mongodb.WriteConcern;
24 25
import com.mongodb.WriteResult;
25 26

  
26 27
import eu.dnetlib.data.information.oai.publisher.PublisherField;
......
65 66
	 */
66 67
	private String idNamespace;
67 68

  
69
	private boolean alwaysNewRecord;
70

  
68 71
	@Override
69 72
	public RecordInfo getRecord(final String recordId) {
70 73
		DBObject query = new BasicDBObject(OAIConfigurationReader.ID_FIELD, recordId);
......
394 397
		obj.put(OAIConfigurationReader.LAST_COLLECTION_DATE_FIELD, feedDate);
395 398
		obj.put(OAIConfigurationReader.DATESTAMP_FIELD, feedDate);
396 399
		obj.put(OAIConfigurationReader.UPDATED_FIELD, false);
397
		collection.insert(obj);
400
		collection.insert(obj, WriteConcern.UNACKNOWLEDGED);
398 401
		this.upsertSets(recordProperties.get(OAIConfigurationReader.SET_FIELD));
399 402
	}
400 403

  
......
436 439
	}
437 440

  
438 441
	private boolean isNewRecord(final String oaiIdentifier) {
442
		if (alwaysNewRecord) return true;
439 443
		return this.collection.findOne(new BasicDBObject(OAIConfigurationReader.ID_FIELD, oaiIdentifier)) == null;
440 444
	}
441 445

  
......
495 499

  
496 500
	public MongoPublisherStore(final String id, final String metadataFormat, final String interpretation, final String layout, final DBCollection collection,
497 501
			final List<PublisherField> mongoFields, final MongoQueryParser queryParser, final RecordInfoGenerator recordInfoGenerator, final String idScheme,
498
			final String idNamespace, final MetadataExtractor metadataExtractor, final RecordChangeDetector recordChangeDetector) {
502
			final String idNamespace, final MetadataExtractor metadataExtractor, final RecordChangeDetector recordChangeDetector, final boolean alwaysNewRecord) {
499 503
		super();
500 504
		this.id = id;
501 505
		this.metadataFormat = metadataFormat;
......
509 513
		this.idScheme = idScheme;
510 514
		this.idNamespace = idNamespace;
511 515
		this.recordChangeDetector = recordChangeDetector;
516
		this.alwaysNewRecord = alwaysNewRecord;
512 517
	}
513 518

  
514 519
	public void setId(final String id) {
......
627 632
		this.mongoFields = mongoFields;
628 633
	}
629 634

  
635
	public boolean isAlwaysNewRecord() {
636
		return alwaysNewRecord;
637
	}
638

  
639
	public void setAlwaysNewRecord(final boolean alwaysNewRecord) {
640
		this.alwaysNewRecord = alwaysNewRecord;
641
	}
642

  
630 643
}

Also available in: Unified diff