Project

General

Profile

« Previous | Next » 

Revision 39082

changed POM version and fixed feeding of tagging

View differences:

modules/dnet-gridfs-objectstore/branches/tag/src/main/java/eu/dnetlib/data/objectstore/modular/gridFS/GridFSObjectStore.java
355 355
	 */
356 356
	@Override
357 357
	public String feedObjectRecord(final ObjectStoreRecord record) throws ObjectStoreServiceException {
358
		if (record == null || record.getFileMetadata() == null) { throw new ObjectStoreServiceException("Empty input Record"); }
358
		if (record == null || record.getFileMetadata() == null) throw new ObjectStoreServiceException("Empty input Record");
359 359

  
360 360
		if (existIDStartsWith(record.getFileMetadata().getObjectID())) {
361 361
			log.debug("Object already exist ");
......
373 373
		long timestamp = System.currentTimeMillis();
374 374
		String URI = "";
375 375

  
376
		if (record.getInputStream() == null) { throw new ObjectStoreServiceException("missing inputstream on record " + record.getFileMetadata().getObjectID()); }
376
		if (record.getInputStream() == null) throw new ObjectStoreServiceException("missing inputstream on record " + record.getFileMetadata().getObjectID());
377 377
		final GridFSInputFile currentFile = collection.createFile(record.getInputStream());
378 378
		currentFile.setId(record.getFileMetadata().getObjectID());
379 379
		currentFile.setFilename(record.getFileMetadata().getObjectID());
......
381 381
		metadata.put("id", record.getFileMetadata().getObjectID());
382 382
		metadata.put("mime", record.getFileMetadata().getMimeType());
383 383
		metadata.put("originalObject", record.getFileMetadata().toJSON());
384

  
385 384
		metadata.put("timestamp", timestamp);
386 385
		try {
387 386
			URI = baseURI + "?objectStore=" + URLEncoder.encode(id, "UTF-8") + "&objectId="
388 387
					+ URLEncoder.encode(record.getFileMetadata().getObjectID(), "UTF-8");
389 388
			metadata.put("uri", URI);
389
			if (metadata.get("tags") == null) {
390
				metadata.put("tags", Sets.newHashSet("UNVISITED"));
391
			} else {
392
				final BasicDBList tagList = (BasicDBList) metadata.get("tags");
393
				final Set<String> inputSet = Sets.newHashSet();
394
				for (final Object o : tagList) {
395
					inputSet.add((String) o);
396
				}
397
				inputSet.add("UNVISITED");
398
				metadata.put("tags", inputSet);
399
			}
390 400
			currentFile.setMetaData(metadata);
391 401
			currentFile.save();
392 402

  
......
521 531
	 */
522 532
	@Override
523 533
	public int tagIds(final Iterable<String> ids, final String tag) {
524
		if (ids == null) { return 0; }
534
		if (ids == null) return 0;
525 535

  
526 536
		int counter = 0;
527 537
		for (final String id : ids) {
......
558 568
	 */
559 569
	@Override
560 570
	public int untagIds(final Iterable<String> ids, final String tag) {
561
		if (ids == null) { return 0; }
571
		if (ids == null) return 0;
562 572

  
563 573
		int counter = 0;
564 574
		for (final String id : ids) {
......
659 669
	 *             the object store file not found exception
660 670
	 */
661 671
	private void checkSingleItem(final String objectId, final List<GridFSDBFile> file) throws ObjectStoreFileNotFoundException {
662
		if (file.isEmpty()) { throw new ObjectStoreFileNotFoundException(String.format("Object file not found with id: %s", objectId)); }
663
		if (file.size() > 1) { throw new IllegalStateException(String.format("More than one objects found with id: %s", objectId)); }
672
		if (file.isEmpty()) throw new ObjectStoreFileNotFoundException(String.format("Object file not found with id: %s", objectId));
673
		if (file.size() > 1) throw new IllegalStateException(String.format("More than one objects found with id: %s", objectId));
664 674
	}
665 675

  
666 676
	/**
modules/dnet-gridfs-objectstore/branches/tag/src/main/java/eu/dnetlib/data/objectstore/modular/gridFS/GridFSObjectstoreResultSetListener.java
23 23
/**
24 24
 * The listener interface for receiving gridFSObjectstoreResultSet events. The class that is interested in processing a
25 25
 * gridFSObjectstoreResultSet event implements this interface, and the object created with that class is registered with a component using
26
 * the component's <code>addGridFSObjectstoreResultSetListener<code> method. When
27
 * the gridFSObjectstoreResultSet event occurs, that object's appropriate
28
 * method is invoked.
26
 * the component's <code>addGridFSObjectstoreResultSetListener<code> method. When the gridFSObjectstoreResultSet event occurs, that object's
27
 * appropriate method is invoked.
29 28
 *
30 29
 * @see GridFSObjectstoreResultSetEvent
31 30
 */
......
66 65

  
67 66
	/*
68 67
	 * (non-Javadoc)
69
	 * 
68
	 *
70 69
	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getResult(int, int)
71 70
	 */
72 71
	@Override
......
82 81
			List<GridFSDBFile> out = collection.find(q);
83 82

  
84 83
			return MappedCollection.listMap(out, ObjectStoreFileUtility.asJSON(baseURI, objectStoreID));
85
		} else if (tags != null || tags.isEmpty()) {
84
		} else if (tags != null && !tags.isEmpty()) {
86 85
			if (currentCursor == null || cursorPosition > from) {
87 86
				createCurrentCursor(this.tags);
88 87
			}
......
154 153

  
155 154
	/*
156 155
	 * (non-Javadoc)
157
	 * 
156
	 *
158 157
	 * @see eu.dnetlib.enabling.resultset.TypedResultSetListener#getSize()
159 158
	 */
160 159
	@Override
......
192 191

  
193 192
	/*
194 193
	 * (non-Javadoc)
195
	 * 
194
	 *
196 195
	 * @see eu.dnetlib.enabling.resultset.ResultSetAware#setResultSet(eu.dnetlib.enabling.resultset.ResultSet)
197 196
	 */
198 197
	@Override
modules/dnet-gridfs-objectstore/branches/tag/src/main/java/eu/dnetlib/data/objectstore/modular/gridFS/GridFSObjectstoreDaoImpl.java
49 49
			}
50 50
		}
51 51
		if (!hasTimestampIndex) {
52
			coll.ensureIndex("metadata.timestamp");
52
			coll.createIndex("metadata.timestamp");
53 53
		}
54 54
	}
55 55

  
modules/dnet-gridfs-objectstore/branches/tag/pom.xml
9 9
	<groupId>eu.dnetlib</groupId>
10 10
	<artifactId>dnet-gridfs-objectstore</artifactId>
11 11
	<packaging>jar</packaging>
12
	<version>4.0.2-SNAPSHOT</version>
12
	<version>4.0.2-TAG-SNAPSHOT</version>
13 13
	<scm>
14 14
	  <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-gridfs-objectstore/trunk</developerConnection>
15 15
	</scm>
......
17 17
		<dependency>
18 18
			<groupId>eu.dnetlib</groupId>
19 19
			<artifactId>dnet-modular-objectstore-service</artifactId>
20
			<version>[4.0.0,5.0.0)</version>
20
			<version>[4.0.2-TAG-SNAPSHOT]</version>
21 21
		</dependency>
22 22
		<dependency>
23 23
			<groupId>eu.dnetlib</groupId>
modules/dnet-modular-objectstore-service/branches/tag/src/main/resources/eu/dnetlib/enabling/views/inspector/objectstore.st
34 34
   			<tr><td>Original URL :</td><td><a href="$it.downloadedURL$">$it.downloadedURL$</a></tr>
35 35
   			<tr><td>md5Sum :</td><td>$it.md5Sum$</td></tr>
36 36
   			<tr><td>file size :</td><td>$it.fileSizeKB$ kb</td></tr>
37
   			<tr><td>Tags :</td><td>[$it.tags:{$it$ , }$]</td></tr>
37 38
   		</table>
38 39
   		
39 40
   	</div>
modules/dnet-modular-objectstore-service/branches/tag/pom.xml
9 9
	<groupId>eu.dnetlib</groupId>
10 10
	<artifactId>dnet-modular-objectstore-service</artifactId>
11 11
	<packaging>jar</packaging>
12
	<version>4.0.2-SNAPSHOT</version>
12
	<version>4.0.2-TAG-SNAPSHOT</version>
13 13
	<scm>
14 14
	  <developerConnection>scm:svn:https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/dnet-modular-objectstore-service/trunk</developerConnection>
15 15
	</scm>
......
17 17
		<dependency>
18 18
			<groupId>eu.dnetlib</groupId>
19 19
			<artifactId>dnet-objectstore-rmi</artifactId>
20
			<version>[2.0.0,3.0.0)</version>
20
			<version>[2.0.5-TAG-SNAPSHOT]</version>
21 21
		</dependency>
22 22
		<dependency>
23 23
			<groupId>eu.dnetlib</groupId>

Also available in: Unified diff