Author: amarkhel
Date: 2009-04-10 11:51:13 -0400 (Fri, 10 Apr 2009)
New Revision: 13501
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ShelfManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/SlideshowManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/UserManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java
trunk/test-applications/realworld2/web/src/main/webapp/includes/album/albumInfo.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/album/albumsList.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/contextMenu/CMForImage.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/imageList.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/slideshow.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/index/tree.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/userResult.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/shelf/shelfInfo.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/userSharedAlbums.xhtml
Log:
Refactoring
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java 2009-04-10
15:50:57 UTC (rev 13500)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java 2009-04-10
15:51:13 UTC (rev 13501)
@@ -112,13 +112,6 @@
Events.instance().raiseEvent(Constants.ALBUM_DELETED_EVENT, album, pathToDelete);
Events.instance().raiseEvent(Constants.CLEAR_TREE_EVENT);
}
-
- public List<Image> getUnvisitedImages(Album album){
- if(album.getCountUnvisitedImages() == 0){
- album.setUnvisitedImages(albumAction.getUnvisitedImages(album));
- }
- return album.getUnvisitedImages();
- }
public boolean isValidationSuccess() {
return validationSuccess;
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java 2009-04-10
15:50:57 UTC (rev 13500)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java 2009-04-10
15:51:13 UTC (rev 13501)
@@ -32,7 +32,6 @@
import org.jboss.seam.annotations.End;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.web.RequestParameter;
import org.jboss.seam.contexts.Contexts;
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java 2009-04-10
15:50:57 UTC (rev 13500)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java 2009-04-10
15:51:13 UTC (rev 13501)
@@ -31,7 +31,6 @@
import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.Events;
-import org.richfaces.event.DataScrollerEvent;
import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.domain.MetaTag;
@@ -58,7 +57,7 @@
}
public void selectImages(){
- model.resetModel(NavigationEnum.ALL_IMAGES, user, null, null, null, user.getAllImages()
);
+ model.resetModel(NavigationEnum.ALL_IMAGES, user, null, null, null, user.getImages()
);
}
@Restrict("#{s:hasRole('admin')}")
@@ -100,7 +99,7 @@
return;
}
model.resetModel(NavigationEnum.ALBUM_IMAGE_PREVIEW, image.getAlbum().getOwner(),
image.getAlbum().getShelf(), image.getAlbum(), image, image.getAlbum().getImages());
- image.getAlbum().visitImage(image, true);
+ image.setVisited(true);
}
@Restrict("#{s:hasRole('admin')}")
@@ -208,13 +207,11 @@
}
public void showSharedAlbums(User user){
- UserManager userManager =
(UserManager)Contexts.getEventContext().get("userManager");
- model.resetModel(NavigationEnum.USER_SHARED_ALBUMS, user, null, null, null,
userManager.getSharedImages(model.getSelectedUser()));
+ model.resetModel(NavigationEnum.USER_SHARED_ALBUMS, user, null, null, null,
user.getSharedImages());
}
public void showSharedImages(User user){
- UserManager userManager =
(UserManager)Contexts.getEventContext().get("userManager");
- model.resetModel(NavigationEnum.USER_SHARED_IMAGES, user, null, null, null,
userManager.getSharedImages(model.getSelectedUser()));
+ model.resetModel(NavigationEnum.USER_SHARED_IMAGES, user, null, null, null,
user.getSharedImages());
}
public void showUser(User user){
@@ -222,13 +219,11 @@
}
public void showUnvisitedImages(Shelf shelf){
- ShelfManager shelfManager =
(ShelfManager)Contexts.getEventContext().get("shelfManager");
- model.resetModel(NavigationEnum.SHELF_UNVISITED, shelf.getOwner(), shelf, null, null,
shelfManager.getUnvisitedImages(shelf));
+ model.resetModel(NavigationEnum.SHELF_UNVISITED, shelf.getOwner(), shelf, null, null,
shelf.getUnvisitedImages());
}
public void showUnvisitedImages(Album album){
- AlbumManager albumManager =
(AlbumManager)Contexts.getEventContext().get("albumManager");
- model.resetModel(NavigationEnum.ALBUM_UNVISITED, album.getShelf().getOwner(),
album.getShelf(), album, null, albumManager.getUnvisitedImages(album));
+ model.resetModel(NavigationEnum.ALBUM_UNVISITED, album.getShelf().getOwner(),
album.getShelf(), album, null, album.getUnvisitedImages());
}
public void showTag(MetaTag metatag){
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java 2009-04-10
15:50:57 UTC (rev 13500)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java 2009-04-10
15:51:13 UTC (rev 13501)
@@ -64,6 +64,7 @@
}
private void handleAlbum(Album dragValue, Shelf dropValue) {
+ String pathOld = dragValue.getPath();
dropValue.addAlbum(dragValue);
try{
albumAction.editAlbum(dragValue);
@@ -71,6 +72,7 @@
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.ERROR_IN_DB);
return;
}
+ Events.instance().raiseEvent(Constants.ALBUM_DRAGGED_EVENT, dragValue, pathOld);
Events.instance().raiseEvent(Constants.CLEAR_TREE_EVENT);
}
@@ -78,6 +80,7 @@
if(dragValue.getAlbum().equals(dropValue)){
return;
}
+ String pathOld = dragValue.getFullPath();
dropValue.addImage(dragValue);
try{
albumAction.editAlbum(dropValue);
@@ -85,6 +88,6 @@
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.ERROR_IN_DB);
return;
}
- Events.instance().raiseEvent(Constants.DNDUPLOADED_EVENT, dragValue);
+ Events.instance().raiseEvent(Constants.IMAGE_DRAGGED_EVENT, dragValue, pathOld);
}
}
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileManager.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileManager.java 2009-04-10
15:50:57 UTC (rev 13500)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileManager.java 2009-04-10
15:51:13 UTC (rev 13501)
@@ -185,6 +185,34 @@
return file.exists();
}
+ @Observer(Constants.ALBUM_DRAGGED_EVENT)
+ public void renameAlbumDirectory(Album album, String pathOld){
+ File file = getFileByPath(pathOld);
+ File file2 = getFileByPath(album.getPath());
+ if(file2.exists()){
+ if(file2.isDirectory()){
+ FileUtils.deleteDirectory(file2, false);
+ }else{
+ FileUtils.deleteFile(file2);
+ }
+ }
+ file.renameTo(file2);
+ }
+
+ @Observer(Constants.IMAGE_DRAGGED_EVENT)
+ public void renameImageFile(Image image, String pathOld){
+ File file = getFileByPath(pathOld);
+ File file2 = getFileByPath(image.getFullPath());
+ if(file2.exists()){
+ if(file2.isDirectory()){
+ FileUtils.deleteDirectory(file2, false);
+ }else{
+ FileUtils.deleteFile(file2);
+ }
+ }
+ file.renameTo(file2);
+ }
+
private void deleteDirectory(String directory){
final File file = getFileByPath(directory);
FileUtils.deleteDirectory(file, false);
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ShelfManager.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ShelfManager.java 2009-04-10
15:50:57 UTC (rev 13500)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ShelfManager.java 2009-04-10
15:51:13 UTC (rev 13501)
@@ -114,13 +114,6 @@
shelfs = null;
}
- public List<Image> getUnvisitedImages(Shelf shelf) {
- if (shelf.getCountUnvisitedImages() == 0) {
- shelf.setUnvisitedImages(shelfAction.getUnvisitedImages(shelf));
- }
- return shelf.getUnvisitedImages();
- }
-
public boolean isValidationSuccess() {
return validationSuccess;
}
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/SlideshowManager.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/SlideshowManager.java 2009-04-10
15:50:57 UTC (rev 13500)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/SlideshowManager.java 2009-04-10
15:51:13 UTC (rev 13501)
@@ -73,7 +73,7 @@
return;
}
this.selectedImage = model.getImages().get(this.slideshowIndex);
- this.selectedImage.getAlbum().visitImage(selectedImage, true);
+ this.selectedImage.setVisited(true);
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);
@@ -92,7 +92,7 @@
}
this.slideshowIndex = model.getImages().indexOf(selectedImage);
this.selectedImage = selectedImage;
- this.selectedImage.getAlbum().visitImage(selectedImage, true);
+ this.selectedImage.setVisited(true);
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);
@@ -134,7 +134,7 @@
}
slideshowIndex++;
selectedImage = model.getImages().get(slideshowIndex);
- this.selectedImage.getAlbum().visitImage(selectedImage, true);
+ this.selectedImage.setVisited(true);
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/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/UserManager.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/UserManager.java 2009-04-10
15:50:57 UTC (rev 13500)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/UserManager.java 2009-04-10
15:51:13 UTC (rev 13501)
@@ -34,7 +34,6 @@
import org.jboss.seam.core.Events;
import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.domain.Shelf;
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.service.IUserAction;
@@ -54,22 +53,6 @@
@In IUserAction userAction;
- public Long countSharedImages(User u) {
- return userAction.countSharedImages(u);
- }
-
- public Long countSharedAlbums(User u) {
- return userAction.countSharedAlbums(u);
- }
-
- public List<Album> getSharedAlbums(User user){
- return userAction.getSharedAlbums(user);
- }
-
- public List<Image> getSharedImages(User user){
- return userAction.getSharedImages(user);
- }
-
@Observer(Constants.EDIT_USER_EVENT)
public void editUser(){
if (avatarData != null) {
@@ -92,24 +75,4 @@
public void cancelEditUser() {
avatarData = null;
}
-
- @Observer(Constants.IMAGE_ADDED_EVENT)
- public void onImageAdded(Image image) {
- user.addImage(image);
- }
-
- @Observer(Constants.IMAGE_DELETED_EVENT)
- public void onImageDeleted(Image image, String path){
- user.removeImage(image);
- }
-
- @Observer(Constants.ALBUM_DELETED_EVENT)
- public void onAlbumDeleted(Album album, String path){
- user.removeAlbum(album);
- }
-
- @Observer(Constants.ALBUM_ADDED_EVENT)
- public void onAlbumAdded(Album album){
- user.addAlbum(album);
- }
}
\ No newline at end of file
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java 2009-04-10
15:50:57 UTC (rev 13500)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java 2009-04-10
15:51:13 UTC (rev 13501)
@@ -79,8 +79,8 @@
this.files = files;
}
- @Observer(Constants.DNDUPLOADED_EVENT)
- public void removeImage(Image image){
+ @Observer(Constants.IMAGE_DRAGGED_EVENT)
+ public void removeImage(Image image, String pathOld){
files.remove(image);
}
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/album/albumInfo.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/album/albumsList.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/contextMenu/CMForImage.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/imageList.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/slideshow.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/index/tree.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/userResult.xhtml
===================================================================
---
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/userResult.xhtml 2009-04-10
15:50:57 UTC (rev 13500)
+++
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/userResult.xhtml 2009-04-10
15:51:13 UTC (rev 13501)
@@ -28,7 +28,7 @@
</h:outputText>
</h:panelGroup>
<h:panelGroup layout="block" styleClass="photo_data">
- <a4j:commandLink reRender="tree, mainArea"
actionListener="#{controller.showSharedAlbums(searchedUser)}"
><h:outputText value="#{userManager.countSharedAlbums(searchedUser)} albums
"/></a4j:commandLink> | <a4j:commandLink reRender="mainArea"
actionListener="#{controller.showSharedImages(searchedUser)}"><h:outputText
value="#{userManager.countSharedImages(searchedUser)}
photos"/></a4j:commandLink>
+ <a4j:commandLink reRender="tree, mainArea"
actionListener="#{controller.showSharedAlbums(searchedUser)}"
><h:outputText value="#{searchedUser.sharedAlbums.size} albums
"/></a4j:commandLink> | <a4j:commandLink reRender="mainArea"
actionListener="#{controller.showSharedImages(searchedUser)}"><h:outputText
value="#{searchedUser.sharedImages.size} photos"/></a4j:commandLink>
</h:panelGroup>
</h:panelGroup>
</a4j:repeat>
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/shelf/shelfInfo.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/userSharedAlbums.xhtml
===================================================================
(Binary files differ)