Author: amarkhel
Date: 2009-05-12 12:18:36 -0400 (Tue, 12 May 2009)
New Revision: 14125
Added:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/Environment.java
Modified:
trunk/examples/photoalbum/source/web/environment/dev/environment.properties
trunk/examples/photoalbum/source/web/environment/prod/environment.properties
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/ui/Help.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/SessionListener.java
trunk/examples/photoalbum/source/web/src/main/webapp/error.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/fileUpload/fileUploader.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/fileUpload/uploadResult.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/help/buttonHelp.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/help/fileUploadHelp.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/help/tree_user.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageInfo.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageScroller.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/inputNumberSlider.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/index/status.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/index/tree.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/misc/errorPanel.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/misc/help.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/userPrefs/userPrefsEdit.xhtml
Log:
Modified: trunk/examples/photoalbum/source/web/environment/dev/environment.properties
===================================================================
--- trunk/examples/photoalbum/source/web/environment/dev/environment.properties 2009-05-12
16:18:17 UTC (rev 14124)
+++ trunk/examples/photoalbum/source/web/environment/dev/environment.properties 2009-05-12
16:18:36 UTC (rev 14125)
@@ -1 +1,2 @@
-environment=development
\ No newline at end of file
+environment=development
+showHelpIconsStrategy=yes
Modified: trunk/examples/photoalbum/source/web/environment/prod/environment.properties
===================================================================
---
trunk/examples/photoalbum/source/web/environment/prod/environment.properties 2009-05-12
16:18:17 UTC (rev 14124)
+++
trunk/examples/photoalbum/source/web/environment/prod/environment.properties 2009-05-12
16:18:36 UTC (rev 14125)
@@ -1 +1,2 @@
-environment=production
\ No newline at end of file
+environment=production
+showHelpIconsStrategy=yes
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java 2009-05-12
16:18:17 UTC (rev 14124)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java 2009-05-12
16:18:36 UTC (rev 14125)
@@ -42,6 +42,7 @@
import org.richfaces.photoalbum.domain.User;
import org.richfaces.photoalbum.service.Constants;
import org.richfaces.photoalbum.service.IUserAction;
+import org.richfaces.photoalbum.util.Environment;
import org.richfaces.photoalbum.util.HashUtils;
@Name("authenticator")
@@ -78,6 +79,10 @@
user = userAction.login(credentials.getUsername(), HashUtils
.hash(credentials.getPassword()));
if (user != null) {
+ if (Environment.isInProduction() && user.isPreDefined()) {
+ loginFailed();
+ return false;
+ }
identity.addRole(Constants.ADMIN_ROLE);
Events.instance().raiseEvent(Constants.AUTHENTICATED_EVENT,
user);
@@ -85,10 +90,7 @@
return true;
}
} catch (Exception nre) {
- setLoginFailed(true);
- facesMessages.clear();
- facesMessages.add(Constants.INVALID_LOGIN_OR_PASSWORD);
- FacesContext.getCurrentInstance().renderResponse();
+ loginFailed();
return false;
}
return false;
@@ -147,6 +149,13 @@
Events.instance().raiseEvent(Constants.START_REGISTER_EVENT);
}
+ public String startConversation() {
+ Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
+ NavigationEnum.ANONYM);
+ setConversationStarted(true);
+ return "";
+ }
+
private boolean checkUserExist(User user) {
if (userAction.isUserExist(user.getLogin())) {
addFacesMessage(Constants.REGISTER_LOGIN_NAME_ID,
@@ -186,11 +195,11 @@
return false;
}
- public String startConversation() {
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT,
- NavigationEnum.ANONYM);
- setConversationStarted(true);
- return "";
+ private void loginFailed() {
+ setLoginFailed(true);
+ facesMessages.clear();
+ facesMessages.add(Constants.INVALID_LOGIN_OR_PASSWORD);
+ FacesContext.getCurrentInstance().renderResponse();
}
public boolean isLoginFailed() {
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/ui/Help.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/ui/Help.java 2009-05-12
16:18:17 UTC (rev 14124)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/ui/Help.java 2009-05-12
16:18:36 UTC (rev 14125)
@@ -4,6 +4,7 @@
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
+import org.richfaces.photoalbum.util.Environment;
@Name("help")
@Scope(ScopeType.EVENT)
@@ -23,4 +24,8 @@
public void navigateTo(String src){
this.setPage(src);
}
+
+ public boolean isShowHelp(){
+ return Environment.isShowHelp();
+ }
}
Added:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/Environment.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/Environment.java
(rev 0)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/Environment.java 2009-05-12
16:18:36 UTC (rev 14125)
@@ -0,0 +1,67 @@
+package org.richfaces.photoalbum.util;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.jboss.seam.contexts.ServletLifecycle;
+
+public class Environment {
+
+ private static final String SHOW_HELP_ICONS_STRATEGY =
"showHelpIconsStrategy";
+
+ public static final String ENVIRONMENT_PROPERTIES = "environment.properties";
+
+ public static final String ENVIRONMENT = "environment";
+ public static final String DEVELOPMENT = "development";
+ public static final String PRODUCTION = "production";
+ public static final String SHOW = "yes";
+ public static final String NOT_SHOW = "no";
+
+ private static String getEnvironment() {
+ try {
+ final Properties props = new Properties();
+ props.load(new FileInputStream(ServletLifecycle.getServletContext()
+ .getRealPath("WEB-INF/classes/" + ENVIRONMENT_PROPERTIES)));
+ return props.getProperty(ENVIRONMENT);
+ } catch (FileNotFoundException e) {
+ // Do nothing.
+ } catch (IOException e) {
+ // Do nothing.
+ }
+
+ return null;
+ }
+
+ private static String getShowHelpIconsStrategy() {
+ try {
+ final Properties props = new Properties();
+ props.load(new FileInputStream(ServletLifecycle.getServletContext()
+ .getRealPath("WEB-INF/classes/" + ENVIRONMENT_PROPERTIES)));
+ return props.getProperty(SHOW_HELP_ICONS_STRATEGY);
+ } catch (FileNotFoundException e) {
+ // Do nothing.
+ } catch (IOException e) {
+ // Do nothing.
+ }
+
+ return null;
+ }
+
+ public static boolean isInProduction(){
+ final String environment = getEnvironment();
+ if (DEVELOPMENT.equals(environment)) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean isShowHelp(){
+ final String environment = getShowHelpIconsStrategy();
+ if (SHOW.equals(environment)) {
+ return true;
+ }
+ return false;
+ }
+}
Property changes on:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/Environment.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/SessionListener.java
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/SessionListener.java 2009-05-12
16:18:17 UTC (rev 14124)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/SessionListener.java 2009-05-12
16:18:36 UTC (rev 14125)
@@ -1,16 +1,10 @@
package org.richfaces.photoalbum.util;
import java.util.List;
-import java.util.Properties;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.FileNotFoundException;
import javax.persistence.EntityManager;
-import javax.servlet.ServletContext;
import org.jboss.seam.ScopeType;
-import org.jboss.seam.contexts.ServletLifecycle;
import org.jboss.seam.annotations.Destroy;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
@@ -28,13 +22,7 @@
@Name("sessionListener")
@Startup
public class SessionListener {
- public static final String ENVIRONMENT_PROPERTIES = "environment.properties";
-
- public static final String ENVIRONMENT = "environment";
- public static final String DEVELOPMENT = "development";
- public static final String PRODUCTION = "production";
-
-
+
@In(required=false)
private User user;
@@ -47,8 +35,7 @@
@Transactional
@Observer("org.jboss.seam.sessionExpired")
public void onDestroy(){
- final String environment = getEnviroment();
- if (DEVELOPMENT.equals(environment)) {
+ if (!Environment.isInProduction()) {
return;
}
@@ -65,18 +52,5 @@
}
}
- private String getEnviroment() {
- try {
- final Properties props = new Properties();
- props.load(new FileInputStream(ServletLifecycle.getServletContext()
- .getRealPath("WEB-INF/classes/" + ENVIRONMENT_PROPERTIES)));
- return props.getProperty(ENVIRONMENT);
- } catch (FileNotFoundException e) {
- // Do nothing.
- } catch (IOException e) {
- // Do nothing.
- }
-
- return null;
- }
+
}
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/error.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/fileUpload/fileUploader.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/fileUpload/uploadResult.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/help/buttonHelp.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/help/fileUploadHelp.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/help/tree_user.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageInfo.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageScroller.xhtml
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageScroller.xhtml 2009-05-12
16:18:17 UTC (rev 14124)
+++
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageScroller.xhtml 2009-05-12
16:18:36 UTC (rev 14125)
@@ -35,7 +35,7 @@
</a4j:outputPanel>
</a4j:repeat>
</h:panelGrid>
- <a4j:commandLink style="position: absolute; right: -65px; top: 80px;"
actionListener="#{help.navigateTo('/includes/help/imageScrollerHelp.xhtml')}"
oncomplete="#{rich:component('helpPanel')}.show()"
+ <a4j:commandLink rendered="#{help.isShowHelp()}" style="position:
absolute; right: -65px; top: 80px;"
actionListener="#{help.navigateTo('/includes/help/imageScrollerHelp.xhtml')}"
oncomplete="#{rich:component('helpPanel')}.show()"
reRender="helpPanel">
<h:panelGroup style="width: 34px; height: 34px; display: inline-block;
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/icons/help_sign.png',sizingMethod='scale');">
<h:graphicImage style="border:none;" height="34"
width="34" border="0" styleClass="ie6transparency"
value="img/icons/help_sign.png"></h:graphicImage>
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/inputNumberSlider.xhtml
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/inputNumberSlider.xhtml 2009-05-12
16:18:17 UTC (rev 14124)
+++
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/inputNumberSlider.xhtml 2009-05-12
16:18:36 UTC (rev 14125)
@@ -12,7 +12,7 @@
step="40" width="100">
<a4j:support event="onchange" reRender="userAlbumImages" />
</rich:inputNumberSlider>
- <a4j:commandLink
actionListener="#{help.navigateTo('/includes/help/inputSliderHelp.xhtml')}"
oncomplete="#{rich:component('helpPanel')}.show()"
+ <a4j:commandLink rendered="#{help.isShowHelp()}"
actionListener="#{help.navigateTo('/includes/help/inputSliderHelp.xhtml')}"
oncomplete="#{rich:component('helpPanel')}.show()"
reRender="helpPanel">
<h:panelGroup style="width: 34px; height: 34px; display: inline-block;
filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='img/icons/help_sign.png',sizingMethod='scale');">
<h:graphicImage style="border:none;" border="0"
width="34" height="34" styleClass="ie6transparency"
value="img/icons/help_sign.png"></h:graphicImage>
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/index/status.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/index/tree.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/misc/errorPanel.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/misc/help.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/userPrefs/userPrefsEdit.xhtml
===================================================================
(Binary files differ)
Show replies by date