roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ganes...@apache.org
Subject svn commit: r749634 [1/2] - in /roller/branches/roller_mediablogging/apps/weblogger: src/java/org/apache/roller/weblogger/business/ src/java/org/apache/roller/weblogger/pojos/ src/java/org/apache/roller/weblogger/ui/struts2/editor/ src/java/org/apache/...
Date Tue, 03 Mar 2009 15:44:04 GMT
Author: ganeshmb
Date: Tue Mar  3 15:44:03 2009
New Revision: 749634

URL: http://svn.apache.org/viewvc?rev=749634&view=rev
Log:
Commiting second patch for media blogging with the following features:
- View media files in a tabular fashion
- View media files in a hierarchical fashion
- Search for a media file with results displayed with pagination.
- Create directories from tabular view and search view.
- Ability to move multiple files across directories
- Ability to delete one or more files.
- Edit metadata for media file.

Added:
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileComparator.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectoryComparator.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileFilter.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileType.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileEdit.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileSearch.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileSearchBean.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/pagers/MediaFilePager.java
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileEdit.jsp
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileHierarchicalView.jsp
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileSearch.jsp
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileViewLight.jsp
Removed:
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/TabularView.jsp
Modified:
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManager.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManagerImpl.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectory.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectory.orm.xml
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBean.java
    roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/business/FileContentManagerTest.java
    roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/business/MediaFileTest.java
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/classes/struts.xml
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAdd.jsp
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileSidebar.jsp
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/tiles.xml
    roller/branches/roller_mediablogging/apps/weblogger/web/roller-ui/styles/roller.css

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManager.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManager.java?rev=749634&r1=749633&r2=749634&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManager.java (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManager.java Tue Mar  3 15:44:03 2009
@@ -24,25 +24,31 @@
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.pojos.MediaFile;
 import org.apache.roller.weblogger.pojos.MediaFileDirectory;
+import org.apache.roller.weblogger.pojos.MediaFileFilter;
 import org.apache.roller.weblogger.pojos.Weblog;
 
 public interface MediaFileManager {
 
-	// TODO: Ganesh - Remove old FileManager implementation
 	public void createMediaFile(Weblog weblog, MediaFile mediaFile) throws WebloggerException ;
 	public void updateMediaFile(Weblog weblog, MediaFile mediaFile) throws WebloggerException ;
 	public MediaFile getMediaFile(String id) throws WebloggerException;
 	public MediaFile getMediaFile(String id, boolean includeContent) throws WebloggerException;
-	public void removeMediaFile(MediaFile mediaFile) throws WebloggerException;
-	
+	public void removeMediaFile(Weblog weblog, MediaFile mediaFile) throws WebloggerException;
+
+	public List<MediaFile> searchMediaFiles(Weblog weblog, MediaFileFilter filter) throws WebloggerException;
+
 	public MediaFileDirectory createRootMediaFileDirectory(Weblog weblog) throws WebloggerException;
+	public MediaFileDirectory createMediaFileDirectory(MediaFileDirectory parentDirectory, String newDirName) throws WebloggerException;
 	public void createMediaFileDirectory(MediaFileDirectory directory) throws WebloggerException;
+	public MediaFileDirectory createMediaFileDirectoryByPath(Weblog weblog, String path) throws WebloggerException; 
 
 	public MediaFileDirectory getMediaFileDirectory(String id) throws WebloggerException;
+	public MediaFileDirectory getMediaFileDirectoryByPath(Weblog weblog, String path) throws WebloggerException; 
 	public List<MediaFileDirectory> getMediaFileDirectories(Weblog weblog) throws WebloggerException;
     public MediaFileDirectory getMediaFileRootDirectory(Weblog weblog) throws WebloggerException;
     
     public void moveMediaFiles(Collection<MediaFile> mediaFiles, MediaFileDirectory directory) throws WebloggerException;
+    public void moveMediaFile(MediaFile mediaFile, MediaFileDirectory directory) throws WebloggerException;
 
 	public void release();
 }

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManagerImpl.java?rev=749634&r1=749633&r2=749634&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManagerImpl.java (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManagerImpl.java Tue Mar  3 15:44:03 2009
@@ -20,6 +20,7 @@
 
 import java.sql.Timestamp;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 
@@ -27,6 +28,7 @@
 import javax.persistence.OneToMany;
 import javax.persistence.Query;
 
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
@@ -34,8 +36,9 @@
 import org.apache.roller.weblogger.pojos.FileContent;
 import org.apache.roller.weblogger.pojos.MediaFile;
 import org.apache.roller.weblogger.pojos.MediaFileDirectory;
+import org.apache.roller.weblogger.pojos.MediaFileFilter;
 import org.apache.roller.weblogger.pojos.Weblog;
-import org.apache.roller.weblogger.pojos.WeblogBookmarkFolder;
+import org.apache.roller.weblogger.pojos.MediaFileFilter.MediaFileOrder;
 import org.apache.roller.weblogger.util.RollerMessages;
 
 @com.google.inject.Singleton
@@ -63,7 +66,6 @@
 		
 	}
 	
-    @OneToMany
 	public void moveMediaFiles(Collection<MediaFile> mediaFiles, MediaFileDirectory targetDirectory) 
         throws WebloggerException {
     	for (MediaFile mediaFile: mediaFiles) {
@@ -74,6 +76,25 @@
         roller.getWeblogManager().saveWeblog(targetDirectory.getWeblog());
     }
 
+	public void moveMediaFile(MediaFile mediaFile, MediaFileDirectory targetDirectory) 
+        throws WebloggerException {
+		moveMediaFiles(Arrays.asList(mediaFile), targetDirectory);
+	}
+	
+	public MediaFileDirectory createMediaFileDirectory(MediaFileDirectory parentDirectory, String newDirName) 
+	  throws WebloggerException {
+		
+		if (parentDirectory.hasDirectory(newDirName)) {
+            throw new WebloggerException("Directory exists");
+		}
+		
+		MediaFileDirectory newDirectory = parentDirectory.createNewDirectory(newDirName);
+
+		// update weblog last modified date.  date updated by saveWeblog()
+        roller.getWeblogManager().saveWeblog(newDirectory.getWeblog());
+        
+        return newDirectory;
+	}
 	
 	public void createMediaFileDirectory(MediaFileDirectory directory) 
 	  throws WebloggerException {
@@ -83,6 +104,54 @@
         roller.getWeblogManager().saveWeblog(directory.getWeblog());
 	}
 	
+	public MediaFileDirectory createMediaFileDirectoryByPath(Weblog weblog, String path) 
+	    throws WebloggerException {
+		if (path.startsWith("/")) {
+			path = path.substring(1);
+		}
+		
+		if (path.endsWith("/")) {
+			path = path.substring(0, path.length() - 1);
+		}
+		
+		if (path.equals("")) {
+			/**
+			 * Root cannot be created using this method. Use createRootMediaFileDirectory instead
+			 */
+			throw new WebloggerException("Invalid path!");
+		}
+		
+		int lastPathIndex = path.lastIndexOf("/");
+		
+		MediaFileDirectory parentDirectory;
+		String newDirName;
+		if (lastPathIndex == -1) {
+			//Directory needs to be created under root
+			newDirName = path;
+			parentDirectory = getMediaFileRootDirectory(weblog);
+		}
+		else {
+			String parentPath = path.substring(0, lastPathIndex);
+			newDirName = path.substring(lastPathIndex + 1);
+			parentDirectory = getMediaFileDirectoryByPath(weblog, "/" + parentPath);
+			// Validate whether the parent directory exists
+			if (parentDirectory == null) {
+	            throw new WebloggerException("Parent directory does not exist");
+			}
+		}
+
+		if (parentDirectory.hasDirectory(newDirName)) {
+            throw new WebloggerException("Directory exists");
+		}
+		
+		MediaFileDirectory newDirectory = parentDirectory.createNewDirectory(newDirName);
+
+		// update weblog last modified date.  date updated by saveWeblog()
+        roller.getWeblogManager().saveWeblog(weblog);
+        
+        return newDirectory;
+	}
+	
 	public MediaFileDirectory createRootMediaFileDirectory(Weblog weblog) 
 	    throws WebloggerException {
         MediaFileDirectory rootDirectory = new MediaFileDirectory(null, "root", "root directory", weblog);
@@ -130,6 +199,20 @@
         return mediaFile;
 	}
 
+	public MediaFileDirectory getMediaFileDirectoryByPath(Weblog weblog, String path) 
+    throws WebloggerException {
+        Query q = this.persistenceStrategy.getNamedQuery("MediaFileDirectory.getByWeblogAndPath");
+        q.setParameter(1, weblog);
+        q.setParameter(2, path);
+        try {
+            return (MediaFileDirectory)q.getSingleResult();
+        } catch (NoResultException e) {
+            return null;
+        }
+    }
+
+
+	
 	public MediaFileDirectory getMediaFileDirectory(String id) 
 	    throws WebloggerException {
 		return (MediaFileDirectory) this.persistenceStrategy.load(MediaFileDirectory.class, id);
@@ -154,11 +237,115 @@
         return q.getResultList();
 	}
 	
-	public void removeMediaFile(MediaFile mediaFile) 
+	public void removeMediaFile(Weblog weblog, MediaFile mediaFile) 
 	    throws WebloggerException {
-		this.persistenceStrategy.remove(mediaFile);
+        FileContentManager cmgr = WebloggerFactory.getWeblogger().getFileContentManager();
+
+        this.persistenceStrategy.remove(mediaFile);
+        // update weblog last modified date.  date updated by saveWeblog()
+        roller.getWeblogManager().saveWeblog(weblog);
+
+        cmgr.deleteFile(weblog, mediaFile.getId());
 	}
 	
+	public List<MediaFile> searchMediaFiles(Weblog weblog, MediaFileFilter filter) 
+	     throws WebloggerException {
+        
+		List<Object> params = new ArrayList<Object>();
+        int size = 0;
+        StringBuffer queryString = new StringBuffer();
+        StringBuffer whereClause = new StringBuffer();
+        StringBuffer orderBy = new StringBuffer();
+        
+        queryString.append("SELECT m FROM MediaFile m WHERE ");
+        
+        params.add(size ++, weblog);
+        whereClause.append("m.directory.weblog = ?" + size);
+        
+        if (!StringUtils.isEmpty(filter.getName())) {
+        	params.add(size ++, filter.getName());
+        	whereClause.append(" AND m.name = ?" + size);
+        }
+
+        if (filter.getSize() > 0) {
+        	params.add(size ++, filter.getSize());
+        	whereClause.append(" AND m.length ");
+        	switch (filter.getSizeFilterType()) {
+            	case GT: whereClause.append(">");break;
+            	case GTE: whereClause.append(">=");break;
+            	case EQ: whereClause.append("=");break;
+        	    case LT: whereClause.append("<");break;
+        	    case LTE: whereClause.append("<=");break;
+        	    default: whereClause.append("=");break;
+        	}
+        	whereClause.append(" ?" + size);
+        }
+        
+        if (filter.getTags() != null) {
+        	whereClause.append(" AND EXISTS (SELECT t FROM MediaFileTag t WHERE t.mediaFile = m and t.name IN (");
+        	for (String tag: filter.getTags()) {
+        	    params.add(size ++, tag);
+        	    whereClause.append("?").append(size).append(",");
+        	}
+        	whereClause.deleteCharAt(whereClause.lastIndexOf(","));
+        	whereClause.append("))");
+        }
+        
+        if (filter.getType() != null) {
+        	whereClause.append(" AND m.contentType IN (");
+    		for (String contentType: filter.getType().getContentTypes()) {
+        	    params.add(size ++, contentType);
+        	    whereClause.append("?").append(size).append(",");
+    		}
+        	whereClause.deleteCharAt(whereClause.lastIndexOf(","));
+        	whereClause.append(")");
+        }
+        
+        switch(filter.getOrder()) {
+            case NAME: orderBy.append(" order by m.name");break;
+            case DATE_UPLOADED: orderBy.append(" order by m.dateUploaded");break;
+            case TYPE: orderBy.append(" order by m.contentType");break;
+            default:
+        }
+
+        Query query = persistenceStrategy.getDynamicQuery(queryString.toString() + whereClause.toString());
+        for (int i=0; i<params.size(); i++) {
+            query.setParameter(i+1, params.get(i));
+        }
+        
+        if (filter.getStartIndex() >= 0) {
+            query.setFirstResult(filter.getStartIndex());
+            query.setMaxResults(filter.getLength());
+        }
+        
+        return query.getResultList();
+	}
+	
+	public static void main(String[] args) {
+		/**
+		MediaFileManagerImpl impl = new MediaFileManagerImpl(null, null);
+		
+		MediaFileFilter filter = new MediaFileFilter();
+		filter.setName("testname");
+
+		filter.setSize(3);
+		filter.setSizeFilterType(MediaFileFilter.SizeFilterType.EQ);
+		
+		List<String> tags = new ArrayList<String>();
+		tags.add("test1");
+		tags.add("test2");
+		filter.setTags(tags);
+		
+		filter.setType(MediaFileType.IMAGE);
+
+		System.out.println(impl.searchMediaFiles(null, filter));
+		*/
+	}
+	
+	
+	
+	
+	
 	/*
 	public void searchMediaFiles(MediaFileSearchCriteria searchCriteria) {
 		

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java?rev=749634&r1=749633&r2=749634&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java Tue Mar  3 15:44:03 2009
@@ -237,4 +237,15 @@
 	public void setContent(FileContent content) {
 		this.content = content;
 	}
+	
+	public boolean isImageFile() {
+		if (this.contentType == null) return false;
+    	String[] allowedImageContentTypes = MediaFileType.IMAGE.getContentTypes(); 
+    	for (String imageContentType: allowedImageContentTypes) {
+    		if (imageContentType.equals(this.contentType)) {
+    			return true;
+    		}
+    	}
+    	return false;
+	}
 }

Added: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileComparator.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileComparator.java?rev=749634&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileComparator.java (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileComparator.java Tue Mar  3 15:44:03 2009
@@ -0,0 +1,24 @@
+package org.apache.roller.weblogger.pojos;
+
+import java.util.Comparator;
+
+public class MediaFileComparator implements Comparator<MediaFile> {
+	
+	public enum MediaFileComparatorType {NAME, TYPE, DATE_UPLOADED};
+	MediaFileComparatorType type;
+	
+	public MediaFileComparator(MediaFileComparatorType type) {
+		this.type = type;
+	}
+
+	public int compare(MediaFile file1, MediaFile file2) {
+		switch (this.type) {
+		    case NAME: return file1.getName().compareTo(file2.getName());
+		    case TYPE: return file1.getContentType().compareTo(file2.getContentType());
+		    // Do descending comparison by default for date field
+		    case DATE_UPLOADED: return file2.getDateUploaded().compareTo(file1.getDateUploaded());  
+		    default: return 0;
+		}
+	}
+
+}

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectory.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectory.java?rev=749634&r1=749633&r2=749634&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectory.java (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectory.java Tue Mar  3 15:44:03 2009
@@ -200,6 +200,8 @@
     
     public boolean hasMediaFile(String name) {
     	Set<MediaFile> fileSet = this.getMediaFiles();
+    	if (fileSet == null) 
+    		return false;
     	for (MediaFile mediaFile: fileSet) {
     		if (mediaFile.getName().equals(name)) {
     			return true;
@@ -208,6 +210,34 @@
     	return false;
     }
     
+    public MediaFile getMediaFile(String name) {
+    	Set<MediaFile> fileSet = this.getMediaFiles();
+    	if (fileSet == null) 
+    		return null;
+    	for (MediaFile mediaFile: fileSet) {
+    		if (mediaFile.getName().equals(name)) {
+    			return mediaFile;
+    		}
+    	}
+    	return null;
+    }
+    
+    public boolean hasDirectory(String name) {
+    	Set<MediaFileDirectory> dirSet = this.getChildDirectories();
+    	for (MediaFileDirectory directory: dirSet) {
+    		if (directory.getName().equals(name)) {
+    			return true;
+    		}
+    	}
+    	return false;
+    }
+    
+    public MediaFileDirectory createNewDirectory(String name) {
+    	MediaFileDirectory newDirectory = new MediaFileDirectory(this, name, "", this.getWeblog());
+    	this.getChildDirectories().add(newDirectory);
+    	return newDirectory;
+    }
+    
     
     public Set<MediaFile> getMediaFiles() {
 		return mediaFiles;

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectory.orm.xml
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectory.orm.xml?rev=749634&r1=749633&r2=749634&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectory.orm.xml (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectory.orm.xml Tue Mar  3 15:44:03 2009
@@ -18,6 +18,9 @@
         <named-query name="MediaFileDirectory.getByWeblogAndNoParent">
             <query>SELECT d FROM MediaFileDirectory d WHERE d.weblog = ?1 AND d.parent IS NULL</query>
         </named-query>
+        <named-query name="MediaFileDirectory.getByWeblogAndPath">
+            <query>SELECT d FROM MediaFileDirectory d WHERE d.weblog = ?1 AND d.path = ?2</query>
+        </named-query>
         <attributes>
             <id name="id">
                 <column name="id"/>
@@ -40,6 +43,7 @@
             <one-to-many name="childDirectories" mapped-by="parent" target-entity="org.apache.roller.weblogger.pojos.MediaFileDirectory" fetch="LAZY">
                 <order-by>name</order-by>
                 <cascade>
+                    <cascade-persist/>
                     <cascade-remove/>
                 </cascade>
             </one-to-many>

Added: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectoryComparator.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectoryComparator.java?rev=749634&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectoryComparator.java (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectoryComparator.java Tue Mar  3 15:44:03 2009
@@ -0,0 +1,22 @@
+package org.apache.roller.weblogger.pojos;
+
+import java.util.Comparator;
+
+public class MediaFileDirectoryComparator implements Comparator<MediaFileDirectory> {
+	
+	public enum DirectoryComparatorType {NAME, PATH};
+	DirectoryComparatorType type;
+	
+	public MediaFileDirectoryComparator(DirectoryComparatorType type) {
+		this.type = type;
+	}
+
+	public int compare(MediaFileDirectory dir1, MediaFileDirectory dir2) {
+		switch (this.type) {
+		    case NAME: return dir1.getName().compareTo(dir2.getName());
+		    case PATH: return dir1.getPath().compareTo(dir2.getPath());
+		    default: return 0;
+		}
+	}
+
+}

Added: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileFilter.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileFilter.java?rev=749634&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileFilter.java (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileFilter.java Tue Mar  3 15:44:03 2009
@@ -0,0 +1,94 @@
+package org.apache.roller.weblogger.pojos;
+
+import java.util.List;
+
+public class MediaFileFilter {
+	
+	public enum SizeFilterType {GT, GTE, EQ, LT, LTE};
+	public enum MediaFileOrder {NAME, DATE_UPLOADED, TYPE};
+
+	String name;
+	MediaFileType type;
+	long size;
+	SizeFilterType sizeFilterType;
+	List<String> tags;
+	MediaFileOrder order;
+	
+	/**
+	 * Indicates the starting index in the complete result set 
+	 * from which results should be returned.  This is always applied
+	 * along with the length attribute below.
+	 * A value of -1 means that the complete result set should be
+	 * returned. length will be ignored in this case.
+	 */
+	int startIndex = -1;
+	/**
+	 * Number of results to be returned starting from startIndex.
+	 */
+	int length;
+	
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public MediaFileType getType() {
+		return type;
+	}
+
+	public void setType(MediaFileType type) {
+		this.type = type;
+	}
+
+	public List<String> getTags() {
+		return tags;
+	}
+
+	public void setTags(List<String> tags) {
+		this.tags = tags;
+	}
+
+	public long getSize() {
+		return size;
+	}
+
+	public void setSize(long size) {
+		this.size = size;
+	}
+
+	public SizeFilterType getSizeFilterType() {
+		return sizeFilterType;
+	}
+
+	public void setSizeFilterType(SizeFilterType sizeFilterType) {
+		this.sizeFilterType = sizeFilterType;
+	}
+
+	public int getStartIndex() {
+		return startIndex;
+	}
+
+	public void setStartIndex(int startIndex) {
+		this.startIndex = startIndex;
+	}
+
+	public int getLength() {
+		return length;
+	}
+
+	public void setLength(int length) {
+		this.length = length;
+	}
+
+	public MediaFileOrder getOrder() {
+		return order;
+	}
+
+	public void setOrder(MediaFileOrder order) {
+		this.order = order;
+	}
+
+}

Added: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileType.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileType.java?rev=749634&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileType.java (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileType.java Tue Mar  3 15:44:03 2009
@@ -0,0 +1,30 @@
+package org.apache.roller.weblogger.pojos;
+
+public enum MediaFileType {
+
+	AUDIO("audio", "Audio", "audio/mpeg", "audio/x-ms-wma", "audio/x-wav", "audio/vnd.rn-realaudio"), 
+	VIDEO("video", "Video", "video/mpeg", "video/mp4", "video/quicktime", "video/x-ms-wmv"),  
+	IMAGE("image", "Image", "image/jpeg", "image/gif", "image/png", "image/tiff");
+
+	String[] contentTypes;
+	String id;
+	String description;
+	
+	MediaFileType(String id, String desc, String... contentTypes) {
+		this.id = id;
+		this.description = desc;
+		this.contentTypes = contentTypes;
+	}
+
+	public String[] getContentTypes() {
+		return contentTypes;
+	}
+
+	public String getId() {
+		return id;
+	}
+
+	public String getDesc() {
+		return description;
+	}
+}

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd.java?rev=749634&r1=749633&r2=749634&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd.java (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd.java Tue Mar  3 15:44:03 2009
@@ -20,6 +20,7 @@
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 
@@ -33,21 +34,21 @@
 import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
 import org.apache.roller.weblogger.pojos.MediaFile;
 import org.apache.roller.weblogger.pojos.MediaFileDirectory;
-import org.apache.roller.weblogger.ui.struts2.util.UIAction;
+import org.apache.roller.weblogger.pojos.MediaFileType;
 import org.apache.struts2.interceptor.validation.SkipValidation;
 
 /**
  * Adds a new media file.
  */
 @SuppressWarnings("serial")
-public class MediaFileAdd extends UIAction {
+public class MediaFileAdd extends MediaFileBase {
     private static Log log = LogFactory.getLog(MediaFileAdd.class);
     
     private MediaFileBean bean =  new MediaFileBean();
+    
+    // TODO: Ganesh - Move this to MediaFileBean
     private String directoryId;
     private MediaFileDirectory directory;
-    private List<MediaFileDirectory> allDirectories;
-
     // file uploaded by the user
     private File uploadedFile = null;
     
@@ -64,9 +65,10 @@
     }
     
     public void myPrepare() {
-        try {
+        System.out.println("Into myprepare");
+    	refreshAllDirectories();
+    	try {
             MediaFileManager mgr = WebloggerFactory.getWeblogger().getMediaFileManager();
-            setAllDirectories(mgr.getMediaFileDirectories(getActionWeblog()));
             if(!StringUtils.isEmpty(getDirectoryId())) {
                 setDirectory(mgr.getMediaFileDirectory(getDirectoryId()));
             }
@@ -133,18 +135,28 @@
         if (StringUtils.isEmpty(this.uploadedFileFileName)) {
         	addError("error.upload.file");
         }
-    }
+        
+        if (getBean().getCopyrightText().length() > 1023) {
+        	addError("errors.maxlength", Arrays.asList("Copyright text", "1023"));
+        }
+
+        if (getBean().getDescription().length() > 255) {
+        	addError("errors.maxlength", Arrays.asList("File description", "255"));
+        }
+}
     
     /**
      * Get the list of all categories for the action weblog, not including root.
      */
     public List<MediaFileDirectory> getDirectories() {
-        try {
-        	MediaFileManager mgr = WebloggerFactory.getWeblogger().getMediaFileManager();
+        
+    	try {
+        	// TODO: Ganesh - do this in prepare method?
+    		MediaFileManager mgr = WebloggerFactory.getWeblogger().getMediaFileManager();
             return mgr.getMediaFileDirectories(getActionWeblog());
         } catch (WebloggerException ex) {
             log.error("Error getting media file directory list for weblog - "+getWeblog(), ex);
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
         }
     }
 
@@ -172,14 +184,6 @@
 		this.directory = directory;
 	}
 	
-	public List<MediaFileDirectory> getAllDirectories() {
-		return allDirectories;
-	}
-    
-	public void setAllDirectories(List<MediaFileDirectory> dirs) {
-		this.allDirectories = dirs;
-	}
-
     public File getUploadedFile() {
         return uploadedFile;
     }
@@ -205,13 +209,12 @@
     }
     
     public boolean isContentTypeImage() {
-    	// TODO: To be expanded
-    	if ("image/jpeg".equals(this.uploadedFileContentType)
-    	|| 	"image/gif".equals(this.uploadedFileContentType)	
-    	) {
-    		return true;
+    	String[] allowedImageContentTypes = MediaFileType.IMAGE.getContentTypes(); 
+    	for (String imageContentType: allowedImageContentTypes) {
+    		if (imageContentType.equals(this.uploadedFileContentType)) {
+    			return true;
+    		}
     	}
-    	
     	return false;
     }
 }

Added: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java?rev=749634&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java Tue Mar  3 15:44:03 2009
@@ -0,0 +1,162 @@
+package org.apache.roller.weblogger.ui.struts2.editor;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.MediaFileManager;
+import org.apache.roller.weblogger.business.WebloggerFactory;
+import org.apache.roller.weblogger.pojos.MediaFile;
+import org.apache.roller.weblogger.pojos.MediaFileDirectory;
+import org.apache.roller.weblogger.pojos.MediaFileDirectoryComparator;
+import org.apache.roller.weblogger.pojos.MediaFileDirectoryComparator.DirectoryComparatorType;
+import org.apache.roller.weblogger.ui.struts2.util.UIAction;
+
+@SuppressWarnings("serial")
+public class MediaFileBase extends UIAction {
+    private static Log log = LogFactory.getLog(MediaFileBase.class);
+
+    private String[] selectedMediaFiles;
+    private String selectedDirectory;
+    private String mediaFileId;
+
+    private List<MediaFileDirectory> allDirectories;
+    
+    protected void doDeleteMediaFile() {
+        
+    	try {
+			log.debug("Processing delete of file id - " + this.mediaFileId);
+			MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+			MediaFile mediaFile = manager.getMediaFile(this.mediaFileId);
+			manager.removeMediaFile(getActionWeblog(), mediaFile);
+			// flush changes
+			WebloggerFactory.getWeblogger().flush();
+			addMessage("mediaFile.delete.success");
+		} catch (WebloggerException e) {
+            log.error("Error deleting media file", e);
+            // TODO: i18n
+            addError("Error deleting media file - " + this.mediaFileId);
+		}
+    }
+    
+    protected void doIncludeMediaFileInGallery() {
+        
+    	try {
+			log.debug("Processing include-in-gallery of file id - " + this.mediaFileId);
+			MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+			MediaFile mediaFile = manager.getMediaFile(this.mediaFileId);
+			mediaFile.setSharedForGallery(true);
+			manager.updateMediaFile(getActionWeblog(), mediaFile);
+			// flush changes
+			WebloggerFactory.getWeblogger().flush();
+			addMessage("mediaFile.includeInGallery.success");
+		} catch (WebloggerException e) {
+            log.error("Error including media file in gallery", e);
+            // TODO: i18n
+            addError("Error including media file in gallery - " + this.mediaFileId);
+		}
+    }
+    
+
+    protected void doDeleteSelected() {
+        String[] fileIds = getSelectedMediaFiles();
+        if (fileIds != null && fileIds.length > 0) {
+        	try {
+				log.debug("Processing delete of " + fileIds.length + " media files.");
+				MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+				for (int index = 0; index < fileIds.length; index++) {
+				    log.debug("Deleting media file - " + fileIds[index]);
+				    MediaFile mediaFile = manager.getMediaFile(fileIds[index]);
+				    manager.removeMediaFile(getActionWeblog(), mediaFile);
+				}
+				// flush changes
+				WebloggerFactory.getWeblogger().flush();
+				addMessage("mediaFile.delete.success");
+			} catch (WebloggerException e) {
+	            log.error("Error deleting selected media files", e);
+                // TODO: i18n
+                addError("Error deleting selected media files");
+			}
+        }
+        else {
+        	addError("mediaFile.error.noneSelectedForDelete");
+        }
+    }
+    
+    protected void doMoveSelected() {
+        String[] fileIds = getSelectedMediaFiles();
+        if (fileIds != null && fileIds.length > 0) {
+        	try {
+				log.debug("Processing move of " + fileIds.length + " media files.");
+				MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+				MediaFileDirectory targetDirectory = manager.getMediaFileDirectory(this.selectedDirectory);
+				for (int index = 0; index < fileIds.length; index++) {
+				    log.debug("Moving media file - " + fileIds[index] + " to directory - " + this.selectedDirectory);
+				    MediaFile mediaFile = manager.getMediaFile(fileIds[index]);
+				    manager.moveMediaFile(mediaFile, targetDirectory);
+				}
+				// flush changes
+				WebloggerFactory.getWeblogger().flush();
+				addMessage("mediaFile.move.success");
+			} catch (WebloggerException e) {
+	            log.error("Error moving selected media files", e);
+                // TODO: i18n
+                addError("Error moving selected media files");
+			}
+        }
+        else {
+        	addError("mediaFile.error.noneSelectedForMove");
+        }
+    }
+
+    protected void refreshAllDirectories() {
+        try {
+            MediaFileManager mgr = WebloggerFactory.getWeblogger().getMediaFileManager();
+            List<MediaFileDirectory> directories = mgr.getMediaFileDirectories(getActionWeblog());
+            List<MediaFileDirectory> sortedDirList = new ArrayList<MediaFileDirectory>();
+            sortedDirList.addAll(directories);
+            Collections.sort(sortedDirList, new MediaFileDirectoryComparator(DirectoryComparatorType.PATH));
+            setAllDirectories(sortedDirList);
+        } catch (WebloggerException ex) {
+            log.error("Error looking up media file directories", ex);
+            // TODO: Ganesh - Handle exception
+        }
+    }
+
+	public String[] getSelectedMediaFiles() {
+		return selectedMediaFiles;
+	}
+
+	public void setSelectedMediaFiles(String[] selectedMediaFiles) {
+		this.selectedMediaFiles = selectedMediaFiles;
+	}
+
+	public String getSelectedDirectory() {
+		return selectedDirectory;
+	}
+
+	public void setSelectedDirectory(String selectedDirectory) {
+		this.selectedDirectory = selectedDirectory;
+	}
+
+
+	public List<MediaFileDirectory> getAllDirectories() {
+		return allDirectories;
+	}
+
+	public void setAllDirectories(List<MediaFileDirectory> allDirectories) {
+		this.allDirectories = allDirectories;
+	}
+
+	public String getMediaFileId() {
+		return mediaFileId;
+	}
+
+	public void setMediaFileId(String mediaFileId) {
+		this.mediaFileId = mediaFileId;
+	}
+
+}

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBean.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBean.java?rev=749634&r1=749633&r2=749634&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBean.java (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBean.java Tue Mar  3 15:44:03 2009
@@ -44,6 +44,7 @@
     boolean isSharedForGallery;
 
     public void copyTo(MediaFile dataHolder) throws WebloggerException {
+    	
     	dataHolder.setName(this.name);
     	dataHolder.setDescription(this.description);
     	dataHolder.setCopyrightText(this.copyrightText);
@@ -58,6 +59,24 @@
     
     
     public void copyFrom(MediaFile dataHolder) {
+    	this.setId(dataHolder.getId());
+    	this.setName(dataHolder.getName());
+    	this.setDescription(dataHolder.getDescription());
+    	this.setCopyrightText(dataHolder.getCopyrightText());
+    	
+    	Set<MediaFileTag> tags = dataHolder.getTags();
+    	if (tags != null && !tags.isEmpty()) {
+        	StringBuffer tagDisplayBuffer = new StringBuffer();
+        	for (MediaFileTag tag: dataHolder.getTags()) {
+        		tagDisplayBuffer.append(tag.getName());
+        		tagDisplayBuffer.append(" ");
+        	}
+        	tagDisplayBuffer.deleteCharAt(tagDisplayBuffer.length() - 1);
+        	this.setTags(tagDisplayBuffer.toString());
+    	}
+    	
+    	this.setSharedForGallery(dataHolder.isSharedForGallery());
+    	this.setDirectoryId(dataHolder.getDirectory().getId());
     }
 
 

Added: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileEdit.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileEdit.java?rev=749634&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileEdit.java (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileEdit.java Tue Mar  3 15:44:03 2009
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.weblogger.ui.struts2.editor;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.FileIOException;
+import org.apache.roller.weblogger.business.MediaFileManager;
+import org.apache.roller.weblogger.business.WebloggerFactory;
+import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
+import org.apache.roller.weblogger.pojos.MediaFile;
+import org.apache.roller.weblogger.pojos.MediaFileDirectory;
+import org.apache.roller.weblogger.ui.struts2.util.UIAction;
+import org.apache.struts2.interceptor.validation.SkipValidation;
+
+/**
+ * Adds a new media file.
+ */
+@SuppressWarnings("serial")
+public class MediaFileEdit extends UIAction {
+    private static Log log = LogFactory.getLog(MediaFileEdit.class);
+    
+    private String mediaFileId; 
+
+    private MediaFileBean bean =  new MediaFileBean();
+    private MediaFileDirectory directory;
+    
+    private List<MediaFileDirectory> allDirectories;
+
+    public MediaFileEdit() {
+        this.actionName = "mediaFileEdit";
+        this.desiredMenu = "editor";
+        this.pageTitle = "mediaFile.edit.title";
+    }
+    
+    public void myPrepare() {
+        try {
+            MediaFileManager mgr = WebloggerFactory.getWeblogger().getMediaFileManager();
+            setAllDirectories(mgr.getMediaFileDirectories(getActionWeblog()));
+            if(!StringUtils.isEmpty(bean.getDirectoryId())) {
+                setDirectory(mgr.getMediaFileDirectory(bean.getDirectoryId()));
+            }
+        } catch (WebloggerException ex) {
+            log.error("Error looking up media file directory", ex);
+            // TODO: Ganesh - Handle exception
+        }
+    }
+
+    /**
+     * Show form for adding a new media file.
+     * 
+     * @return String The result of the action.
+     */
+    @SkipValidation
+    public String execute() {
+		MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+		try {
+			MediaFile mediaFile = manager.getMediaFile(this.mediaFileId);
+			this.bean.copyFrom(mediaFile);
+    		return SUCCESS;
+        } catch (FileIOException ex) {
+            addError("uploadFiles.error.upload", bean.getName());
+		} catch (Exception e) {
+            log.error("Error saving new entry", e);
+            // TODO: i18n
+            addError("Error reading uploaded file - " + bean.getName());
+		}
+
+		return INPUT;
+    }
+    
+    /**
+     * Save a media file.
+     * 
+     * @return String The result of the action.
+     */
+    public String save() {
+    	myValidate();
+    	if (!hasActionErrors()) {
+    		MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+    		try {
+    			MediaFile mediaFile = manager.getMediaFile(this.mediaFileId);
+    			bean.copyTo(mediaFile);
+				manager.updateMediaFile(getActionWeblog(), mediaFile);
+	            WebloggerFactory.getWeblogger().flush();
+	            addMessage("mediaFile.update.success");
+	    		return SUCCESS;
+            } catch (FileIOException ex) {
+                addError("uploadFiles.error.upload", bean.getName());
+			} catch (Exception e) {
+	            log.error("Error saving new entry", e);
+                // TODO: i18n
+                addError("Error reading uploaded file - " + bean.getName());
+			}
+			
+    	}
+		return INPUT;
+    }
+    
+    public void myValidate() {
+    	MediaFile fileWithSameName = getDirectory().getMediaFile(getBean().getName());
+        if (fileWithSameName != null && !fileWithSameName.getId().equals(this.mediaFileId)) {
+            addError("MediaFile.error.duplicateName", getBean().getName());
+        }
+    }
+    
+    /**
+     * Get the list of all categories for the action weblog, not including root.
+     */
+    public List<MediaFileDirectory> getDirectories() {
+        
+    	try {
+        	// TODO: Ganesh - do this in prepare method?
+    		MediaFileManager mgr = WebloggerFactory.getWeblogger().getMediaFileManager();
+            return mgr.getMediaFileDirectories(getActionWeblog());
+        } catch (WebloggerException ex) {
+            log.error("Error getting media file directory list for weblog - "+getWeblog(), ex);
+            return Collections.EMPTY_LIST;
+        }
+    }
+
+    public MediaFileBean getBean() {
+    	return bean;
+    }
+    
+    public void setBean(MediaFileBean b) {
+    	this.bean = b;
+    }
+    
+	public List<MediaFileDirectory> getAllDirectories() {
+		return allDirectories;
+	}
+    
+	public void setAllDirectories(List<MediaFileDirectory> dirs) {
+		this.allDirectories = dirs;
+	}
+
+	public String getMediaFileId() {
+		return mediaFileId;
+	}
+
+	public void setMediaFileId(String mediaFileId) {
+		this.mediaFileId = mediaFileId;
+	}
+
+	public MediaFileDirectory getDirectory() {
+		return directory;
+	}
+
+	public void setDirectory(MediaFileDirectory directory) {
+		this.directory = directory;
+	}
+
+}

Added: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileSearch.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileSearch.java?rev=749634&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileSearch.java (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileSearch.java Tue Mar  3 15:44:03 2009
@@ -0,0 +1,237 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.weblogger.ui.struts2.editor;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.MediaFileManager;
+import org.apache.roller.weblogger.business.WebloggerFactory;
+import org.apache.roller.weblogger.pojos.MediaFile;
+import org.apache.roller.weblogger.pojos.MediaFileFilter;
+import org.apache.roller.weblogger.ui.struts2.pagers.MediaFilePager;
+import org.apache.roller.weblogger.ui.struts2.util.KeyValueObject;
+import org.apache.struts2.interceptor.validation.SkipValidation;
+
+/**
+ * Handles actions associated with media file search page.
+ */
+@SuppressWarnings("serial")
+public class MediaFileSearch extends MediaFileBase {
+    private static Log log = LogFactory.getLog(MediaFileSearch.class);
+
+    private static final List<String> fileTypes;
+    private static final List<KeyValueObject> sizeFilterTypes;
+    private static final List<KeyValueObject> sizeUnits;
+    private static final List<KeyValueObject> sortOptions;
+    
+    private MediaFilePager pager;
+
+    private String newDirectoryPath;
+    
+    static {
+        fileTypes = Arrays.asList("", "Audio", "Video", "Image");
+        
+        sizeFilterTypes = Arrays.asList(
+        		new KeyValueObject(0, "greater than"),
+        		new KeyValueObject(1, "greater than or equal to"),
+        		new KeyValueObject(2, "equal to"),
+        		new KeyValueObject(3, "less than or equal to"),
+        		new KeyValueObject(4, "less than")
+        		);
+
+        sizeUnits = Arrays.asList(
+        		new KeyValueObject(0, "bytes"),
+        		new KeyValueObject(1, "kilobytes"),
+        		new KeyValueObject(2, "megabytes")
+        		);
+        
+        sortOptions = Arrays.asList(
+        		new KeyValueObject(0, "Name"),
+        		new KeyValueObject(1, "Date Uploaded"),
+        		new KeyValueObject(2, "Type")
+        		); 
+    }
+    
+    private MediaFileSearchBean bean =  new MediaFileSearchBean();
+
+    public MediaFileSearch() {
+        this.actionName = "mediaFileSearch";
+        this.desiredMenu = "editor";
+        this.pageTitle = "mediaFile.search.title";
+    }
+    
+    public void myPrepare() {
+    	refreshAllDirectories();
+    }
+    
+    /**
+     * Show form for adding a new media file.
+     * 
+     * @return String The result of the action.
+     */
+    @SkipValidation
+    public String execute() {
+		return INPUT;
+    }
+    
+    /**
+     * Save a media file.
+     * 
+     * @return String The result of the action.
+     */
+    public String search() {
+    	boolean valSuccess = myValidate();
+    	if (valSuccess) {
+    		MediaFileFilter filter = new MediaFileFilter();
+    		bean.copyTo(filter);
+    		MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+    		try {
+    			List<MediaFile> rawResults = manager.searchMediaFiles(getActionWeblog(), filter);
+    			boolean hasMore = false;
+    			List<MediaFile> results = new ArrayList<MediaFile>();
+    			results.addAll(rawResults);
+    			if (results.size() > MediaFileSearchBean.PAGE_SIZE) {
+    				results.remove(results.size() - 1);
+    				hasMore = true;
+    			}
+    			
+    			this.pager = new MediaFilePager(bean.getPageNum(), results, hasMore);
+    			
+    			if (results.isEmpty()) {
+                    addError("MediaFile.error.search.noResults");
+    			}
+	    		return SUCCESS;
+			} catch (Exception e) {
+	            log.error("Error applying search criteria", e);
+                // TODO: i18n
+                addError("Error applying search criteria");
+			}
+    		
+    	}
+		return INPUT;
+    }
+    
+    public String delete() {
+    	doDeleteMediaFile();
+    	return search();
+    }
+    
+    public String includeInGallery() {
+    	doIncludeMediaFileInGallery();
+    	return search();
+    }
+
+    public String deleteSelected() {
+    	doDeleteSelected();
+    	return search();
+    }
+    
+    public String moveSelected() {
+        doMoveSelected();
+    	return search();
+    }
+    
+    public String createDirByPath() {
+    	boolean dirCreated = false;
+		if (StringUtils.isEmpty(this.newDirectoryPath)) {
+			addError("mediaFile.error.search.dirPathEmpty");
+		}
+		else if (!this.newDirectoryPath.startsWith("/")) {
+			addError("mediaFile.error.search.dirPathInvalid");
+		}
+		else {
+	    	try {
+				log.debug("Creating directory by path - " + this.newDirectoryPath);
+				MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+				manager.createMediaFileDirectoryByPath(getActionWeblog(), this.newDirectoryPath);
+				// flush changes
+				WebloggerFactory.getWeblogger().flush();
+				addMessage("mediaFile.directoryCreate.success");
+				dirCreated = true;
+			} catch (WebloggerException e) {
+	            log.error("Error creating new directory by path", e);
+	            // TODO: i18n
+	            addError("Error creating new directory by path");
+			}
+		}
+        
+		if (dirCreated) {
+			// Refresh list of directories so the newly created directory is included.
+			refreshAllDirectories();
+		}
+    	return search();
+    }
+    
+    public boolean myValidate() {
+        if (StringUtils.isEmpty(bean.getName())
+        	&& StringUtils.isEmpty(bean.getTags())
+        	&& StringUtils.isEmpty(bean.getType())
+        	&& bean.getSize() == 0) {
+        	addError("MediaFile.error.search.empty");
+        	return false;
+        }
+        return true;
+    }
+    
+    public MediaFileSearchBean getBean() {
+    	return bean;
+    }
+    
+    public void setBean(MediaFileSearchBean b) {
+    	this.bean = b;
+    }
+    
+    public List<String> getFileTypes() {
+    	return fileTypes;
+    }
+    
+    public List<KeyValueObject> getSizeFilterTypes() {
+    	return sizeFilterTypes;
+    }
+    
+    public List<KeyValueObject> getSizeUnits() {
+    	return sizeUnits;
+    }
+
+    public List<KeyValueObject> getSortOptions() {
+    	return sortOptions;
+    }
+
+    public MediaFilePager getPager() {
+		return pager;
+	}
+
+	public void setPager(MediaFilePager pager) {
+		this.pager = pager;
+	}
+
+	public String getNewDirectoryPath() {
+		return newDirectoryPath;
+	}
+
+	public void setNewDirectoryPath(String newDirectoryPath) {
+		this.newDirectoryPath = newDirectoryPath;
+	}
+}

Added: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileSearchBean.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileSearchBean.java?rev=749634&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileSearchBean.java (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileSearchBean.java Tue Mar  3 15:44:03 2009
@@ -0,0 +1,160 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.weblogger.ui.struts2.editor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.roller.weblogger.pojos.MediaFileFilter;
+import org.apache.roller.weblogger.pojos.MediaFileType;
+import org.apache.roller.weblogger.pojos.MediaFileFilter.MediaFileOrder;
+import org.apache.roller.weblogger.pojos.MediaFileFilter.SizeFilterType;
+
+/**
+ * Bean for holding media file search criteria.
+ */
+public class MediaFileSearchBean {
+	public static int PAGE_SIZE = 5;
+
+	String name;
+	String type;
+	int sizeFilterType;
+	long size;
+	int sizeUnit;
+	String tags;
+	int pageNum = 0;
+	int sortOption;
+
+	public String getName() {
+		return name;
+	}
+	public void setName(String name) {
+		this.name = name;
+	}
+	public String getType() {
+		return type;
+	}
+	public void setType(String type) {
+		this.type = type;
+	}
+	public int getSizeFilterType() {
+		return sizeFilterType;
+	}
+	public void setSizeFilterType(int sizeFilterType) {
+		this.sizeFilterType = sizeFilterType;
+	}
+	public long getSize() {
+		return size;
+	}
+	public void setSize(long size) {
+		this.size = size;
+	}
+	public int getSizeUnit() {
+		return sizeUnit;
+	}
+	public void setSizeUnit(int sizeUnit) {
+		this.sizeUnit = sizeUnit;
+	}
+	public String getTags() {
+		return tags;
+	}
+	public void setTags(String tags) {
+		this.tags = tags;
+	}
+	
+    public int getPageNum() {
+		return pageNum;
+	}
+	public void setPageNum(int pageNum) {
+		this.pageNum = pageNum;
+	}
+
+	public int getSortOption() {
+		return sortOption;
+	}
+	public void setSortOption(int sortOption) {
+		this.sortOption = sortOption;
+	}
+
+	public void copyTo(MediaFileFilter dataHolder) {
+    	dataHolder.setName(this.name);
+    	
+    	if (!StringUtils.isEmpty(this.type)) {
+        	MediaFileType filterType = null;
+    		if ("Audio".equals(this.type)) {
+    			filterType = MediaFileType.AUDIO;
+    		}
+    		else if ("Video".equals(this.type)) {
+    			filterType = MediaFileType.VIDEO;
+    		}
+    		else if ("Image".equals(this.type)) {
+    			filterType = MediaFileType.IMAGE;
+    		}
+    		
+    		dataHolder.setType(filterType);
+    	}
+    	
+    	if (this.size > 0) {
+        	SizeFilterType type;
+        	switch(this.sizeFilterType) {
+        	case 0: type = SizeFilterType.GT;break;
+        	case 1: type = SizeFilterType.GTE;break;
+        	case 2: type = SizeFilterType.EQ;break;
+        	case 3: type = SizeFilterType.LTE;break;
+        	case 4: type = SizeFilterType.LT;break;
+        	default: type = null;
+        	}
+        	dataHolder.setSizeFilterType(type);
+        	
+        	long filterSize;
+        	switch (this.sizeUnit) {
+        	case 1: filterSize = this.size * 1024;break;
+        	case 2: filterSize = this.size * 1024 * 1024;break;
+        	default: filterSize = this.size;
+        	}
+        	dataHolder.setSize(filterSize);
+    	}
+    	
+    	if (!StringUtils.isEmpty(this.tags)) {
+        	List<String> tagsSet = new ArrayList<String>();  
+        	for (String tag: this.tags.split(" ")) {
+        		tagsSet.add(tag);
+        	}
+        	dataHolder.setTags(tagsSet);
+    	}
+    	
+    	dataHolder.setStartIndex(pageNum * PAGE_SIZE);
+    	/**
+    	 * Set length to fetch to one more than what is required.
+    	 * This would help us determine whether there are more pages
+    	 */
+    	dataHolder.setLength(PAGE_SIZE + 1);
+    	
+    	MediaFileOrder order; 
+    	switch(this.sortOption) {
+    	case 0: order = MediaFileOrder.NAME;break;
+    	case 1: order = MediaFileOrder.DATE_UPLOADED;break;
+    	case 2: order = MediaFileOrder.TYPE;break;
+    	default: order = null;
+    	}
+    	dataHolder.setOrder(order);
+    }
+
+}

Added: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java?rev=749634&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java Tue Mar  3 15:44:03 2009
@@ -0,0 +1,275 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.weblogger.ui.struts2.editor;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.FileIOException;
+import org.apache.roller.weblogger.business.MediaFileManager;
+import org.apache.roller.weblogger.business.WebloggerFactory;
+import org.apache.roller.weblogger.pojos.MediaFile;
+import org.apache.roller.weblogger.pojos.MediaFileComparator;
+import org.apache.roller.weblogger.pojos.MediaFileDirectory;
+import org.apache.roller.weblogger.pojos.MediaFileDirectoryComparator;
+import org.apache.roller.weblogger.pojos.MediaFileComparator.MediaFileComparatorType;
+import org.apache.roller.weblogger.pojos.MediaFileDirectoryComparator.DirectoryComparatorType;
+import org.apache.roller.weblogger.ui.struts2.util.KeyValueObject;
+import org.apache.struts2.interceptor.validation.SkipValidation;
+
+/**
+ * Adds a new media file.
+ */
+@SuppressWarnings("serial")
+public class MediaFileView extends MediaFileBase {
+    private static Log log = LogFactory.getLog(MediaFileView.class);
+    
+    private static final List<KeyValueObject> sortOptions;
+
+    static {
+        sortOptions = Arrays.asList(
+        		new KeyValueObject("", ""),
+        		new KeyValueObject("name", "Name"),
+        		new KeyValueObject("date_uploaded", "Date Uploaded"),
+        		new KeyValueObject("type", "Type")
+        		); 
+    }
+
+    private String directoryId;
+    private String directoryPath;
+    private MediaFileDirectory currentDirectory;
+    
+    private String sortBy;
+
+    private List<MediaFileDirectory> childDirectories;
+    private List<MediaFile> childFiles;
+    
+    private String newDirectoryName;
+
+    public MediaFileView() {
+        this.actionName = "mediaViewAdd";
+        this.desiredMenu = "editor";
+        this.pageTitle = "mediaFile.view.title";
+    }
+    
+    public void myPrepare() {
+    	refreshAllDirectories();
+    }
+
+    public String createNewDirectory() {
+    	boolean dirCreated = false;
+		if (StringUtils.isEmpty(this.newDirectoryName)) {
+			addError("mediaFile.error.view.dirNameEmpty");
+		}
+		else if (this.newDirectoryName.contains("/")) {
+			addError("mediaFile.error.view.dirNameInvalid");
+		}
+		else {
+			try {
+				log.debug("Creating new directory - " + this.newDirectoryName);
+				MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+				MediaFileDirectory parentDirectory = manager.getMediaFileDirectory(this.directoryId);
+				manager.createMediaFileDirectory(parentDirectory, this.newDirectoryName);
+				// flush changes
+				WebloggerFactory.getWeblogger().flush();
+				addMessage("mediaFile.directoryCreate.success");
+				dirCreated = true;
+			} catch (WebloggerException e) {
+	            log.error("Error creating new directory by path", e);
+	            // TODO: i18n
+	            addError("Error creating new directory by path");
+			}
+		}
+
+        
+		if (dirCreated) {
+			// Refresh list of directories so the newly created directory is included.
+			refreshAllDirectories();
+		}
+    	return execute();
+    	
+    }
+    
+    // TODO: Ganesh - use a different name
+    // Returns directory content in JSON format. 
+    public String fetchDirectoryContentLight() {
+    	execute();
+    	return "success.json";
+    }
+    
+    /**
+     * Show form for adding a new media file.
+     * 
+     * @return String The result of the action.
+     */
+    @SkipValidation
+    public String execute() {
+		MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+		try {
+			MediaFileDirectory directory;
+			if (this.directoryId != null) {
+				directory = manager.getMediaFileDirectory(this.directoryId);
+			}
+			else if (this.directoryPath != null){
+				directory = manager.getMediaFileDirectoryByPath(getActionWeblog(), this.directoryPath);
+				this.directoryId = directory.getId();
+			}
+			else {
+				directory = manager.getMediaFileRootDirectory(getActionWeblog());
+				this.directoryId = directory.getId();
+			}
+
+			this.childDirectories = new ArrayList<MediaFileDirectory>();
+			this.childDirectories.addAll(directory.getChildDirectories());
+			
+			this.childFiles = new ArrayList<MediaFile>();
+			this.childFiles.addAll(directory.getMediaFiles());
+			
+			if (!StringUtils.isEmpty(this.sortBy)) {
+				if ("name".equals(sortBy)) {
+					Collections.sort(this.childDirectories, new MediaFileDirectoryComparator(DirectoryComparatorType.NAME));
+					Collections.sort(this.childFiles, new MediaFileComparator(MediaFileComparatorType.NAME));
+				}
+				else if ("type".equals(sortBy)) {
+					Collections.sort(this.childFiles, new MediaFileComparator(MediaFileComparatorType.TYPE));
+				}
+				else if ("date_uploaded".equals(sortBy)) {
+					Collections.sort(this.childFiles, new MediaFileComparator(MediaFileComparatorType.DATE_UPLOADED));
+				}
+			}
+			
+			this.currentDirectory = directory;
+			
+    		return SUCCESS;
+        } catch (FileIOException ex) {
+        	log.error("Error viewing media file directory ", ex);
+            addError("MediaFile.error.view");
+		} catch (Exception e) {
+            log.error("Error viewing media file directory ", e);
+            addError("MediaFile.error.view");
+		}
+		return SUCCESS;
+    }
+    
+    public List<KeyValueObject> getCurrentDirectoryHierarchy() {
+    	List<KeyValueObject> directoryHierarchy = new ArrayList<KeyValueObject>();
+
+    	directoryHierarchy.add(new KeyValueObject("/", "root"));
+    	String fullPath = this.currentDirectory.getPath();
+    	if (fullPath.length() > 1) {
+        	String[] directoryNames = fullPath.substring(1).split("/");
+        	String directoryPath = "";
+        	for (String directoryName: directoryNames) {
+        		directoryPath = directoryPath + "/" + directoryName; 
+            	directoryHierarchy.add(new KeyValueObject(directoryPath, directoryName));
+        	}
+    	}
+    	return directoryHierarchy;
+    }
+    
+    public String deleteSelected() {
+    	doDeleteSelected();
+    	return execute();
+    }
+    
+    public String delete() {
+    	doDeleteMediaFile();
+    	return execute();
+    }
+    
+    public String includeInGallery() {
+    	doIncludeMediaFileInGallery();
+    	return execute();
+    }
+
+    public String moveSelected() {
+        doMoveSelected();
+    	return execute();
+    }
+    
+    public void myValidate() {
+    }
+    
+	public String getDirectoryId() {
+		return directoryId;
+	}
+
+	public void setDirectoryId(String id) {
+		this.directoryId = id;
+	}
+
+	public List<MediaFileDirectory> getChildDirectories() {
+		return childDirectories;
+	}
+
+	public void setChildDirectories(List<MediaFileDirectory> directories) {
+		this.childDirectories = directories;
+	}
+
+	public List<MediaFile> getChildFiles() {
+		return childFiles;
+	}
+
+	public void setChildFiles(List<MediaFile> files) {
+		this.childFiles = files;
+	}
+
+	public String getNewDirectoryName() {
+		return newDirectoryName;
+	}
+
+	public void setNewDirectoryName(String newDirectoryName) {
+		this.newDirectoryName = newDirectoryName;
+	}
+
+	public MediaFileDirectory getCurrentDirectory() {
+		return currentDirectory;
+	}
+
+	public void setCurrentDirectory(MediaFileDirectory currentDirectory) {
+		this.currentDirectory = currentDirectory;
+	}
+
+	public String getDirectoryPath() {
+		return directoryPath;
+	}
+
+	public void setDirectoryPath(String path) {
+		this.directoryPath = path;
+	}
+
+	public String getSortBy() {
+		return sortBy;
+	}
+
+	public void setSortBy(String sortBy) {
+		this.sortBy = sortBy;
+	}
+
+    public List<KeyValueObject> getSortOptions() {
+    	return sortOptions;
+    }
+
+}

Added: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/pagers/MediaFilePager.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/pagers/MediaFilePager.java?rev=749634&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/pagers/MediaFilePager.java (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/pagers/MediaFilePager.java Tue Mar  3 15:44:03 2009
@@ -0,0 +1,49 @@
+package org.apache.roller.weblogger.ui.struts2.pagers;
+
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.pojos.MediaFile;
+
+public class MediaFilePager {
+    private static final Log log = LogFactory.getLog(MediaFilePager.class);
+    
+    // the collection for the pager
+    private final List<MediaFile> items;
+    
+    // what page we are on
+    private final int pageNum;
+    
+    // are there more items?
+    private final boolean moreItems;
+    
+    public MediaFilePager(int page, List<MediaFile> mediaFiles, boolean hasMore) {
+        this.pageNum = page;
+        this.items = mediaFiles;
+        this.moreItems = hasMore;
+    }
+    
+    public List<MediaFile> getItems() {
+        return items;
+    }
+
+    public boolean isMoreItems() {
+        return moreItems;
+    }
+
+    public boolean isJustOnePage() {
+    	return (pageNum == 0 && !moreItems);
+    }
+    
+    public boolean hasPrevious() {
+    	return (pageNum > 0);
+    }
+    
+    public boolean hasNext() {
+    	return this.moreItems;
+    }
+    
+    
+
+}

Modified: roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/business/FileContentManagerTest.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/business/FileContentManagerTest.java?rev=749634&r1=749633&r2=749634&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/business/FileContentManagerTest.java (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/business/FileContentManagerTest.java Tue Mar  3 15:44:03 2009
@@ -60,13 +60,6 @@
         // setup weblogger
         TestUtils.setupWeblogger();
         
-        try {
-            testUser = TestUtils.setupUser("FCMTest_userName");
-            testWeblog = TestUtils.setupWeblog("FCMTest_handle", testUser);
-            TestUtils.endSession(true);
-        } catch (Exception ex) {
-            log.error(ex);
-        }
     }
     
     public void tearDown() throws Exception {
@@ -80,6 +73,14 @@
             log.error(ex);
         }
         */
+        PropertiesManager pmgr = WebloggerFactory.getWeblogger().getPropertiesManager();
+        Map config = config = pmgr.getProperties();
+        ((RuntimeConfigProperty)config.get("uploads.dir.maxsize")).setValue("30000");
+        ((RuntimeConfigProperty)config.get("uploads.types.forbid")).setValue("");
+        ((RuntimeConfigProperty)config.get("uploads.types.allowed")).setValue("");
+        ((RuntimeConfigProperty)config.get("uploads.enabled")).setValue("true");
+        pmgr.saveProperties(config);
+        TestUtils.endSession(true);
     }
     
     
@@ -88,6 +89,14 @@
      */
     public void testFileCRUD() throws Exception {
         
+        try {
+            testUser = TestUtils.setupUser("FCMTest_userName1");
+            testWeblog = TestUtils.setupWeblog("FCMTest_handle1", testUser);
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+        }
+
         // update roller properties to prepare for test
         PropertiesManager pmgr = WebloggerFactory.getWeblogger().getPropertiesManager();
         Map config = pmgr.getProperties();
@@ -138,6 +147,14 @@
      */
     public void testCanSave() throws Exception {
         
+        try {
+            testUser = TestUtils.setupUser("FCMTest_userName2");
+            testWeblog = TestUtils.setupWeblog("FCMTest_handle2", testUser);
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+        }
+
         FileContentManager fmgr = WebloggerFactory.getWeblogger().getFileContentManager();
         PropertiesManager pmgr = WebloggerFactory.getWeblogger().getPropertiesManager();
         Map config = config = pmgr.getProperties();



Mime
View raw message