[jboss-cvs] jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao ...
Christian Bauer
christian at hibernate.org
Mon Apr 2 14:25:06 EDT 2007
User: cbauer
Date: 07/04/02 14:25:06
Modified: examples/wiki/src/main/org/jboss/seam/wiki/core/dao
NodeDAO.java UserDAO.java
UserRoleAccessFactory.java WikiNodeFactory.java
Log:
Totally overengineered but definitely cool system/user/instance wiki preferences architecture
Revision Changes Path
1.8 +2 -2 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/NodeDAO.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NodeDAO.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/NodeDAO.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- NodeDAO.java 22 Mar 2007 12:16:08 -0000 1.7
+++ NodeDAO.java 2 Apr 2007 18:25:06 -0000 1.8
@@ -256,14 +256,14 @@
}
public <N extends Node> List<N> findWithParent(Class<N> nodeType, Directory directory, Node ignoreNode,
- String orderByProperty, boolean orderDescending, int firstResult, int maxResults) {
+ String orderByProperty, boolean orderDescending, long firstResult, long maxResults) {
Criteria crit = prepareCriteria(nodeType, orderByProperty, orderDescending);
crit.add(Restrictions.eq("parent", directory));
if (ignoreNode != null)
crit.add(Restrictions.ne("id", ignoreNode.getId()));
if ( !(firstResult == 0 && maxResults == 0) )
- crit.setFirstResult(firstResult).setMaxResults(maxResults);
+ crit.setFirstResult(Long.valueOf(firstResult).intValue()).setMaxResults(Long.valueOf(maxResults).intValue());
//noinspection unchecked
return crit.list();
}
1.4 +5 -0 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/UserDAO.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UserDAO.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/UserDAO.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- UserDAO.java 18 Mar 2007 15:44:36 -0000 1.3
+++ UserDAO.java 2 Apr 2007 18:25:06 -0000 1.4
@@ -28,6 +28,11 @@
@In
protected EntityManager entityManager;
+ public User findUser(Long userId) {
+ entityManager.joinTransaction();
+ return entityManager.find(User.class, userId);
+ }
+
public User findUser(String username, boolean onlyActivated, boolean caseSensitive) {
entityManager.joinTransaction();
1.2 +7 -7 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/UserRoleAccessFactory.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: UserRoleAccessFactory.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/UserRoleAccessFactory.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- UserRoleAccessFactory.java 18 Mar 2007 15:44:36 -0000 1.1
+++ UserRoleAccessFactory.java 2 Apr 2007 18:25:06 -0000 1.2
@@ -3,7 +3,7 @@
import org.jboss.seam.ScopeType;
import org.jboss.seam.wiki.core.model.Role;
import org.jboss.seam.wiki.core.model.User;
-import org.jboss.seam.wiki.core.model.GlobalPreferences;
+import org.jboss.seam.wiki.core.action.prefs.UserManagementPreferences;
import org.jboss.seam.annotations.*;
import javax.persistence.EntityManager;
@@ -24,7 +24,7 @@
EntityManager entityManager;
@In
- private GlobalPreferences globalPrefs;
+ private UserManagementPreferences userManagementPreferences;
@Factory(value = "guestUser", scope = ScopeType.SESSION)
public User getGuestUser() {
@@ -96,10 +96,10 @@
try {
entityManager.joinTransaction();
return (Role) entityManager
- .createQuery("select r from Role r where r.name = '"+globalPrefs.getNewUserInRole()+"'")
+ .createQuery("select r from Role r where r.name = '"+userManagementPreferences.getNewUserInRole()+"'")
.getSingleResult();
} catch (NoResultException ex) {
- throw new RuntimeException("Configured default role for new users '"+globalPrefs.getNewUserInRole()+"' not found");
+ throw new RuntimeException("Configured default role for new users '"+userManagementPreferences.getNewUserInRole()+"' not found");
}
}
@@ -109,7 +109,7 @@
@Name("rolesList")
@Scope(ScopeType.CONVERSATION)
@AutoCreate
- public static class RoleList {
+ public static class RoleList implements Serializable {
@In
protected EntityManager entityManager;
@@ -154,7 +154,7 @@
@Name("accessLevelsList")
@Scope(ScopeType.CONVERSATION)
@AutoCreate
- public static class AccessLevelsList {
+ public static class AccessLevelsList implements Serializable {
@In
List<Role> rolesList;
@@ -198,7 +198,7 @@
@Name("assignableAccessLevelsList")
@Scope(ScopeType.CONVERSATION)
@AutoCreate
- public static class AssignableAccessLevelsList {
+ public static class AssignableAccessLevelsList implements Serializable {
@In
List<Role.AccessLevel> accessLevelsList;
1.4 +5 -6 jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/WikiNodeFactory.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: WikiNodeFactory.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/wiki/src/main/org/jboss/seam/wiki/core/dao/WikiNodeFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- WikiNodeFactory.java 20 Mar 2007 18:40:33 -0000 1.3
+++ WikiNodeFactory.java 2 Apr 2007 18:25:06 -0000 1.4
@@ -4,8 +4,8 @@
import org.jboss.seam.ScopeType;
import org.jboss.seam.Component;
import org.jboss.seam.wiki.core.model.Directory;
-import org.jboss.seam.wiki.core.model.GlobalPreferences;
import org.jboss.seam.wiki.core.model.Document;
+import org.jboss.seam.wiki.core.action.prefs.WikiPreferences;
import javax.persistence.EntityManager;
import javax.persistence.EntityNotFoundException;
@@ -21,8 +21,6 @@
@In
protected EntityManager restrictedEntityManager;
- @In
- protected GlobalPreferences globalPrefs;
@Factory(value = "wikiRoot", scope = ScopeType.CONVERSATION, autoCreate = true)
@Transactional
@@ -41,15 +39,16 @@
@Transactional
public Document loadWikiStart() {
restrictedEntityManager.joinTransaction();
+ WikiPreferences wikiPreferences = (WikiPreferences) Component.getInstance("wikiPreferences");
try {
return (Document) restrictedEntityManager
.createQuery("select d from Document d where d.id = :id")
- .setParameter("id", globalPrefs.getDefaultDocumentId())
+ .setParameter("id", wikiPreferences.getDefaultDocumentId())
.getSingleResult();
} catch (EntityNotFoundException ex) {
} catch (NoResultException ex) {
}
- throw new RuntimeException("Couldn't find default document with id '" + globalPrefs.getDefaultDocumentId() +"'");
+ throw new RuntimeException("Couldn't find default document with id '" + wikiPreferences.getDefaultDocumentId() +"'");
}
// Loads the same instance into a different persistence context
@@ -64,7 +63,7 @@
@Factory(value = "memberArea", scope = ScopeType.CONVERSATION, autoCreate = true)
@Transactional
public Directory loadMemberArea() {
- Long memberAreaId = ((GlobalPreferences)Component.getInstance("globalPrefs")).getMemberAreaId();
+ Long memberAreaId = ((WikiPreferences)Component.getInstance("wikiPreferences")).getMemberAreaId();
entityManager.joinTransaction();
try {
return (Directory) entityManager
More information about the jboss-cvs-commits
mailing list