Author: amarkhel
Date: 2009-04-03 09:32:44 -0400 (Fri, 03 Apr 2009)
New Revision: 13375
Added:
trunk/test-applications/realworld2/web/src/main/webapp/includes/album/createAlbum.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/confirmation.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/help.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/shelf/createShelf.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/userPrefs/avatar.xhtml
Removed:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileItem.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/FileManagerTest.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test.java
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/tags/templates/
trunk/test-applications/realworld2/web/src/main/webapp/main.xhtml
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Album.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Image.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Shelf.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/User.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ISearchAction.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IUserAction.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/SearchAction.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java
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/ImageManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Model.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/RegistrationManager.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/TreeManager.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/search/ISearchOption.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/ImageSearchHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByAlbum.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByImage.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByShelf.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByTag.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByUser.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ConfirmationPopupHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java
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/ImageSizeHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ErrorHandlerBean.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/Help.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/pages.xml
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/tags/realWorld-taglib.xml
trunk/test-applications/realworld2/web/src/main/webapp/includes/album/albumsList.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/directImage.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/fileUpload/uploadResult.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/image.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/imageAdditionalInfo.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/imageEditInfo.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/imageInfo.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/imageEdit.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/index/menu.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/index/tree.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/errorPanel.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/inputNumberSlider.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/modalPanels.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/imageResult.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/userResult.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/searchWidget.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/tag.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/userPrefs/userPrefs.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/userPrefs/userPrefsEdit.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/layout/template.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/scripts/realworld.js
Log:
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Album.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Album.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Album.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -46,6 +46,7 @@
import org.hibernate.validator.NotEmpty;
import org.hibernate.validator.NotNull;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Role;
import org.jboss.seam.annotations.Scope;
@@ -59,6 +60,7 @@
@Name("album")
@Table(name = "albums")
@Scope(ScopeType.CONVERSATION)
+@AutoCreate
public class Album implements Serializable {
private static final long serialVersionUID = -7042878411608396483L;
@@ -72,7 +74,6 @@
@NotNull
@NotEmpty
@Length(min = 3, max = 50)
- //TODO nick - add maxLength validation here and everywhere?
private String name;
@Column(length = 1024)
@@ -166,18 +167,16 @@
public void addImage(Image image) {
if (image == null) {
throw new IllegalArgumentException("Null image!");
+ }if(this.getImages().contains(image)){
+ return;
}
if (image.getAlbum() != null && !this.equals(image.getAlbum())) {
//TODO nick - use removeImage()
- if(image.getAlbum().getUnvisitedImages().contains(image)){
- image.getAlbum().getUnvisitedImages().remove(image);
- }
- if(image.getAlbum().getShelf().getUnvisitedImages().contains(image)){
- image.getAlbum().getShelf().getUnvisitedImages().remove(image);
- }
image.getAlbum().removeImage(image);
+ }if(!image.isVisited()){
+ this.getShelf().getUnvisitedImages().add(image);
+ this.getUnvisitedImages().add(image);
}
- this.setUnvisitedImages(new ArrayList<Image>());
image.setAlbum(this);
images.add(image);
}
@@ -194,6 +193,12 @@
}
//TODO nick - check if image is in the current album
if(image.getAlbum().equals(this)){
+ if(image.getAlbum().getUnvisitedImages().contains(image)){
+ image.getAlbum().getUnvisitedImages().remove(image);
+ }
+ if(image.getAlbum().getShelf().getUnvisitedImages().contains(image)){
+ image.getAlbum().getShelf().getUnvisitedImages().remove(image);
+ }
image.setAlbum(null);
images.remove(image);
}else{
@@ -268,10 +273,14 @@
this.unvisitedImages = unvisitedImages;
}
- public void visitImage(Image image) {
+ public void visitImage(Image image, boolean isSetVisited) {
if (unvisitedImages.contains(image)) {
unvisitedImages.remove(image);
+ if(this.getShelf().getUnvisitedImages().contains(image)){
+ this.getShelf().getUnvisitedImages().remove(image);
+ }
}
+ image.setVisited(isSetVisited);
}
public void setCoveringImage(Image coveringImage) {
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Image.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Image.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Image.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -52,9 +52,11 @@
import org.hibernate.validator.NotEmpty;
import org.hibernate.validator.NotNull;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Role;
import org.jboss.seam.annotations.Scope;
+import org.richfaces.realworld.service.ActionTools;
@NamedQueries({
@NamedQuery(
@@ -74,6 +76,7 @@
@Name("image")
@Table(name = "Images")
@Scope(ScopeType.CONVERSATION)
+@AutoCreate
public class Image implements Serializable {
private static final long serialVersionUID = -7042878411608396483L;
@@ -108,7 +111,8 @@
referencedColumnName = "METATAG_ID"))
protected List<MetaTag> imageTags = new ArrayList<MetaTag>();
-
+ @Transient
+ private boolean visited;
/*
* Comma separated tag value
* */
@@ -388,4 +392,19 @@
result = 31 * result + (path != null ? path.hashCode() : 0);
return result;
}
+
+ public boolean isVisited() {
+ return visited;
+ }
+
+ public void setVisited(boolean visited) {
+ this.visited = visited;
+ }
+
+ public boolean isNew(){
+ if(!visited){
+ return this.getUploaded().after(ActionTools.getRecentlyDate());
+ }
+ return false;
+ }
}
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Shelf.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Shelf.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/Shelf.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -23,6 +23,7 @@
import org.hibernate.validator.NotEmpty;
import org.hibernate.validator.NotNull;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
@@ -30,6 +31,7 @@
@Name("shelf")
@Scope(ScopeType.CONVERSATION)
@Table(name = "shelves")
+@AutoCreate
public class Shelf implements Serializable {
private static final long serialVersionUID = -7042878411608396483L;
@@ -124,22 +126,26 @@
public void addAlbum(Album album) {
if (album == null)
- throw new IllegalArgumentException("Null child!");
- if (album.getShelf() != null){
- //TODO nick - use removeChildAlbum()
- album.getShelf().setUnvisitedImages(new ArrayList<Image>());
- album.getShelf().removeChildAlbum(album);
+ throw new IllegalArgumentException("Null album!");
+ if (album.getShelf() != null &&
!album.getShelf().getAlbums().contains(this)){
+ album.getShelf().removeAlbum(album);
+ album.setShelf(this);
+ for(Image i : album.getImages()){
+ if(i.isNew()){
+ this.getUnvisitedImages().add(i);
+ }
+ }
+ albums.add(album);
}
- album.setShelf(this);
- this.setUnvisitedImages(new ArrayList<Image>());
- albums.add(album);
}
- public void removeChildAlbum(Album album) {
+ public void removeAlbum(Album album) {
if (album == null)
- throw new IllegalArgumentException("Null child!");
- //TODO nick - check that shelf is "this"
+ throw new IllegalArgumentException("Null album!");
if(album.getShelf().equals(this)){
+ for(Image i : album.getImages()){
+ album.visitImage(i, false);
+ }
album.setShelf(null);
albums.remove(album);
}else{
@@ -195,12 +201,6 @@
this.unvisitedImages = unvisitedImages;
}
- public void visitImage(Image image) {
- if (unvisitedImages.contains(image)) {
- unvisitedImages.remove(image);
- }
- }
-
public Album getFirstAlbum() {
//TODO nick - use random album for cover?
if (this.albums.size() > 0) {
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/User.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/User.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/domain/User.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -121,7 +121,10 @@
@NotNull
private Sex sex;
-
+ @Transient
+ private Long countImages;
+ @Transient
+ private Long countAlbums;
private Boolean hasAvatar;
@OneToMany(mappedBy = "owner", cascade = { CascadeType.ALL})
@@ -192,9 +195,10 @@
if (shelf == null) {
throw new IllegalArgumentException("Null shelf!");
}
- //TODO nick - remove shelf from the previous user?
- shelf.setOwner(this);
- shelfs.add(shelf);
+ if(!shelfs.contains(shelf)){
+ shelf.setOwner(this);
+ shelfs.add(shelf);
+ }
}
public void removeShelf(Shelf shelf) {
@@ -210,6 +214,11 @@
}
}
+ public void updateStatistics() {
+ countAlbums = null;
+ countImages = null;
+ }
+
public String getConfirmPassword() {
return confirmPassword;
}
@@ -263,4 +272,20 @@
}
return images;
}
+
+ public Long getCountImages() {
+ return countImages;
+ }
+
+ public void setCountImages(Long countImages) {
+ this.countImages = countImages;
+ }
+
+ public Long getCountAlbums() {
+ return countAlbums;
+ }
+
+ public void setCountAlbums(Long countAlbums) {
+ this.countAlbums = countAlbums;
+ }
}
\ No newline at end of file
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -56,10 +56,10 @@
}
public void deleteAlbum(Album album){
- if(album.getShelf()!=null){
- album.getShelf().setUnvisitedImages(new ArrayList<Image>());
+ if(album.getShelf()==null){
+ return;
}
- album.getShelf().removeChildAlbum(album);
+ album.getShelf().removeAlbum(album);
em.remove(album);
if(flushStrategy.isDatabaseStoreStrategy()){
em.flush();
@@ -74,7 +74,7 @@
public List<Image> getUnvisitedImages(Album album){
//TODO nick - use Shelf/Album.unvisitedImages
- return (List<Image>)em.createQuery("from Image i where i.album=:album and
i.created >= :date").setParameter("album",
album).setParameter("date", getDate()).getResultList();
+ return (List<Image>)em.createQuery("from Image i where i.album=:album and
i.uploaded > :date").setParameter("album",
album).setParameter("date", getDate()).getResultList();
}
private Date getDate() {
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ISearchAction.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ISearchAction.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ISearchAction.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -2,17 +2,20 @@
import java.util.List;
+import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.domain.MetaTag;
import org.richfaces.realworld.domain.Shelf;
+import org.richfaces.realworld.domain.User;
public interface ISearchAction {
public List<Image> searchByImage(String query, boolean searchInMyAlbums, boolean
searchInShared);
- public List<Image> searchByTags(String query, boolean searchInMyAlbums, boolean
searchInShared);
+ public List<MetaTag> searchByTags(String query, boolean searchInMyAlbums, boolean
searchInShared);
- public List<Image> searchByAlbum(String query, boolean searchInMyAlbums, boolean
searchInShared);
+ public List<Album> searchByAlbum(String query, boolean searchInMyAlbums, boolean
searchInShared);
- public List<Image> searchByUsers(String query, boolean searchInMyAlbums, boolean
searchInShared);
+ public List<User> searchByUsers(String query, boolean searchInMyAlbums, boolean
searchInShared);
public List<Shelf> searchByShelfs(String query,boolean searchInMyAlbums, boolean
searchInShared);
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IUserAction.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IUserAction.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IUserAction.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -35,8 +35,8 @@
public boolean isUserExist(String login);
public User updateUser();
public User resetUser();
- public Long countAlbums(User user);
- public Long countImages(User user);
+ public Long countAlbums();
+ public Long countImages();
public Long countSharedImages(User u);
public Long countSharedAlbums(User user);
public List<Album> getSharedAlbums(User user);
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/SearchAction.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/SearchAction.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/SearchAction.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -10,7 +10,9 @@
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
+import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.domain.MetaTag;
import org.richfaces.realworld.domain.Shelf;
import org.richfaces.realworld.domain.User;
@@ -27,7 +29,7 @@
@In @Out
private User user;
- public List<Image> searchByAlbum(String searchQuery, boolean searchInMyAlbums,
boolean searchInShared) {
+ public List<Album> searchByAlbum(String searchQuery, boolean searchInMyAlbums,
boolean searchInShared) {
StringBuilder b = new StringBuilder("from Album a where lower(a.name) like :name
or lower(a.description) like :name");
if (searchInMyAlbums) {
b.append(" and a.owner.login=:login");
@@ -67,7 +69,7 @@
return query.getResultList();
}
- public List<Image> searchByUsers(String searchQuery, boolean searchInMyAlbums,
boolean searchInShared) {
+ public List<User> searchByUsers(String searchQuery, boolean searchInMyAlbums,
boolean searchInShared) {
StringBuilder b = new StringBuilder("select u from User u where lower(u.login)
like :name or lower(u.firstName) like :name or lower(u.secondName) like :name");
Query query = em.createQuery(b.toString());
@@ -76,7 +78,7 @@
return query.getResultList();
}
- public List<Image> searchByTags(String searchQuery, boolean searchInMyAlbums,
boolean searchInShared) {
+ public List<MetaTag> searchByTags(String searchQuery, boolean searchInMyAlbums,
boolean searchInShared) {
StringBuilder b = new StringBuilder("from MetaTag t where lower(t.tag) like
:name");
Query query = em.createQuery(b.toString());
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -86,7 +86,7 @@
return (List<Image>)em.createQuery("from Image i where
i.album.shelf.owner=:user and
i.album.shelf.shared=true").setParameter("user", user).getResultList();
}
- public Long countAlbums(User user){
+ public Long countAlbums(){
return (Long)em.createQuery("select count(a) from Album a where
a.shelf.owner=:user").setParameter("user", user).getSingleResult();
}
@@ -94,7 +94,7 @@
return (Long)em.createQuery("select count(a) from Album a where
a.shelf.owner=:user and a.shelf.shared=true").setParameter("user",
user).getSingleResult();
}
- public Long countImages(User user){
+ public Long countImages(){
return (Long)em.createQuery("select count(i) from Image i where
i.album.shelf.owner=:user").setParameter("user", user).getSingleResult();
}
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-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/AlbumManager.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -31,6 +31,7 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.Events;
import org.jboss.seam.faces.FacesMessages;
@@ -57,6 +58,7 @@
@In FacesMessages facesMessages;
@In @Out Model model;
+ @Restrict("#{s:hasRole('admin')}")
public void addAlbum(Album album){
if(album.getShelf() == null){
facesMessages.addToControl("shelf", "Shelf must be not-null",
null);
@@ -73,6 +75,7 @@
Events.instance().raiseEvent("clearTree");
}
+ @Restrict("#{s:hasRole('admin')}")
public void createAlbum(Shelf shelf){
Album album = new Album();
if(shelf == null){
@@ -80,7 +83,7 @@
shelf = user.getShelfs().get(0);
}
if(shelf == null){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception("You must
create at least one shelf before creating album!"));
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, "You must create at
least one shelf before creating album!");
return;
}
}
@@ -88,12 +91,14 @@
Contexts.getConversationContext().set("album", album);
}
+ @Restrict("#{s:hasRole('admin')}")
public void editAlbum(Album album){
albumAction.editAlbum(album);
model.resetModel(NavigationEnum.ALBUM_PREVIEW, model.getSelectedUser(),
model.getSelectedShelf(), album, null);
Events.instance().raiseEvent("albumEdited");
}
+ @Restrict("#{s:hasRole('admin')}")
public void deleteAlbum(Album album){
//Update domain model
String string = album.getId().toString();
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-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -80,7 +80,6 @@
private boolean loginFailed = false;
public String login(){
- setLoginFailed(false);
if(identity.hasRole("admin")){
//TODO nick - return null
return "";
@@ -93,7 +92,7 @@
try {
identity.authenticate();
//TODO nick - maybe clearShelves() before trying to aunthenticate?
- shelfManager.clearShelfs();
+ //shelfManager.clearShelfs();
} catch (LoginException e) {
setLoginFailed(true);
credentials.clear();
@@ -105,7 +104,7 @@
}
return "main";
}
-
+
public boolean authenticate()
{
if (wantLoginAnonymous()) {
@@ -136,18 +135,6 @@
return "logout";
}
- public String loginAnonymous(){
- credentials.setUsername(null);
- credentials.setPassword(null);
- try {
- identity.authenticate();
- } catch (LoginException e) {
- facesMessages.add(INVALID_LOGIN_OR_PASSWORD);
- return "";
- }
- return Constants.MAIN_OUTCOME;
- }
-
public String start(){
if(!identity.isLoggedIn()){
credentials.clear();
@@ -184,6 +171,4 @@
public void setLoginFailed(boolean loginFailed) {
this.loginFailed = loginFailed;
}
-
-
}
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-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -28,6 +28,7 @@
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Synchronized;
+import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.core.Events;
import org.richfaces.event.DataScrollerEvent;
import org.richfaces.realworld.domain.Album;
@@ -38,8 +39,7 @@
import org.richfaces.realworld.service.Constants;
@Name("controller")
-(a)Scope(ScopeType.CONVERSATION)
-@Synchronized(timeout=200000)
+(a)Scope(ScopeType.EVENT)
public class Controller implements Serializable{
private static final long serialVersionUID = 5656562187249324512L;
@@ -69,11 +69,13 @@
public void selectImages(){
model.resetModel(NavigationEnum.ALL_IMAGES, user, null, null, null);
+ model.setImages(user.getAllImages());
}
+ @Restrict("#{s:hasRole('admin')}")
public void startEditShelf(Shelf shelf){
if(!canViewShelf(shelf)){
- pushEvent(Constants.ADD_ERROR_EVENT, new Exception(HAVENT_ACCESS));
+ pushEvent(Constants.ADD_ERROR_EVENT, HAVENT_ACCESS);
return;
}
model.resetModel(NavigationEnum.SHELF_EDIT, shelf.getOwner(), shelf, null, null);
@@ -86,7 +88,7 @@
public void showAlbum(Album album){
if(!canViewAlbum(album)){
- pushEvent(Constants.ADD_ERROR_EVENT, new Exception(HAVENT_ACCESS));
+ pushEvent(Constants.ADD_ERROR_EVENT, HAVENT_ACCESS);
return;
}
model.resetModel(NavigationEnum.ALBUM_PREVIEW, album.getOwner(), album.getShelf(),
album, null);
@@ -95,14 +97,13 @@
public void showImage(Image image){
if(!canViewImage(image)){
- pushEvent(Constants.ADD_ERROR_EVENT, new Exception(HAVENT_ACCESS));
+ pushEvent(Constants.ADD_ERROR_EVENT, HAVENT_ACCESS);
return;
}
model.resetModel(NavigationEnum.ALBUM_IMAGE_PREVIEW, image.getAlbum().getOwner(),
image.getAlbum().getShelf(), image.getAlbum(), image);
//TODO nick - model should already has enough information to set up image index
model.setSelectedImageIndex(model.getSelectedAlbum().getIndex(model.getSelectedImage())+1);
- image.getAlbum().getShelf().visitImage(image);
- image.getAlbum().visitImage(image);
+ image.getAlbum().visitImage(image, true);
}
public void scroll(DataScrollerEvent e){
@@ -110,14 +111,13 @@
model.setSelectedImageIndex(index);
Image image = model.getSelectedAlbum().getImages().get(index - 1);
model.resetModel(NavigationEnum.ALBUM_IMAGE_PREVIEW, image.getAlbum().getOwner(),
image.getAlbum().getShelf(), image.getAlbum(), image);
- image.getAlbum().visitImage(image);
- //TODO nick - album can notify shelf
- image.getAlbum().getShelf().visitImage(image);
+ image.getAlbum().visitImage(image, true);
}
+ @Restrict("#{s:hasRole('admin')}")
public void startEditImage(Image image){
if(!canViewImage(image)){
- pushEvent(Constants.ADD_ERROR_EVENT, new Exception(HAVENT_ACCESS));
+ pushEvent(Constants.ADD_ERROR_EVENT, HAVENT_ACCESS);
return;
}
//TODO nick - resetModel?
@@ -141,9 +141,10 @@
return image.getAlbum().getOwner().getLogin().equals(user.getLogin());
}
+ @Restrict("#{s:hasRole('admin')}")
public void startEditAlbum(Album album){
if(!album.getOwner().getLogin().equals(user.getLogin())){
- pushEvent(Constants.ADD_ERROR_EVENT, new Exception(HAVENT_ACCESS));
+ pushEvent(Constants.ADD_ERROR_EVENT, HAVENT_ACCESS);
return;
}
//TODO nick - resetModel?
@@ -160,7 +161,7 @@
public void showFileUpload(){
if(!(user.getShelfs().size() > 0)){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception("You must
create at least one shelf before creating album!"));
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, "You must create at least
one shelf before creating album!");
return;
}
model.setMainArea(NavigationEnum.FILE_UPLOAD);
@@ -204,7 +205,7 @@
public void showUnvisitedImages(Album album){
model.resetModel(NavigationEnum.ALBUM_UNVISITED, album.getShelf().getOwner(),
album.getShelf(), album, null);
- model.setImages(album.getUnvisitedImages());
+ model.setImages(albumManager.getUnvisitedImages(album));
}
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-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/DnDManager.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -24,6 +24,7 @@
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.core.Events;
import org.richfaces.component.Dropzone;
import org.richfaces.event.DropEvent;
@@ -43,13 +44,14 @@
@In FileManager fileManager;
@In IAlbumAction albumAction;
+ @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, new Exception("You
can't add photo's to that album"));
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, "You can't add
photo's to that album");
return;
}
handleImage((Image)dragValue, (Album)dropValue);
@@ -73,8 +75,9 @@
String newPath = getNewPathOfImage(dragValue, dropValue);
dragValue.setPath(newPath);
dropValue.addImage(dragValue);
- dropValue.setUnvisitedImages(new ArrayList<Image>());
albumAction.editAlbum(dropValue);
+ Events.instance().raiseEvent("DNDUploadedEvent", dragValue);
+
}
private String getNewPathOfImage(Image dragValue, Album dropValue) {
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-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileManager.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -26,6 +26,7 @@
import org.jboss.seam.annotations.Create;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.security.Restrict;
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.service.Constants;
@@ -63,31 +64,8 @@
private static final String UPLOAD_ROOT_COMPONENT_NAME = "uploadRoot";
private static final String UPLOAD_ROOT_PATH_COMPONENT_NAME =
"uploadRootPath";
- private static final String IMAGE_JAR = "images.jar";
-
private File uploadRoot;
private String uploadRootPath;
-
- /* @Create
- public void create() {
- uploadRoot = (File) Component.getInstance(UPLOAD_ROOT_COMPONENT_NAME,
ScopeType.APPLICATION);
- if (!uploadRoot.exists() && !uploadRoot.mkdir()) {
- logError("Can't create directory: " + uploadRoot.getName(),
null);
- }
-
- uploadRootPath = (String) Component.getInstance(UPLOAD_ROOT_PATH_COMPONENT_NAME,
ScopeType.APPLICATION);
-
- final JarFile jarFile;
- try {
- jarFile = new JarFile(this.getClass().getClassLoader()
- .getResource("WEB-INF/lib/" + IMAGE_JAR).getPath());
- } catch (IOException e) {
- logError(IMAGE_JAR + " not found, please check it in WEB-INF/lib ",
e);
- return;
- }
-
- extract(jarFile);
- }*/
@Create
public void create() {
@@ -112,98 +90,20 @@
}
}
- private String joinFiles(String... files) {
- final StringBuilder res = new StringBuilder();
- for (String file : files) {
- res.append(file).append(File.pathSeparatorChar);
- }
-
- return res.substring(0, res.length() - 1);
- }
-
- private void logError(String s, Exception e) {
- if (s != null) {
- System.out.println(s);
- }
-
- if (e != null) {
- e.printStackTrace();
- }
- }
-
- public void extract(JarFile jarFile) {
- final Enumeration<JarEntry> entries = jarFile.entries();
- while (entries.hasMoreElements()) {
- final JarEntry jarEntry = entries.nextElement();
- System.out.println("Extracting file : " + jarEntry.getName());
- final File tmpFile = new File(joinFiles(uploadRootPath,
jarEntry.getName()));
- if (jarEntry.isDirectory()) {
- if (!tmpFile.mkdir()) {
- logError("Can't create directory: " +
tmpFile.getName(), null);
- return;
- }
- } else {
- extractEntryFile(jarFile, jarEntry, tmpFile);
- }
- }
- }
-
- private void extractEntryFile(JarFile jarFile, ZipEntry jarEntry, File tmpFile) {
- try {
- final InputStream in = jarFile.getInputStream(jarEntry);
- final FileOutputStream out = new FileOutputStream(tmpFile);
-
- int readedBytes = in.read();
- while (readedBytes != -1) {
- out.write(readedBytes);
- readedBytes = in.read();
- }
-
- out.close();
- in.close();
- } catch (FileNotFoundException e) {
- logError(e.getMessage(), e);
- } catch (IOException e) {
- logError(e.getMessage(), e);
- }
- }
-
-/* public void setUploadRoot(String uploadRootPath) throws IOException {
- if (uploadRootPath != null) {
- this.uploadRoot = new File(uploadRootPath);
- for (String f : uploadRoot.list()) {
- final File temp = new File(uploadRoot, f);
- temp.delete();
- }
- uploadRoot.delete();
- uploadRoot.mkdirs();
- this.uploadRootPath = this.uploadRoot.getCanonicalPath() + File.separator;
- } else {
- this.uploadRoot = null;
- this.uploadRootPath = null;
- }
- }*/
-
-
- private File getFileByPath(String path) {
+ public File getFileByPath(String path) {
if (this.uploadRoot != null) {
File result = new File(this.uploadRoot, path);
-
try {
final String resultCanonicalPath = result.getCanonicalPath();
if (!resultCanonicalPath.startsWith(this.uploadRootPath)) {
- // TODO log error
result = null;
}
return result;
} catch (IOException e) {
- // TODO: handle exception
result = null;
}
-
return result;
}
-
return null;
}
@@ -212,6 +112,7 @@
return file.exists() && file.isDirectory();
}
+ @Restrict("#{s:hasRole('admin')}")
public void deleteDirectory(String... directories) {
final File file = getFileByPath(joinFiles(directories).toString());
if (file.exists()) {
@@ -223,6 +124,17 @@
}
}
+
+ private String joinFiles(String... files) {
+ final StringBuilder res = new StringBuilder();
+ for (String file : files) {
+ res.append(file).append(File.pathSeparatorChar);
+ }
+
+ return res.substring(0, res.length() - 1);
+ }
+
+ @Restrict("#{s:hasRole('admin')}")
public boolean renameDirectory(String directoryOld, String directoryNew) {
final File fileOld = getFileByPath(directoryOld);
final File fileNew = getFileByPath(directoryNew);
@@ -239,6 +151,7 @@
return true;
}
+ @Restrict("#{s:hasRole('admin')}")
public void addDirectory(String... directories) {
final StringBuilder directory = new StringBuilder();
for (String chunk : directories) {
@@ -249,11 +162,13 @@
file.mkdirs();
}
+ @Restrict("#{s:hasRole('admin')}")
public boolean saveAvatar(String path, User user) {
return writeFile("/" + user.getLogin() +
"/avatar.jpg", path, "", 80, true);
}
+ @Restrict("#{s:hasRole('admin')}")
public void renameImage(String fileNameOld, String fileNameNew) {
createDirectoryIfNotExist(fileNameNew);
renameImage(getFileByPath(fileNameNew), getFileByPath(fileNameOld));
@@ -274,7 +189,7 @@
getFileByPath(transformPath(fileNameOld, _SMALL200)));
}
-
+ @Restrict("#{s:hasRole('admin')}")
public void deleteImage(String fileName) {
deleteImage(getFileByPath(fileName));
deleteImage(getFileByPath(transformPath(fileName, _MEDIUM)));
@@ -284,6 +199,7 @@
deleteImage(getFileByPath(transformPath(fileName, _SMALL200)));
}
+ @Restrict("#{s:hasRole('admin')}")
public boolean addImage(String fileName, String tempFilePath) {
createDirectoryIfNotExist(fileName);
if(!writeFile(fileName, tempFilePath, _SMALL80, 80, true)){
@@ -395,6 +311,7 @@
return ret;
}
+ @Restrict("#{s:hasRole('admin')}")
public boolean writeFile(String newFileName, String fileName,
String pattern, int size, boolean includeUploadRoot) {
BufferedImage bsrc = null;
@@ -462,17 +379,7 @@
return getFileByPath(fileName) != null &&
getFileByPath(fileName).exists() && !getFileByPath(fileName).isDirectory();
}
- public File getImage(String fileName) {
- if (isImagePresent(fileName)) {
- return getFileByPath(fileName);
- }
- return null;
- }
-
- public File getImageFile(String fileName) {
- return new File(fileName);
- }
-
+ @Restrict("#{s:hasRole('admin')}")
public void deleteDirectories(Iterable<String> directoriesToDelete) {
for (String directory : directoriesToDelete) {
deleteDirectory(directory);
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ImageManager.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -23,6 +23,10 @@
import java.util.Date;
import java.util.List;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.servlet.http.HttpServletRequest;
+
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
@@ -30,21 +34,24 @@
import org.jboss.seam.annotations.Observer;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.core.Events;
import org.richfaces.realworld.domain.Comment;
import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.domain.MetaTag;
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.service.Constants;
-import org.richfaces.realworld.service.FlushStrategy;
import org.richfaces.realworld.service.IImageAction;
-import org.richfaces.realworld.util.DirectLinkHelper;
@Name("imageManager")
-(a)Scope(ScopeType.CONVERSATION)
+(a)Scope(ScopeType.EVENT)
@AutoCreate
public class ImageManager {
+ private static final String IMAGE_DIRECT_LINK =
"/includes/directImage.seam?imageId=";
+
+ private static String imageDirectLinkPrefix;
+
@In
IImageAction imageAction;
@@ -57,6 +64,7 @@
@In
private User user;
+ @Restrict("#{s:hasRole('admin')}")
public void deleteImage(Image image) {
//TODO nick - should we check image owner?
String imagePath = image.getPath();
@@ -68,12 +76,14 @@
Events.instance().raiseEvent("imageDeleted");
}
+ @Restrict("#{s:hasRole('admin')}")
public void editImage(Image image) {
imageAction.editImage(image);
Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
NavigationEnum.ALBUM_IMAGE_PREVIEW);
Events.instance().raiseEvent("imageEdited");
}
+ @Restrict("#{s:hasRole('admin')}")
//TODO nick - Constants.ADD_IMAGE_EVENT is not used anywhere else
@Observer(Constants.ADD_IMAGE_EVENT)
public void addImage(Image image) {
@@ -82,12 +92,13 @@
Events.instance().raiseEvent("imageAdded");
}
+ @Restrict("#{s:hasRole('admin')}")
public void addComment(Image image, String message) {
if (null == user.getLogin()) {
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception("For vote on this picture you must login"));
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, "For vote on
this picture you must login");
return;
}if(message.trim().equals("")){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception("Comment must be not-null"));
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, "Comment must be
not-null");
return;
}
Comment comment = new Comment();
@@ -99,6 +110,7 @@
Events.instance().raiseEvent(Constants.CLEAR_EDITOR_EVENT, "");
}
+ @Restrict("#{s:hasRole('admin')}")
public void deleteComment(Comment comment) {
imageAction.deleteComment(comment);
}
@@ -114,4 +126,31 @@
}
return imageAction.getTagsLikeString((String)suggest);
}
+
+ public String getImageDirectLink(Image image) {
+ if (imageDirectLinkPrefix == null) {
+ FacesContext context = FacesContext.getCurrentInstance();
+ if (context == null) {
+ return null;
+ }
+ ExternalContext extc = context.getExternalContext();
+ if (extc == null) {
+ return null;
+ }
+
+ //TODO nick - see
org.ajax4jsf.renderkit.RendererUtils#encodeResourceURL(TemplateContext, Object)
+ Object request = extc.getRequest();
+
+ if (request instanceof HttpServletRequest) {
+ HttpServletRequest servletRequest = (HttpServletRequest)request;
+ String contextPath = servletRequest.getContextPath();
+ StringBuffer url = servletRequest.getRequestURL();
+ int i = url.indexOf(contextPath);
+ if (i > 0) {
+ imageDirectLinkPrefix = url.substring(0, i) + contextPath + IMAGE_DIRECT_LINK;
+ }
+ }
+ }
+ return imageDirectLinkPrefix + image.getId();
+ }
}
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Model.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Model.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Model.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -1,5 +1,6 @@
package org.richfaces.realworld.manager;
+import java.io.Serializable;
import java.util.List;
import org.jboss.seam.ScopeType;
@@ -18,9 +19,10 @@
@Name("model")
@Scope(ScopeType.CONVERSATION)
@AutoCreate
-public class Model {
+public class Model implements Serializable{
-private Integer selectedImageIndex = 1;
+ private static final long serialVersionUID = -1767281809514660171L;
+ private Integer selectedImageIndex = 1;
private Image selectedImage;
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/RegistrationManager.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/RegistrationManager.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/RegistrationManager.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -1,5 +1,7 @@
package org.richfaces.realworld.manager;
+import java.io.Serializable;
+
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -21,9 +23,10 @@
import org.richfaces.realworld.ui.PasswordHolder;
@Name("registerManager")
-(a)Scope(ScopeType.CONVERSATION)
-public class RegistrationManager {
-
+(a)Scope(ScopeType.EVENT)
+public class RegistrationManager implements Serializable{
+
+ private static final long serialVersionUID = -1767281809514660171L;
@In("#{messages['user.exist']}") private String
USER_WITH_THIS_LOGIN_ALREADY_EXIST;
@In("#{messages['user.confirm.error']}") private String
CONFIRM_PASSWORD_NOT_EQUALS_PASSWORD;
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-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/ShelfManager.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -31,6 +31,7 @@
import org.jboss.seam.annotations.Observer;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.Events;
import org.richfaces.realworld.domain.Album;
@@ -61,12 +62,13 @@
@In
User user;
- //TODO nick - rename to createShelf
+ @Restrict("#{s:hasRole('admin')}")
public void createShelf() {
Shelf shelf = new Shelf();
Contexts.getConversationContext().set("shelf", shelf);
}
+ @Restrict("#{s:hasRole('admin')}")
public void addShelf(Shelf shelf) {
validationSuccess = true;
shelfAction.addShelf(shelf);
@@ -78,11 +80,13 @@
return user.getShelfs();
}
+ @Restrict("#{s:hasRole('admin')}")
public void editShelf(Shelf shelf) {
shelfAction.editShelf(shelf);
model.resetModel(NavigationEnum.SHELF_PREVIEW, model.getSelectedUser(), shelf,
null, null);
}
+ @Restrict("#{s:hasRole('admin')}")
public void deleteShelf(Shelf shelf) {
//Update domain model
List<String> directoriesToDelete = new ArrayList<String>();
@@ -92,6 +96,7 @@
shelfAction.deleteShelf(shelf);
deleteDirectories(directoriesToDelete);
model.resetModel(NavigationEnum.ALL_SHELFS, model.getSelectedUser(), null, null,
null);
+ Events.instance().raiseEvent("shelfDeleted");
Events.instance().raiseEvent("clearTree");
}
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-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/SlideshowManager.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -24,8 +24,11 @@
import java.util.List;
import org.jboss.seam.ScopeType;
+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.core.Events;
import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.service.Constants;
@@ -36,9 +39,10 @@
private static final long serialVersionUID = 7801877176558409702L;
private Integer slideshowIndex;
private Image selectedImage;
- private List<Image> images;
private boolean active;
+ @In @Out Model model;
+
private int interval = Constants.INITIAL_DELAY;
public int getInterval() {
@@ -57,27 +61,32 @@
this.active = active;
}
- public void startSlideshow(List<Image> images){
+ public void startSlideshow(){
active = true;
- this.images = images;
this.slideshowIndex = 0;
- this.selectedImage = this.images.get(this.slideshowIndex);
- this.selectedImage.getAlbum().visitImage(selectedImage);
- this.selectedImage.getAlbum().getShelf().visitImage(selectedImage);
+ if(model.getImages() == null || model.getImages().size() < 1){
+ stopSlideshow();
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, "No images for
slideshow!");
+ return;
+ }
+ this.selectedImage = model.getImages().get(this.slideshowIndex);
+ this.selectedImage.getAlbum().visitImage(selectedImage, true);
}
- public void startSlideshow(List<Image> images, Image selectedImage){
+ public void startSlideshow(Image selectedImage){
active = true;
- this.images = images;
- this.slideshowIndex = images.indexOf(selectedImage);
+ if(model.getImages() == null || model.getImages().size() < 1){
+ stopSlideshow();
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, "No images for
slideshow!");
+ return;
+ }
+ this.slideshowIndex = model.getImages().indexOf(selectedImage);
this.selectedImage = selectedImage;
- this.selectedImage.getAlbum().visitImage(selectedImage);
- this.selectedImage.getAlbum().getShelf().visitImage(selectedImage);
+ this.selectedImage.getAlbum().visitImage(selectedImage, true);
}
public void stopSlideshow(){
active = false;
- this.images = null;
this.selectedImage = null;
this.slideshowIndex = 0;
}
@@ -97,26 +106,17 @@
public void setSelectedImage(Image selectedImage) {
this.selectedImage = selectedImage;
}
-
- public List<Image> getImages() {
- return images;
- }
-
- public void setImages(List<Image> images) {
- this.images = images;
- }
public void showNextImage(){
if(!active){
return;
}
- if(slideshowIndex == images.size() - 1){
+ if(slideshowIndex == model.getImages().size() - 1){
slideshowIndex = -1;
}
//TODO nick - this will start slideshow from the 2nd image (slideshowIndex == 1)
slideshowIndex++;
- selectedImage = images.get(slideshowIndex);
- this.selectedImage.getAlbum().visitImage(selectedImage);
- this.selectedImage.getAlbum().getShelf().visitImage(selectedImage);
+ selectedImage = model.getImages().get(slideshowIndex);
+ this.selectedImage.getAlbum().visitImage(selectedImage, true);
}
}
\ No newline at end of file
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/TreeManager.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/TreeManager.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/TreeManager.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -13,11 +13,9 @@
import org.richfaces.realworld.domain.User;
@Name("treeManager")
-(a)Scope(ScopeType.CONVERSATION)
+(a)Scope(ScopeType.EVENT)
public class TreeManager implements Serializable{
- @In
- private User user;
@In @Out Model model;
private static final long serialVersionUID = 5656562187249324512L;
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-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/UserManager.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -28,6 +28,7 @@
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Observer;
+import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.Image;
@@ -35,23 +36,21 @@
import org.richfaces.realworld.service.IUserAction;
@Name("userManager")
-(a)Scope(ScopeType.CONVERSATION)
+(a)Scope(ScopeType.EVENT)
@AutoCreate
public class UserManager implements Serializable{
private static final long serialVersionUID = 6027103521084558931L;
- @In private User user;
-
- private Long countImages;
- private Long countAlbums;
+ @In(scope=ScopeType.CONVERSATION) @Out(scope=ScopeType.CONVERSATION) private User user;
+
@In private IUserAction userAction;
- public Long countImages(User u) {
- if(null == countImages ){
- countImages = userAction.countImages(u);
+ public Long countImages() {
+ if(null == user.getCountImages() ){
+ user.setCountImages(userAction.countImages());
}
- return countImages;
+ return user.getCountImages();
}
public Long countSharedImages(User u) {
@@ -59,14 +58,14 @@
}
public Long countSharedAlbums(User u) {
- return userAction.countSharedAlbums(user);
+ return userAction.countSharedAlbums(u);
}
- public Long countAlbums(User u) {
- if(null == countAlbums ){
- countAlbums = userAction.countAlbums(user);
+ public Long countAlbums() {
+ if(null == user.getCountAlbums() ){
+ user.setCountAlbums(userAction.countAlbums());
}
- return countAlbums;
+ return user.getCountAlbums();
}
public List<Album> getSharedAlbums(User user){
@@ -77,34 +76,29 @@
return userAction.getSharedImages(user);
}
- @Observer(value = "imageAdded", create = false)
+ @Observer(value = "imageAdded")
public void onImageAdded() {
- updateStatistics(countAlbums, countImages + 1);
+ user.updateStatistics();
}
- @Observer(value = "imageDeleted", create = false)
+ @Observer(value = "imageDeleted")
public void onImageDeleted(){
- updateStatistics(countAlbums, countImages - 1);
+ user.updateStatistics();
}
- @Observer(value = "albumDeleted", create = false)
+ @Observer(value = "albumDeleted")
public void onAlbumDeleted(){
- updateStatistics(countAlbums-1, countImages);
+ user.updateStatistics();
}
- @Observer(value = "albumAdded", create = false)
+ @Observer(value = "albumAdded")
public void onAlbumAdded(){
- updateStatistics(countAlbums+1, countImages);
+ user.updateStatistics();
}
-
- @Observer(value = "fileAdded", create = false)
- public void onFileAdded(){
- updateStatistics(countAlbums, countImages+1);
- }
- private void updateStatistics(Long i, Long j) {
- countAlbums = i;
- countImages = j;
+ @Observer(value = "shelfDeleted")
+ public void onShelfDeleted(){
+ user.updateStatistics();
}
-}
+}
\ No newline at end of file
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/ISearchOption.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/ISearchOption.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/ISearchOption.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -3,6 +3,7 @@
*/
package org.richfaces.realworld.search;
+import java.util.ArrayList;
import java.util.List;
import org.richfaces.realworld.service.ISearchAction;
@@ -20,11 +21,7 @@
public abstract String getName();
public abstract String getSearchResultName();
-
- public abstract String getTemplate();
- public abstract String getSearchResultTemplate();
-
public abstract void search(ISearchAction action, String searchQuery, boolean
searchInMyAlbums, boolean searchInShared);
public boolean getSelected() {
@@ -40,6 +37,10 @@
return getName();
}
+ public String getSearchResultTemplate() {
+ return "/includes/search/result/albumsResult.xhtml";
+ }
+
public List<?> getSearchResult() {
return searchResult;
}
@@ -48,5 +49,4 @@
this.searchResult = searchResult;
}
-}
-
+}
\ No newline at end of file
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/ImageSearchHelper.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/ImageSearchHelper.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/ImageSearchHelper.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -7,6 +7,7 @@
import java.util.List;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
@@ -18,6 +19,7 @@
@Name("searchImageHelper")
@Scope(ScopeType.CONVERSATION)
+@AutoCreate
public class ImageSearchHelper implements Serializable {
private static final long serialVersionUID = -304368268896942902L;
@@ -58,7 +60,6 @@
if (s.length() >= 2) {
s.delete(s.length() - 2, s.length());
}
- //TODO nick - remove trailing comma
return s.toString();
}
@@ -73,8 +74,6 @@
if (option.getSelected()) {
//TODO nick - use search(keyword)
option.search(searchAction, selectedKeyword , seachInMyAlbums, searchInShared);
- }else {
- option.setSearchResult(null);
}
}
}
@@ -86,8 +85,6 @@
ISearchOption option = it.next();
if (option.getSelected()) {
option.search(searchAction,selectedKeyword , seachInMyAlbums, searchInShared);
- }else {
- option.setSearchResult(null);
}
}
}
@@ -110,11 +107,6 @@
}
}
}
-
- @Out
- public String getTemplate() {
- return (isOptionSelected()) ? selectedOption.getTemplate() :
"/includes/search/searchOptions.xhtml";
- }
public ISearchOption getSelectedOption() {
return selectedOption;
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByAlbum.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByAlbum.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByAlbum.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -1,9 +1,11 @@
package org.richfaces.realworld.search;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.service.ISearchAction;
@@ -12,7 +14,6 @@
Map<String, Object> params = new HashMap<String, Object>();
-
@Override
public String getName() {
return "Albums";
@@ -25,16 +26,15 @@
@Override
public void search(ISearchAction action, String q, boolean searchInMyAlbums, boolean
searchInShared) {
- List<Image> searchByAlbum = action.searchByAlbum(q, searchInMyAlbums,
searchInShared);
- setSearchResult(searchByAlbum);
+ List<Album> searchByAlbum = action.searchByAlbum(q, searchInMyAlbums,
searchInShared);
+ if(searchByAlbum != null){
+ setSearchResult(searchByAlbum);
+ }else{
+ setSearchResult(new ArrayList<Album>());
+ }
}
@Override
- public String getTemplate() {
- return "/includes/search/searchByAlbumTemplate.xhtml";
- }
-
- @Override
public String getSearchResultTemplate() {
return "/includes/search/result/albumsResult.xhtml";
}
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByImage.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByImage.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByImage.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -3,6 +3,7 @@
*/
package org.richfaces.realworld.search;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -33,16 +34,12 @@
@Override
public void search(ISearchAction action, String q, boolean searchInMyAlbums, boolean
searchInShared) {
List<Image> searchByImage = action.searchByImage(q, searchInMyAlbums,
searchInShared);
- setSearchResult(searchByImage);
+ if(searchByImage != null){
+ setSearchResult(searchByImage);
+ }else{
+ setSearchResult(new ArrayList<Image>());
+ }
}
-
-
- /* (non-Javadoc)
- * @see org.richfaces.realworld.search.ISearchOption#getTemplate()
- */
- public String getTemplate() {
- return "/includes/search/searchByImageTemplate.xhtml";
- }
@Override
public String getSearchResultTemplate() {
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByShelf.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByShelf.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByShelf.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -3,8 +3,10 @@
*/
package org.richfaces.realworld.search;
+import java.util.ArrayList;
import java.util.List;
+import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.domain.Shelf;
import org.richfaces.realworld.service.ISearchAction;
@@ -39,22 +41,17 @@
}
/* (non-Javadoc)
- * @see org.richfaces.realworld.search.ISearchOption#getTemplate()
- */
- @Override
- public String getTemplate() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
* @see
org.richfaces.realworld.search.ISearchOption#search(org.richfaces.realworld.service.ISearchAction,
java.lang.String, boolean, boolean)
*/
@Override
public void search(ISearchAction action, String searchQuery,
boolean searchInMyAlbums, boolean searchInShared) {
List<Shelf> list = action.searchByShelfs(searchQuery, searchInMyAlbums,
searchInShared);
- setSearchResult(list);
+ if(list != null){
+ setSearchResult(list);
+ }else{
+ setSearchResult(new ArrayList<Shelf>());
+ }
}
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByTag.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByTag.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByTag.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -3,9 +3,12 @@
*/
package org.richfaces.realworld.search;
+import java.util.ArrayList;
import java.util.List;
+import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.domain.MetaTag;
import org.richfaces.realworld.service.ISearchAction;
/**
@@ -39,22 +42,17 @@
}
/* (non-Javadoc)
- * @see org.richfaces.realworld.search.ISearchOption#getTemplate()
- */
- @Override
- public String getTemplate() {
- // TODO Auto-generated method stub
- return null;
- }
-
- /* (non-Javadoc)
* @see
org.richfaces.realworld.search.ISearchOption#search(org.richfaces.realworld.service.ISearchAction,
java.lang.String, boolean, boolean)
*/
@Override
public void search(ISearchAction action, String searchQuery,
boolean searchInMyAlbums, boolean searchInShared) {
- List<Image> searchByTags = action.searchByTags(searchQuery, searchInMyAlbums,
searchInShared);
- setSearchResult(searchByTags);
+ List<MetaTag> searchByTags = action.searchByTags(searchQuery, searchInMyAlbums,
searchInShared);
+ if(searchByTags != null){
+ setSearchResult(searchByTags);
+ }else{
+ setSearchResult(new ArrayList<MetaTag>());
+ }
}
}
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByUser.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByUser.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/search/SearchOptionByUser.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -3,9 +3,12 @@
*/
package org.richfaces.realworld.search;
+import java.util.ArrayList;
import java.util.List;
import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.domain.MetaTag;
+import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.service.ISearchAction;
/**
@@ -39,20 +42,16 @@
}
/* (non-Javadoc)
- * @see org.richfaces.realworld.search.ISearchOption#getTemplate()
- */
- @Override
- public String getTemplate() {
- return null;
- }
-
- /* (non-Javadoc)
* @see
org.richfaces.realworld.search.ISearchOption#search(org.richfaces.realworld.service.ISearchAction)
*/
@Override
public void search(ISearchAction action, String q, boolean searchInMyAlbums, boolean
searchInShared) {
- List<Image> searchByUsers = action.searchByUsers(q, searchInMyAlbums,
searchInShared);
- setSearchResult(searchByUsers);
+ List<User> searchByUsers = action.searchByUsers(q, searchInMyAlbums,
searchInShared);
+ if(searchByUsers != null){
+ setSearchResult(searchByUsers);
+ }else{
+ setSearchResult(new ArrayList<User>());
+ }
}
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ConfirmationPopupHelper.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ConfirmationPopupHelper.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ConfirmationPopupHelper.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -44,13 +44,13 @@
private String actionName;
- @In(create=true, required=true) @Out(required=false)
+ @In @Out(required=false)
private Image image;
- @In(create=true, required=true) @Out(required=false)
+ @In @Out(required=false)
private Shelf shelf;
- @In(create=true, required=true) @Out(required=false)
+ @In @Out(required=false)
private Album album;
@In AlbumManager albumManager;
Deleted:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileItem.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileItem.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileItem.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -1,83 +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.ui;
-
-import java.io.File;
-
-import org.richfaces.realworld.domain.Image;
-
-//TODO nick - no references - dead class?
-public class FileItem {
-
- private Image image = new Image();
-
- private boolean selected;
-
- private long length;
-
- private byte[] data;
-
- private File file;
-
- private String name;
-
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public byte[] getData() {
- return data;
- }
- public void setData(byte[] data) {
- this.data = data;
- }
-
- public long getLength() {
- return length;
- }
- public void setLength(long length) {
- this.length = length;
- }
-
- public boolean isSelected() {
- return selected;
- }
-
- public void setSelected(boolean selected) {
- this.selected = selected;
- }
-
- public Image getImage() {
- return image;
- }
-
- public void setImage(Image image) {
- this.image = image;
- }
- public File getFile() {
- return file;
- }
- public void setFile(File file) {
- this.file = file;
- }
-}
\ No newline at end of file
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -33,6 +33,7 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.core.Events;
import org.richfaces.event.UploadEvent;
import org.richfaces.model.UploadItem;
@@ -58,7 +59,7 @@
*
*/
@Name("fileUploadBean")
-(a)Scope(ScopeType.CONVERSATION)
+(a)Scope(ScopeType.EVENT)
public class FileUploadBean implements Serializable {
@In("#{messages['file_processing_error']}")
@@ -82,21 +83,22 @@
private static final long serialVersionUID = 4969087557225414955L;
+ @Restrict("#{s:hasRole('admin')}")
public synchronized void listener(UploadEvent event) throws Exception {
UploadItem item = event.getUploadItem();
Image image = constructImage(item);
try {
extractMetadata(item, image);
} catch (JpegProcessingException e1) {
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(FILE_PROCESSING_ERROR));
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, FILE_PROCESSING_ERROR);
return;
} catch (MetadataException me) {
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(FILE_PROCESSING_ERROR));
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, FILE_PROCESSING_ERROR);
return;
}
image.setAlbum(model.getSelectedAlbum());
if(model.getSelectedAlbum() == null){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception("Please
specify album to download"));
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, "Please specify album to
download");
return;
}
String newPath = "/" +model.getSelectedAlbum().getOwner().getLogin() +
"/" + model.getSelectedAlbum().getId() + "/" +item.getFileName();
@@ -104,7 +106,7 @@
//TODO nick - file manager should be protected from another users accessing images of
another people
if(!fileManager.addImage(newPath, item.getFile().getPath())){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(FILE_SAVE_ERROR));
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, FILE_SAVE_ERROR);
item.getFile().delete();
return;
}
@@ -113,8 +115,6 @@
imageAction.addImage(image);
Events.instance().raiseEvent("imageAdded");
item.getFile().delete();
- image.getAlbum().getUnvisitedImages().add(image);
- image.getAlbum().getShelf().getUnvisitedImages().add(image);
}
private Image constructImage(UploadItem item) {
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-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -20,6 +20,7 @@
*/
package org.richfaces.realworld.ui;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -33,8 +34,9 @@
@Name("fileWrapper")
@Scope(ScopeType.SESSION)
@AutoCreate
-public class FileWrapper {
+public class FileWrapper implements Serializable{
+ private static final long serialVersionUID = -1767281809514660171L;
private List<Image> files = new ArrayList<Image>();
public int getSize() {
return getFiles().size();
@@ -48,6 +50,11 @@
this.files = files;
}
+ @Observer("DNDUploadedEvent")
+ public void removeImage(Image image){
+ files.remove(image);
+ }
+
@Observer("clearFileUpload")
public void clear(){
files.clear();
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ImageSizeHelper.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ImageSizeHelper.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ImageSizeHelper.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -12,7 +12,7 @@
*
*/
@Name("imageSizeHelper")
-(a)Scope(ScopeType.CONVERSATION)
+(a)Scope(ScopeType.EVENT)
public class ImageSizeHelper {
static final int DEFAULT_VALUE = 120;
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -4,6 +4,8 @@
package org.richfaces.realworld.ui;
import java.io.File;
+import java.io.Serializable;
+import java.util.List;
import javax.faces.model.SelectItem;
@@ -12,6 +14,7 @@
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.security.Restrict;
import org.jboss.seam.core.Events;
import org.richfaces.event.UploadEvent;
import org.richfaces.model.UploadItem;
@@ -30,8 +33,9 @@
*/
@Name("userPrefsBean")
@Scope(ScopeType.SESSION)
-public class UserPrefsHelper {
-
+public class UserPrefsHelper implements Serializable{
+
+ private static final long serialVersionUID = -1767281809514660171L;
@In IUserAction userAction;
@In FileManager fileManager;
@In @Out Model model;
@@ -41,22 +45,23 @@
File avatarData = null;
- static final SelectItem [] sexs = new SelectItem []
- {
- new SelectItem(Sex.MALE, "Male"),
- new SelectItem(Sex.FEMALE, "Female")
- };
+ static final Sex[] sexs = Sex.values();
+ public static Sex[] getSexs() {
+ return sexs;
+ }
+
public void uploadAvatar(UploadEvent event) {
UploadItem item = event.getUploadItem();
avatarData = item.getFile();
}
+ @Restrict("#{s:hasRole('admin')}")
//TODO nick - are we saving current user?
public void saveUser(){
if (avatarData != null) {
if(!fileManager.saveAvatar(avatarData.getPath(), user)){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new Exception("File IO
Error"));
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, "File IO Error");
return;
}
avatarData.delete();
@@ -70,15 +75,13 @@
public String goToIndex(){
return "index";
}
+
+ @Restrict("#{s:hasRole('admin')}")
public void cancel() {
user = userAction.resetUser();
avatarData = null;
model.resetModel(NavigationEnum.ALL_SHELFS, user, model.getSelectedShelf(),
model.getSelectedAlbum(), model.getSelectedImage());
}
-
- public SelectItem [] getSexs () {
- return sexs;
- }
public Boolean getAvatarModalOpened() {
return avatarModalOpened;
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -1,107 +1,38 @@
package org.richfaces.realworld.util;
-import java.awt.image.BufferedImage;
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.io.OutputStream;
-import javax.faces.context.ExternalContext;
-import javax.faces.context.FacesContext;
-import javax.imageio.ImageIO;
import javax.persistence.EntityManager;
-import javax.servlet.http.HttpServletRequest;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.web.RequestParameter;
-import org.jboss.seam.core.Events;
import org.jboss.seam.security.Identity;
import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.manager.FileManager;
-import org.richfaces.realworld.service.Constants;
@Name("directLink")
@Scope(ScopeType.EVENT)
@AutoCreate
-//TODO nick - session-scoped bean depending on request parameters? i'm in doubts...
public class DirectLinkHelper {
@In(value="entityManager")
protected EntityManager em;
- @In(create = true)
- FileManager fileManager;
+ @In ImageLoader imageLoader;
+
@In Identity identity;
- private static final String IMAGE_DIRECT_LINK =
"/includes/directImage.seam?imageId=";
-
- private static String imageDirectLinkPrefix;
-
public synchronized void paintImage(OutputStream out, Object data)
throws IOException {
Long id=Long.valueOf(data.toString());
Image im = em.find(Image.class, id);
//TODO nick - '&&' so only admins can see their own unshared images?
if(im.getAlbum().getShelf().isShared() || (identity.hasRole("admin")
&& im.getAlbum().getOwner().getLogin().equals(identity.getUsername()))){
- //TODO nick - copy-pasted 99% from ImageLoader
- File imageResource = fileManager.getImage(im.getPath());
- if (imageResource != null) {
- FileInputStream fileInputStream = new FileInputStream(imageResource);
- BufferedInputStream bufferedInputStream = new BufferedInputStream(
- fileInputStream);
- InputStream paintData = bufferedInputStream;
- if (null == paintData) {
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
- new Exception(""));
- 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(""));
- return;
- } finally {
- fileInputStream.close();
- bufferedInputStream.close();
- paintData.close();
- }
- }
+ imageLoader.paintImage(out, im.getPath());
}else{
return;
}
}
-
- public String getDirectImageLink(Image image) {
- if (imageDirectLinkPrefix == null) {
- FacesContext context = FacesContext.getCurrentInstance();
- if (context == null) {
- return null;
- }
- ExternalContext extc = context.getExternalContext();
- if (extc == null) {
- return null;
- }
-
- //TODO nick - see
org.ajax4jsf.renderkit.RendererUtils#encodeResourceURL(TemplateContext, Object)
- Object request = extc.getRequest();
-
- if (request instanceof HttpServletRequest) {
- HttpServletRequest servletRequest = (HttpServletRequest)request;
- String contextPath = servletRequest.getContextPath();
- StringBuffer url = servletRequest.getRequestURL();
- int i = url.indexOf(contextPath);
- if (i > 0) {
- imageDirectLinkPrefix = url.substring(0, i) + contextPath + IMAGE_DIRECT_LINK;
- }
- }
- }
- return imageDirectLinkPrefix + image.getId();
- }
}
\ No newline at end of file
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ErrorHandlerBean.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ErrorHandlerBean.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ErrorHandlerBean.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -37,15 +37,11 @@
@Scope(ScopeType.EVENT)
@AutoCreate
public class ErrorHandlerBean {
- private List<Exception> errors = new ArrayList<Exception>();
+ private List<String> errors = new ArrayList<String>();
- public List<Exception> getErrors() {
+ public List<String> getErrors() {
return errors;
}
-
- public void setErrors(List<Exception> errors) {
- this.errors = errors;
- }
public boolean isErrorExist(){
return errors.size() > 0 ;
@@ -57,7 +53,7 @@
}
@Observer(Constants.ADD_ERROR_EVENT)
- public void addToErrors(Exception e){
+ public void addToErrors(String e){
FacesContext context = FacesContext.getCurrentInstance();
AjaxContext ac = AjaxContext.getCurrentInstance(context);
//TODO nick - should add to AjaxContext#getAjaxAreasToRender()
Deleted:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/FileManagerTest.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/FileManagerTest.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/FileManagerTest.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -1,137 +0,0 @@
-package org.richfaces.realworld.util;
-
-import junit.framework.TestCase;
-
-import org.richfaces.realworld.manager.FileManager;
-
-//TODO nick - test should be moved to src\main\test
-//TODO nick - test doesn't pass
-public class FileManagerTest extends TestCase {
-
- protected void setUp() throws Exception {
- fileManager=new FileManager();
- fileManager.setUploadRoot("C:/Upload/");
- }
-
- protected void tearDown() throws Exception {
- }
-
-private byte[] image = new byte[40];
- private FileManager fileManager;
- public void testIsDirectoryPresent() {
- fileManager.addDirectory("amarkhel");
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
- assertEquals(fileManager.isDirectoryPresent("amarkhel2"), false);
- fileManager.deleteDirectory("amarkhel");
- }
-
- public void testDeleteDirectory() {
- fileManager.addDirectory("amarkhel");
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
- fileManager.deleteDirectory("amarkhel");
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), false);
- }
-
- public void testRenameDirectory() throws Exception {
- fileManager.addDirectory("amarkhel");
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
- fileManager.renameDirectory("amarkhel", "amarkhel2");
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), false);
- assertEquals(fileManager.isDirectoryPresent("amarkhel2"), true);
- fileManager.deleteDirectory("amarkhel2");
- }
-
- public void testRenameDirectory2(){
- fileManager.addDirectory("amarkhel");
- fileManager.addDirectory("amarkhel2");
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
- try {
- fileManager.renameDirectory("amarkhel", "amarkhel2");
- } catch (Exception e) {
- assertTrue(true);
- }
-
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
- assertEquals(fileManager.isDirectoryPresent("amarkhel2"), true);
- fileManager.deleteDirectory("amarkhel");
- fileManager.deleteDirectory("amarkhel2");
- }
-
- public void testRenameDirectory3() throws Exception {
- fileManager.addDirectory("a"+System.getProperty("file.separator")+"amarkhel");
- assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"amarkhel"),
true);
- fileManager.renameDirectory("a"+System.getProperty("file.separator")+"amarkhel",
"b"+System.getProperty("file.separator")+"amarkhel");
- assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"amarkhel"),
false);
- assertEquals(fileManager.isDirectoryPresent("b"+System.getProperty("file.separator")+"amarkhel"),
true);
- fileManager.deleteDirectory("b"+System.getProperty("file.separator")+"amarkhel");
- }
-
- public void testRenameDirectory4() throws Exception {
- fileManager.addDirectory("a"+System.getProperty("file.separator")+"a"+System.getProperty("file.separator")+"amarkhel");
- assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"a"+System.getProperty("file.separator")+"amarkhel"),
true);
- fileManager.renameDirectory("a"+System.getProperty("file.separator")+"a"+System.getProperty("file.separator")+"amarkhel",
"b"+System.getProperty("file.separator")+"b"+System.getProperty("file.separator")+"amarkhel");
- assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"a"+System.getProperty("file.separator")+"amarkhel"),
false);
- assertEquals(fileManager.isDirectoryPresent("b"+System.getProperty("file.separator")+"b"+System.getProperty("file.separator")+"amarkhel"),
true);
- fileManager.deleteDirectory("b"+System.getProperty("file.separator")+"b"+System.getProperty("file.separator")+"amarkhel");
- }
-
- public void testAddDirectory() {
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), false);
- fileManager.addDirectory("amarkhel");
- assertEquals(fileManager.isDirectoryPresent("amarkhel"), true);
- fileManager.deleteDirectory("amarkhel");
- }
-
- public void testAddDirectory2() {
- assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"amarkhel"),
false);
- fileManager.addDirectory("a"+System.getProperty("file.separator")+"amarkhel");
- assertEquals(fileManager.isDirectoryPresent("a"+System.getProperty("file.separator")+"amarkhel"),
true);
- fileManager.deleteDirectory("a"+System.getProperty("file.separator")+"amarkhel");
- }
-
- /*public void testAddImage() throws IOException {
- assertEquals(fileManager.isImagePresent("amarkhel.gif"), false);
- fileManager.addImage("amarkhel.gif", image);
- assertEquals(fileManager.isImagePresent("amarkhel.gif"), true);
- fileManager.deleteImage("amarkhel.gif");
- }
-
- public void testDeleteImage() throws IOException {
- fileManager.addImage("amarkhel.gif", image);
- assertEquals(fileManager.isImagePresent("amarkhel.gif"), true);
- fileManager.deleteImage("amarkhel.gif");
- assertEquals(fileManager.isImagePresent("amarkhel.gif"), false);
- }
-
- public void testRenameImage() throws IOException {
- fileManager.addImage("amarkhel.gif", image);
- assertEquals(fileManager.isImagePresent("amarkhel.gif"), true);
- fileManager.renameImage("amarkhel.gif", "amarkhel2.gif");
- assertEquals(fileManager.isImagePresent("amarkhel.gif"), false);
- assertEquals(fileManager.isImagePresent("amarkhel2.gif"), true);
- fileManager.deleteImage("amarkhel2.gif");
- }
-
- public void testRenameImage2() throws IOException {
- fileManager.addImage("a"+System.getProperty("file.separator")+"amarkhel.gif",
image);
- assertEquals(fileManager.isImagePresent("a"+System.getProperty("file.separator")+"amarkhel.gif"),
true);
- fileManager.renameImage("a"+System.getProperty("file.separator")+"amarkhel.gif",
"b"+System.getProperty("file.separator")+"amarkhel2.gif");
- assertEquals(fileManager.isImagePresent("a"+System.getProperty("file.separator")+"amarkhel.gif"),
false);
- assertEquals(fileManager.isImagePresent("b"+System.getProperty("file.separator")+"amarkhel2.gif"),
true);
- fileManager.deleteImage("b"+System.getProperty("file.separator")+"amarkhel2.gif");
- fileManager.deleteDirectory("b");
- fileManager.deleteDirectory("a");
- }
-
- public void testIsImagePresent() throws IOException {
- fileManager.addImage("amarkhel.gif", image);
- assertEquals(fileManager.isImagePresent("amarkhel.gif"), true);
- assertEquals(fileManager.isImagePresent("amarkhel3.gif"), false);
- fileManager.deleteImage("amarkhel.gif");
- fileManager.addImage("am"+System.getProperty("file.separator")+"amarkhel.gif",
image);
- assertEquals(fileManager.isImagePresent("am"+System.getProperty("file.separator")+"amarkhel.gif"),
true);
- fileManager.deleteImage("am"+System.getProperty("file.separator")+"amarkhel.gif");
- fileManager.deleteDirectory("am");
- }*/
-
-}
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/Help.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/Help.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/Help.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -6,11 +6,11 @@
import org.jboss.seam.annotations.Scope;
@Name("help")
-(a)Scope(ScopeType.CONVERSATION)
+(a)Scope(ScopeType.EVENT)
@AutoCreate
public class Help {
- private String page;
+ private String page = "/includes/help/tree_click_descr.xhtml";
public String getPage() {
return page;
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -32,6 +32,7 @@
import javax.imageio.ImageIO;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
@@ -40,8 +41,8 @@
import org.richfaces.realworld.service.Constants;
@Name("imageLoader")
-(a)Scope(ScopeType.CONVERSATION)
-//TODO nick - why is this conversation-scoped?
+(a)Scope(ScopeType.EVENT)
+@AutoCreate
public class ImageLoader implements Serializable {
private static final long serialVersionUID = -1572789608594870285L;
@@ -53,64 +54,25 @@
//TODO nick - synchronized would make this a bottleneck, especially considering that
this method
// consumes plenty of CPU time
- public synchronized void paintImage(OutputStream out, Object data) throws IOException
{
+ public void paintImage(OutputStream out, Object data) throws IOException {
if (null == data) {
return;
}
- File imageResource = fileManager.getImage(data.toString());
+ File imageResource = fileManager.getFileByPath(data.toString());
if (imageResource != null) {
FileInputStream fileInputStream = new FileInputStream(imageResource);
BufferedInputStream bufferedInputStream = new
BufferedInputStream(fileInputStream);
InputStream paintData = bufferedInputStream;
- //TODO nick - paintData is never null
- if (null == paintData) {
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(FILE_PROCESSING_ERROR));
- return;
- }
try {
//TODO nick - pass-through writing will save us large amount of CPU time
and images quality
BufferedImage images = ImageIO.read(paintData);
ImageIO.write(images, Constants.JPEG, out);
} catch (Exception e) {
//TODO nick - any particular reason to catch not to take the whole method
body into try/catch?
- //TODO nick - how useful is new Exception(...)? why not use just String?
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(FILE_PROCESSING_ERROR));
- //TODO nick - that's not necessary at all
- return;
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
FILE_PROCESSING_ERROR);
} finally {
- //TODO nick - calling bufferedInputStream.close() is enough
- fileInputStream.close();
bufferedInputStream.close();
- paintData.close();
}
}
}
-
- //TODO nick - this is copy-pasted 99% from paintImage()
- public synchronized void paintImageFromFile(OutputStream out, Object data) throws
IOException {
- if (null == data) {
- return;
- }
- File imageResource = fileManager.getImageFile(data.toString());
- if (imageResource != null) {
- FileInputStream fileInputStream = new FileInputStream(imageResource);
- BufferedInputStream bufferedInputStream = new
BufferedInputStream(fileInputStream);
- InputStream paintData = bufferedInputStream;
- if (null == paintData) {
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, new
Exception(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(FILE_PROCESSING_ERROR));
- return;
- } finally {
- fileInputStream.close();
- bufferedInputStream.close();
- paintData.close();
- }
- }
- }
}
Deleted:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test.java 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/test.java 2009-04-03
13:32:44 UTC (rev 13375)
@@ -1,195 +0,0 @@
-package org.richfaces.realworld.util;
-
-import java.awt.Graphics2D;
-import java.awt.RenderingHints;
-import java.awt.Transparency;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import javax.imageio.ImageIO;
-import javax.imageio.ImageReader;
-import javax.imageio.ImageWriter;
-import javax.imageio.stream.ImageInputStream;
-
-//TODO nick - delete this class
-public class test {
-// private static String directory =
"E:\\realworldnew\\web\\src\\main\\webapp\\WEB-INF\\Upload\\Viking\\15";
- private static String directory = "E:\\temp\\out_images\\";
-
- public static void main(String[] args) throws IOException {
- if (args.length > 0 && args[0] != null) {
- directory = args[0];
- }
-
- File file = new File(directory);
- writeFiles(file, "_small80", 80);
- writeFiles(file, "_small120", 120);
- writeFiles(file, "_small160", 160);
- writeFiles(file, "_small200", 200);
- writeFiles(file, "_mini", 150);
- writeFiles(file, "_medium", 600);
- }
-
- private static void writeFiles(File file, String pattern, int size) {
- if (file.isDirectory()) {
- for (File subFile : file.listFiles()){
- writeFiles(subFile, pattern, size);
- }
- } else if (file.isFile()) {
- final String s = file.getName().toLowerCase();
- if (s.endsWith(".jpg") &&
!s.endsWith("_mini.jpg") && !s.endsWith("_medium.jpg")
- && !s.endsWith("_small80.jpg") &&
!s.endsWith("_small120.jpg")
- && !s.endsWith("_small160.jpg") &&
!s.endsWith("_small200.jpg")) {
- System.out.println("processing file >> " +
file.getPath());
- writeOneImage(file.getParent(), pattern, size, s);
- }
- } else {
- throw new IllegalArgumentException("Unknow file type");
- }
- }
-
- private static void writeOneImage(String directory, String pattern, int size, String
s) {
- BufferedImage bsrc;
- try {
- bsrc = bitmapToImage(directory + "\\" + s, "JPG");
- } catch (IOException e1) {
- e1.printStackTrace();
- return;
- }
-
- int i = bsrc.getWidth() > bsrc.getHeight() ? bsrc.getWidth() :
bsrc.getHeight();
- double d = ((double) size) / i;
- Double yy = d * bsrc.getWidth();
- int width = yy.intValue();
- yy = d * bsrc.getHeight();
- int height = yy.intValue();
- BufferedImage bdest = getScaledInstance(bsrc, width, height,
RenderingHints.VALUE_INTERPOLATION_BICUBIC, true);
- String dest = transformPath(directory + "\\" + s, pattern);
-
- try {
- imageToBitmap(bdest, dest, "JPG");
- } catch (IOException ex) {
- ex.printStackTrace();
- }
- }
-
- private static String transformPath(String target, String substitute) {
- String begin = target.substring(0, target.lastIndexOf("."));
- String end = target.substring(target.lastIndexOf("."));
- return begin + substitute + end;
- }
-
-/* private static void generateTags() {
- try {
- BufferedWriter out = new BufferedWriter(new
FileWriter("C:\\1114.txt"));
- //String a ="INSERT INTO comments(comment_id, date, message,
image_comment_id, from_user_id) VALUES ("+commentId+", '1985-01-08',
'Hello I am user',"+ imageId+", 2);\n"+ "INSERT INTO
comments(comment_id, date, message, image_comment_id, from_user_id) VALUES
("+commentId2+", '1985-01-08', 'Hello I am user2',"+
imageId+", 3);\n";
-
- //out.write("INSERT INTO IMAGES_METATAGS(CI_IMAGE_ID, CI_METATAG_ID)
VALUES("+"1"+"," +"1"+ ");\n");
- for (int i = 2; i < 84; i++) {
- String imageId = (new Integer(i)).toString();
- String commentId = (new Integer(i * 2 - 1)).toString();
- String commentId2 = (new Integer(i * 2)).toString();
- out.append("INSERT INTO comments(comment_id, date, message,
image_comment_id, from_user_id) VALUES (" + commentId + ", '1985-01-08',
'Hello I am user'," + imageId + ", 2);\n" + "INSERT INTO
comments(comment_id, date, message, image_comment_id, from_user_id) VALUES (" +
commentId2 + ", '1985-01-08', 'Hello I am user2'," + imageId +
", 3);\n");
- }
- out.close();
- } catch (IOException e) {
- // Do nothing.
- }
-
- }*/
-
- public static BufferedImage bitmapToImage(String data, String format) throws
IOException {
- InputStream inb = new FileInputStream(data);
- ImageReader rdr = ImageIO.getImageReadersByFormatName(format).next();
- ImageInputStream imageInput = ImageIO.createImageInputStream(inb);
- rdr.setInput(imageInput);
- BufferedImage image = rdr.read(0);
- inb.close();
- return image;
- }
-
- public static void imageToBitmap(BufferedImage image, String data, String format)
throws IOException {
- OutputStream inb = new FileOutputStream(data);
- ImageWriter wrt = ImageIO.getImageWritersByFormatName(format).next();
- ImageInputStream imageInput = ImageIO.createImageOutputStream(inb);
- wrt.setOutput(imageInput);
- wrt.write(image);
- inb.close();
- }
-
- /**
- * Convenience method that returns a scaled instance of the
- * provided {@code BufferedImage}.
- *
- * @param img the original image to be scaled
- * @param targetWidth the desired width of the scaled instance,
- * in pixels
- * @param targetHeight the desired height of the scaled instance,
- * in pixels
- * @param hint one of the rendering hints that corresponds to
- * {@code RenderingHints.KEY_INTERPOLATION} (e.g.
- * {@code RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR},
- * {@code RenderingHints.VALUE_INTERPOLATION_BILINEAR},
- * {@code RenderingHints.VALUE_INTERPOLATION_BICUBIC})
- * @param higherQuality if true, this method will use a multi-step
- * scaling technique that provides higher quality than the
usual
- * one-step technique (only useful in downscaling cases, where
- * {@code targetWidth} or {@code targetHeight} is
- * smaller than the original dimensions, and generally only
when
- * the {@code BILINEAR} hint is specified)
- * @return a scaled version of the original {@code BufferedImage}
- */
- public static BufferedImage getScaledInstance(BufferedImage img,
- int targetWidth,
- int targetHeight,
- Object hint,
- boolean higherQuality) {
- int type = (img.getTransparency() == Transparency.OPAQUE) ?
- BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB;
- BufferedImage ret = img;
- int w, h;
- if (higherQuality) {
- // Use multi-step technique: start with original size, then
- // scale down in multiple passes with drawImage()
- // until the target size is reached
- w = img.getWidth();
- h = img.getHeight();
- } else {
- // Use one-step technique: scale directly from original
- // size to target size with a single drawImage() call
- w = targetWidth;
- h = targetHeight;
- }
-
- do {
- if (higherQuality && w > targetWidth) {
- w /= 2;
- if (w < targetWidth) {
- w = targetWidth;
- }
- }
-
- if (higherQuality && h > targetHeight) {
- h /= 2;
- if (h < targetHeight) {
- h = targetHeight;
- }
- }
-
- BufferedImage tmp = new BufferedImage(w, h, type);
- Graphics2D g2 = tmp.createGraphics();
- g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint);
- g2.drawImage(ret, 0, 0, w, h, null);
- g2.dispose();
-
- ret = tmp;
- } while (w != targetWidth || h != targetHeight);
-
- return ret;
- }
-}
Modified: trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/pages.xml
===================================================================
--- trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/pages.xml 2009-04-03
13:17:38 UTC (rev 13374)
+++ trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/pages.xml 2009-04-03
13:32:44 UTC (rev 13375)
@@ -9,7 +9,7 @@
<redirect view-id="/register.xhtml"/>
</rule>
<rule if-outcome="main">
- <redirect view-id="/main.xhtml"/>
+ <redirect view-id="/index.xhtml"/>
</rule>
<rule if-outcome="index">
<redirect view-id="/index.html"/>
@@ -19,7 +19,7 @@
<page view-id="/index.xhtml">
<begin-conversation if="#{!identity.isLoggedIn()}"/>
- <action if="#{authenticator.startConversation!=null}"
execute="#{authenticator.startConversation}"/>
+ <action if="#{authenticator.startConversation!=null}"
execute="#{authenticator.startConversation()}"/>
<action if="#{!identity.isLoggedIn()}"
execute="#{authenticator.start}"/>
<navigation from-action="#{authenticator.logout}">
<rule if-outcome="logout">
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/tags/realWorld-taglib.xml
===================================================================
---
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/tags/realWorld-taglib.xml 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/tags/realWorld-taglib.xml 2009-04-03
13:32:44 UTC (rev 13375)
@@ -5,22 +5,6 @@
<facelet-taglib>
<
namespace>http://richfaces.org/richx</namespace>
<tag>
- <tag-name>album</tag-name>
- <source>templates/album.xhtml</source>
- </tag>
- <tag>
- <tag-name>shelf</tag-name>
- <source>templates/shelf.xhtml</source>
- </tag>
- <tag>
- <tag-name>help</tag-name>
- <source>templates/help.xhtml</source>
- </tag>
- <tag>
- <tag-name>confirm</tag-name>
- <source>templates/confirmation.xhtml</source>
- </tag>
- <tag>
<tag-name>commandButton</tag-name>
<component>
<component-type>org.ajax4jsf.CommandButton</component-type>
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/album/albumsList.xhtml
===================================================================
(Binary files differ)
Added:
trunk/test-applications/realworld2/web/src/main/webapp/includes/album/createAlbum.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/realworld2/web/src/main/webapp/includes/album/createAlbum.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/directImage.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/fileUpload/uploadResult.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/imageAdditionalInfo.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/imageEditInfo.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/image/imageInfo.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/image.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/imageEdit.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/index/menu.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/index/tree.xhtml
===================================================================
(Binary files differ)
Added:
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/confirmation.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/confirmation.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/errorPanel.xhtml
===================================================================
(Binary files differ)
Added: trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/help.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/help.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/inputNumberSlider.xhtml
===================================================================
---
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/inputNumberSlider.xhtml 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/inputNumberSlider.xhtml 2009-04-03
13:32:44 UTC (rev 13375)
@@ -14,7 +14,7 @@
showBoundaryValues="true"
showInput="false"
step="40">
- <a4j:support event="onchange"
reRender="#{reRenderArea}"></a4j:support>
+ <a4j:support event="onchange"
reRender="userAlbumImages"/>
</rich:inputNumberSlider>
</div>
</ui:composition>
\ No newline at end of file
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/modalPanels.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/imageResult.xhtml
===================================================================
---
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/imageResult.xhtml 2009-04-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/imageResult.xhtml 2009-04-03
13:32:44 UTC (rev 13375)
@@ -5,12 +5,13 @@
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<a4j:outputPanel rendered="#{result.size() > 0}"
id="imagesList">
-
+ <rich:datascroller for="imageList"
reRender="userAlbumImages"></rich:datascroller>
<ui:include src="/includes/misc/inputNumberSlider.xhtml">
<ui:param name="reRenderArea" value="imagesList" />
</ui:include>
<br/><br/>
- <a4j:repeat value="#{result}" var="image">
+ <h:panelGroup id="userAlbumImages">
+ <a4j:repeat id="imageList" value="#{result}"
var="image" rows="20">
<h:panelGroup layout="block"
styleClass="#{imageSizeHelper.currentDimension.cssClass}">
<h:graphicImage styleClass="pr_photo_bg"
value="#{imageSizeHelper.currentDimension.imageBg}" />
<h:panelGrid cellpadding="0">
@@ -39,6 +40,7 @@
</h:panelGroup>
</h:panelGroup>
</a4j:repeat>
+ </h:panelGroup>
</a4j:outputPanel>
<h:outputText rendered="#{result.size() == 0}" value="No results
found" />
</ui:composition>
\ No newline at end of file
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-03
13:17:38 UTC (rev 13374)
+++
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/result/userResult.xhtml 2009-04-03
13:32:44 UTC (rev 13375)
@@ -4,31 +4,31 @@
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
- <a4j:repeat rendered="#{result.size() > 0}" id="userList"
value="#{result}" var="user">
+ <a4j:repeat rendered="#{result.size() > 0}" id="userList"
value="#{result}" var="searchedUser">
<h:panelGroup layout="block"
styleClass="preview_box_photo_120">
<h:graphicImage styleClass="pr_photo_bg"
value="/img/shell/frame_photo_200.png" style="border:none"/>
<h:panelGrid cellpadding="0">
<h:panelGroup>
- <a4j:commandLink reRender="mainArea"
actionListener="#{controller.showUser(user)}">
- <a4j:mediaOutput rendered="#{user.hasAvatar}" element="img"
createContent="#{imageLoader.paintImage}"
+ <a4j:commandLink reRender="mainArea"
actionListener="#{controller.showUser(searchedUser)}">
+ <a4j:mediaOutput rendered="#{searchedUser.hasAvatar}"
element="img" createContent="#{imageLoader.paintImage}"
styleClass="avatar"
- value="/#{user.login}/avatar.jpg" />
- <h:graphicImage rendered="#{!user.hasAvatar and user.sex.key =='1'
}" value="/img/shell/avatar_default.png" width="80"
height="80" alt="" style="border:none"/>
- <h:graphicImage rendered="#{!user.hasAvatar and user.sex.key =='0'
}" value="/img/shell/avatar_w_default.png" width="80"
height="80" alt="" style="border:none"/>
+ value="/#{searchedUser.login}/avatar.jpg" />
+ <h:graphicImage rendered="#{!searchedUser.hasAvatar and
searchedUser.sex.key =='1' }" value="/img/shell/avatar_default.png"
width="80" height="80" alt=""
style="border:none"/>
+ <h:graphicImage rendered="#{!searchedUser.hasAvatar and
searchedUser.sex.key =='0' }"
value="/img/shell/avatar_w_default.png" width="80"
height="80" alt="" style="border:none"/>
</a4j:commandLink>
<br/>
</h:panelGroup>
</h:panelGrid>
<h:panelGroup layout="block" styleClass="photo_name">
- <strong>#{user.firstName} #{user.secondName}</strong>
+ <strong>#{searchedUser.firstName} #{searchedUser.secondName}</strong>
</h:panelGroup>
<h:panelGroup layout="block" styleClass="photo_data">
- <h:outputText value="#{user.birthDate}" >
+ <h:outputText value="#{searchedUser.birthDate}" >
<f:convertDateTime />
</h:outputText>
</h:panelGroup>
<h:panelGroup layout="block" styleClass="photo_data">
- <a4j:commandLink reRender="tree, mainArea"
actionListener="#{controller.showSharedAlbums(user)}" ><h:outputText
value="#{userManager.countSharedAlbums(user)} albums
"/></a4j:commandLink> | <a4j:commandLink reRender="mainArea"
actionListener="#{controller.showSharedImages(user)}"><h:outputText
value="#{userManager.countSharedImages(user)}
photos"/></a4j:commandLink>
+ <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>
</h:panelGroup>
</h:panelGroup>
</a4j:repeat>
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/search/searchWidget.xhtml
===================================================================
(Binary files differ)
Added:
trunk/test-applications/realworld2/web/src/main/webapp/includes/shelf/createShelf.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/realworld2/web/src/main/webapp/includes/shelf/createShelf.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/tag.xhtml
===================================================================
(Binary files differ)
Added:
trunk/test-applications/realworld2/web/src/main/webapp/includes/userPrefs/avatar.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/realworld2/web/src/main/webapp/includes/userPrefs/avatar.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/userPrefs/userPrefs.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/userPrefs/userPrefsEdit.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/layout/template.xhtml
===================================================================
(Binary files differ)
Deleted: trunk/test-applications/realworld2/web/src/main/webapp/main.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/scripts/realworld.js
===================================================================
--- trunk/test-applications/realworld2/web/src/main/webapp/scripts/realworld.js 2009-04-03
13:17:38 UTC (rev 13374)
+++ trunk/test-applications/realworld2/web/src/main/webapp/scripts/realworld.js 2009-04-03
13:32:44 UTC (rev 13375)
@@ -1,40 +1,3 @@
-function selectAllFiles(f) {
- for (var i = 0; i < filesCount; i++) {
- var b = $('mainform:files:'+i+':file_selected');
- if (b) {
- b.checked = f;
- }
-
- }
-}
-
-function onselectFileClick(el) {
- if (!el.checked) {
- $('select_all').checked = false;
- }else {
- var b = true;
- for (var i = 0; i < filesCount; i++) {
- var d = $('mainform:files:'+i+':file_selected');
- if (!d.checked) {
- b = false;
- break;
- }
- }
- if (b) {
- $('select_all').checked = true;
- }
-
- }
-}
-
-function SearchPanelShowHide(e, elt) {
- if (Element.visible(elt)) {
- hideSearch();
- }else {
- showSearch();
- }
-}
-
function selectPopularTag(tag, target) {
if(target){
var value = target.value;