Author: amarkhel
Date: 2009-05-05 09:52:08 -0400 (Tue, 05 May 2009)
New Revision: 14019
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/DnDManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/FileUploadManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ImageManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/SlideshowManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/UserManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ISearchOption.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ImageSearchHelper.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByAlbum.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByImage.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByShelf.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByTag.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByUser.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/CopyImageStuff.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/FileUtils.java
trunk/examples/photoalbum/source/web/src/main/resources/messages_en.properties
trunk/examples/photoalbum/source/web/src/main/webapp/includes/album/albumInfo.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/contextMenu/CMForAlbum.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/contextMenu/CMForImage.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/contextMenu/CMForShelf.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/contextMenu/CMForUser.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageEditInfo.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/index/tree.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/search.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/shelf/shelfInfo.xhtml
Log:
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -115,7 +115,7 @@
}
/**
- * Method, that invoked when user click 'Edit album' button. Only registered
users can create new albums.
+ * Method, that invoked when user click 'Edit album' button. Only registered
users can edit albums.
* @param album - edited album
*
*/
@@ -132,7 +132,7 @@
}
/**
- * Method, that invoked when user click 'Delete album' button. Only registered
users can create new albums.
+ * Method, that invoked when user click 'Delete album' button. Only registered
users can delete albums.
* @param album - album to delete
*
*/
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -22,7 +22,6 @@
import java.io.File;
import java.io.Serializable;
-import java.security.MessageDigest;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
@@ -39,7 +38,6 @@
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.security.Credentials;
import org.jboss.seam.security.Identity;
-import org.jboss.seam.util.Hex;
import org.richfaces.photoalbum.domain.User;
import org.richfaces.photoalbum.service.Constants;
import org.richfaces.photoalbum.service.IUserAction;
@@ -77,8 +75,7 @@
} catch (LoginException e) {
setLoginFailed(true);
credentials.clear();
- identity.login();
- identity.addRole(Constants.GUEST_ROLE);
+ loginAnonymous();
facesMessages.clear();
facesMessages.add(Constants.INVALID_LOGIN_OR_PASSWORD);
FacesContext.getCurrentInstance().renderResponse();
@@ -145,9 +142,7 @@
public boolean authenticate()
{
if (wantLoginAnonymous()) {
- identity.addRole(Constants.GUEST_ROLE);
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.ANONYM);
- return true;
+ return loginAnonymous();
}
try {
User user = userAction.login(credentials.getUsername(),
HashUtils.hash(credentials.getPassword()));
@@ -164,6 +159,12 @@
return false;
}
+ private boolean loginAnonymous() {
+ identity.addRole(Constants.GUEST_ROLE);
+ Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT, NavigationEnum.ANONYM);
+ return true;
+ }
+
public String logout(){
identity.logout();
return Constants.LOGOUT_OUTCOME;
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/DnDManager.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/DnDManager.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/DnDManager.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -19,7 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.richfaces.photoalbum.manager;
-
+/**
+ * Class encapsulated all functionality, related to drag'n'drop process.
+ *
+ * @author Andrey Markhel
+ */
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -47,18 +51,25 @@
@In IAlbumAction albumAction;
+ /**
+ * Listenet, that invoked during drag'n'drop process. Only registered users can
drag images.
+ *
+ * @param event - event, indicated that drag'n'drop started
+ */
@Restrict("#{s:hasRole('admin')}")
public void processDrop(DropEvent dropEvent) {
Dropzone dropzone = (Dropzone) dropEvent.getComponent();
Object dragValue = dropEvent.getDragValue();
Object dropValue = dropzone.getDropValue();
if(dragValue instanceof Image){
- if(!((Album)dropValue).getOwner().getLogin().equals(user.getLogin())){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.DND_PHOTO_ERROR);
- return;
- }
- handleImage((Image)dragValue, (Album)dropValue);
+ //If user drag image
+ if(!((Album)dropValue).getOwner().getLogin().equals(user.getLogin())){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.DND_PHOTO_ERROR);
+ return;
+ }
+ handleImage((Image)dragValue, (Album)dropValue);
}else if(dragValue instanceof Album){
+ //If user drag album
if(!((Shelf)dropValue).getOwner().getLogin().equals(user.getLogin())){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.DND_ALBUM_ERROR);
return;
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/FileUploadManager.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/FileUploadManager.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/FileUploadManager.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -67,11 +67,18 @@
@In private FileManager fileManager;
+ /**
+ * Listenet, that invoked during file upload process. Only registered users can upload
images.
+ *
+ * @param event - event, indicated that file upload started
+ */
@Restrict("#{s:hasRole('admin')}")
public void listener(UploadEvent event) throws Exception {
UploadItem item = event.getUploadItem();
+ //Construct image from item
Image image = constructImage(item);
try {
+ //Extract metadata(size, camera model etc..)
extractMetadata(item, image);
} catch (Exception e1) {
addError(item, image, Constants.FILE_PROCESSING_ERROR);
@@ -83,20 +90,26 @@
return;
}
try{
+ //Check if image with given name already exist
if(imageAction.isImageWithThisPathExist(image)){
+ //If exist generate new path for image
image.setPath(generateNewPath(image.getPath()));
}
+ //Save to database
imageAction.addImage(image);
}catch(Exception e){
addError(item, image, Constants.IMAGE_SAVING_ERROR);
return;
}
+ //Save to disk
if(!fileManager.addImage(image.getFullPath(), item.getFile().getPath())){
addError(item, image, Constants.FILE_SAVE_ERROR);
return;
}
+ //Prepare to show in UI
fileWrapper.getFiles().add(image);
Events.instance().raiseEvent(Constants.IMAGE_ADDED_EVENT, image);
+ //Delete temporary fule
item.getFile().delete();
}
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ImageManager.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ImageManager.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ImageManager.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -57,7 +57,7 @@
@In User user;
/**
- * Method, that invoked when user click 'Delete image' button. Only registered
users can create new albums.
+ * Method, that invoked when user click 'Delete image' button. Only registered
users can delete images.
* @param image - image to delete
*
*/
@@ -75,7 +75,7 @@
}
/**
- * Method, that invoked when user click 'Edit image' button. Only registered
users can create new albums.
+ * Method, that invoked when user click 'Edit image' button. Only registered
users can edit images.
* @param image - image to edit
*
*/
@@ -91,7 +91,7 @@
}
/**
- * Method, that invoked when user add comment to image. Only registered users can create
new albums.
+ * Method, that invoked when user add comment to image. Only registered users can add
comments to image.
* @param image - image
* @param message - comment text
*
@@ -121,7 +121,7 @@
}
/**
- * Method, that invoked when user delete comment. Only registered users can create new
albums.
+ * Method, that invoked when user delete comment. Only registered users can delete
comments.
* @param comment - comment to delete
*
*/
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -57,7 +57,7 @@
@In User user;
/**
- * Method, that invoked when user want to create new shelf. Only registered users can
create new albums.
+ * Method, that invoked when user want to create new shelf. Only registered users can
create new shelves.
*
*/
@Restrict("#{s:hasRole('admin')}")
@@ -67,7 +67,7 @@
}
/**
- * Method, that invoked on creation of the new shelf. Only registered users can create
new albums.
+ * Method, that invoked on creation of the new shelf. Only registered users can create
new shelves.
* @param album - new album
*
*/
@@ -88,7 +88,7 @@
}
/**
- * Method, that invoked when user click 'Edit shelf' button. Only registered
users can create new albums.
+ * Method, that invoked when user click 'Edit shelf' button. Only registered
users can edit shelves.
* @param shelf - shelf to edit
*
*/
@@ -104,7 +104,7 @@
}
/**
- * Method, that invoked when user click 'Delete shelf' button. Only registered
users can create new albums.
+ * Method, that invoked when user click 'Delete shelf' button. Only registered
users can delete shelves.
* @param image - shelf to delete
*
*/
@@ -123,7 +123,7 @@
/**
* This method used to populate 'pre-defined shelves' tree
*
- * @return List of predefined shelfs
+ * @return List of predefined shelves
*
*/
public List<Shelf> getPredefinedShelves() {
@@ -136,7 +136,7 @@
/**
* This method used to populate 'my shelves' tree
*
- * @return List of users shelfs
+ * @return List of users shelves
*
*/
public List<Shelf> getUserShelves(){
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/SlideshowManager.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/SlideshowManager.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/SlideshowManager.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -19,7 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.richfaces.photoalbum.manager;
-
+/**
+ * Class encapsulated all functionality, related to working with slideshow.
+ *
+ * @author Andrey Markhel
+ */
import java.io.Serializable;
import org.jboss.seam.ScopeType;
@@ -64,6 +68,10 @@
this.active = active;
}
+ /**
+ * This method invoked after user click on 'Start slideshow' button and no image
is selected. After execution of this method slideshow will be activated.
+ *
+ */
public void startSlideshow(){
active = true;
this.slideshowIndex = 0;
@@ -73,7 +81,9 @@
return;
}
this.selectedImage = model.getImages().get(this.slideshowIndex);
+ //mark image as 'visited'
this.selectedImage.setVisited(true);
+ //Check if that image was recently deleted. If yes, immediately stop slideshow
FileManager fileManager =
(FileManager)Contexts.getApplicationContext().get(Constants.FILE_MANAGER_COMPONENT);
if(!fileManager.isFilePresent(this.selectedImage.getFullPath())){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.IMAGE_RECENTLY_DELETED_ERROR);
@@ -83,6 +93,11 @@
}
}
+ /**
+ * This method invoked after user click on 'Start slideshow' button. After
execution of this method slideshow will be activated starting from selected image.
+ *
+ *@param selectedImage - first image to show during slideshow
+ */
public void startSlideshow(Image selectedImage){
active = true;
if(model.getImages() == null || model.getImages().size() < 1){
@@ -92,7 +107,9 @@
}
this.slideshowIndex = model.getImages().indexOf(selectedImage);
this.selectedImage = selectedImage;
+ //mark image as 'visited'
this.selectedImage.setVisited(true);
+ //Check if that image was recently deleted. If yes, immediately stop slideshow
FileManager fileManager =
(FileManager)Contexts.getApplicationContext().get(Constants.FILE_MANAGER_COMPONENT);
if(!fileManager.isFilePresent(this.selectedImage.getFullPath())){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.IMAGE_RECENTLY_DELETED_ERROR);
@@ -102,6 +119,10 @@
}
}
+ /**
+ * This method invoked after user click on 'Stop slideshow' button. After
execution of this method slideshow will be de-activated.
+ *
+ */
@Observer(Constants.STOP_SLIDESHOW_EVENT)
public void stopSlideshow(){
active = false;
@@ -125,16 +146,23 @@
this.selectedImage = selectedImage;
}
+ /**
+ * This method used to prepare next image to show during slideshow
+ *
+ */
public void showNextImage(){
if(!active){
return;
}
+ //reset index if we reached last image
if(slideshowIndex == model.getImages().size() - 1){
slideshowIndex = -1;
}
slideshowIndex++;
selectedImage = model.getImages().get(slideshowIndex);
+ //mark image as 'visited'
this.selectedImage.setVisited(true);
+ //Check if that image was recently deleted. If yes, stopping slideshow
FileManager fileManager =
(FileManager)Contexts.getApplicationContext().get(Constants.FILE_MANAGER_COMPONENT);
if(!fileManager.isFilePresent(this.selectedImage.getFullPath())){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.IMAGE_RECENTLY_DELETED_ERROR);
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/UserManager.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/UserManager.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/UserManager.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -19,7 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.richfaces.photoalbum.manager;
-
+/**
+ * Class encapsulated all functionality, related to working with user.
+ *
+ * @author Andrey Markhel
+ */
import java.io.File;
import java.io.Serializable;
@@ -51,8 +55,13 @@
@In IUserAction userAction;
+ /**
+ * Method, that invoked when user want to edit her profile.
+ *
+ */
@Observer(Constants.EDIT_USER_EVENT)
public void editUser(){
+ //If new avatar was uploaded
if (avatarData != null) {
if(!fileManager.saveAvatar(avatarData, user)){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.FILE_IO_ERROR);
@@ -71,6 +80,10 @@
}
}
+ /**
+ * Method, that invoked when user click 'Cancel' button during edit her
profile.
+ *
+ */
@Observer(Constants.CANCEL_EDIT_USER_EVENT)
public void cancelEditUser() {
avatarData = null;
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ISearchOption.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ISearchOption.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ISearchOption.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -8,21 +8,37 @@
import org.richfaces.photoalbum.service.ISearchAction;
/**
+ * Abstract class, that represent base functionality for particular search option(album,
shelf, etc..)
* @author Andrey Markavtsov
*
*/
public abstract class ISearchOption {
- private static final String TEMPLATE =
"/includes/search/result/albumsResult.xhtml";
-
private boolean selected = true;
private List<?> searchResult;
-
+ /**
+ * Abstract method, that return name of particular search option. This name used in UI
as header of rich:tab. Must be implemented in sub-classes
+ *
+ * @return name
+ */
public abstract String getName();
+ /**
+ * Abstract method, that return description of particular search option. This
description used in UI as header of page with search result. Must be implemented in
sub-classes
+ *
+ * @return description of search option
+ */
public abstract String getSearchResultName();
+ /**
+ * Abstract method, that perform search in given option. Must be implemented in
sub-classes
+ *
+ * @param action - action will be performed
+ * @param searchQuery - query to search
+ * @param searchInMyAlbums - is search in users albums will be performed
+ * @param searchInShared - is search in shared albums will be performed
+ */
public abstract void search(ISearchAction action, String searchQuery, boolean
searchInMyAlbums, boolean searchInShared);
public boolean getSelected() {
@@ -38,9 +54,12 @@
return getName();
}
- public String getSearchResultTemplate() {
- return TEMPLATE;
- }
+ /**
+ * Abstract method, that return template to render of particular search option. Must be
implemented in sub-classes
+ *
+ * @return template to render
+ */
+ public abstract String getSearchResultTemplate();
public List<?> getSearchResult() {
return searchResult;
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ImageSearchHelper.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ImageSearchHelper.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ImageSearchHelper.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -15,7 +15,11 @@
import org.richfaces.photoalbum.manager.NavigationEnum;
import org.richfaces.photoalbum.service.Constants;
import org.richfaces.photoalbum.service.ISearchAction;
-
+/**
+ * Class, that encapsulate functionality related to search process.
+ * @author Andrey Markavtsov
+ *
+ */
@Name("searchImageHelper")
@Scope(ScopeType.CONVERSATION)
@AutoCreate
@@ -41,6 +45,10 @@
boolean searchInShared = true;
+ /**
+ * Default constructor. During instantiation populate in field options all possible
search options
+ *
+ */
public ImageSearchHelper() {
options = new ArrayList<ISearchOption>();
options.add(new SearchOptionByShelf());
@@ -50,6 +58,9 @@
options.add(new SearchOptionByTag());
}
+ /**
+ * Method, used to construct criteria string, to represent this string in UI.
+ */
public String getCriteriaString(){
StringBuilder s = new StringBuilder();
for(ISearchOption option:options) {
@@ -63,19 +74,27 @@
return s.toString();
}
+ /**
+ * Method, that perform search, when user clicks by 'Find' button.
+ */
public void search() {
if(!isSearchOptionSelected()){
+ //If no options selected
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.SEARCH_NO_OPTIONS_ERROR);
return;
}
if(!isWhereSearchOptionSelected()){
+ //If both search in My and search is shared unselected
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.SEARCH_NO_WHERE_OPTIONS_ERROR);
return;
}
keywords = new ArrayList<String>();
+ //Update view
Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT, NavigationEnum.SEARCH);
+ // parse query
keywords = parse(searchQuery);
Iterator<ISearchOption> it = options.iterator();
+ //Search by first keyword by default
selectedKeyword = keywords.get(0).trim();
while (it.hasNext()) {
ISearchOption option = it.next();
@@ -84,11 +103,11 @@
}
}
}
-
- private boolean isWhereSearchOptionSelected() {
- return seachInMyAlbums || searchInShared;
- }
+ /**
+ * Method, that perform search by particular phrase
+ * @param keyword - keyword to search
+ */
public void search(String keyword) {
if(!isSearchOptionSelected()){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.SEARCH_NO_OPTIONS_ERROR);
@@ -104,25 +123,9 @@
}
}
- private List<String> parse(String searchQuery2) {
- return Arrays.asList(searchQuery2.split(Constants.COMMA));
- }
-
- boolean isOptionSelected() {
- return selectedOption != null;
- }
-
- private boolean isSearchOptionSelected() {
- boolean isOptionSelected = false;
- for(ISearchOption i : options){
- if(i.getSelected()){
- isOptionSelected = true;
- break;
- }
- }
- return isOptionSelected;
- }
-
+ /**
+ * Method, invoked when user select or unselect search option.
+ */
public void processSelection() {
Iterator<ISearchOption> it = options.iterator();
while (it.hasNext()) {
@@ -189,4 +192,36 @@
public void setSelectedKeyword(String selectedKeyword) {
this.selectedKeyword = selectedKeyword;
}
+
+ public boolean isResultExist(){
+ for(ISearchOption option : options){
+ if(option.getSelected() && option.getSearchResult().size() > 0){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private List<String> parse(String searchQuery2) {
+ return Arrays.asList(searchQuery2.split(Constants.COMMA));
+ }
+
+ private boolean isWhereSearchOptionSelected() {
+ return seachInMyAlbums || searchInShared;
+ }
+
+ boolean isOptionSelected() {
+ return selectedOption != null;
+ }
+
+ private boolean isSearchOptionSelected() {
+ boolean isOptionSelected = false;
+ for(ISearchOption i : options){
+ if(i.getSelected()){
+ isOptionSelected = true;
+ break;
+ }
+ }
+ return isOptionSelected;
+ }
}
\ No newline at end of file
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByAlbum.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByAlbum.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByAlbum.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -1,31 +1,40 @@
package org.richfaces.photoalbum.search;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.richfaces.photoalbum.domain.Album;
import org.richfaces.photoalbum.service.ISearchAction;
-
-
+/**
+ * Class, that encapsulate functionality related to search by album entity.
+ * @author Andrey Markavtsov
+ *
+ */
public class SearchOptionByAlbum extends ISearchOption {
private static final String TEMPLATE =
"/includes/search/result/albumsResult.xhtml";
private static final String ALBUMS_SEARCH_RESULT = "Albums search result";
private static final String ALBUMS = "Albums";
- Map<String, Object> params = new HashMap<String, Object>();
+ /* (non-Javadoc)
+ * @see org.richfaces.photoalbum.search.ISearchOption#getName()
+ */
@Override
public String getName() {
return ALBUMS;
}
+ /* (non-Javadoc)
+ * @see org.richfaces.photoalbum.search.ISearchOption#getSearchResultName()
+ */
@Override
public String getSearchResultName() {
return ALBUMS_SEARCH_RESULT;
}
+ /* (non-Javadoc)
+ * @see org.richfaces.photoalbum.search.ISearchOption#search()
+ */
@Override
public void search(ISearchAction action, String q, boolean searchInMyAlbums, boolean
searchInShared) {
List<Album> searchByAlbum = action.searchByAlbum(q, searchInMyAlbums,
searchInShared);
@@ -36,16 +45,11 @@
}
}
+ /* (non-Javadoc)
+ * @see org.richfaces.photoalbum.search.ISearchOption#getSearchResultTemplate()
+ */
@Override
public String getSearchResultTemplate() {
return TEMPLATE;
}
-
- public Map<String, Object> getParams() {
- return params;
- }
-
- public void setParams(Map<String, Object> params) {
- this.params = params;
- }
}
\ No newline at end of file
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByImage.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByImage.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByImage.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -4,14 +4,13 @@
package org.richfaces.photoalbum.search;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.richfaces.photoalbum.domain.Image;
import org.richfaces.photoalbum.service.ISearchAction;
/**
+ * Class, that encapsulate functionality related to search by image entity.
* @author Andrey Markavtsov
*
*/
@@ -20,7 +19,6 @@
private static final String TEMPLATE =
"/includes/search/result/imageResult.xhtml";
private static final String IMAGES_SEARCH_RESULT = "Images search result";
private static final String IMAGES = "Images";
- Map<String, Object> params = new HashMap<String, Object>();
/* (non-Javadoc)
* @see org.richfaces.photoalbum.search.ISearchOption#getName()
@@ -29,11 +27,17 @@
return IMAGES;
}
+ /* (non-Javadoc)
+ * @see org.richfaces.photoalbum.search.ISearchOption#getSearchResultName()
+ */
@Override
public String getSearchResultName() {
return IMAGES_SEARCH_RESULT;
}
+ /* (non-Javadoc)
+ * @see org.richfaces.photoalbum.search.ISearchOption#search()
+ */
@Override
public void search(ISearchAction action, String q, boolean searchInMyAlbums, boolean
searchInShared) {
List<Image> searchByImage = action.searchByImage(q, searchInMyAlbums,
searchInShared);
@@ -44,16 +48,11 @@
}
}
+ /* (non-Javadoc)
+ * @see org.richfaces.photoalbum.search.ISearchOption#getSearchResultTemplate()
+ */
@Override
public String getSearchResultTemplate() {
return TEMPLATE;
}
-
- public Map<String, Object> getParams() {
- return params;
- }
-
- public void setParams(Map<String, Object> params) {
- this.params = params;
- }
}
\ No newline at end of file
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByShelf.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByShelf.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByShelf.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -10,7 +10,8 @@
import org.richfaces.photoalbum.service.ISearchAction;
/**
- * @author Andrey
+ * Class, that encapsulate functionality related to search by shelf entity.
+ * @author Andrey Markavtsov
*
*/
public class SearchOptionByShelf extends ISearchOption {
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByTag.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByTag.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByTag.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -10,7 +10,8 @@
import org.richfaces.photoalbum.service.ISearchAction;
/**
- * @author Andrey
+ * Class, that encapsulate functionality related to search by metatag entity.
+ * @author Andrey Markavtsov
*
*/
public class SearchOptionByTag extends ISearchOption {
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByUser.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByUser.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByUser.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -10,6 +10,7 @@
import org.richfaces.photoalbum.service.ISearchAction;
/**
+ * Class, that encapsulate functionality related to search by user entity.
* @author Andrey Markavtsov
*
*/
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/CopyImageStuff.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/CopyImageStuff.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/CopyImageStuff.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -3,14 +3,6 @@
*/
package org.richfaces.photoalbum.util;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.Destroy;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Out;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Startup;
-import org.jboss.seam.contexts.ServletLifecycle;
import static org.richfaces.photoalbum.service.Constants.IMAGE_FOLDER;
import static org.richfaces.photoalbum.service.Constants.PHOTOALBUM_FOLDER;
import static org.richfaces.photoalbum.service.Constants.TEMP_DIR;
@@ -19,13 +11,24 @@
import static org.richfaces.photoalbum.util.FileUtils.deleteDirectory;
import static org.richfaces.photoalbum.util.FileUtils.joinFiles;
-import javax.servlet.ServletContext;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
+import javax.servlet.ServletContext;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Destroy;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Out;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Startup;
+import org.jboss.seam.contexts.ServletLifecycle;
+
+
/**
+ * Utility class, that perform copying images from ear file to temp folder at startup
application
* @author Andrey Markavtsov
*
*/
@@ -43,14 +46,21 @@
private String imageSrc;
+ /**
+ * Method, that perform copying images from ear file to temp folder at startup
application
+ *
+ */
@Create
public void create() throws IOException {
resolveImageFolder();
resolveUploadRoot();
-
copyImages();
}
+ /**
+ * Method, that perform deleting images from temp folder during destroy application
+ *
+ */
@Destroy
public void destroy()throws IOException {
deleteDirectory(uploadRoot, true);
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/FileUtils.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/FileUtils.java 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/FileUtils.java 2009-05-05
13:52:08 UTC (rev 14019)
@@ -12,6 +12,11 @@
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageInputStream;
+/**
+ * Utility class for operations with file-system
+ *
+ */
+
public class FileUtils {
private static final String JPEG = "jpeg";
@@ -20,6 +25,10 @@
private static final boolean CLOCK = true;
private static final boolean VERIFY = true;
+ /**
+ * Utility method for copying file
+ *
+ */
public static void copyFile(File srcFile, File destFile) throws IOException {
if (!srcFile.getPath().toLowerCase().endsWith(JPG) &&
!srcFile.getPath().toLowerCase().endsWith(JPEG)) {
return;
@@ -54,6 +63,10 @@
}
}
+ /**
+ * Utility method for copying directory
+ *
+ */
public static void copyDirectory(File srcDir, File dstDir)
throws IOException {
@@ -74,6 +87,10 @@
}
}
+ /**
+ * Utility method for delete directory
+ *
+ */
public static boolean deleteDirectory(File dir , boolean isInitialDelete){
if (dir.isDirectory()) {
if (dir.exists()) {
@@ -100,6 +117,10 @@
return true;
}
+ /**
+ * Utility method for concatenation names of collection of files
+ *
+ */
public static String joinFiles(String... files) {
final StringBuilder res = new StringBuilder();
for (String file : files) {
@@ -109,7 +130,10 @@
return res.substring(0, res.length() - 1);
}
-
+ /**
+ * Utility method for delete file
+ *
+ */
public static void deleteFile(File file) {
if (file.exists()) {
file.delete();
@@ -207,6 +231,10 @@
return ret;
}
+ /**
+ * Utility method for creation of directory
+ *
+ */
public static void addDirectory(File directory) {
if (directory.exists()) {
deleteDirectory(directory, false);
Modified: trunk/examples/photoalbum/source/web/src/main/resources/messages_en.properties
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/resources/messages_en.properties 2009-05-05
12:18:44 UTC (rev 14018)
+++
trunk/examples/photoalbum/source/web/src/main/resources/messages_en.properties 2009-05-05
13:52:08 UTC (rev 14019)
@@ -105,6 +105,7 @@
confirm.ok=OK
confirm.cancel=Cancel
shelf.edit=Edit shelf properties
+shelf.view=View shelf
shelf.delete=Delete shelf
album.edit=Edit album properties
album.delete=Delete album
@@ -221,7 +222,7 @@
created.image=Captured
contain=contain
pics_into=images into
-new=new
+new= new
shelf.albums=albums
images_=images
tags=Tags
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/album/albumInfo.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/contextMenu/CMForAlbum.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/contextMenu/CMForImage.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/contextMenu/CMForShelf.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/contextMenu/CMForUser.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageEditInfo.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/index/tree.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/search.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/shelf/shelfInfo.xhtml
===================================================================
(Binary files differ)