roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ganes...@apache.org
Subject svn commit: r749634 [2/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
Modified: roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/business/MediaFileTest.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/business/MediaFileTest.java?rev=749634&r1=749633&r2=749634&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/business/MediaFileTest.java (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/business/MediaFileTest.java Tue Mar  3 15:44:03 2009
@@ -22,6 +22,8 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
@@ -33,13 +35,18 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.TestUtils;
+import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.ant.StartDerbyTask;
 import org.apache.roller.weblogger.ant.StopDerbyTask;
 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.MediaFileTag;
+import org.apache.roller.weblogger.pojos.MediaFileType;
 import org.apache.roller.weblogger.pojos.User;
 import org.apache.roller.weblogger.pojos.Weblog;
+import org.apache.roller.weblogger.pojos.MediaFileFilter.MediaFileOrder;
+import org.apache.roller.weblogger.pojos.MediaFileFilter.SizeFilterType;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.taskdefs.SQLExec;
 import org.junit.After;
@@ -97,21 +104,21 @@
 
     public static void startDatabase() throws Exception {
     	StartDerbyTask startTask = new StartDerbyTask();
-    	startTask.setDatabase("C:/Ganesh/edu/Project/sources/roller-svn/apps/weblogger/build/tests/derby-system/roller");
+    	startTask.setDatabase("C:/Ganesh/edu/Project/sources/media-blogging-branch/apps/weblogger/build/tests/derby-system/roller");
     	startTask.setPort("3219");
     	startTask.execute();
     }
 
     public static void initDatabaseShort() throws Exception {
     	Properties props = new Properties();
-    	props.load(new FileInputStream("C:/Ganesh/edu/Project/sources/roller-svn/apps/weblogger/build.properties"));
+    	props.load(new FileInputStream("C:/Ganesh/edu/Project/sources/media-blogging-branch/apps/weblogger/build.properties"));
 
     	SQLExec sqlTask1 = new SQLExec();
     	sqlTask1.setDriver(props.getProperty("test.db.driver"));
     	sqlTask1.setUrl(props.getProperty("test.db.url"));
     	sqlTask1.setUserid(props.getProperty("test.db.username"));
     	sqlTask1.setPassword(props.getProperty("test.db.password"));
-    	sqlTask1.setSrc(new File("C:/Ganesh/edu/Project/sources/roller-svn/apps/weblogger/src/sql/media_file_delete_data.sql"));
+    	sqlTask1.setSrc(new File("C:/Ganesh/edu/Project/sources/media-blogging-branch/apps/weblogger/src/sql/media_file_delete_data.sql"));
     	SQLExec.OnError onError1 = new SQLExec.OnError();
     	onError1.setValue("continue");
     	sqlTask1.setOnerror(onError1);
@@ -123,14 +130,14 @@
     public static void initDatabase() throws Exception {
     	
     	Properties props = new Properties();
-    	props.load(new FileInputStream("C:/Ganesh/edu/Project/sources/roller-svn/apps/weblogger/build.properties"));
+    	props.load(new FileInputStream("C:/Ganesh/edu/Project/sources/media-blogging-branch/apps/weblogger/build.properties"));
 
     	SQLExec sqlTask1 = new SQLExec();
     	sqlTask1.setDriver(props.getProperty("test.db.driver"));
     	sqlTask1.setUrl(props.getProperty("test.db.url"));
     	sqlTask1.setUserid(props.getProperty("test.db.username"));
     	sqlTask1.setPassword(props.getProperty("test.db.password"));
-    	sqlTask1.setSrc(new File("C:/Ganesh/edu/Project/sources/roller-svn/apps/weblogger/build/webapp/WEB-INF/classes/dbscripts/droptables.sql"));
+    	sqlTask1.setSrc(new File("C:/Ganesh/edu/Project/sources/media-blogging-branch/apps/weblogger/build/webapp/WEB-INF/classes/dbscripts/droptables.sql"));
     	SQLExec.OnError onError1 = new SQLExec.OnError();
     	onError1.setValue("continue");
     	sqlTask1.setOnerror(onError1);
@@ -143,7 +150,7 @@
     	sqlTask2.setUrl(props.getProperty("test.db.url"));
     	sqlTask2.setUserid(props.getProperty("test.db.username"));
     	sqlTask2.setPassword(props.getProperty("test.db.password"));
-    	sqlTask2.setSrc(new File("C:/Ganesh/edu/Project/sources/roller-svn/apps/weblogger/build/webapp/WEB-INF/classes/dbscripts/derby/createdb.sql"));
+    	sqlTask2.setSrc(new File("C:/Ganesh/edu/Project/sources/media-blogging-branch/apps/weblogger/build/webapp/WEB-INF/classes/dbscripts/derby/createdb.sql"));
     	SQLExec.OnError onError2 = new SQLExec.OnError();
     	onError2.setValue("continue");
     	sqlTask2.setOnerror(onError2);
@@ -177,6 +184,105 @@
         
     }
     
+    /**
+     * Test directory creation
+     */
+    @Test
+    public void testCreateMediaFileDirectoryByPath() throws Exception {
+        User testUser = null;
+        Weblog testWeblog = null;
+        
+    	// TODO: Setup code, to be moved to setUp method.
+    	System.out.println("Before setting up weblogger");
+        // setup weblogger
+        try {
+            testUser = TestUtils.setupUser("mediaFileTestUser8");
+            testWeblog = TestUtils.setupWeblog("mediaFileTestWeblog8", testUser);
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+            throw new Exception("Test setup failed", ex);
+        }
+
+        /**
+         * Real test starts here.
+         */
+        MediaFileManager mfMgr = WebloggerFactory.getWeblogger().getMediaFileManager();
+        
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        MediaFileDirectory rootDirectory = new MediaFileDirectory(null, "root", "root d", testWeblog);
+        mfMgr.createMediaFileDirectory(rootDirectory);
+        assertNotNull(rootDirectory.getId() != null);
+        TestUtils.endSession(true);
+        
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+
+        try {
+            mfMgr.createMediaFileDirectoryByPath(testWeblog, "");
+        	assertTrue(false);
+        }
+        catch (WebloggerException e) {
+        	assertTrue(true);
+        }
+        
+        try {
+            mfMgr.createMediaFileDirectoryByPath(testWeblog, "/");
+        	assertTrue(false);
+        }
+        catch (WebloggerException e) {
+        	assertTrue(true);
+        }
+        
+        MediaFileDirectory newDirectory1 = mfMgr.createMediaFileDirectoryByPath(testWeblog, "/test1");
+        MediaFileDirectory newDirectory2 = mfMgr.createMediaFileDirectoryByPath(testWeblog, "/test2/");
+        TestUtils.endSession(true);
+        
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+
+        MediaFileDirectory newDirectory1ById = mfMgr.getMediaFileDirectory(newDirectory1.getId());
+        assertEquals(newDirectory1, newDirectory1ById);
+        
+        MediaFileDirectory newDirectory2ById = mfMgr.getMediaFileDirectory(newDirectory2.getId());
+        assertEquals("test2", newDirectory2ById.getName());
+
+        try {
+            mfMgr.createMediaFileDirectoryByPath(testWeblog, "test1");
+        	assertTrue(false);
+        }
+        catch (WebloggerException e) {
+        	assertTrue(true);
+        }
+
+        try {
+            mfMgr.createMediaFileDirectoryByPath(testWeblog, "/test1/test2/test3");
+        	assertTrue(false);
+        }
+        catch (WebloggerException e) {
+        	assertTrue(true);
+        }
+        
+        MediaFileDirectory newDirectory3 = mfMgr.createMediaFileDirectoryByPath(testWeblog, "/test1/test2");
+        TestUtils.endSession(true);
+        
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        MediaFileDirectory newDirectory3ById = mfMgr.getMediaFileDirectory(newDirectory3.getId());
+        assertEquals(newDirectory3, newDirectory3ById);
+        
+        MediaFileDirectory newDirectory4 = mfMgr.createMediaFileDirectoryByPath(testWeblog, "/test1/test2/test3");
+        TestUtils.endSession(true);
+        
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        MediaFileDirectory newDirectory4ById = mfMgr.getMediaFileDirectory(newDirectory4.getId());
+        assertEquals(newDirectory4, newDirectory4ById);
+
+        try {
+            mfMgr.createMediaFileDirectoryByPath(testWeblog, "/test1/test2/test3");
+        	assertTrue(false);
+        }
+        catch (WebloggerException e) {
+        	assertTrue(true);
+        }
+    }
     
     /**
      * Test directory creation
@@ -189,7 +295,6 @@
     	// TODO: Setup code, to be moved to setUp method.
     	System.out.println("Before setting up weblogger");
         // setup weblogger
-        TestUtils.setupWeblogger();
         try {
             testUser = TestUtils.setupUser("mediaFileTestUser");
             testWeblog = TestUtils.setupWeblog("mediaFileTestWeblog", testUser);
@@ -321,7 +426,7 @@
         assertNotNull(mediaFile1.getTags());
         assertEquals(2, mediaFile1.getTags().size());
         
-        mfMgr.removeMediaFile(mediaFile1);
+        mfMgr.removeMediaFile(testWeblog, mediaFile1);
         TestUtils.endSession(true);
         
         MediaFile mediaFile2 = mfMgr.getMediaFile(id);
@@ -381,6 +486,322 @@
     }
 
     /**
+     * Test searching media file.
+     */
+    public void testSearchMediaFile() throws Exception {
+        
+        User testUser = null;
+        Weblog testWeblog = null;
+        testUser = TestUtils.setupUser("mediaFileTestUser7");
+        testWeblog = TestUtils.setupWeblog("mediaFileTestWeblog7", testUser);
+        
+        MediaFileManager mfMgr = WebloggerFactory.getWeblogger().getMediaFileManager();
+
+        MediaFileDirectory rootDirectory = new MediaFileDirectory(null, "root", "root d", testWeblog);
+        mfMgr.createMediaFileDirectory(rootDirectory);
+
+        TestUtils.endSession(true);
+
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        rootDirectory = mfMgr.getMediaFileDirectory(rootDirectory.getId());
+        
+        MediaFile mediaFile = new MediaFile();
+        mediaFile.setName("test_work.jpg");
+        mediaFile.setDescription("This is a test image");
+        mediaFile.setCopyrightText("test copyright text");
+        mediaFile.setSharedForGallery(true);
+        mediaFile.setLength(2000);
+        mediaFile.setDirectory(rootDirectory);
+        mediaFile.setInputStream(getClass().getResourceAsStream("/test.jpg"));
+        mediaFile.setContentType("image/jpeg");
+        
+        MediaFileTag tag1 = new MediaFileTag("work", mediaFile);
+        Set<MediaFileTag> tags = new HashSet<MediaFileTag>();
+        tags.add(tag1);
+        mediaFile.setTags(tags);
+        
+        mfMgr.createMediaFile(testWeblog, mediaFile);
+        TestUtils.endSession(true);
+        assertNotNull(mediaFile.getId());
+        assertNotNull(mediaFile.getId().length() > 0);
+        
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        MediaFile mediaFile1 = new MediaFile();
+        mediaFile1 = new MediaFile();
+        mediaFile1.setName("test_home.jpg");
+        mediaFile1.setDescription("This is a test image");
+        mediaFile1.setCopyrightText("test copyright text");
+        mediaFile1.setSharedForGallery(true);
+        mediaFile1.setLength(3000);
+        mediaFile1.setDirectory(rootDirectory);
+        mediaFile1.setInputStream(getClass().getResourceAsStream("/test.jpg"));
+        mediaFile1.setContentType("image/jpeg");
+        
+        MediaFileTag tag2 = new MediaFileTag("home", mediaFile1);
+        tags = new HashSet<MediaFileTag>();
+        tags.add(tag2);
+        mediaFile1.setTags(tags);
+        
+        mfMgr.createMediaFile(testWeblog, mediaFile1);
+        TestUtils.endSession(true);
+        assertNotNull(mediaFile1.getId());
+        assertNotNull(mediaFile1.getId().length() > 0);
+        
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        MediaFile mediaFile2 = new MediaFile();
+        mediaFile2 = new MediaFile();
+        mediaFile2.setName("test_pers.jpg");
+        mediaFile2.setDescription("This is a personal test image");
+        mediaFile2.setCopyrightText("test pers copyright text");
+        mediaFile2.setSharedForGallery(true);
+        mediaFile2.setLength(4000);
+        mediaFile2.setDirectory(rootDirectory);
+        mediaFile2.setInputStream(getClass().getResourceAsStream("/test.jpg"));
+        mediaFile2.setContentType("image/jpeg");
+        
+        MediaFileTag tag3 = new MediaFileTag("home", mediaFile2);
+        tags = new HashSet<MediaFileTag>();
+        tags.add(tag3);
+        mediaFile2.setTags(tags);
+        
+        mfMgr.createMediaFile(testWeblog, mediaFile2);
+        TestUtils.endSession(true);
+        assertNotNull(mediaFile2.getId());
+        assertNotNull(mediaFile2.getId().length() > 0);
+
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+
+        List<MediaFile> searchResults;
+        
+        MediaFileFilter filter1 = new MediaFileFilter();
+        filter1.setName("mytest.jpg");
+        searchResults = mfMgr.searchMediaFiles(testWeblog, filter1);
+        assertTrue(searchResults.isEmpty());
+        
+        MediaFileFilter filter2 = new MediaFileFilter();
+        filter2.setName("test_home.jpg");
+        searchResults = mfMgr.searchMediaFiles(testWeblog, filter2);
+        assertFalse(searchResults.isEmpty());
+        assertEquals(mediaFile1.getId(), ((MediaFile)searchResults.get(0)).getId());
+        assertNotNull(((MediaFile)searchResults.get(0)).getDirectory());
+        assertEquals("/", ((MediaFile)searchResults.get(0)).getDirectory().getPath());
+
+        MediaFileFilter filter3 = new MediaFileFilter();
+        filter3.setName("test_work.jpg");
+        searchResults = mfMgr.searchMediaFiles(testWeblog, filter3);
+        assertFalse(searchResults.isEmpty());
+        assertEquals(mediaFile.getId(), ((MediaFile)searchResults.get(0)).getId());
+
+        MediaFileFilter filter4 = new MediaFileFilter();
+        filter4.setTags(Arrays.asList("work"));
+        searchResults = mfMgr.searchMediaFiles(testWeblog, filter4);
+        assertFalse(searchResults.isEmpty());
+        assertEquals(1, searchResults.size());
+        assertEquals("test_work.jpg", ((MediaFile)searchResults.get(0)).getName());
+        
+        MediaFileFilter filter5 = new MediaFileFilter();
+        filter5.setTags(Arrays.asList("home"));
+        searchResults = mfMgr.searchMediaFiles(testWeblog, filter5);
+        assertFalse(searchResults.isEmpty());
+        assertEquals(2, searchResults.size());
+
+        MediaFileFilter filter6 = new MediaFileFilter();
+        filter6.setSize(3000);
+        filter6.setSizeFilterType(MediaFileFilter.SizeFilterType.LT);
+        searchResults = mfMgr.searchMediaFiles(testWeblog, filter6);
+        assertFalse(searchResults.isEmpty());
+        assertEquals(1, searchResults.size());
+        assertEquals("test_work.jpg", ((MediaFile)searchResults.get(0)).getName());
+
+        MediaFileFilter filter7 = new MediaFileFilter();
+        filter7.setSize(3000);
+        filter7.setSizeFilterType(MediaFileFilter.SizeFilterType.EQ);
+        searchResults = mfMgr.searchMediaFiles(testWeblog, filter7);
+        assertFalse(searchResults.isEmpty());
+        assertEquals(1, searchResults.size());
+        assertEquals("test_home.jpg", ((MediaFile)searchResults.get(0)).getName());
+
+        MediaFileFilter filter8 = new MediaFileFilter();
+        filter8.setSize(3000);
+        filter8.setSizeFilterType(MediaFileFilter.SizeFilterType.GT);
+        searchResults = mfMgr.searchMediaFiles(testWeblog, filter8);
+        assertFalse(searchResults.isEmpty());
+        assertEquals(1, searchResults.size());
+        assertEquals("test_pers.jpg", ((MediaFile)searchResults.get(0)).getName());
+
+        MediaFileFilter filter9 = new MediaFileFilter();
+        filter9.setSize(3000);
+        filter9.setSizeFilterType(MediaFileFilter.SizeFilterType.LTE);
+        searchResults = mfMgr.searchMediaFiles(testWeblog, filter9);
+        assertFalse(searchResults.isEmpty());
+        assertEquals(2, searchResults.size());
+
+        MediaFileFilter filter10 = new MediaFileFilter();
+        filter10.setSize(3000);
+        filter10.setSizeFilterType(MediaFileFilter.SizeFilterType.GTE);
+        searchResults = mfMgr.searchMediaFiles(testWeblog, filter10);
+        assertFalse(searchResults.isEmpty());
+        assertEquals(2, searchResults.size());
+
+        MediaFileFilter filter11 = new MediaFileFilter();
+        filter11.setType(MediaFileType.IMAGE);
+        searchResults = mfMgr.searchMediaFiles(testWeblog, filter11);
+        assertFalse(searchResults.isEmpty());
+        assertEquals(3, searchResults.size());
+
+        MediaFileFilter filter12 = new MediaFileFilter();
+        filter12.setType(MediaFileType.IMAGE);
+        filter12.setTags(Arrays.asList("home"));
+        searchResults = mfMgr.searchMediaFiles(testWeblog, filter12);
+        assertFalse(searchResults.isEmpty());
+        assertEquals(2, searchResults.size());
+    }
+
+    /**
+     * Test searching media file with paging logic.
+     */
+    public void testSearchMediaFilePaging() throws Exception {
+        User testUser = null;
+        Weblog testWeblog = null;
+        testUser = TestUtils.setupUser("mediaFileTestUser9");
+        testWeblog = TestUtils.setupWeblog("mediaFileTestWeblog9", testUser);
+    	
+        MediaFileManager mfMgr = WebloggerFactory.getWeblogger().getMediaFileManager();
+
+        MediaFileDirectory rootDirectory = new MediaFileDirectory(null, "root", "root d", testWeblog);
+        mfMgr.createMediaFileDirectory(rootDirectory);
+
+        TestUtils.endSession(true);
+
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        rootDirectory = mfMgr.getMediaFileDirectory(rootDirectory.getId());
+
+        for (int i = 0; i < 15; i ++) {
+            MediaFile mediaFile = new MediaFile();
+            mediaFile.setName("test_file<index>.jpg".replace("<index>", i + ""));
+            mediaFile.setDescription("This is a test image");
+            mediaFile.setCopyrightText("test copyright text");
+            mediaFile.setSharedForGallery(true);
+            mediaFile.setLength(2000);
+            mediaFile.setDirectory(rootDirectory);
+            mediaFile.setInputStream(getClass().getResourceAsStream("/test.jpg"));
+            mediaFile.setContentType("image/jpeg");
+            mfMgr.createMediaFile(testWeblog, mediaFile);
+            assertNotNull(mediaFile.getId());
+            assertNotNull(mediaFile.getId().length() > 0);
+        }
+        TestUtils.endSession(true);
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        
+        MediaFileFilter filter1 = new MediaFileFilter();
+        filter1.setSize(1000);
+        filter1.setSizeFilterType(SizeFilterType.GT);
+        List<MediaFile> searchResults1 = mfMgr.searchMediaFiles(testWeblog, filter1);
+        assertFalse(searchResults1.isEmpty());
+        assertEquals(15, searchResults1.size());
+        
+        MediaFileFilter filter2 = new MediaFileFilter();
+        filter2.setSize(1000);
+        filter2.setSizeFilterType(SizeFilterType.GT);
+        filter2.setStartIndex(5);
+        filter2.setLength(3);
+        List<MediaFile> searchResults2 = mfMgr.searchMediaFiles(testWeblog, filter2);
+        assertFalse(searchResults2.isEmpty());
+        assertEquals(3, searchResults2.size());
+        assertEquals("test_file5.jpg", searchResults2.get(0).getName());
+
+        MediaFileFilter filter3 = new MediaFileFilter();
+        filter3.setSize(1000);
+        filter3.setSizeFilterType(SizeFilterType.GT);
+        filter3.setStartIndex(13);
+        filter3.setLength(6);
+        List<MediaFile> searchResults3 = mfMgr.searchMediaFiles(testWeblog, filter3);
+        assertFalse(searchResults3.isEmpty());
+        assertEquals(2, searchResults3.size());
+        assertEquals("test_file13.jpg", searchResults3.get(0).getName());
+
+        MediaFileFilter filter4 = new MediaFileFilter();
+        filter4.setSize(1000);
+        filter4.setSizeFilterType(SizeFilterType.GT);
+        filter4.setStartIndex(14);
+        filter4.setLength(1);
+        List<MediaFile> searchResults4 = mfMgr.searchMediaFiles(testWeblog, filter4);
+        assertFalse(searchResults4.isEmpty());
+        assertEquals(1, searchResults4.size());
+        assertEquals("test_file14.jpg", searchResults4.get(0).getName());
+    }
+    
+    /**
+     * Test searching media file with paging logic.
+     */
+    public void testSearchMediaFileOrderBy() throws Exception {
+        User testUser = null;
+        Weblog testWeblog = null;
+        testUser = TestUtils.setupUser("mediaFileTestUser10");
+        testWeblog = TestUtils.setupWeblog("mediaFileTestWeblog10", testUser);
+    	
+        MediaFileManager mfMgr = WebloggerFactory.getWeblogger().getMediaFileManager();
+
+        MediaFileDirectory rootDirectory = new MediaFileDirectory(null, "root", "root d", testWeblog);
+        mfMgr.createMediaFileDirectory(rootDirectory);
+
+        TestUtils.endSession(true);
+
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        rootDirectory = mfMgr.getMediaFileDirectory(rootDirectory.getId());
+        String[] contentTypes = {"image/gif", "image/jpeg", "image/bmp"};
+        for (int i = 0; i < 3; i ++) {
+            MediaFile mediaFile = new MediaFile();
+            mediaFile.setName("test_file<index>.jpg".replace("<index>", i + ""));
+            mediaFile.setDescription("This is a test image");
+            mediaFile.setCopyrightText("test copyright text");
+            mediaFile.setSharedForGallery(true);
+            mediaFile.setLength(2000);
+            mediaFile.setDirectory(rootDirectory);
+            mediaFile.setInputStream(getClass().getResourceAsStream("/test.jpg"));
+            mediaFile.setContentType(contentTypes[i]);
+            mfMgr.createMediaFile(testWeblog, mediaFile);
+            assertNotNull(mediaFile.getId());
+            assertNotNull(mediaFile.getId().length() > 0);
+        }
+        TestUtils.endSession(true);
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        
+        MediaFileFilter filter1 = new MediaFileFilter();
+        filter1.setSize(1000);
+        filter1.setSizeFilterType(SizeFilterType.GT);
+        filter1.setOrder(MediaFileOrder.NAME);
+        List<MediaFile> searchResults1 = mfMgr.searchMediaFiles(testWeblog, filter1);
+        assertFalse(searchResults1.isEmpty());
+        assertEquals(3, searchResults1.size());
+        assertEquals("test_file0.jpg", searchResults1.get(0).getName());
+        assertEquals("test_file1.jpg", searchResults1.get(1).getName());
+        assertEquals("test_file2.jpg", searchResults1.get(2).getName());
+
+        MediaFileFilter filter2 = new MediaFileFilter();
+        filter2.setSize(1000);
+        filter2.setSizeFilterType(SizeFilterType.GT);
+        filter2.setOrder(MediaFileOrder.TYPE);
+        List<MediaFile> searchResults2 = mfMgr.searchMediaFiles(testWeblog, filter2);
+        assertFalse(searchResults2.isEmpty());
+        assertEquals(3, searchResults2.size());
+        assertEquals("test_file2.jpg", searchResults2.get(0).getName());
+        assertEquals("test_file1.jpg", searchResults2.get(1).getName());
+        assertEquals("test_file0.jpg", searchResults2.get(2).getName());
+
+        MediaFileFilter filter3 = new MediaFileFilter();
+        filter3.setSize(1000);
+        filter3.setSizeFilterType(SizeFilterType.GT);
+        filter3.setOrder(MediaFileOrder.DATE_UPLOADED);
+        List<MediaFile> searchResults3 = mfMgr.searchMediaFiles(testWeblog, filter3);
+        assertFalse(searchResults3.isEmpty());
+        assertEquals(3, searchResults3.size());
+        assertEquals("test_file0.jpg", searchResults3.get(0).getName());
+        assertEquals("test_file1.jpg", searchResults3.get(1).getName());
+        assertEquals("test_file2.jpg", searchResults3.get(2).getName());
+    }
+    
+    /**
      * Test media file update
      */
     public void testUpdateMediaFile() throws Exception {

Modified: roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties?rev=749634&r1=749633&r2=749634&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties Tue Mar  3 15:44:03 2009
@@ -947,12 +947,36 @@
 
 # ----------------------------------------------------------- Media file management
 mediaFile.add.title=Add new media file
+mediaFile.edit.title=Edit new media file
+mediaFile.search.title=Search media files
+mediaFile.delete.confirm=Delete selected media files?
+mediaFile.move.confirm=Move selected media files?
+mediaFile.view.title=View uploaded files
+mediaFile.directoryCreate.success=New directory succesfully created.
+
+
+mediaFile.includeInGallery.success = Media file(s) successfully included in gallery.
+mediaFile.delete.success = Media file(s) successfully deleted.
+mediaFile.move.success = Media file(s) successfully moved.
+
+mediaFile.update.success = Media file successfully updated.
+
+
 
 # errors from validation
 MediaFile.error.nameNull=Name is a required field
 MediaFile.error.nameSize=Name cannot be more than 255 characters
 MediaFile.error.descriptionSize=Description cannot be more than 255 characters
 MediaFile.error.duplicateName=The file name {0} is already in use, you will need to choose another
+MediaFile.error.search.empty=Please enter one or more criteria for search.
+MediaFile.error.search.noResults=No results found.
+mediaFile.error.search.dirPathEmpty=Directory path is empty.
+mediaFile.error.search.dirPathInvalid=Directory path is invalid.
+mediaFile.error.view.dirNameEmpty=Directory name is empty.
+mediaFile.error.view.dirNameInvalid=Directory name is invalid.
+mediaFile.error.noneSelectedForMove=Please select one or more files to be moved.
+mediaFile.error.noneSelectedForDelete=Please select one or more files to be deleted.
+
 
 # ----------------------------------------------------------- Member permissions
 

Modified: roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/classes/struts.xml
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/classes/struts.xml?rev=749634&r1=749633&r2=749634&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/classes/struts.xml (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/classes/struts.xml Tue Mar  3 15:44:03 2009
@@ -222,6 +222,31 @@
                 class="org.apache.roller.weblogger.ui.struts2.editor.MediaFileAdd">
             <result name="input" type="tiles">.MediaFileAdd</result>
             <result name="success" type="tiles">.MediaFileAddSuccess</result>
+            <result name="error" type="tiles">.MediaFileAdd</result>
+        </action>
+
+	<action name="mediaFileEdit!*" method="{1}"
+                class="org.apache.roller.weblogger.ui.struts2.editor.MediaFileEdit">
+            <result name="input" type="tiles">.MediaFileEdit</result>
+            <result name="success" type="tiles">.MediaFileEdit</result>
+        </action>
+
+	<action name="mediaFileView!*" method="{1}"
+                class="org.apache.roller.weblogger.ui.struts2.editor.MediaFileView">
+            <result name="success" type="tiles">.MediaFileView</result>
+            <result name="success.json" type="dispatcher">/WEB-INF/jsps/editor/MediaFileViewLight.jsp</result>
+        </action>
+
+	<action name="mediaFileHierarchicalView!*" method="{1}"
+                class="org.apache.roller.weblogger.ui.struts2.editor.MediaFileView">
+            <result name="success" type="tiles">.MediaFileHierarchicalView</result>
+        </action>
+
+	<action name="mediaFileSearch!*" method="{1}"
+                class="org.apache.roller.weblogger.ui.struts2.editor.MediaFileSearch">
+            <result name="input" type="tiles">.MediaFileSearch</result>
+            <result name="error" type="tiles">.MediaFileSearch</result>
+            <result name="success" type="tiles">.MediaFileSearch</result>
         </action>
 
 	<action name="tabular!*" method="{1}"

Modified: roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAdd.jsp
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAdd.jsp?rev=749634&r1=749633&r2=749634&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAdd.jsp (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAdd.jsp Tue Mar  3 15:44:03 2009
@@ -18,32 +18,33 @@
 <%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
 
 <p class="subtitle">
-   Add Media Files
+    <s:text name="mediaFile.add.title"  />
+
 </p>
 
 <s:form id="entry" action="mediaFileAdd!save" onsubmit="editorCleanup()" method="POST" enctype="multipart/form-data">
     <s:hidden name="weblog" />
-    
+
     <%-- ================================================================== --%>
     <%-- Title, category, dates and other metadata --%>
-    
-    <table class="entryEditTable" cellpadding="0" cellspacing="0" width="100%">   
-        
+
+    <table class="entryEditTable" cellpadding="0" cellspacing="0" width="100%">
+
         <tr>
             <td class="entryEditFormLabel">
                 <label for="title">File Location</label>
             </td>
             <td>
-                 <s:file name="uploadedFile" size="30" /><br />
+                 <s:file name="uploadedFile" size="30" onchange="this.form['bean.name'].value=this.value" /><br />
             </td>
         </tr>
-        
+
         <tr>
             <td class="entryEditFormLabel">
                 <label for="status">Name</label>
             </td>
             <td>
-                <s:textfield name="bean.name" size="50" maxlength="255" tabindex="1" />
+                <s:textfield name="bean.name" size="50" maxlength="255" />
             </td>
        </tr>
 
@@ -52,7 +53,7 @@
                 <label for="status">A short Description of file</label>
             </td>
             <td>
-                <s:textarea name="bean.description" cols="50" rows="5" tabindex="3"/>
+                <s:textarea name="bean.description" cols="50" rows="5" />
             </td>
        </tr>
 
@@ -61,7 +62,7 @@
                 <label for="status">Copyright Statement (optional)</label>
             </td>
             <td>
-                <s:textarea name="bean.copyrightText" cols="50" rows="3" tabindex="4"/>
+                <s:textarea name="bean.copyrightText" cols="50" rows="3" />
             </td>
        </tr>
 
@@ -70,7 +71,7 @@
                 <label for="status">Tags (separated by spaces)</label>
             </td>
             <td>
-                <s:textfield name="bean.tags" size="50" maxlength="255" tabindex="5" />
+                <s:textfield name="bean.tags" size="50" maxlength="255" />
             </td>
        </tr>
 
@@ -88,42 +89,42 @@
                 <label for="status">Include in Gallery?</label>
             </td>
 			<td>
-                <input type="checkbox" name="checkbox" checked />
+                <s:checkbox name="bean.sharedForGallery" />
             </td>
        </tr>
-        
-       
-        
-        
-       
-        
+
+
+
+
+
+
     </table>
-    
-    
+
+
     <%-- ================================================================== --%>
     <%-- Weblog edit or preview --%>
-    
-   
-    
-   
-    
-    
+
+
+
+
+
+
     <%-- ================================================================== --%>
     <%-- plugin chooser --%>
-    
- 
 
-    
+
+
+
     <%-- ================================================================== --%>
     <%-- advanced settings  --%>
-  
-    
+
+
     <%-- ================================================================== --%>
     <%-- the button box --%>
-    
+
     <br>
     <div class="control">
        <input type="submit" value="Upload" name="upload" />
     </div>
-    
+
 </s:form>

Modified: roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp?rev=749634&r1=749633&r2=749634&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp Tue Mar  3 15:44:03 2009
@@ -33,13 +33,12 @@
 <s:url id="mediaFileURL" value="/roller-ui/rendering/media-resources/%{bean.id}">
 </s:url>
 
-<s:a href="%{mediaFileURL}">
 <s:if test="contentTypeImage">
 <div style="margin-bottom:10px;"><img border="0" src='<s:property value="%{mediaFileURL}" />' width="150px" alt="image"/></div>
 </s:if>
-<s:else>
+
+<s:a href="%{mediaFileURL}">
 <s:property value="%{mediaFileURL}" />
-</s:else>
 </s:a>
 
 <div style="margin-top:20px;text-decoration:underline">
@@ -56,31 +55,31 @@
 
 
 
-       
-        
-   
-    
-    
+
+
+
+
+
     <%-- ================================================================== --%>
     <%-- Weblog edit or preview --%>
-    
-   
-    
-   
-    
-    
+
+
+
+
+
+
     <%-- ================================================================== --%>
     <%-- plugin chooser --%>
-    
- 
 
-    
+
+
+
     <%-- ================================================================== --%>
     <%-- advanced settings  --%>
-  
-    
+
+
     <%-- ================================================================== --%>
     <%-- the button box --%>
-   
+
 
    </s:form>

Added: roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileEdit.jsp
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileEdit.jsp?rev=749634&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileEdit.jsp (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileEdit.jsp Tue Mar  3 15:44:03 2009
@@ -0,0 +1,121 @@
+<%--
+  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.
+--%>
+<%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
+
+<p class="subtitle">
+    <s:text name="mediaFile.edit.title"  />
+</p>
+
+<s:form id="entry" action="mediaFileEdit!save" onsubmit="editorCleanup()" method="POST">
+    <s:hidden name="weblog" />
+    <s:hidden name="mediaFileId" />
+
+    <%-- ================================================================== --%>
+    <%-- Title, category, dates and other metadata --%>
+
+    <table class="entryEditTable" cellpadding="0" cellspacing="0" width="100%">
+
+        <tr>
+            <td class="entryEditFormLabel">
+                <label for="status">Name</label>
+            </td>
+            <td>
+                <s:textfield name="bean.name" size="50" maxlength="255" tabindex="1" />
+            </td>
+       </tr>
+
+	    <tr>
+            <td class="entryEditFormLabel">
+                <label for="status">A short Description of file</label>
+            </td>
+            <td>
+                <s:textarea name="bean.description" cols="50" rows="5" tabindex="3"/>
+            </td>
+       </tr>
+
+	    <tr>
+            <td class="entryEditFormLabel">
+                <label for="status">Copyright Statement (optional)</label>
+            </td>
+            <td>
+                <s:textarea name="bean.copyrightText" cols="50" rows="3" tabindex="4"/>
+            </td>
+       </tr>
+
+	   <tr>
+            <td class="entryEditFormLabel">
+                <label for="status">Tags (separated by spaces)</label>
+            </td>
+            <td>
+                <s:textfield name="bean.tags" size="50" maxlength="255" tabindex="5" />
+            </td>
+       </tr>
+
+	    <tr>
+            <td class="entryEditFormLabel">
+                <label for="status">Place file under</label>
+            </td>
+            <td>
+                <s:select name="bean.directoryId" list="allDirectories" listKey="id" listValue="path" />
+            </td>
+       </tr>
+
+	   <tr>
+            <td class="entryEditFormLabel">
+                <label for="status">Include in Gallery?</label>
+            </td>
+			<td>
+                <s:checkbox name="bean.sharedForGallery" />
+            </td>
+       </tr>
+
+
+
+
+
+
+    </table>
+
+
+    <%-- ================================================================== --%>
+    <%-- Weblog edit or preview --%>
+
+
+
+
+
+
+    <%-- ================================================================== --%>
+    <%-- plugin chooser --%>
+
+
+
+
+    <%-- ================================================================== --%>
+    <%-- advanced settings  --%>
+
+
+    <%-- ================================================================== --%>
+    <%-- the button box --%>
+
+    <br>
+    <div class="control">
+       <input type="submit" value="Submit" name="submit" />
+    </div>
+
+</s:form>

Added: roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileHierarchicalView.jsp
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileHierarchicalView.jsp?rev=749634&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileHierarchicalView.jsp (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileHierarchicalView.jsp Tue Mar  3 15:44:03 2009
@@ -0,0 +1,214 @@
+<%--
+  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.
+--%>
+<%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
+
+<style type = "text/css">
+  .indented {
+    margin-left:5%;
+    /*padding: 5% 5% 5% 5%;*/
+    color: #000;
+    width : 95%;}
+</style>
+
+<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.6.0/build/fonts/fonts-min.css" />
+<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.6.0/build/treeview/assets/skins/sam/treeview.css" />
+<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
+<script type="text/javascript" src="http://yui.yahooapis.com/2.6.0/build/treeview/treeview-min.js"></script>
+
+
+<!--begin custom header content for this example-->
+<!--bring in the folder-style CSS for the TreeView Control-->
+<link rel="stylesheet" type="text/css" href="http://developer.yahoo.com/yui/examples/treeview/assets/css/folders/tree.css">
+
+<!-- Some custom style for the expand/contract section-->
+<style>
+#expandcontractdiv {border:1px dotted #dedede; background-color:#EBE4F2; margin:0 0 .5em 0; padding:0.4em;}
+#treeDiv1 { background: #fff; padding:1em; margin-top:1em; }
+</style>
+
+<script src="http://yui.yahooapis.com/2.2.2/build/yahoo/yahoo-min.js" type="text/javascript"></script>
+<script src="http://yui.yahooapis.com/2.2.2/build/connection/connection-min.js" type="text/javascript"></script>
+
+<p class="subtitle">
+   View Uploaded Files
+</p>
+
+<s:url id="mediaFileTabularViewURL" action="mediaFileView">
+    <s:param name="weblog" value="%{actionWeblog.handle}" />
+</s:url>
+
+<p><s:a href="%{mediaFileTabularViewURL}">Tabular</s:a> | <span style="font-weight:bold">Hierarchical</span></p>
+
+<div id="treeDiv1"></div>
+
+<script type="text/javascript">
+
+hierarchicalViewImpl = function() {
+
+    var tree, currentIconMode;
+
+    function changeIconMode() {
+        var newVal = parseInt(this.value);
+        if (newVal != currentIconMode) {
+            currentIconMode = newVal;
+        }
+        buildTree();
+    }
+
+        function loadNodeData(node, fnLoadComplete)  {
+
+            //We'll load node data based on what we get back when we
+            //use Connection Manager topass the text label of the
+            //expanding node to the Yahoo!
+            //Search "related suggestions" API.  Here, we're at the
+            //first part of the request -- we'll make the request to the
+            //server.  In our success handler, we'll build our new children
+            //and then return fnLoadComplete back to the tree.
+
+            //Get the node's label and urlencode it; this is the word/s
+            //on which we'll search for related words:
+            //alert(node.label);
+            //alert(node.data.key);
+            var nodeLabel = encodeURI(node.label);
+            var nodeKey = node.data.key;
+
+            //prepare URL for XHR request:
+            var sUrl = 'mediaFileView!fetchDirectoryContentLight.rol?selectedDirectoryId=media-directory-id&weblog=<s:property value="actionWeblog.handle" />'.replace("media-directory-id", nodeKey);
+
+
+
+
+            //prepare our callback object
+            var callback = {
+
+                //if our XHR call is successful, we want to make use
+                //of the returned data and create child nodes.
+                success: function(oResponse) {
+                    YAHOO.log("XHR transaction was successful.", "info", "example");
+                    //YAHOO.log(oResponse.responseText);
+                    var oResults = eval("(" + oResponse.responseText + ")");
+                    if((oResults.Result) && (oResults.Result.length)) {
+                        //Result is an array if more than one result, string otherwise
+                        if(YAHOO.lang.isArray(oResults.Result)) {
+                            for (var i=0, j=oResults.Result.length; i<j; i++) {
+                                var tempNode = new YAHOO.widget.TextNode(oResults.Result[i], node, false);
+                                if (oResults.Result[i].type == 'file') {
+                                    tempNode.isLeaf = true;
+                                }
+                            }
+                        } else {
+                            //there is only one result; comes as string:
+                            var tempNode = new YAHOO.widget.TextNode(oResults.Result, node, false)
+                        }
+                    }
+
+                    //When we're done creating child nodes, we execute the node's
+                    //loadComplete callback method which comes in via the argument
+                    //in the response object (we could also access it at node.loadComplete,
+                    //if necessary):
+                    oResponse.argument.fnLoadComplete();
+                },
+
+                //if our XHR call is not successful, we want to
+                //fire the TreeView callback and let the Tree
+                //proceed with its business.
+                failure: function(oResponse) {
+                    YAHOO.log("Failed to process XHR transaction.", "info", "example");
+                    oResponse.argument.fnLoadComplete();
+                },
+
+                //our handlers for the XHR response will need the same
+                //argument information we got to loadNodeData, so
+                //we'll pass those along:
+                argument: {
+                    "node": node,
+                    "fnLoadComplete": fnLoadComplete
+                },
+
+                //timeout -- if more than 7 seconds go by, we'll abort
+                //the transaction and assume there are no children:
+                timeout: 7000
+            };
+
+            //With our callback object ready, it's now time to
+            //make our XHR call using Connection Manager's
+            //asyncRequest method:
+            YAHOO.util.Connect.asyncRequest('POST', sUrl, callback);
+        }
+
+        function buildTree() {
+           //create a new tree:
+           tree = new YAHOO.widget.TreeView("treeDiv1");
+
+           //turn dynamic loading on for entire tree:
+           tree.setDynamicLoad(loadNodeData, currentIconMode);
+
+           //get root node for tree:
+           var root = tree.getRoot();
+
+           //add child nodes for tree; our top level nodes are
+           var aDirectories = [
+    <s:iterator id="directory" value="childDirectories" status="dirStatus">
+{label:"<s:property value="#directory.name" />",key:"<s:property value="#directory.id" />"}<s:if test="!#dirStatus.last">,</s:if>
+    </s:iterator>
+           ];
+
+           for (var i=0, j=aDirectories.length; i<j; i++) {
+                var tempNode = new YAHOO.widget.TextNode(aDirectories[i], root, false);
+           }
+
+           var aFiles = [
+    <s:iterator id="mediaFile" value="childFiles" status="fileStatus">
+{label:"<s:property value="#mediaFile.name" />",key:"<s:property value="#mediaFile.id" />"}<s:if test="!#fileStatus.last">,</s:if>
+    </s:iterator>
+           ];
+
+           for (var i=0, j=aFiles.length; i<j; i++) {
+                var tempNode = new YAHOO.widget.TextNode(aFiles[i], root, false);
+           // Use the isLeaf property to force the leaf node presentation for a given node.
+           // This disables dynamic loading for the node.
+                tempNode.isLeaf = true;
+           }
+
+           //render tree with these toplevel nodes; all descendants of these nodes
+           //will be generated as needed by the dynamic loader.
+           tree.draw();
+        }
+
+
+    return {
+        init: function() {
+            YAHOO.util.Event.on(["mode0", "mode1"], "click", changeIconMode);
+            var el = document.getElementById("mode1");
+            if (el && el.checked) {
+                currentIconMode = parseInt(el.value);
+            } else {
+                currentIconMode = 0;
+            }
+
+            buildTree();
+        }
+
+    }
+} ();
+
+//once the DOM has loaded, we can go ahead and set up our tree:
+YAHOO.util.Event.onDOMReady(hierarchicalViewImpl.init, hierarchicalViewImpl,true)
+
+</script>
+

Added: roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileSearch.jsp
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileSearch.jsp?rev=749634&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileSearch.jsp (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileSearch.jsp Tue Mar  3 15:44:03 2009
@@ -0,0 +1,195 @@
+<%--
+  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.
+--%>
+<%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
+<%-- JavaScript for media file search page--%>
+<script type="text/javascript">
+<!--
+
+function onDelete(id)
+{
+    document.mediaFileSearchForm.mediaFileId.value=id;
+    document.mediaFileSearchForm.action='<s:url action="mediaFileSearch!delete" />';
+    document.mediaFileSearchForm.submit();
+}
+
+function onIncludeInGallery(id)
+{
+    document.mediaFileSearchForm.mediaFileId.value=id;
+    document.mediaFileSearchForm.action='<s:url action="mediaFileSearch!includeInGallery" />';
+    document.mediaFileSearchForm.submit();
+}
+
+
+function onDeleteSelected()
+{
+    if ( confirm("<s:text name='mediaFile.delete.confirm' />") ) {
+        document.mediaFileSearchForm.action='<s:url action="mediaFileSearch!deleteSelected" />';
+        document.mediaFileSearchForm.submit();
+    }
+}
+
+function onMoveSelected()
+{
+    if ( confirm("<s:text name='mediaFile.move.confirm' />") ) {
+        document.mediaFileSearchForm.action='<s:url action="mediaFileSearch!moveSelected" />';
+        document.mediaFileSearchForm.submit();
+    }
+}
+function onCreateDirectory()
+{
+    document.mediaFileSearchForm.action='<s:url action="mediaFileSearch!createDirByPath" />';
+    document.mediaFileSearchForm.submit();
+}
+function onNext()
+{
+    document.mediaFileSearchForm["bean.pageNum"].value = parseInt(document.mediaFileSearchForm["bean.pageNum"].value) +  1;
+    document.mediaFileSearchForm.submit();
+}
+function onPrevious()
+{
+    document.mediaFileSearchForm["bean.pageNum"].value = parseInt(document.mediaFileSearchForm["bean.pageNum"].value) -  1;
+    document.mediaFileSearchForm.submit();
+}
+-->
+</script>
+
+<p class="subtitle">
+   Search uploaded files
+</p>
+
+	<s:form id="mediaFileSearchForm" name="mediaFileSearchForm" action="mediaFileSearch!search" onsubmit="editorCleanup()">
+    <s:hidden name="weblog" />
+    <input type="hidden" name="mediaFileId" value="" />
+    <table class="mediaFileSearchTable" cellpadding="0" cellspacing="0" width="100%">
+        <tr>
+            <td>
+                <label for="name">Name</label>
+            </td>
+            <td>
+                <s:textfield name="bean.name" size="40" maxlength="255" />
+            </td>
+            <td>
+                <label for="type">File Type</label>
+            </td>
+            <td>
+                <s:select name="bean.type" list="fileTypes" />
+            </td>
+        </tr>
+        <tr>
+            <td>
+                <label for="size">Size</label>
+            </td>
+            <td>
+                <s:select name="bean.sizeFilterType" list="sizeFilterTypes" listKey="key" listValue="value" />
+                <s:textfield name="bean.size" size="10" maxlength="15" />
+                <s:select name="bean.sizeUnit" list="sizeUnits" listKey="key" listValue="value" />
+            </td>
+            <td>
+                <label for="tags">Tags</label>
+            </td>
+            <td>
+                <s:textfield name="bean.tags" size="20	" maxlength="50" />
+            </td>
+        </tr>
+        <tr>
+            <td>
+                <input type="submit" name="search" value="Search" />
+            </td>
+            <td>&nbsp;</td>
+            <td>&nbsp;</td>
+            <td>&nbsp;</td>
+        </tr>
+     </table>
+
+ <div class="control">
+    <span style="padding-left:20px">Sort by:</span>
+    <s:select name="bean.sortOption" list="sortOptions" listKey="key" listValue="value" />
+	<s:if test="!pager.justOnePage">
+	<span style="padding-left:300px">
+	<s:if test="pager.hasPrevious()"><a href="#" onclick="onPrevious()">&lt;Previous</a></s:if>
+	<s:if test="pager.hasNext()"><a href="#" onclick="onNext()">Next&gt;</a></s:if>
+	<span>
+	</s:if>
+    </div>
+
+    <s:hidden name="bean.pageNum" />
+
+    <%-- ================================================================== --%>
+    <%-- Title, category, dates and other metadata --%>
+
+    <ul style="margin-top:10px">
+
+    <s:iterator id="mediaFile" value="pager.items">
+    <li class="mediaFileSearchResult">
+	<img border="0" src='<s:url value="/roller-ui/rendering/media-resources/%{#mediaFile.id}" />' width="120px" alt="mediaFolder.png"/><br/>
+	<input type="checkbox" name="selectedMediaFiles" value="<s:property value="#mediaFile.id"/>" style="float:left;clear:left"/>
+    <label><s:property value="#mediaFile.name" /></label>
+    <label><s:property value="#mediaFile.path" /></label>
+	<a href='<s:url action="mediaFileEdit"><s:param name="mediaFileId" value="%{#mediaFile.id}" /><s:param name="weblog" value="%{actionWeblog.handle}" /></s:url>'>Edit</a>
+	<a href="#" onclick="onDelete('<s:property value="#mediaFile.id" />')">Delete</a>
+	<a href="#" onclick="onIncludeInGallery('<s:property value="#mediaFile.id" />')">Include in gallery</a>
+    </li>
+    </s:iterator>
+    </ul>
+
+
+<br/>
+<div style="width: 100%; clear:both; padding-top:2em">
+<label>New Directory:</label>
+<input type="text" name="newDirectoryPath" size="30" />
+<input type="button" value="Create" onclick="onCreateDirectory()" />
+</div>
+
+</div>
+
+
+
+
+
+    <%-- ================================================================== --%>
+    <%-- Weblog edit or preview --%>
+
+
+
+
+
+
+    <%-- ================================================================== --%>
+    <%-- plugin chooser --%>
+
+
+
+
+    <%-- ================================================================== --%>
+    <%-- advanced settings  --%>
+
+
+    <%-- ================================================================== --%>
+    <%-- the button box --%>
+
+	<br/>
+	<div class="control">
+     <input type="button" style="padding-left:20px" value="Delete Selected" onclick="onDeleteSelected()" />
+     <input type="button" style="padding-left:20px" value="Move Selected" onclick="onMoveSelected()" />
+	 <span style="padding-left:20px">
+         <s:select name="selectedDirectory" list="allDirectories" listKey="id" listValue="path" />
+	 </span>
+    </div>
+	</s:form>
+
+

Modified: roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileSidebar.jsp
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileSidebar.jsp?rev=749634&r1=749633&r2=749634&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileSidebar.jsp (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileSidebar.jsp Tue Mar  3 15:44:03 2009
@@ -20,32 +20,27 @@
 <div class="sidebarFade">
     <div class="menu-tr">
         <div class="menu-tl">
-
             <div class="sidebarInner">
-
                 <b>Actions:</b>
-                <hr size="1" noshade="noshade" />
-                <s:url id="mediaFileAddURL" action="mediaFileAdd">
-                    <s:param name="weblog" value="%{actionWeblog.handle}" />
-                </s:url>
-                <s:a href="%{mediaFileAddURL}">Add Media file</s:a>
-
-                <hr size="1" noshade="noshade" />
-
-                <s:url id="viewUploads" action="tabular">
-                    <s:param name="weblog" value="%{actionWeblog.handle}" />
-                </s:url>
-                <s:a href="${viewUploads}">View Uploaded files</s:a>
-
-                <hr size="1" noshade="noshade" />
-                <a href="#">Search uploaded files</a>
-
-                <hr size="1" noshade="noshade" />
-
+                    <s:url id="mediaFileAddURL" action="mediaFileAdd">
+                        <s:param name="weblog" value="%{actionWeblog.handle}" />
+                    </s:url>
+                    <s:url id="mediaFileSearchURL" action="mediaFileSearch">
+                        <s:param name="weblog" value="%{actionWeblog.handle}" />
+                    </s:url>
+                    <s:url id="mediaFileViewURL" action="mediaFileView">
+                        <s:param name="weblog" value="%{actionWeblog.handle}" />
+                    </s:url>
+                    <hr size="1" noshade="noshade" />
+                    <s:a href="%{mediaFileAddURL}">Add Media file</s:a>
+                    <hr size="1" noshade="noshade" />
+                    <s:a href="%{mediaFileViewURL}">View Uploaded files</s:a>
+                    <hr size="1" noshade="noshade" />
+                    <s:a href="%{mediaFileSearchURL}">Search uploaded files</s:a>
+                    <hr size="1" noshade="noshade" />
                 <br />
                 <br />
             </div>
-
         </div>
     </div>
 </div>

Added: roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp?rev=749634&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp Tue Mar  3 15:44:03 2009
@@ -0,0 +1,168 @@
+<%--
+  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.
+--%>
+<%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
+
+<script type="text/javascript">
+<!--
+function onDelete(id)
+{
+    document.mediaFileViewForm.mediaFileId.value=id;
+    document.mediaFileViewForm.action='<s:url action="mediaFileView!delete" />';
+    document.mediaFileViewForm.submit();
+}
+
+function onIncludeInGallery(id)
+{
+    document.mediaFileViewForm.mediaFileId.value=id;
+    document.mediaFileViewForm.action='<s:url action="mediaFileView!includeInGallery" />';
+    document.mediaFileViewForm.submit();
+}
+
+function onSelectDirectory(id) {
+    document.mediaFileViewForm.directoryId.value = id;
+    document.mediaFileViewForm.submit();
+}
+
+function onCreateDirectory()
+{
+    document.mediaFileViewForm.action='<s:url action="mediaFileView!createNewDirectory" />';
+    document.mediaFileViewForm.submit();
+}
+
+function onDeleteSelected()
+{
+    if ( confirm("<s:text name='mediaFile.delete.confirm' />") ) {
+        document.mediaFileViewForm.action='<s:url action="mediaFileView!deleteSelected" />';
+        document.mediaFileViewForm.submit();
+    }
+}
+
+function onMoveSelected()
+{
+    if ( confirm("<s:text name='mediaFile.move.confirm' />") ) {
+        document.mediaFileViewForm.action='<s:url action="mediaFileView!moveSelected" />';
+        document.mediaFileViewForm.submit();
+    }
+}
+-->
+</script>
+
+<p class="subtitle">
+   View Uploaded Files
+</p>
+<p class="subtitle">
+Path: /
+<s:iterator id="directory" value="currentDirectoryHierarchy">
+    <s:url id="getDirectoryByPathUrl" action="mediaFileView">
+        <s:param name="directoryPath" value="#directory.key" />
+        <s:param name="weblog" value="%{actionWeblog.handle}" />
+    </s:url>
+    <s:a href="%{getDirectoryByPathUrl}"><s:property value="#directory.value" /></s:a> /
+</s:iterator>
+</p>
+
+<s:form id="mediaFileViewForm" name="mediaFileViewForm" action="mediaFileView" onsubmit="editorCleanup()">
+<s:url id="mediaFileHierarchicalViewURL" action="mediaFileHierarchicalView">
+    <s:param name="weblog" value="%{actionWeblog.handle}" />
+</s:url>
+<p><span style="font-weight:bold">Tabular</span> | <s:a href="%{mediaFileHierarchicalViewURL}">Hierarchical</s:a></p>
+ <div class="control">
+    <span style="padding-left:20px">Sort by:</span>
+    <s:select name="sortBy" list="sortOptions" listKey="key" listValue="value" onchange="document.mediaFileViewForm.submit();" />
+	</span>
+ </div>
+
+    <s:hidden name="weblog" />
+    <s:hidden name="directoryId" />
+    <input type="hidden" name="mediaFileId" value="" />
+
+    <%-- ================================================================== --%>
+    <%-- Title, category, dates and other metadata --%>
+
+    <div style="margin-top:10px">
+	<ul>
+
+    <s:iterator id="directory" value="childDirectories">
+	<li>
+	<img border="0" src='<s:url value="/images/folder.png"/>' style="cursor:pointer;width:120px;height:100px" alt="mediaFolder.png" onclick="onSelectDirectory('<s:property value="#directory.id"/>')"/>
+    <label><s:property value="#directory.name" /></label>
+	</li>
+    </s:iterator>
+
+    <s:iterator id="mediaFile" value="childFiles">
+	<li>
+	<s:if test="#mediaFile.imageFile">
+    <s:url id="mediaFileURL" value="/roller-ui/rendering/media-resources/%{#mediaFile.id}"></s:url>
+	</s:if>
+	<s:else>
+    <s:url id="mediaFileURL" value="/images/page.png"></s:url>
+	</s:else>
+	<img border="0" src='<s:property value="%{mediaFileURL}" />' width="120px" />
+    <label><s:property value="#mediaFile.name" /></label>
+    <input type="checkbox" name="selectedMediaFiles" value="<s:property value="#mediaFile.id"/>" style="float:left;clear:left"/>
+    <a href='<s:url action="mediaFileEdit"><s:param name="mediaFileId" value="%{#mediaFile.id}" /><s:param name="weblog" value="%{actionWeblog.handle}" /></s:url>'>Edit</a>
+	<a href="#" onclick="onDelete('<s:property value="#mediaFile.id" />')">Delete</a>
+	<a href="#" onclick="onIncludeInGallery('<s:property value="#mediaFile.id" />')">Include in gallery</a>
+	</li>
+    </s:iterator>
+
+</ul>
+</div>
+
+<div style="margin-left:320px">
+New Directory:
+<input type="text" name="newDirectoryName" size="30" />
+<input type="button" value="Create" onclick="onCreateDirectory()" />
+</div>
+
+
+
+
+    <%-- ================================================================== --%>
+    <%-- Weblog edit or preview --%>
+
+
+
+
+
+
+    <%-- ================================================================== --%>
+    <%-- plugin chooser --%>
+
+
+
+
+    <%-- ================================================================== --%>
+    <%-- advanced settings  --%>
+
+
+    <%-- ================================================================== --%>
+    <%-- the button box --%>
+
+	<br/>
+	<div class="control">
+     <input type="button" style="padding-left:20px" value="Delete Selected" onclick="onDeleteSelected()" />
+     <input type="button" style="padding-left:20px" value="Move Selected" onclick="onMoveSelected()" />
+	 <span style="padding-left:20px">
+         <s:select name="selectedDirectory" list="allDirectories" listKey="id" listValue="path" />
+	 </span>
+    </div>
+
+	</s:form>
+
+

Added: roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileViewLight.jsp
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileViewLight.jsp?rev=749634&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileViewLight.jsp (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileViewLight.jsp Tue Mar  3 15:44:03 2009
@@ -0,0 +1,12 @@
+<%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
+{
+"Result":
+[
+    <s:iterator id="directory" value="childDirectories" status="dirStatus">
+{"label":"<s:property value="#directory.name" />","key":"<s:property value="#directory.id" />","type":"dir"}<s:if test="(!#dirStatus.last) || (#dirStatus.last && childFiles.size() > 0)">,</s:if>
+    </s:iterator>
+    <s:iterator id="mediaFile" value="childFiles" status="fileStatus">
+{"label":"<s:property value="#mediaFile.name" />","key":"<s:property value="#mediaFile.id" />","type":"file"}<s:if test="!#fileStatus.last">,</s:if>
+    </s:iterator>
+]
+}

Modified: roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/tiles.xml
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/tiles.xml?rev=749634&r1=749633&r2=749634&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/tiles.xml (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/tiles.xml Tue Mar  3 15:44:03 2009
@@ -209,14 +209,42 @@
         <put-attribute name="styles" value="/WEB-INF/jsps/tiles/css-sidebar.jsp" />
     </definition>
 
-	<definition name=".MediaFileAddSuccess" extends=".tiles-tabbedpage" >
+    <definition name=".MediaFileEdit" extends=".tiles-tabbedpage" >
+        <put-attribute name="head" value="/WEB-INF/jsps/tiles/head-ajax.jsp" />
+        <put-attribute name="content" value="/WEB-INF/jsps/editor/MediaFileEdit.jsp" />
+        <put-attribute name="sidebar" value="/WEB-INF/jsps/editor/MediaFileSidebar.jsp" />
+        <put-attribute name="styles" value="/WEB-INF/jsps/tiles/css-sidebar.jsp" />
+    </definition>
+
+    <definition name=".MediaFileView" extends=".tiles-tabbedpage" >
+        <put-attribute name="head" value="/WEB-INF/jsps/tiles/head-ajax.jsp" />
+        <put-attribute name="content" value="/WEB-INF/jsps/editor/MediaFileView.jsp" />
+        <put-attribute name="sidebar" value="/WEB-INF/jsps/editor/MediaFileSidebar.jsp" />
+        <put-attribute name="styles" value="/WEB-INF/jsps/tiles/css-sidebar.jsp" />
+    </definition>
+
+    <definition name=".MediaFileHierarchicalView" extends=".tiles-tabbedpage" >
+        <put-attribute name="head" value="/WEB-INF/jsps/tiles/head-ajax.jsp" />
+        <put-attribute name="content" value="/WEB-INF/jsps/editor/MediaFileHierarchicalView.jsp" />
+        <put-attribute name="sidebar" value="/WEB-INF/jsps/editor/MediaFileSidebar.jsp" />
+        <put-attribute name="styles" value="/WEB-INF/jsps/tiles/css-sidebar.jsp" />
+    </definition>
+
+    <definition name=".MediaFileAddSuccess" extends=".tiles-tabbedpage" >
         <put-attribute name="head" value="/WEB-INF/jsps/tiles/head-ajax.jsp" />
         <put-attribute name="content" value="/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp" />
         <put-attribute name="sidebar" value="/WEB-INF/jsps/editor/MediaFileSidebar.jsp" />
         <put-attribute name="styles" value="/WEB-INF/jsps/tiles/css-sidebar.jsp" />
     </definition>
 
-	<definition name=".TabularView" extends=".tiles-tabbedpage" >
+    <definition name=".MediaFileSearch" extends=".tiles-tabbedpage" >
+        <put-attribute name="head" value="/WEB-INF/jsps/tiles/head-ajax.jsp" />
+        <put-attribute name="content" value="/WEB-INF/jsps/editor/MediaFileSearch.jsp" />
+        <put-attribute name="sidebar" value="/WEB-INF/jsps/editor/MediaFileSidebar.jsp" />
+        <put-attribute name="styles" value="/WEB-INF/jsps/tiles/css-sidebar.jsp" />
+    </definition>
+
+    <definition name=".TabularView" extends=".tiles-tabbedpage" >
         <put-attribute name="head" value="/WEB-INF/jsps/tiles/head-ajax.jsp" />
         <put-attribute name="content" value="/WEB-INF/jsps/editor/TabularView.jsp" />
         <put-attribute name="sidebar" value="/WEB-INF/jsps/editor/MediaFileSidebar.jsp" />

Modified: roller/branches/roller_mediablogging/apps/weblogger/web/roller-ui/styles/roller.css
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/roller-ui/styles/roller.css?rev=749634&r1=749633&r2=749634&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/roller-ui/styles/roller.css (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/roller-ui/styles/roller.css Tue Mar  3 15:44:03 2009
@@ -672,6 +672,12 @@
     font-weight: bold;
 }
 
+/* media file pages */
+.mediaFileSearchResult {
+   float: left;
+   margin: 10px 10px 10px 10px;
+}
+
 /* weblog entry form page */
 
 span.entryEditSidebarLink {



Mime
View raw message