• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

User complete Deletion and cache

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,
i'm working to adapt Jforum my needed and i have implemented in Jforum other stats and in particular one function that permit to complete delete a user and all about him like posts, topics privmsgs and so on.
I see that the deletion work fine, but i have a problem that is much probable is caused by the cache.
When i delete definitively the User, after i go take a look in the forum and i see that every topic in which there was a post wrote by the user deleted, is not shown. Only when i re-deploy Jforum i see correctly the topic and the posts.
What you think about?
...there is a method to force the cache re-init?
...i have tried to disable the cache in jforum-custom.conf but not solve nothing

Thank a lot for your help
[originally posted on jforum.net by fscanu]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Afaik, the only way to rebuild the topics listing cache is to restart the jForum webapp (which re-deploying does). Most Application server have tools that allow you to restart just a specific webapp and not any others. E.g., Tomcat's manager application (/manager/html) allows you to do this.
[originally posted on jforum.net by monroe]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you a lot for the reply,
i have solved in another way i don't now if is much clean but work much well!"
So i have used the same method that is used in Jforum to delete and update statistics, and i have taken from there what i need, in particular i have create this method:



public void postDeletion(int postId, int forumId, int userId) {

UserDAO um = DataAccessDriver.getInstance().newUserDAO();
User u = um.selectById(userId);
// Post
PostDAO pm = DataAccessDriver.getInstance().newPostDAO();
Post p = pm.selectById(postId);

if (p.getId() == 0) {
return;
}

TopicDAO tm = DataAccessDriver.getInstance().newTopicDAO();
Topic t = TopicRepository.getTopic(new Topic(p.getTopicId()));

if (t == null) {
t = tm.selectRaw(p.getTopicId());
}

if (!TopicsCommon.isTopicAccessible(t.getForumId())) {
return;
}

pm.delete(p);
DataAccessDriver.getInstance().newUserDAO().decrementPosts(p.getUserId());

// Karma
KarmaDAO karmaDao = DataAccessDriver.getInstance().newKarmaDAO();
karmaDao.updateUserKarma(p.getUserId());

// It was the last remaining post in the topic?
int totalPosts = tm.getTotalPosts(p.getTopicId());

if (totalPosts > 0) {
// Topic
tm.decrementTotalReplies(p.getTopicId());

int maxPostId = tm.getMaxPostId(p.getTopicId());
if (maxPostId > -1) {
tm.setLastPostId(p.getTopicId(), maxPostId);
}

int minPostId = tm.getMinPostId(p.getTopicId());
if (minPostId > -1) {
tm.setFirstPostId(p.getTopicId(), minPostId);
}

// Forum
ForumDAO fm = DataAccessDriver.getInstance().newForumDAO();

maxPostId = fm.getMaxPostId(p.getForumId());
if (maxPostId > -1) {
fm.setLastPost(p.getForumId(), maxPostId);
}
}

PostRepository.remove(t.getId(), p.getId());
TopicRepository.loadMostRecentTopics();
ForumRepository.reloadForum(p.getForumId());

TopicRepository.clearCache(p.getForumId());
PostRepository.clearCache(t.getId());
ForumRepository.updateForumStats(t,u,p);
}

Thank you a lot, if can be useful i can post all the Complete deletion method,
best regards Federico
[originally posted on jforum.net by fscanu]
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!