Compare commits
7 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| be4362c884 | |||
| 4602818bac | |||
| 3303ace2f7 | |||
| e974bd65d9 | |||
| dc2ef4cd8a | |||
| 76206ffa08 | |||
| 0d4b34b239 |
4 changed files with 46 additions and 50 deletions
|
|
@ -11,7 +11,6 @@
|
||||||
<property name="outputRoot" value="${gitRoot}/build" />
|
<property name="outputRoot" value="${gitRoot}/build" />
|
||||||
<property name="buildDir" value="${outputRoot}/production" />
|
<property name="buildDir" value="${outputRoot}/production" />
|
||||||
<property name="releaseDir" value="${outputRoot}/release" />
|
<property name="releaseDir" value="${outputRoot}/release" />
|
||||||
<property name="deployPath" value="/var/lib/tomcat7/webapps/Zallery.war" />
|
|
||||||
|
|
||||||
<!-- Deployment properties -->
|
<!-- Deployment properties -->
|
||||||
<property name="tomcat.url" value="http://localhost:8080/manager/text" />
|
<property name="tomcat.url" value="http://localhost:8080/manager/text" />
|
||||||
|
|
@ -78,6 +77,10 @@
|
||||||
path="/Zallery"
|
path="/Zallery"
|
||||||
update="true"
|
update="true"
|
||||||
war="file:${releaseDir}/Zallery.war" />
|
war="file:${releaseDir}/Zallery.war" />
|
||||||
|
|
||||||
|
<!-- Workaround as tomcat deletes the webapp context file from conf dir -->
|
||||||
|
<copy file="/var/lib/tomcat7/conf/Catalina/localhost/Zallery.xml_orig"
|
||||||
|
toFile="/var/lib/tomcat7/conf/Catalina/localhost/Zallery.xml" />
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
|
||||||
|
|
@ -30,9 +30,8 @@ public class UploadServlet extends AjaxFileUpload{
|
||||||
private static final Logger logger = LogUtil.getLogger();
|
private static final Logger logger = LogUtil.getLogger();
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public static final Set<String> VIDEO_EXT = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(new String[]{
|
private static final Set<String> VIDEO_EXT = Collections.unmodifiableSet(new HashSet<String>(Arrays.asList(
|
||||||
"avi","mp4","mpeg","mpeg","divx","xvid","wmv","mov","flv","m4v"
|
"avi","mp4","mpeg","mpeg","divx","xvid","wmv","mov","flv","m4v")));
|
||||||
})));
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProgressHTML() {
|
public String getProgressHTML() {
|
||||||
|
|
@ -76,6 +75,7 @@ public class UploadServlet extends AjaxFileUpload{
|
||||||
vid.setUser( user );
|
vid.setUser( user );
|
||||||
vid.setFile( item );
|
vid.setFile( item );
|
||||||
vid.save(db);
|
vid.save(db);
|
||||||
|
logger.info("Video upload successful: "+vid.getFolder().getPath());
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Image img = new Image();
|
Image img = new Image();
|
||||||
|
|
@ -83,7 +83,8 @@ public class UploadServlet extends AjaxFileUpload{
|
||||||
img.setFolder( folder );
|
img.setFolder( folder );
|
||||||
img.setUser( user );
|
img.setUser( user );
|
||||||
img.setFile( item );
|
img.setFile( item );
|
||||||
img.save(db);
|
img.save(db);
|
||||||
|
logger.info("Image upload successful: "+img.getFolder().getPath());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.log(Level.WARNING, "Error: Creating new Media(\""+item.getName()+"\")", e);
|
logger.log(Level.WARNING, "Error: Creating new Media(\""+item.getName()+"\")", e);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ import zutil.log.LogUtil;
|
||||||
public class Zallery extends HttpServlet{
|
public class Zallery extends HttpServlet{
|
||||||
private static Logger logger = LogUtil.getLogger();
|
private static Logger logger = LogUtil.getLogger();
|
||||||
|
|
||||||
public static final String VERSION = "1.0.0";
|
public static final String VERSION = "1.0.2";
|
||||||
|
|
||||||
public static String WEBSITE_NAME = "Example.com";
|
public static String WEBSITE_NAME = "Example.com";
|
||||||
public static String WEBSITE_URL = "http://example.com";
|
public static String WEBSITE_URL = "http://example.com";
|
||||||
|
|
@ -54,7 +54,7 @@ public class Zallery extends HttpServlet{
|
||||||
Context context = new InitialContext();
|
Context context = new InitialContext();
|
||||||
// Check if Zallery has been properly configured
|
// Check if Zallery has been properly configured
|
||||||
if ("C:\\\\data".equals(context.lookup("java:comp/env/DATA_PATH")))
|
if ("C:\\\\data".equals(context.lookup("java:comp/env/DATA_PATH")))
|
||||||
throw new ServletException("Zallery has not been properly configured, set proper configuration in Zaller.xml context file.");
|
throw new ServletException("Zallery has not been properly configured, set proper configuration in Zallery.xml context file.");
|
||||||
|
|
||||||
WEBSITE_NAME = (String)context.lookup("java:comp/env/WEBSITE_NAME");
|
WEBSITE_NAME = (String)context.lookup("java:comp/env/WEBSITE_NAME");
|
||||||
WEBSITE_URL = (String)context.lookup("java:comp/env/WEBSITE_URL");
|
WEBSITE_URL = (String)context.lookup("java:comp/env/WEBSITE_URL");
|
||||||
|
|
@ -211,7 +211,7 @@ public class Zallery extends HttpServlet{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<Media> list = Media.load(db, folder);
|
List<Media> list = Media.load(db, folder);
|
||||||
List<Folder> subFolders = Folder.loadSubFolders(db, folder.getId(), user);
|
List<Folder> subFolders = Folder.loadSubFolders(db, folder, user);
|
||||||
|
|
||||||
//session.setAttribute("user", user);
|
//session.setAttribute("user", user);
|
||||||
request.setAttribute("folder", folder);
|
request.setAttribute("folder", folder);
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,10 @@ import java.io.File;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
|
|
@ -21,25 +23,24 @@ import zall.Zallery;
|
||||||
public class Folder extends DBBean{
|
public class Folder extends DBBean{
|
||||||
private static final Logger logger = LogUtil.getLogger();
|
private static final Logger logger = LogUtil.getLogger();
|
||||||
|
|
||||||
protected transient String name;
|
private transient String name;
|
||||||
protected User user;
|
protected long user = -1;
|
||||||
protected String path;
|
protected transient User userInstance;
|
||||||
|
private String path;
|
||||||
protected Folder parent;
|
protected Folder parent;
|
||||||
protected Timestamp date;
|
protected Timestamp date;
|
||||||
protected boolean isPrivate;
|
private boolean isPrivate;
|
||||||
|
|
||||||
//@DBLinkTable(name="FolderTree", beanClass=Folder.class, idColumn="parent")
|
|
||||||
//protected LinkedList<Folder> subFolders;
|
|
||||||
|
|
||||||
|
|
||||||
public static Folder load(DBConnection db, Long id) throws SQLException{
|
public static Folder load(DBConnection db, Long id) throws SQLException{
|
||||||
return load(db, Folder.class, id);
|
return load(db, Folder.class, id);
|
||||||
}
|
}
|
||||||
public static List<Folder> loadSubFolders(DBConnection db, Long id, User user) throws SQLException{
|
public static List<Folder> loadSubFolders(DBConnection db, Folder folder, User requestingUser) throws SQLException{
|
||||||
PreparedStatement sql = db.getPreparedStatement("SELECT * FROM Folder WHERE parent=? AND (isPrivate=0 OR user=? OR ?)");
|
PreparedStatement sql = db.getPreparedStatement("SELECT * FROM Folder WHERE parent=? AND (isPrivate=0 OR user=? OR ?)");
|
||||||
sql.setLong(1, id);
|
sql.setLong(1, folder.getId());
|
||||||
sql.setLong(2, user.getId());
|
sql.setLong(2, folder.user);
|
||||||
sql.setBoolean(3, user.isSuperUser());
|
sql.setBoolean(3, requestingUser.isSuperUser());
|
||||||
return DBConnection.exec(sql, DBBeanSQLResultHandler.createList(Folder.class, db));
|
return DBConnection.exec(sql, DBBeanSQLResultHandler.createList(Folder.class, db));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,15 +61,14 @@ public class Folder extends DBBean{
|
||||||
|
|
||||||
public static List<Folder> load(DBConnection db, User user) throws SQLException{
|
public static List<Folder> load(DBConnection db, User user) throws SQLException{
|
||||||
if( user.getId() == null )
|
if( user.getId() == null )
|
||||||
return new LinkedList<Folder>();
|
return Collections.emptyList();
|
||||||
PreparedStatement sql = db.getPreparedStatement("SELECT * FROM Folder WHERE user=?");
|
PreparedStatement sql = db.getPreparedStatement("SELECT * FROM Folder WHERE user=?");
|
||||||
sql.setLong(1, user.getId() );
|
sql.setLong(1, user.getId() );
|
||||||
return DBConnection.exec(sql, DBBeanSQLResultHandler.createList(Folder.class, db));
|
return DBConnection.exec(sql, DBBeanSQLResultHandler.createList(Folder.class, db));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Folder(){
|
public Folder(){
|
||||||
//subFolders = new LinkedList<Folder>();
|
date = new Timestamp( System.currentTimeMillis() );
|
||||||
date = new Timestamp( System.currentTimeMillis() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName(){
|
public String getName(){
|
||||||
|
|
@ -76,20 +76,25 @@ public class Folder extends DBBean{
|
||||||
String[] tmp = path.split("/");
|
String[] tmp = path.split("/");
|
||||||
name = tmp[tmp.length-1];
|
name = tmp[tmp.length-1];
|
||||||
}
|
}
|
||||||
String userName = user != null ? user.getName() : "UNKNOWN";
|
String userName = getUser() != null ? getUser().getName() : "UNKNOWN";
|
||||||
String tmp = name.replaceAll("\\{NAME\\}", userName);
|
String tmp = name.replaceAll("\\{NAME\\}", userName);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
public String getUnModName(){
|
|
||||||
if(name == null)
|
|
||||||
getName();
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
public User getUser(){
|
public User getUser(){
|
||||||
return user;
|
if (userInstance == null) {
|
||||||
|
try {
|
||||||
|
DBConnection db = Zallery.getDB();
|
||||||
|
userInstance = User.load(db, user);
|
||||||
|
db.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.log(Level.WARNING, null, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return userInstance;
|
||||||
}
|
}
|
||||||
public void setUser(User user){
|
public void setUser(User user){
|
||||||
this.user = user;
|
this.user = user.getId();
|
||||||
|
this.userInstance = null;
|
||||||
}
|
}
|
||||||
public boolean isPrivate(){
|
public boolean isPrivate(){
|
||||||
return isPrivate;
|
return isPrivate;
|
||||||
|
|
@ -98,12 +103,9 @@ public class Folder extends DBBean{
|
||||||
this.isPrivate = priv;
|
this.isPrivate = priv;
|
||||||
}
|
}
|
||||||
public String getPath(){
|
public String getPath(){
|
||||||
String tmp = path.replaceAll("\\{NAME\\}", user.getName());
|
String tmp = path.replaceAll("\\{NAME\\}", getUser().getName());
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
public String getUnModPath(){
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
public void setName(String name){
|
public void setName(String name){
|
||||||
this.name = name;
|
this.name = name;
|
||||||
if( parent.path.endsWith("/") )
|
if( parent.path.endsWith("/") )
|
||||||
|
|
@ -125,20 +127,10 @@ public class Folder extends DBBean{
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public void addSubFolder(Folder f){
|
public Timestamp getDate(){
|
||||||
if( !subFolders.contains(f) ){
|
return date;
|
||||||
subFolders.add( f );
|
}
|
||||||
f.setParent( this );
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/*public List<Folder> getSubFolders(){
|
|
||||||
return subFolders;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public Timestamp getDate(){
|
|
||||||
return date;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param filename is the name of the file
|
* @param filename is the name of the file
|
||||||
|
|
@ -153,7 +145,7 @@ public class Folder extends DBBean{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( user == null || filename == null )
|
if( user < 0 || filename == null )
|
||||||
return null;
|
return null;
|
||||||
StringBuilder tmp = new StringBuilder();
|
StringBuilder tmp = new StringBuilder();
|
||||||
|
|
||||||
|
|
@ -166,7 +158,7 @@ public class Folder extends DBBean{
|
||||||
tmp.append( File.separatorChar );
|
tmp.append( File.separatorChar );
|
||||||
|
|
||||||
// Add UserID and this folders path
|
// Add UserID and this folders path
|
||||||
String tmp_path = path.replaceAll("\\{NAME\\}", ""+user.getId());
|
String tmp_path = path.replaceAll("\\{NAME\\}", ""+user);
|
||||||
tmp_path = tmp_path.replaceAll("/", Matcher.quoteReplacement(File.separator));
|
tmp_path = tmp_path.replaceAll("/", Matcher.quoteReplacement(File.separator));
|
||||||
tmp.append( tmp_path );
|
tmp.append( tmp_path );
|
||||||
|
|
||||||
|
|
@ -195,6 +187,6 @@ public class Folder extends DBBean{
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEmpty(DBConnection db) throws SQLException {
|
public boolean isEmpty(DBConnection db) throws SQLException {
|
||||||
return Folder.loadSubFolders(db, this.getId(), user).isEmpty() && Media.load(db, this).isEmpty();
|
return Folder.loadSubFolders(db, this, getUser()).isEmpty() && Media.load(db, this).isEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue