• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

how to disable cache, or refresh cache

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,
I'm running version 2.1.7 of JForum and i'm integrating it with an existing webapp. From the existing app i'm making calls to the JForum database to enable users to create Forums. Things run well except that once the user adds the forum and navigates to the main forum list page, the new forum does not appear. My assumption is that it has not been added to the forumRepository cache,( if i restart server it then appears) but i'm not sure how to add it properly. Is there a definitive way to disable the cash or refresh the cache remotely? Any help will be very greatly appreciated.
[originally posted on jforum.net by cordeiro12]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's possible, but not easy. Basically, you need to look at the admin action code that you are trying to automate. This will point you to the cache repository calls that need to be made.

Then you need to figure out how to make these calls in the jforum webapp since thats where the cache repository is located.

This can be done a variety of ways. I've done it with cross-context calls using the requestDispatcher. Another way would be to add a servlet to do what you needed and have the remote app do an internal call to it (URL.getContent() call).
[originally posted on jforum.net by monroe]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the quick reply Monroe,

I have actually placed a servlet into JForum and have been calling it from my App. In it i make calls to the addForum method referenced in the view.admin.ForumAction.insertSave method. I keep getting an error though, specifically:

"java.lang.NullPointerException at net.jforum.repository.ForumRepository.addForum(ForumRepository.java:451)"


which is in :

"public synchronized static void addForum(Forum forum)
{
String categoryId = Integer.toString(forum.getCategoryId());
line 451 Category c = (Category)cache.get(FQN, categoryId);
c.addForum(forum);
cache.add(FQN, categoryId, c);

Map m = (Map)cache.get(FQN, RELATION);
m.put(Integer.toString(forum.getId()), categoryId);
cache.add(FQN, RELATION, m);

Set s = (Set)cache.get(FQN, CATEGORIES_SET);
cache.add(FQN, CATEGORIES_SET, s);
}
"

I've created the forum object in my servlet, and i know the categoryID is returning the proper number. FQN seems
to just be a static string , what am i missing?

[originally posted on jforum.net by cordeiro12]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There's a few things you may need to look at. First, for some of the Repository calls, you will need to make sure that your session has an authorized user information defined. Here's a snippet of my code that I used to do this (the call is being made by an "admin" user from my webapp which is an "admin" in the jForum webapp.



Then to create a new forum, I do the following:



To update an existing forum



And finally, to delete a forum:



One thing to note, is the setForumRights call that's in a couple of places. I'd post the code for that here but it's very specific to my needs and wouldn't be too clear to anyone else. Basically, you will need to make sure that the required groups have rights to the forum and that the following is called once you have updated the info:


[originally posted on jforum.net by monroe]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks again Monroe for you quick response, but there are still issues.
First i notice that although in your code you have



When i look at the JForum source there exists no setRequest or setResponse method for the JForumExecutionContext class. At least in my version, 2.1.7.
But in addition to this is another issue. For our app we are using SSO so that we need only log in once at our apps authentication module and then users are passed directly into JForum (This is working great btw). From what i understand about what you've outlined, the user would have to be an administrator to be able to execute the commands you've given, since they include adding the Forum, but we do not wish to give the users admin priviliges. This is why i have been gathering the forum data in our app and then accessing the Jforum database directly to insert all of the appropriate info/permissions/etc.
So to try and clarify, this is our goal:
- User logs in to our app, which creates appropriate SSO cookie for JForum use (keeping in mind we do not want users to be admins)(works well)
- User goes to OUR forum creation page, which in the backend is adding all the data directly to the jforum database (works well)
- the missing piece is just adding the forum to the cache or forcing a cache refresh (or even just plain disable all caching)

is this possible? have i misunderstood your post in some way? Much thanks again for taking the time to help out.

[originally posted on jforum.net by cordeiro12]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

cordeiro12 wrote:
When i look at the JForum source there exists no setRequest or setResponse method for the JForumExecutionContext class. At least in my version, 2.1.7.



Sorry, I cut and pasted out from my production code which is still at 2.1.6. To see the new syntax, see the service method of the net.jforum.JForum class.

cordeiro12 wrote:
But in addition to this is another issue. For our app we are using SSO so that we need only log in once at our apps authentication module and then users are passed directly into JForum (This is working great btw). From what i understand about what you've outlined, the user would have to be an administrator to be able to execute the commands you've given, since they include adding the Forum, but we do not wish to give the users admin priviliges. This is why i have been gathering the forum data in our app and then accessing the Jforum database directly to insert all of the appropriate info/permissions/etc.

So to try and clarify, this is our goal:
- User logs in to our app, which creates appropriate SSO cookie for JForum use (keeping in mind we do not want users to be admins)(works well)
- User goes to OUR forum creation page, which in the backend is adding all the data directly to the jforum database (works well)
- the missing piece is just adding the forum to the cache or forcing a cache refresh (or even just plain disable all caching)

is this possible? have i misunderstood your post in some way? Much thanks again for taking the time to help out.



If I remember right, the issue is that some (but not all) of the ForumRepository methods make subcalls to Classes that do security right check. I know I when I first started doing this, I had no security issues and then on a later one I started getting errors that where security related. That's when I went back and add the code to make sure the User info was correct on the call. You might be able to do what you want to do without running up against the security issues.

An alternative to meet your needs might be to do a temporary "id swap" by saving the current user's UserSession info from the SessionFacade, modifying it so it contains an "admin" user's info. Make the calls to update the Repository and then restoring the original user after you're done.

Another possibility to check out is that if you're using cross context calls, I seem to remember that the actual session you get when a request.getSession() call is made, is the Calling session. (At least with Tomcat 5.5..). In this case, setting up an Admin SessionFacade (and resetting it after the call) would not effect a users JForum SessionFacade setting (different session). Just beware that the standard is very vague on what the getSession() method should return in this case.
[originally posted on jforum.net by monroe]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your help Monroe, its all working now
[originally posted on jforum.net by cordeiro12]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Monroe,

Does current JForum 217 support clustering at web server mid-tier level? In another words, if we deploy JForum in a clustered environment (session replication enabled among multiple application server instances), will Cachable stuffs (FormRepository, SecurityRepository, etc.) be replicated automatically along with session? If not, can you provide some instructions or guidelines on this?


Thank you very much!

John
[originally posted on jforum.net by jforum217]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I haven't done a lot of cluster code recently but I'll take a whack at this...

The default cache repositories all use Static class variables for a single point of storage at the web application instance class loader level. Even if your environment will automatically sync such classes, there will be problems because the data in these can be updated in multiple loaders...e.g., a user in Cluster JVM A adds a post which gets added to JVM A's static repository. JVM B has a user who posts something at the same time so JVM B's respository is updated. You can't just copy these objects between JVM's they need to be synced.

Most clustering environment supply some sort of mechanism to do things like this. Generally some sort of event notification across cluster nodes. So, to make a caching repository work in a clustered environment you have two choices. Write a Repository implementation that uses you're specific cluster environment's mechanism or write one that eliminates or minimizes the caching. E.g., just always make SQL calls or add in a short term "freshness" dating mechanism that reloads the cache automatically.

There may be other options as I'm not up on the current state of clustering.
[originally posted on jforum.net by monroe]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for your advice, Monroe. They make a whole lot sense.

Really appreciate it,
John
[originally posted on jforum.net by jforum217]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic