roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r797811 - /roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java
Date Sat, 25 Jul 2009 18:07:41 GMT
Author: snoopdave
Date: Sat Jul 25 18:07:40 2009
New Revision: 797811

URL: http://svn.apache.org/viewvc?rev=797811&view=rev
Log:
fixing formatting

Modified:
    roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java

Modified: roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java
URL: http://svn.apache.org/viewvc/roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java?rev=797811&r1=797810&r2=797811&view=diff
==============================================================================
--- roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java
(original)
+++ roller/trunk/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileView.java
Sat Jul 25 18:07:40 2009
@@ -15,7 +15,6 @@
  * copyright in this work, please see the NOTICE file in the top level
  * directory of this distribution.
  */
-
 package org.apache.roller.weblogger.ui.struts2.editor;
 
 import java.util.ArrayList;
@@ -44,29 +43,24 @@
  */
 @SuppressWarnings("serial")
 public class MediaFileView extends MediaFileBase {
+
     private static Log log = LogFactory.getLog(MediaFileView.class);
-    
     // Drop-down values for sorting media files.
     private static final List<KeyValueObject> SORT_OPTIONS;
 
     static {
-    	SORT_OPTIONS = Arrays.asList(
-        		new KeyValueObject("", ""),
-        		new KeyValueObject("name", "Name"),
-        		new KeyValueObject("date_uploaded", "Date Uploaded"),
-        		new KeyValueObject("type", "Type")
-        		); 
+        SORT_OPTIONS = Arrays.asList(
+                new KeyValueObject("", ""),
+                new KeyValueObject("name", "Name"),
+                new KeyValueObject("date_uploaded", "Date Uploaded"),
+                new KeyValueObject("type", "Type"));
     }
-
     private String directoryId;
     private String directoryPath;
     private MediaFileDirectory currentDirectory;
-    
     private String sortBy;
-
     private List<MediaFileDirectory> childDirectories;
     private List<MediaFile> childFiles;
-    
     private String newDirectoryName;
 
     public MediaFileView() {
@@ -74,59 +68,57 @@
         this.desiredMenu = "editor";
         this.pageTitle = "mediaFile.view.title";
     }
-    
+
     /**
      * Prepares view action
      */
     public void myPrepare() {
-    	refreshAllDirectories();
+        refreshAllDirectories();
     }
 
     /**
      * Create a new directory by name under current directory
      */
     public String createNewDirectory() {
-    	boolean dirCreated = false;
-		if (StringUtils.isEmpty(this.newDirectoryName)) {
-			addError("mediaFile.error.view.dirNameEmpty");
-		}
-		else if (this.newDirectoryName.contains("/")) {
-			addError("mediaFile.error.view.dirNameInvalid");
-		}
-		else {
-			try {
-				log.debug("Creating new directory - " + this.newDirectoryName);
-				MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
-				MediaFileDirectory parentDirectory = manager.getMediaFileDirectory(this.directoryId);
-				manager.createMediaFileDirectory(parentDirectory, this.newDirectoryName);
-				// flush changes
-				WebloggerFactory.getWeblogger().flush();
-				addMessage("mediaFile.directoryCreate.success");
-				dirCreated = true;
-			} catch (WebloggerException e) {
-	            log.error("Error creating new directory by path", e);
-	            // TODO: i18n
-	            addError("Error creating new directory by path");
-			}
-		}
-
-        
-		if (dirCreated) {
-			// Refresh list of directories so the newly created directory is included.
-			refreshAllDirectories();
-		}
-    	return execute();
-    	
+        boolean dirCreated = false;
+        if (StringUtils.isEmpty(this.newDirectoryName)) {
+            addError("mediaFile.error.view.dirNameEmpty");
+        } else if (this.newDirectoryName.contains("/")) {
+            addError("mediaFile.error.view.dirNameInvalid");
+        } else {
+            try {
+                log.debug("Creating new directory - " + this.newDirectoryName);
+                MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+                MediaFileDirectory parentDirectory = manager.getMediaFileDirectory(this.directoryId);
+                manager.createMediaFileDirectory(parentDirectory, this.newDirectoryName);
+                // flush changes
+                WebloggerFactory.getWeblogger().flush();
+                addMessage("mediaFile.directoryCreate.success");
+                dirCreated = true;
+            } catch (WebloggerException e) {
+                log.error("Error creating new directory by path", e);
+                // TODO: i18n
+                addError("Error creating new directory by path");
+            }
+        }
+
+
+        if (dirCreated) {
+            // Refresh list of directories so the newly created directory is included.
+            refreshAllDirectories();
+        }
+        return execute();
+
     }
-    
+
     /**
      * Returns directory content in JSON format.
      */
     public String fetchDirectoryContentLight() {
-    	execute();
-    	return "success.json";
+        execute();
+        return "success.json";
     }
-    
+
     /**
      * Fetches and displays list of media file for the given directory.
      * The directory could be chosen by ID or path.
@@ -135,98 +127,94 @@
      */
     @SkipValidation
     public String execute() {
-		MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
-		try {
-			MediaFileDirectory directory;
-			if (this.directoryId != null) {
-				directory = manager.getMediaFileDirectory(this.directoryId);
-			}
-			else if (this.directoryPath != null){
-				directory = manager.getMediaFileDirectoryByPath(getActionWeblog(), this.directoryPath);
-				this.directoryId = directory.getId();
-			}
-			else {
-				directory = manager.getMediaFileRootDirectory(getActionWeblog());
-				this.directoryId = directory.getId();
-			}
-
-			this.childDirectories = new ArrayList<MediaFileDirectory>();
-			this.childDirectories.addAll(directory.getChildDirectories());
-			
-			this.childFiles = new ArrayList<MediaFile>();
-			this.childFiles.addAll(directory.getMediaFiles());
-			
-			if (!StringUtils.isEmpty(this.sortBy)) {
-				if ("name".equals(sortBy)) {
-					Collections.sort(this.childDirectories, new MediaFileDirectoryComparator(DirectoryComparatorType.NAME));
-					Collections.sort(this.childFiles, new MediaFileComparator(MediaFileComparatorType.NAME));
-				}
-				else if ("type".equals(sortBy)) {
-					Collections.sort(this.childFiles, new MediaFileComparator(MediaFileComparatorType.TYPE));
-				}
-				else if ("date_uploaded".equals(sortBy)) {
-					Collections.sort(this.childFiles, new MediaFileComparator(MediaFileComparatorType.DATE_UPLOADED));
-				}
-			}
-			
-			this.currentDirectory = directory;
-			
-    		return SUCCESS;
+        MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+        try {
+            MediaFileDirectory directory;
+            if (this.directoryId != null) {
+                directory = manager.getMediaFileDirectory(this.directoryId);
+            } else if (this.directoryPath != null) {
+                directory = manager.getMediaFileDirectoryByPath(getActionWeblog(), this.directoryPath);
+                this.directoryId = directory.getId();
+            } else {
+                directory = manager.getMediaFileRootDirectory(getActionWeblog());
+                this.directoryId = directory.getId();
+            }
+
+            this.childDirectories = new ArrayList<MediaFileDirectory>();
+            this.childDirectories.addAll(directory.getChildDirectories());
+
+            this.childFiles = new ArrayList<MediaFile>();
+            this.childFiles.addAll(directory.getMediaFiles());
+
+            if (!StringUtils.isEmpty(this.sortBy)) {
+                if ("name".equals(sortBy)) {
+                    Collections.sort(this.childDirectories, new MediaFileDirectoryComparator(DirectoryComparatorType.NAME));
+                    Collections.sort(this.childFiles, new MediaFileComparator(MediaFileComparatorType.NAME));
+                } else if ("type".equals(sortBy)) {
+                    Collections.sort(this.childFiles, new MediaFileComparator(MediaFileComparatorType.TYPE));
+                } else if ("date_uploaded".equals(sortBy)) {
+                    Collections.sort(this.childFiles, new MediaFileComparator(MediaFileComparatorType.DATE_UPLOADED));
+                }
+            }
+
+            this.currentDirectory = directory;
+
+            return SUCCESS;
         } catch (FileIOException ex) {
-        	log.error("Error viewing media file directory ", ex);
+            log.error("Error viewing media file directory ", ex);
             addError("MediaFile.error.view");
-		} catch (Exception e) {
+        } catch (Exception e) {
             log.error("Error viewing media file directory ", e);
             addError("MediaFile.error.view");
-		}
-		return SUCCESS;
+        }
+        return SUCCESS;
     }
-    
+
     /**
      * Returns the hierarchy of the current directory. This is useful in
      * displaying path information as breadcrumb.
      */
     public List<KeyValueObject> getCurrentDirectoryHierarchy() {
-    	List<KeyValueObject> directoryHierarchy = new ArrayList<KeyValueObject>();
+        List<KeyValueObject> directoryHierarchy = new ArrayList<KeyValueObject>();
 
-    	directoryHierarchy.add(new KeyValueObject("/", "root"));
-    	String fullPath = this.currentDirectory.getPath();
-    	if (fullPath.length() > 1) {
-        	String[] directoryNames = fullPath.substring(1).split("/");
-        	String directoryPath = "";
-        	for (String directoryName: directoryNames) {
-        		directoryPath = directoryPath + "/" + directoryName; 
-            	directoryHierarchy.add(new KeyValueObject(directoryPath, directoryName));
-        	}
-    	}
-    	return directoryHierarchy;
+        directoryHierarchy.add(new KeyValueObject("/", "root"));
+        String fullPath = this.currentDirectory.getPath();
+        if (fullPath.length() > 1) {
+            String[] directoryNames = fullPath.substring(1).split("/");
+            String directoryPath = "";
+            for (String directoryName : directoryNames) {
+                directoryPath = directoryPath + "/" + directoryName;
+                directoryHierarchy.add(new KeyValueObject(directoryPath, directoryName));
+            }
+        }
+        return directoryHierarchy;
     }
-    
+
     /**
      * Delete selected media files.
      * 
      */
     public String deleteSelected() {
-    	doDeleteSelected();
-    	return execute();
+        doDeleteSelected();
+        return execute();
     }
-    
+
     /**
      * Delete selected media file
      * 
      */
     public String delete() {
-    	doDeleteMediaFile();
-    	return execute();
+        doDeleteMediaFile();
+        return execute();
     }
-    
+
     /**
      * Include selected media file in gallery
      * 
      */
     public String includeInGallery() {
-    	doIncludeMediaFileInGallery();
-    	return execute();
+        doIncludeMediaFileInGallery();
+        return execute();
     }
 
     /**
@@ -235,70 +223,69 @@
      */
     public String moveSelected() {
         doMoveSelected();
-    	return execute();
+        return execute();
     }
-    
+
     public void myValidate() {
     }
-    
-	public String getDirectoryId() {
-		return directoryId;
-	}
-
-	public void setDirectoryId(String id) {
-		this.directoryId = id;
-	}
-
-	public List<MediaFileDirectory> getChildDirectories() {
-		return childDirectories;
-	}
-
-	public void setChildDirectories(List<MediaFileDirectory> directories) {
-		this.childDirectories = directories;
-	}
-
-	public List<MediaFile> getChildFiles() {
-		return childFiles;
-	}
-
-	public void setChildFiles(List<MediaFile> files) {
-		this.childFiles = files;
-	}
-
-	public String getNewDirectoryName() {
-		return newDirectoryName;
-	}
-
-	public void setNewDirectoryName(String newDirectoryName) {
-		this.newDirectoryName = newDirectoryName;
-	}
-
-	public MediaFileDirectory getCurrentDirectory() {
-		return currentDirectory;
-	}
-
-	public void setCurrentDirectory(MediaFileDirectory currentDirectory) {
-		this.currentDirectory = currentDirectory;
-	}
-
-	public String getDirectoryPath() {
-		return directoryPath;
-	}
-
-	public void setDirectoryPath(String path) {
-		this.directoryPath = path;
-	}
-
-	public String getSortBy() {
-		return sortBy;
-	}
-
-	public void setSortBy(String sortBy) {
-		this.sortBy = sortBy;
-	}
 
-    public List<KeyValueObject> getSortOptions() {
-    	return SORT_OPTIONS;
+    public String getDirectoryId() {
+        return directoryId;
+    }
+
+    public void setDirectoryId(String id) {
+        this.directoryId = id;
+    }
+
+    public List<MediaFileDirectory> getChildDirectories() {
+        return childDirectories;
+    }
+
+    public void setChildDirectories(List<MediaFileDirectory> directories) {
+        this.childDirectories = directories;
     }
 
+    public List<MediaFile> getChildFiles() {
+        return childFiles;
+    }
+
+    public void setChildFiles(List<MediaFile> files) {
+        this.childFiles = files;
+    }
+
+    public String getNewDirectoryName() {
+        return newDirectoryName;
+    }
+
+    public void setNewDirectoryName(String newDirectoryName) {
+        this.newDirectoryName = newDirectoryName;
+    }
+
+    public MediaFileDirectory getCurrentDirectory() {
+        return currentDirectory;
+    }
+
+    public void setCurrentDirectory(MediaFileDirectory currentDirectory) {
+        this.currentDirectory = currentDirectory;
+    }
+
+    public String getDirectoryPath() {
+        return directoryPath;
+    }
+
+    public void setDirectoryPath(String path) {
+        this.directoryPath = path;
+    }
+
+    public String getSortBy() {
+        return sortBy;
+    }
+
+    public void setSortBy(String sortBy) {
+        this.sortBy = sortBy;
+    }
+
+    public List<KeyValueObject> getSortOptions() {
+        return SORT_OPTIONS;
+    }
 }



Mime
View raw message