Fixed media not showing up
This commit is contained in:
parent
886b4cdb88
commit
3024826f57
7 changed files with 35 additions and 13 deletions
|
|
@ -38,7 +38,7 @@
|
||||||
<div class="grid image-grid">
|
<div class="grid image-grid">
|
||||||
<c:forEach items="${media}" var="item">
|
<c:forEach items="${media}" var="item">
|
||||||
<div class="grid-item photo-thumb col-md-3 col-sm-6 col-xs-12">
|
<div class="grid-item photo-thumb col-md-3 col-sm-6 col-xs-12">
|
||||||
<img class="img-responsive" src="${ContentServlet.getMediaUrl(item, Media.Size.SMALL)}"/>
|
<img class="img-responsive" src="${item.getUrlSmall()}"/>
|
||||||
</div>
|
</div>
|
||||||
</c:forEach>
|
</c:forEach>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,9 @@ public class Folder extends DBBean {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Folder> loadSubFolders(DBConnection db, Folder folder) throws SQLException {
|
public static List<Folder> loadSubFolders(DBConnection db, Folder folder) throws SQLException {
|
||||||
|
if (folder == null || folder.getId() == null)
|
||||||
|
return Collections.emptyList();
|
||||||
|
|
||||||
PreparedStatement sql = db.getPreparedStatement("SELECT * FROM Folder WHERE parent=?");
|
PreparedStatement sql = db.getPreparedStatement("SELECT * FROM Folder WHERE parent=?");
|
||||||
sql.setLong(1, folder.getId());
|
sql.setLong(1, folder.getId());
|
||||||
return DBConnection.exec(sql, DBBeanSQLResultHandler.createList(Folder.class, db));
|
return DBConnection.exec(sql, DBBeanSQLResultHandler.createList(Folder.class, db));
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
@ -37,7 +38,8 @@ public class Image extends Media {
|
||||||
*/
|
*/
|
||||||
public static List<Image> loadFolder(DBConnection db, Folder folder) throws SQLException {
|
public static List<Image> loadFolder(DBConnection db, Folder folder) throws SQLException {
|
||||||
if (folder == null || folder.getId() == null)
|
if (folder == null || folder.getId() == null)
|
||||||
return new LinkedList<Image>();
|
return Collections.emptyList();
|
||||||
|
|
||||||
PreparedStatement sql = db.getPreparedStatement("SELECT * FROM Image WHERE folder=? ORDER BY dateUploaded DESC");
|
PreparedStatement sql = db.getPreparedStatement("SELECT * FROM Image WHERE folder=? ORDER BY dateUploaded DESC");
|
||||||
sql.setLong(1, folder.getId());
|
sql.setLong(1, folder.getId());
|
||||||
return DBConnection.exec(sql, DBBeanSQLResultHandler.createList(Image.class, db));
|
return DBConnection.exec(sql, DBBeanSQLResultHandler.createList(Image.class, db));
|
||||||
|
|
@ -64,6 +66,7 @@ public class Image extends Media {
|
||||||
public void setFile(FileItem item) throws Exception {
|
public void setFile(FileItem item) throws Exception {
|
||||||
if (folder == null)
|
if (folder == null)
|
||||||
throw new Exception("Folder not set for image!");
|
throw new Exception("Folder not set for image!");
|
||||||
|
|
||||||
// Generate unique filename
|
// Generate unique filename
|
||||||
fileName = ResourceManager.generateFileName();
|
fileName = ResourceManager.generateFileName();
|
||||||
fileExtension = FileUtil.getFileExtension(item.getName());
|
fileExtension = FileUtil.getFileExtension(item.getName());
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ import java.util.logging.Logger;
|
||||||
import org.apache.commons.fileupload.FileItem;
|
import org.apache.commons.fileupload.FileItem;
|
||||||
|
|
||||||
import zall.manager.ResourceManager;
|
import zall.manager.ResourceManager;
|
||||||
|
import zall.page.ContentServlet;
|
||||||
import zutil.db.DBConnection;
|
import zutil.db.DBConnection;
|
||||||
import zutil.db.bean.DBBean;
|
import zutil.db.bean.DBBean;
|
||||||
import zutil.log.LogUtil;
|
import zutil.log.LogUtil;
|
||||||
|
|
@ -134,6 +135,18 @@ public abstract class Media extends DBBean implements Comparable<Media> {
|
||||||
return ResourceManager.getFile(this, size);
|
return ResourceManager.getFile(this, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public abstract Type getType();
|
public abstract Type getType();
|
||||||
|
|
||||||
|
public String getUrlSmall() {
|
||||||
|
return ContentServlet.getMediaUrl(this, Size.SMALL);
|
||||||
|
}
|
||||||
|
public String getUrlMedium() {
|
||||||
|
return ContentServlet.getMediaUrl(this, Size.MEDIUM);
|
||||||
|
}
|
||||||
|
public String getUrlLarge() {
|
||||||
|
return ContentServlet.getMediaUrl(this, Size.LARGE);
|
||||||
|
}
|
||||||
|
public String getUrlOriginal() {
|
||||||
|
return ContentServlet.getMediaUrl(this, Size.ORIGINAL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package zall.bean;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -42,7 +43,8 @@ public class Video extends Media {
|
||||||
*/
|
*/
|
||||||
public static List<Video> loadFolder(DBConnection db, Folder folder) throws SQLException {
|
public static List<Video> loadFolder(DBConnection db, Folder folder) throws SQLException {
|
||||||
if (folder == null || folder.getId() == null)
|
if (folder == null || folder.getId() == null)
|
||||||
return new LinkedList<Video>();
|
return Collections.emptyList();
|
||||||
|
|
||||||
PreparedStatement sql = db.getPreparedStatement("SELECT * FROM Video WHERE folder=? ORDER BY dateUploaded DESC");
|
PreparedStatement sql = db.getPreparedStatement("SELECT * FROM Video WHERE folder=? ORDER BY dateUploaded DESC");
|
||||||
sql.setLong(1, folder.getId());
|
sql.setLong(1, folder.getId());
|
||||||
return DBConnection.exec(sql, DBBeanSQLResultHandler.createList(Video.class, db));
|
return DBConnection.exec(sql, DBBeanSQLResultHandler.createList(Video.class, db));
|
||||||
|
|
@ -88,6 +90,7 @@ public class Video extends Media {
|
||||||
public void setFile(FileItem item) throws Exception {
|
public void setFile(FileItem item) throws Exception {
|
||||||
if (folder == null)
|
if (folder == null)
|
||||||
throw new Exception("Folder not set for Video!");
|
throw new Exception("Folder not set for Video!");
|
||||||
|
|
||||||
// Generate unique filename
|
// Generate unique filename
|
||||||
fileName = ResourceManager.generateFileName();
|
fileName = ResourceManager.generateFileName();
|
||||||
fileExtension = "." + FileUtil.getFileExtension(item.getName());
|
fileExtension = "." + FileUtil.getFileExtension(item.getName());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue