Author: agilliland
Date: Sat Apr 8 15:35:15 2006
New Revision: 392617
URL: http://svn.apache.org/viewcvs?rev=392617&view=rev
Log:
first batch of backend refactorings.
- removed store/remove methods from various Pojos
- changed access rights from protected to public for a few Hierarchical object
methods
- modified grant/revoke role methods of UserData to not contain persistence
calls
- removed canSave methods for various Pojos
Modified:
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/FolderData.java
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/HierarchicalPersistentObject.java
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/PersistentObject.java
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/PingTargetData.java
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/RollerConfigData.java
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/UserData.java
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogCategoryAssoc.java
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogCategoryData.java
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogEntryData.java
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogTemplate.java
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WebsiteData.java
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WebsiteObject.java
Modified:
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/FolderData.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/pojos/FolderData.java?rev=392617&r1=392616&r2=392617&view=diff
==============================================================================
---
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/FolderData.java
(original)
+++
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/FolderData.java
Sat Apr 8 15:35:15 2006
@@ -481,7 +481,7 @@
/**
* @see org.roller.pojos.HierarchicalPersistentObject#getParentAssoc()
*/
- protected Assoc getParentAssoc() throws RollerException
+ public Assoc getParentAssoc() throws RollerException
{
return
RollerFactory.getRoller().getBookmarkManager().getFolderParentAssoc(this);
}
@@ -489,7 +489,7 @@
/**
* @see org.roller.pojos.HierarchicalPersistentObject#getChildAssocs()
*/
- protected List getChildAssocs() throws RollerException
+ public List getChildAssocs() throws RollerException
{
return
RollerFactory.getRoller().getBookmarkManager().getFolderChildAssocs(this);
}
@@ -510,6 +510,7 @@
return
RollerFactory.getRoller().getBookmarkManager().getFolderAncestorAssocs(this);
}
+ // TODO: this needs to be refactored to not use the PersistenceStrategy
protected void removeDescendent(
PersistenceStrategy pstrategy, PersistentObject po) throws
RollerException
{
Modified:
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/HierarchicalPersistentObject.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/pojos/HierarchicalPersistentObject.java?rev=392617&r1=392616&r2=392617&view=diff
==============================================================================
---
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/HierarchicalPersistentObject.java
(original)
+++
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/HierarchicalPersistentObject.java
Sat Apr 8 15:35:15 2006
@@ -20,10 +20,10 @@
*/
public abstract class HierarchicalPersistentObject extends WebsiteObject
{
- protected HierarchicalPersistentObject mNewParent = null;
+ HierarchicalPersistentObject mNewParent = null;
/** Create an association between object and ancestor. */
- protected abstract Assoc createAssoc(
+ public abstract Assoc createAssoc(
HierarchicalPersistentObject object,
HierarchicalPersistentObject ancestor,
String relation ) throws RollerException;
@@ -40,9 +40,9 @@
/** Set new parent - invalidates getPath() until object is saved(). */
public abstract void setParent(HierarchicalPersistentObject parent);
- protected abstract Assoc getParentAssoc() throws RollerException;
+ public abstract Assoc getParentAssoc() throws RollerException;
- protected abstract List getChildAssocs() throws RollerException;
+ public abstract List getChildAssocs() throws RollerException;
public abstract List getAllDescendentAssocs() throws RollerException;
@@ -51,120 +51,10 @@
/** Returns true if this object is in use and should not be deleted */
public abstract boolean isInUse() throws RollerException;
- /** Save this object and ancestoral associations. */
- public void save() throws RollerException
- {
- boolean fresh = (getId() == null || "".equals(getId()));
- PersistenceStrategy pstrategy =
- RollerFactory.getRoller().getPersistenceStrategy();
- pstrategy.store(this);
- if (fresh)
- {
- // Every fresh cat needs a parent assoc
- Assoc parentAssoc = createAssoc(
- this, mNewParent, Assoc.PARENT);
- parentAssoc.save();
- }
- else if (null != mNewParent)
- {
- // New parent must be added to parentAssoc
- Assoc parentAssoc = getParentAssoc();
- parentAssoc.setAncestor(mNewParent);
- parentAssoc.save();
- }
-
- // Clear out existing grandparent associations
- Iterator ancestors = getAncestorAssocs().iterator();
- while (ancestors.hasNext())
- {
- Assoc assoc = (Assoc)ancestors.next();
- if (assoc.getRelation().equals(Assoc.GRANDPARENT))
- {
- assoc.remove();
- }
- }
-
- // Walk parent assocations, creating new grandparent associations
- int count = 0;
- Assoc currentAssoc = getParentAssoc();
- while (null != currentAssoc.getAncestor())
- {
- if (count > 0)
- {
- Assoc assoc = createAssoc(this,
- currentAssoc.getAncestor(),
- Assoc.GRANDPARENT);
- assoc.save();
- }
- currentAssoc = currentAssoc.getAncestor().getParentAssoc();
- count++;
- }
-
- Iterator children = getChildAssocs().iterator();
- while (children.hasNext())
- {
- Assoc assoc = (Assoc) children.next();
-
- // resetting parent will cause reset of ancestors links
- assoc.getObject().setParent(this);
-
- // recursively...
- assoc.getObject().save();
- }
-
- // Clear new parent now that new parent has been saved
- mNewParent = null;
- }
-
-
- /** Remove self, all decendent children and associations. */
- public void remove() throws RollerException
- {
- PersistenceStrategy pstrategy =
- RollerFactory.getRoller().getPersistenceStrategy();
-
- // loop to remove all of my descendents and associations
- List toRemove = new LinkedList();
- List assocs = this.getAllDescendentAssocs();
- for (int i=assocs.size()-1; i>=0; i--)
- {
- Assoc assoc = (Assoc)assocs.get(i);
- HierarchicalPersistentObject hpo = assoc.getObject();
-
- // remove my descendent's parent and grandparent associations
- Iterator ancestors = hpo.getAncestorAssocs().iterator();
- while (ancestors.hasNext())
- {
- Assoc dassoc = (Assoc)ancestors.next();
- dassoc.remove();
- }
-
- // remove decendent association and descendents
- //assoc.remove();
- toRemove.add(hpo);
- }
- Iterator removeIterator = toRemove.iterator();
- while (removeIterator.hasNext())
- {
- PersistentObject po = (PersistentObject) removeIterator.next();
- removeDescendent(pstrategy, po);
- }
-
- // loop to remove my own parent and grandparent associations
- Iterator ancestors = getAncestorAssocs().iterator();
- while (ancestors.hasNext())
- {
- Assoc assoc = (Assoc)ancestors.next();
- assoc.remove();
- }
-
- // remove myself
- removeDescendent(pstrategy, this);
- }
-
/**
* Override this if you want to handle descendant removal yourself.
*/
+ // TODO: this needs to be refactored to not use the PersistenceStrategy
protected void removeDescendent(
PersistenceStrategy pstrategy, PersistentObject po) throws
RollerException
{
Modified:
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/PersistentObject.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/pojos/PersistentObject.java?rev=392617&r1=392616&r2=392617&view=diff
==============================================================================
---
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/PersistentObject.java
(original)
+++
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/PersistentObject.java
Sat Apr 8 15:35:15 2006
@@ -2,70 +2,71 @@
package org.roller.pojos;
import java.io.Serializable;
-
import org.apache.commons.lang.builder.EqualsBuilder;
-import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.roller.RollerException;
-import org.roller.business.PersistenceStrategy;
-import org.roller.model.RollerFactory;
-/**
+/**
* Base class for all of Roller's persistent objects.
*/
-public abstract class PersistentObject implements Serializable
-{
- private long mTimeStamp = 0L; // this was only for Castor, right? -Lance
-
- /** Setter needed by RollerImpl.storePersistentObject() */
- public abstract void setData( PersistentObject vo );
-
+public abstract class PersistentObject implements Serializable {
+
+ private long mTimeStamp = 0L; // this was only for Castor, right? -Lance
+
+
+ public PersistentObject() {}
+
+
+ /** Setter needed by RollerImpl.storePersistentObject() */
+ public abstract void setData( PersistentObject vo );
+
+
/** Get ID */
- public abstract String getId();
-
+ public abstract String getId();
+
+
/** Set ID */
- public abstract void setId( String id );
-
- //--------------------------------------------------------------
implementation
-
- public PersistentObject()
- {
- }
- public void save() throws RollerException
- {
- PersistenceStrategy pstrategy =
- RollerFactory.getRoller().getPersistenceStrategy();
- pstrategy.store(this);
- }
- public void remove() throws RollerException
- {
- PersistenceStrategy pstrategy =
- RollerFactory.getRoller().getPersistenceStrategy();
- pstrategy.remove(this);
- }
- public String toString()
- {
- try
- {
+ public abstract void setId( String id );
+
+
+ public void save() throws RollerException {
+ // NOTE: eoled for new backend
+// PersistenceStrategy pstrategy =
+// RollerFactory.getRoller().getPersistenceStrategy();
+// pstrategy.store(this);
+ }
+
+
+ public void remove() throws RollerException {
+ // NOTE: eoled for new backend
+// PersistenceStrategy pstrategy =
+// RollerFactory.getRoller().getPersistenceStrategy();
+// pstrategy.remove(this);
+ }
+
+
+ public String toString() {
+ try {
// this may throw an exception if called by a thread that
return ToStringBuilder.reflectionToString(
- this, ToStringStyle.MULTI_LINE_STYLE);
- }
- catch (Throwable e)
- {
+ this, ToStringStyle.MULTI_LINE_STYLE);
+ } catch (Throwable e) {
// alternative toString() implementation used in case of exception
return getClass().getName() + ":" + getId();
}
}
+
+
public boolean equals(Object o) {
return EqualsBuilder.reflectionEquals(this, o);
}
+
+
/** Can user associated with persistence session save this object? */
- public boolean canSave() throws RollerException
- {
+ public boolean canSave() throws RollerException {
return true;
}
-
+
}
Modified:
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/PingTargetData.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/pojos/PingTargetData.java?rev=392617&r1=392616&r2=392617&view=diff
==============================================================================
---
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/PingTargetData.java
(original)
+++
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/PingTargetData.java
Sat Apr 8 15:35:15 2006
@@ -258,32 +258,6 @@
return true;
}
- /**
- * Determine if the current user has rights to save the current instance.
- *
- * @return true if the user has rights to save the current instance, false
otherwise.
- * @throws RollerException
- */
- public boolean canSave() throws RollerException
- {
- Roller roller = RollerFactory.getRoller();
- UserData user = roller.getUser();
- // This is more verbose but easier to debug than returning the value
of the boolean expression
- if (user.equals(UserData.SYSTEM_USER))
- {
- return true;
- }
- if (website == null && user.hasRole("admin"))
- {
- return true;
- }
- if (website != null && website.hasUserPermissions(
- user, (short)(PermissionsData.ADMIN |
PermissionsData.AUTHOR)))
- {
- return true;
- }
- return false;
- }
/**
* Remove the object.
Modified:
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/RollerConfigData.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/pojos/RollerConfigData.java?rev=392617&r1=392616&r2=392617&view=diff
==============================================================================
---
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/RollerConfigData.java
(original)
+++
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/RollerConfigData.java
Sat Apr 8 15:35:15 2006
@@ -787,17 +787,4 @@
return super.hashCode();
}
- public boolean canSave() throws RollerException
- {
- Roller roller = RollerFactory.getRoller();
- if (roller.getUser().equals(UserData.SYSTEM_USER))
- {
- return true;
- }
- if (roller.getUser().hasRole("admin"))
- {
- return true;
- }
- return false;
- }
}
Modified:
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/UserData.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/pojos/UserData.java?rev=392617&r1=392616&r2=392617&view=diff
==============================================================================
---
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/UserData.java
(original)
+++
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/UserData.java
Sat Apr 8 15:35:15 2006
@@ -27,280 +27,245 @@
* @hibernate.cache usage="read-write"
*/
public class UserData
- extends org.roller.pojos.PersistentObject
- implements java.io.Serializable
-{
+ extends org.roller.pojos.PersistentObject
+ implements java.io.Serializable {
public static final UserData SYSTEM_USER = new UserData(
- "n/a","systemuser","n/a","systemuser","n/a",
- "en_US_WIN", "America/Los_Angeles", new Date(), Boolean.TRUE);
-
+ "n/a","systemuser","n/a","systemuser","n/a",
+ "en_US_WIN", "America/Los_Angeles", new Date(), Boolean.TRUE);
+
public static final UserData ANONYMOUS_USER = new UserData(
- "n/a","anonymoususer","n/a","anonymoususer","n/a",
- "en_US_WIN", "America/Los_Angeles", new Date(), Boolean.TRUE);
-
- static final long serialVersionUID = -6354583200913127874L;
-
- private String id;
- private String userName;
- private String password;
- private String fullName;
- private String emailAddress;
- private Date dateCreated;
- private String locale;
- private String timeZone;
- private Boolean enabled = Boolean.TRUE;
-
- private Set roles = new TreeSet();
- private List permissions = new ArrayList();
-
- public UserData()
- {
- }
-
- public UserData( String id, String userName,
- String password, String fullName,
- String emailAddress,
- String locale, String timeZone,
- Date dateCreated,
- Boolean isEnabled)
- {
- this.id = id;
- this.userName = userName;
- this.password = password;
- this.fullName = fullName;
- this.emailAddress = emailAddress;
- this.dateCreated = (Date)dateCreated.clone();
- this.locale = locale;
- this.timeZone = timeZone;
- this.enabled = enabled;
- }
-
- public UserData( UserData otherData )
- {
- setData(otherData);
- }
-
- /**
- * @hibernate.bag lazy="true" inverse="true" cascade="delete"
+ "n/a","anonymoususer","n/a","anonymoususer","n/a",
+ "en_US_WIN", "America/Los_Angeles", new Date(), Boolean.TRUE);
+
+ static final long serialVersionUID = -6354583200913127874L;
+
+ private String id;
+ private String userName;
+ private String password;
+ private String fullName;
+ private String emailAddress;
+ private Date dateCreated;
+ private String locale;
+ private String timeZone;
+ private Boolean enabled = Boolean.TRUE;
+
+ private Set roles = new TreeSet();
+ private List permissions = new ArrayList();
+
+ public UserData() {
+ }
+
+ public UserData( String id, String userName,
+ String password, String fullName,
+ String emailAddress,
+ String locale, String timeZone,
+ Date dateCreated,
+ Boolean isEnabled) {
+ this.id = id;
+ this.userName = userName;
+ this.password = password;
+ this.fullName = fullName;
+ this.emailAddress = emailAddress;
+ this.dateCreated = (Date)dateCreated.clone();
+ this.locale = locale;
+ this.timeZone = timeZone;
+ this.enabled = enabled;
+ }
+
+ public UserData( UserData otherData ) {
+ setData(otherData);
+ }
+
+ /**
+ * @hibernate.bag lazy="true" inverse="true" cascade="delete"
* @hibernate.collection-key column="user_id"
- * @hibernate.collection-one-to-many
+ * @hibernate.collection-one-to-many
* class="org.roller.pojos.PermissionsData"
*/
- public List getPermissions()
- {
+ public List getPermissions() {
return permissions;
}
- public void setPermissions(List perms)
- {
+ public void setPermissions(List perms) {
permissions = perms;
}
-
+
/**
* @ejb:persistent-field
* @hibernate.property column="isenabled" non-null="true" unique="false"
*/
- public Boolean getEnabled()
- {
+ public Boolean getEnabled() {
return this.enabled;
}
- /** @ejb:persistent-field */
- public void setEnabled(Boolean enabled)
- {
+ /** @ejb:persistent-field */
+ public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}
/** Id of the User.
* Not remote since primary key may be extracted by other means.
- *
+ *
* @struts.validator type="required" msgkey="errors.required"
- * @ejb:persistent-field
+ * @ejb:persistent-field
* @hibernate.id column="id"
* generator-class="uuid.hex" unsaved-value="null"
*/
- public String getId()
- {
- return this.id;
- }
-
- /** @ejb:persistent-field */
- public void setId( String id )
- {
- this.id = id;
- }
-
- /** User name of the user.
- * @ejb:persistent-field
+ public String getId() {
+ return this.id;
+ }
+
+ /** @ejb:persistent-field */
+ public void setId( String id ) {
+ this.id = id;
+ }
+
+ /** User name of the user.
+ * @ejb:persistent-field
* @hibernate.property column="username" non-null="true" unique="true"
*/
- public String getUserName()
- {
- return this.userName;
- }
- /** @ejb:persistent-field */
- public void setUserName( String userName )
- {
- this.userName = userName;
- }
-
- /**
- * Get password.
- * If password encryption is enabled, will return encrypted password.
- *
- * @ejb:persistent-field
- * @hibernate.property column="passphrase" non-null="true"
- */
- public String getPassword()
- {
- return this.password;
- }
- /**
- * Set password.
- * If password encryption is turned on, then pass in an encrypted password.
- * @ejb:persistent-field
- */
- public void setPassword( String password )
- {
- this.password = password;
- }
-
- /**
- * Full name of the user.
- *
- * @roller.wrapPojoMethod type="simple"
- * @ejb:persistent-field
- * @hibernate.property column="fullname" non-null="true" unique="true"
- */
- public String getFullName()
- {
- return this.fullName;
- }
- /** @ejb:persistent-field */
- public void setFullName( String fullName )
- {
- this.fullName = fullName;
- }
-
- /**
- * E-mail address of the user.
- *
- * @roller.wrapPojoMethod type="simple"
- * @ejb:persistent-field
- * @hibernate.property column="emailaddress" non-null="true" unique="true"
- */
- public String getEmailAddress()
- {
- return this.emailAddress;
- }
- /** @ejb:persistent-field */
- public void setEmailAddress( String emailAddress )
- {
- this.emailAddress = emailAddress;
- }
-
- /**
- * @roller.wrapPojoMethod type="simple"
- * @ejb:persistent-field
- * @hibernate.property column="datecreated" non-null="true" unique="false"
- */
- public Date getDateCreated()
- {
- if (dateCreated == null)
- {
- return null;
- }
- else
- {
- return (Date)dateCreated.clone();
- }
- }
- /** @ejb:persistent-field */
- public void setDateCreated(final Date date)
- {
- if (date != null)
- {
- dateCreated = (Date)date.clone();
- }
- else
- {
- dateCreated = null;
- }
- }
-
- /**
- * Locale of the user.
- * @ejb:persistent-field
- * @hibernate.property column="locale" non-null="true" unique="false"
- */
- public String getLocale()
- {
- return this.locale;
- }
-
- /** @ejb:persistent-field */
- public void setLocale(String locale)
- {
- this.locale = locale;
- }
-
- /**
- * Timezone of the user.
- * @ejb:persistent-field
- * @hibernate.property column="timeZone" non-null="true" unique="false"
- */
- public String getTimeZone()
- {
- return this.timeZone;
- }
-
- /** @ejb:persistent-field */
- public void setTimeZone(String timeZone)
- {
- this.timeZone = timeZone;
- }
-
- //-------------------------------------------------------------------
citizenship
- public String toString()
- {
- StringBuffer str = new StringBuffer("{");
-
- str.append("id=" + id + " ");
- str.append("userName=" + userName + " ");
- str.append("password=" + password + " ");
- str.append("fullName=" + fullName + " ");
- str.append("emailAddress=" + emailAddress + " ");
- str.append("dateCreated=" + dateCreated + " ");
- str.append('}');
-
- return(str.toString());
- }
-
- public boolean equals( Object pOther )
- {
- if (pOther instanceof UserData)
- {
- UserData lTest = (UserData) pOther;
- boolean lEquals = true;
- lEquals = PojoUtil.equals(lEquals, this.getId(), lTest.getId());
- lEquals = PojoUtil.equals(lEquals, this.getUserName(),
lTest.getUserName());
- lEquals = PojoUtil.equals(lEquals, this.getPassword(),
lTest.getPassword());
- lEquals = PojoUtil.equals(lEquals, this.getFullName(),
lTest.getFullName());
- lEquals = PojoUtil.equals(lEquals, this.getEmailAddress(),
lTest.getEmailAddress());
- return lEquals;
- }
- else
- {
- return false;
- }
+ public String getUserName() {
+ return this.userName;
+ }
+ /** @ejb:persistent-field */
+ public void setUserName( String userName ) {
+ this.userName = userName;
+ }
+
+ /**
+ * Get password.
+ * If password encryption is enabled, will return encrypted password.
+ *
+ * @ejb:persistent-field
+ * @hibernate.property column="passphrase" non-null="true"
+ */
+ public String getPassword() {
+ return this.password;
}
-
+ /**
+ * Set password.
+ * If password encryption is turned on, then pass in an encrypted password.
+ * @ejb:persistent-field
+ */
+ public void setPassword( String password ) {
+ this.password = password;
+ }
+
+ /**
+ * Full name of the user.
+ *
+ * @roller.wrapPojoMethod type="simple"
+ * @ejb:persistent-field
+ * @hibernate.property column="fullname" non-null="true" unique="true"
+ */
+ public String getFullName() {
+ return this.fullName;
+ }
+ /** @ejb:persistent-field */
+ public void setFullName( String fullName ) {
+ this.fullName = fullName;
+ }
+
+ /**
+ * E-mail address of the user.
+ *
+ * @roller.wrapPojoMethod type="simple"
+ * @ejb:persistent-field
+ * @hibernate.property column="emailaddress" non-null="true" unique="true"
+ */
+ public String getEmailAddress() {
+ return this.emailAddress;
+ }
+ /** @ejb:persistent-field */
+ public void setEmailAddress( String emailAddress ) {
+ this.emailAddress = emailAddress;
+ }
+
+ /**
+ * @roller.wrapPojoMethod type="simple"
+ * @ejb:persistent-field
+ * @hibernate.property column="datecreated" non-null="true" unique="false"
+ */
+ public Date getDateCreated() {
+ if (dateCreated == null) {
+ return null;
+ } else {
+ return (Date)dateCreated.clone();
+ }
+ }
+ /** @ejb:persistent-field */
+ public void setDateCreated(final Date date) {
+ if (date != null) {
+ dateCreated = (Date)date.clone();
+ } else {
+ dateCreated = null;
+ }
+ }
+
+ /**
+ * Locale of the user.
+ * @ejb:persistent-field
+ * @hibernate.property column="locale" non-null="true" unique="false"
+ */
+ public String getLocale() {
+ return this.locale;
+ }
+
+ /** @ejb:persistent-field */
+ public void setLocale(String locale) {
+ this.locale = locale;
+ }
+
+ /**
+ * Timezone of the user.
+ * @ejb:persistent-field
+ * @hibernate.property column="timeZone" non-null="true" unique="false"
+ */
+ public String getTimeZone() {
+ return this.timeZone;
+ }
+
+ /** @ejb:persistent-field */
+ public void setTimeZone(String timeZone) {
+ this.timeZone = timeZone;
+ }
+
+ //-------------------------------------------------------------------
citizenship
+ public String toString() {
+ StringBuffer str = new StringBuffer("{");
+
+ str.append("id=" + id + " ");
+ str.append("userName=" + userName + " ");
+ str.append("password=" + password + " ");
+ str.append("fullName=" + fullName + " ");
+ str.append("emailAddress=" + emailAddress + " ");
+ str.append("dateCreated=" + dateCreated + " ");
+ str.append('}');
+
+ return(str.toString());
+ }
+
+ public boolean equals( Object pOther ) {
+ if (pOther instanceof UserData) {
+ UserData lTest = (UserData) pOther;
+ boolean lEquals = true;
+ lEquals = PojoUtil.equals(lEquals, this.getId(), lTest.getId());
+ lEquals = PojoUtil.equals(lEquals, this.getUserName(),
lTest.getUserName());
+ lEquals = PojoUtil.equals(lEquals, this.getPassword(),
lTest.getPassword());
+ lEquals = PojoUtil.equals(lEquals, this.getFullName(),
lTest.getFullName());
+ lEquals = PojoUtil.equals(lEquals, this.getEmailAddress(),
lTest.getEmailAddress());
+ return lEquals;
+ } else {
+ return false;
+ }
+ }
+
/*public boolean equals( Object pOther )
{
if( pOther instanceof UserData )
{
UserData lTest = (UserData) pOther;
boolean lEquals = true;
-
+
if( this.id == null )
{
lEquals = lEquals && ( lTest.id == null );
@@ -341,16 +306,16 @@
{
lEquals = lEquals && this.emailAddress.equals( lTest.emailAddress
);
}
-
- if( this.dateCreated == null )
- {
- lEquals = lEquals && ( lTest.dateCreated == null );
- }
- else
- {
- lEquals = lEquals && datesEquivalent(this.dateCreated,
lTest.dateCreated);
- }
-
+
+ if( this.dateCreated == null )
+ {
+ lEquals = lEquals && ( lTest.dateCreated == null );
+ }
+ else
+ {
+ lEquals = lEquals && datesEquivalent(this.dateCreated,
lTest.dateCreated);
+ }
+
return lEquals;
}
else
@@ -358,9 +323,8 @@
return false;
}
}*/
-
- private boolean datesEquivalent(Date d1, Date d2)
- {
+
+ private boolean datesEquivalent(Date d1, Date d2) {
boolean equiv = true;
equiv = equiv && d1.getHours() == d1.getHours();
equiv = equiv && d1.getMinutes() == d1.getMinutes();
@@ -370,147 +334,117 @@
equiv = equiv && d1.getYear() == d1.getYear();
return equiv;
}
-
- public int hashCode()
- {
- int result = 17;
- result = 37*result + ((this.id != null) ? this.id.hashCode() : 0);
- result = 37*result + ((this.userName != null) ? this.userName.hashCode()
: 0);
- result = 37*result + ((this.password != null) ? this.password.hashCode()
: 0);
- result = 37*result + ((this.fullName != null) ? this.fullName.hashCode()
: 0);
- result = 37*result + ((this.emailAddress != null) ?
this.emailAddress.hashCode() : 0);
- result = 37*result + ((this.dateCreated != null) ?
this.dateCreated.hashCode() : 0);
- return result;
- }
-
- /**
- * Setter is needed in RollerImpl.storePersistentObject()
- */
- public void setData( org.roller.pojos.PersistentObject otherData )
- {
- UserData other = (UserData)otherData;
- this.id = other.getId();
- this.userName = other.getUserName();
- this.password = other.getPassword();
- this.fullName = other.getFullName();
- this.emailAddress = other.getEmailAddress();
- this.locale = other.getLocale();
- this.timeZone = other.getTimeZone();
- this.dateCreated = other.getDateCreated()!=null ?
(Date)other.getDateCreated().clone() : null;
- }
-
- /**
- * Removing a user also removes his/her website.
- * @see org.roller.pojos.PersistentObject#remove()
- */
- public void remove() throws RollerException
- {
- UserManager uMgr = RollerFactory.getRoller().getUserManager();
-
- // remove user roles
- //Iterator roles = uMgr.getUserRoles(this).iterator();
- //while (roles.hasNext())
- //{
- //((RoleData)roles.next()).remove();
- //}
- super.remove();
+
+ public int hashCode() {
+ int result = 17;
+ result = 37*result + ((this.id != null) ? this.id.hashCode() : 0);
+ result = 37*result + ((this.userName != null) ?
this.userName.hashCode() : 0);
+ result = 37*result + ((this.password != null) ?
this.password.hashCode() : 0);
+ result = 37*result + ((this.fullName != null) ?
this.fullName.hashCode() : 0);
+ result = 37*result + ((this.emailAddress != null) ?
this.emailAddress.hashCode() : 0);
+ result = 37*result + ((this.dateCreated != null) ?
this.dateCreated.hashCode() : 0);
+ return result;
}
- /**
+ /**
+ * Setter is needed in RollerImpl.storePersistentObject()
+ */
+ public void setData( org.roller.pojos.PersistentObject otherData ) {
+ UserData other = (UserData)otherData;
+ this.id = other.getId();
+ this.userName = other.getUserName();
+ this.password = other.getPassword();
+ this.fullName = other.getFullName();
+ this.emailAddress = other.getEmailAddress();
+ this.locale = other.getLocale();
+ this.timeZone = other.getTimeZone();
+ this.dateCreated = other.getDateCreated()!=null ?
(Date)other.getDateCreated().clone() : null;
+ }
+
+
+ /**
* Reset this user's password.
* @param roller Roller instance to use for configuration information
* @param new1 New password
* @param new2 Confirm this matches new password
* @author Dave Johnson
*/
- public void resetPassword(Roller roller, String new1, String new2) throws
RollerException
- {
- if (!new1.equals(new2))
- {
+ public void resetPassword(Roller roller, String new1, String new2) throws
RollerException {
+ if (!new1.equals(new2)) {
throw new RollerException("newUser.error.mismatchedPasswords");
}
-
+
String encrypt =
RollerConfig.getProperty("passwds.encryption.enabled");
String algorithm =
RollerConfig.getProperty("passwds.encryption.algorithm");
- if (new Boolean(encrypt).booleanValue())
- {
- password = Utilities.encodePassword(new1, algorithm);
- }
- else
- {
+ if (new Boolean(encrypt).booleanValue()) {
+ password = Utilities.encodePassword(new1, algorithm);
+ } else {
password = new1;
}
}
- /**
- * @hibernate.set lazy="false" inverse="true" cascade="delete"
+
+ /**
+ * @hibernate.set lazy="false" inverse="true" cascade="all-delete-orphan"
* @hibernate.collection-key column="userid"
* @hibernate.collection-one-to-many class="org.roller.pojos.RoleData"
*/
- public Set getRoles()
- {
+ public Set getRoles() {
return roles;
}
- public void setRoles(Set roles)
- {
+ public void setRoles(Set roles) {
this.roles = roles;
}
-
+
/**
* Returns true if user has role specified.
- * @param roleName Name of role
- * @return True if user has specified role.
*/
- public boolean hasRole(String roleName)
- {
+ public boolean hasRole(String roleName) {
Iterator iter = roles.iterator();
- while (iter.hasNext())
- {
+ while (iter.hasNext()) {
RoleData role = (RoleData) iter.next();
- if (role.getRole().equals(roleName))
- {
+ if (role.getRole().equals(roleName)) {
return true;
}
}
return false;
}
-
+
+
/**
* Revokes specified role from user.
- * @param roleName Name of role to be revoked.
*/
- public void revokeRole(String roleName) throws RollerException
- {
- RoleData removeme = null;
+ public void revokeRole(String roleName) throws RollerException {
+ RoleData removeme = null;
Iterator iter = roles.iterator();
- while (iter.hasNext())
- {
+ while (iter.hasNext()) {
RoleData role = (RoleData) iter.next();
- if (role.getRole().equals(roleName))
- {
+ if (role.getRole().equals(roleName)) {
removeme = role;
}
}
- if (removeme != null)
- {
+
+ /*
+ * NOTE: we do this outside the loop above because we are not allowed
+ * to modify the contents of the Set while we are iterating over it.
+ * doing so causes a ConcurrentModificationException
+ */
+ if(removeme != null) {
roles.remove(removeme);
-
RollerFactory.getRoller().getUserManager().removeRole(removeme.getId());
}
}
-
+
+
/**
* Grant to user role specified by role name.
- * @param roleName Name of role to be granted.
*/
- public void grantRole(String roleName) throws RollerException
- {
- if (!hasRole(roleName))
- {
+ public void grantRole(String roleName) throws RollerException {
+ if (!hasRole(roleName)) {
RoleData role = new RoleData(null, this, roleName);
- RollerFactory.getRoller().getUserManager().storeRole(role);
roles.add(role);
}
}
+
}
Modified:
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogCategoryAssoc.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogCategoryAssoc.java?rev=392617&r1=392616&r2=392617&view=diff
==============================================================================
---
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogCategoryAssoc.java
(original)
+++
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogCategoryAssoc.java
Sat Apr 8 15:35:15 2006
@@ -1,7 +1,6 @@
package org.roller.pojos;
import org.roller.RollerException;
-import org.roller.business.PersistenceStrategy;
import org.roller.model.RollerFactory;
/**
@@ -70,23 +69,6 @@
this.id = id;
}
-
- /**
- * Remove self and all child categories.
- */
- public void remove() throws RollerException
- {
- PersistenceStrategy pstrategy =
- RollerFactory.getRoller().getPersistenceStrategy();
- pstrategy.remove(this);
- }
-
- public void save() throws RollerException
- {
- PersistenceStrategy pstrategy =
- RollerFactory.getRoller().getPersistenceStrategy();
- pstrategy.store(this);
- }
/**
* Setter is needed in RollerImpl.storePersistentObject()
Modified:
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogCategoryData.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogCategoryData.java?rev=392617&r1=392616&r2=392617&view=diff
==============================================================================
---
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogCategoryData.java
(original)
+++
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogCategoryData.java
Sat Apr 8 15:35:15 2006
@@ -458,7 +458,7 @@
/**
* @see org.roller.pojos.HierarchicalPersistentObject#getParentAssoc()
*/
- protected Assoc getParentAssoc() throws RollerException
+ public Assoc getParentAssoc() throws RollerException
{
return
RollerFactory.getRoller().getWeblogManager().getWeblogCategoryParentAssoc(this);
}
@@ -466,7 +466,7 @@
/**
* @see org.roller.pojos.HierarchicalPersistentObject#getChildAssocs()
*/
- protected List getChildAssocs() throws RollerException
+ public List getChildAssocs() throws RollerException
{
return
RollerFactory.getRoller().getWeblogManager().getWeblogCategoryChildAssocs(this);
}
Modified:
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogEntryData.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogEntryData.java?rev=392617&r1=392616&r2=392617&view=diff
==============================================================================
---
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogEntryData.java
(original)
+++
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogEntryData.java
Sat Apr 8 15:35:15 2006
@@ -1139,21 +1139,4 @@
{
}
- public boolean canSave() throws RollerException
- {
- Roller roller = RollerFactory.getRoller();
- if (roller.getUser().equals(UserData.SYSTEM_USER))
- {
- return true;
- }
- boolean author = getWebsite().hasUserPermissions(
- roller.getUser(), (short)(PermissionsData.AUTHOR));
- boolean limited = getWebsite().hasUserPermissions(
- roller.getUser(), (short)(PermissionsData.LIMITED));
- if (author || (limited && isDraft()) || (limited && isPending()))
- {
- return true;
- }
- return false;
- }
}
Modified:
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogTemplate.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogTemplate.java?rev=392617&r1=392616&r2=392617&view=diff
==============================================================================
---
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogTemplate.java
(original)
+++
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WeblogTemplate.java
Sat Apr 8 15:35:15 2006
@@ -320,18 +320,5 @@
this.lastModified = other.getLastModified()!=null ?
(Date)other.getLastModified().clone() : null;
}
- public boolean canSave() throws RollerException
- {
- Roller roller = RollerFactory.getRoller();
- if (roller.getUser().equals(UserData.SYSTEM_USER))
- {
- return true;
- }
- if (getWebsite().hasUserPermissions(roller.getUser(),
PermissionsData.ADMIN))
- {
- return true;
- }
- return false;
- }
}
Modified:
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WebsiteData.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WebsiteData.java?rev=392617&r1=392616&r2=392617&view=diff
==============================================================================
---
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WebsiteData.java
(original)
+++
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WebsiteData.java
Sat Apr 8 15:35:15 2006
@@ -46,8 +46,8 @@
private String handle = null;
private String name = null;
private String description = null;
- private String defaultPageId = null;
- private String weblogDayPageId = null;
+ private String defaultPageId = "dummy";
+ private String weblogDayPageId = "dummy";
private Boolean enableBloggerApi = Boolean.TRUE;
private String editorPage = null;
private String blacklist = null;
@@ -130,7 +130,7 @@
}
/**
- * @hibernate.bag lazy="true" inverse="true" cascade="delete"
+ * @hibernate.bag lazy="true" inverse="true" cascade="delete"
* @hibernate.collection-key column="website_id"
* @hibernate.collection-one-to-many
* class="org.roller.pojos.PermissionsData"
@@ -951,30 +951,7 @@
}
return TimeZone.getTimeZone(timeZone);
}
-
- /**
- * @see org.roller.pojos.PersistentObject#remove()
- */
- public void remove() throws RollerException
- {
-
RollerFactory.getRoller().getUserManager().removeWebsiteContents(this);
- super.remove();
- }
- public boolean canSave() throws RollerException
- {
- Roller roller = RollerFactory.getRoller();
- if (roller.getUser().equals(UserData.SYSTEM_USER))
- {
- return true;
- }
- if (hasUserPermissions(roller.getUser(),
- (short)(PermissionsData.ADMIN|PermissionsData.AUTHOR)))
- {
- return true;
- }
- return false;
- }
/**
* Returns true if user has all permissions specified by mask.
Modified:
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WebsiteObject.java
URL:
http://svn.apache.org/viewcvs/incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WebsiteObject.java?rev=392617&r1=392616&r2=392617&view=diff
==============================================================================
---
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WebsiteObject.java
(original)
+++
incubator/roller/branches/roller-newbackend/src/org/roller/pojos/WebsiteObject.java
Sat Apr 8 15:35:15 2006
@@ -11,19 +11,5 @@
{
public abstract WebsiteData getWebsite();
- public boolean canSave() throws RollerException
- {
- Roller roller = RollerFactory.getRoller();
- if (roller.getUser().equals(UserData.SYSTEM_USER))
- {
- return true;
- }
- if (getWebsite().hasUserPermissions(
- roller.getUser(), PermissionsData.AUTHOR))
- {
- return true;
- }
- return false;
- }
}