roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r739576 [2/2] - in /roller/branches/roller_mediablogging/apps/weblogger: nbproject/ src/java/META-INF/ src/java/org/apache/roller/weblogger/business/ src/java/org/apache/roller/weblogger/business/jpa/ src/java/org/apache/roller/weblogger/po...
Date Sat, 31 Jan 2009 16:49:52 GMT
Added: 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=739576&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBean.java (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBean.java Sat Jan 31 16:49:51 2009
@@ -0,0 +1,134 @@
+/*
+ * 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.HashSet;
+import java.util.Set;
+
+import org.apache.commons.lang.StringUtils;
+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.MediaFileTag;
+
+
+/**
+ * Bean for managing media file.
+ */
+public class MediaFileBean {
+    
+    String id;
+	String name;
+    String description;
+    String copyrightText;
+    String tags;
+    String directoryId;
+    boolean isSharedForGallery;
+
+    public void copyTo(MediaFile dataHolder) throws WebloggerException {
+    	dataHolder.setName(this.name);
+    	dataHolder.setDescription(this.description);
+    	dataHolder.setCopyrightText(this.copyrightText);
+
+    	Set<MediaFileTag> tagsSet = new HashSet<MediaFileTag>();  
+    	for (String tag: this.tags.split(" ")) {
+    		tagsSet.add(new MediaFileTag(tag, dataHolder));
+    	}
+    	dataHolder.setTags(tagsSet);
+    	dataHolder.setSharedForGallery(this.isSharedForGallery);
+    }
+    
+    
+    public void copyFrom(MediaFile dataHolder) {
+    }
+
+
+	public String getName() {
+		return name;
+	}
+
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+
+	public String getDescription() {
+		return description;
+	}
+
+
+	public void setDescription(String description) {
+		this.description = description;
+	}
+
+
+	public String getCopyrightText() {
+		return copyrightText;
+	}
+
+
+	public void setCopyrightText(String copyrightText) {
+		this.copyrightText = copyrightText;
+	}
+
+
+	public String getTags() {
+		return tags;
+	}
+
+
+	public void setTags(String tags) {
+		this.tags = tags;
+	}
+
+
+	public String getDirectoryId() {
+		return directoryId;
+	}
+
+
+	public void setDirectoryId(String directoryId) {
+		this.directoryId = directoryId;
+	}
+
+
+	public boolean isSharedForGallery() {
+		return isSharedForGallery;
+	}
+
+
+	public void setSharedForGallery(boolean isSharedForGallery) {
+		this.isSharedForGallery = isSharedForGallery;
+	}
+
+
+	public String getId() {
+		return id;
+	}
+
+
+	public void setId(String id) {
+		this.id = id;
+	}
+	
+    
+}

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/editor-menu.xml
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/editor-menu.xml?rev=739576&r1=739575&r2=739576&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/editor-menu.xml (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/editor-menu.xml Sat Jan 31 16:49:51 2009
@@ -53,11 +53,17 @@
                    weblogPerms="post"
                    subactions="bookmarkAdd,bookmarkEdit,folderAdd,folderEdit,bookmarksImport" />
         
-        <menu-item action="resources"  
-                   name="tabbedmenu.website.files" 
+        <menu-item action="resources"
+                   name="tabbedmenu.website.files"
                    globalPerms="login"
                    perms="post"/>
-        
+
+        <menu-item action="mediaFileAdd"
+                   name="tabbedmenu.weblog.mediaFileAdd"
+                   globalPerms="login"
+                   perms="post"
+                   subactions="tabular" />
+
         <menu-item action="referrers"     
                    name="tabbedmenu.weblog.referers" 
                    globalPerms="login"

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/sql/400-to-410-migration.vm
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/sql/400-to-410-migration.vm?rev=739576&r1=739575&r2=739576&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/sql/400-to-410-migration.vm (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/sql/400-to-410-migration.vm Sat Jan 31 16:49:51 2009
@@ -67,3 +67,46 @@
 create index ua_username_idx  on roller_userattribute( username$!db.INDEXSIZE );
 create index ua_attrname_idx  on roller_userattribute( attrname$!db.INDEXSIZE );
 create index ua_attrvalue_idx on roller_userattribute( attrvalue$!db.INDEXSIZE );
+
+create table media_file (
+    id              varchar(48) not null primary key,
+    name            varchar(255) not null,
+    description     varchar(255),
+    content_type    varchar(50)  not null,
+    copyright_text  varchar(1023),
+    directory_id    varchar(48),
+    size_in_bytes   integer,
+    date_uploaded   $db.TIMESTAMP_SQL_TYPE not null,
+    last_updated    $db.TIMESTAMP_SQL_TYPE,
+    is_public       $db.BOOLEAN_SQL_TYPE_FALSE not null
+);
+
+create table media_file_tag (
+    id              varchar(48) not null primary key,
+    media_file_id   varchar(48) not null,
+    name            varchar(30) not null
+);
+
+create table media_file_directory (
+    id               varchar(48) not null primary key,
+    name             varchar(255) not null,
+    description      varchar(255),
+    websiteid        varchar(48) not null,
+    parentid         varchar(48),
+    path             varchar(255)
+);
+
+-- media files
+alter table media_file add constraint media_file_directory_id_fk
+    foreign key (directory_id) references media_file_directory(id) $!db.ADDL_FK_PARAMS ;
+
+alter table media_file_tag add constraint media_file_id_tag_fk
+    foreign key (media_file_id) references media_file(id) $!db.ADDL_FK_PARAMS ;
+
+alter table media_file_directory add constraint mf_websiteid_fk
+    foreign key ( websiteid ) references website( id ) $!db.ADDL_FK_PARAMS ;
+
+alter table media_file_directory add constraint mf_parentid_fk
+    foreign key ( parentid ) references media_file_directory( id )  $!db.ADDL_FK_PARAMS ;
+
+

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/sql/createdb.vm
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/sql/createdb.vm?rev=739576&r1=739575&r2=739576&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/sql/createdb.vm (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/sql/createdb.vm Sat Jan 31 16:49:51 2009
@@ -506,6 +506,33 @@
 insert into rag_planet (id, handle, title) values ('zzz_default_planet_zzz', 'default', 'Default Planet');
 insert into rag_group (id, planet_id, handle, title) values ('zzz_all_group_zzz', 'zzz_default_planet_zzz', 'all', 'Default Group');
 
+create table media_file (
+    id              varchar(48) not null primary key,
+    name            varchar(255) not null,
+    description     varchar(255),
+    content_type    varchar(50)  not null,
+    copyright_text  varchar(1023),
+    directory_id    varchar(48), 
+    size_in_bytes   integer,
+    date_uploaded   $db.TIMESTAMP_SQL_TYPE not null,
+    last_updated    $db.TIMESTAMP_SQL_TYPE,
+    is_public       $db.BOOLEAN_SQL_TYPE_FALSE not null
+);
+
+create table media_file_tag (
+    id              varchar(48) not null primary key,
+    media_file_id   varchar(48) not null,
+    name            varchar(30) not null
+);
+
+create table media_file_directory (
+    id               varchar(48) not null primary key,
+    name             varchar(255) not null,
+    description      varchar(255),
+    websiteid        varchar(48) not null,
+    parentid         varchar(48),
+    path             varchar(255) 
+);
 
 -- *****************************************************
 -- Now add the foreign key relationships
@@ -551,6 +578,19 @@
 alter table bookmark add constraint bm_folderid_fk
     foreign key ( folderid ) references folder( id ) $!db.ADDL_FK_PARAMS ;
 
+-- media files
+alter table media_file add constraint media_file_directory_id_fk
+    foreign key (directory_id) references media_file_directory(id) $!db.ADDL_FK_PARAMS ;
+
+alter table media_file_tag add constraint media_file_id_tag_fk
+    foreign key (media_file_id) references media_file(id) $!db.ADDL_FK_PARAMS ;
+
+alter table media_file_directory add constraint mf_websiteid_fk
+    foreign key ( websiteid ) references website( id ) $!db.ADDL_FK_PARAMS ;
+
+alter table media_file_directory add constraint mf_parentid_fk
+    foreign key ( parentid ) references media_file_directory( id )  $!db.ADDL_FK_PARAMS ;
+
 -- newsfeed
 
 alter table newsfeed add constraint nf_websiteid_fk

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/sql/droptables.sql
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/sql/droptables.sql?rev=739576&r1=739575&r2=739576&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/sql/droptables.sql (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/sql/droptables.sql Sat Jan 31 16:49:51 2009
@@ -39,6 +39,11 @@
 drop table bookmark;
 drop table folder;
 drop table folderassoc;
+drop table roller_userattribute;
+drop table media_file_tag;
+drop table media_file;
+drop table media_file_directory;
+
 
 -- core services tables
 drop table roller_hitcounts;

Modified: roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/ant/StartDerbyTask.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/ant/StartDerbyTask.java?rev=739576&r1=739575&r2=739576&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/ant/StartDerbyTask.java (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/ant/StartDerbyTask.java Sat Jan 31 16:49:51 2009
@@ -32,7 +32,7 @@
     
     public void execute() throws BuildException {
         try {
-            System.out.println("Stopping Derby");
+            System.out.println("Starting Derby");
             System.setProperty("derby.system.home", database);
             System.setProperty("derby.drda.portNumber", port);
             System.setProperty("derby.drda.host", "localhost");

Added: 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=739576&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/business/FileContentManagerTest.java (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/business/FileContentManagerTest.java Sat Jan 31 16:49:51 2009
@@ -0,0 +1,182 @@
+/*
+ * 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.business;
+
+import java.io.InputStream;
+import java.util.Map;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.TestUtils;
+import org.apache.roller.weblogger.pojos.FileContent;
+import org.apache.roller.weblogger.pojos.RuntimeConfigProperty;
+import org.apache.roller.weblogger.pojos.User;
+import org.apache.roller.weblogger.pojos.Weblog;
+import org.apache.roller.weblogger.util.RollerMessages;
+
+/**
+ * Test File Management business layer operations.
+ */
+public class FileContentManagerTest extends TestCase {
+    
+    private static Log log = LogFactory.getLog(FileContentManagerTest.class);
+    
+    User testUser = null;
+    Weblog testWeblog = null;
+    
+    
+    public FileContentManagerTest(String name) {
+        super(name);
+    }
+    
+    
+    public static Test suite() {
+        return new TestSuite(FileContentManagerTest.class);
+    }
+    
+    
+    public void setUp() throws Exception {
+        
+        // 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 {
+        
+        /*
+    	try {
+            TestUtils.teardownWeblog(testWeblog.getId());
+            TestUtils.teardownUser(testUser.getUserName());
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+        }
+        */
+    }
+    
+    
+    /**
+     * Test simple file save/delete.
+     */
+    public void testFileCRUD() throws Exception {
+        
+        // update roller properties to prepare for test
+        PropertiesManager pmgr = WebloggerFactory.getWeblogger().getPropertiesManager();
+        Map config = pmgr.getProperties();
+        ((RuntimeConfigProperty)config.get("uploads.enabled")).setValue("true");
+        ((RuntimeConfigProperty)config.get("uploads.types.allowed")).setValue("opml");
+        ((RuntimeConfigProperty)config.get("uploads.dir.maxsize")).setValue("1.00");
+        pmgr.saveProperties(config);
+        TestUtils.endSession(true);
+        
+        /* NOTE: upload dir for unit tests is set in
+               roller/testdata/roller-custom.properties */
+        FileContentManager fmgr = WebloggerFactory.getWeblogger().getFileContentManager();
+        
+        // File should not exist initially
+        try {
+			FileContent fileContent = fmgr.getFileContent(testWeblog, "bookmarks-file-id");
+			assertTrue("Non-existant file retrieved without any exception", false);
+		} catch (FileNotFoundException e) {
+			assertTrue("Exception thrown for non-existant file as expected", true);
+		}
+        
+        // store a file
+        InputStream is = getClass().getResourceAsStream("/bookmarks.opml");
+        fmgr.saveFileContent(testWeblog, "bookmarks-file-id", is);
+        
+        // make sure file was stored successfully
+        FileContent fileContent1 = fmgr.getFileContent(testWeblog, "bookmarks-file-id");
+        assertEquals("bookmarks-file-id", fileContent1.getFileId());
+        
+        
+        // delete file
+        fmgr.deleteFile(testWeblog, "bookmarks-file-id");
+        
+        // File should not exist after delete
+        try {
+			FileContent fileContent = fmgr.getFileContent(testWeblog, "bookmarks-file-id");
+			assertTrue("Non-existant file retrieved without any exception", false);
+		} catch (FileNotFoundException e) {
+			assertTrue("Exception thrown for non-existant file as expected", true);
+		}
+    }
+    
+    
+    /**
+     * Test FileContentManager.saveFile() checks.
+     *
+     * This should test all conditions where a save should fail.
+     */
+    public void testCanSave() throws Exception {
+        
+        FileContentManager fmgr = WebloggerFactory.getWeblogger().getFileContentManager();
+        PropertiesManager pmgr = WebloggerFactory.getWeblogger().getPropertiesManager();
+        Map config = config = pmgr.getProperties();
+        ((RuntimeConfigProperty)config.get("uploads.dir.maxsize")).setValue("1.00");
+        ((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);
+        
+        config = pmgr.getProperties();
+        ((RuntimeConfigProperty)config.get("uploads.dir.maxsize")).setValue("1.00");
+        pmgr.saveProperties(config);
+        TestUtils.endSession(true);
+        
+        RollerMessages msgs = new RollerMessages();
+        boolean canSave = fmgr.canSave(testWeblog, "test.gif", "text/plain", 2500000, msgs);
+        assertFalse(canSave);
+        
+        config = pmgr.getProperties();
+        ((RuntimeConfigProperty)config.get("uploads.types.forbid")).setValue("gif");
+        pmgr.saveProperties(config);
+        TestUtils.endSession(true);
+        
+        // forbidden types check should fail
+    	msgs = new RollerMessages();
+    	fmgr.canSave(testWeblog, "test.gif", "text/plain", 10, msgs);
+        assertFalse(canSave);
+        
+        
+        config = pmgr.getProperties();
+        ((RuntimeConfigProperty)config.get("uploads.enabled")).setValue("false");
+        pmgr.saveProperties(config);
+        TestUtils.endSession(true);
+        
+        // uploads disabled should fail
+    	msgs = new RollerMessages();
+    	fmgr.canSave(testWeblog, "test.gif", "text/plain", 10, msgs);
+        assertFalse(canSave);
+    }
+    
+}

Added: 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=739576&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/business/MediaFileTest.java (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/test/java/org/apache/roller/weblogger/business/MediaFileTest.java Sat Jan 31 16:49:51 2009
@@ -0,0 +1,589 @@
+/*
+* 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.business;
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.TestUtils;
+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.MediaFileTag;
+import org.apache.roller.weblogger.pojos.User;
+import org.apache.roller.weblogger.pojos.Weblog;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.SQLExec;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test User related business operations.
+ */
+public class MediaFileTest extends TestCase {
+    
+    public static Log log = LogFactory.getLog(MediaFileTest.class);
+    static final String runtimeEnv;
+
+    public MediaFileTest() {
+    	// TODO: create setup and teardown classes and move test user/weblgo to them after resolving the issue with teardown.
+    }
+    
+    public MediaFileTest(String name) {
+    	super(name);
+    }
+    
+    static {
+    	runtimeEnv = System.getProperty("runtime-environment");
+    	try {
+			classInit();
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+    }
+    
+    @BeforeClass
+    public static void classInit() throws Exception {
+    	if ("eclipse".equals(runtimeEnv)) {
+        	startDatabase();
+        	initDatabase();
+    	}
+    	else {
+    		if ("true".equalsIgnoreCase(System.getProperty("debug-enabled"))) {
+        		System.out.println("Sleeping for 5 seconds, you might want to start your debugger");
+        		Thread.sleep(5000);
+    		}
+    	}
+    }
+    
+    @AfterClass
+    public static void classTearDown() {
+    	if ("eclipse".equals(runtimeEnv)) {
+        	stopDatabase();
+    	}
+    }
+
+    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.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"));
+
+    	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"));
+    	SQLExec.OnError onError1 = new SQLExec.OnError();
+    	onError1.setValue("continue");
+    	sqlTask1.setOnerror(onError1);
+    	//sqlTask1.setClasspath(new Path());
+    	sqlTask1.setProject(new Project());
+    	sqlTask1.execute();
+    }
+
+    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"));
+
+    	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"));
+    	SQLExec.OnError onError1 = new SQLExec.OnError();
+    	onError1.setValue("continue");
+    	sqlTask1.setOnerror(onError1);
+    	//sqlTask1.setClasspath(new Path());
+    	sqlTask1.setProject(new Project());
+    	sqlTask1.execute();
+    	
+    	SQLExec sqlTask2 = new SQLExec();
+    	sqlTask2.setDriver(props.getProperty("test.db.driver"));
+    	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"));
+    	SQLExec.OnError onError2 = new SQLExec.OnError();
+    	onError2.setValue("continue");
+    	sqlTask2.setOnerror(onError2);
+    	//sqlTask2.setClasspath(new Path());
+    	sqlTask2.setProject(new Project());
+    	sqlTask2.execute();
+    }
+    
+    public static void stopDatabase() {
+    	StopDerbyTask stopTask = new StopDerbyTask();
+    	stopTask.setPort("3219");
+    	stopTask.execute();
+    }
+
+    @Before
+    public void setUpApp() throws Exception {
+    }
+    
+    @After
+    public void tearDown() throws Exception {
+    	/*
+    	try {
+            TestUtils.teardownWeblog(testWeblog.getId());
+            TestUtils.teardownUser(this.testUser.getUserName());
+            TestUtils.endSession(true);
+        } catch (Exception ex) {
+            log.error(ex);
+            throw new Exception("Test teardown failed", ex);
+        }
+        */
+        
+    }
+    
+    
+    /**
+     * Test directory creation
+     */
+    @Test
+    public void testCreateMediaFileDirectory() 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
+        TestUtils.setupWeblogger();
+        try {
+            testUser = TestUtils.setupUser("mediaFileTestUser");
+            testWeblog = TestUtils.setupWeblog("mediaFileTestWeblog", 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 directory = new MediaFileDirectory(null, "root", "root d", testWeblog);
+        mfMgr.createMediaFileDirectory(directory);
+        assertEquals("/", directory.getPath());
+        assertNotNull(directory.getId() != null);
+        System.out.println("The directory id is " + directory.getId());
+        TestUtils.endSession(true);
+        
+        MediaFileDirectory directoryById = mfMgr.getMediaFileDirectory(directory.getId());
+        assertEquals(directory, directoryById);
+        
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        MediaFileDirectory rootDirectory = mfMgr.getMediaFileRootDirectory(testWeblog);
+        assertEquals(directory, rootDirectory);
+
+    }
+    
+    
+    
+    /**
+     * Test getting list of all directories for a given user.
+     */
+    public void testGetMediaFileDirectories() throws Exception {
+        
+        User testUser = null;
+        Weblog testWeblog = null;
+        testUser = TestUtils.setupUser("mediaFileTestUser2");
+        testWeblog = TestUtils.setupWeblog("mediaFileTestWeblog2", testUser);
+        
+        MediaFileManager mfMgr = WebloggerFactory.getWeblogger().getMediaFileManager();
+
+        MediaFileDirectory rootDirectory = new MediaFileDirectory(null, "root", "root d", testWeblog);
+        mfMgr.createMediaFileDirectory(rootDirectory);
+
+        MediaFileDirectory directory2 = new MediaFileDirectory(rootDirectory, "dir2", "directory 2", testWeblog);
+        mfMgr.createMediaFileDirectory(directory2);
+
+        MediaFileDirectory directory3 = new MediaFileDirectory(rootDirectory, "dir3", "directory 3", testWeblog);
+        mfMgr.createMediaFileDirectory(directory3);
+        
+        TestUtils.endSession(true);
+
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        List<MediaFileDirectory> directories = mfMgr.getMediaFileDirectories(testWeblog);
+        assertNotNull(directories);
+        assertEquals(3, directories.size());
+        assertTrue(containsPath(directories, "/"));
+        assertTrue(containsPath(directories, "/dir2"));
+        assertTrue(containsPath(directories, "/dir3"));
+        
+    }
+    
+    private boolean containsPath(Collection<MediaFileDirectory> directories, String path) {
+    	for (MediaFileDirectory directory: directories) {
+    		if (path.equals(directory.getPath())) return true;
+    	}
+    	return false;
+    	
+    }
+    
+    private boolean containsFileWithName(Collection<MediaFile> files, String name) {
+    	for (MediaFile file: files) {
+    		if (name.equals(file.getName())) return true;
+    	}
+    	return false;
+    	
+    }
+    
+    /**
+     * Test deletion of media file
+     */
+    public void testDeleteMediaFile() throws Exception {
+        User testUser = null;
+        Weblog testWeblog = null;
+        testUser = TestUtils.setupUser("mediaFileTestUser4");
+        testWeblog = TestUtils.setupWeblog("mediaFileTestWeblog4", 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("test4.jpg");
+        mediaFile.setDescription("This is a test image 4");
+        mediaFile.setCopyrightText("test 4 copyright text");
+        mediaFile.setSharedForGallery(false);
+        mediaFile.setLength(3000);
+        mediaFile.setDirectory(rootDirectory);
+        mediaFile.setContentType("image/jpeg");
+        mediaFile.setInputStream(getClass().getResourceAsStream("/test4.jpg"));
+        
+        MediaFileTag tag1 = new MediaFileTag("tst4work", mediaFile);
+        MediaFileTag tag2 = new MediaFileTag("tst4home", mediaFile);
+        Set<MediaFileTag> tags = new HashSet<MediaFileTag>();
+        tags.add(tag1);
+        tags.add(tag2);
+        mediaFile.setTags(tags);
+        
+        mfMgr.createMediaFile(testWeblog, mediaFile);
+        String id = mediaFile.getId();
+        TestUtils.endSession(true);
+        assertNotNull(id);
+        assertNotNull(id.length() > 0);
+        
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        MediaFile mediaFile1 = mfMgr.getMediaFile(id);
+        
+        assertEquals("test4.jpg", mediaFile1.getName());
+        assertNotNull(mediaFile1.getTags());
+        assertEquals(2, mediaFile1.getTags().size());
+        
+        mfMgr.removeMediaFile(mediaFile1);
+        TestUtils.endSession(true);
+        
+        MediaFile mediaFile2 = mfMgr.getMediaFile(id);
+        assertNull(mediaFile2);
+    	
+    }
+
+    /**
+     * Test creation of media file.
+     */
+    public void testCreateMediaFile() throws Exception {
+        
+        User testUser = null;
+        Weblog testWeblog = null;
+        testUser = TestUtils.setupUser("mediaFileTestUser3");
+        testWeblog = TestUtils.setupWeblog("mediaFileTestWeblog3", 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.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);
+        MediaFileTag tag2 = new MediaFileTag("home", mediaFile);
+        Set<MediaFileTag> tags = new HashSet<MediaFileTag>();
+        tags.add(tag1);
+        tags.add(tag2);
+        mediaFile.setTags(tags);
+        
+        mfMgr.createMediaFile(testWeblog, mediaFile);
+        TestUtils.endSession(true);
+        assertNotNull(mediaFile.getId());
+        assertNotNull(mediaFile.getId().length() > 0);
+        
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        MediaFile mediaFile1 = mfMgr.getMediaFile(mediaFile.getId());
+        assertEquals("test.jpg", mediaFile1.getName());
+        assertEquals("This is a test image", mediaFile1.getDescription());
+        assertEquals("test copyright text", mediaFile1.getCopyrightText());
+        assertTrue(mediaFile1.isSharedForGallery());
+        assertEquals(2000, mediaFile1.getLength());
+    }
+
+    /**
+     * Test media file update
+     */
+    public void testUpdateMediaFile() throws Exception {
+        User testUser = null;
+        Weblog testWeblog = null;
+        testUser = TestUtils.setupUser("mediaFileTestUser5");
+        testWeblog = TestUtils.setupWeblog("mediaFileTestWeblog5", 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("test5.jpg");
+        mediaFile.setDescription("This is a test image 5");
+        mediaFile.setCopyrightText("test 5 copyright text");
+        mediaFile.setSharedForGallery(false);
+        mediaFile.setLength(3000);
+        mediaFile.setDirectory(rootDirectory);
+        mediaFile.setInputStream(getClass().getResourceAsStream("/test5.jpg"));
+        mediaFile.setContentType("image/jpeg");
+        
+        
+        MediaFileTag tag1 = new MediaFileTag("tst5work", mediaFile);
+        MediaFileTag tag2 = new MediaFileTag("tst5home", mediaFile);
+        Set<MediaFileTag> tags = new HashSet<MediaFileTag>();
+        tags.add(tag1);
+        tags.add(tag2);
+        mediaFile.setTags(tags);
+        
+        mfMgr.createMediaFile(testWeblog, mediaFile);
+        String id = mediaFile.getId();
+        TestUtils.endSession(true);
+        assertNotNull(id);
+        assertNotNull(id.length() > 0);
+        
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        MediaFile mediaFile1 = mfMgr.getMediaFile(id);
+        mediaFile1.setName("updated.gif");
+        mediaFile1.setDescription("updated desc");
+        mediaFile1.setCopyrightText("updated copyright");
+        mediaFile1.setContentType("image/gif");
+        mediaFile1.setSharedForGallery(true);
+        mfMgr.updateMediaFile(testWeblog, mediaFile1);
+        TestUtils.endSession(true);
+        
+        MediaFile mediaFile2 = mfMgr.getMediaFile(id);
+        assertEquals("updated.gif", mediaFile2.getName());
+        assertEquals("updated desc", mediaFile2.getDescription());
+        assertEquals("updated copyright", mediaFile2.getCopyrightText());
+        assertEquals("image/gif", mediaFile2.getContentType());
+        assertTrue(mediaFile2.isSharedForGallery());
+        assertNotNull(mediaFile2.getTags());
+        assertEquals(2, mediaFile2.getTags().size());
+    }
+
+    /**
+     * Test media file update
+     */
+    public void testGetDirectoryContents() throws Exception {
+        User testUser = null;
+        Weblog testWeblog = null;
+        testUser = TestUtils.setupUser("mediaFileTestUser6");
+        testWeblog = TestUtils.setupWeblog("mediaFileTestWeblog6", testUser);
+        
+        MediaFileManager mfMgr = WebloggerFactory.getWeblogger().getMediaFileManager();
+
+        MediaFileDirectory rootDirectory = new MediaFileDirectory(null, "root", "root d", testWeblog);
+        mfMgr.createMediaFileDirectory(rootDirectory);
+
+        MediaFileDirectory directory1 = new MediaFileDirectory(rootDirectory, "dir1", "directory 1", testWeblog);
+        mfMgr.createMediaFileDirectory(directory1);
+
+        MediaFileDirectory directory2 = new MediaFileDirectory(rootDirectory, "dir2", "directory 2", testWeblog);
+        mfMgr.createMediaFileDirectory(directory2);
+
+        MediaFileDirectory directory3 = new MediaFileDirectory(rootDirectory, "dir3", "directory 3", testWeblog);
+        mfMgr.createMediaFileDirectory(directory3);
+        
+        
+        MediaFile mediaFile = new MediaFile();
+        mediaFile.setDirectory(rootDirectory);
+        mediaFile.setName("test6_1.jpg");
+        mediaFile.setDescription("This is a test image 6.1");
+        mediaFile.setCopyrightText("test 6.1 copyright text");
+        mediaFile.setSharedForGallery(false);
+        mediaFile.setLength(4000);
+        mediaFile.setInputStream(getClass().getResourceAsStream("/test6.jpg"));
+        mediaFile.setContentType("image/jpeg");
+        mfMgr.createMediaFile(testWeblog, mediaFile);
+
+        MediaFile mediaFile2 = new MediaFile();
+        mediaFile2.setDirectory(rootDirectory);
+        mediaFile2.setName("test6_2.jpg");
+        mediaFile2.setDescription("This is a test image 6.2");
+        mediaFile2.setCopyrightText("test 6.2 copyright text");
+        mediaFile2.setSharedForGallery(true);
+        mediaFile2.setLength(4000);
+        mediaFile2.setInputStream(getClass().getResourceAsStream("/test6.jpg"));
+        mediaFile2.setContentType("image/jpeg");
+        mfMgr.createMediaFile(testWeblog, mediaFile2);
+        
+        TestUtils.endSession(true);
+
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        rootDirectory = mfMgr.getMediaFileDirectory(rootDirectory.getId());
+        
+        Set<MediaFileDirectory> childDirectories = rootDirectory.getChildDirectories();
+        assertEquals(3, childDirectories.size());
+        assertTrue(containsPath(childDirectories, "/dir1"));
+        assertTrue(containsPath(childDirectories, "/dir2"));
+        assertTrue(containsPath(childDirectories, "/dir3"));
+        
+        Set<MediaFile> mediaFiles = rootDirectory.getMediaFiles();
+        assertEquals(2, mediaFiles.size());
+        assertTrue(containsFileWithName(mediaFiles, "test6_1.jpg"));
+        assertTrue(containsFileWithName(mediaFiles, "test6_2.jpg"));
+        TestUtils.endSession(true);
+        
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        rootDirectory = mfMgr.getMediaFileDirectory(rootDirectory.getId());
+        assertTrue(rootDirectory.hasMediaFile("test6_1.jpg"));
+        assertTrue(rootDirectory.hasMediaFile("test6_2.jpg"));
+        
+    }
+
+    /**
+     * Test media file update
+     */
+    public void testMoveDirectoryContents() 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);
+
+        MediaFileDirectory directory1 = new MediaFileDirectory(rootDirectory, "dir1", "directory 1", testWeblog);
+        mfMgr.createMediaFileDirectory(directory1);
+        String dir1Id = directory1.getId();
+
+        MediaFileDirectory directory2 = new MediaFileDirectory(rootDirectory, "dir2", "directory 2", testWeblog);
+        mfMgr.createMediaFileDirectory(directory2);
+
+        MediaFileDirectory directory3 = new MediaFileDirectory(rootDirectory, "dir3", "directory 3", testWeblog);
+        mfMgr.createMediaFileDirectory(directory3);
+        
+        
+        MediaFile mediaFile = new MediaFile();
+        mediaFile.setDirectory(rootDirectory);
+        mediaFile.setName("test7_1.jpg");
+        mediaFile.setDescription("This is a test image 7.1");
+        mediaFile.setCopyrightText("test 7.1 copyright text");
+        mediaFile.setSharedForGallery(false);
+        mediaFile.setLength(4000);
+        mediaFile.setInputStream(getClass().getResourceAsStream("/test7.jpg"));
+        mediaFile.setContentType("image/jpeg");
+        mfMgr.createMediaFile(testWeblog, mediaFile);
+
+        MediaFile mediaFile2 = new MediaFile();
+        mediaFile2.setDirectory(rootDirectory);
+        mediaFile2.setName("test7_2.jpg");
+        mediaFile2.setDescription("This is a test image 7.2");
+        mediaFile2.setCopyrightText("test 7.2 copyright text");
+        mediaFile2.setSharedForGallery(true);
+        mediaFile2.setLength(4000);
+        mediaFile2.setInputStream(getClass().getResourceAsStream("/test7.jpg"));
+        mediaFile2.setContentType("image/jpeg");
+        mfMgr.createMediaFile(testWeblog, mediaFile2);
+        
+        TestUtils.endSession(true);
+
+        testWeblog = TestUtils.getManagedWebsite(testWeblog);
+        rootDirectory = mfMgr.getMediaFileDirectory(rootDirectory.getId());
+        
+        Set<MediaFile> mediaFiles = rootDirectory.getMediaFiles();
+        assertEquals(2, mediaFiles.size());
+        assertTrue(containsFileWithName(mediaFiles, "test7_1.jpg"));
+        assertTrue(containsFileWithName(mediaFiles, "test7_2.jpg"));
+        
+        MediaFileDirectory targetDirectory = mfMgr.getMediaFileDirectory(dir1Id);
+        mfMgr.moveMediaFiles(mediaFiles, targetDirectory);
+        TestUtils.endSession(true);
+        
+        rootDirectory = mfMgr.getMediaFileDirectory(rootDirectory.getId());
+        targetDirectory = mfMgr.getMediaFileDirectory(dir1Id);
+        
+        mediaFiles = targetDirectory.getMediaFiles();
+        assertEquals(2, mediaFiles.size());
+        assertTrue(containsFileWithName(mediaFiles, "test7_1.jpg"));
+        assertTrue(containsFileWithName(mediaFiles, "test7_2.jpg"));
+
+        mediaFiles = rootDirectory.getMediaFiles();
+        assertEquals(0, mediaFiles.size());
+        
+    }
+}

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=739576&r1=739575&r2=739576&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 Sat Jan 31 16:49:51 2009
@@ -945,6 +945,15 @@
 maintenance.message.flushed=Successfully flushed the page cache of your \
 Roller weblog
 
+# ----------------------------------------------------------- Media file management
+mediaFile.add.title=Add new media file
+
+# 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
+
 # ----------------------------------------------------------- Member permissions
 
 memberPermissions.title=Weblog Member Permissions
@@ -1407,6 +1416,9 @@
 tabbedmenu.weblog.import=Import
 tabbedmenu.weblog.flushCache=Flush Cache
 
+tabbedmenu.weblog.mediaFileAdd=Add Media File
+tabbedmenu.weblog.tabularView=Media Files
+
 tabbedmenu.admin=Server Admin
 tabbedmenu.admin.config=Configuration
 tabbedmenu.admin.userAdmin=User Admin

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=739576&r1=739575&r2=739576&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 Sat Jan 31 16:49:51 2009
@@ -217,6 +217,18 @@
             <result name="input" type="tiles">.EntryAdd</result>
             <result name="success" type="chain">entryEdit</result>
         </action>
+
+	<action name="mediaFileAdd!*" method="{1}"
+                class="org.apache.roller.weblogger.ui.struts2.editor.MediaFileAdd">
+            <result name="input" type="tiles">.MediaFileAdd</result>
+            <result name="success" type="tiles">.MediaFileAddSuccess</result>
+        </action>
+
+	<action name="tabular!*" method="{1}"
+                class="org.apache.roller.weblogger.ui.struts2.editor.Resources">
+            <result name="list" type="tiles">.TabularView</result>
+        </action>
+        
         
         <action name="entryEdit!*" method="{1}"
                 class="org.apache.roller.weblogger.ui.struts2.editor.EntryEdit">

Added: 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=739576&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAdd.jsp (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAdd.jsp Sat Jan 31 16:49:51 2009
@@ -0,0 +1,129 @@
+<%--
+  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">
+   Add Media Files
+</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%">   
+        
+        <tr>
+            <td class="entryEditFormLabel">
+                <label for="title">File Location</label>
+            </td>
+            <td>
+                 <s:file name="uploadedFile" size="30" /><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" />
+            </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="directoryId" list="allDirectories" listKey="id" listValue="path" />
+            </td>
+       </tr>
+
+	   <tr>
+            <td class="entryEditFormLabel">
+                <label for="status">Include in Gallery?</label>
+            </td>
+			<td>
+                <input type="checkbox" name="checkbox" checked />
+            </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>

Added: 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=739576&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp Sat Jan 31 16:49:51 2009
@@ -0,0 +1,86 @@
+<%--
+  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">
+   Add Media Files
+</p>
+
+<s:form id="entry" action="addMedia!submit" onsubmit="editorCleanup()">
+    <s:hidden name="weblog" />
+
+<div style="border:1px solid; width=80px;background-color: #cfc;margin-bottom:5px;">
+<ul>
+<li> <s:property value="bean.name" /> uploaded successfully</li>
+</ul>
+</div>
+
+<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:property value="%{mediaFileURL}" />
+</s:else>
+</s:a>
+
+<div style="margin-top:20px;text-decoration:underline">
+<a href="#">Create a blog post out of <s:property value="bean.name" /></a><br/>
+
+<s:url id="mediaFileAddURL" action="mediaFileAdd">
+    <s:param name="weblog" value="%{actionWeblog.handle}" />
+</s:url>
+
+<s:a href="%{mediaFileAddURL}">Add another media file</s:a>
+</div>
+
+
+
+
+
+       
+        
+   
+    
+    
+    <%-- ================================================================== --%>
+    <%-- 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/MediaFileSidebar.jsp
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileSidebar.jsp?rev=739576&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileSidebar.jsp (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileSidebar.jsp Sat Jan 31 16:49:51 2009
@@ -0,0 +1,51 @@
+<%--
+  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" %>
+
+<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" />
+
+                <br />
+                <br />
+            </div>
+
+        </div>
+    </div>
+</div>

Added: roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/TabularView.jsp
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/TabularView.jsp?rev=739576&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/TabularView.jsp (added)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/TabularView.jsp Sat Jan 31 16:49:51 2009
@@ -0,0 +1,150 @@
+<%--
+  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">
+   View Uploaded Files
+</p>
+<p><span style="font-weight:bold">Tabular</span>| Hierarchical</p>
+ <div class="control">
+    <span style="padding-left:20px">Sort by:</span>  
+	<select>
+	<option value="name">Name</option>
+	<option value="Date Modified">Date Modified</option>
+	<option value="Type">Type</option>
+	</select>
+	<span style="padding-left:300px">
+	<a href="">&lt;&lt;First</a>
+	<a href="">&lt;Previous</a>
+	<a href="">1</a>
+	<a href="">2</a>
+	<a href="">3</a>
+	<a href="">4</a>
+	<a href="">Next&gt;</a>
+	<a href="">Last&gt;&gt;</a>
+    </div>
+    
+	<s:form id="entry" action="addMedia!submit" onsubmit="editorCleanup()">
+    <s:hidden name="weblog" />
+
+
+    
+    <%-- ================================================================== --%>
+    <%-- Title, category, dates and other metadata --%>
+    
+    <div style="margin-top:10px">
+	<table border="0" cellspacing="30">
+	<tr>
+	<td>
+	<img border="0" src='<s:url value="/images/mediaFolder.png"/>' width=120px alt="mediaFolder.png"/><br/>
+    <label>Vegas Trip</label><br/>
+	</td>
+	<td>
+	<img border="0" src='<s:url value="/images/mediaFolder.png"/>' width=120px alt="mediaFolder.png"/><br/>
+    <label>Yosemite Trip</label><br/>
+	</td>
+	<td>
+	<img border="0" src='<s:url value="/images/mediaFolder.png"/>' width=120px alt="mediaFolder.png"/><br/>
+    <label>New York Trip Videos</label><br/>
+	</td>
+	<td>
+	<img border="0" src='<s:url value="/images/Winter.png"/>' width=120px alt="Winter.png"/><br/>
+    <label>Winter.png</label><br/>
+	<input type="checkbox" name="pic1" />
+	<span style="padding-left:20px"<a href="">Edit</a>
+	<a href="">More...</a></span>
+	</td>
+	</tr>
+	<tr>
+	<td>
+	<img border="0" src='<s:url value="/images/library.png"/>' width=120px alt="Library.png"/><br/>
+    <label>Library.png</label><br/>
+	<input type="checkbox" name="pic2" />
+	<span style="padding-left:20px"<a href="">Edit</a>
+	<a href="">More...</a></span>
+	</td>
+	<td>
+	<img border="0" src='<s:url value="/images/cake1.png"/>' width=120px alt="cake1.png"/><br/>
+    <label>Cake1.png</label><br/>
+	<input type="checkbox" name="pic3" />
+	<span style="padding-left:20px"<a href="">Edit</a>
+	<a href="">More...</a></span>
+	</td>
+	<td>
+	<img border="0" src='<s:url value="/images/cake2.png"/>' width=120px alt="cake2.png"/><br/>
+    <label>Cake2.png</label><br/>
+	<input type="checkbox" name="pic4" />
+	<span style="padding-left:20px"<a href="">Edit</a>
+	<a href="">More...</a></span>
+	</td>
+	<td>
+	<img border="0" src='<s:url value="/images/cake3.png"/>' width=120px alt="cake3.png"/><br/>
+    <label>Cake3.png</label><br/>
+	<input type="checkbox" name="pic5" />
+	<span style="padding-left:20px"<a href="">Edit</a>
+	<a href="">More...</a></span>
+	</td>
+	</tr>
+</table>
+</div>
+
+<div style="margin-left:320px">
+New Directory: 
+<input type="text" size="30" />
+<input type="button" name="create" value="Create" />
+</div>
+
+
+
+    
+    <%-- ================================================================== --%>
+    <%-- Weblog edit or preview --%>
+    
+   
+    
+   
+    
+    
+    <%-- ================================================================== --%>
+    <%-- plugin chooser --%>
+    
+ 
+
+    
+    <%-- ================================================================== --%>
+    <%-- advanced settings  --%>
+  
+    
+    <%-- ================================================================== --%>
+    <%-- the button box --%>
+
+	<br/>
+	<div class="control">
+       <input type="button" value="Delete Selected" name="delete" />
+	 <span style="padding-left:20px" <input type="button" value="Move Selected" name="move" /></span>
+	 <span style="padding-left:20px" <select> <option name="vegas">Vegas Trip</option>
+	 <option name="vegas">New York Trip Videos</option>
+	 <option name="vegas">Yosemite Trip</option>
+	 </select></span>
+    </div>
+    
+    
+   
+	</s:form>
+    
+

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=739576&r1=739575&r2=739576&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 Sat Jan 31 16:49:51 2009
@@ -201,6 +201,27 @@
         <put-attribute name="sidebar" value="/WEB-INF/jsps/editor/EntrySidebar.jsp" />
         <put-attribute name="styles" value="/WEB-INF/jsps/tiles/css-sidebar.jsp" />
     </definition>
+
+    <definition name=".MediaFileAdd" extends=".tiles-tabbedpage" >
+        <put-attribute name="head" value="/WEB-INF/jsps/tiles/head-ajax.jsp" />
+        <put-attribute name="content" value="/WEB-INF/jsps/editor/MediaFileAdd.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" >
+        <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" />
+        <put-attribute name="styles" value="/WEB-INF/jsps/tiles/css-sidebar.jsp" />
+    </definition>
     
     <definition name=".EntryEdit" extends=".tiles-tabbedpage" >
         <put-attribute name="head" value="/WEB-INF/jsps/tiles/head-ajax.jsp" />

Modified: roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/web.xml?rev=739576&r1=739575&r2=739576&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/web.xml (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/web.xml Sat Jan 31 16:49:51 2009
@@ -225,6 +225,12 @@
     </servlet>
     
     <servlet>
+        <servlet-name>MediaResourceServlet</servlet-name>
+        <servlet-class>org.apache.roller.weblogger.ui.rendering.servlets.MediaResourceServlet</servlet-class>
+        <load-on-startup>5</load-on-startup>
+    </servlet>
+
+    <servlet>
         <servlet-name>SearchServlet</servlet-name>
         <servlet-class>org.apache.roller.weblogger.ui.rendering.servlets.SearchServlet</servlet-class>
         <load-on-startup>5</load-on-startup>
@@ -352,6 +358,11 @@
     </servlet-mapping>
     
     <servlet-mapping>
+        <servlet-name>MediaResourceServlet</servlet-name>
+        <url-pattern>/roller-ui/rendering/media-resources/*</url-pattern>
+    </servlet-mapping>
+    
+    <servlet-mapping>
         <servlet-name>CommentServlet</servlet-name>
         <url-pattern>/roller-ui/rendering/comment/*</url-pattern>
     </servlet-mapping>



Mime
View raw message