use of org.springframework.dao.EmptyResultDataAccessException in project perun by CESNET.
the class AttributesManagerImpl method getAttributes.
public List<Attribute> getAttributes(PerunSession sess, Vo vo, List<String> attrNames) throws InternalErrorException {
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("vId", vo.getId());
parameters.addValue("nSC", AttributesManager.NS_VO_ATTR_CORE);
parameters.addValue("nSO", AttributesManager.NS_VO_ATTR_OPT);
parameters.addValue("nSD", AttributesManager.NS_VO_ATTR_DEF);
parameters.addValue("nSV", AttributesManager.NS_VO_ATTR_VIRT);
parameters.addValue("attrNames", attrNames);
try {
return namedParameterJdbcTemplate.query("select " + getAttributeMappingSelectQuery("vot") + " from attr_names " + "left join vo_attr_values vot on id=vot.attr_id and vo_id=:vId " + "where namespace in ( :nSC,:nSO,:nSD,:nSV ) and attr_names.attr_name in ( :attrNames )", parameters, new AttributeRowMapper(sess, this, vo));
} catch (EmptyResultDataAccessException ex) {
return new ArrayList<Attribute>();
} catch (RuntimeException ex) {
throw new InternalErrorException(ex);
}
}
use of org.springframework.dao.EmptyResultDataAccessException in project perun by CESNET.
the class DatabaseManagerImpl method updateDatabaseVersion.
public void updateDatabaseVersion(List<DBVersion> dbVersions) throws InternalErrorException {
Collections.reverse(dbVersions);
for (DBVersion v : dbVersions) {
log.debug("Executing update commands of version " + v.getVersion());
List<String> successfulCommands = new ArrayList<>();
for (String c : v.getCommands()) {
try {
jdbc.execute(c);
log.debug("Command executed: " + c);
successfulCommands.add(c);
} catch (EmptyResultDataAccessException ex) {
log.error("Update unsuccessful. All versions before " + v.getVersion() + " were successfully executed. " + "Error executing command in version " + v.getVersion() + ": " + c, ex);
log.error("Successful commands from " + v.getVersion() + ": " + successfulCommands);
throw new ConsistencyErrorException("Update unsuccessful. Error executing command in version " + v.getVersion() + ": " + c, ex);
} catch (RuntimeException ex) {
log.error("Update unsuccessful. All versions before " + v.getVersion() + " were successfully executed. " + "Error executing command in version " + v.getVersion() + ": " + c, ex);
log.error("Successful commands from " + v.getVersion() + ": " + successfulCommands);
throw new InternalErrorException("Update unsuccessful. Error executing command in version " + v.getVersion() + ": " + c, ex);
}
}
}
}
use of org.springframework.dao.EmptyResultDataAccessException in project 2017-01-HUDI-MAC-CHAR by NHNNEXT.
the class UserRepository method findUserByNickname.
public User findUserByNickname(String nickname) {
String query = "SELECT * FROM User WHERE nickname = ?";
List<User> resultUser;
try {
resultUser = jdbcTemplate.query(query, (rs, rowNum) -> {
User user = new User();
user.setId(rs.getLong("id"));
user.setEmail(rs.getString("email"));
user.setPassword(rs.getString("password"));
user.setNickname(rs.getString("nickname"));
return user;
}, nickname);
} catch (EmptyResultDataAccessException e) {
log.error(e.getMessage());
return null;
}
return resultUser.size() > 0 ? resultUser.get(0) : null;
}
use of org.springframework.dao.EmptyResultDataAccessException in project perun by CESNET.
the class VosManagerImpl method getAdmins.
@Deprecated
@Override
public List<User> getAdmins(PerunSession sess, Vo vo) throws InternalErrorException {
try {
Set<User> setOfAdmins = new HashSet<User>();
// direct admins
setOfAdmins.addAll(jdbc.query("select " + UsersManagerImpl.userMappingSelectQuery + " from authz join users on authz.user_id=users.id " + "where authz.vo_id=? and authz.role_id=(select id from roles where name='voadmin')", UsersManagerImpl.USER_MAPPER, vo.getId()));
// admins through a group
List<Group> listOfGroupAdmins = getAdminGroups(sess, vo);
for (Group group : listOfGroupAdmins) {
setOfAdmins.addAll(jdbc.query("select " + UsersManagerImpl.userMappingSelectQuery + " from users join members on users.id=members.user_id " + "join groups_members on groups_members.member_id=members.id where groups_members.group_id=?", UsersManagerImpl.USER_MAPPER, group.getId()));
}
return new ArrayList(setOfAdmins);
} catch (EmptyResultDataAccessException ex) {
return new ArrayList<User>();
} catch (RuntimeException ex) {
throw new InternalErrorException(ex);
}
}
use of org.springframework.dao.EmptyResultDataAccessException in project perun by CESNET.
the class UsersManagerImpl method getUserExtsourcesByIds.
public List<UserExtSource> getUserExtsourcesByIds(PerunSession sess, List<Integer> ids) throws InternalErrorException {
if (ids.size() == 0) {
return new ArrayList<UserExtSource>();
}
MapSqlParameterSource parameters = new MapSqlParameterSource();
parameters.addValue("ids", ids);
try {
return namedParameterJdbcTemplate.query("select " + userExtSourceMappingSelectQuery + "," + ExtSourcesManagerImpl.extSourceMappingSelectQuery + " from user_ext_sources left join ext_sources on user_ext_sources.ext_sources_id=ext_sources.id where" + " user_ext_sources.id in ( :ids )", parameters, USEREXTSOURCE_MAPPER);
} catch (EmptyResultDataAccessException ex) {
return new ArrayList<UserExtSource>();
} catch (RuntimeException e) {
throw new InternalErrorException(e);
}
}
Aggregations