Project

General

Profile

« Previous | Next » 

Revision 38780

check if the collection exists

View differences:

DnetLoggerMongoDao.java
6 6
import java.util.Map.Entry;
7 7

  
8 8
import org.apache.commons.lang.StringUtils;
9
import org.apache.commons.logging.Log;
10
import org.apache.commons.logging.LogFactory;
9 11
import org.springframework.beans.factory.annotation.Required;
10 12

  
11 13
import com.google.common.collect.Maps;
......
21 23

  
22 24
public class DnetLoggerMongoDao implements DnetLoggerDao {
23 25

  
26
	private static final Log log = LogFactory.getLog(DnetLoggerMongoDao.class);
27

  
24 28
	private DB db;
25 29

  
26 30
	@Override
27 31
	public void init(final String collection) {
28
		db.createCollection(collection, null);
32
		if (!db.collectionExists(collection)) {
33
			log.info(String.format("creating collection %s", collection));
34
			db.createCollection(collection, null);
35
		}
29 36
	}
30 37

  
31 38
	@Override

Also available in: Unified diff