roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ganes...@apache.org
Subject svn commit: r768475 - in /roller/branches/roller_mediablogging/apps/weblogger: src/java/org/apache/roller/weblogger/pojos/ src/java/org/apache/roller/weblogger/ui/rendering/servlets/ src/java/org/apache/roller/weblogger/ui/struts2/editor/ web/WEB-INF/c...
Date Sat, 25 Apr 2009 05:56:40 GMT
Author: ganeshmb
Date: Sat Apr 25 05:56:39 2009
New Revision: 768475

URL: http://svn.apache.org/viewvc?rev=768475&view=rev
Log:
Minor bug fixes, code cleanup

Modified:
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/MediaResourceServlet.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd-validation.xml
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileEdit.java
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAdd.jsp
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileSearch.jsp

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java?rev=768475&r1=768474&r2=768475&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java
(original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFile.java
Sat Apr 25 05:56:39 2009
@@ -30,12 +30,8 @@
  * @hibernate.cache usage="read-write"
  * @hibernate.class lazy="true" table="media_file"
  */
-public class MediaFile implements ThemeResource {
+public class MediaFile {
 
-    // TODO: Ganesh - change class name to WeblogMediaFile?
-    // TODO Ganesh - review all class attributes
-    // TODO Ganesh - database constraints (not null etc) - revisit.
-	
 	final String id;
     String name;
     String description;
@@ -207,19 +203,6 @@
 		return directory.getPath();
 	}
 
-	public ThemeResource[] getChildren() {
-		// TODO - Ganesh - To be implemented
-		return null;
-	}
-
-	public boolean isDirectory() {
-		return false;
-	}
-
-	public boolean isFile() {
-		return true;
-	}
-
 	public InputStream getInputStream() {
 		if (is != null) {
 			return is;

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/MediaResourceServlet.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/MediaResourceServlet.java?rev=768475&r1=768474&r2=768475&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/MediaResourceServlet.java
(original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/rendering/servlets/MediaResourceServlet.java
Sat Apr 25 05:56:39 2009
@@ -33,11 +33,9 @@
 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.Weblog;
 import org.apache.roller.weblogger.ui.rendering.util.ModDateHeaderUtil;
 
 
-// TODO: Ganesh - update documentation
 /**
  * Serves media files uploaded by users.
  *
@@ -45,8 +43,8 @@
  * context we need a way to serve them up.  This servlet assumes that
  * resources are stored on a filesystem in the "uploads.dir" directory.
  *
- * @web.servlet name="ResourcesServlet" load-on-startup="5"
- * @web.servlet-mapping url-pattern="/roller-ui/rendering/resources/*"
+ * @web.servlet name="MediaResourceServlet" load-on-startup="5"
+ * @web.servlet-mapping url-pattern="/roller-ui/rendering/media-resources/*"
  */
 public class MediaResourceServlet extends HttpServlet {
 
@@ -61,7 +59,7 @@
 
 
     /**
-     * Handles requests for user uploaded resources.
+     * Handles requests for user uploaded media file resources.
      */
     public void doGet(HttpServletRequest request, HttpServletResponse response)
             throws ServletException, IOException {

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd-validation.xml
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd-validation.xml?rev=768475&r1=768474&r2=768475&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd-validation.xml
(original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd-validation.xml
Sat Apr 25 05:56:39 2009
@@ -20,4 +20,10 @@
         </field-validator>
     </field>
     
+    <field name="bean.copyrightText">
+        <field-validator type="stringlength">
+            <param name="maxLength">1023</param>
+            <message key="MediaFile.error.copyrightTextSize">unspecified key</message>
+        </field-validator>
+    </field>
 </validators>

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd.java?rev=768475&r1=768474&r2=768475&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd.java
(original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileAdd.java
Sat Apr 25 05:56:39 2009
@@ -21,8 +21,6 @@
 import java.io.File;
 import java.io.FileInputStream;
 import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
@@ -46,8 +44,6 @@
     
     private MediaFileBean bean =  new MediaFileBean();
     
-    // TODO: Ganesh - Move this to MediaFileBean
-    private String directoryId;
     private MediaFileDirectory directory;
     // file uploaded by the user
     private File uploadedFile = null;
@@ -69,15 +65,14 @@
     	refreshAllDirectories();
     	try {
             MediaFileManager mgr = WebloggerFactory.getWeblogger().getMediaFileManager();
-            if(!StringUtils.isEmpty(getDirectoryId())) {
-                setDirectory(mgr.getMediaFileDirectory(getDirectoryId()));
+            if(!StringUtils.isEmpty(bean.getDirectoryId())) {
+                setDirectory(mgr.getMediaFileDirectory(bean.getDirectoryId()));
             }
             else {
                 setDirectory(mgr.createRootMediaFileDirectory(getActionWeblog()));
             }
         } catch (WebloggerException ex) {
             log.error("Error looking up media file directory", ex);
-            // TODO: Ganesh - Handle exception
         }
     }
 
@@ -135,31 +130,8 @@
         if (StringUtils.isEmpty(this.uploadedFileFileName)) {
         	addError("error.upload.file");
         }
-        
-        if (getBean().getCopyrightText().length() > 1023) {
-        	addError("errors.maxlength", Arrays.asList("Copyright text", "1023"));
-        }
-
-        if (getBean().getDescription().length() > 255) {
-        	addError("errors.maxlength", Arrays.asList("File description", "255"));
-        }
-}
-    
-    /**
-     * Get the list of all categories for the action weblog, not including root.
-     */
-    public List<MediaFileDirectory> getDirectories() {
-        
-    	try {
-        	// TODO: Ganesh - do this in prepare method?
-    		MediaFileManager mgr = WebloggerFactory.getWeblogger().getMediaFileManager();
-            return mgr.getMediaFileDirectories(getActionWeblog());
-        } catch (WebloggerException ex) {
-            log.error("Error getting media file directory list for weblog - "+getWeblog(),
ex);
-            return Collections.emptyList();
-        }
     }
-
+    
     public MediaFileBean getBean() {
     	return bean;
     }
@@ -168,14 +140,6 @@
     	this.bean = b;
     }
     
-	public String getDirectoryId() {
-		return directoryId;
-	}
-
-	public void setDirectoryId(String id) {
-		this.directoryId = id;
-	}
-
 	public MediaFileDirectory getDirectory() {
 		return directory;
 	}

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java?rev=768475&r1=768474&r2=768475&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
(original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
Sat Apr 25 05:56:39 2009
@@ -124,7 +124,6 @@
             setAllDirectories(sortedDirList);
         } catch (WebloggerException ex) {
             log.error("Error looking up media file directories", ex);
-            // TODO: Ganesh - Handle exception
         }
     }
 

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileEdit.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileEdit.java?rev=768475&r1=768474&r2=768475&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileEdit.java
(original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileEdit.java
Sat Apr 25 05:56:39 2009
@@ -65,7 +65,6 @@
             }
         } catch (WebloggerException ex) {
             log.error("Error looking up media file directory", ex);
-            // TODO: Ganesh - Handle exception
         }
     }
 
@@ -127,21 +126,6 @@
         }
     }
     
-    /**
-     * Get the list of all categories for the action weblog, not including root.
-     */
-    public List<MediaFileDirectory> getDirectories() {
-        
-    	try {
-        	// TODO: Ganesh - do this in prepare method?
-    		MediaFileManager mgr = WebloggerFactory.getWeblogger().getMediaFileManager();
-            return mgr.getMediaFileDirectories(getActionWeblog());
-        } catch (WebloggerException ex) {
-            log.error("Error getting media file directory list for weblog - "+getWeblog(),
ex);
-            return Collections.EMPTY_LIST;
-        }
-    }
-
     public MediaFileBean getBean() {
     	return bean;
     }

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java?rev=768475&r1=768474&r2=768475&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java
(original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java
Sat Apr 25 05:56:39 2009
@@ -112,8 +112,9 @@
     	
     }
     
-    // TODO: Ganesh - use a different name
-    // Returns directory content in JSON format. 
+    /**
+     * Returns directory content in JSON format.
+     */
     public String fetchDirectoryContentLight() {
     	execute();
     	return "success.json";

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=768475&r1=768474&r2=768475&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 Apr 25 05:56:39 2009
@@ -967,6 +967,7 @@
 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.copyrightTextSize=Copyright text cannot be more than 1023 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.

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=768475&r1=768474&r2=768475&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
Sat Apr 25 05:56:39 2009
@@ -17,6 +17,25 @@
 --%>
 <%@ include file="/WEB-INF/jsps/taglibs-struts2.jsp" %>
 
+<script type="text/javascript">
+<!--
+function getFileName(fullName) {
+   var backslashIndex = fullName.lastIndexOf('/');
+   var fwdslashIndex = fullName.lastIndexOf('\\');
+   var fileName;
+   if (backslashIndex >= 0) {
+       fileName = fullName.substring(backslashIndex + 1);
+   } else if (fwdslashIndex >= 0) {
+       fileName = fullName.substring(fwdslashIndex + 1);
+   }
+   else {
+       fileName = fullName;
+   }
+   return fileName;
+}
+-->
+</script>
+
 <p class="subtitle">
     <s:text name="mediaFile.add.title"  />
 
@@ -35,7 +54,7 @@
                 <label for="title">File Location</label>
             </td>
             <td>
-                 <s:file name="uploadedFile" size="30" onchange="this.form['bean.name'].value=this.value"
/><br />
+                 <s:file name="uploadedFile" size="30" onchange="this.form['bean.name'].value=getFileName(this.value)"
/><br />
             </td>
         </tr>
 
@@ -80,7 +99,7 @@
                 <label for="status">Place file under</label>
             </td>
             <td>
-                <s:select name="directoryId" list="allDirectories" listKey="id" listValue="path"
/>
+                <s:select name="bean.directoryId" list="allDirectories" listKey="id" listValue="path"
/>
             </td>
        </tr>
 

Modified: 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=768475&r1=768474&r2=768475&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileSearch.jsp
(original)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileSearch.jsp
Sat Apr 25 05:56:39 2009
@@ -376,7 +376,13 @@
 
     <s:iterator id="mediaFile" value="pager.items">
     <li class="align-images">
-	<img style="border:1px solid #000000;margin:5px;" border="0" src='<s:url value="/roller-ui/rendering/media-resources/%{#mediaFile.id}"
/>' width="120px" height="100px" alt="mediaFolder.png"/><br/>
+	<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 style="border:1px solid #000000;margin:5px;" border="0" src='<s:property value="%{mediaFileURL}"
/>' width="120px" height="100px" alt="mediaFolder.png"/><br/>
 	 <div style="clear:left;width:130px;margin-left:5px;"><label><s:property
 value="#mediaFile.name" /></label>
 <div style="padding-top:5px;">   <!--  one -->



Mime
View raw message