You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by sn...@apache.org on 2007/06/03 22:18:33 UTC
svn commit: r543978 [3/8] - in /roller/branches/roller_guice/apps/weblogger:
src/java/org/apache/roller/weblogger/
src/java/org/apache/roller/weblogger/business/
src/java/org/apache/roller/weblogger/business/hibernate/
src/java/org/apache/roller/weblog...
Modified: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateUserManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateUserManagerImpl.java?view=diff&rev=543978&r1=543977&r2=543978
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateUserManagerImpl.java (original)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateUserManagerImpl.java Sun Jun 3 13:18:24 2007
@@ -20,7 +20,6 @@
import java.util.ArrayList;
import java.util.Date;
-import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
@@ -38,12 +37,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.criterion.SimpleExpression;
-import org.apache.roller.RollerException;
+import org.apache.roller.weblogger.WebloggerException;
import org.apache.roller.weblogger.config.RollerConfig;
import org.apache.roller.weblogger.business.pings.AutoPingManager;
import org.apache.roller.weblogger.business.BookmarkManager;
+import org.apache.roller.weblogger.business.Roller;
import org.apache.roller.weblogger.business.pings.PingTargetManager;
-import org.apache.roller.weblogger.business.RollerFactory;
import org.apache.roller.weblogger.business.UserManager;
import org.apache.roller.weblogger.business.WeblogManager;
import org.apache.roller.weblogger.pojos.AutoPing;
@@ -66,35 +65,37 @@
/**
* Hibernate implementation of the UserManager.
- */
+ */
public class HibernateUserManagerImpl implements UserManager {
static final long serialVersionUID = -5128460637997081121L;
private static Log log = LogFactory.getLog(HibernateUserManagerImpl.class);
private HibernatePersistenceStrategy strategy = null;
+ private Roller roller;
// cached mapping of weblogHandles -> weblogIds
private Map weblogHandleToIdMap = new Hashtable();
// cached mapping of userNames -> userIds
private Map userNameToIdMap = new Hashtable();
-
- public HibernateUserManagerImpl(HibernatePersistenceStrategy strat) {
+
+ @com.google.inject.Inject
+ public HibernateUserManagerImpl(Roller roller, HibernatePersistenceStrategy strat) {
log.debug("Instantiating Hibernate User Manager");
-
+ this.roller = roller;
this.strategy = strat;
}
/**
* Update existing website.
*/
- public void saveWebsite(Weblog website) throws RollerException {
+ public void saveWebsite(Weblog website) throws WebloggerException {
website.setLastModified(new java.util.Date());
strategy.store(website);
}
- public void removeWebsite(Weblog weblog) throws RollerException {
+ public void removeWebsite(Weblog weblog) throws WebloggerException {
// remove contents first, then remove website
this.removeWebsiteContents(weblog);
@@ -109,12 +110,12 @@
* TODO BACKEND: use manager methods instead of queries here
*/
private void removeWebsiteContents(Weblog website)
- throws HibernateException, RollerException {
+ throws HibernateException, WebloggerException {
Session session = this.strategy.getSession();
- BookmarkManager bmgr = RollerFactory.getRoller().getBookmarkManager();
- WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
+ BookmarkManager bmgr = roller.getBookmarkManager();
+ WeblogManager wmgr = roller.getWeblogManager();
// remove tags
Criteria tagQuery = session.createCriteria(WeblogEntryTag.class)
@@ -147,7 +148,7 @@
List queueEntries = criteria.list();
// Remove the website's auto ping configurations
- AutoPingManager autoPingMgr = RollerFactory.getRoller().getAutopingManager();
+ AutoPingManager autoPingMgr = roller.getAutopingManager();
List autopings = autoPingMgr.getAutoPingsByWebsite(website);
Iterator it = autopings.iterator();
while(it.hasNext()) {
@@ -155,7 +156,7 @@
}
// Remove the website's custom ping targets
- PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
+ PingTargetManager pingTargetMgr = roller.getPingTargetManager();
List pingtargets = pingTargetMgr.getCustomPingTargets(website);
it = pingtargets.iterator();
while(it.hasNext()) {
@@ -207,22 +208,22 @@
}
}
- public void saveUser(User data) throws RollerException {
+ public void saveUser(User data) throws WebloggerException {
this.strategy.store(data);
}
- public void removeUser(User user) throws RollerException {
+ public void removeUser(User user) throws WebloggerException {
this.strategy.remove(user);
// remove entry from cache mapping
this.userNameToIdMap.remove(user.getUserName());
}
- public void savePermissions(WeblogPermission perms) throws RollerException {
+ public void savePermissions(WeblogPermission perms) throws WebloggerException {
this.strategy.store(perms);
}
- public void removePermissions(WeblogPermission perms) throws RollerException {
+ public void removePermissions(WeblogPermission perms) throws WebloggerException {
// make sure associations are broken
perms.getWebsite().getPermissions().remove(perms);
@@ -234,24 +235,24 @@
/**
* @see org.apache.roller.weblogger.model.UserManager#storePage(org.apache.roller.weblogger.pojos.WeblogTemplate)
*/
- public void savePage(WeblogTemplate page) throws RollerException {
+ public void savePage(WeblogTemplate page) throws WebloggerException {
this.strategy.store(page);
// update weblog last modified date. date updated by saveWebsite()
- RollerFactory.getRoller().getUserManager().saveWebsite(page.getWebsite());
+ roller.getUserManager().saveWebsite(page.getWebsite());
}
- public void removePage(WeblogTemplate page) throws RollerException {
+ public void removePage(WeblogTemplate page) throws WebloggerException {
this.strategy.remove(page);
// update weblog last modified date. date updated by saveWebsite()
- RollerFactory.getRoller().getUserManager().saveWebsite(page.getWebsite());
+ roller.getUserManager().saveWebsite(page.getWebsite());
}
- public void addUser(User newUser) throws RollerException {
+ public void addUser(User newUser) throws WebloggerException {
if(newUser == null)
- throw new RollerException("cannot add null user");
+ throw new WebloggerException("cannot add null user");
// TODO BACKEND: we must do this in a better fashion, like getUserCnt()?
boolean adminUser = false;
@@ -263,7 +264,7 @@
if(getUserByUserName(newUser.getUserName()) != null ||
getUserByUserName(newUser.getUserName().toLowerCase()) != null) {
- throw new RollerException("error.add.user.userNameInUse");
+ throw new WebloggerException("error.add.user.userNameInUse");
}
newUser.grantRole("editor");
@@ -279,16 +280,16 @@
this.strategy.store(newUser);
}
- public void addWebsite(Weblog newWeblog) throws RollerException {
+ public void addWebsite(Weblog newWeblog) throws WebloggerException {
this.strategy.store(newWeblog);
this.addWeblogContents(newWeblog);
}
- private void addWeblogContents(Weblog newWeblog) throws RollerException {
+ private void addWeblogContents(Weblog newWeblog) throws WebloggerException {
- UserManager umgr = RollerFactory.getRoller().getUserManager();
- WeblogManager wmgr = RollerFactory.getRoller().getWeblogManager();
+ UserManager umgr = roller.getUserManager();
+ WeblogManager wmgr = roller.getWeblogManager();
// grant weblog creator ADMIN permissions
WeblogPermission perms = new WeblogPermission();
@@ -358,8 +359,8 @@
}
// add any auto enabled ping targets
- PingTargetManager pingTargetMgr = RollerFactory.getRoller().getPingTargetManager();
- AutoPingManager autoPingMgr = RollerFactory.getRoller().getAutopingManager();
+ PingTargetManager pingTargetMgr = roller.getPingTargetManager();
+ AutoPingManager autoPingMgr = roller.getAutopingManager();
Iterator pingTargets = pingTargetMgr.getCommonPingTargets().iterator();
PingTarget pingTarget = null;
@@ -378,10 +379,10 @@
* TODO BACKEND: do we really need this? can't we just use storePermissions()?
*/
public WeblogPermission inviteUser(Weblog website,
- User user, short mask) throws RollerException {
+ User user, short mask) throws WebloggerException {
- if (website == null) throw new RollerException("Website cannot be null");
- if (user == null) throw new RollerException("User cannot be null");
+ if (website == null) throw new WebloggerException("Website cannot be null");
+ if (user == null) throw new WebloggerException("User cannot be null");
WeblogPermission perms = new WeblogPermission();
perms.setWebsite(website);
@@ -401,10 +402,10 @@
*
* TODO: replace this with a domain model method like weblog.retireUser(user)
*/
- public void retireUser(Weblog website, User user) throws RollerException {
+ public void retireUser(Weblog website, User user) throws WebloggerException {
- if (website == null) throw new RollerException("Website cannot be null");
- if (user == null) throw new RollerException("User cannot be null");
+ if (website == null) throw new WebloggerException("Website cannot be null");
+ if (user == null) throw new WebloggerException("User cannot be null");
Iterator perms = website.getPermissions().iterator();
WeblogPermission target = null;
@@ -415,17 +416,17 @@
break;
}
}
- if (target == null) throw new RollerException("User not member of website");
+ if (target == null) throw new WebloggerException("User not member of website");
website.removePermission(target);
this.strategy.remove(target);
}
- public Weblog getWebsite(String id) throws RollerException {
+ public Weblog getWebsite(String id) throws WebloggerException {
return (Weblog) this.strategy.load(id,Weblog.class);
}
- public Weblog getWebsiteByHandle(String handle) throws RollerException {
+ public Weblog getWebsiteByHandle(String handle) throws WebloggerException {
return getWebsiteByHandle(handle, Boolean.TRUE);
}
@@ -433,10 +434,10 @@
* Return website specified by handle.
*/
public Weblog getWebsiteByHandle(String handle, Boolean enabled)
- throws RollerException {
+ throws WebloggerException {
if (handle==null )
- throw new RollerException("Handle cannot be null");
+ throw new WebloggerException("Handle cannot be null");
// check cache first
// NOTE: if we ever allow changing handles then this needs updating
@@ -478,7 +479,7 @@
}
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
@@ -487,7 +488,7 @@
*/
public List getWebsites(User user, Boolean enabled, Boolean active,
Date startDate, Date endDate, int offset, int length)
- throws RollerException {
+ throws WebloggerException {
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -521,23 +522,23 @@
return criteria.list();
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
- public User getUser(String id) throws RollerException {
+ public User getUser(String id) throws WebloggerException {
return (User)this.strategy.load(id,User.class);
}
- public User getUserByUserName(String userName) throws RollerException {
+ public User getUserByUserName(String userName) throws WebloggerException {
return getUserByUserName(userName, Boolean.TRUE);
}
public User getUserByUserName(String userName, Boolean enabled)
- throws RollerException {
+ throws WebloggerException {
if (userName==null )
- throw new RollerException("userName cannot be null");
+ throw new WebloggerException("userName cannot be null");
// check cache first
// NOTE: if we ever allow changing usernames then this needs updating
@@ -582,14 +583,14 @@
return user;
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
public List getUsers(Weblog weblog, Boolean enabled, Date startDate,
Date endDate, int offset, int length)
- throws RollerException {
+ throws WebloggerException {
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -626,13 +627,13 @@
return criteria.list();
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
public List getUsersStartingWith(String startsWith, Boolean enabled,
- int offset, int length) throws RollerException {
+ int offset, int length) throws WebloggerException {
List results = new ArrayList();
try {
@@ -655,12 +656,12 @@
}
results = criteria.list();
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
return results;
}
- public WeblogTemplate getPage(String id) throws RollerException {
+ public WeblogTemplate getPage(String id) throws WebloggerException {
// Don't hit database for templates stored on disk
if (id != null && id.endsWith(".vm")) return null;
@@ -671,13 +672,13 @@
* Use Hibernate directly because Roller's Query API does too much allocation.
*/
public WeblogTemplate getPageByLink(Weblog website, String pagelink)
- throws RollerException {
+ throws WebloggerException {
if (website == null)
- throw new RollerException("userName is null");
+ throw new WebloggerException("userName is null");
if (pagelink == null)
- throw new RollerException("Pagelink is null");
+ throw new WebloggerException("Pagelink is null");
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -687,7 +688,7 @@
return (WeblogTemplate) criteria.uniqueResult();
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
@@ -696,13 +697,13 @@
* @see org.apache.roller.weblogger.model.UserManager#getPageByAction(WebsiteData, java.lang.String)
*/
public WeblogTemplate getPageByAction(Weblog website, String action)
- throws RollerException {
+ throws WebloggerException {
if (website == null)
- throw new RollerException("website is null");
+ throw new WebloggerException("website is null");
if (action == null)
- throw new RollerException("Action name is null");
+ throw new WebloggerException("Action name is null");
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -712,7 +713,7 @@
return (WeblogTemplate) criteria.uniqueResult();
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
@@ -721,13 +722,13 @@
* @see org.apache.roller.weblogger.model.UserManager#getPageByName(WebsiteData, java.lang.String)
*/
public WeblogTemplate getPageByName(Weblog website, String pagename)
- throws RollerException {
+ throws WebloggerException {
if (website == null)
- throw new RollerException("website is null");
+ throw new WebloggerException("website is null");
if (pagename == null)
- throw new RollerException("Page name is null");
+ throw new WebloggerException("Page name is null");
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -737,17 +738,17 @@
return (WeblogTemplate) criteria.uniqueResult();
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
/**
* @see org.apache.roller.weblogger.model.UserManager#getPages(WebsiteData)
*/
- public List getPages(Weblog website) throws RollerException {
+ public List getPages(Weblog website) throws WebloggerException {
if (website == null)
- throw new RollerException("website is null");
+ throw new WebloggerException("website is null");
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -757,11 +758,11 @@
return criteria.list();
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
- public WeblogPermission getPermissions(String inviteId) throws RollerException {
+ public WeblogPermission getPermissions(String inviteId) throws WebloggerException {
return (WeblogPermission)this.strategy.load(inviteId,WeblogPermission.class);
}
@@ -769,7 +770,7 @@
* Return permissions for specified user in website
*/
public WeblogPermission getPermissions(
- Weblog website, User user) throws RollerException {
+ Weblog website, User user) throws WebloggerException {
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -780,14 +781,14 @@
List list = criteria.list();
return list.size()!=0 ? (WeblogPermission)list.get(0) : null;
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
/**
* Get pending permissions for user
*/
- public List getPendingPermissions(User user) throws RollerException {
+ public List getPendingPermissions(User user) throws WebloggerException {
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -797,14 +798,14 @@
return criteria.list();
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
/**
* Get pending permissions for website
*/
- public List getPendingPermissions(Weblog website) throws RollerException {
+ public List getPendingPermissions(Weblog website) throws WebloggerException {
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -814,14 +815,14 @@
return criteria.list();
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
/**
* Get all permissions of a website (pendings not including)
*/
- public List getAllPermissions(Weblog website) throws RollerException {
+ public List getAllPermissions(Weblog website) throws WebloggerException {
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -831,14 +832,14 @@
return criteria.list();
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
/**
* Get all permissions of a user.
*/
- public List getAllPermissions(User user) throws RollerException {
+ public List getAllPermissions(User user) throws WebloggerException {
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -848,13 +849,13 @@
return criteria.list();
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
public void release() {}
- public Map getUserNameLetterMap() throws RollerException {
+ public Map getUserNameLetterMap() throws WebloggerException {
// TODO: ATLAS getUserNameLetterMap DONE TESTED
String msg = "Getting username letter map";
try {
@@ -872,12 +873,12 @@
return results;
} catch (Throwable pe) {
log.error(msg, pe);
- throw new RollerException(msg, pe);
+ throw new WebloggerException(msg, pe);
}
}
public List getUsersByLetter(char letter, int offset, int length)
- throws RollerException {
+ throws WebloggerException {
// TODO: ATLAS getUsersByLetter DONE
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -892,11 +893,11 @@
}
return criteria.list();
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
- public Map getWeblogHandleLetterMap() throws RollerException {
+ public Map getWeblogHandleLetterMap() throws WebloggerException {
// TODO: ATLAS getWeblogHandleLetterMap DONE
String msg = "Getting weblog letter map";
try {
@@ -914,12 +915,12 @@
return results;
} catch (Throwable pe) {
log.error(msg, pe);
- throw new RollerException(msg, pe);
+ throw new WebloggerException(msg, pe);
}
}
public List getWeblogsByLetter(char letter, int offset, int length)
- throws RollerException {
+ throws WebloggerException {
// TODO: ATLAS getWeblogsByLetter DONE
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -934,12 +935,12 @@
}
return criteria.list();
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
public List getMostCommentedWebsites(Date startDate, Date endDate, int offset, int length)
- throws RollerException {
+ throws WebloggerException {
// TODO: ATLAS getMostCommentedWebsites DONE TESTED
String msg = "Getting most commented websites";
if (endDate == null) endDate = new Date();
@@ -979,7 +980,7 @@
return results;
} catch (Throwable pe) {
log.error(msg, pe);
- throw new RollerException(msg, pe);
+ throw new WebloggerException(msg, pe);
}
}
@@ -987,7 +988,7 @@
/**
* Get count of weblogs, active and inactive
*/
- public long getWeblogCount() throws RollerException {
+ public long getWeblogCount() throws WebloggerException {
long ret = 0;
try {
Session session = ((HibernatePersistenceStrategy)strategy).getSession();
@@ -995,12 +996,12 @@
List result = session.createQuery(query).list();
ret = ((Number)result.get(0)).intValue();
} catch (Exception e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
return ret;
}
- public void revokeRole(String roleName, User user) throws RollerException {
+ public void revokeRole(String roleName, User user) throws WebloggerException {
UserRole removeme = null;
Collection roles = user.getRoles();
Iterator iter = roles.iterator();
@@ -1018,7 +1019,7 @@
/**
* Get count of users, enabled only
*/
- public long getUserCount() throws RollerException {
+ public long getUserCount() throws WebloggerException {
long ret = 0;
try {
Session session = ((HibernatePersistenceStrategy)strategy).getSession();
@@ -1026,7 +1027,7 @@
List result = session.createQuery(query).list();
ret = ((Number)result.get(0)).intValue();
} catch (Exception e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
return ret;
}
@@ -1040,10 +1041,10 @@
}
- public User getUserByActivationCode(String activationCode) throws RollerException {
+ public User getUserByActivationCode(String activationCode) throws WebloggerException {
if (activationCode == null)
- throw new RollerException("activationcode is null");
+ throw new WebloggerException("activationcode is null");
try {
Session session = ((HibernatePersistenceStrategy) this.strategy)
@@ -1056,7 +1057,7 @@
return user;
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
}
Modified: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateWeblogManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateWeblogManagerImpl.java?view=diff&rev=543978&r1=543977&r2=543978
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateWeblogManagerImpl.java (original)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/hibernate/HibernateWeblogManagerImpl.java Sun Jun 3 13:18:24 2007
@@ -35,8 +35,8 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.roller.RollerException;
-import org.apache.roller.weblogger.business.RollerFactory;
+import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.Roller;
import org.apache.roller.weblogger.business.WeblogManager;
import org.apache.roller.weblogger.pojos.WeblogEntryComment;
import org.apache.roller.weblogger.pojos.WeblogHitCount;
@@ -72,6 +72,7 @@
private static Log log = LogFactory.getLog(HibernateWeblogManagerImpl.class);
private HibernatePersistenceStrategy strategy = null;
+ private Roller roller;
// cached mapping of entryAnchors -> entryIds
private Hashtable entryAnchorToIdMap = new Hashtable();
@@ -81,30 +82,31 @@
private Comparator tagStatComparator = new TagStatComparator();
- public HibernateWeblogManagerImpl(HibernatePersistenceStrategy strat) {
+ @com.google.inject.Inject
+ public HibernateWeblogManagerImpl(Roller roller, HibernatePersistenceStrategy strat) {
log.debug("Instantiating Hibernate Weblog Manager");
-
+ this.roller = roller;
this.strategy = strat;
}
- public void saveWeblogCategory(WeblogCategory cat) throws RollerException {
+ public void saveWeblogCategory(WeblogCategory cat) throws WebloggerException {
if(cat == null) {
throw new IllegalArgumentException("Category is null");
}
// update weblog last modified date. date updated by saveWebsite()
- RollerFactory.getRoller().getUserManager().saveWebsite(cat.getWebsite());
+ roller.getUserManager().saveWebsite(cat.getWebsite());
this.strategy.store(cat);
}
- public void removeWeblogCategory(WeblogCategory cat) throws RollerException {
+ public void removeWeblogCategory(WeblogCategory cat) throws WebloggerException {
if(cat.retrieveWeblogEntries(true).size() > 0) {
- throw new RollerException("Cannot remove category with entries");
+ throw new WebloggerException("Cannot remove category with entries");
}
// remove cat
@@ -124,16 +126,16 @@
}
// update weblog last modified date. date updated by saveWebsite()
- RollerFactory.getRoller().getUserManager().saveWebsite(cat.getWebsite());
+ roller.getUserManager().saveWebsite(cat.getWebsite());
}
public void moveWeblogCategory(WeblogCategory srcCat, WeblogCategory destCat)
- throws RollerException {
+ throws WebloggerException {
// TODO: this check should be made before calling this method?
if (destCat.descendentOf(srcCat)) {
- throw new RollerException(
+ throw new WebloggerException(
"ERROR cannot move parent category into it's own child");
}
@@ -154,11 +156,11 @@
public void moveWeblogCategoryContents(WeblogCategory srcCat, WeblogCategory destCat)
- throws RollerException {
+ throws WebloggerException {
// TODO: this check should be made before calling this method?
if (destCat.descendentOf(srcCat)) {
- throw new RollerException(
+ throw new WebloggerException(
"ERROR cannot move parent category into it's own child");
}
@@ -192,24 +194,24 @@
}
- public void saveComment(WeblogEntryComment comment) throws RollerException {
+ public void saveComment(WeblogEntryComment comment) throws WebloggerException {
this.strategy.store(comment);
// update weblog last modified date. date updated by saveWebsite()
- RollerFactory.getRoller().getUserManager().saveWebsite(comment.getWeblogEntry().getWebsite());
+ roller.getUserManager().saveWebsite(comment.getWeblogEntry().getWebsite());
}
- public void removeComment(WeblogEntryComment comment) throws RollerException {
+ public void removeComment(WeblogEntryComment comment) throws WebloggerException {
this.strategy.remove(comment);
// update weblog last modified date. date updated by saveWebsite()
- RollerFactory.getRoller().getUserManager().saveWebsite(comment.getWeblogEntry().getWebsite());
+ roller.getUserManager().saveWebsite(comment.getWeblogEntry().getWebsite());
}
// TODO: perhaps the createAnchor() and queuePings() items should go outside this method?
- public void saveWeblogEntry(WeblogEntry entry) throws RollerException {
+ public void saveWeblogEntry(WeblogEntry entry) throws WebloggerException {
if (entry.getAnchor() == null || entry.getAnchor().trim().equals("")) {
entry.setAnchor(this.createAnchor(entry));
@@ -240,17 +242,17 @@
// update weblog last modified date. date updated by saveWebsite()
if(entry.isPublished()) {
- RollerFactory.getRoller().getUserManager().saveWebsite(entry.getWebsite());
+ roller.getUserManager().saveWebsite(entry.getWebsite());
}
if(entry.isPublished()) {
// Queue applicable pings for this update.
- RollerFactory.getRoller().getAutopingManager().queueApplicableAutoPings(entry);
+ roller.getAutopingManager().queueApplicableAutoPings(entry);
}
}
- public void removeWeblogEntry(WeblogEntry entry) throws RollerException {
+ public void removeWeblogEntry(WeblogEntry entry) throws WebloggerException {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -292,7 +294,7 @@
// update weblog last modified date. date updated by saveWebsite()
if(entry.isPublished()) {
- RollerFactory.getRoller().getUserManager().saveWebsite(entry.getWebsite());
+ roller.getUserManager().saveWebsite(entry.getWebsite());
}
// remove entry from cache mapping
@@ -300,7 +302,7 @@
}
public void removeWeblogEntryAttribute(String name,WeblogEntry entry)
- throws RollerException {
+ throws WebloggerException {
for (Iterator it = entry.getEntryAttributes().iterator(); it.hasNext();) {
WeblogEntryAttribute entryAttribute = (WeblogEntryAttribute) it.next();
if (entryAttribute.getName().equals(name)) {
@@ -315,7 +317,7 @@
}
public void removeWeblogEntryTag(String name,WeblogEntry entry)
- throws RollerException {
+ throws WebloggerException {
for (Iterator it = entry.getTags().iterator(); it.hasNext();) {
WeblogEntryTag tag = (WeblogEntryTag) it.next();
if (tag.getName().equals(name)) {
@@ -331,7 +333,7 @@
public List getNextPrevEntries(WeblogEntry current, String catName,
String locale, int maxEntries, boolean next)
- throws RollerException {
+ throws WebloggerException {
Junction conjunction = Expression.conjunction();
conjunction.add(Expression.eq("website", current.getWebsite()));
@@ -349,7 +351,7 @@
if (category != null) {
conjunction.add(Expression.eq("category", category));
} else {
- throw new RollerException("Cannot find category: "+catName);
+ throw new WebloggerException("Cannot find category: "+catName);
}
}
@@ -366,14 +368,14 @@
List results = criteria.list();
return results;
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
public WeblogCategory getRootWeblogCategory(Weblog website)
- throws RollerException {
+ throws WebloggerException {
if (website == null)
- throw new RollerException("website is null");
+ throw new WebloggerException("website is null");
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -386,16 +388,16 @@
return (WeblogCategory) criteria.uniqueResult();
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
public List getWeblogCategories(Weblog website, boolean includeRoot)
- throws RollerException {
+ throws WebloggerException {
if (website == null) {
- throw new RollerException("website is null");
+ throw new WebloggerException("website is null");
}
try {
@@ -409,7 +411,7 @@
return criteria.list();
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
@@ -427,7 +429,7 @@
String sortOrder,
String locale,
int offset,
- int length) throws RollerException {
+ int length) throws WebloggerException {
WeblogCategory cat = null;
if (StringUtils.isNotEmpty(catName) && website != null) {
@@ -529,11 +531,11 @@
} catch (HibernateException e) {
log.error(e);
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
- public List getWeblogEntriesPinnedToMain(Integer max) throws RollerException {
+ public List getWeblogEntriesPinnedToMain(Integer max) throws WebloggerException {
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
Criteria criteria = session.createCriteria(WeblogEntry.class);
@@ -546,19 +548,19 @@
return criteria.list();
} catch (HibernateException e) {
log.error(e);
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
public WeblogEntry getWeblogEntryByAnchor(Weblog website, String anchor)
- throws RollerException {
+ throws WebloggerException {
if (website == null)
- throw new RollerException("Website is null");
+ throw new WebloggerException("Website is null");
if (anchor == null)
- throw new RollerException("Anchor is null");
+ throw new WebloggerException("Anchor is null");
// mapping key is combo of weblog + anchor
String mappingKey = website.getHandle()+":"+anchor;
@@ -602,14 +604,14 @@
return entry;
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
// TODO: this method should be removed and it's functionality moved to getWeblogEntries()
public List getWeblogEntries(WeblogCategory cat, boolean subcats)
- throws RollerException {
+ throws WebloggerException {
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -630,12 +632,12 @@
return criteria.list();
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
- public String createAnchor(WeblogEntry entry) throws RollerException {
+ public String createAnchor(WeblogEntry entry) throws WebloggerException {
try {
// Check for uniqueness of anchor
String base = entry.createAnchorBase();
@@ -662,14 +664,14 @@
}
return name;
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
// TODO: provide unit test case
public boolean isDuplicateWeblogCategoryName(WeblogCategory cat)
- throws RollerException {
+ throws WebloggerException {
// ensure that no sibling categories share the same name
WeblogCategory parent = cat.getParent();
@@ -682,7 +684,7 @@
public boolean isWeblogCategoryInUse(WeblogCategory cat)
- throws RollerException {
+ throws WebloggerException {
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
Criteria criteria = session.createCriteria(WeblogEntry.class);
@@ -712,7 +714,7 @@
return false;
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
@@ -728,7 +730,7 @@
int offset,
int length
- ) throws RollerException {
+ ) throws WebloggerException {
try {
Session session = ((HibernatePersistenceStrategy)this.strategy).getSession();
@@ -787,7 +789,7 @@
} catch (HibernateException e) {
log.error(e);
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
@@ -797,7 +799,7 @@
String searchString,
Date startDate,
Date endDate,
- String status) throws RollerException {
+ String status) throws WebloggerException {
try {
List comments = getComments(
@@ -895,13 +897,13 @@
} catch (HibernateException e) {
log.error(e);
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
public WeblogCategory getWeblogCategory(String id)
- throws RollerException {
+ throws WebloggerException {
return (WeblogCategory) this.strategy.load(
id,
WeblogCategory.class);
@@ -911,7 +913,7 @@
public WeblogCategory getWeblogCategoryByPath(Weblog website,
String categoryPath)
- throws RollerException {
+ throws WebloggerException {
if (categoryPath == null || categoryPath.trim().equals("/")) {
return getRootWeblogCategory(website);
@@ -934,12 +936,12 @@
}
- public WeblogEntryComment getComment(String id) throws RollerException {
+ public WeblogEntryComment getComment(String id) throws WebloggerException {
return (WeblogEntryComment) this.strategy.load(id,WeblogEntryComment.class);
}
public WeblogEntry getWeblogEntry(String id)
- throws RollerException {
+ throws WebloggerException {
return (WeblogEntry) this.strategy.load(
id,WeblogEntry.class);
@@ -955,7 +957,7 @@
String status,
String locale,
int offset,
- int length) throws RollerException {
+ int length) throws WebloggerException {
return getWeblogEntryMap(
website,
startDate,
@@ -979,7 +981,7 @@
String locale,
int offset,
int length
- ) throws RollerException {
+ ) throws WebloggerException {
return getWeblogEntryMap(
website,
startDate,
@@ -1005,7 +1007,7 @@
String locale,
int offset,
int length
- ) throws RollerException {
+ ) throws WebloggerException {
TreeMap map = new TreeMap(reverseComparator);
@@ -1050,7 +1052,7 @@
public List getMostCommentedWeblogEntries(
Weblog website, Date startDate, Date endDate, int offset, int length)
- throws RollerException {
+ throws WebloggerException {
// TODO: ATLAS getMostCommentedWeblogEntries DONE
String msg = "Getting most commented weblog entries";
if (endDate == null) endDate = new Date();
@@ -1111,14 +1113,14 @@
return results;
} catch (Throwable pe) {
log.error(msg, pe);
- throw new RollerException(msg, pe);
+ throw new WebloggerException(msg, pe);
}
}
public WeblogEntry getNextEntry(WeblogEntry current, String catName,
String locale)
- throws RollerException {
+ throws WebloggerException {
WeblogEntry entry = null;
List entryList = getNextPrevEntries(current, catName, locale, 1, true);
@@ -1131,7 +1133,7 @@
public WeblogEntry getPreviousEntry(WeblogEntry current, String catName,
String locale)
- throws RollerException {
+ throws WebloggerException {
WeblogEntry entry = null;
List entryList = getNextPrevEntries(current, catName, locale, 1, false);
@@ -1149,7 +1151,7 @@
* all existing entries in a website using a single HQL query.
* @param website Website where comment defaults are from/to be applied.
*/
- public void applyCommentDefaultsToEntries(Weblog website) throws RollerException {
+ public void applyCommentDefaultsToEntries(Weblog website) throws WebloggerException {
if (log.isDebugEnabled()) {
log.debug("applyCommentDefaults");
}
@@ -1173,7 +1175,7 @@
* @see org.apache.roller.weblogger.model.WeblogManager#getPopularTags(org.apache.roller.weblogger.pojos.WebsiteData, java.util.Date, int)
*/
public List getPopularTags(Weblog website, Date startDate, int limit)
- throws RollerException {
+ throws WebloggerException {
try {
Session session = ((HibernatePersistenceStrategy) strategy)
.getSession();
@@ -1237,7 +1239,7 @@
return results;
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
@@ -1247,7 +1249,7 @@
* @see org.apache.roller.weblogger.model.WeblogManager#getTags(org.apache.roller.weblogger.pojos.WebsiteData,
* java.lang.String, java.lang.String, int)
*/
- public List getTags(Weblog website, String sortBy, String startsWith, int limit) throws RollerException {
+ public List getTags(Weblog website, String sortBy, String startsWith, int limit) throws WebloggerException {
try {
List results = new ArrayList();
@@ -1287,7 +1289,7 @@
return results;
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
@@ -1300,7 +1302,7 @@
* miss and we return false.
*/
public boolean getTagComboExists(List tags, Weblog weblog)
- throws RollerException {
+ throws WebloggerException {
boolean comboExists = false;
@@ -1330,24 +1332,24 @@
comboExists = (results != null && results.size() == tags.size());
} catch (HibernateException ex) {
- throw new RollerException(ex);
+ throw new WebloggerException(ex);
}
return comboExists;
}
- public void updateTagCount(String name, Weblog website, int amount) throws RollerException {
+ public void updateTagCount(String name, Weblog website, int amount) throws WebloggerException {
Session session = ((HibernatePersistenceStrategy) strategy)
.getSession();
if(amount == 0) {
- throw new RollerException("Tag increment amount cannot be zero.");
+ throw new WebloggerException("Tag increment amount cannot be zero.");
}
if(website == null) {
- throw new RollerException("Website cannot be NULL.");
+ throw new WebloggerException("Website cannot be NULL.");
}
Junction conjunction = Expression.conjunction();
@@ -1405,7 +1407,7 @@
}
- public WeblogHitCount getHitCount(String id) throws RollerException {
+ public WeblogHitCount getHitCount(String id) throws WebloggerException {
// do lookup
try {
@@ -1417,12 +1419,12 @@
return hitCount;
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
public WeblogHitCount getHitCountByWeblog(Weblog weblog)
- throws RollerException {
+ throws WebloggerException {
// do lookup
try {
@@ -1434,13 +1436,13 @@
return hitCount;
} catch (HibernateException e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
public List getHotWeblogs(int sinceDays, int offset, int length)
- throws RollerException {
+ throws WebloggerException {
// figure out start date
Calendar cal = Calendar.getInstance();
@@ -1469,32 +1471,32 @@
return query.list();
} catch (Throwable pe) {
- throw new RollerException(pe);
+ throw new WebloggerException(pe);
}
}
- public void saveHitCount(WeblogHitCount hitCount) throws RollerException {
+ public void saveHitCount(WeblogHitCount hitCount) throws WebloggerException {
this.strategy.store(hitCount);
}
- public void removeHitCount(WeblogHitCount hitCount) throws RollerException {
+ public void removeHitCount(WeblogHitCount hitCount) throws WebloggerException {
this.strategy.remove(hitCount);
}
public void incrementHitCount(Weblog weblog, int amount)
- throws RollerException {
+ throws WebloggerException {
Session session = ((HibernatePersistenceStrategy) strategy).getSession();
if(amount == 0) {
- throw new RollerException("Tag increment amount cannot be zero.");
+ throw new WebloggerException("Tag increment amount cannot be zero.");
}
if(weblog == null) {
- throw new RollerException("Website cannot be NULL.");
+ throw new WebloggerException("Website cannot be NULL.");
}
Criteria criteria = session.createCriteria(WeblogHitCount.class);
@@ -1516,32 +1518,32 @@
}
- public void resetAllHitCounts() throws RollerException {
+ public void resetAllHitCounts() throws WebloggerException {
try {
Session session = ((HibernatePersistenceStrategy)strategy).getSession();
session.createQuery("update WeblogHitCount set dailyHits = 0").executeUpdate();
} catch (Exception e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
- public void resetHitCount(Weblog weblog) throws RollerException {
+ public void resetHitCount(Weblog weblog) throws WebloggerException {
try {
Session session = ((HibernatePersistenceStrategy)strategy).getSession();
String query = "update WeblogHitCount set dailyHits = 0 where weblog = ?";
session.createQuery(query).setParameter(0, weblog).executeUpdate();
} catch (Exception e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
}
/**
* Get site-wide comment count
*/
- public long getCommentCount() throws RollerException {
+ public long getCommentCount() throws WebloggerException {
return getCommentCount(null);
}
@@ -1549,7 +1551,7 @@
/**
* Get weblog comment count
*/
- public long getCommentCount(Weblog website) throws RollerException {
+ public long getCommentCount(Weblog website) throws WebloggerException {
long ret = 0;
try {
Session session = ((HibernatePersistenceStrategy)strategy).getSession();
@@ -1567,7 +1569,7 @@
List result = query.list();
ret = ((Number)result.get(0)).intValue();
} catch (Exception e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
return ret;
}
@@ -1576,7 +1578,7 @@
/**
* Get site-wide entry count
*/
- public long getEntryCount() throws RollerException {
+ public long getEntryCount() throws WebloggerException {
return getEntryCount(null);
}
@@ -1584,7 +1586,7 @@
/**
* Get weblog entry count
*/
- public long getEntryCount(Weblog website) throws RollerException {
+ public long getEntryCount(Weblog website) throws WebloggerException {
long ret = 0;
try {
Session session = ((HibernatePersistenceStrategy)strategy).getSession();
@@ -1602,7 +1604,7 @@
List result = query.list();
ret = ((Number)result.get(0)).intValue();
} catch (Exception e) {
- throw new RollerException(e);
+ throw new WebloggerException(e);
}
return ret;
}
Modified: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAAutoPingManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAAutoPingManagerImpl.java?view=diff&rev=543978&r1=543977&r2=543978
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAAutoPingManagerImpl.java (original)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAAutoPingManagerImpl.java Sun Jun 3 13:18:24 2007
@@ -20,8 +20,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.roller.RollerException;
-import org.apache.roller.weblogger.business.RollerFactory;
+import org.apache.roller.weblogger.WebloggerException;
import org.apache.roller.weblogger.business.pings.AutoPingManager;
import org.apache.roller.weblogger.business.pings.PingQueueManager;
import org.apache.roller.weblogger.config.PingConfig;
@@ -35,7 +34,8 @@
import java.util.Iterator;
import java.util.List;
import javax.persistence.Query;
-import org.apache.roller.business.jpa.JPAPersistenceStrategy;
+import org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy;
+import org.apache.roller.weblogger.business.Roller;
/*
* JPAAutoPingManagerImpl.java
@@ -46,6 +46,7 @@
public class JPAAutoPingManagerImpl implements AutoPingManager {
private JPAPersistenceStrategy strategy;
+ private Roller roller = null;
/**
* The logger instance for this class.
@@ -56,25 +57,26 @@
/**
* Creates a new instance of JPAAutoPingManagerImpl
*/
- public JPAAutoPingManagerImpl
- (JPAPersistenceStrategy strategy) {
+ @com.google.inject.Inject
+ public JPAAutoPingManagerImpl(Roller roller, JPAPersistenceStrategy strategy) {
+ this.roller = roller;
this.strategy = strategy;
}
- public AutoPing getAutoPing(String id) throws RollerException {
+ public AutoPing getAutoPing(String id) throws WebloggerException {
return (AutoPing)strategy.load(AutoPing.class, id);
}
- public void saveAutoPing(AutoPing autoPing) throws RollerException {
+ public void saveAutoPing(AutoPing autoPing) throws WebloggerException {
strategy.store(autoPing);
}
- public void removeAutoPing(AutoPing autoPing) throws RollerException {
+ public void removeAutoPing(AutoPing autoPing) throws WebloggerException {
strategy.remove(autoPing);
}
public void removeAutoPing(PingTarget pingTarget, Weblog website)
- throws RollerException {
+ throws WebloggerException {
Query q = strategy.getNamedUpdate("AutoPing.removeByPingTarget&Website");
q.setParameter(1, pingTarget);
q.setParameter(2, website);
@@ -82,18 +84,18 @@
}
public void removeAutoPings(Collection autopings)
- throws RollerException {
+ throws WebloggerException {
strategy.removeAll(autopings);
}
public void removeAllAutoPings()
- throws RollerException {
+ throws WebloggerException {
Query q = strategy.getNamedUpdate("AutoPing.getAll");
removeAutoPings(q.getResultList());
}
public void queueApplicableAutoPings(WeblogEntry changedWeblogEntry)
- throws RollerException {
+ throws WebloggerException {
if (PingConfig.getSuspendPingProcessing()) {
if (logger.isDebugEnabled())
logger.debug("Ping processing is suspended." +
@@ -101,7 +103,7 @@
return;
}
- PingQueueManager pingQueueMgr = RollerFactory.getRoller().
+ PingQueueManager pingQueueMgr = roller.
getPingQueueManager();
List applicableAutopings = getApplicableAutoPings(changedWeblogEntry);
for (Iterator i = applicableAutopings.iterator(); i.hasNext(); ) {
@@ -111,28 +113,28 @@
}
public List getAutoPingsByWebsite(Weblog website)
- throws RollerException {
+ throws WebloggerException {
Query q = strategy.getNamedQuery("AutoPing.getByWebsite");
q.setParameter(1, website);
return q.getResultList();
}
public List getAutoPingsByTarget(PingTarget pingTarget)
- throws RollerException {
+ throws WebloggerException {
Query q = strategy.getNamedQuery("AutoPing.getByPingTarget");
q.setParameter(1, pingTarget);
return q.getResultList();
}
public List getApplicableAutoPings(WeblogEntry changedWeblogEntry)
- throws RollerException {
+ throws WebloggerException {
return getAutoPingsByWebsite(changedWeblogEntry.getWebsite());
// return (List)strategy.newQuery(AutoPing.class, "AutoPing.getByWebsite")
// .execute(changedWeblogEntry.getWebsite());
}
public List getCategoryRestrictions(AutoPing autoPing)
- throws RollerException {
+ throws WebloggerException {
return Collections.EMPTY_LIST;
}
Modified: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl.java?view=diff&rev=543978&r1=543977&r2=543978
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl.java (original)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl.java Sun Jun 3 13:18:24 2007
@@ -26,10 +26,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.roller.business.jpa.JPAPersistenceStrategy;
-import org.apache.roller.RollerException;
+import org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy;
+import org.apache.roller.weblogger.WebloggerException;
import org.apache.roller.weblogger.business.BookmarkManager;
-import org.apache.roller.weblogger.business.RollerFactory;
+import org.apache.roller.weblogger.business.Roller;
import org.apache.roller.weblogger.pojos.WeblogBookmark;
import org.apache.roller.weblogger.pojos.WeblogBookmarkFolder;
import org.apache.roller.weblogger.pojos.Weblog;
@@ -46,6 +46,7 @@
public class JPABookmarkManagerImpl implements BookmarkManager {
private JPAPersistenceStrategy strategy;
+ private Roller roller = null;
/**
* The logger instance for this class.
@@ -56,14 +57,14 @@
/**
* Creates a new instance of JPABookmarkManagerImpl
*/
- public JPABookmarkManagerImpl
- (JPAPersistenceStrategy strategy) {
+ @com.google.inject.Inject
+ public JPABookmarkManagerImpl(Roller roller, JPAPersistenceStrategy strategy) {
log.debug("Instantiating JPA Bookmark Manager");
-
+ this.roller = roller;
this.strategy = strategy;
}
- public void saveBookmark(WeblogBookmark bookmark) throws RollerException {
+ public void saveBookmark(WeblogBookmark bookmark) throws WebloggerException {
boolean exists = getBookmark(bookmark.getId()) != null;
if (!exists) {
// New object make sure that relationship is set on managed copy of other side
@@ -73,30 +74,30 @@
this.strategy.store(bookmark);
// update weblog last modified date (date is updated by saveWebsite())
- RollerFactory.getRoller().getUserManager().
+ roller.getUserManager().
saveWebsite(bookmark.getWebsite());
}
- public WeblogBookmark getBookmark(String id) throws RollerException {
+ public WeblogBookmark getBookmark(String id) throws WebloggerException {
return (WeblogBookmark) strategy.load(WeblogBookmark.class, id);
}
- public void removeBookmark(WeblogBookmark bookmark) throws RollerException {
+ public void removeBookmark(WeblogBookmark bookmark) throws WebloggerException {
//Now remove it from database
this.strategy.remove(bookmark);
//Remove the bookmark from its parent folder
bookmark.getFolder().getBookmarks().remove(bookmark);
// update weblog last modified date. date updated by saveWebsite()
- RollerFactory.getRoller().getUserManager()
+ roller.getUserManager()
.saveWebsite(bookmark.getWebsite());
}
- public void saveFolder(WeblogBookmarkFolder folder) throws RollerException {
+ public void saveFolder(WeblogBookmarkFolder folder) throws WebloggerException {
if(folder.getId() == null || this.getFolder(folder.getId()) == null) {
// New folder, so make sure name is unique
if (isDuplicateFolderName(folder)) {
- throw new RollerException("Duplicate folder name");
+ throw new WebloggerException("Duplicate folder name");
}
// And If it has a parent, maintain relationship from both sides
@@ -109,10 +110,10 @@
this.strategy.store(folder);
// update weblog last modified date. date updated by saveWebsite()
- RollerFactory.getRoller().getUserManager().saveWebsite(folder.getWebsite());
+ roller.getUserManager().saveWebsite(folder.getWebsite());
}
- public void removeFolder(WeblogBookmarkFolder folder) throws RollerException {
+ public void removeFolder(WeblogBookmarkFolder folder) throws WebloggerException {
this.strategy.remove(folder);
WeblogBookmarkFolder parent = folder.getParent();
if (parent != null) {
@@ -120,16 +121,16 @@
}
// update weblog last modified date. date updated by saveWebsite()
- RollerFactory.getRoller().getUserManager().
+ roller.getUserManager().
saveWebsite(folder.getWebsite());
}
public void moveFolder(WeblogBookmarkFolder srcFolder, WeblogBookmarkFolder destFolder)
- throws RollerException {
+ throws WebloggerException {
// TODO: this check should be made before calling this method?
if (destFolder.descendentOf(srcFolder)) {
- throw new RollerException(
+ throw new WebloggerException(
"ERROR cannot move parent folder into it's own child");
}
@@ -157,7 +158,7 @@
}
// updates the paths of all descendents of the given folder
- private void updatePathTree(WeblogBookmarkFolder folder) throws RollerException {
+ private void updatePathTree(WeblogBookmarkFolder folder) throws WebloggerException {
log.debug("Updating path tree for folder "+folder.getPath());
@@ -188,14 +189,14 @@
/**
* Retrieve folder and lazy-load it's sub-folders and bookmarks.
*/
- public WeblogBookmarkFolder getFolder(String id) throws RollerException {
+ public WeblogBookmarkFolder getFolder(String id) throws WebloggerException {
return (WeblogBookmarkFolder) strategy.load(WeblogBookmarkFolder.class, id);
}
public void importBookmarks(
Weblog website, String folderName, String opml)
- throws RollerException {
+ throws WebloggerException {
String msg = "importBookmarks";
try {
// Build JDOC document OPML string
@@ -220,7 +221,7 @@
}
} catch (Exception ex) {
- throw new RollerException(ex);
+ throw new WebloggerException(ex);
}
}
@@ -229,7 +230,7 @@
// that is done by importBookmarks()
private void importOpmlElement(
Weblog website, Element elem, WeblogBookmarkFolder parent)
- throws RollerException {
+ throws WebloggerException {
String text = elem.getAttributeValue("text");
String title = elem.getAttributeValue("title");
String desc = elem.getAttributeValue("description");
@@ -285,7 +286,7 @@
public WeblogBookmarkFolder getFolder(Weblog website, String path)
- throws RollerException {
+ throws WebloggerException {
if (path == null || path.trim().equals("/")) {
return getRootFolder(website);
@@ -314,7 +315,7 @@
* org.apache.roller.weblogger.pojos.WeblogBookmarkFolder, boolean)
*/
public List getBookmarks(WeblogBookmarkFolder folder, boolean subfolders)
- throws RollerException {
+ throws WebloggerException {
Query query = null;
List results = null;
@@ -337,9 +338,9 @@
}
public WeblogBookmarkFolder getRootFolder(Weblog website)
- throws RollerException {
+ throws WebloggerException {
if (website == null)
- throw new RollerException("website is null");
+ throw new WebloggerException("website is null");
Query q = strategy.getNamedQuery("WeblogBookmarkFolder.getByWebsite&ParentNull");
q.setParameter(1, website);
@@ -351,9 +352,9 @@
}
public List getAllFolders(Weblog website)
- throws RollerException {
+ throws WebloggerException {
if (website == null)
- throw new RollerException("Website is null");
+ throw new WebloggerException("Website is null");
Query q = strategy.getNamedQuery("WeblogBookmarkFolder.getByWebsite");
q.setParameter(1, website);
@@ -365,7 +366,7 @@
* make sure the given folder doesn't already exist.
*/
private boolean isDuplicateFolderName(WeblogBookmarkFolder folder)
- throws RollerException {
+ throws WebloggerException {
// ensure that no sibling categories share the same name
WeblogBookmarkFolder parent = folder.getParent();
Modified: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPingQueueManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPingQueueManagerImpl.java?view=diff&rev=543978&r1=543977&r2=543978
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPingQueueManagerImpl.java (original)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPingQueueManagerImpl.java Sun Jun 3 13:18:24 2007
@@ -24,9 +24,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.roller.business.jpa.JPAPersistenceStrategy;
+import org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy;
-import org.apache.roller.RollerException;
+import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.Roller;
import org.apache.roller.weblogger.business.pings.PingQueueManager;
import org.apache.roller.weblogger.pojos.AutoPing;
@@ -45,35 +46,37 @@
/** The strategy for this manager. */
private JPAPersistenceStrategy strategy;
+ private Roller roller = null;
/**
* Creates a new instance of JPAPingQueueManagerImpl
*/
- public JPAPingQueueManagerImpl(
- JPAPersistenceStrategy strategy) {
+ @com.google.inject.Inject
+ public JPAPingQueueManagerImpl(Roller roller, JPAPersistenceStrategy strategy) {
+ this.roller = roller;
this.strategy = strategy;
}
public PingQueueEntry getQueueEntry(String id)
- throws RollerException {
+ throws WebloggerException {
return (PingQueueEntry)strategy.load(
PingQueueEntry.class, id);
}
public void saveQueueEntry(PingQueueEntry pingQueueEntry)
- throws RollerException {
+ throws WebloggerException {
log.debug("Storing ping queue entry: " + pingQueueEntry);
strategy.store(pingQueueEntry);
}
public void removeQueueEntry(PingQueueEntry pingQueueEntry)
- throws RollerException {
+ throws WebloggerException {
log.debug("Removing ping queue entry: " + pingQueueEntry);
strategy.remove(pingQueueEntry);
}
- public void addQueueEntry(AutoPing autoPing) throws RollerException {
+ public void addQueueEntry(AutoPing autoPing) throws WebloggerException {
log.debug("Creating new ping queue entry for auto ping configuration: "
+ autoPing);
@@ -94,7 +97,7 @@
}
public List getAllQueueEntries()
- throws RollerException {
+ throws WebloggerException {
return (List)strategy.getNamedQuery(
"PingQueueEntry.getAllOrderByEntryTime").getResultList();
}
@@ -102,7 +105,7 @@
// private helper to determine if an has already been queued
// for the same website and ping target.
private boolean isAlreadyQueued(AutoPing autoPing)
- throws RollerException {
+ throws WebloggerException {
// first, determine if an entry already exists
Query q = strategy.getNamedQuery("PingQueueEntry.getByPingTarget&Website");
q.setParameter(1, autoPing.getPingTarget());
Modified: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPingTargetManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPingTargetManagerImpl.java?view=diff&rev=543978&r1=543977&r2=543978
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPingTargetManagerImpl.java (original)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPingTargetManagerImpl.java Sun Jun 3 13:18:24 2007
@@ -28,9 +28,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.roller.business.jpa.JPAPersistenceStrategy;
+import org.apache.roller.weblogger.business.jpa.JPAPersistenceStrategy;
-import org.apache.roller.RollerException;
+import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.business.Roller;
import org.apache.roller.weblogger.business.pings.PingTargetManager;
import org.apache.roller.weblogger.pojos.PingTarget;
@@ -49,14 +50,16 @@
JPAPingTargetManagerImpl.class);
private JPAPersistenceStrategy strategy;
+ private Roller roller = null;
- public JPAPingTargetManagerImpl(
- JPAPersistenceStrategy strategy) {
+ @com.google.inject.Inject
+ public JPAPingTargetManagerImpl(Roller roller, JPAPersistenceStrategy strategy) {
+ this.roller = roller;
this.strategy = strategy;
}
public void removePingTarget(PingTarget pingTarget)
- throws RollerException {
+ throws WebloggerException {
// remove contents and then target
this.removePingTargetContents(pingTarget);
this.strategy.remove(pingTarget);
@@ -67,7 +70,7 @@
* reference the given ping target.
*/
private void removePingTargetContents(PingTarget ping)
- throws RollerException {
+ throws WebloggerException {
// Remove the website's ping queue entries
Query q = strategy.getNamedUpdate("PingQueueEntry.removeByPingTarget");
q.setParameter(1, ping);
@@ -80,24 +83,24 @@
}
public void removeAllCustomPingTargets()
- throws RollerException {
+ throws WebloggerException {
Query q = strategy.getNamedUpdate(
"PingTarget.removeByWebsiteNotNull");
q.executeUpdate();
}
public void savePingTarget(PingTarget pingTarget)
- throws RollerException {
+ throws WebloggerException {
strategy.store(pingTarget);
}
public PingTarget getPingTarget(String id)
- throws RollerException {
+ throws WebloggerException {
return (PingTarget)strategy.load(PingTarget.class, id);
}
public boolean isNameUnique(PingTarget pingTarget)
- throws RollerException {
+ throws WebloggerException {
String name = pingTarget.getName();
if (name == null || name.trim().length() == 0) return false;
@@ -130,7 +133,7 @@
public boolean isUrlWellFormed(PingTarget pingTarget)
- throws RollerException {
+ throws WebloggerException {
String url = pingTarget.getPingUrl();
if (url == null || url.trim().length() == 0) return false;
try {
@@ -148,7 +151,7 @@
public boolean isHostnameKnown(PingTarget pingTarget)
- throws RollerException {
+ throws WebloggerException {
String url = pingTarget.getPingUrl();
if (url == null || url.trim().length() == 0) return false;
try {
@@ -165,14 +168,14 @@
}
public List getCommonPingTargets()
- throws RollerException {
+ throws WebloggerException {
Query q = strategy.getNamedQuery(
"PingTarget.getByWebsiteNullOrderByName");
return q.getResultList();
}
public List getCustomPingTargets(Weblog website)
- throws RollerException {
+ throws WebloggerException {
Query q = strategy.getNamedQuery(
"PingTarget.getByWebsiteOrderByName");
q.setParameter(1, website);
Modified: roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPropertiesManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPropertiesManagerImpl.java?view=diff&rev=543978&r1=543977&r2=543978
==============================================================================
--- roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPropertiesManagerImpl.java (original)
+++ roller/branches/roller_guice/apps/weblogger/src/java/org/apache/roller/weblogger/business/jpa/JPAPropertiesManagerImpl.java Sun Jun 3 13:18:24 2007
@@ -25,9 +25,8 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.roller.business.jpa.JPAPersistenceStrategy;
-import org.apache.roller.RollerException;
+import org.apache.roller.weblogger.WebloggerException;
import org.apache.roller.weblogger.business.PropertiesManager;
import org.apache.roller.weblogger.config.RollerRuntimeConfig;
@@ -36,7 +35,7 @@
import org.apache.roller.weblogger.config.runtime.PropertyDef;
import org.apache.roller.weblogger.config.runtime.RuntimeConfigDefs;
import org.apache.roller.weblogger.pojos.RuntimeConfigProperty;
-import org.apache.roller.business.jpa.JPAPersistenceStrategy;
+import org.apache.roller.weblogger.business.Roller;
/*
@@ -52,14 +51,15 @@
JPAPropertiesManagerImpl.class);
private JPAPersistenceStrategy strategy;
+ private Roller roller = null;
/**
* Creates a new instance of JPAPropertiesManagerImpl
*/
- public JPAPropertiesManagerImpl (
- JPAPersistenceStrategy strategy) {
+ @com.google.inject.Inject
+ public JPAPropertiesManagerImpl(Roller roller, JPAPersistenceStrategy strategy) {
log.debug("Instantiating JPA Properties Manager");
-
+ this.roller = roller;
this.strategy = strategy;
// TODO: and new method initialize(props)
@@ -69,7 +69,7 @@
/**
* Retrieve a single property by name.
*/
- public RuntimeConfigProperty getProperty(String name) throws RollerException {
+ public RuntimeConfigProperty getProperty(String name) throws WebloggerException {
return (RuntimeConfigProperty) strategy
.load(RuntimeConfigProperty.class,name);
}
@@ -82,7 +82,7 @@
* uses the property name as the key and the RuntimeConfigProperty object
* as the value.
*/
- public Map getProperties() throws RollerException {
+ public Map getProperties() throws WebloggerException {
HashMap props = new HashMap();
List list = (List) strategy.getNamedQuery("RuntimeConfigProperty.getAll").getResultList();
@@ -107,7 +107,7 @@
* Save a single property.
*/
public void saveProperty(RuntimeConfigProperty property)
- throws RollerException {
+ throws WebloggerException {
this.strategy.store(property);
}
@@ -115,7 +115,7 @@
/**
* Save all properties.
*/
- public void saveProperties(Map properties) throws RollerException {
+ public void saveProperties(Map properties) throws WebloggerException {
// just go through the list and saveProperties each property
Iterator props = properties.values().iterator();