[richfaces-svn-commits] JBoss Rich Faces SVN: r12431 - in trunk/test-applications/realworld: ejb/src/main/java/org/richfaces/realworld/service and 8 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Jan 26 14:28:18 EST 2009


Author: amarkhel
Date: 2009-01-26 14:28:18 -0500 (Mon, 26 Jan 2009)
New Revision: 12431

Added:
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/SearchManager.java
Removed:
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchBean.java
Modified:
   trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java
   trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java
   trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java
   trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java
   trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java
   trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageComparator.java
   trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeAlbumItem.java
   trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ConversationState.java
   trunk/test-applications/realworld/web/src/main/webapp/includes/fileUpload/fileUploader.xhtml
   trunk/test-applications/realworld/web/src/main/webapp/includes/search.xhtml
   trunk/test-applications/realworld/web/src/main/webapp/includes/search/advancedSearch.xhtml
   trunk/test-applications/realworld/web/src/main/webapp/includes/search/searchResults.xhtml
Log:


Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -53,7 +53,11 @@
  * 
  * @author Andrey Markhel
  */
- at NamedQueries( { @NamedQuery(name = "album-byAlbumNameAndLogin", query = "from Album a where a.name=:albumName and a.owner.login=:login") })
+ at NamedQueries(
+		{ 
+			@NamedQuery(name = "album-byAlbumNameAndLogin", query = "from Album a where a.name=:albumName and a.owner.login=:login") 
+			}
+		)
 @Entity
 @Name("album")
 @Table(name = "albums")
@@ -106,12 +110,6 @@
 	@org.hibernate.annotations.ForeignKey(name = "FK_ALBUM_PARENT_ID")
 	private Album parent;
 
-	/**
-	 * No-arg constructor for JavaBean tools
-	 */
-	public Album() {
-	}
-
 	// ********************** Accessor Methods ********************** //
 
 	public List<Album> getChildAlbums() {
@@ -120,7 +118,7 @@
 
 	public void addChildAlbum(Album album) {
 		if (album == null)
-			throw new IllegalArgumentException("Null child category!");
+			throw new IllegalArgumentException("Null child!");
 		if (album.getParent() != null)
 			album.getParent().getChildAlbums().remove(album);
 		album.setParent(this);
@@ -129,7 +127,7 @@
 
 	public void removeChildAlbum(Album album) {
 		if (album == null)
-			throw new IllegalArgumentException("Null child category!");
+			throw new IllegalArgumentException("Null child!");
 		album.setParent(null);
 		childAlbums.remove(album);
 	}
@@ -142,17 +140,28 @@
 		this.parent = parent;
 	}
 
+	public String getAlbumPathFromParents(Album album,
+			String delimiter, boolean includeSelf) {
+		return this.getAlbumPathFromParents(album, new ArrayList<String>(), delimiter, includeSelf);
+	}
+	
 	public String getAlbumPathFromParents(Album album, List<String> list,
-			String delimiter) {
+			String delimiter, boolean includeSelf) {
 		if (album.getParent() == null) {
+			//If this album haven't parent - it is root, so add them first
 			list.add(album.getName() + delimiter);
-			return "";
+			//If it's method invoke on root album returned value will be dependent on flag
+			return includeSelf ? album.getName() + delimiter : "";
 		} else {
+			//recursive call
 			album.getParent().getAlbumPathFromParents(album.getParent(), list,
-					delimiter);
+					delimiter, includeSelf);
 		}
-		list.add(this.getName() + delimiter);
+		if(includeSelf){
+			list.add(this.getName() + delimiter);
+		}
 		String path = "";
+		//Create string representation of path
 		for (int i = 0; i < list.size(); i++) {
 			path += list.get(i);
 		}

Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -153,28 +153,12 @@
     )
     private List<User> sharedOwners = new ArrayList<User>();
 
-	/**
-	 * No-arg constructor for JavaBean tools
-	 */
-    public Image() {
-    }
-	
-	/**
-	 * Constructor
-	 * 
-	 * @param name - name of album
-	 * @param parent - link for parent album
-	 */
-    public Image(String name) {
-        this.name = name;
-    }
-
 	// ********************** Accessor Methods ********************** //
 
     /**
 	 * Getter for property id
 	 * 
-	 * @return id of album
+	 * @return id of image
 	 */
     public Long getId() {
         return id;
@@ -183,7 +167,7 @@
     /**
 	 * Getter for property name
 	 * 
-	 * @return name of album
+	 * @return name of image
 	 */
     public String getName() {
         return name;
@@ -192,7 +176,7 @@
 	/**
 	 * Setter for property name
 	 * 
-	 * @param name - name of album
+	 * @param name - name of image
 	 */
     public void setName(String name) {
         this.name = name;
@@ -209,7 +193,7 @@
 	/**
 	 * Getter for property description
 	 * 
-	 * @return description of album
+	 * @return description of image
 	 */
     public String getDescription() {
         return description;
@@ -218,7 +202,7 @@
 	/**
 	 * Setter for property description
 	 * 
-	 * @param description - description of album
+	 * @param description - description of image
 	 */
     public void setDescription(String description) {
         this.description = description;
@@ -320,10 +304,6 @@
 		return comments;
 	}
 
-	public void setComments(List<Comment> comments) {
-		this.comments = comments;
-	}
-
 	public Rank getRank() {
 		return rank;
 	}

Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -169,12 +169,6 @@
 	@OneToMany(mappedBy = "user", cascade = { CascadeType.ALL }, fetch = FetchType.LAZY)
     private List<FriendshipRequest> friendshipRequests = new ArrayList<FriendshipRequest>();
 
-	/**
-	 * No-arg constructor for JavaBean tools
-	 */
-    public User() {
-    }
-
 	public String getFirstName() {
 		return firstName;
 	}
@@ -230,18 +224,9 @@
 	public List<Album> getChildAlbums() {
 		return childAlbums;
 	}
-
-	public void setChildAlbums(List<Album> childAlbums) {
-		this.childAlbums = childAlbums;
-	}
 	
 	//---------------------------Business methods
 	
-	/**
-	 * This method add image to collection of images of current album
-	 * 
-	 * @param image - image to add
-	 */
     public void addAlbum(Album album) {
         if (album == null) {
             throw new IllegalArgumentException("Null album!");
@@ -253,11 +238,6 @@
         childAlbums.add(album);
     }
 
-	/**
-	 * This method remove image from collection of images of album
-	 * 
-	 * @param image - image to remove
-	 */
     public void removeAlbum(Album album) {
         if (album == null) {
             throw new IllegalArgumentException("Null album");
@@ -304,34 +284,18 @@
 		return friends;
 	}
 
-	public void setFriends(List<User> friends) {
-		this.friends = friends;
-	}
-
 	public List<Album> getFavoriteAlbums() {
 		return favoriteAlbums;
 	}
 
-	public void setFavoriteAlbums(List<Album> favoriteAlbums) {
-		this.favoriteAlbums = favoriteAlbums;
-	}
-
 	public List<Message> getMessages() {
 		return messages;
 	}
 
-	public void setMessages(List<Message> messages) {
-		this.messages = messages;
-	}
-
 	public List<FriendshipRequest> getFriendshipRequests() {
 		return friendshipRequests;
 	}
 
-	public void setFriendshipRequests(List<FriendshipRequest> friendshipRequests) {
-		this.friendshipRequests = friendshipRequests;
-	}
-
 	public void addFriendshipRequest(User owner) {
 		if (getFriendshipRequest(owner, this) != null) {
 			return;
@@ -359,15 +323,6 @@
 		return null;
 	}
 
-	public Album getAlbumByName(String albumName){
-		for(Album a : this.getChildAlbums()){
-			if(a.getName().equals(albumName)){
-				return a;
-			}
-		}
-		return null;
-	}
-
 	public void removeFromFavoriteAlbums(Album album) {
 		favoriteAlbums.remove(album);
 	}
@@ -399,8 +354,4 @@
 	public List<Image> getFavoriteImages() {
 		return favoriteImages;
 	}
-
-	public void setFavoriteImages(List<Image> favoriteImages) {
-		this.favoriteImages = favoriteImages;
-	}
 }
\ No newline at end of file

Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/Constants.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -1,8 +1,25 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007  Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
 package org.richfaces.realworld.service;
 
-import org.jboss.seam.annotations.In;
-import org.richfaces.realworld.service.IUserAction;
-
 public class Constants {
 
 	public static final String ERROR_ID = "mainform:error";

Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -78,12 +78,8 @@
 	}
 
 	public void vote(Image image, Long value) {
-		Long total = image.getRank().getTotal();
-		Long votes = image.getRank().getHits();
-		total += value;
-		votes++;
-		image.getRank().setHits(votes);
-		image.getRank().setTotal(total);
+		image.getRank().setHits(image.getRank().getHits() + 1);
+		image.getRank().setTotal(value += image.getRank().getTotal());
 		em.flush();
 	}
 }

Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageComparator.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageComparator.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/MessageComparator.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -26,7 +26,7 @@
 
 public class MessageComparator implements Comparator<Message> {
 
-		  public int compare(Message mes1, Message mes2) {
-		    return mes1.getDate().after(mes2.getDate())?-1:1;
-		  }
+	public int compare(Message mes1, Message mes2) {
+		return mes1.getDate().after(mes2.getDate()) ? -1 : 1;
+	}
 }

Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/SearchService.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -52,14 +52,7 @@
 			return null;
 		}
 		String fullQuery = null;
-		if(paramMap != null && paramMap.get(Constants.CASE_SENSITIVE_PARAMETER) != null){
-			boolean sensitive = (Boolean)paramMap.get(Constants.CASE_SENSITIVE_PARAMETER);
-			if(sensitive){
-				fullQuery = Constants.SEARCH_SENSITIVE_QUERY_BEGIN + additionalParams + Constants.SEARCH_QUERY_END;
-			}else{
-				fullQuery = Constants.SEARCH_QUERY_BEGIN + additionalParams + Constants.SEARCH_QUERY_END;
-			}
-		}
+		fullQuery = setupCaseForQuery(additionalParams, paramMap, fullQuery);
 		Query prepared = prepareQuery(fullQuery, additions.get(0), additionalParams, paramMap);
 		List<Image> tempResult = prepared.getResultList();
 		additions.remove(0);
@@ -92,6 +85,19 @@
 		return (List<String>)query.getResultList();
 	}
 	
+	private String setupCaseForQuery(String additionalParams,
+			Map<String, Object> paramMap, String fullQuery) {
+		if(paramMap != null && paramMap.get(Constants.CASE_SENSITIVE_PARAMETER) != null){
+			boolean sensitive = (Boolean)paramMap.get(Constants.CASE_SENSITIVE_PARAMETER);
+			if(sensitive){
+				fullQuery = Constants.SEARCH_SENSITIVE_QUERY_BEGIN + additionalParams + Constants.SEARCH_QUERY_END;
+			}else{
+				fullQuery = Constants.SEARCH_QUERY_BEGIN + additionalParams + Constants.SEARCH_QUERY_END;
+			}
+		}
+		return fullQuery;
+	}
+	
 	private Query prepareQuery(String fullQuery ,String searchPattern, String additionalParams,
 			Map<String, Object> paramMap) {
 		Query prepared = em.createQuery(fullQuery);

Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileManager.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -70,8 +70,12 @@
 		File file = new File(fullPath);
 		return file.exists() && file.isDirectory();
 	}
-
-	public void deleteDirectory(String directory) {
+	
+	public void deleteDirectory(String... directories) {
+		String directory = new String();
+		for (String chunk: directories){
+			directory += chunk + getFileSeparator();
+		}
 		String fullPath = getAbsolutePath(directory);
 		File file = new File(fullPath);
 		if(file.exists()){
@@ -82,6 +86,22 @@
 			file.delete();
 		}
 	}
+	
+	public String concat(String... directories){
+		String directory = new String();
+		for (String chunk: directories){
+			directory += chunk + getFileSeparator();
+		}
+		return directory;
+	}
+	
+	public String concatwithSlash(String... directories){
+		String directory = new String();
+		for (String chunk: directories){
+			directory += chunk + Constants.SLASH;
+		}
+		return directory;
+	}
 
 	public boolean renameDirectory(String directoryOld, String directoryNew){
 		String fullPath = getAbsolutePath(directoryOld);
@@ -90,7 +110,6 @@
 		createDirectoryIfNotExist(directoryNew);
 		if(fileNew.exists())
 			if( fileNew.isDirectory() ){
-				//throw new Exception(Constants.ALBUM_WITH_THIS_NAME_ALREADY_PRESENT);
 				return false;
 			}else{
 				fileNew.delete();
@@ -98,18 +117,31 @@
 		fileOld.renameTo(fileNew);
 		return true;
 	}
-
-	public void addDirectory(String directory) {
-		String fullPath = getAbsolutePath(directory);
+	
+	public void addDirectory(String... directories) {
+		String directory = new String();
+		for (String chunk: directories){
+			directory += chunk + getFileSeparator();
+		}
+		String fullPath = getAbsolutePath(removeSlashFromEnd(directory));
 		File file = new File(fullPath);
 		file.mkdirs();
 	}
 
-	public void addImage(String fileName, byte[] data) throws IOException {
+	private String removeSlashFromEnd(String directory) {
+		return directory.substring(0, directory.length() - 2);
+	}
+
+	public boolean addImage(String fileName, byte[] data) {
 		createDirectoryIfNotExist(fileName);
-		writeFileTodisk(data, fileName, 0, 0, "" );
-		writeFileTodisk(data, fileName, 50, 50, _MINI );
-		writeFileTodisk(data, fileName, 600, 400, _MEDIUM );
+		try {
+			writeFileTodisk(data, fileName, 0, 0, "" );
+			writeFileTodisk(data, fileName, 50, 50, _MINI );
+			writeFileTodisk(data, fileName, 600, 400, _MEDIUM );
+		} catch (IOException e) {
+			return false;
+		}
+		return true;
 	}
 	
 	private void writeFileTodisk(byte[] data, String fileName, int width, int height, String format) throws IOException{
@@ -140,57 +172,33 @@
 		String end = target.substring(target.lastIndexOf(Constants.DOT));
 		return begin + substitute + end;
 	}
-
-	public void deleteAllFromDirectory(String directory){
-		String fullPath = getAbsolutePath(directory);
-		File file = new File(fullPath);
-		if(file.exists()){
-			for(String f :file.list()){
-				File temp = new File(fullPath+getFileSeparator()+f);
-				temp.delete();
-			}
-		}else{
-			file.mkdirs();
-		}
-	}
 	
 	public void deleteImage(String fileName) {
 		String fullPath = getAbsolutePath(fileName);
-		File file = new File(fullPath);
+		deleteImage(new File(fullPath));
+		deleteImage(new File(transformPath(fullPath, _MINI)));
+		deleteImage(new File(transformPath(fullPath, _MEDIUM)));
+	}
+
+	private void deleteImage(File file){
 		if(file.exists()){
 			file.delete();
 		}
-		file = new File(transformPath(fullPath, _MINI));
-		if(file.exists()){
-			file.delete();
-		}
-		file = new File(transformPath(fullPath, _MEDIUM));
-		if(file.exists()){
-			file.delete();
-		}
 	}
-
+	
 	public void renameImage(String fileNameOld, String fileNameNew) {
 		createDirectoryIfNotExist(fileNameNew);
 		String fullPath = getAbsolutePath(fileNameOld);
-		File fileOld = new File(fullPath);
-		File fileNew = new File(getAbsolutePath(fileNameNew));
+		renameImage(new File(getAbsolutePath(fileNameNew)), new File(fullPath));
+		renameImage(new File(getAbsolutePath(transformPath(fileNameNew, _MINI))), new File(transformPath(fullPath, _MINI)));
+		renameImage(new File(getAbsolutePath(transformPath(fileNameNew, _MEDIUM))), new File(transformPath(fullPath, _MEDIUM)));
+	}
+	
+	private void renameImage(File fileNew, File fileOld){
 		if(fileNew.exists()){
 			fileNew.delete();
 		}
 		fileOld.renameTo(fileNew);
-		fileOld = new File(transformPath(fullPath, _MINI));
-		fileNew = new File(getAbsolutePath(transformPath(fileNameNew, _MINI)));
-		if(fileNew.exists()){
-			fileNew.delete();
-		}
-		fileOld.renameTo(fileNew);
-		fileOld = new File(transformPath(fullPath, _MEDIUM));
-		fileNew = new File(getAbsolutePath(transformPath(fileNameNew, _MEDIUM)));
-		if(fileNew.exists()){
-			fileNew.delete();
-		}
-		fileOld.renameTo(fileNew);
 	}
 
 	private void createDirectoryIfNotExist(String fileNameNew) {

Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -22,7 +22,6 @@
 package org.richfaces.realworld.fileupload;
 
 import java.io.ByteArrayInputStream;
-import java.io.IOException;
 import java.io.InputStream;
 import java.io.Serializable;
 import java.util.ArrayList;
@@ -30,7 +29,6 @@
 import java.util.List;
 
 import javax.faces.model.SelectItem;
-import org.richfaces.realworld.service.Constants;
 
 import org.jboss.seam.ScopeType;
 import org.jboss.seam.annotations.In;
@@ -45,6 +43,7 @@
 import org.richfaces.realworld.domain.MetaTag;
 import org.richfaces.realworld.domain.Rank;
 import org.richfaces.realworld.domain.User;
+import org.richfaces.realworld.service.Constants;
 import org.richfaces.realworld.util.ConversationState;
 
 import com.drew.imaging.jpeg.JpegMetadataReader;
@@ -86,6 +85,8 @@
 	private String selectedMode;
 	
 	private int fileQuantity = 1;
+	
+	private boolean immediateUpload = false;
 
 	private boolean fileUploadRendered;
 
@@ -128,11 +129,8 @@
 			if (file.isSelected()) {
 				// Save file to disk
 				String fileName = fileManager.transformToServerPath(file.getImage().getPath());
-				try {
-					fileManager.addImage(fileName, file.getData());
-				} catch (IOException e) {
+				if(!fileManager.addImage(fileName, file.getData())){
 					Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(Constants.FILE_SAVE_ERROR));
-					return;
 				}
 				// Update domain model
 				Events.instance().raiseEvent(Constants.ADD_IMAGE_EVENT, file.getImage());
@@ -149,11 +147,8 @@
 			// Save file to disk
 			String fileName = fileManager.transformToServerPath(file.getImage()
 					.getPath());
-			try {
-				fileManager.addImage(fileName, file.getData());
-			} catch (IOException e) {
+			if(!fileManager.addImage(fileName, file.getData())){
 				Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(Constants.FILE_SAVE_ERROR));
-				return;
 			}
 			// Update domain model
 			Events.instance().raiseEvent(Constants.ADD_IMAGE_EVENT, file.getImage());
@@ -176,10 +171,12 @@
 	}
 
 	public void changeMode() {
-		if (this.getSelectedMode().equals(Constants.SINGLE)) {
-			this.setFileQuantity(Constants.SINGLE_MODE_FILE_QUANTITY);
-		} else if (this.getSelectedMode().equals(Constants.MULTY)) {
-			this.setFileQuantity(Constants.MULTY_MODE_FILE_QUANTITY);
+		if (getSelectedMode().equals(Constants.SINGLE)) {
+			setFileQuantity(Constants.SINGLE_MODE_FILE_QUANTITY);
+			setImmediateUpload(false);
+		} else if (getSelectedMode().equals(Constants.MULTY)) {
+			setFileQuantity(Constants.MULTY_MODE_FILE_QUANTITY);
+			setImmediateUpload(true);
 		}
 	}
 
@@ -214,7 +211,7 @@
 		image.setName(SAMPLE_NAME);
 		image.setSize(file.getLength() / Constants.KB);
 		String albumPath = conversationState.getSelectedAlbum().getAlbumPathFromParents(conversationState.getSelectedAlbum(),
-			new ArrayList<String>(), Constants.SLASH)+ conversationState.getSelectedAlbum().getName() + Constants.SLASH;
+			 Constants.SLASH, true);
 		image.setPath(user.getLogin() + Constants.SLASH + albumPath + item.getFileName());
 		image.setAlbumName(conversationState.getSelectedAlbum().getName());
 		image.setAlbum(conversationState.getSelectedAlbum());
@@ -278,4 +275,12 @@
 			image.setCameraModel(cameraModel);
 		}
 	}
+
+	public boolean isImmediateUpload() {
+		return immediateUpload;
+	}
+
+	public void setImmediateUpload(boolean immediateUpload) {
+		this.immediateUpload = immediateUpload;
+	}
 }
\ No newline at end of file

Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/ImageLoader.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -37,6 +37,7 @@
 import org.jboss.seam.annotations.In;
 import org.jboss.seam.annotations.Name;
 import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.core.Events;
 
 @Name("imageLoader")
 @Scope(ScopeType.CONVERSATION)
@@ -73,8 +74,8 @@
 				paintData = bufferedInputStream;
 				paintData.read(data);
 			} catch (FileNotFoundException e) {
-				// TODO Auto-generated catch block
-				e.printStackTrace();
+				Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(Constants.FILE_PROCESSING_ERROR));
+				return;
 			} finally {
 				fileInputStream.close();
 				bufferedInputStream.close();
@@ -94,14 +95,15 @@
 			BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
 			InputStream paintData = bufferedInputStream;
 			if (null == paintData) {
-				// throw new Exception("");
-				// TODO
+				Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(Constants.FILE_PROCESSING_ERROR));
+				return;
 			}
 			try {
 				BufferedImage images = ImageIO.read(paintData);
 				ImageIO.write(images, Constants.JPEG, out);
 			} catch (Exception e) {
-
+				Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception(Constants.FILE_PROCESSING_ERROR));
+				return;
 			} finally {
 				fileInputStream.close();
 				bufferedInputStream.close();

Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -20,9 +20,6 @@
  */
 package org.richfaces.realworld.manager;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import org.jboss.seam.ScopeType;
 import org.jboss.seam.annotations.In;
 import org.jboss.seam.annotations.Name;
@@ -33,10 +30,10 @@
 import org.richfaces.realworld.domain.Album;
 import org.richfaces.realworld.domain.User;
 import org.richfaces.realworld.fileupload.FileManager;
+import org.richfaces.realworld.service.Constants;
 import org.richfaces.realworld.service.IAlbumAction;
 import org.richfaces.realworld.tree.TreeAlbumItem;
 import org.richfaces.realworld.tree.TreeMyAlbumsItem;
-import org.richfaces.realworld.service.Constants;
 import org.richfaces.realworld.util.ConversationState;
 
 @Name("albumManager")
@@ -61,61 +58,98 @@
 	private ConversationState conversationState;
 	
 	public void addAlbum(){
-		//Update domain model
 		albumAction.addAlbum(album);
-		//Correcting tree
-		TreeNode<Object> parent = findParentTreeNode();
-		TreeAlbumItem albumItem = new TreeAlbumItem(album.getId(), parent, album, treeMyAlbumsItem);
-		treeMyAlbumsItem.addAlbumToTree(parent, albumItem);
-		//Create directory on disk
-		List<String> list = new ArrayList<String>();
-		String albumPath = album.getAlbumPathFromParents(album, list, fileManager.getFileSeparator()) + album.getName();
-		fileManager.addDirectory(user.getLogin() + fileManager.getFileSeparator() + albumPath);
+		addAlbumToTree();
+		addDirectory();
 		//Update conversation state
 		conversationState.setSelectedImage(null);
-		conversationState.setSelectedAlbum(albumItem.getAlbum());
-		
+		conversationState.setSelectedAlbum(album);
 	}
-
-	private TreeNode<Object> findParentTreeNode() {
-		TreeNode<Object> parent = null;
-		if(null == album.getParent()){
-			parent = treeMyAlbumsItem;
-		}else{
-			parent = treeMyAlbumsItem.getNode(album.getParent().getName());
-		}
-		return parent;
-	}
-
+	
 	public void editAlbum(Album album){
 		boolean nameChanged = !album.getName().equals(album.getChangedName());
 		if(nameChanged){
-			String directoryOld = user.getLogin() + fileManager.getFileSeparator() + album.getAlbumPathFromParents(album, new ArrayList<String>(),fileManager.getFileSeparator() )+album.getName();
-			Album oldAlbum = ((TreeAlbumItem)treeMyAlbumsItem.getNode(album.getName())).getAlbum();
-			String directoryNew = user.getLogin() + fileManager.getFileSeparator() + oldAlbum.getAlbumPathFromParents(oldAlbum, new ArrayList<String>(),fileManager.getFileSeparator() )+album.getChangedName();
-			if(!fileManager.renameDirectory(directoryOld, directoryNew)){
+			Album oldAlbum = getOldTreeNode(album);
+			if(!renameDirectory(album, oldAlbum)){
 				Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.ALBUM_WITH_THIS_NAME_ALREADY_PRESENT);
 				return;
 			}
-			String albumOld = user.getLogin() + Constants.SLASH + album.getAlbumPathFromParents(album, new ArrayList<String>(),Constants.SLASH )+album.getName();
-			String albumNew = user.getLogin() + Constants.SLASH + oldAlbum.getAlbumPathFromParents(oldAlbum, new ArrayList<String>(),Constants.SLASH )+album.getChangedName();
-			albumAction.renameAllImagesFromAlbumAndChilds(album, albumOld, albumNew);
+			renameImagesFromAlbum(album, oldAlbum);
 			album.setName(album.getChangedName());
 			album.setChangedName(null);
 		}
 		albumAction.editAlbum(album);
 		treeMyAlbumsItem.updateChild(album);
+		conversationState.setSelectedAlbum(album);
 	}
-
+	
 	public void deleteAlbum(Album album){
 		//Update domain model
-		String albumName = album.getName();
+		String albumName = album.getAlbumPathFromParents(album, fileManager.getFileSeparator(), true);
 		albumAction.deleteAlbum(album);
-		//Update tree
+		removeFromTree(album);
+		deleteDirectory(albumName);
+		conversationState.setSelectedImage(null);
+		conversationState.setSelectedAlbum(null);
+	}
+
+	private void renameImagesFromAlbum(Album album, Album oldAlbum) {
+		String albumOld = getOldAlbumPath(album);
+		String albumNew = getNewAlbumPath(album, oldAlbum);
+		albumAction.renameAllImagesFromAlbumAndChilds(album, albumOld, albumNew);
+	}
+
+	private boolean renameDirectory(Album album, Album oldAlbum) {
+		String directoryOld = getOldDirectory(album);
+		String directoryNew = getNewDirectory(album, oldAlbum);
+		return fileManager.renameDirectory(directoryOld, directoryNew);
+	}
+
+	private String getNewAlbumPath(Album album, Album oldAlbum) {
+		return fileManager.concatwithSlash(user.getLogin(), oldAlbum.getAlbumPathFromParents(oldAlbum, Constants.SLASH, false ), album.getChangedName());
+	}
+
+	private String getOldAlbumPath(Album album) {
+		return fileManager.concatwithSlash(user.getLogin(), album.getAlbumPathFromParents(album, Constants.SLASH, true ));
+	}
+
+	private String getNewDirectory(Album album, Album oldAlbum) {
+		return fileManager.concat(user.getLogin(), oldAlbum.getAlbumPathFromParents(oldAlbum, fileManager.getFileSeparator(), false ), album.getChangedName());
+	}
+
+	private Album getOldTreeNode(Album album) {
+		return ((TreeAlbumItem)treeMyAlbumsItem.getNode(album.getName())).getAlbum();
+	}
+
+	private String getOldDirectory(Album album) {
+		return fileManager.concat(user.getLogin() ,album.getAlbumPathFromParents(album, fileManager.getFileSeparator(), true ));
+	}
+	
+	private void removeFromTree(Album album) {
 		TreeAlbumItem oldAlbum = (TreeAlbumItem)treeMyAlbumsItem.getNode(album.getName());
 		oldAlbum.getParent().removeChild(album.getId());
-		//Delete from disk
-		fileManager.deleteDirectory(user.getLogin() + fileManager.getFileSeparator() + albumName);
 	}
 
+	private void deleteDirectory(String albumName) {
+		fileManager.deleteDirectory(user.getLogin(), albumName);
+	}
+
+	private void addDirectory() {
+		String albumPath = album.getAlbumPathFromParents(album, fileManager.getFileSeparator(), true) ;
+		fileManager.addDirectory(user.getLogin(), albumPath);
+	}
+
+	private void addAlbumToTree() {
+		TreeNode<Object> parent = findParentTreeNode();
+		TreeAlbumItem albumItem = new TreeAlbumItem(album.getId(), parent, album, treeMyAlbumsItem);
+		treeMyAlbumsItem.addAlbumToTree(parent, albumItem);
+	}
+
+	private TreeNode<Object> findParentTreeNode() {
+		if(null == album.getParent()){
+			return treeMyAlbumsItem;
+		}else{
+			return treeMyAlbumsItem.getNode(album.getParent().getName());
+		}
+	}
 }

Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -75,7 +75,7 @@
 
     public boolean authenticate()
     {
-    	if (null == credentials.getUsername() || credentials.getUsername().equals("")) {
+    	if (wantLoginAnonymous()) {
 			identity.addRole(Constants.GUEST_ROLE);
 			userAction.loginAnonymous();
 			Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,NavigationEnum.SEARCH);
@@ -85,9 +85,7 @@
 			User user = userAction.login(credentials.getUsername(), credentials.getPassword());
 			if (user != null) {
 				identity.addRole(Constants.ADMIN_ROLE);
-				if (!fileManager.isDirectoryPresent(credentials.getUsername())) {
-					fileManager.addDirectory(credentials.getUsername());
-				}
+				setupCatalogForUser();
 				conversationState.setSelectedUser(user);
 				Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,NavigationEnum.IMAGE_PREVIEW);
 				return true;
@@ -98,6 +96,16 @@
 		}
 		return false; 
     }
+
+	private void setupCatalogForUser() {
+		if (!fileManager.isDirectoryPresent(credentials.getUsername())) {
+			fileManager.addDirectory(credentials.getUsername());
+		}
+	}
+
+	private boolean wantLoginAnonymous() {
+		return null == credentials.getUsername() || credentials.getUsername().equals("");
+	}
     
     @End
     public String register(User user){

Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -20,8 +20,6 @@
  */
 package org.richfaces.realworld.manager;
 
-import java.util.ArrayList;
-
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import org.richfaces.realworld.service.Constants;
@@ -81,13 +79,13 @@
 		}else{
 			return;
 		}
-		String directoryOld = user.getLogin() + fileManager.getFileSeparator() + dragValue.getAlbumPathFromParents(dragValue, new ArrayList<String>(), fileManager.getFileSeparator() )+ dragValue.getName();
+		String directoryOld = user.getLogin() + fileManager.getFileSeparator() + dragValue.getAlbumPathFromParents(dragValue,  fileManager.getFileSeparator(), true );
 		String directoryNew = user.getLogin() + fileManager.getFileSeparator() + dragValue.getName();
 		if(!fileManager.renameDirectory(directoryOld, directoryNew)){
 			Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.ALBUM_WITH_THIS_NAME_ALREADY_PRESENT);
 			return;
 		}
-		String albumOld = user.getLogin() + Constants.SLASH + dragValue.getAlbumPathFromParents(dragValue, new ArrayList<String>(), Constants.SLASH );
+		String albumOld = user.getLogin() + Constants.SLASH + dragValue.getAlbumPathFromParents(dragValue, Constants.SLASH, false );
 		String albumNew = user.getLogin() + Constants.SLASH;
 		TreeAlbumItem item = (TreeAlbumItem)treeMyAlbumsItem.getNode(dragValue.getName());
 		itemParent.removeChild(item.getId());
@@ -121,10 +119,10 @@
 		}else{
 			itemParent = treeMyAlbumsItem;
 		}
-		String directoryOld = user.getLogin() + fileManager.getFileSeparator() + dragValue.getAlbumPathFromParents(dragValue, new ArrayList<String>(), fileManager.getFileSeparator() ) + dragValue.getName();
-		String directoryNew = user.getLogin() + fileManager.getFileSeparator() + dropValue.getAlbumPathFromParents(dropValue, new ArrayList<String>(), fileManager.getFileSeparator()) + dragValue.getName();
-		String albumOld = user.getLogin() + Constants.SLASH + dragValue.getAlbumPathFromParents(dragValue, new ArrayList<String>(), Constants.SLASH );
-		String albumNew = user.getLogin() + Constants.SLASH + dropValue.getAlbumPathFromParents(dropValue, new ArrayList<String>(), Constants.SLASH);
+		String directoryOld = user.getLogin() + fileManager.getFileSeparator() + dragValue.getAlbumPathFromParents(dragValue, fileManager.getFileSeparator(), true );
+		String directoryNew = user.getLogin() + fileManager.getFileSeparator() + dropValue.getAlbumPathFromParents(dropValue,  fileManager.getFileSeparator(), false) + dragValue.getName();
+		String albumOld = user.getLogin() + Constants.SLASH + dragValue.getAlbumPathFromParents(dragValue, Constants.SLASH, false );
+		String albumNew = user.getLogin() + Constants.SLASH + dropValue.getAlbumPathFromParents(dropValue, Constants.SLASH, false);
 		dropValue.addChildAlbum(dragValue);
 		TreeAlbumItem itemParentNew = (TreeAlbumItem)treeMyAlbumsItem.getNode(dropValue.getName());
 		TreeAlbumItem item = (TreeAlbumItem)treeMyAlbumsItem.getNode(dragValue.getName());
@@ -145,12 +143,11 @@
 		String fileNameOld = fileManager.transformToServerPath(dragValue.getPath());
 		int lastIndexOf = dragValue.getPath().lastIndexOf(Constants.SLASH);
 		String prevPathEnd = dragValue.getPath().substring(lastIndexOf);
-		String fileNameNew = user.getLogin() + fileManager.getFileSeparator() + dropValue.getAlbumPathFromParents(dropValue, new ArrayList<String>(), fileManager.getFileSeparator()) + prevPathEnd;
-		String newPath = user.getLogin() + Constants.SLASH + dropValue.getAlbumPathFromParents(dropValue, new ArrayList<String>(), Constants.SLASH) + prevPathEnd;
+		String fileNameNew = user.getLogin() + fileManager.getFileSeparator() + dropValue.getAlbumPathFromParents(dropValue, fileManager.getFileSeparator(), true) + prevPathEnd;
+		String newPath = user.getLogin() + Constants.SLASH + dropValue.getAlbumPathFromParents(dropValue, Constants.SLASH, true) + prevPathEnd;
 		dragValue.setPath(newPath);
 		dropValue.addImage(dragValue);
 		fileManager.renameImage(fileNameOld, fileNameNew);
 		albumAction.flush();
 	}
-	
 }

Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -79,8 +79,8 @@
 			int lastIndexOf = image.getPath().lastIndexOf(Constants.SLASH);
 			String prevPathEnd = image.getPath().substring(lastIndexOf);
 			Album dropValue = ((TreeAlbumItem)treeMyAlbumsItem.getNode(image.getAlbumName())).getAlbum();
-			String fileNameNew = user.getLogin() + fileManager.getFileSeparator() + dropValue.getAlbumPathFromParents(dropValue , new ArrayList<String>(), fileManager.getFileSeparator()) + prevPathEnd;
-			String newPath = user.getLogin() + Constants.SLASH + albumItem.getAlbum().getAlbumPathFromParents(albumItem.getAlbum(), new ArrayList<String>(), Constants.SLASH) + prevPathEnd;
+			String fileNameNew = user.getLogin() + fileManager.getFileSeparator() + dropValue.getAlbumPathFromParents(dropValue , fileManager.getFileSeparator(), true) + prevPathEnd;
+			String newPath = user.getLogin() + Constants.SLASH + albumItem.getAlbum().getAlbumPathFromParents(albumItem.getAlbum(), Constants.SLASH, true) + prevPathEnd;
 			image.setPath(newPath);
 			fileManager.renameImage(fileNameOld, fileNameNew);
 			conversationState.setSelectedImage(image);

Added: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/SearchManager.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/SearchManager.java	                        (rev 0)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/SearchManager.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -0,0 +1,163 @@
+/**
+ * License Agreement.
+ *
+ *  JBoss RichFaces - Ajax4jsf Component Library
+ *
+ * Copyright (C) 2007  Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+package org.richfaces.realworld.manager;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.search.SearchBeanHelper;
+import org.richfaces.realworld.search.SearchParamHolder;
+import org.richfaces.realworld.service.Constants;
+import org.richfaces.realworld.service.ISearchService;
+
+ at Name("searchManager")
+ at Scope(ScopeType.CONVERSATION)
+public class SearchManager implements Serializable {
+
+	@In(required = false)
+	private SearchBeanHelper helper;
+	
+	@In(required = false)
+	private SearchParamHolder searchParams;
+
+	private static final long serialVersionUID = 5071655218132021316L;
+
+	@In(create=true)
+	private ISearchService searchService;
+	
+	private List<Image> findedImages = new ArrayList<Image>();
+	
+	public List<String> getAllCameras(){
+		return searchService.getAllCameras();
+	}
+	
+	public List<String> getAllMetatags(){
+		return searchService.getAllMetatags();
+	}
+	
+	public List<Image> searchImages(){
+		String additionalParams = populateAdditionalParams();
+		findedImages = searchService.searchImages(searchParams.getSearchPattern(), additionalParams, populateMap(additionalParams));
+		return findedImages;
+	}
+	
+	public List<Image> popularImages(){
+		return searchService.popularImages();
+	}
+	
+	public List<Image> worstImages(){
+		return searchService.worstImages();
+	}
+	
+	private Map<String, Object> populateMap(String additionalParams) {
+		Map<String, Object> map = new HashMap<String, Object>();
+		populateParameter(map, additionalParams, Constants.SPINNER_VALUE_NAMED_PARAMETER, Long.valueOf(helper.getInputSpinner().getValue().toString()));
+		populateParameter(map, additionalParams, Constants.CHOICE_NAMED_PARAMETER, searchParams.getNumberOfVotes());
+		populateParameter(map, additionalParams, Constants.DATE_NAMED_PARAMETER, searchParams.getDate());
+		populateParameter(map, additionalParams, Constants.UPLOAD_NAMED_PARAMETER, searchParams.getUploadDate());
+		populateParameter(map, additionalParams, Constants.SIZE_NAMED_PARAMETER, searchParams.getSize());
+		populateParameter(map, additionalParams, Constants.WIDTH_NAMED_PARAMETER, searchParams.getWidth());
+		populateParameter(map, additionalParams, Constants.HEIGHT_NAMED_PARAMETER, searchParams.getHeight());
+		populateParameter(map, additionalParams, Constants.CAMERA_NAMED_PARAMETER, searchParams.getCamera());
+		if(searchParams.getMatcherChoice() != null){
+			map.put(Constants.STRICT_PARAMETER, getMatcher(searchParams.getMatcherChoice()));
+		}
+		map.put(Constants.CASE_SENSITIVE_PARAMETER, searchParams.isCaseSensitive());
+		return map;
+	}
+	
+	private String populateAdditionalParams() {
+		StringBuilder additionalParams = new StringBuilder("");
+		populateChoiceAddon(additionalParams, searchParams.getSpinnerChoice(), Constants.SPINNER_ADDON, Constants.SPINNER_VALUE_NAMED_PARAMETER);
+		populateChoiceAddon(additionalParams, searchParams.getVotesChoice(), Constants.VOTES_ADDON, Constants.CHOICE_NAMED_PARAMETER);
+		populateDateAddon(additionalParams, searchParams.getDateChoice(), Constants.DATE_ADDON, Constants.DATE_NAMED_PARAMETER, searchParams.getDate());
+		populateDateAddon(additionalParams, searchParams.getUploadChoice(), Constants.UPLOAD_ADDON, Constants.UPLOAD_NAMED_PARAMETER, searchParams.getUploadDate());
+		populateChoiceAddon(additionalParams, searchParams.getWidthChoice(), Constants.WIDTH_ADDON, Constants.WIDTH_NAMED_PARAMETER);
+		populateChoiceAddon(additionalParams, searchParams.getHeightChoice(), Constants.HEIGHT_ADDON, Constants.HEIGHT_NAMED_PARAMETER);
+		populateChoiceAddon(additionalParams, searchParams.getSizeChoice(), Constants.SIZE_ADDON, Constants.SIZE_NAMED_PARAMETER);
+		if(searchParams.getCamera()!= null && !searchParams.getCamera().equals("")){
+			additionalParams.append(Constants.CAMERA_ADDON);
+			additionalParams.append(Constants.EQUALS);
+			additionalParams.append(Constants.CAMERA_NAMED_PARAMETER);
+		}
+		return additionalParams.toString();
+	}
+
+	private String getAstFromIndex(Long item){
+		if(item == 1L){
+			return Constants.GREATTHEN;
+		}else if(item == 2L){
+			return Constants.LESSTHEN;
+		}else if(item == 3L){
+			return Constants.EQUALS;
+		}
+		return null;
+	}
+	
+	private String getMatcher(Long item){
+		if(item == 1L){
+			return Constants.START;
+		}else if(item == 2L){
+			return Constants.END;
+		}else if(item == 3L){
+			return Constants.INCLUDE;
+		}else if(item == 0L){
+			return Constants.STRICT;
+		}
+		return null;
+	}
+	
+	private void populateParameter(Map<String, Object> map, String additionalParams, String parameter, Object value){
+		if(additionalParams.lastIndexOf(parameter) != -1){
+			map.put(parameter, value);
+		}
+	}
+	
+	private void populateChoiceAddon(StringBuilder additionalParams, Long choice, String addon, String namedParameter){
+		if(choice != null && choice > 0L){
+			additionalParams.append(addon);
+			additionalParams.append(getAstFromIndex(choice));
+			additionalParams.append(namedParameter);
+		}
+	}
+	
+	private void populateDateAddon(StringBuilder additionalParams, Long choice, String addon, String namedParameter, Date date){
+		if(choice != null && choice > 0L && date != null ){
+			additionalParams.append(addon);
+			additionalParams.append(getAstFromIndex(choice));
+			additionalParams.append(namedParameter);
+		}
+	}
+
+	public List<Image> getFindedImages() {
+		return findedImages;
+	}
+	
+}
\ No newline at end of file


Property changes on: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/manager/SearchManager.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Author Id Revision Date
Name: svn:eol-style
   + native

Deleted: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchBean.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchBean.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchBean.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -1,161 +0,0 @@
-/**
- * License Agreement.
- *
- *  JBoss RichFaces - Ajax4jsf Component Library
- *
- * Copyright (C) 2007  Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
- */
-package org.richfaces.realworld.search;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.service.Constants;
-import org.richfaces.realworld.service.ISearchService;
-
- at Name("searchBean")
- at Scope(ScopeType.CONVERSATION)
-public class SearchBean implements Serializable {
-
-	@In(required = false)
-	private SearchBeanHelper helper;
-	
-	@In(required = false)
-	private SearchParamHolder searchParams;
-
-	private static final long serialVersionUID = 5071655218132021316L;
-
-	@In(create=true)
-	private ISearchService searchService;
-	
-	private List<Image> findedImages = new ArrayList<Image>();
-	
-	public List<String> getAllCameras(){
-		return searchService.getAllCameras();
-	}
-	
-	public List<String> getAllMetatags(){
-		return searchService.getAllMetatags();
-	}
-	
-	public List<Image> searchImages(){
-		String additionalParams = populateAdditionalParams();
-		findedImages = searchService.searchImages(searchParams.getSearchPattern(), additionalParams, populateMap(additionalParams));
-		return findedImages;
-	}
-	
-	public List<Image> popularImages(){
-		return searchService.popularImages();
-	}
-	
-	public List<Image> worstImages(){
-		return searchService.worstImages();
-	}
-	
-	private Map<String, Object> populateMap(String additionalParams) {
-		Map<String, Object> map = new HashMap<String, Object>();
-		populateParameter(map, additionalParams, Constants.SPINNER_VALUE_NAMED_PARAMETER, Long.valueOf(helper.getInputSpinner().getValue().toString()));
-		populateParameter(map, additionalParams, Constants.CHOICE_NAMED_PARAMETER, searchParams.getNumberOfVotes());
-		populateParameter(map, additionalParams, Constants.DATE_NAMED_PARAMETER, searchParams.getDate());
-		populateParameter(map, additionalParams, Constants.UPLOAD_NAMED_PARAMETER, searchParams.getUploadDate());
-		populateParameter(map, additionalParams, Constants.SIZE_NAMED_PARAMETER, searchParams.getSize());
-		populateParameter(map, additionalParams, Constants.WIDTH_NAMED_PARAMETER, searchParams.getWidth());
-		populateParameter(map, additionalParams, Constants.HEIGHT_NAMED_PARAMETER, searchParams.getHeight());
-		populateParameter(map, additionalParams, Constants.CAMERA_NAMED_PARAMETER, searchParams.getCamera());
-		if(searchParams.getMatcherChoice() != null){
-			map.put(Constants.STRICT_PARAMETER, getMatcher(searchParams.getMatcherChoice()));
-		}
-		map.put(Constants.CASE_SENSITIVE_PARAMETER, searchParams.isCaseSensitive());
-		return map;
-	}
-	
-	private String populateAdditionalParams() {
-		StringBuilder additionalParams = new StringBuilder("");
-		populateChoiceAddon(additionalParams, searchParams.getSpinnerChoice(), Constants.SPINNER_ADDON, Constants.SPINNER_VALUE_NAMED_PARAMETER);
-		populateChoiceAddon(additionalParams, searchParams.getVotesChoice(), Constants.VOTES_ADDON, Constants.CHOICE_NAMED_PARAMETER);
-		populateDateAddon(additionalParams, searchParams.getDateChoice(), Constants.DATE_ADDON, Constants.DATE_NAMED_PARAMETER, searchParams.getDate());
-		populateDateAddon(additionalParams, searchParams.getUploadChoice(), Constants.UPLOAD_ADDON, Constants.UPLOAD_NAMED_PARAMETER, searchParams.getUploadDate());
-		populateChoiceAddon(additionalParams, searchParams.getWidthChoice(), Constants.WIDTH_ADDON, Constants.WIDTH_NAMED_PARAMETER);
-		populateChoiceAddon(additionalParams, searchParams.getHeightChoice(), Constants.HEIGHT_ADDON, Constants.HEIGHT_NAMED_PARAMETER);
-		populateChoiceAddon(additionalParams, searchParams.getSizeChoice(), Constants.SIZE_ADDON, Constants.SIZE_NAMED_PARAMETER);
-		if(searchParams.getCamera()!= null && !searchParams.getCamera().equals("")){
-			additionalParams.append(Constants.CAMERA_ADDON);
-			additionalParams.append(Constants.EQUALS);
-			additionalParams.append(Constants.CAMERA_NAMED_PARAMETER);
-		}
-		return additionalParams.toString();
-	}
-
-	private String getAstFromIndex(Long item){
-		if(item == 1L){
-			return Constants.GREATTHEN;
-		}else if(item == 2L){
-			return Constants.LESSTHEN;
-		}else if(item == 3L){
-			return Constants.EQUALS;
-		}
-		return null;
-	}
-	
-	private String getMatcher(Long item){
-		if(item == 1L){
-			return Constants.START;
-		}else if(item == 2L){
-			return Constants.END;
-		}else if(item == 3L){
-			return Constants.INCLUDE;
-		}else if(item == 0L){
-			return Constants.STRICT;
-		}
-		return null;
-	}
-	
-	private void populateParameter(Map<String, Object> map, String additionalParams, String parameter, Object value){
-		if(additionalParams.lastIndexOf(parameter) != -1){
-			map.put(parameter, value);
-		}
-	}
-	
-	private void populateChoiceAddon(StringBuilder additionalParams, Long choice, String addon, String namedParameter){
-		if(choice != null && choice > 0L){
-			additionalParams.append(addon);
-			additionalParams.append(getAstFromIndex(choice));
-			additionalParams.append(namedParameter);
-		}
-	}
-	
-	private void populateDateAddon(StringBuilder additionalParams, Long choice, String addon, String namedParameter, Date date){
-		if(choice != null && choice > 0L && date != null ){
-			additionalParams.append(addon);
-			additionalParams.append(getAstFromIndex(choice));
-			additionalParams.append(namedParameter);
-		}
-	}
-
-	public List<Image> getFindedImages() {
-		return findedImages;
-	}
-	
-}
\ No newline at end of file

Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeAlbumItem.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeAlbumItem.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeAlbumItem.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -142,7 +142,7 @@
 		List<SelectItem> items = new ArrayList<SelectItem>();
 		for(TreeNode<Object> item: this.getAlbums()){
 			TreeAlbumItem a = (TreeAlbumItem)item;
-			String pathFromParents = a.getAlbum().getAlbumPathFromParents(a.getAlbum(), new ArrayList<String>(), "/");
+			String pathFromParents = a.getAlbum().getAlbumPathFromParents(a.getAlbum(), Constants.SLASH, true);
 			SelectItem e = new SelectItem(pathFromParents);
 			items.add(e);
 			a.getArrayOfChildsAlbumsNames(items);
@@ -153,7 +153,7 @@
 	public void getArrayOfChildsAlbumsNames(List<SelectItem> list) {
 		for(TreeNode<Object> item: this.getAlbums()){
 			TreeAlbumItem a = (TreeAlbumItem)item;
-			String pathFromParents = this.getAlbum().getAlbumPathFromParents(this.getAlbum(), new ArrayList<String>(), "/");
+			String pathFromParents = this.getAlbum().getAlbumPathFromParents(this.getAlbum(), Constants.SLASH, true);
 			SelectItem e = new SelectItem(pathFromParents);
 			list.add(e);
 			a.getArrayOfChildsAlbumsNames(list);

Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ConversationState.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ConversationState.java	2009-01-26 17:03:40 UTC (rev 12430)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ConversationState.java	2009-01-26 19:28:18 UTC (rev 12431)
@@ -21,7 +21,6 @@
 package org.richfaces.realworld.util;
 
 import java.io.Serializable;
-import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -47,11 +46,11 @@
 import org.richfaces.realworld.domain.Image;
 import org.richfaces.realworld.domain.User;
 import org.richfaces.realworld.navigation.NavigationEnum;
+import org.richfaces.realworld.service.Constants;
 import org.richfaces.realworld.tree.TreeAlbumItem;
 import org.richfaces.realworld.tree.TreeFriendItem;
 import org.richfaces.realworld.tree.TreeFriendsItem;
 import org.richfaces.realworld.tree.TreeMyAlbumsItem;
-import org.richfaces.realworld.service.Constants;
 
 @Name("conversationState")
 @Scope(ScopeType.CONVERSATION)
@@ -115,7 +114,7 @@
 		if(null == selectedAlbum){
 			return "";
 		}
-		return selectedAlbum.getAlbumPathFromParents(selectedAlbum, new ArrayList<String>(), Constants.SLASH);
+		return selectedAlbum.getAlbumPathFromParents(selectedAlbum, Constants.SLASH, true);
 	}
 
 	public void setSelectedAlbumName(String selectedAlbumName) {

Modified: trunk/test-applications/realworld/web/src/main/webapp/includes/fileUpload/fileUploader.xhtml
===================================================================
(Binary files differ)

Modified: trunk/test-applications/realworld/web/src/main/webapp/includes/search/advancedSearch.xhtml
===================================================================
(Binary files differ)

Modified: trunk/test-applications/realworld/web/src/main/webapp/includes/search/searchResults.xhtml
===================================================================
(Binary files differ)

Modified: trunk/test-applications/realworld/web/src/main/webapp/includes/search.xhtml
===================================================================
(Binary files differ)




More information about the richfaces-svn-commits mailing list