Commit 8cdcac5d authored by Matija Obreza's avatar Matija Obreza

Addressed issues reported by FindBugs

parent 5e1a9159
......@@ -62,11 +62,13 @@ public class AccessionEsTrait {
t.sval = new HashSet<String>();
for (ExperimentTrait et : vals) {
Object value = et.getValue();
if (et == null || value == null)
if (et == null)
continue;
Object value = et.getValue();
if (value instanceof String)
if (value == null)
continue;
else if (value instanceof String)
t.sval.add((String) value);
else if (value instanceof Integer)
t.ival.add(((Integer) value).longValue());
......
......@@ -23,7 +23,7 @@ public class Geo {
Geo g = new Geo();
g.datum = StringUtils.defaultIfBlank(ag.getDatum(), null);
g.elevation = ag.getElevation();
if (ag.getLongitude() != null & ag.getLatitude() != null)
if (ag.getLongitude() != null && ag.getLatitude() != null)
g.coordinates = new Double[] { ag.getLongitude(), ag.getLatitude() };
g.longitude = ag.getLongitude();
g.latitude = ag.getLatitude();
......
......@@ -31,7 +31,8 @@ public class AccessionOpResponse implements Serializable {
private String error;
private UpsertResult result;
public static class UpsertResult {
public static class UpsertResult implements Serializable {
private static final long serialVersionUID = -7936259406612250074L;
private Type action = Type.NOOP;
private UUID uuid;
......
......@@ -504,10 +504,10 @@ public class GenesysServiceImpl implements GenesysService, DatasetService {
@Override
public List<AllStuff> loadAllStuff(Collection<Long> accessionIds) {
List<AllStuff> alls = new ArrayList<AllStuff>(accessionIds.size());
if (accessionIds == null || accessionIds.size() == 0) {
return alls;
return Collections.emptyList();
}
List<AllStuff> alls = new ArrayList<AllStuff>(accessionIds.size());
HashMap<Long, AllStuff> map = new HashMap<Long, AllStuff>();
for (Long accessionId : accessionIds) {
......
......@@ -99,6 +99,10 @@ public class CountryAlternateNamesUpdater implements CountryNamesUpdater {
// Get hold of the response entity
final HttpEntity entity = response.getEntity();
if (entity == null) {
LOG.warn("No HttpEntity in response, bailing out");
return;
}
LOG.debug(entity.getContentType() + " " + entity.getContentLength());
// If the response does not enclose an entity, there is no
......
......@@ -94,6 +94,10 @@ public class ITPGRFAStatusUpdater {
// Get hold of the response entity
final HttpEntity entity = response.getEntity();
if (entity == null) {
LOG.warn("No HttpEntity in response, bailing out");
return;
}
LOG.debug(entity.getContentType() + " " + entity.getContentLength());
// If the response does not enclose an entity, there is no
......
......@@ -113,6 +113,10 @@ public class InstituteUpdater {
// Get hold of the response entity
final HttpEntity entity = response.getEntity();
if (entity == null) {
LOG.warn("No HttpEntity in response, bailing out");
return;
}
LOG.debug(entity.getContentType() + " " + entity.getContentLength());
// If the response does not enclose an entity, there is no
......
......@@ -21,6 +21,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.commons.io.IOUtils;
......@@ -130,7 +131,7 @@ public class SGSVUpdate {
}
if (line.length > SGSV_HEADERS.length) {
LOG.warn("Funny line length " + line);
LOG.warn("Funny line length " + Arrays.toString(line));
}
bulk.add(line);
......
......@@ -194,25 +194,33 @@ public class OAuthManagementController extends RequestsController {
final AclObjectIdentity objectIdentity = aclService.ensureObjectIdentity(CLAZZ, id);
resultMap.put("aclObjectIdentity", objectIdentity);
resultMap.put("aclEntries", aclService.getPermissions(id, CLAZZ));
Set<User> users = new HashSet<>();
resultMap.put("users", users);
if (objectIdentity != null) {
resultMap.put("aclPermissions", aclService.getAvailablePermissions(CLAZZ));
AclSid ownerSid = objectIdentity.getOwnerSid();
if (ownerSid != null) {
User user = userService.getUserByUuid(ownerSid.getSid());
if (user!=null) {
users.add(user);
} else
LOG.warn("Could not find user by UUID=" + ownerSid.getSid());
} else
LOG.warn("ObjectIdentity does not provide ownerSid");
}
List<AclSid> aclSids = aclService.getSids(id, CLAZZ);
resultMap.put("aclSids", aclSids);
resultMap.put("aclEntries", aclService.getPermissions(id, CLAZZ));
Set<User> users = new HashSet<>();
users.add(userService.getUserByUuid(objectIdentity.getOwnerSid().getSid()));
for (AclSid sid: aclSids){
users.add(userService.getUserByUuid(sid.getSid()));
users.add(userService.getUserByUuid(sid.getSid()));
}
resultMap.put("users", users);
return resultMap;
}
......
......@@ -41,7 +41,7 @@ import com.hazelcast.spring.cache.HazelcastCacheManager;
@ActiveProfiles("dev")
@Ignore
public class WorldClimUpdaterDummyTest {
@Import({ HazelcastConfig.class, JpaDataConfig.class })
public static class Config {
......@@ -60,7 +60,7 @@ public class WorldClimUpdaterDummyTest {
public HttpClientBuilder httpClientBuilder() {
return HttpClientBuilder.create();
}
@Bean
public GenesysLowlevelRepository genesysLowlevel() {
return new GenesysLowlevelRepositoryCustomImpl();
......@@ -108,7 +108,7 @@ public class WorldClimUpdaterDummyTest {
}
});
if (altFiles.length == 0) {
if (altFiles == null || altFiles.length == 0) {
System.out.println("Must download");
List<File> files = worldClimUpdater.downloadAndExtract(destination, "alt_2-5m_bil.zip");
for (File file : files) {
......@@ -150,7 +150,7 @@ public class WorldClimUpdaterDummyTest {
}
});
if (altFiles.length == 0) {
if (altFiles == null || altFiles.length == 0) {
System.out.println("Must download");
List<File> files = worldClimUpdater.downloadAndExtract(destination, "alt_2-5m_bil.zip");
for (File file : files) {
......@@ -163,7 +163,7 @@ public class WorldClimUpdaterDummyTest {
GenericGridFile ggf = new GenericGridFile(destination, "alt");
Header header = ggf.readHeader();
short nullValue=(short) header.getNoDataValue();
short nullValue = (short) header.getNoDataValue();
MappedByteBuffer x = ggf.mapDataBuffer();
for (int i = 0; i < header.getColumns(); i++) {
System.out.println(x.getShort(i * 2));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment