DATADOC-270 - Removed critical Sonar warnings from codebase.
This commit is contained in:
@@ -2,10 +2,6 @@ package org.springframework.data.persistence.document.mongodb;
|
|||||||
|
|
||||||
import javax.persistence.EntityManagerFactory;
|
import javax.persistence.EntityManagerFactory;
|
||||||
|
|
||||||
import com.mongodb.BasicDBObject;
|
|
||||||
import com.mongodb.DBCollection;
|
|
||||||
import com.mongodb.DBObject;
|
|
||||||
import com.mongodb.MongoException;
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.dao.DataAccessException;
|
import org.springframework.dao.DataAccessException;
|
||||||
@@ -18,6 +14,11 @@ import org.springframework.data.persistence.ChangeSetBacked;
|
|||||||
import org.springframework.data.persistence.ChangeSetPersister;
|
import org.springframework.data.persistence.ChangeSetPersister;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
|
import com.mongodb.BasicDBObject;
|
||||||
|
import com.mongodb.DBCollection;
|
||||||
|
import com.mongodb.DBObject;
|
||||||
|
import com.mongodb.MongoException;
|
||||||
|
|
||||||
public class MongoChangeSetPersister implements ChangeSetPersister<Object> {
|
public class MongoChangeSetPersister implements ChangeSetPersister<Object> {
|
||||||
|
|
||||||
private static final String ENTITY_CLASS = "_entity_class";
|
private static final String ENTITY_CLASS = "_entity_class";
|
||||||
@@ -108,10 +109,10 @@ public class MongoChangeSetPersister implements ChangeSetPersister<Object> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String collName = getCollectionNameForEntity(entity.getClass());
|
String collName = getCollectionNameForEntity(entity.getClass());
|
||||||
DBCollection dbc = mongoTemplate.getCollection(collName);
|
if (mongoTemplate.getCollection(collName) == null) {
|
||||||
if (dbc == null) {
|
mongoTemplate.createCollection(collName);
|
||||||
dbc = mongoTemplate.createCollection(collName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String key : cs.getValues().keySet()) {
|
for (String key : cs.getValues().keySet()) {
|
||||||
if (key != null && !key.startsWith("_") && !key.equals(ChangeSetPersister.ID_KEY)) {
|
if (key != null && !key.startsWith("_") && !key.equals(ChangeSetPersister.ID_KEY)) {
|
||||||
Object value = cs.getValues().get(key);
|
Object value = cs.getValues().get(key);
|
||||||
|
|||||||
@@ -35,10 +35,10 @@ public class CannotGetMongoDbConnectionException extends DataAccessResourceFailu
|
|||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CannotGetMongoDbConnectionException(String msg, String database, String username, char[] password2) {
|
public CannotGetMongoDbConnectionException(String msg, String database, String username, char[] password) {
|
||||||
super(msg);
|
super(msg);
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password2;
|
this.password = password == null ? null : password.clone();
|
||||||
this.database = database;
|
this.database = database;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1277,7 +1277,7 @@ public class MongoTemplate implements MongoOperations, ApplicationContextAware {
|
|||||||
|
|
||||||
if (entityClass == null) {
|
if (entityClass == null) {
|
||||||
throw new InvalidDataAccessApiUsageException(
|
throw new InvalidDataAccessApiUsageException(
|
||||||
"No class parameter provided, entity collection can't be determined for " + entityClass);
|
"No class parameter provided, entity collection can't be determined!");
|
||||||
}
|
}
|
||||||
|
|
||||||
MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityClass);
|
MongoPersistentEntity<?> entity = mappingContext.getPersistentEntity(entityClass);
|
||||||
|
|||||||
@@ -100,9 +100,8 @@ public class QueryMapper {
|
|||||||
newConditions.add(getMappedObject((DBObject) iter.next(), entity));
|
newConditions.add(getMappedObject((DBObject) iter.next(), entity));
|
||||||
}
|
}
|
||||||
value = newConditions;
|
value = newConditions;
|
||||||
} else {
|
|
||||||
// TODO: Implement other forms of conversion (like @Alias and whatnot)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newDbo.put(newKey, value);
|
newDbo.put(newKey, value);
|
||||||
}
|
}
|
||||||
return newDbo;
|
return newDbo;
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ public class MappingMongoConverter extends AbstractMongoConverter implements App
|
|||||||
spelCtx.setBeanResolver(new BeanFactoryResolver(applicationContext));
|
spelCtx.setBeanResolver(new BeanFactoryResolver(applicationContext));
|
||||||
}
|
}
|
||||||
if (!(dbo instanceof BasicDBList)) {
|
if (!(dbo instanceof BasicDBList)) {
|
||||||
String[] keySet = dbo.keySet().toArray(new String[] {});
|
String[] keySet = dbo.keySet().toArray(new String[dbo.keySet().size()]);
|
||||||
for (String key : keySet) {
|
for (String key : keySet) {
|
||||||
spelCtx.setVariable(key, dbo.get(key));
|
spelCtx.setVariable(key, dbo.get(key));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,6 @@ public class Circle {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("Circle [center=%s, radius=%d]", center, radius);
|
return String.format("Circle [center=%s, radius=%f]", center, radius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class OrCriteria implements CriteriaDefinition {
|
|||||||
|
|
||||||
public OrCriteria(Query[] queries) {
|
public OrCriteria(Query[] queries) {
|
||||||
super();
|
super();
|
||||||
this.queries = queries;
|
this.queries = queries == null ? null : queries.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user