Seam SVN: r8281 - branches/Seam_2_0/src/main/org/jboss/seam.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-05-25 08:55:06 -0400 (Sun, 25 May 2008)
New Revision: 8281
Modified:
branches/Seam_2_0/src/main/org/jboss/seam/Seam.java
Log:
removed unnecessary null check
Modified: branches/Seam_2_0/src/main/org/jboss/seam/Seam.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/Seam.java 2008-05-25 00:26:51 UTC (rev 8280)
+++ branches/Seam_2_0/src/main/org/jboss/seam/Seam.java 2008-05-25 12:55:06 UTC (rev 8281)
@@ -48,8 +48,7 @@
{
return info;
}
- else if (clazz.getClassLoader() == null ||
- (clazz.getClassLoader() != null && !CLASSLOADERS_LOADED.contains(clazz.getClassLoader())))
+ else if (!CLASSLOADERS_LOADED.contains(clazz.getClassLoader()))
{
cacheEjbDescriptors(clazz);
return EJB_DESCRIPTOR_CACHE.get(clazz);
16 years, 7 months
Seam SVN: r8280 - trunk/src/main/org/jboss/seam.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-05-24 20:26:51 -0400 (Sat, 24 May 2008)
New Revision: 8280
Modified:
trunk/src/main/org/jboss/seam/Seam.java
Log:
synchronize loading of cache
Modified: trunk/src/main/org/jboss/seam/Seam.java
===================================================================
--- trunk/src/main/org/jboss/seam/Seam.java 2008-05-25 00:25:09 UTC (rev 8279)
+++ trunk/src/main/org/jboss/seam/Seam.java 2008-05-25 00:26:51 UTC (rev 8280)
@@ -44,7 +44,7 @@
private static final Map<Class, EjbDescriptor> EJB_DESCRIPTOR_CACHE = new ConcurrentHashMap<Class, EjbDescriptor>();
private static final Set<ClassLoader> CLASSLOADERS_LOADED = new HashSet<ClassLoader>();
- private static EjbDescriptor getEjbDescriptor(Class clazz)
+ public static EjbDescriptor getEjbDescriptor(Class clazz)
{
EjbDescriptor info = EJB_DESCRIPTOR_CACHE.get(clazz);
if (info != null)
@@ -54,14 +54,22 @@
else if (clazz.getClassLoader() == null ||
(clazz.getClassLoader() != null && !CLASSLOADERS_LOADED.contains(clazz.getClassLoader())))
{
+ cacheEjbDescriptors(clazz);
+ return EJB_DESCRIPTOR_CACHE.get(clazz);
+ }
+
+ return null;
+ }
+
+ private synchronized static void cacheEjbDescriptors(Class clazz)
+ {
+ if (!CLASSLOADERS_LOADED.contains(clazz.getClassLoader()))
+ {
Map<Class, EjbDescriptor> ejbDescriptors = new DeploymentDescriptor(clazz).getEjbDescriptors();
EJB_DESCRIPTOR_CACHE.putAll(ejbDescriptors);
- CLASSLOADERS_LOADED.add(clazz.getClassLoader());
- return ejbDescriptors.get(clazz);
+ CLASSLOADERS_LOADED.add(clazz.getClassLoader());
}
-
- return null;
- }
+ }
/**
* Get the default scope
16 years, 7 months
Seam SVN: r8279 - branches/Seam_2_0/src/main/org/jboss/seam.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-05-24 20:25:09 -0400 (Sat, 24 May 2008)
New Revision: 8279
Modified:
branches/Seam_2_0/src/main/org/jboss/seam/Seam.java
Log:
oops, method can't be private
Modified: branches/Seam_2_0/src/main/org/jboss/seam/Seam.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/Seam.java 2008-05-25 00:24:20 UTC (rev 8278)
+++ branches/Seam_2_0/src/main/org/jboss/seam/Seam.java 2008-05-25 00:25:09 UTC (rev 8279)
@@ -41,7 +41,7 @@
private static final Map<Class, EjbDescriptor> EJB_DESCRIPTOR_CACHE = new ConcurrentHashMap<Class, EjbDescriptor>();
private static final Set<ClassLoader> CLASSLOADERS_LOADED = new HashSet<ClassLoader>();
- private static EjbDescriptor getEjbDescriptor(Class clazz)
+ public static EjbDescriptor getEjbDescriptor(Class clazz)
{
EjbDescriptor info = EJB_DESCRIPTOR_CACHE.get(clazz);
if (info != null)
16 years, 7 months
Seam SVN: r8278 - branches/Seam_2_0/src/main/org/jboss/seam.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-05-24 20:24:20 -0400 (Sat, 24 May 2008)
New Revision: 8278
Modified:
branches/Seam_2_0/src/main/org/jboss/seam/Seam.java
Log:
synchronized loading of cache
Modified: branches/Seam_2_0/src/main/org/jboss/seam/Seam.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/Seam.java 2008-05-24 10:09:54 UTC (rev 8277)
+++ branches/Seam_2_0/src/main/org/jboss/seam/Seam.java 2008-05-25 00:24:20 UTC (rev 8278)
@@ -41,7 +41,7 @@
private static final Map<Class, EjbDescriptor> EJB_DESCRIPTOR_CACHE = new ConcurrentHashMap<Class, EjbDescriptor>();
private static final Set<ClassLoader> CLASSLOADERS_LOADED = new HashSet<ClassLoader>();
- static EjbDescriptor getEjbDescriptor(Class clazz)
+ private static EjbDescriptor getEjbDescriptor(Class clazz)
{
EjbDescriptor info = EJB_DESCRIPTOR_CACHE.get(clazz);
if (info != null)
@@ -51,14 +51,22 @@
else if (clazz.getClassLoader() == null ||
(clazz.getClassLoader() != null && !CLASSLOADERS_LOADED.contains(clazz.getClassLoader())))
{
+ cacheEjbDescriptors(clazz);
+ return EJB_DESCRIPTOR_CACHE.get(clazz);
+ }
+
+ return null;
+ }
+
+ private synchronized static void cacheEjbDescriptors(Class clazz)
+ {
+ if (!CLASSLOADERS_LOADED.contains(clazz.getClassLoader()))
+ {
Map<Class, EjbDescriptor> ejbDescriptors = new DeploymentDescriptor(clazz).getEjbDescriptors();
EJB_DESCRIPTOR_CACHE.putAll(ejbDescriptors);
- CLASSLOADERS_LOADED.add(clazz.getClassLoader());
- return ejbDescriptors.get(clazz);
+ CLASSLOADERS_LOADED.add(clazz.getClassLoader());
}
-
- return null;
- }
+ }
/**
* Get the default scope
16 years, 7 months
Seam SVN: r8277 - in branches/Seam_2_0/src/main/org/jboss/seam: init and 1 other directory.
by seam-commits@lists.jboss.org
Author: shane.bryzak(a)jboss.com
Date: 2008-05-24 06:09:54 -0400 (Sat, 24 May 2008)
New Revision: 8277
Modified:
branches/Seam_2_0/src/main/org/jboss/seam/Seam.java
branches/Seam_2_0/src/main/org/jboss/seam/init/DeploymentDescriptor.java
Log:
backported JBSEAM-2917
Modified: branches/Seam_2_0/src/main/org/jboss/seam/Seam.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/Seam.java 2008-05-23 20:30:05 UTC (rev 8276)
+++ branches/Seam_2_0/src/main/org/jboss/seam/Seam.java 2008-05-24 10:09:54 UTC (rev 8277)
@@ -11,7 +11,9 @@
import static org.jboss.seam.util.EJB.STATELESS;
import static org.jboss.seam.util.EJB.name;
+import java.util.HashSet;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import javax.persistence.Entity;
@@ -35,30 +37,28 @@
*/
public class Seam
{
-
private static final Map<Class, String> COMPONENT_NAME_CACHE = new ConcurrentHashMap<Class, String>();
- private static final Map<String, EjbDescriptor> EJB_DESCRIPTOR_CACHE = new ConcurrentHashMap<String, EjbDescriptor>();
+ private static final Map<Class, EjbDescriptor> EJB_DESCRIPTOR_CACHE = new ConcurrentHashMap<Class, EjbDescriptor>();
+ private static final Set<ClassLoader> CLASSLOADERS_LOADED = new HashSet<ClassLoader>();
- public static EjbDescriptor getEjbDescriptor(String className)
+ static EjbDescriptor getEjbDescriptor(Class clazz)
{
- EjbDescriptor info = EJB_DESCRIPTOR_CACHE.get(className);
+ EjbDescriptor info = EJB_DESCRIPTOR_CACHE.get(clazz);
if (info != null)
{
return info;
}
- else
+ else if (clazz.getClassLoader() == null ||
+ (clazz.getClassLoader() != null && !CLASSLOADERS_LOADED.contains(clazz.getClassLoader())))
{
- Map<String, EjbDescriptor> ejbDescriptors = new DeploymentDescriptor().getEjbDescriptors();
+ Map<Class, EjbDescriptor> ejbDescriptors = new DeploymentDescriptor(clazz).getEjbDescriptors();
EJB_DESCRIPTOR_CACHE.putAll(ejbDescriptors);
- return ejbDescriptors.get(className);
+ CLASSLOADERS_LOADED.add(clazz.getClassLoader());
+ return ejbDescriptors.get(clazz);
}
+
+ return null;
}
-
- // TODO Better impl
- static EjbDescriptor getEjbDescriptor(Class clazz)
- {
- return getEjbDescriptor(clazz.getName());
- }
/**
* Get the default scope
@@ -161,7 +161,7 @@
}
else
{
- EjbDescriptor ejbDescriptor = Seam.getEjbDescriptor(clazz.getName());
+ EjbDescriptor ejbDescriptor = Seam.getEjbDescriptor(clazz);
if (ejbDescriptor != null)
{
return ejbDescriptor.getBeanType() == ComponentType.ENTITY_BEAN ? clazz : null;
Modified: branches/Seam_2_0/src/main/org/jboss/seam/init/DeploymentDescriptor.java
===================================================================
--- branches/Seam_2_0/src/main/org/jboss/seam/init/DeploymentDescriptor.java 2008-05-23 20:30:05 UTC (rev 8276)
+++ branches/Seam_2_0/src/main/org/jboss/seam/init/DeploymentDescriptor.java 2008-05-24 10:09:54 UTC (rev 8277)
@@ -23,10 +23,16 @@
{
private static final LogProvider log = Logging.getLogProvider(Initialization.class);
- private Map<String, EjbDescriptor> ejbDescriptors = new HashMap<String, EjbDescriptor>();
+ private Map<Class, EjbDescriptor> ejbDescriptors = new HashMap<Class, EjbDescriptor>();
+ private Class componentClass;
- public DeploymentDescriptor()
+ public DeploymentDescriptor(Class clazz)
{
+ componentClass = clazz;
+ if (clazz.getClassLoader() == null) {
+ return;
+ }
+
try
{
InputStream ejbJarXml = Resources.getResourceAsStream("META-INF/ejb-jar.xml", null);
@@ -54,7 +60,7 @@
}
}
- public Map<String, EjbDescriptor> getEjbDescriptors()
+ public Map<Class, EjbDescriptor> getEjbDescriptors()
{
return ejbDescriptors;
}
@@ -197,6 +203,14 @@
protected void add(EjbDescriptor descriptor)
{
- ejbDescriptors.put(descriptor.getEjbClassName(), descriptor);
+ try
+ {
+ Class ejbClass = componentClass.getClassLoader().loadClass( descriptor.getEjbClassName() );
+ ejbDescriptors.put(ejbClass, descriptor);
+ }
+ catch (ClassNotFoundException cnfe)
+ {
+ log.warn("Could not load EJB class: " + descriptor.getEjbClassName());
+ }
}
}
16 years, 7 months
Seam SVN: r8276 - trunk/src/main/org/jboss/seam/framework.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-05-23 16:30:05 -0400 (Fri, 23 May 2008)
New Revision: 8276
Modified:
trunk/src/main/org/jboss/seam/framework/HibernateEntityController.java
trunk/src/main/org/jboss/seam/framework/HibernateEntityHome.java
trunk/src/main/org/jboss/seam/framework/HibernateEntityQuery.java
Log:
JBSEAM-3037
Modified: trunk/src/main/org/jboss/seam/framework/HibernateEntityController.java
===================================================================
--- trunk/src/main/org/jboss/seam/framework/HibernateEntityController.java 2008-05-23 20:02:56 UTC (rev 8275)
+++ trunk/src/main/org/jboss/seam/framework/HibernateEntityController.java 2008-05-23 20:30:05 UTC (rev 8276)
@@ -35,7 +35,7 @@
@Override
protected String getPersistenceContextName()
{
- return "session";
+ return "hibernateSession";
}
protected Criteria createCriteria(Class clazz)
Modified: trunk/src/main/org/jboss/seam/framework/HibernateEntityHome.java
===================================================================
--- trunk/src/main/org/jboss/seam/framework/HibernateEntityHome.java 2008-05-23 20:02:56 UTC (rev 8275)
+++ trunk/src/main/org/jboss/seam/framework/HibernateEntityHome.java 2008-05-23 20:30:05 UTC (rev 8276)
@@ -23,7 +23,7 @@
super.create();
if ( getSession()==null )
{
- throw new IllegalStateException("session is null");
+ throw new IllegalStateException("hibernateSession is null");
}
}
@@ -103,7 +103,7 @@
@Override
protected String getPersistenceContextName()
{
- return "session";
+ return "hibernateSession";
}
@Override
Modified: trunk/src/main/org/jboss/seam/framework/HibernateEntityQuery.java
===================================================================
--- trunk/src/main/org/jboss/seam/framework/HibernateEntityQuery.java 2008-05-23 20:02:56 UTC (rev 8275)
+++ trunk/src/main/org/jboss/seam/framework/HibernateEntityQuery.java 2008-05-23 20:30:05 UTC (rev 8276)
@@ -29,7 +29,7 @@
super.validate();
if ( getSession()==null )
{
- throw new IllegalStateException("session is null");
+ throw new IllegalStateException("hibernateSession is null");
}
}
@@ -128,7 +128,7 @@
@Override
protected String getPersistenceContextName()
{
- return "session";
+ return "hibernateSession";
}
protected org.hibernate.Query createQuery()
16 years, 7 months
Seam SVN: r8275 - trunk/seam-gen.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-05-23 16:02:56 -0400 (Fri, 23 May 2008)
New Revision: 8275
Modified:
trunk/seam-gen/build.xml
Log:
JBSEAM-3027
Modified: trunk/seam-gen/build.xml
===================================================================
--- trunk/seam-gen/build.xml 2008-05-23 20:02:27 UTC (rev 8274)
+++ trunk/seam-gen/build.xml 2008-05-23 20:02:56 UTC (rev 8275)
@@ -205,7 +205,7 @@
<property name="old.richfaces.skin" value="blueSky"/>
<input addproperty="richfaces.skin.new"
message="Select a RichFaces skin [${old.richfaces.skin}]"
- validargs="blueSky,classic,ruby,wine,deepMarine,emeraldTown,sakura,DEFAULT"
+ validargs="blueSky,classic,ruby,wine,deepMarine,emeraldTown,japanCherry,DEFAULT"
defaultvalue="${old.richfaces.skin}"/>
<property name="old.project.type" value="ear"/>
16 years, 7 months
Seam SVN: r8274 - branches/Seam_2_0/seam-gen.
by seam-commits@lists.jboss.org
Author: dan.j.allen
Date: 2008-05-23 16:02:27 -0400 (Fri, 23 May 2008)
New Revision: 8274
Modified:
branches/Seam_2_0/seam-gen/build.xml
Log:
JBSEAM-3027
Modified: branches/Seam_2_0/seam-gen/build.xml
===================================================================
--- branches/Seam_2_0/seam-gen/build.xml 2008-05-23 16:12:57 UTC (rev 8273)
+++ branches/Seam_2_0/seam-gen/build.xml 2008-05-23 20:02:27 UTC (rev 8274)
@@ -205,7 +205,7 @@
<property name="old.richfaces.skin" value="blueSky"/>
<input addproperty="richfaces.skin.new"
message="Select a RichFaces skin [${old.richfaces.skin}]"
- validargs="blueSky,classic,ruby,wine,deepMarine,emeraldTown,sakura,DEFAULT"
+ validargs="blueSky,classic,ruby,wine,deepMarine,emeraldTown,japanCherry,DEFAULT"
defaultvalue="${old.richfaces.skin}"/>
<property name="old.project.type" value="ear"/>
16 years, 7 months
Seam SVN: r8273 - in trunk/examples/wiki: src/main/org/jboss/seam/wiki/core/action and 8 other directories.
by seam-commits@lists.jboss.org
Author: christian.bauer(a)jboss.com
Date: 2008-05-23 12:12:57 -0400 (Fri, 23 May 2008)
New Revision: 8273
Added:
trunk/examples/wiki/view/errors/
trunk/examples/wiki/view/errors/generic.jsp
trunk/examples/wiki/view/errors/toomanysessions.html
Modified:
trunk/examples/wiki/src/etc/WEB-INF/pages.xml
trunk/examples/wiki/src/etc/WEB-INF/web.xml
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHistory.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/TagQuery.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/renderer/WikiURLRenderer.java
trunk/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/templates/forumReplies.xhtml
trunk/examples/wiki/view/docDisplay_d.xhtml
trunk/examples/wiki/view/docHistory_d.xhtml
trunk/examples/wiki/view/includes/commentForm.xhtml
trunk/examples/wiki/view/includes/commentsDisplay.xhtml
trunk/examples/wiki/view/themes/default/css/template.css
trunk/examples/wiki/view/themes/inrelationto/css/inrelationto.css
trunk/examples/wiki/view/themes/sfwkorg/css/sfwk.css
Log:
Replaced dangerous (for bots) s:links, highlighting of selected comments, improved generic error handling
Modified: trunk/examples/wiki/src/etc/WEB-INF/pages.xml
===================================================================
--- trunk/examples/wiki/src/etc/WEB-INF/pages.xml 2008-05-23 16:09:51 UTC (rev 8272)
+++ trunk/examples/wiki/src/etc/WEB-INF/pages.xml 2008-05-23 16:12:57 UTC (rev 8273)
@@ -198,7 +198,7 @@
<page view-id="/userHome*" no-conversation-view-id="/wiki.xhtml">
<param name="userId" value="#{userHome.userId}"/>
- <action execute="#{userHome.init}"/>
+ <action execute="#{userHome.initEdit}"/>
<begin-conversation flush-mode="MANUAL" join="true"/>
<navigation>
<rule if-outcome="updatedCurrentCredentials">
@@ -217,6 +217,7 @@
<page view-id="/userInfo*">
<param name="userId" value="#{userHome.userId}"/>
<param name="username" value="#{userHome.requestedUsername}"/>
+ <action execute="#{userHome.initDisplay}"/>
</page>
<page view-id="/userList*">
Modified: trunk/examples/wiki/src/etc/WEB-INF/web.xml
===================================================================
--- trunk/examples/wiki/src/etc/WEB-INF/web.xml 2008-05-23 16:09:51 UTC (rev 8272)
+++ trunk/examples/wiki/src/etc/WEB-INF/web.xml 2008-05-23 16:12:57 UTC (rev 8273)
@@ -128,6 +128,19 @@
<!-- Misc Settings -->
+ <error-page>
+ <error-code>500</error-code>
+ <exception-type>java.lang.IllegalStateException</exception-type>
+ <location>/errors/toomanysessions.html</location>
+ <!-- Don't use a Faces or JSP page here, too many sessions means nothing works anymore!
+ Unfortunately, Tomcat can't be bothered to throw anything better than an IllegalStateException... -->
+ </error-page>
+
+ <error-page>
+ <error-code>500</error-code>
+ <location>/errors/generic.jsp</location>
+ </error-page>
+
<!-- Session timeout,can be extended for authenticated users in components.xml! -->
<session-config>
<session-timeout>10</session-timeout>
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHistory.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHistory.java 2008-05-23 16:09:51 UTC (rev 8272)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/DocumentHistory.java 2008-05-23 16:12:57 UTC (rev 8273)
@@ -12,6 +12,7 @@
import org.jboss.seam.wiki.core.dao.WikiNodeDAO;
import org.jboss.seam.wiki.core.model.WikiDocument;
import org.jboss.seam.wiki.core.model.WikiFile;
+import org.jboss.seam.wiki.core.exception.InvalidWikiRequestException;
import org.jboss.seam.wiki.util.Diff;
import org.jboss.seam.wiki.util.WikiUtil;
@@ -87,7 +88,7 @@
if (!isInitialized) {
if (getFileId() == null)
- throw new org.jboss.seam.framework.EntityNotFoundException(getFileId(), WikiDocument.class);
+ throw new InvalidWikiRequestException("Missing filedId request parameter");
log.debug("initializing document history with file id: " + getFileId());
@@ -113,6 +114,7 @@
public void displayHistoricalRevision() {
log.debug("displaying historical file id: " + selectedHistoricalFile.getHistoricalFileId());
+
displayedHistoricalFile = selectedHistoricalFile;
diffResult = null;
@@ -124,28 +126,16 @@
);
}
- public void diff() {
- init(); // TODO: Why doesn't Seam execute my page action but instead s:link action="diff" in a fake RENDER RESPONSE?!?
- displayedHistoricalFile = null;
+ public void diffHistoricalRevision() {
+ log.debug("diffing historical file id: " + selectedHistoricalFile.getHistoricalFileId());
- if (historicalFileId == null) return;
- selectedHistoricalFile = wikiNodeDAO.findHistoricalFile(getCurrentFile().getHistoricalEntityName(), historicalFileId);
- if (selectedHistoricalFile == null) {
- statusMessages.addFromResourceBundleOrDefault(
- ERROR,
- "lacewiki.msg.HistoricalNodeNotFound",
- "Couldn't find historical node: {0}",
- historicalFileId
- );
- return;
- }
-
String[] a = ((WikiDocument)selectedHistoricalFile).getContent().split("\n");
String[] b = ((WikiDocument)currentFile).getContent().split("\n");
StringBuilder result = new StringBuilder();
List<Diff.Difference> differences = new Diff(a, b).diff();
+ // TODO: Externalize and i18n these strings
for (Diff.Difference diff : differences) {
int delStart = diff.getDeletedStart();
int delEnd = diff.getDeletedEnd();
@@ -201,6 +191,25 @@
);
}
+ // This methods takes the historicalFileId parameter to load a revision from the DB
+ public void diff() {
+ init(); // TODO: Why doesn't Seam execute my page action but instead s:link action="diff" in a fake RENDER RESPONSE?!?
+ displayedHistoricalFile = null;
+
+ if (historicalFileId == null) return;
+ selectedHistoricalFile = wikiNodeDAO.findHistoricalFile(getCurrentFile().getHistoricalEntityName(), historicalFileId);
+ if (selectedHistoricalFile == null) {
+ statusMessages.addFromResourceBundleOrDefault(
+ ERROR,
+ "lacewiki.msg.HistoricalNodeNotFound",
+ "Couldn't find historical node: {0}",
+ historicalFileId
+ );
+ return;
+ }
+ diffHistoricalRevision();
+ }
+
@Restrict("#{s:hasPermission('Node', 'edit', documentHistory.currentFile)}")
public String rollback() {
statusMessages.addFromResourceBundleOrDefault(
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/TagQuery.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/TagQuery.java 2008-05-23 16:09:51 UTC (rev 8272)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/TagQuery.java 2008-05-23 16:12:57 UTC (rev 8273)
@@ -16,6 +16,7 @@
import org.jboss.seam.wiki.core.model.WikiDirectory;
import org.jboss.seam.wiki.core.model.WikiFile;
import org.jboss.seam.wiki.core.model.WikiNode;
+import org.jboss.seam.wiki.core.exception.InvalidWikiRequestException;
import java.io.Serializable;
import java.util.List;
@@ -50,6 +51,9 @@
}
public void loadTaggedFiles() {
+ if (tag == null) {
+ throw new InvalidWikiRequestException("Missing tag parameter");
+ }
log.debug("loading wiki files tagged with: " + tag);
taggedFiles = tagDAO.findWikFiles(wikiRoot, null, tag, WikiNode.SortableProperty.createdOn, false);
}
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java 2008-05-23 16:09:51 UTC (rev 8272)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/UserHome.java 2008-05-23 16:12:57 UTC (rev 8273)
@@ -27,6 +27,7 @@
import org.jboss.seam.wiki.core.model.User;
import org.jboss.seam.wiki.core.model.WikiUploadImage;
import org.jboss.seam.wiki.core.upload.Uploader;
+import org.jboss.seam.wiki.core.exception.InvalidWikiRequestException;
import org.jboss.seam.wiki.preferences.PreferenceVisibility;
import org.jboss.seam.wiki.preferences.Preferences;
import org.jboss.seam.wiki.preferences.PreferenceProvider;
@@ -34,7 +35,6 @@
import org.jboss.seam.wiki.util.Hash;
import org.jboss.seam.wiki.util.WikiUtil;
-import static org.jboss.seam.international.StatusMessage.Severity.ERROR;
import static org.jboss.seam.international.StatusMessage.Severity.WARN;
import static org.jboss.seam.international.StatusMessage.Severity.INFO;
@@ -115,6 +115,19 @@
}
}
+ public void initEdit() {
+ if (getUserId() == null) {
+ throw new InvalidWikiRequestException("Missing userId request parameter");
+ }
+ init();
+ }
+
+ public void initDisplay() {
+ if (getUserId() == null && getRequestedUsername() == null) {
+ throw new InvalidWikiRequestException("Missing userId or username request parameter");
+ }
+ }
+
@Override
protected void initInstance() {
if ( isIdDefined() || (getRequestedUsername() != null && getRequestedUsername().length() >0) ) {
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java 2008-05-23 16:09:51 UTC (rev 8272)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/WikiIdentity.java 2008-05-23 16:12:57 UTC (rev 8273)
@@ -200,8 +200,8 @@
// Can't delete admin and guest accounts
User adminUser = (User)Component.getInstance("adminUser");
User guestUser = (User)Component.getInstance("guestUser");
- if (user.getId().equals(adminUser.getId())) return false;
- if (user.getId().equals(guestUser.getId())) return false;
+ if (adminUser.getId().equals(user.getId())) return false;
+ if (guestUser.getId().equals(user.getId())) return false;
if (currentAccessLevel == Role.ADMINROLE_ACCESSLEVEL) return true;
return false;
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/renderer/WikiURLRenderer.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/renderer/WikiURLRenderer.java 2008-05-23 16:09:51 UTC (rev 8272)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/renderer/WikiURLRenderer.java 2008-05-23 16:12:57 UTC (rev 8273)
@@ -90,6 +90,10 @@
return url.toString();
}
+ public String renderFeedURL(Feed feed) {
+ return renderFeedURL(feed, null, null, false);
+ }
+
public String renderFeedURL(Feed feed, String tag, String comments) {
return renderFeedURL(feed, tag, comments, false);
}
Modified: trunk/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/templates/forumReplies.xhtml
===================================================================
--- trunk/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/templates/forumReplies.xhtml 2008-05-23 16:09:51 UTC (rev 8272)
+++ trunk/examples/wiki/src/plugin/org/jboss/seam/wiki/plugin/forum/templates/forumReplies.xhtml 2008-05-23 16:12:57 UTC (rev 8273)
@@ -42,25 +42,25 @@
</s:div>
<s:div id="forumPostingControls" styleClass="forumPostingControls">
+ <h:form>
+ <h:panelGroup rendered="#{not replyHome.showForm and replyHome.isPersistAllowed(null,null)}">
- <h:panelGroup rendered="#{not replyHome.showForm and replyHome.isPersistAllowed(null,null)}">
+ <h:commandLink tabindex="1" action="#{replyHome.replyToDocument()}"
+ accesskey="#{messages['forum.button.Reply.accesskey']}"
+ styleClass="buttonNonpersistent">
+ <f:param name="conversationPropagation" value="none"/>
+ <h:outputText styleClass="buttonLabel" escape="false" value="#{messages['forum.button.Reply']}"/>
+ </h:commandLink>
- <s:link tabindex="1" propagation="none"
- action="#{replyHome.replyToDocument()}"
- accesskey="#{messages['forum.button.Reply.accesskey']}"
- styleClass="buttonNonpersistent">
- <h:outputText styleClass="buttonLabel" escape="false" value="#{messages['forum.button.Reply']}"/>
- </s:link>
+ <h:commandLink tabindex="1" action="#{replyHome.quoteDocument()}"
+ styleClass="buttonNonpersistent"
+ accesskey="#{messages['forum.button.Quote.accesskey']}">
+ <f:param name="conversationPropagation" value="none"/>
+ <h:outputText styleClass="buttonLabel" escape="false" value="#{messages['forum.button.Quote']}"/>
+ </h:commandLink>
- <s:link tabindex="1" propagation="none"
- action="#{replyHome.quoteDocument()}"
- styleClass="buttonNonpersistent"
- accesskey="#{messages['forum.button.Quote.accesskey']}">
- <h:outputText styleClass="buttonLabel" escape="false" value="#{messages['forum.button.Quote']}"/>
- </s:link>
-
- </h:panelGroup>
-
+ </h:panelGroup>
+ </h:form>
</s:div>
<!-- The forumPostingDocumentWrapper <div> is closed here! -->
@@ -124,19 +124,19 @@
<s:fragment rendered="#{not replyHome.showForm and replyHome.isPersistAllowed(null,null)}">
- <s:link tabindex="102" propagation="none"
- action="#{replyHome.replyTo()}"
- styleClass="buttonNonpersistent">
+ <h:commandLink tabindex="102" action="#{replyHome.replyTo()}"
+ styleClass="buttonNonpersistent">
+ <f:param name="conversationPropagation" value="none"/>
<f:param name="parentCommentId" value="#{c.id}"/>
<h:outputText styleClass="buttonLabel" value="#{messages['lacewiki.button.commentsDisplay.ReplyTo']}"/>
- </s:link>
+ </h:commandLink>
- <s:link tabindex="102" propagation="none"
- action="#{replyHome.quote()}"
- styleClass="buttonNonpersistent">
+ <h:commandLink tabindex="102" action="#{replyHome.quote()}"
+ styleClass="buttonNonpersistent">
+ <f:param name="conversationPropagation" value="none"/>
<f:param name="parentCommentId" value="#{c.id}"/>
<h:outputText styleClass="buttonLabel" value="#{messages['lacewiki.button.commentsDisplay.Quote']}"/>
- </s:link>
+ </h:commandLink>
</s:fragment>
Modified: trunk/examples/wiki/view/docDisplay_d.xhtml
===================================================================
--- trunk/examples/wiki/view/docDisplay_d.xhtml 2008-05-23 16:09:51 UTC (rev 8272)
+++ trunk/examples/wiki/view/docDisplay_d.xhtml 2008-05-23 16:12:57 UTC (rev 8273)
@@ -15,7 +15,7 @@
<s:fragment rendered="#{not empty documentHome.instance.parent.feed}">
<link rel="alternate" type="application/atom+xml"
title="#{documentHome.instance.parent.name}"
- href="#{wikiURLRenderer.renderFeedURL(currentDirectory.feed, null, null)}"/>
+ href="#{wikiURLRenderer.renderFeedURL(currentDirectory.feed)}"/>
</s:fragment>
@@ -223,19 +223,19 @@
<s:fragment rendered="#{not commentHome.showForm and s:hasPermission('Comment', 'create', documentHome.instance)}">
- <s:link tabindex="102" propagation="none"
- action="#{commentHome.replyTo()}"
- styleClass="buttonNonpersistent">
+ <h:commandLink tabindex="102" action="#{commentHome.replyTo()}"
+ styleClass="buttonNonpersistent">
+ <f:param name="conversationPropagation" value="none"/>
<f:param name="parentCommentId" value="#{c.id}"/>
<h:outputText styleClass="buttonLabel" value="#{messages['lacewiki.button.commentsDisplay.ReplyTo']}"/>
- </s:link>
+ </h:commandLink>
- <s:link tabindex="102" propagation="none"
- action="#{commentHome.quote()}"
- styleClass="buttonNonpersistent">
+ <h:commandLink tabindex="102" action="#{commentHome.quote()}"
+ styleClass="buttonNonpersistent">
+ <f:param name="conversationPropagation" value="none"/>
<f:param name="parentCommentId" value="#{c.id}"/>
<h:outputText styleClass="buttonLabel" value="#{messages['lacewiki.button.commentsDisplay.Quote']}"/>
- </s:link>
+ </h:commandLink>
</s:fragment>
Modified: trunk/examples/wiki/view/docHistory_d.xhtml
===================================================================
--- trunk/examples/wiki/view/docHistory_d.xhtml 2008-05-23 16:09:51 UTC (rev 8272)
+++ trunk/examples/wiki/view/docHistory_d.xhtml 2008-05-23 16:12:57 UTC (rev 8273)
@@ -97,26 +97,21 @@
</h:column>
<h:column>
- <a:commandLink id="show" status="globalStatus"
- oncomplete="onAjaxRequestComplete()"
- action="#{documentHistory.displayHistoricalRevision}"
+ <a:commandLink action="#{documentHistory.displayHistoricalRevision}"
+ status="globalStatus" oncomplete="onAjaxRequestComplete()"
reRender="messageBoxContainer, historyTable, diffResult, historicalPreview"
tabindex="3" styleClass="buttonNonpersistent sessionEventTrigger">
<h:outputText styleClass="buttonLabel" value="#{messages['lacewiki.button.docHistory.Show']}"/>
</a:commandLink>
- <s:link id="diff" rendered="#{empty documentHistory.diffResult or hfile.historicalFileId != documentHistory.historicalFileId}"
- action="#{documentHistory.diff}" tabindex="3" styleClass="buttonNonpersistent sessionEventTrigger">
+ <a:commandLink action="#{documentHistory.diffHistoricalRevision}"
+ status="globalStatus" oncomplete="onAjaxRequestComplete()"
+ reRender="messageBoxContainer, historyTable, diffResult, historicalPreview"
+ tabindex="3" styleClass="buttonNonpersistent sessionEventTrigger">
<h:outputText styleClass="buttonLabel" value="#{messages['lacewiki.button.docHistory.Diff']}"/>
- <f:param name="historicalFileId" value="#{hfile.historicalFileId}"/>
- </s:link>
- <h:outputLink rendered="#{not empty documentHistory.diffResult and hfile.historicalFileId == documentHistory.historicalFileId}"
- value="#diffResult" tabindex="3" styleClass="buttonNonpersistent sessionEventTrigger">
- <h:outputText styleClass="buttonLabel" value="Diff Output"/>
- </h:outputLink>
+ </a:commandLink>
- <h:commandLink id="rollback"
- action="#{documentHistory.rollback}"
+ <h:commandLink action="#{documentHistory.rollback}"
tabindex="4" styleClass="buttonNonpersistent sessionEventTrigger"
rendered="#{s:hasPermission('Node', 'edit', documentHistory.currentFile)}">
<h:outputText styleClass="buttonLabel" value="#{messages['lacewiki.button.docHistory.Rollback']}"/>
Added: trunk/examples/wiki/view/errors/generic.jsp
===================================================================
--- trunk/examples/wiki/view/errors/generic.jsp (rev 0)
+++ trunk/examples/wiki/view/errors/generic.jsp 2008-05-23 16:12:57 UTC (rev 8273)
@@ -0,0 +1,94 @@
+<%@ page import="java.io.PrintWriter" %>
+<%@ page import="org.jboss.seam.wiki.util.WikiUtil" %>
+<html>
+<head>
+ <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=UTF-8" />
+ <title>Generic error message</title>
+</head>
+<body>
+<style>
+body {
+ font-family : arial, verdana, Geneva, Arial, Helvetica, sans-serif;
+ font-size : 1.1em;
+}
+.errorHeader {
+ font-size: 1.6em;
+ background-color: #6392C6;
+ color: white;
+ font-weight: bold;
+ padding: 3px;
+ margin-bottom: 10px;
+}
+
+.errorFooter {
+ font-size: 0.8em;
+ background-color: #6392C6;
+ color: white;
+ font-style: italic;
+ padding: 3px;
+ margin-top: 5px;
+}
+
+.errorMessage {
+ color: red;
+ font-weight: bold;
+}
+.errorExceptions {
+}
+.errorExceptionStack {
+ margin-top: 5px;
+ padding: 3px;
+ border-style: solid;
+ border-width: 1px;
+ border-color: #9F9F9F;
+ background-color: #E0E0E0;
+}
+.errorExceptionCause {
+ font-size: 1.1em;
+ padding: 3px;
+ border-style: solid;
+ border-width: 1px;
+ border-color: #9F9F9F;
+ background-color: #E0E0E0;
+}
+.errorException {
+ font-size: 1.0em;
+}
+</style>
+<div class="errorHeader">Your request was not successful, server-side error encountered.</div>
+
+<%
+Object exception = request.getAttribute("javax.servlet.error.exception");
+if (exception != null)
+{
+ Throwable throwable = WikiUtil.unwrap((Throwable)exception);
+ String exceptionMessage = throwable.getMessage();
+
+ %>Message: <span class="errorMessage"><%=exceptionMessage%></span><%
+
+ PrintWriter pw = new PrintWriter(out);
+
+ %><br/><%
+ %><span id="errorDetails" class="errorExceptions"><%
+ %><pre class="errorExceptionCause"><%
+ throwable.printStackTrace(pw);
+ %></pre><%
+
+ %><input type="button" value="More Details>>" onclick="document.getElementById('errorMoreDetails').style.display=''"/><%
+ %><div id="errorMoreDetails" style="display:none" class="errorExceptionStack"><%
+
+ %><pre class="errorException"><%
+ throwable.printStackTrace(pw);
+ %></pre><%
+
+ %></div><%
+ %></span><%
+}
+else
+{
+ %>Unknown error<%
+}
+%>
+<div class="errorFooter">End of exception report</div>
+</body>
+</html>
\ No newline at end of file
Added: trunk/examples/wiki/view/errors/toomanysessions.html
===================================================================
--- trunk/examples/wiki/view/errors/toomanysessions.html (rev 0)
+++ trunk/examples/wiki/view/errors/toomanysessions.html 2008-05-23 16:12:57 UTC (rev 8273)
@@ -0,0 +1,11 @@
+<html>
+<head>
+ <title>Too many active users</title>
+</head>
+<body>
+<p>
+ Sorry, your request could not be completed. Too many users are currently active on our website. Please try again later.
+</p>
+</body>
+</html>
+
Modified: trunk/examples/wiki/view/includes/commentForm.xhtml
===================================================================
--- trunk/examples/wiki/view/includes/commentForm.xhtml 2008-05-23 16:09:51 UTC (rev 8272)
+++ trunk/examples/wiki/view/includes/commentForm.xhtml 2008-05-23 16:12:57 UTC (rev 8273)
@@ -27,13 +27,15 @@
<script type="text/javascript">stopSessionTimeoutCheck();</script>
</s:fragment>
- <s:link tabindex="102" rendered="#{!commentHome.showForm}"
- action="#{commentHome.newComment()}" propagation="none"
- accesskey="#{messages['lacewiki.button.commentForm.PostComment.accesskey']}"
- styleClass="buttonNonpersistent">
+ <h:commandLink tabindex="102" rendered="#{!commentHome.showForm}"
+ action="#{commentHome.newComment()}"
+ accesskey="#{messages['lacewiki.button.commentForm.PostComment.accesskey']}"
+ styleClass="buttonNonpersistent">
+
+ <f:attribute name="conversationPropagation" value="none"/>
<h:outputText escape="false" styleClass="buttonLabel"
value="#{messages['lacewiki.button.commentForm.PostComment']}"/>
- </s:link>
+ </h:commandLink>
<s:fragment rendered="#{commentHome.showForm}">
<h:outputText value="#{messages['lacewiki.label.commentForm.PostComment']}"/>
Modified: trunk/examples/wiki/view/includes/commentsDisplay.xhtml
===================================================================
--- trunk/examples/wiki/view/includes/commentsDisplay.xhtml 2008-05-23 16:09:51 UTC (rev 8272)
+++ trunk/examples/wiki/view/includes/commentsDisplay.xhtml 2008-05-23 16:12:57 UTC (rev 8273)
@@ -10,6 +10,20 @@
<s:div styleClass="box" rendered="#{not empty commentQuery.comments}">
+ <script type="text/javascript">
+ jQuery(function() {
+ var fragment = window.location.hash;
+ if (fragment.substring(1,8) == 'comment') {
+ selectCommentBox(fragment);
+ }
+ });
+
+ function selectCommentBox(commentAnchor) {
+ jQuery(".commentBox").removeClass("commentBoxSelected");
+ jQuery(commentAnchor).parent(".commentBox").addClass("commentBoxSelected");
+ }
+ </script>
+
<h:panelGrid columns="1"
styleClass="datatable"
columnClasses="commentColumn"
@@ -25,16 +39,14 @@
<c:forEach var="c" items="#{commentQuery.comments}">
<s:div style="margin-left:#{c.level > 1 ? c.level : ''}0px;"
- styleClass="#{c.level > 1 ? 'commentLevel' : 'commentFirstLevel'}">
+ styleClass="commentBox #{c.level > 1 ? 'commentLevel' : 'commentFirstLevel'}">
- <a id="comment#{c.id}"/>
-
<h:panelGrid columns="3" styleClass="commentHeader"
columnClasses="commentSubject, commentAuthorInfo smallFont, commentAuthorPortrait"
cellpadding="0" cellspacing="0" border="0">
<s:div styleClass="undecoratedLink largeFont" rendered="#{currentDocument.name != c.subject}">
- <h:outputLink value="#{wikiURLRenderer.renderURL(c)}">
+ <h:outputLink value="#{wikiURLRenderer.renderURL(c)}" onclick="selectCommentBox('#comment#{c.id}')">
<h:outputText value="#{c.subject}"/>
</h:outputLink>
</s:div>
@@ -96,6 +108,8 @@
</h:panelGrid>
+ <a id="comment#{c.id}"/>
+
<s:div styleClass="commentText" rendered="#{c.useWikiText and not empty currentDocument.areaNumber}">
<s:cache region="wiki.Comment" key="#{c.id}">
<wiki:formattedText value="#{c.content}"
Modified: trunk/examples/wiki/view/themes/default/css/template.css
===================================================================
--- trunk/examples/wiki/view/themes/default/css/template.css 2008-05-23 16:09:51 UTC (rev 8272)
+++ trunk/examples/wiki/view/themes/default/css/template.css 2008-05-23 16:12:57 UTC (rev 8273)
@@ -1069,6 +1069,10 @@
.commentForm {}
+.commentBoxSelected {
+ border-left: 5px solid #C3BBB6;
+}
+
/* Document history and diff
-----------------------------------------------*/
Modified: trunk/examples/wiki/view/themes/inrelationto/css/inrelationto.css
===================================================================
--- trunk/examples/wiki/view/themes/inrelationto/css/inrelationto.css 2008-05-23 16:09:51 UTC (rev 8272)
+++ trunk/examples/wiki/view/themes/inrelationto/css/inrelationto.css 2008-05-23 16:12:57 UTC (rev 8273)
@@ -1095,6 +1095,10 @@
.commentForm {}
+.commentBoxSelected {
+ border-left: 5px solid #C3BBB6;
+}
+
/* Document history and diff
-----------------------------------------------*/
Modified: trunk/examples/wiki/view/themes/sfwkorg/css/sfwk.css
===================================================================
--- trunk/examples/wiki/view/themes/sfwkorg/css/sfwk.css 2008-05-23 16:09:51 UTC (rev 8272)
+++ trunk/examples/wiki/view/themes/sfwkorg/css/sfwk.css 2008-05-23 16:12:57 UTC (rev 8273)
@@ -808,6 +808,9 @@
.commentForm {}
+.commentBoxSelected {
+ border-left: 5px solid #75a8bd;
+}
/* Document history and diff
-----------------------------------------------*/
16 years, 7 months
Seam SVN: r8272 - trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/ui.
by seam-commits@lists.jboss.org
Author: christian.bauer(a)jboss.com
Date: 2008-05-23 12:09:51 -0400 (Fri, 23 May 2008)
New Revision: 8272
Modified:
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/FeedServlet.java
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/FileServlet.java
Log:
Optimized custom servlets for feeds and files
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/FeedServlet.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/FeedServlet.java 2008-05-23 15:15:55 UTC (rev 8271)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/FeedServlet.java 2008-05-23 16:09:51 UTC (rev 8272)
@@ -8,10 +8,8 @@
import com.sun.syndication.feed.synd.*;
import com.sun.syndication.io.SyndFeedOutput;
+import com.sun.syndication.io.FeedException;
import org.jboss.seam.Component;
-import org.jboss.seam.transaction.Transaction;
-import org.jboss.seam.web.Session;
-import org.jboss.seam.security.Identity;
import org.jboss.seam.international.Messages;
import org.jboss.seam.wiki.core.feeds.FeedDAO;
import org.jboss.seam.wiki.core.model.*;
@@ -31,7 +29,6 @@
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.transaction.UserTransaction;
import java.io.IOException;
import java.util.*;
@@ -79,6 +76,7 @@
// Allow unit testing
public FeedServlet() {}
+ // TODO: All data access in this method runs with auto-commit mode, see http://jira.jboss.com/jira/browse/JBSEAM-957
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
@@ -95,7 +93,6 @@
if (!feedTypes.containsKey(pathInfo)) {
log.debug("can not render this feed type, returning BAD REQUEST");
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Unsupported feed type " + pathInfo);
- invalidateSessionIfPossible(request);
return;
}
SyndFeedType syndFeedType = feedTypes.get(pathInfo);
@@ -120,181 +117,168 @@
tag = tagParam;
}
- // TODO: Seam should use its transaction interceptor for java beans: http://jira.jboss.com/jira/browse/JBSEAM-957
- // and that would allow us to break up this gigantic if/then/else clause easily...
- UserTransaction userTx = null;
- boolean startedTx = false;
- try {
- userTx = Transaction.instance();
- if (userTx.getStatus() != javax.transaction.Status.STATUS_ACTIVE) {
- startedTx = true;
- userTx.begin();
- }
+ Feed feed = resolveFeed(aggregateParam, feedIdParam, areaNameParam, nodeNameParam);
- Feed feed = null;
+ if (feed == null) {
+ log.debug("feed not found, returning NOT FOUND");
+ response.sendError(HttpServletResponse.SC_NOT_FOUND, "Feed");
+ return;
+ }
- // Find the feed, depending on variations of request parameters
- if (aggregateParam != null && aggregateParam.length() > 0) {
-
- log.debug("trying to retrieve aggregated feed from cache: " + aggregateParam);
-
- FeedAggregateCache aggregateCache = (FeedAggregateCache)Component.getInstance(FeedAggregateCache.class);
- List<FeedEntryDTO> result = aggregateCache.get(aggregateParam);
- if (result != null) {
- feed = new Feed();
- feed.setAuthor(Messages.instance().get("lacewiki.msg.AutomaticallyGeneratedFeed"));
- feed.setTitle(Messages.instance().get("lacewiki.msg.AutomaticallyGeneratedFeed") + ": " + aggregateParam);
- feed.setPublishedDate(new Date());
- // We are lying here, we don't really have an alternate representation link for this resource
- feed.setLink( Preferences.instance().get(WikiPreferences.class).getBaseUrl() );
- for (FeedEntryDTO feedEntryDTO : result) {
- feed.getFeedEntries().add(feedEntryDTO.getFeedEntry());
- }
- }
-
- } else if (feedIdParam != null && feedIdParam.length() >0) {
- try {
-
- log.debug("trying to retrieve feed for id: " + feedIdParam);
- Long feedId = Long.valueOf(feedIdParam);
- FeedDAO feedDAO = (FeedDAO)Component.getInstance(FeedDAO.class);
- feed = feedDAO.findFeed(feedId);
- } catch (NumberFormatException ex) {
- log.debug("feed identifier couldn't be converted to java.lang.Long");
- response.sendError(HttpServletResponse.SC_NOT_FOUND, "Feed " + feedIdParam);
- }
-
-
- } else if (areaNameParam != null && areaNameParam.matches("^[A-Z0-9]+.*")) {
- log.debug("trying to retrieve area: " + areaNameParam);
- WikiNodeDAO nodeDAO = (WikiNodeDAO)Component.getInstance(WikiNodeDAO.class);
- WikiDirectory area = nodeDAO.findAreaUnrestricted(areaNameParam);
- if (area != null && (nodeNameParam == null || !nodeNameParam.matches("^[A-Z0-9]+.*")) && area.getFeed() != null) {
- log.debug("using feed of area, no node requested: " + area);
- feed = area.getFeed();
- } else if (area != null && nodeNameParam != null && nodeNameParam.matches("^[A-Z0-9]+.*")) {
- log.debug("trying to retrieve node: " + nodeNameParam);
- WikiDirectory nodeDir = nodeDAO.findWikiDirectoryInAreaUnrestricted(area.getAreaNumber(), nodeNameParam);
- if (nodeDir != null && nodeDir.getFeed() != null) {
- log.debug("using feed of node: " + nodeDir);
- feed = nodeDir.getFeed();
- } else {
- log.debug("node not found or node has no feed");
- }
- } else {
- log.debug("area not found or area has no feed");
- }
- } else {
- log.debug("neither feed id nor area name requested, getting wikiRoot feed");
- WikiNodeFactory factory = (WikiNodeFactory)Component.getInstance(WikiNodeFactory.class);
- feed = factory.loadWikiRoot().getFeed();
- }
-
- if (feed == null) {
- log.debug("feed not found, returning NOT FOUND");
- response.sendError(HttpServletResponse.SC_NOT_FOUND, "Feed");
- if (startedTx) userTx.commit();
- invalidateSessionIfPossible(request);
+ log.debug("checking permissions of " + feed);
+ // Authenticate and authorize, first with current user (session) then with basic HTTP authentication
+ Integer currentAccessLevel = (Integer)Component.getInstance("currentAccessLevel");
+ if (feed.getReadAccessLevel() > currentAccessLevel) {
+ boolean loggedIn = ((Authenticator)Component.getInstance(Authenticator.class)).authenticateBasicHttp(request);
+ currentAccessLevel = (Integer)Component.getInstance("currentAccessLevel");
+ if (!loggedIn || feed.getReadAccessLevel() > currentAccessLevel) {
+ log.debug("requiring authentication, feed has higher access level than current");
+ response.setHeader("WWW-Authenticate", "Basic realm=\"" + feed.getTitle().replace("\"", "'") + "\"");
+ response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
return;
}
+ }
- log.debug("checking permissions of " + feed);
- // Authenticate and authorize, first with current user (session) then with basic HTTP authentication
- Integer currentAccessLevel = (Integer)Component.getInstance("currentAccessLevel");
- if (feed.getReadAccessLevel() > currentAccessLevel) {
- boolean loggedIn = ((Authenticator)Component.getInstance(Authenticator.class)).authenticateBasicHttp(request);
- currentAccessLevel = (Integer)Component.getInstance("currentAccessLevel");
- if (!loggedIn || feed.getReadAccessLevel() > currentAccessLevel) {
- log.debug("requiring authentication, feed has higher access level than current");
- response.setHeader("WWW-Authenticate", "Basic realm=\"" + feed.getTitle().replace("\"", "'") + "\"");
- response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
- if (startedTx) userTx.commit();
- invalidateSessionIfPossible(request);
- return;
- }
+ Date lastFeedEntryDate = null;
+ if (feed.getId() != null) {
+
+ // Ask the database what the latest feed entry is for that feed, then use its updated timestamp hash
+ FeedDAO feedDAO = (FeedDAO)Component.getInstance(FeedDAO.class);
+ List<FeedEntry> result = feedDAO.findLastFeedEntries(feed.getId(), 1);
+ if (result.size() > 0) {
+ lastFeedEntryDate = result.get(0).getUpdatedDate();
}
- Date lastFeedEntryDate = null;
- if (feed.getId() != null) {
+ } else {
- // Ask the database what the latest feed entry is for that feed, then use its updated timestamp hash
- FeedDAO feedDAO = (FeedDAO)Component.getInstance(FeedDAO.class);
- List<FeedEntry> result = feedDAO.findLastFeedEntries(feed.getId(), 1);
- if (result.size() > 0) {
- lastFeedEntryDate = result.get(0).getUpdatedDate();
- }
-
- } else {
-
- // Get the first (latest) entry of the aggregated feed and use its published timestamp hash (ignoring updates!)
- // There is a wrinkle hidden here: What if a feed entry is updated? Then the published timestamp should also
- // be different because the "first latest" feed entry in the list is sorted by both published and updated
- // timestamps. So even though we only use published timestamp hash as an ETag, this timestamp also changes
- // when a feed entry is updated because the collection order changes as well.
- if (feed.getFeedEntries().size() > 0) {
- lastFeedEntryDate = feed.getFeedEntries().iterator().next().getPublishedDate();
- }
+ // Get the first (latest) entry of the aggregated feed and use its published timestamp hash (ignoring updates!)
+ // There is a wrinkle hidden here: What if a feed entry is updated? Then the published timestamp should also
+ // be different because the "first latest" feed entry in the list is sorted by both published and updated
+ // timestamps. So even though we only use published timestamp hash as an ETag, this timestamp also changes
+ // when a feed entry is updated because the collection order changes as well.
+ if (feed.getFeedEntries().size() > 0) {
+ lastFeedEntryDate = feed.getFeedEntries().iterator().next().getPublishedDate();
}
- if (lastFeedEntryDate != null) {
- String etag = calculateEtag(lastFeedEntryDate);
- log.debug("setting etag header: " + etag);
- response.setHeader("ETag", etag);
- String previousToken = request.getHeader("If-None-Match");
- if (previousToken != null && previousToken.equals(etag)) {
- log.debug("found matching etag in request header, returning 304 Not Modified");
- response.sendError(HttpServletResponse.SC_NOT_MODIFIED);
- if (startedTx) userTx.commit();
- invalidateSessionIfPossible(request);
- return;
- }
+ }
+ if (lastFeedEntryDate != null) {
+ String etag = calculateEtag(lastFeedEntryDate);
+ log.debug("setting etag header: " + etag);
+ response.setHeader("ETag", etag);
+ String previousToken = request.getHeader("If-None-Match");
+ if (previousToken != null && previousToken.equals(etag)) {
+ log.debug("found matching etag in request header, returning 304 Not Modified");
+ response.sendError(HttpServletResponse.SC_NOT_MODIFIED);
+ return;
}
+ }
- // TODO: Refactor this parameter mess a little
- log.debug("finally rendering feed");
- SyndFeed syndFeed =
- createSyndFeed(
- request.getRequestURL().toString(),
- syndFeedType,
- feed,
- currentAccessLevel,
- tag,
- comments,
- aggregateParam
- );
+ // TODO: Refactor this parameter mess a little
+ log.debug("finally rendering feed");
+ SyndFeed syndFeed =
+ createSyndFeed(
+ request.getRequestURL().toString(),
+ syndFeedType,
+ feed,
+ currentAccessLevel,
+ tag,
+ comments,
+ aggregateParam
+ );
- // If we have an entry on this feed, take the last entry's update timestamp and use it as
- // the published timestamp of the feed. The Rome library does not have a setUpdatedDate()
- // method and abuses the published date to write <updated> into the Atom <feed> element.
- if (lastFeedEntryDate != null) {
- syndFeed.setPublishedDate(lastFeedEntryDate);
- }
+ // If we have an entry on this feed, take the last entry's update timestamp and use it as
+ // the published timestamp of the feed. The Rome library does not have a setUpdatedDate()
+ // method and abuses the published date to write <updated> into the Atom <feed> element.
+ if (lastFeedEntryDate != null) {
+ syndFeed.setPublishedDate(lastFeedEntryDate);
+ }
- // Write feed to output
- response.setContentType(syndFeedType.contentType);
- response.setCharacterEncoding("UTF-8");
- SyndFeedOutput output = new SyndFeedOutput();
+ // Write feed to output
+ response.setContentType(syndFeedType.contentType);
+ response.setCharacterEncoding("UTF-8");
+ SyndFeedOutput output = new SyndFeedOutput();
+ try {
output.output(syndFeed, response.getWriter());
- response.getWriter().flush();
+ } catch (FeedException ex) {
+ throw new ServletException(ex);
+ }
+ response.getWriter().flush();
- log.debug("<<< commit, rendering complete");
+ log.debug("<<< feed rendering complete");
+ }
- if (startedTx) userTx.commit();
+ public Feed resolveFeed(String aggregateParam, String feedIdParam, String areaNameParam, String nodeNameParam) {
+ Feed feed;
+ // Find the feed, depending on variations of request parameters
+ if (aggregateParam != null && aggregateParam.length() > 0) {
+ feed = resolveFeedWithAggregateId(aggregateParam);
+ } else if (feedIdParam != null && feedIdParam.length() >0) {
+ feed = resolveFeedWithFeedId(feedIdParam);
+ } else if (areaNameParam != null && areaNameParam.length() > 0) {
+ feed = resolveFeedWithAreaNameAndNodeName(areaNameParam, nodeNameParam);
+ } else {
+ log.debug("no aggregate id, no feed id, no area name requested, getting wikiRoot feed");
+ WikiNodeFactory factory = (WikiNodeFactory)Component.getInstance(WikiNodeFactory.class);
+ feed = factory.loadWikiRoot().getFeed();
+ }
+ return feed;
+ }
- } catch (Exception ex) {
- if (startedTx && userTx != null) {
- // We started it, so we need to roll it back
- try {
- userTx.rollback();
- } catch (Exception rbEx) {
- log.error("could not roll back transaction: " + rbEx.getMessage());
- }
+ public Feed resolveFeedWithAggregateId(String aggregateId) {
+ Feed feed = null;
+ log.debug("trying to retrieve aggregated feed from cache: " + aggregateId);
+ FeedAggregateCache aggregateCache = (FeedAggregateCache)Component.getInstance(FeedAggregateCache.class);
+ List<FeedEntryDTO> result = aggregateCache.get(aggregateId);
+ if (result != null) {
+ feed = new Feed();
+ feed.setAuthor(Messages.instance().get("lacewiki.msg.AutomaticallyGeneratedFeed"));
+ feed.setTitle(Messages.instance().get("lacewiki.msg.AutomaticallyGeneratedFeed") + ": " + aggregateId);
+ feed.setPublishedDate(new Date());
+ // We are lying here, we don't really have an alternate representation link for this resource
+ feed.setLink( Preferences.instance().get(WikiPreferences.class).getBaseUrl() );
+ for (FeedEntryDTO feedEntryDTO : result) {
+ feed.getFeedEntries().add(feedEntryDTO.getFeedEntry());
}
- throw new ServletException(ex);
}
+ return feed;
+ }
- invalidateSessionIfPossible(request);
+ public Feed resolveFeedWithFeedId(String feedId) {
+ Feed feed = null;
+ try {
+ log.debug("trying to retrieve feed for id: " + feedId);
+ Long feedIdentifier = Long.valueOf(feedId);
+ FeedDAO feedDAO = (FeedDAO)Component.getInstance(FeedDAO.class);
+ feed = feedDAO.findFeed(feedIdentifier);
+ } catch (NumberFormatException ex) {
+ log.debug("feed identifier couldn't be converted to java.lang.Long");
+ }
+ return feed;
}
+ public Feed resolveFeedWithAreaNameAndNodeName(String areaName, String nodeName) {
+ Feed feed = null;
+ if (!areaName.matches("^[A-Z0-9]+.*")) return feed;
+ log.debug("trying to retrieve area: " + areaName);
+ WikiNodeDAO nodeDAO = (WikiNodeDAO)Component.getInstance(WikiNodeDAO.class);
+ WikiDirectory area = nodeDAO.findAreaUnrestricted(areaName);
+ if (area != null && (nodeName == null || !nodeName.matches("^[A-Z0-9]+.*")) && area.getFeed() != null) {
+ log.debug("using feed of area, no node requested: " + area);
+ feed = area.getFeed();
+ } else if (area != null && nodeName != null && nodeName.matches("^[A-Z0-9]+.*")) {
+ log.debug("trying to retrieve node: " + nodeName);
+ WikiDirectory nodeDir = nodeDAO.findWikiDirectoryInAreaUnrestricted(area.getAreaNumber(), nodeName);
+ if (nodeDir != null && nodeDir.getFeed() != null) {
+ log.debug("using feed of node: " + nodeDir);
+ feed = nodeDir.getFeed();
+ } else {
+ log.debug("node not found or node has no feed");
+ }
+ } else {
+ log.debug("area not found or area has no feed");
+ }
+ return feed;
+ }
+
public SyndFeed createSyndFeed(String baseURI, SyndFeedType syndFeedType, Feed feed, Integer currentAccessLevel) {
return createSyndFeed(baseURI, syndFeedType, feed, currentAccessLevel, null, Comments.include, null);
}
@@ -369,13 +353,4 @@
Hash hash = new Hash();
return hash.hash(date.toString());
}
-
- private void invalidateSessionIfPossible(HttpServletRequest request) {
- // If the user is not logged in, we might as well destroy the session immediately, saving some memory
- if (request.getSession().isNew() && !Identity.instance().isLoggedIn()) {
- log.debug("destroying session that was only created for reading the feed");
- Session.instance().invalidate();
- }
- }
-
}
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/FileServlet.java
===================================================================
--- trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/FileServlet.java 2008-05-23 15:15:55 UTC (rev 8271)
+++ trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/ui/FileServlet.java 2008-05-23 16:09:51 UTC (rev 8272)
@@ -1,7 +1,5 @@
package org.jboss.seam.wiki.core.ui;
-import org.jboss.seam.security.Identity;
-import org.jboss.seam.web.Session;
import org.jboss.seam.wiki.core.dao.WikiNodeDAO;
import org.jboss.seam.wiki.core.model.WikiUpload;
import org.jboss.seam.wiki.core.model.WikiUploadImage;
@@ -12,7 +10,6 @@
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.transaction.UserTransaction;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -45,6 +42,7 @@
}
+ // TODO: All data access in this method runs with auto-commit mode, see http://jira.jboss.com/jira/browse/JBSEAM-957
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
@@ -63,32 +61,8 @@
response.sendError(HttpServletResponse.SC_NOT_FOUND, "File" + id);
}
- // TODO: Seam should use its transaction interceptor for java beans: http://jira.jboss.com/jira/browse/JBSEAM-957
- UserTransaction userTx = null;
- boolean startedTx = false;
- try {
-
- userTx = (UserTransaction)org.jboss.seam.Component.getInstance("org.jboss.seam.transaction.transaction");
- if (userTx.getStatus() != javax.transaction.Status.STATUS_ACTIVE) {
- startedTx = true;
- userTx.begin();
- }
-
- WikiNodeDAO wikiNodeDAO = (WikiNodeDAO)org.jboss.seam.Component.getInstance(WikiNodeDAO.class);
- file = wikiNodeDAO.findWikiUpload(fileId);
-
- if (startedTx) userTx.commit();
- } catch (Exception ex) {
- if (startedTx && userTx != null) {
- // We started it, so we need to roll it back
- try {
- userTx.rollback();
- } catch (Exception rbEx) {
- log.error("could not roll back transaction: " + rbEx.getMessage());
- }
- }
- throw new ServletException(ex);
- }
+ WikiNodeDAO wikiNodeDAO = (WikiNodeDAO)org.jboss.seam.Component.getInstance(WikiNodeDAO.class);
+ file = wikiNodeDAO.findWikiUpload(fileId);
}
String contentType = null;
@@ -137,15 +111,6 @@
response.getOutputStream().flush();
}
- invalidateSessionIfPossible(request);
}
- private void invalidateSessionIfPossible(HttpServletRequest request) {
- // If the user is not logged in, we might as well destroy the session immediately, saving some memory
- if (request.getSession().isNew() && !Identity.instance().isLoggedIn()) {
- log.debug("destroying session that was only created for reading the file");
- Session.instance().invalidate();
- }
- }
-
}
16 years, 7 months