Commit 995640b1 authored by Matija Obreza's avatar Matija Obreza

Merge branch 'npe' into 'master'

NPE

See merge request genesys-pgr/genesys-server!117
parents 94c118d0 d1867dae
......@@ -40,7 +40,7 @@ public class AuthUserDetailsService implements UserDetailsService {
if (user == null) {
LOG.warn("User does not exist: {}", email);
return null;
throw new UsernameNotFoundException(email);
}
return userService.getUserDetails(user);
......
......@@ -597,7 +597,7 @@ public class BatchRESTServiceImpl implements BatchRESTService {
UpdateTargets targets = new UpdateTargets();
targets.addKwsItem(TermConstants.PASSPORT_DATA);
savedData.stream().map(a -> a.getDoi()).filter(doi -> doi != null).forEach(doi -> targets.addDoisItem(doi));
if (targets.getDois().size() > 0) {
if (targets.getDois() != null && targets.getDois().size() > 0) {
try {
LOG.debug("Updating GLIS for {} accessions with DOIs", targets.getDois().size());
List<UpdatedTarget> glisResponse = glisGenesysApi.registerGenesysAsTarget(targets);
......
......@@ -55,7 +55,6 @@ import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -264,11 +263,10 @@ public class UserServiceImpl extends BasicUserServiceImpl<UserRole, User> implem
public User getUserByEmail(String email) {
final User user = userRepository.findByEmail(email);
if (user == null) {
throw new UsernameNotFoundException(email);
if (user != null) {
user.getRoles().size();
}
user.getRoles().size();
return user;
}
......@@ -276,11 +274,10 @@ public class UserServiceImpl extends BasicUserServiceImpl<UserRole, User> implem
public User getUserByUuid(String uuid) {
final User user = userRepository.findByUuid(uuid);
if (user == null) {
throw new UsernameNotFoundException(uuid);
if (user != null) {
user.getRoles().size();
}
user.getRoles().size();
return user;
}
......
......@@ -25,7 +25,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.RandomUtils;
import org.genesys.blocks.security.UserException;
import org.genesys2.server.model.impl.Country;
import org.genesys2.server.model.impl.Crop;
import org.genesys2.server.model.impl.User;
......@@ -62,10 +61,11 @@ public class JspHelper {
if (userId == null) {
return null;
}
try {
final User user = userService.getUser(userId);
final User user = userService.getUser(userId);
if (user != null) {
return user.getFullName();
} catch (final UserException e) {
} else {
return null;
}
}
......
......@@ -29,7 +29,6 @@ import com.hp.hpl.jena.vocabulary.RDF;
import com.hp.hpl.jena.vocabulary.RDFS;
import org.genesys.blocks.model.AuditedVersionedModel;
import org.genesys.blocks.security.UserException;
import org.genesys2.rdf.model.dc.DublinCore;
import org.genesys2.rdf.model.dwc.DarwinCore;
import org.genesys2.rdf.model.skos.SKOS;
......@@ -155,14 +154,10 @@ public abstract class RdfBaseController extends BaseController {
// dc:creator <user>
final Long userId = entity.getCreatedBy();
if (userId != null) {
try {
final User user = userService.getUser(userId);
final User user = userService.getUser(userId);
if (user != null) {
// just put the user's name for now?
subject.addProperty(DC_11.creator, user.getFullName());
} catch (final UserException e) {
this.LOG.debug("Invalid user access?", e);
}
}
......
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