Author: amarkhel
Date: 2009-04-08 05:55:14 -0400 (Wed, 08 Apr 2009)
New Revision: 13423
Added:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileUploadManager.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/DirectLinkHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ErrorHandlerBean.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/Help.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ImageLoader.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/CopyImageStuff.java
Removed:
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/startup/
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tags/RealworldImageScrollerRenderer.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/PasswordHolder.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/tags/templates/
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/ui/ConfirmationPopupHelper.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/EditorBean.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/components.xml
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/faces-config.xml
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/tags/realWorld-taglib.xml
trunk/test-applications/realworld2/web/src/main/webapp/includes/fileUpload/fileUploader.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/fileUpload/uploadResult.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/index/header.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/includes/index/login.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/register.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/scripts/realworld.js
Log:
Refactoring
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-08
09:53:10 UTC (rev 13422)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Authenticator.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -21,11 +21,15 @@
package org.richfaces.realworld.manager;
import java.io.Serializable;
+import java.security.MessageDigest;
+import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.security.auth.login.LoginException;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.End;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
@@ -37,11 +41,11 @@
import org.jboss.seam.log.Log;
import org.jboss.seam.security.Credentials;
import org.jboss.seam.security.Identity;
+import org.jboss.seam.util.Hex;
import org.jboss.seam.web.Session;
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.service.Constants;
import org.richfaces.realworld.service.IUserAction;
-import org.richfaces.realworld.ui.PasswordHolder;
@Name("authenticator")
@Scope(ScopeType.CONVERSATION)
@@ -55,8 +59,10 @@
@RequestParameter protected Long startConversation;
private static final long serialVersionUID = -4585673256547342140L;
+
+ @In("#{messages['user.exist']}") private String
USER_WITH_THIS_LOGIN_ALREADY_EXIST;
- @In PasswordHolder passwordHolder;
+ @In("#{messages['user.confirm.error']}") private String
CONFIRM_PASSWORD_NOT_EQUALS_PASSWORD;
@Logger Log log;
@@ -78,6 +84,28 @@
private boolean loginFailed = false;
+ private String digestAlgorithm;
+
+ private String charset;
+
+ public void setDigestAlgorithm(String algorithm) {
+ this.digestAlgorithm = algorithm;
+ }
+
+ public void setCharset(String charset) {
+ this.charset = charset;
+ }
+
+ public String hash(String plainTextPassword) {
+ try {
+ MessageDigest digest = MessageDigest.getInstance(digestAlgorithm);
+ digest.update(plainTextPassword.getBytes(charset));
+ byte[] rawHash = digest.digest();
+ return new String(Hex.encodeHex(rawHash));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
public String login(){
if(identity.hasRole("admin")){
return null;
@@ -101,6 +129,51 @@
return "main";
}
+ @End
+ public String register(User user){
+ if(checkPassword(user) || checkUserExist(user)){
+ return "";
+ }
+ user.setPasswordHash(hash(user.getPassword()));
+ userAction.register(user);
+ return "index";
+ }
+
+ public String goToIndex(){
+ return "index";
+ }
+
+ public String goToRegister(){
+ identity.logout();
+ identity.unAuthenticate();
+ credentials.clear();
+ credentials.invalidate();
+ return "register";
+ }
+
+ private boolean checkUserExist(User user) {
+ if(userAction.isUserExist(user.getLogin())){
+ addFacesMessage(Constants.REGISTER_LOGIN_NAME_ID,
USER_WITH_THIS_LOGIN_ALREADY_EXIST);
+ return true;
+ }
+ return false;
+ }
+
+ private void addFacesMessage(String componentId, String message ) {
+ UIComponent root = FacesContext.getCurrentInstance().getViewRoot();
+ UIComponent component = root.findComponent(componentId);
+ FacesContext.getCurrentInstance().addMessage(component.getClientId(FacesContext.getCurrentInstance()),
new FacesMessage(
+ FacesMessage.SEVERITY_ERROR, message , message));
+ }
+
+ private boolean checkPassword(User user) {
+ if(!user.getPassword().equals(user.getConfirmPassword())){
+ addFacesMessage(Constants.REGISTER_CONFIRM_PASSWORD_ID,
CONFIRM_PASSWORD_NOT_EQUALS_PASSWORD);
+ return true;
+ }
+ return false;
+ }
+
public boolean authenticate()
{
if (wantLoginAnonymous()) {
@@ -110,7 +183,7 @@
}
try {
//TODO nick - move password holder into userAction
- user = userAction.login(credentials.getUsername(),
passwordHolder.hash(credentials.getPassword()));
+ user = userAction.login(credentials.getUsername(), hash(credentials.getPassword()));
if (user != null) {
identity.addRole(Constants.ADMIN_ROLE);
model.resetModel(NavigationEnum.ALL_SHELFS, user, null, null, null, null);
Added:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileUploadManager.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileUploadManager.java
(rev 0)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileUploadManager.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -0,0 +1,163 @@
+/**
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.realworld.manager;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.Date;
+
+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.annotations.security.Restrict;
+import org.jboss.seam.core.Events;
+import org.richfaces.event.UploadEvent;
+import org.richfaces.model.UploadItem;
+import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.service.Constants;
+import org.richfaces.realworld.service.IImageAction;
+import org.richfaces.realworld.ui.FileWrapper;
+
+import com.drew.imaging.jpeg.JpegMetadataReader;
+import com.drew.metadata.Directory;
+import com.drew.metadata.Metadata;
+import com.drew.metadata.MetadataException;
+import com.drew.metadata.exif.ExifDirectory;
+import com.drew.metadata.jpeg.JpegDirectory;
+
+/**
+ * @author $Autor$
+ *
+ */
+@Name("fileUploadManager")
+(a)Scope(ScopeType.EVENT)
+public class FileUploadManager implements Serializable {
+
+ @In("#{messages['file_processing_error']}")
+ private String FILE_PROCESSING_ERROR;
+
+ @In("#{messages['file_saving_error']}")
+ private String FILE_SAVE_ERROR;
+
+ @In IImageAction imageAction;
+ @In(required = true, scope=ScopeType.CONVERSATION) @Out(scope=ScopeType.CONVERSATION)
+ FileWrapper fileWrapper;
+
+ @In Model model;
+ @In private FileManager fileManager;
+
+ private static final long serialVersionUID = 4969087557225414955L;
+
+ @Restrict("#{s:hasRole('admin')}")
+ public void listener(UploadEvent event) throws Exception {
+ UploadItem item = event.getUploadItem();
+ Image image = constructImage(item);
+ try {
+ extractMetadata(item, image);
+ } catch (Exception e1) {
+ 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, "Please specify album to
download");
+ return;
+ }
+ String newPath = Constants.SLASH + model.getSelectedAlbum().getOwner().getLogin() +
Constants.SLASH + model.getSelectedAlbum().getId() + Constants.SLASH +item.getFileName();
+ image.setPath(newPath);
+ if(!fileManager.addImage(newPath, item.getFile().getPath())){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, FILE_SAVE_ERROR);
+ item.getFile().delete();
+ return;
+ }
+ fileWrapper.getFiles().add(image);
+ imageAction.addImage(image);
+ Events.instance().raiseEvent("imageAdded");
+ item.getFile().delete();
+ }
+
+ private Image constructImage(UploadItem item) {
+ Image image = new Image();
+ image.setUploaded(new Date());
+ image.setDescription(item.getFileName());
+ image.setName(item.getFileName());
+ image.setSize(item.getFileSize());
+ image.setAllowComments(true);
+ return image;
+ }
+
+ private void extractMetadata(UploadItem item, Image image)
+ throws RuntimeException, IOException {
+ InputStream in =null;
+ try{
+ in = new FileInputStream(item.getFile());
+ Metadata metadata = JpegMetadataReader.readMetadata(in);
+ Directory exifDirectory = metadata.getDirectory(ExifDirectory.class);
+ Directory jpgDirectory = metadata.getDirectory(JpegDirectory.class);
+ setupCameraModel(image, exifDirectory);
+ setupDimensions(image, exifDirectory, jpgDirectory);
+ setupCreatedDate(image, exifDirectory);
+ }catch(Exception e){
+ throw new RuntimeException();
+ }finally{
+ in.close();
+ }
+ }
+
+ private void setupCreatedDate(Image image, Directory exifDirectory)
+ throws MetadataException {
+ if (exifDirectory.containsTag(ExifDirectory.TAG_DATETIME_ORIGINAL)) {
+ Date time = exifDirectory.getDate(ExifDirectory.TAG_DATETIME_ORIGINAL);
+ image.setCreated(time);
+ }
+ }
+
+ private void setupDimensions(Image image, Directory exifDirectory,
+ Directory jpgDirectory) throws MetadataException {
+ if (exifDirectory.containsTag(ExifDirectory.TAG_EXIF_IMAGE_WIDTH) &&
exifDirectory.containsTag(ExifDirectory.TAG_EXIF_IMAGE_HEIGHT)) {
+ int width = exifDirectory.getInt(ExifDirectory.TAG_EXIF_IMAGE_WIDTH);
+ image.setWidth(width);
+ int height = exifDirectory.getInt(ExifDirectory.TAG_EXIF_IMAGE_HEIGHT);
+ image.setHeight(height);
+ } else {
+ if (jpgDirectory.containsTag(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT)) {
+ int width = jpgDirectory.getInt(JpegDirectory.TAG_JPEG_IMAGE_WIDTH);
+ image.setWidth(width);
+ int height = jpgDirectory.getInt(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT);
+ image.setHeight(height);
+ }
+ }
+ }
+
+ private void setupCameraModel(Image image, Directory exifDirectory) {
+ if (exifDirectory.containsTag(ExifDirectory.TAG_MODEL)) {
+ String cameraModel = exifDirectory.getString(ExifDirectory.TAG_MODEL);
+ image.setCameraModel(cameraModel);
+ }else{
+ image.setCameraModel("");
+ }
+ }
+}
\ No newline at end of file
Property changes on:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileUploadManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Deleted:
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-08
09:53:10 UTC (rev 13422)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/RegistrationManager.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -1,88 +0,0 @@
-package org.richfaces.realworld.manager;
-
-import java.io.Serializable;
-
-import javax.faces.application.FacesMessage;
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.End;
-import org.jboss.seam.annotations.In;
-import org.jboss.seam.annotations.Logger;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.faces.FacesMessages;
-import org.jboss.seam.log.Log;
-import org.jboss.seam.security.Credentials;
-import org.jboss.seam.security.Identity;
-import org.richfaces.realworld.domain.User;
-import org.richfaces.realworld.service.Constants;
-import org.richfaces.realworld.service.IUserAction;
-import org.richfaces.realworld.ui.PasswordHolder;
-
-@Name("registerManager")
-(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;
-
- @Logger Log log;
-
- @In Identity identity;
-
- @In Credentials credentials;
-
- @In FacesMessages facesMessages;
-
- @In PasswordHolder passwordHolder;
- @In IUserAction userAction;
-
- @End
- public String register(User user){
- if(checkPassword(user) || checkUserExist(user)){
- return "";
- }
- user.setPasswordHash(passwordHolder.hash(user.getPassword()));
- userAction.register(user);
- return "index";
- }
-
- public String goToIndex(){
- return "index";
- }
-
- public String goToRegister(){
- identity.logout();
- identity.unAuthenticate();
- credentials.clear();
- credentials.invalidate();
- return "register";
- }
-
- private boolean checkUserExist(User user) {
- if(userAction.isUserExist(user.getLogin())){
- addFacesMessage(Constants.REGISTER_LOGIN_NAME_ID,
USER_WITH_THIS_LOGIN_ALREADY_EXIST);
- return true;
- }
- return false;
- }
-
- private void addFacesMessage(String componentId, String message ) {
- UIComponent root = FacesContext.getCurrentInstance().getViewRoot();
- UIComponent component = root.findComponent(componentId);
- FacesContext.getCurrentInstance().addMessage(component.getClientId(FacesContext.getCurrentInstance()),
new FacesMessage(
- FacesMessage.SEVERITY_ERROR, message , message));
- }
-
- private boolean checkPassword(User user) {
- if(!user.getPassword().equals(user.getConfirmPassword())){
- addFacesMessage(Constants.REGISTER_CONFIRM_PASSWORD_ID,
CONFIRM_PASSWORD_NOT_EQUALS_PASSWORD);
- return true;
- }
- return false;
- }
-}
Deleted:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tags/RealworldImageScrollerRenderer.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tags/RealworldImageScrollerRenderer.java 2009-04-08
09:53:10 UTC (rev 13422)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tags/RealworldImageScrollerRenderer.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -1,113 +0,0 @@
-/**
- *
- */
-package org.richfaces.realworld.tags;
-
-import java.io.IOException;
-
-import javax.faces.component.UIComponent;
-import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-
-import org.richfaces.component.UIDatascroller;
-import org.richfaces.renderkit.html.DatascrollerTemplate;
-
-/**
- * @author Andrey Markavtsov
- *
- */
-//TODO nick - remove this
-public class RealworldImageScrollerRenderer extends DatascrollerTemplate {
-
- @Override
- public void renderPager(FacesContext context, UIComponent component,
- int pageIndex, int count) throws IOException {
- ResponseWriter out = context.getResponseWriter();
- UIDatascroller scroller = (UIDatascroller) component;
- int currentPage = pageIndex;
-
- int maxPages = scroller.getMaxPages();
- if (maxPages <= 1) {
- maxPages = 1;
- }
-
- int pageCount = count;
- if (pageCount <= 1) {
- return;
- }
-
- int delta = maxPages / 2;
-
- int pages;
- int start;
- if (pageCount > maxPages && currentPage > delta) {
- pages = maxPages;
- start = currentPage - pages / 2 - 1;
- if (start + pages > pageCount) {
- start = pageCount - pages;
- }
- } else {
- pages = pageCount < maxPages ? pageCount : maxPages;
- start = 0;
- }
-
- for (int i = start, size = start + pages; i < size; i++) {
-
- boolean isCurrentPage = (i + 1 == currentPage);
- String styleClass;
- String style;
- if (isCurrentPage) {
- styleClass = scroller.getSelectedStyleClass();
- style = scroller.getSelectedStyle();
- } else {
- styleClass = scroller.getInactiveStyleClass();
- style = scroller.getInactiveStyle();
- }
- if (styleClass==null){
- styleClass="";
- }
-
- out.startElement("td", component);
- out.startElement("div", component);
-
- if (!isCurrentPage) {
- out.writeAttribute("onclick", getOnClick(Integer.toString(i +
1)), null);
- }
-
- renderPageVar(context, component, i);
-
- if (isCurrentPage) {
- out.writeAttribute("class", styleClass, null);
- UIComponent facet = component.getFacet("activePage");
- if (facet != null) {
- renderChild(context, facet);
- }
- } else {
- out.writeAttribute("class", styleClass, null);
- UIComponent facet = component.getFacet("inactivePage");
- if (facet != null) {
- renderChild(context, facet);
- }
- }
- if (null != style) out.writeAttribute("style", style, null);
- //out.writeText(Integer.toString(i + 1), null);
- //renderChild(context, link);
- out.endElement("div");
- out.endElement("td");
- }
- }
-
- void renderPageVar(FacesContext context, UIComponent component, int i) {
- String varName = (String) component.getAttributes().get("pageVar");
- if (varName != null && varName.length() > 0) {
- context.getExternalContext()
- .getRequestMap().put(varName, new Integer(i));
- }
- }
-
- @Override
- protected Class getComponentClass() {
- return super.getComponentClass();
- }
-
-}
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-08
09:53:10 UTC (rev 13422)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ConfirmationPopupHelper.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -44,13 +44,13 @@
private String actionName;
- @In @Out(required=false)
+ @In @Out
private Image image;
- @In @Out(required=false)
+ @In @Out
private Shelf shelf;
- @In @Out(required=false)
+ @In @Out
private Album album;
@In AlbumManager albumManager;
Copied:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/DirectLinkHelper.java
(from rev 13408,
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/ui/DirectLinkHelper.java
(rev 0)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/DirectLinkHelper.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -0,0 +1,48 @@
+package org.richfaces.realworld.ui;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.persistence.EntityManager;
+
+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.security.Credentials;
+import org.jboss.seam.security.Identity;
+import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.service.Constants;
+import org.richfaces.realworld.util.RealworldException;
+
+@Name("directLink")
+(a)Scope(ScopeType.EVENT)
+@AutoCreate
+public class DirectLinkHelper {
+ private static final String DEFAULT_PICTURE = "default/noimage.jpg";
+
+ @In(value="entityManager")
+ protected EntityManager em;
+
+ @In ImageLoader imageLoader;
+
+ @In Identity identity;
+
+ @In Credentials credentials;
+
+ public void paintImage(OutputStream out, Object data)
+ throws IOException, RealworldException {
+ Long id = Long.valueOf(data.toString());
+ Image im = em.find(Image.class, id);
+ if(im == null || im.getAlbum() == null || im.getAlbum().getShelf() == null){
+ imageLoader.paintImage(out, DEFAULT_PICTURE);
+ return;
+ }
+ if(im.getAlbum().getShelf().isShared() || (identity.hasRole(Constants.ADMIN_ROLE)
&& im.getAlbum().getOwner().getLogin().equals(credentials.getUsername()))){
+ imageLoader.paintImage(out, im.getPath());
+ }else{
+ return;
+ }
+ }
+}
\ No newline at end of file
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/EditorBean.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/EditorBean.java 2009-04-08
09:53:10 UTC (rev 13422)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/EditorBean.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -28,8 +28,6 @@
private String currentConfiguration =
"/org/richfaces/realworld/editor/advanced";
- private boolean liveUpdatesEnabled=false;
-
private String message;
public String getMessage() {
@@ -44,13 +42,4 @@
public String getCurrentConfiguration() {
return currentConfiguration;
}
-
- public boolean isLiveUpdatesEnabled() {
- return liveUpdatesEnabled;
- }
-
- public void setLiveUpdatesEnabled(boolean liveUpdatesEnabled) {
- this.liveUpdatesEnabled = liveUpdatesEnabled;
- }
-
}
\ No newline at end of file
Copied:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ErrorHandlerBean.java
(from rev 13408,
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/ui/ErrorHandlerBean.java
(rev 0)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ErrorHandlerBean.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -0,0 +1,51 @@
+/**
+ * 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.util.ArrayList;
+import java.util.List;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Observer;
+import org.jboss.seam.annotations.Scope;
+import org.richfaces.realworld.service.Constants;
+
+@Name("errorHandlerBean")
+(a)Scope(ScopeType.EVENT)
+@AutoCreate
+public class ErrorHandlerBean {
+ private List<String> errors = new ArrayList<String>();
+
+ public List<String> getErrors() {
+ return errors;
+ }
+
+ public boolean isErrorExist(){
+ return errors.size() > 0 ;
+ }
+
+ @Observer(Constants.ADD_ERROR_EVENT)
+ public void addToErrors(String e){
+ errors.add(e);
+ }
+}
Deleted:
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-08
09:53:10 UTC (rev 13422)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -1,164 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * 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.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.util.Date;
-
-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.annotations.security.Restrict;
-import org.jboss.seam.core.Events;
-import org.richfaces.event.UploadEvent;
-import org.richfaces.model.UploadItem;
-import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.manager.FileManager;
-import org.richfaces.realworld.manager.Model;
-import org.richfaces.realworld.service.Constants;
-import org.richfaces.realworld.service.IImageAction;
-
-import com.drew.imaging.jpeg.JpegMetadataReader;
-import com.drew.metadata.Directory;
-import com.drew.metadata.Metadata;
-import com.drew.metadata.MetadataException;
-import com.drew.metadata.exif.ExifDirectory;
-import com.drew.metadata.jpeg.JpegDirectory;
-
-/**
- * @author $Autor$
- *
- */
-@Name("fileUploadBean")
-(a)Scope(ScopeType.EVENT)
-public class FileUploadBean implements Serializable {
-
- @In("#{messages['file_processing_error']}")
- private String FILE_PROCESSING_ERROR;
-
- @In("#{messages['file_saving_error']}")
- private String FILE_SAVE_ERROR;
-
- @In IImageAction imageAction;
- @In(required = true, scope=ScopeType.CONVERSATION) @Out(scope=ScopeType.CONVERSATION)
- FileWrapper fileWrapper;
-
- @In Model model;
- @In private FileManager fileManager;
-
- private static final long serialVersionUID = 4969087557225414955L;
-
- @Restrict("#{s:hasRole('admin')}")
- public void listener(UploadEvent event) throws Exception {
- UploadItem item = event.getUploadItem();
- Image image = constructImage(item);
- try {
- extractMetadata(item, image);
- } catch (Exception e1) {
- 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, "Please specify album to
download");
- return;
- }
- String newPath = Constants.SLASH + model.getSelectedAlbum().getOwner().getLogin() +
Constants.SLASH + model.getSelectedAlbum().getId() + Constants.SLASH +item.getFileName();
- image.setPath(newPath);
- if(!fileManager.addImage(newPath, item.getFile().getPath())){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, FILE_SAVE_ERROR);
- item.getFile().delete();
- return;
- }
- fileWrapper.getFiles().add(0, image);
- imageAction.addImage(image);
- Events.instance().raiseEvent("imageAdded");
- item.getFile().delete();
- }
-
- private Image constructImage(UploadItem item) {
- Image image = new Image();
- image.setUploaded(new Date());
- image.setDescription(item.getFileName());
- image.setName(item.getFileName());
- image.setSize(item.getFileSize());
- image.setAllowComments(true);
- return image;
- }
-
- private void extractMetadata(UploadItem item, Image image)
- throws RuntimeException, IOException {
- InputStream in =null;
- try{
- in = new FileInputStream(item.getFile());
- Metadata metadata = JpegMetadataReader.readMetadata(in);
- Directory exifDirectory = metadata.getDirectory(ExifDirectory.class);
- Directory jpgDirectory = metadata.getDirectory(JpegDirectory.class);
- setupCameraModel(image, exifDirectory);
- setupDimensions(image, exifDirectory, jpgDirectory);
- setupCreatedDate(image, exifDirectory);
- }catch(Exception e){
- throw new RuntimeException();
- }finally{
- in.close();
- }
- }
-
- private void setupCreatedDate(Image image, Directory exifDirectory)
- throws MetadataException {
- if (exifDirectory.containsTag(ExifDirectory.TAG_DATETIME_ORIGINAL)) {
- Date time = exifDirectory.getDate(ExifDirectory.TAG_DATETIME_ORIGINAL);
- image.setCreated(time);
- }
- }
-
- private void setupDimensions(Image image, Directory exifDirectory,
- Directory jpgDirectory) throws MetadataException {
- if (exifDirectory.containsTag(ExifDirectory.TAG_EXIF_IMAGE_WIDTH) &&
exifDirectory.containsTag(ExifDirectory.TAG_EXIF_IMAGE_HEIGHT)) {
- int width = exifDirectory.getInt(ExifDirectory.TAG_EXIF_IMAGE_WIDTH);
- image.setWidth(width);
- int height = exifDirectory.getInt(ExifDirectory.TAG_EXIF_IMAGE_HEIGHT);
- image.setHeight(height);
- } else {
- if (jpgDirectory.containsTag(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT)) {
- int width = jpgDirectory.getInt(JpegDirectory.TAG_JPEG_IMAGE_WIDTH);
- image.setWidth(width);
- int height = jpgDirectory.getInt(JpegDirectory.TAG_JPEG_IMAGE_HEIGHT);
- image.setHeight(height);
- }
- }
- }
-
- private void setupCameraModel(Image image, Directory exifDirectory) {
- if (exifDirectory.containsTag(ExifDirectory.TAG_MODEL)) {
- String cameraModel = exifDirectory.getString(ExifDirectory.TAG_MODEL);
- image.setCameraModel(cameraModel);
- }else{
- image.setCameraModel("");
- }
- }
-}
\ No newline at end of file
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java 2009-04-08
09:53:10 UTC (rev 13422)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -37,7 +37,9 @@
public class FileWrapper implements Serializable{
private static final long serialVersionUID = -1767281809514660171L;
+
private List<Image> files = new ArrayList<Image>();
+
public int getSize() {
return getFiles().size();
}
@@ -59,4 +61,4 @@
public void clear(){
files.clear();
}
-}
+}
\ No newline at end of file
Copied:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/Help.java
(from rev 13390,
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/ui/Help.java
(rev 0)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/Help.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -0,0 +1,26 @@
+package org.richfaces.realworld.ui;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.AutoCreate;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+
+@Name("help")
+(a)Scope(ScopeType.EVENT)
+@AutoCreate
+public class Help {
+
+ private String page = "/includes/help/tree_click_descr.xhtml";
+
+ public String getPage() {
+ return page;
+ }
+
+ public void setPage(String page) {
+ this.page = page;
+ }
+
+ public void navigateTo(String src){
+ this.setPage(src);
+ }
+}
Copied:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ImageLoader.java
(from rev 13408,
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/ui/ImageLoader.java
(rev 0)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/ImageLoader.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -0,0 +1,78 @@
+/**
+ * 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 java.io.IOException;
+import java.io.OutputStream;
+import java.io.Serializable;
+
+import javax.imageio.ImageIO;
+import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageOutputStream;
+
+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.richfaces.realworld.manager.FileManager;
+
+@Name("imageLoader")
+(a)Scope(ScopeType.EVENT)
+@AutoCreate
+public class ImageLoader implements Serializable {
+
+ private static final long serialVersionUID = -1572789608594870285L;
+
+ @In
+ FileManager fileManager;
+
+ public void paintImage(OutputStream out, Object data) throws IOException {
+ if (null == data) {
+ return;
+ }
+ File imageResource = null;
+ if(data.toString().endsWith("upload")){
+ imageResource = fileManager.getFileByAbsolutePath(data.toString());
+ }else{
+ imageResource = fileManager.getFileByPath(data.toString());
+ }
+ if (imageResource != null && imageResource.exists()) {
+
+ byte [] toWrite = new byte[8192];
+
+ ImageInputStream inputStream = ImageIO.createImageInputStream(imageResource);
+ ImageOutputStream outputStream = ImageIO.createImageOutputStream(out);
+
+ try {
+ while(inputStream.read(toWrite) != -1) {
+ outputStream.write(toWrite);
+ }
+
+ } finally {
+ outputStream.close();
+ inputStream.close();
+ }
+
+ }
+ }
+}
Deleted:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/PasswordHolder.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/PasswordHolder.java 2009-04-08
09:53:10 UTC (rev 13422)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/PasswordHolder.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -1,33 +0,0 @@
-package org.richfaces.realworld.ui;
-
-import java.security.MessageDigest;
-
-import org.jboss.seam.annotations.AutoCreate;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.util.Hex;
-
-@Name("passwordHolder")
-@AutoCreate
-public class PasswordHolder {
- private String digestAlgorithm;
- private String charset;
-
- public void setDigestAlgorithm(String algorithm) {
- this.digestAlgorithm = algorithm;
- }
-
- public void setCharset(String charset) {
- this.charset = charset;
- }
-
- public String hash(String plainTextPassword) {
- try {
- MessageDigest digest = MessageDigest.getInstance(digestAlgorithm);
- digest.update(plainTextPassword.getBytes(charset));
- byte[] rawHash = digest.digest();
- return new String(Hex.encodeHex(rawHash));
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-}
\ No newline at end of file
Copied:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/CopyImageStuff.java
(from rev 13408,
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/startup/CopyImageStuff.java)
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/CopyImageStuff.java
(rev 0)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/CopyImageStuff.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -0,0 +1,107 @@
+/**
+ *
+ */
+package org.richfaces.realworld.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Destroy;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Out;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Startup;
+
+
+/**
+ * @author Andrey Markavtsov
+ *
+ */
+
+@Name("CopyImagesStuff")
+(a)Scope(ScopeType.APPLICATION)
+@Startup
+public class CopyImageStuff {
+
+ static final String WEB_INF = "WEB-INF";
+
+ static final String IMAGE_FOLDER = "/Upload";
+
+ //TODO nick - change constant value to include "richfaces"
+ static final String REALWORLD_FOLDER = "realworld";
+
+ @Out(scope = ScopeType.APPLICATION)
+ File uploadRoot;
+
+ @Out(scope = ScopeType.APPLICATION)
+ String uploadRootPath;
+
+ String imageSrc;
+
+ @Create
+ public void create() throws Exception {
+ resolveImageFolder();
+ resolveUploadRoot();
+
+ copyImages();
+ }
+
+ @Destroy
+ public void destroy()throws IOException {
+ FileUtils.deleteDirectory(uploadRoot);
+ }
+
+ void resolveImageFolder() {
+ //TODO nick - what this cast is for?
+ URLClassLoader loader = (URLClassLoader)getClass().getClassLoader();
+ //TODO nick - rewrite that
+ URL path = loader.getResource("");
+ String classLoadPath = null;
+ String realPath = null;
+
+ if (path != null) {
+ classLoadPath = path.getFile();
+ }
+
+ if (classLoadPath != null) {
+ int index = classLoadPath.indexOf(WEB_INF);
+ if (index != -1) {
+ realPath = classLoadPath.substring(0, index + WEB_INF.length()) + IMAGE_FOLDER;
+ }
+ }
+
+ if (realPath != null) {
+ this.imageSrc = realPath;
+ }else {
+ throw new NullPointerException("Cannot bound image folder path");
+ }
+
+ }
+
+ void resolveUploadRoot()throws IOException {
+ String property = System.getProperty("java.io.tmpdir");
+ if(!property.endsWith(File.separator)){
+ property+=File.separator;
+ }
+ String uploadRootPath = property + REALWORLD_FOLDER + File.separator;
+ if (uploadRootPath != null) {
+ uploadRoot = new File(uploadRootPath);
+ if (uploadRoot.exists()) {
+ FileUtils.deleteDirectory(uploadRoot);
+ }
+ uploadRoot.mkdir();
+ this.uploadRootPath = uploadRoot.getCanonicalPath();
+ }else {
+ throw new NullPointerException("Upload root was not created");
+ }
+ }
+
+ void copyImages()throws IOException {
+ FileUtils.copyDirectory(new File(imageSrc), uploadRoot);
+ }
+
+}
\ No newline at end of file
Deleted:
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-08
09:53:10 UTC (rev 13422)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLinkHelper.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -1,47 +0,0 @@
-package org.richfaces.realworld.util;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.persistence.EntityManager;
-
-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.security.Credentials;
-import org.jboss.seam.security.Identity;
-import org.richfaces.realworld.domain.Image;
-import org.richfaces.realworld.service.Constants;
-
-@Name("directLink")
-(a)Scope(ScopeType.EVENT)
-@AutoCreate
-public class DirectLinkHelper {
- private static final String DEFAULT_PICTURE = "default/noimage.jpg";
-
- @In(value="entityManager")
- protected EntityManager em;
-
- @In ImageLoader imageLoader;
-
- @In Identity identity;
-
- @In Credentials credentials;
-
- public void paintImage(OutputStream out, Object data)
- throws IOException, RealworldException {
- Long id = Long.valueOf(data.toString());
- Image im = em.find(Image.class, id);
- if(im == null || im.getAlbum() == null || im.getAlbum().getShelf() == null){
- imageLoader.paintImage(out, DEFAULT_PICTURE);
- return;
- }
- if(im.getAlbum().getShelf().isShared() || (identity.hasRole(Constants.ADMIN_ROLE)
&& im.getAlbum().getOwner().getLogin().equals(credentials.getUsername()))){
- imageLoader.paintImage(out, im.getPath());
- }else{
- return;
- }
- }
-}
\ No newline at end of file
Deleted:
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-08
09:53:10 UTC (rev 13422)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ErrorHandlerBean.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -1,56 +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.util;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.AutoCreate;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Observer;
-import org.jboss.seam.annotations.Scope;
-import org.richfaces.realworld.service.Constants;
-
-@Name("errorHandlerBean")
-(a)Scope(ScopeType.EVENT)
-@AutoCreate
-public class ErrorHandlerBean {
- private List<String> errors = new ArrayList<String>();
-
- public List<String> getErrors() {
- return errors;
- }
-
- public boolean isErrorExist(){
- return errors.size() > 0 ;
- }
-
- @Observer(Constants.CLEAR_ERROR_EVENT)
- public void clearEvents(){
- errors.clear();
- }
-
- @Observer(Constants.ADD_ERROR_EVENT)
- public void addToErrors(String e){
- errors.add(e);
- }
-}
Deleted:
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-08
09:53:10 UTC (rev 13422)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/Help.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -1,26 +0,0 @@
-package org.richfaces.realworld.util;
-
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.AutoCreate;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Scope;
-
-@Name("help")
-(a)Scope(ScopeType.EVENT)
-@AutoCreate
-public class Help {
-
- private String page = "/includes/help/tree_click_descr.xhtml";
-
- public String getPage() {
- return page;
- }
-
- public void setPage(String page) {
- this.page = page;
- }
-
- public void navigateTo(String src){
- this.setPage(src);
- }
-}
Deleted:
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-08
09:53:10 UTC (rev 13422)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java 2009-04-08
09:55:14 UTC (rev 13423)
@@ -1,78 +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.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.Serializable;
-
-import javax.imageio.ImageIO;
-import javax.imageio.stream.ImageInputStream;
-import javax.imageio.stream.ImageOutputStream;
-
-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.richfaces.realworld.manager.FileManager;
-
-@Name("imageLoader")
-(a)Scope(ScopeType.EVENT)
-@AutoCreate
-public class ImageLoader implements Serializable {
-
- private static final long serialVersionUID = -1572789608594870285L;
-
- @In
- FileManager fileManager;
-
- public void paintImage(OutputStream out, Object data) throws IOException {
- if (null == data) {
- return;
- }
- File imageResource = null;
- if(data.toString().endsWith("upload")){
- imageResource = fileManager.getFileByAbsolutePath(data.toString());
- }else{
- imageResource = fileManager.getFileByPath(data.toString());
- }
- if (imageResource != null && imageResource.exists()) {
-
- byte [] toWrite = new byte[8192];
-
- ImageInputStream inputStream = ImageIO.createImageInputStream(imageResource);
- ImageOutputStream outputStream = ImageIO.createImageOutputStream(out);
-
- try {
- while(inputStream.read(toWrite) != -1) {
- outputStream.write(toWrite);
- }
-
- } finally {
- outputStream.close();
- inputStream.close();
- }
-
- }
- }
-}
Modified: trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/components.xml
===================================================================
---
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/components.xml 2009-04-08
09:53:10 UTC (rev 13422)
+++
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/components.xml 2009-04-08
09:55:14 UTC (rev 13423)
@@ -22,7 +22,7 @@
<core:init transaction-management-enabled="false" debug="true"
jndi-pattern="@jndiPattern@"/>
<core:manager concurrent-request-timeout="20000"
- conversation-timeout="120000"
+ conversation-timeout="200000"
conversation-id-parameter="cid"
default-flush-mode="MANUAL"/>
<persistence:managed-persistence-context name="entityManager"
@@ -30,7 +30,7 @@
persistence-unit-jndi-name="java:/realWorldEntityManager"/>
<transaction:ejb-transaction/>
<security:identity
authenticate-method="#{authenticator.authenticate}"/>
- <component name="passwordHolder" digestAlgorithm="SHA-1"
charset="UTF-8"/>
+ <component name="authenticator" digestAlgorithm="SHA-1"
charset="UTF-8"/>
<component name="org.jboss.seam.ui.entityConverter">
<property name="entityManager">#{em}</property>
</component>
Modified: trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/faces-config.xml 2009-04-08
09:53:10 UTC (rev 13422)
+++
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/faces-config.xml 2009-04-08
09:55:14 UTC (rev 13423)
@@ -21,10 +21,5 @@
<renderer-type>org.ajax4jsf.components.RealworldAjaxCommandButtonRenderer</renderer-type>
<renderer-class>org.richfaces.realworld.tags.RealworldCommandButtonRenderer</renderer-class>
</renderer>
- <renderer>
- <component-family>org.richfaces.Datascroller</component-family>
- <renderer-type>org.ajax4jsf.components.RealworldImageDataScroller</renderer-type>
- <renderer-class>org.richfaces.realworld.tags.RealworldImageScrollerRenderer</renderer-class>
- </renderer>
</render-kit>
</faces-config>
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-08
09:53:10 UTC (rev 13422)
+++
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/tags/realWorld-taglib.xml 2009-04-08
09:55:14 UTC (rev 13423)
@@ -11,11 +11,4 @@
<renderer-type>org.ajax4jsf.components.RealworldAjaxCommandButtonRenderer</renderer-type>
</component>
</tag>
- <tag>
- <tag-name>imageDataScroller</tag-name>
- <component>
- <component-type>org.richfaces.Datascroller</component-type>
-
<renderer-type>org.ajax4jsf.components.RealworldImageDataScroller</renderer-type>
- </component>
- </tag>
</facelet-taglib>
\ No newline at end of file
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/fileUpload/fileUploader.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/index/header.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/index/login.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/errorPanel.xhtml
===================================================================
(Binary files differ)
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-08
09:53:10 UTC (rev 13422)
+++
trunk/test-applications/realworld2/web/src/main/webapp/includes/misc/inputNumberSlider.xhtml 2009-04-08
09:55:14 UTC (rev 13423)
@@ -5,16 +5,10 @@
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:richx="http://richfaces.org/richx">
- <div>
- <rich:inputNumberSlider enableManualInput="false"
- value="#{imageSizeHelper.value}"
- minValue="80"
- maxValue="200"
- showArrows="false"
- showBoundaryValues="true"
- showInput="false"
- step="40">
- <a4j:support event="onchange"
reRender="userAlbumImages"/>
- </rich:inputNumberSlider>
- </div>
+ <div><rich:inputNumberSlider enableManualInput="false"
+ value="#{imageSizeHelper.value}" minValue="80"
maxValue="200"
+ showArrows="false" showBoundaryValues="true"
showInput="false"
+ step="40">
+ <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/register.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-08
09:53:10 UTC (rev 13422)
+++ trunk/test-applications/realworld2/web/src/main/webapp/scripts/realworld.js 2009-04-08
09:55:14 UTC (rev 13423)
@@ -9,18 +9,4 @@
}
target.value += tag;
}
-}
-
-function updateUploadProgressBarLabel (progressBar, fileUpload) {
- var c = fileUpload.entries.length;
- var uploaded = 0;
- for (var i=0;i<c;i++) {
- if (fileUpload.entries[i].state == FileUploadEntry.UPLOAD_SUCCESS) {
- uploaded++;
- }
- }
-
- var value = (c >0) ? 100 * uploaded / c : 0;
- progressBar.setValue(value);
- progressBar.setLabel(uploaded + '/' + c + ' completed');
}
\ No newline at end of file