Merge remote-tracking branch 'origin/pr/1464'
This commit is contained in:
@@ -88,14 +88,14 @@ public class AbstractDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <T> List<T> query(String sql, RowMapper rowMapper, Object... args) {
|
protected <T> List<T> query(String sql, RowMapper<T> rowMapper, Object... args) {
|
||||||
long t = System.nanoTime();
|
long t = System.nanoTime();
|
||||||
List<T> result = getJdbcTemplate().query(sql, args, rowMapper);
|
List<T> result = getJdbcTemplate().query(sql, args, rowMapper);
|
||||||
log(sql, t);
|
log(sql, t);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <T> List<T> namedQuery(String sql, RowMapper rowMapper, Map<String, Object> args) {
|
protected <T> List<T> namedQuery(String sql, RowMapper<T> rowMapper, Map<String, Object> args) {
|
||||||
long t = System.nanoTime();
|
long t = System.nanoTime();
|
||||||
List<T> result = getNamedParameterJdbcTemplate().query(sql, args, rowMapper);
|
List<T> result = getNamedParameterJdbcTemplate().query(sql, args, rowMapper);
|
||||||
log(sql, t);
|
log(sql, t);
|
||||||
@@ -165,12 +165,12 @@ public class AbstractDao {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <T> T queryOne(String sql, RowMapper rowMapper, Object... args) {
|
protected <T> T queryOne(String sql, RowMapper<T> rowMapper, Object... args) {
|
||||||
List<T> list = query(sql, rowMapper, args);
|
List<T> list = query(sql, rowMapper, args);
|
||||||
return list.isEmpty() ? null : list.get(0);
|
return list.isEmpty() ? null : list.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <T> T namedQueryOne(String sql, RowMapper rowMapper, Map<String, Object> args) {
|
protected <T> T namedQueryOne(String sql, RowMapper<T> rowMapper, Map<String, Object> args) {
|
||||||
List<T> list = namedQuery(sql, rowMapper, args);
|
List<T> list = namedQuery(sql, rowMapper, args);
|
||||||
return list.isEmpty() ? null : list.get(0);
|
return list.isEmpty() ? null : list.get(0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class AlbumDao extends AbstractDao {
|
|||||||
|
|
||||||
private static final String QUERY_COLUMNS = "id, " + INSERT_COLUMNS;
|
private static final String QUERY_COLUMNS = "id, " + INSERT_COLUMNS;
|
||||||
|
|
||||||
private final RowMapper rowMapper = new AlbumMapper();
|
private final RowMapper<Album> rowMapper = new AlbumMapper();
|
||||||
|
|
||||||
public Album getAlbum(int id) {
|
public Album getAlbum(int id) {
|
||||||
return queryOne("select " + QUERY_COLUMNS + " from album where id=?", rowMapper, id);
|
return queryOne("select " + QUERY_COLUMNS + " from album where id=?", rowMapper, id);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class ArtistDao extends AbstractDao {
|
|||||||
private static final String INSERT_COLUMNS = "name, cover_art_path, album_count, last_scanned, present, folder_id";
|
private static final String INSERT_COLUMNS = "name, cover_art_path, album_count, last_scanned, present, folder_id";
|
||||||
private static final String QUERY_COLUMNS = "id, " + INSERT_COLUMNS;
|
private static final String QUERY_COLUMNS = "id, " + INSERT_COLUMNS;
|
||||||
|
|
||||||
private final RowMapper rowMapper = new ArtistMapper();
|
private final RowMapper<Artist> rowMapper = new ArtistMapper();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the artist with the given name.
|
* Returns the artist with the given name.
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ public class MediaFileDao extends AbstractDao {
|
|||||||
public static final int VERSION = 4;
|
public static final int VERSION = 4;
|
||||||
|
|
||||||
private final RowMapper<MediaFile> rowMapper = new MediaFileMapper();
|
private final RowMapper<MediaFile> rowMapper = new MediaFileMapper();
|
||||||
private final RowMapper musicFileInfoRowMapper = new MusicFileInfoMapper();
|
private final RowMapper<MediaFile> musicFileInfoRowMapper = new MusicFileInfoMapper();
|
||||||
private final RowMapper genreRowMapper = new GenreMapper();
|
private final RowMapper<Genre> genreRowMapper = new GenreMapper();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the media file for the given path.
|
* Returns the media file for the given path.
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class PlayQueueDao extends AbstractDao {
|
|||||||
|
|
||||||
private static final String INSERT_COLUMNS = "username, current, position_millis, changed, changed_by";
|
private static final String INSERT_COLUMNS = "username, current, position_millis, changed, changed_by";
|
||||||
private static final String QUERY_COLUMNS = "id, " + INSERT_COLUMNS;
|
private static final String QUERY_COLUMNS = "id, " + INSERT_COLUMNS;
|
||||||
private final RowMapper rowMapper = new PlayQueueMapper();
|
private final RowMapper<SavedPlayQueue> rowMapper = new PlayQueueMapper();
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public SavedPlayQueue getPlayQueue(String username) {
|
public SavedPlayQueue getPlayQueue(String username) {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public class PlaylistDao extends AbstractDao {
|
|||||||
private static final String INSERT_COLUMNS = "username, is_public, name, comment, file_count, duration_seconds, " +
|
private static final String INSERT_COLUMNS = "username, is_public, name, comment, file_count, duration_seconds, " +
|
||||||
"created, changed, imported_from";
|
"created, changed, imported_from";
|
||||||
private static final String QUERY_COLUMNS = "id, " + INSERT_COLUMNS;
|
private static final String QUERY_COLUMNS = "id, " + INSERT_COLUMNS;
|
||||||
private final RowMapper rowMapper = new PlaylistMapper();
|
private final RowMapper<Playlist> rowMapper = new PlaylistMapper();
|
||||||
|
|
||||||
public List<Playlist> getReadablePlaylistsForUser(String username) {
|
public List<Playlist> getReadablePlaylistsForUser(String username) {
|
||||||
|
|
||||||
|
|||||||
@@ -182,8 +182,8 @@ public class PodcastDao extends AbstractDao {
|
|||||||
update(sql, id);
|
update(sql, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class PodcastChannelRowMapper implements RowMapper {
|
private static class PodcastChannelRowMapper implements RowMapper<PodcastChannel> {
|
||||||
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
|
public PodcastChannel mapRow(ResultSet rs, int rowNum) throws SQLException {
|
||||||
return new PodcastChannel(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5),
|
return new PodcastChannel(rs.getInt(1), rs.getString(2), rs.getString(3), rs.getString(4), rs.getString(5),
|
||||||
PodcastStatus.valueOf(rs.getString(6)), rs.getString(7));
|
PodcastStatus.valueOf(rs.getString(6)), rs.getString(7));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,14 +79,13 @@ public class ParameterDecodingFilter implements Filter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map getParameterMap() {
|
public Map<String, String[]> getParameterMap() {
|
||||||
Map map = super.getParameterMap();
|
Map<String, String[]> map = super.getParameterMap();
|
||||||
Map<String, String[]> result = new HashMap<String, String[]>();
|
Map<String, String[]> result = new HashMap<String, String[]>();
|
||||||
|
|
||||||
for (Object o : map.entrySet()) {
|
for (Map.Entry<String, String[]> entry : map.entrySet()) {
|
||||||
Map.Entry entry = (Map.Entry) o;
|
String name = entry.getKey();
|
||||||
String name = (String) entry.getKey();
|
String[] values = entry.getValue();
|
||||||
String[] values = (String[]) entry.getValue();
|
|
||||||
|
|
||||||
if (name.endsWith(PARAM_SUFFIX)) {
|
if (name.endsWith(PARAM_SUFFIX)) {
|
||||||
result.put(name.replace(PARAM_SUFFIX, ""), decode(values));
|
result.put(name.replace(PARAM_SUFFIX, ""), decode(values));
|
||||||
@@ -98,11 +97,11 @@ public class ParameterDecodingFilter implements Filter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Enumeration getParameterNames() {
|
public Enumeration<String> getParameterNames() {
|
||||||
Enumeration e = super.getParameterNames();
|
Enumeration<String> e = super.getParameterNames();
|
||||||
Vector<String> v = new Vector<String>();
|
Vector<String> v = new Vector<String>();
|
||||||
while (e.hasMoreElements()) {
|
while (e.hasMoreElements()) {
|
||||||
String name = (String) e.nextElement();
|
String name = e.nextElement();
|
||||||
if (name.endsWith(PARAM_SUFFIX)) {
|
if (name.endsWith(PARAM_SUFFIX)) {
|
||||||
name = name.replace(PARAM_SUFFIX, "");
|
name = name.replace(PARAM_SUFFIX, "");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ public class ResponseHeaderFilter implements Filter {
|
|||||||
HttpServletResponse response = (HttpServletResponse) res;
|
HttpServletResponse response = (HttpServletResponse) res;
|
||||||
|
|
||||||
// Sets the provided HTTP response parameters
|
// Sets the provided HTTP response parameters
|
||||||
for (Enumeration e = filterConfig.getInitParameterNames(); e.hasMoreElements();) {
|
for (Enumeration<String> e = filterConfig.getInitParameterNames(); e.hasMoreElements();) {
|
||||||
String headerName = (String) e.nextElement();
|
String headerName = e.nextElement();
|
||||||
response.setHeader(headerName, filterConfig.getInitParameter(headerName));
|
response.setHeader(headerName, filterConfig.getInitParameter(headerName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user