roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r821455 - in /roller/trunk/apps/weblogger: src/java/org/apache/roller/weblogger/business/ src/java/org/apache/roller/weblogger/business/jpa/ src/java/org/apache/roller/weblogger/pojos/ src/java/org/apache/roller/weblogger/ui/struts2/editor/...
Date Sun, 04 Oct 2009 02:14:50 GMT
Author: snoopdave
Date: Sun Oct  4 02:14:50 2009
New Revision: 821455

URL: http://svn.apache.org/viewvc?rev=821455&view=rev
Log:
Fix for https://issues.apache.org/jira/browse/ROL-1837
"Media Blogging: allow move and delete of directories"


Modified:
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManager.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAMediaFileManagerImpl.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectory.java
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
    roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties
    roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp
    roller/trunk/apps/weblogger/web/roller-ui/styles/roller.css

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManager.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManager.java?rev=821455&r1=821454&r2=821455&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManager.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/MediaFileManager.java
Sun Oct  4 02:14:50 2009
@@ -164,6 +164,20 @@
             throws WebloggerException;
 
     /**
+     * Move a set of media files to a new directory.
+     */
+    public void moveMediaFileDirectories(
+            Collection<MediaFileDirectory> mediaFilesDir, MediaFileDirectory directory)
+            throws WebloggerException;
+
+    /**
+     * Move one media file to a new directory.
+     */
+    public void moveMediaFileDirectory(
+            MediaFileDirectory mediaFileDir, MediaFileDirectory directory)
+            throws WebloggerException;
+
+    /**
      * Return recently added media files that are public.
      */
     public List<MediaFile> fetchRecentPublicMediaFiles(int length)
@@ -175,4 +189,12 @@
      */
     public void removeAllFiles(Weblog website) throws WebloggerException;
 
+    /**
+     * Remove media file directory
+     * @param weblog
+     * @param mediaFileDir
+     */
+    public void removeMediaFileDirectory(MediaFileDirectory mediaFileDir)
+            throws WebloggerException;
+
 }

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAMediaFileManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAMediaFileManagerImpl.java?rev=821455&r1=821454&r2=821455&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAMediaFileManagerImpl.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAMediaFileManagerImpl.java
Sun Oct  4 02:14:50 2009
@@ -96,8 +96,23 @@
     /**
      * {@inheritDoc}
      */
+    public void moveMediaFileDirectories(Collection<MediaFileDirectory> mediaFileDirs,
MediaFileDirectory targetDir)
+            throws WebloggerException {
+
+        for (MediaFileDirectory mediaFileDir : mediaFileDirs) {
+            mediaFileDir.setParent(targetDir);
+            this.strategy.store(mediaFileDir);
+        }
+        // update weblog last modified date.  date updated by saveWebsite()
+        roller.getWeblogManager().saveWeblog(targetDir.getWeblog());
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public void moveMediaFiles(Collection<MediaFile> mediaFiles, MediaFileDirectory
targetDirectory)
             throws WebloggerException {
+
         for (MediaFile mediaFile : mediaFiles) {
             mediaFile.setDirectory(targetDirectory);
             this.strategy.store(mediaFile);
@@ -117,6 +132,14 @@
     /**
      * {@inheritDoc}
      */
+    public void moveMediaFileDirectory(MediaFileDirectory mediaFileDir, MediaFileDirectory
targetDirectory)
+            throws WebloggerException {
+        moveMediaFileDirectories(Arrays.asList(mediaFileDir), targetDirectory);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
     public MediaFileDirectory createMediaFileDirectory(MediaFileDirectory parentDirectory,
String newDirName)
             throws WebloggerException {
 
@@ -758,7 +781,7 @@
             }
         }
 
-        try { // flush changes to this directory
+        try { // flush changes to this directory 
             roller.flush();
 
             log.debug("Count of dirs  created: " + dirCount);
@@ -773,7 +796,7 @@
         removeMediaFileDirectory(getMediaFileRootDirectory(website));
     }
 
-    private void removeMediaFileDirectory(MediaFileDirectory dir) 
+    public void removeMediaFileDirectory(MediaFileDirectory dir) 
             throws WebloggerException {
 
         if (dir == null) return;
@@ -788,4 +811,5 @@
         }
         this.strategy.remove(dir);
     }
+
 }

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectory.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectory.java?rev=821455&r1=821454&r2=821455&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectory.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/pojos/MediaFileDirectory.java
Sun Oct  4 02:14:50 2009
@@ -63,6 +63,10 @@
         }
     }
 
+    public boolean isEmpty() {
+        return getChildDirectories().isEmpty() && getMediaFiles().isEmpty();
+    }
+
     /**
      * Database surrogate key.
      *

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java?rev=821455&r1=821454&r2=821455&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
Sun Oct  4 02:14:50 2009
@@ -41,6 +41,7 @@
 
     private static Log log = LogFactory.getLog(MediaFileBase.class);
     private String[] selectedMediaFiles;
+    private String[] selectedMediaFileDirectories;
     private String selectedDirectory;
     private String mediaFileId;
     private List<MediaFileDirectory> allDirectories;
@@ -92,25 +93,37 @@
      */
     protected void doDeleteSelected() {
         String[] fileIds = getSelectedMediaFiles();
-        if (fileIds != null && fileIds.length > 0) {
-            try {
+        String[] dirIds = getSelectedMediaFileDirectories();
+        try {
+            MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+
+            if (fileIds != null && fileIds.length > 0) {
                 log.debug("Processing delete of " + fileIds.length + " media files.");
-                MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
                 for (int index = 0; index < fileIds.length; index++) {
                     log.debug("Deleting media file - " + fileIds[index]);
                     MediaFile mediaFile = manager.getMediaFile(fileIds[index]);
                     manager.removeMediaFile(getActionWeblog(), mediaFile);
                 }
-                // flush changes
-                WebloggerFactory.getWeblogger().flush();
-                addMessage("mediaFile.delete.success");
-            } catch (WebloggerException e) {
-                log.error("Error deleting selected media files", e);
-                // TODO: i18n
-                addError("Error deleting selected media files");
             }
-        } else {
-            addError("mediaFile.error.noneSelectedForDelete");
+
+            if (dirIds != null && dirIds.length > 0) {
+                log.debug("Processing delete of " + dirIds.length + " media directories.");
+                manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+                for (int index = 0; index < dirIds.length; index++) {
+                    log.debug("Deleting media file directory - " + dirIds[index]);
+                    MediaFileDirectory mediaFileDir = manager.getMediaFileDirectory(dirIds[index]);
+                    manager.removeMediaFileDirectory(mediaFileDir);
+                }
+            }
+
+            // flush changes
+            WebloggerFactory.getWeblogger().flush();
+            addMessage("mediaFile.delete.success");
+
+        } catch (WebloggerException e) {
+            log.error("Error deleting selected media files", e);
+            // TODO: i18n
+            addError("Error deleting selected media files");
         }
     }
 
@@ -119,26 +132,40 @@
      */
     protected void doMoveSelected() {
         String[] fileIds = getSelectedMediaFiles();
-        if (fileIds != null && fileIds.length > 0) {
-            try {
+        String[] dirIds = getSelectedMediaFileDirectories();
+        try {
+            MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+
+            if (fileIds != null && fileIds.length > 0) {
                 log.debug("Processing move of " + fileIds.length + " media files.");
-                MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
-                MediaFileDirectory targetDirectory = manager.getMediaFileDirectory(this.selectedDirectory);
+                MediaFileDirectory targetDirectory =
+                        manager.getMediaFileDirectory(this.selectedDirectory);
                 for (int index = 0; index < fileIds.length; index++) {
                     log.debug("Moving media file - " + fileIds[index] + " to directory -
" + this.selectedDirectory);
                     MediaFile mediaFile = manager.getMediaFile(fileIds[index]);
                     manager.moveMediaFile(mediaFile, targetDirectory);
                 }
-                // flush changes
-                WebloggerFactory.getWeblogger().flush();
-                addMessage("mediaFile.move.success");
-            } catch (WebloggerException e) {
-                log.error("Error moving selected media files", e);
-                // TODO: i18n
-                addError("Error moving selected media files");
             }
-        } else {
-            addError("mediaFile.error.noneSelectedForMove");
+
+            if (dirIds != null && dirIds.length > 0) {
+                log.debug("Processing move of " + dirIds.length + " media files directories.");
+                MediaFileDirectory targetDirectory =
+                        manager.getMediaFileDirectory(this.selectedDirectory);
+                for (int index = 0; index < dirIds.length; index++) {
+                    log.debug("Moving media file - " + dirIds[index] + " to directory - "
+ this.selectedDirectory);
+                    MediaFileDirectory mediaFileDir = manager.getMediaFileDirectory(dirIds[index]);
+                    manager.moveMediaFileDirectory(mediaFileDir, targetDirectory);
+                }
+            }
+
+            // flush changes
+            WebloggerFactory.getWeblogger().flush();
+            addMessage("mediaFile.move.success");
+
+        } catch (WebloggerException e) {
+            log.error("Error moving selected media files", e);
+            // TODO: i18n
+            addError("Error moving selected media files");
         }
     }
 
@@ -205,4 +232,18 @@
     public void setOverlayMode(boolean mode) {
         this.overlayMode = mode;
     }
+
+    /**
+     * @return the selectedMediaFileDirectories
+     */
+    public String[] getSelectedMediaFileDirectories() {
+        return selectedMediaFileDirectories;
+    }
+
+    /**
+     * @param selectedMediaFileDirectories the selectedMediaFileDirectories to set
+     */
+    public void setSelectedMediaFileDirectories(String[] selectedMediaFileDirectories) {
+        this.selectedMediaFileDirectories = selectedMediaFileDirectories;
+    }
 }

Modified: roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties?rev=821455&r1=821454&r2=821455&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ roller/trunk/apps/weblogger/web/WEB-INF/classes/ApplicationResources.properties Sun Oct
 4 02:14:50 2009
@@ -1127,7 +1127,7 @@
 
 
 mediaFile.search.title=Search media files
-mediaFile.delete.confirm=Delete selected media files?
+mediaFile.delete.confirm=Delete selected media files and/or directories?
 mediaFile.move.confirm=Move selected media files?
 mediaFile.directoryCreate.success=New directory succesfully created.
 mediaFile.includeInGallery.success = Media file(s) successfully included in gallery.

Modified: roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp?rev=821455&r1=821454&r2=821455&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp (original)
+++ roller/trunk/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileView.jsp Sun Oct  4 02:14:50
2009
@@ -175,6 +175,9 @@
 <s:if test="childFiles || childDirectories || (pager && pager.items.size() >
0)">
 
   <s:form id="mediaFileViewForm" name="mediaFileViewForm" action="mediaFileView">
+    <s:hidden name="weblog" />
+    <s:hidden name="directoryId" />
+    <input type="hidden" name="mediaFileId" value="" />
 
     <%--
     <s:url id="mediaFileHierarchicalViewURL" action="mediaFileHierarchicalView">
@@ -185,16 +188,26 @@
     --%>
 
     <div class="control">
-        <span style="padding-left:20px"><s:text name="mediaFileView.sortby" /></span>
-        <s:select name="sortBy" list="sortOptions" listKey="key"
+
+        <span style="padding-left:20px">
+            <s:text name="mediaFileView.sortby" />
+            <s:select name="sortBy" list="sortOptions" listKey="key"
                   listValue="value"
                   onchange="document.mediaFileViewForm.submit();" />
         </span>
+
+        <span style="float:right">
+            <input type="button" style="padding-right:20px"
+               value='<s:text name="mediaFileView.deleteSelected" />' onclick="onDeleteSelected()"
/>
+
+            <input type="button" style="padding-left:20px"
+               value=<s:text name="mediaFileView.moveSelected" /> onclick="onMoveSelected()"
/>
+
+            <s:select name="selectedDirectory" list="allDirectories" listKey="id" listValue="path"
/>
+        </span>
+
     </div>
 
-    <s:hidden name="weblog" />
-    <s:hidden name="directoryId" />
-    <input type="hidden" name="mediaFileId" value="" />
 
 
     <%-- ***************************************************************** --%>
@@ -236,6 +249,11 @@
                         </div>
                         <div class="mediaObjectInfo">
                             <label><s:property value="#directory.name" /></label>
+                                <input type="checkbox" style="float:right"
+                                       name="selectedMediaFileDirectories"
+                                       value="<s:property value="#directory.id"/>"/>
+                                <inut type="hidden" id="mediadiridentity"
+                                       value="<s:property value='#directory.id'/>">
                         </div>
                     </li>
                 </s:iterator>
@@ -345,22 +363,6 @@
     <div style="clear:left;"></div>
 
 
-    <%-- ***************************************************************** --%>
-
-    <%-- Delete and move controls --%>
-
-    <br/>
-    <div class="control">
-        <input type="button" style="padding-left:20px"
-           value='<s:text name="mediaFileView.deleteSelected" />' onclick="onDeleteSelected()"
/>
-        <input type="button" style="padding-left:20px"
-           value=<s:text name="mediaFileView.moveSelected" /> onclick="onMoveSelected()"
/>
-        <span style="padding-left:20px">
-            <s:select name="selectedDirectory" list="allDirectories" listKey="id" listValue="path"
/>
-        </span>
-    </div>
-
-
   <s:if test="!pager">
     <br/>
     <br/>

Modified: roller/trunk/apps/weblogger/web/roller-ui/styles/roller.css
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/web/roller-ui/styles/roller.css?rev=821455&r1=821454&r2=821455&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/web/roller-ui/styles/roller.css (original)
+++ roller/trunk/apps/weblogger/web/roller-ui/styles/roller.css Sun Oct  4 02:14:50 2009
@@ -511,13 +511,17 @@
 }
 div.control {
     width: 100%;
+    height: 2.5em;
 }
 div.controlToggle {
     width: 100%;
     height: 25px;
 }
 .control input {
-    margin: 5px;
+    margin: 0.5em;
+}
+.control select {
+    margin: 0.5em;
 }
 a.controlToggle {
     margin: 5px;



Mime
View raw message