raphael 2002/11/05 16:00:05
Modified: src/java/org/apache/jetspeed/om/registry/base
BaseCachedParameter.java BaseCapabilityMap.java
BaseClientEntry.java BaseContentURL.java
BaseMediaTypeEntry.java BaseMimetypeMap.java
BaseSecurityAccess.java BaseSecurityEntry.java
BaseSkinEntry.java
Log:
Fix Regsitry "double entry" issue, auto-save at startup and
unnecessary work at startup
Revision Changes Path
1.3 +27 -1
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseCachedParameter.java
Index: BaseCachedParameter.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseCachedParameter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BaseCachedParameter.java 3 Nov 2002 15:10:06 -0000 1.2
+++ BaseCachedParameter.java 6 Nov 2002 00:00:04 -0000 1.3
@@ -73,6 +73,32 @@
private boolean cachedOnName = true;
private boolean cachedOnValue = true;
+ /**
+ * Implements the equals operation so that 2 elements are equal if
+ * all their member values are equal.
+ */
+ public boolean equals(Object object)
+ {
+ if (object==null)
+ {
+ return false;
+ }
+
+ BaseCachedParameter obj = (BaseCachedParameter)object;
+
+ if (cachedOnName != obj.getCachedOnName())
+ {
+ return false;
+ }
+
+ if (cachedOnValue != obj.getCachedOnValue())
+ {
+ return false;
+ }
+
+ return super.equals(object);
+ }
+
public boolean isCachedOnName()
{
return cachedOnName;
1.2 +79 -1
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseCapabilityMap.java
Index: BaseCapabilityMap.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseCapabilityMap.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BaseCapabilityMap.java 30 Oct 2002 15:52:05 -0000 1.1
+++ BaseCapabilityMap.java 6 Nov 2002 00:00:04 -0000 1.2
@@ -73,6 +73,49 @@
{
}
+ /**
+ * Implements the equals operation so that 2 elements are equal if
+ * all their member values are equal.
+ */
+ public boolean equals(Object object)
+ {
+ if (object==null)
+ {
+ return false;
+ }
+
+ BaseCapabilityMap obj = (BaseCapabilityMap)object;
+
+ Iterator i = caps.iterator();
+ Iterator i2 = obj.caps.iterator();
+ while(i.hasNext())
+ {
+ String c1 = (String)i.next();
+ String c2 = null;
+
+ if (i2.hasNext())
+ {
+ c2 = (String)i2.next();
+ }
+ else
+ {
+ return false;
+ }
+
+ if (!c1.equals(c2))
+ {
+ return false;
+ }
+ }
+
+ if (i2.hasNext())
+ {
+ return false;
+ }
+
+ return true;
+ }
+
public Iterator getCapabilities()
{
return caps.iterator();
@@ -89,6 +132,41 @@
public void removeCapability(String name)
{
caps.remove(name);
+ }
+
+ /**
+ * Checks if the argument capability is included in this map
+ *
+ * @param capabiltiy a capability descriptor
+ * @return true if the capability is supported
+ */
+ public boolean contains(String capability)
+ {
+ return caps.contains(capability);
+ }
+
+ /**
+ * Checks if the all the elements of argument capability map
+ * are included in the current one
+ *
+ * @param map a CapabilityMap implementation to test
+ * @return true is all the elements the argument map are included in the
+ * current map.
+ */
+ public boolean containsAll(CapabilityMap map)
+ {
+ Iterator i = map.getCapabilities();
+
+ while(i.hasNext())
+ {
+ String capability = (String)i.next();
+ if (!contains(capability))
+ {
+ return false;
+ }
+ }
+
+ return true;
}
// castor related method definitions
1.3 +87 -1
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseClientEntry.java
Index: BaseClientEntry.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseClientEntry.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BaseClientEntry.java 3 Nov 2002 15:10:06 -0000 1.2
+++ BaseClientEntry.java 6 Nov 2002 00:00:04 -0000 1.3
@@ -79,6 +79,92 @@
{
}
+ /**
+ * Implements the equals operation so that 2 elements are equal if
+ * all their member values are equal.
+ */
+ public boolean equals(Object object)
+ {
+ if (object==null)
+ {
+ return false;
+ }
+
+ BaseClientEntry obj = (BaseClientEntry)object;
+
+ if (useragentpattern!=null)
+ {
+ if (!useragentpattern.equals(obj.useragentpattern))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (obj.useragentpattern!=null)
+ {
+ return false;
+ }
+ }
+
+ if (manufacturer!=null)
+ {
+ if (!manufacturer.equals(obj.manufacturer))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (obj.manufacturer!=null)
+ {
+ return false;
+ }
+ }
+
+ if (model!=null)
+ {
+ if (!model.equals(obj.model))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (obj.model!=null)
+ {
+ return false;
+ }
+ }
+
+ if (version!=null)
+ {
+ if (!version.equals(obj.version))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (obj.version!=null)
+ {
+ return false;
+ }
+ }
+
+ if (!mimetypes.equals(obj.mimetypes))
+ {
+ return false;
+ }
+
+ if (!capabilities.equals(obj.capabilities))
+ {
+ return false;
+ }
+
+ return super.equals(object);
+ }
+
public String getUseragentpattern()
{
return useragentpattern;
1.2 +42 -6
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseContentURL.java
Index: BaseContentURL.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseContentURL.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BaseContentURL.java 26 Mar 2002 09:06:53 -0000 1.1
+++ BaseContentURL.java 6 Nov 2002 00:00:04 -0000 1.2
@@ -60,9 +60,9 @@
import org.apache.jetspeed.om.registry.ContentURL;
/**
- * Bean like implementation of the ContentURL interface suitable for
+ * Bean like implementation of the ContentURL interface suitable for
* Castor serialization.
- *
+ *
* @see org.apache.jetspeed.om.registry.Security
* @author <a href="mailto:taylor@;apache.org">David Sean Taylor</a>
* @version $Id$
@@ -72,6 +72,42 @@
private String url;
private boolean cacheKey = true;
+ /**
+ * Implements the equals operation so that 2 elements are equal if
+ * all their member values are equal.
+ */
+ public boolean equals(Object object)
+ {
+ if (object==null)
+ {
+ return false;
+ }
+
+ BaseContentURL obj = (BaseContentURL)object;
+
+ if (cacheKey != obj.cacheKey)
+ {
+ return false;
+ }
+
+ if (url!=null)
+ {
+ if(!url.equals(obj.url))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (obj.url!=null)
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
/** @return the string URL */
public String getURL()
{
@@ -79,14 +115,14 @@
}
/** Sets the string URL
- *
+ *
* @param value the new URL value
*/
public void setURL(String value)
{
this.url = value;
}
-
+
public boolean isCacheKey()
{
return cacheKey;
@@ -94,7 +130,7 @@
public void setCachedOnURL(boolean cacheKey)
{
- this.cacheKey = cacheKey;
+ this.cacheKey = cacheKey;
}
public boolean getCachedOnURL()
1.5 +50 -1
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseMediaTypeEntry.java
Index: BaseMediaTypeEntry.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseMediaTypeEntry.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BaseMediaTypeEntry.java 30 Oct 2002 15:52:05 -0000 1.4
+++ BaseMediaTypeEntry.java 6 Nov 2002 00:00:04 -0000 1.5
@@ -88,7 +88,56 @@
this.mimeType = mimeType;
}
+ /**
+ * Implements the equals operation so that 2 elements are equal if
+ * all their member values are equal.
+ */
+ public boolean equals(Object object)
+ {
+ if (object==null)
+ {
+ return false;
+ }
+ BaseMediaTypeEntry obj = (BaseMediaTypeEntry)object;
+
+ if (mimeType!=null)
+ {
+ if (!mimeType.equals(obj.mimeType))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (obj.mimeType!=null)
+ {
+ return false;
+ }
+ }
+
+ if (characterSet!=null)
+ {
+ if (!characterSet.equals(obj.characterSet))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (obj.characterSet!=null)
+ {
+ return false;
+ }
+ }
+
+ if (!capabilities.equals(obj.capabilities))
+ {
+ return false;
+ }
+
+ return super.equals(object);
+ }
/** @return the mime type associated with this MediaType */
public String getMimeType()
1.2 +76 -4
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseMimetypeMap.java
Index: BaseMimetypeMap.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseMimetypeMap.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BaseMimetypeMap.java 30 Oct 2002 15:52:05 -0000 1.1
+++ BaseMimetypeMap.java 6 Nov 2002 00:00:04 -0000 1.2
@@ -55,6 +55,7 @@
package org.apache.jetspeed.om.registry.base;
import org.apache.jetspeed.om.registry.MimetypeMap;
+import org.apache.jetspeed.util.MimeType;
import java.util.Vector;
import java.util.Iterator;
@@ -69,18 +70,73 @@
{
private Vector mimetypesVector = new Vector();
+ private transient Vector mimes;
+
public BaseMimetypeMap()
{
}
+ /**
+ * Implements the equals operation so that 2 elements are equal if
+ * all their member values are equal.
+ */
+ public boolean equals(Object object)
+ {
+ if (object==null)
+ {
+ return false;
+ }
+
+ BaseMimetypeMap obj = (BaseMimetypeMap)object;
+
+ Iterator i = mimetypesVector.iterator();
+ Iterator i2 = obj.mimetypesVector.iterator();
+ while(i.hasNext())
+ {
+ String c1 = (String)i.next();
+ String c2 = null;
+
+ if (i2.hasNext())
+ {
+ c2 = (String)i2.next();
+ }
+ else
+ {
+ return false;
+ }
+
+ if (!c1.equals(c2))
+ {
+ return false;
+ }
+ }
+
+ if (i2.hasNext())
+ {
+ return false;
+ }
+
+ return true;
+ }
+
public Iterator getMimetypes()
{
- return mimetypesVector.iterator();
+ if (mimes == null)
+ {
+ buildMimetable();
+ }
+
+ return mimes.iterator();
}
- public String getPreferredMimetype()
+ public MimeType getPreferredMimetype()
{
- return (String)mimetypesVector.get(0);
+ if (mimes == null)
+ {
+ buildMimetable();
+ }
+
+ return (MimeType)mimes.get(0);
}
public void addMimetype(String name)
@@ -88,12 +144,28 @@
if (!mimetypesVector.contains(name))
{
mimetypesVector.add(name);
+ buildMimetable();
}
}
public void removeMimetype(String name)
{
mimetypesVector.remove(name);
+ buildMimetable();
+ }
+
+ protected void buildMimetable()
+ {
+ Vector types = new Vector();
+ Iterator i = mimetypesVector.iterator();
+
+ while(i.hasNext())
+ {
+ String mime = (String)i.next();
+ types.add(new MimeType(mime));
+ }
+
+ this.mimes = types;
}
// castor related method definitions
1.5 +103 -17
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseSecurityAccess.java
Index: BaseSecurityAccess.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseSecurityAccess.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BaseSecurityAccess.java 25 Aug 2002 20:41:02 -0000 1.4
+++ BaseSecurityAccess.java 6 Nov 2002 00:00:04 -0000 1.5
@@ -56,13 +56,14 @@
// Java imports
import java.util.Vector;
+import java.util.Iterator;
// Jetspeed imports
import org.apache.jetspeed.om.registry.SecurityAccess;
/**
* Interface for manipulatin the Security Access on the registry entries
- *
+ *
* @author <a href="mailto:paulsp@;apache.org">Paul Spencer</a>
* @version $Id$
*/
@@ -71,21 +72,106 @@
/** Holds value of property action. */
private String action;
-
+
/** Holds value of property allows. */
- private Vector allows;
-
+ private Vector allows = new Vector();
+
/** Holds value of property ownerAllows. */
- private Vector ownerAllows;
-
+ private Vector ownerAllows = new Vector();
+
/** Holds the combination of allows and ownerAllows. */
- private Vector allAllows;
-
+ private transient Vector allAllows = new Vector();
+
/** Creates new BaseSecurityAccess */
public BaseSecurityAccess()
{
}
+ /**
+ * Implements the equals operation so that 2 elements are equal if
+ * all their member values are equal.
+ */
+ public boolean equals(Object object)
+ {
+ if (object==null)
+ {
+ return false;
+ }
+
+ BaseSecurityAccess obj = (BaseSecurityAccess)object;
+
+ if (action!=null)
+ {
+ if (!action.equals(obj.action))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (obj.action!=null)
+ {
+ return false;
+ }
+ }
+
+ Iterator i = allows.iterator();
+ Iterator i2 = obj.allows.iterator();
+ while(i.hasNext())
+ {
+ BaseSecurityAllow c1 = (BaseSecurityAllow)i.next();
+ BaseSecurityAllow c2 = null;
+
+ if (i2.hasNext())
+ {
+ c2 = (BaseSecurityAllow)i2.next();
+ }
+ else
+ {
+ return false;
+ }
+
+ if (!c1.equals(c2))
+ {
+ return false;
+ }
+ }
+
+ if (i2.hasNext())
+ {
+ return false;
+ }
+
+ i = ownerAllows.iterator();
+ i2 = obj.ownerAllows.iterator();
+ while(i.hasNext())
+ {
+ BaseSecurityAllowOwner c1 = (BaseSecurityAllowOwner)i.next();
+ BaseSecurityAllowOwner c2 = null;
+
+ if (i2.hasNext())
+ {
+ c2 = (BaseSecurityAllowOwner)i2.next();
+ }
+ else
+ {
+ return false;
+ }
+
+ if (!c1.equals(c2))
+ {
+ return false;
+ }
+ }
+
+ if (i2.hasNext())
+ {
+ return false;
+ }
+
+ return true;
+ }
+
/** Getter for property action.
* @return Value of property action.
*/
@@ -93,7 +179,7 @@
{
return action;
}
-
+
/** Setter for property action.
* @param action New value of property action.
*/
@@ -101,7 +187,7 @@
{
this.action = action;
}
-
+
/** Getter for property allows.
* @return Value of property allows.
*/
@@ -109,7 +195,7 @@
{
return allows;
}
-
+
/** Setter for property allows.
* @param allows New value of property allows.
*/
@@ -121,7 +207,7 @@
allAllows.removeAllElements();
}
}
-
+
/** Getter for property ownerAllows.
* @return Value of property ownerAllows.
*/
@@ -129,7 +215,7 @@
{
return this.ownerAllows;
}
-
+
/** Setter for property ownerAllows.
* @param ownerAllows New value of property ownerAllows.
*/
@@ -141,10 +227,10 @@
allAllows.removeAllElements();
}
}
-
+
/**
* Return a vector contain all allows elements. If the vector is null
- * or empty, then create and populate it with elements from the allows
+ * or empty, then create and populate it with elements from the allows
* and ownerAllows vectors.
*
* @return vector containing all allows
@@ -165,7 +251,7 @@
allAllows.ensureCapacity(elementCount);
allAllows.addAll(this.allows);
}
-
+
if (this.ownerAllows != null)
{
elementCount += this.ownerAllows.size();
1.7 +45 -2
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseSecurityEntry.java
Index: BaseSecurityEntry.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseSecurityEntry.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- BaseSecurityEntry.java 3 Nov 2002 15:10:06 -0000 1.6
+++ BaseSecurityEntry.java 6 Nov 2002 00:00:05 -0000 1.7
@@ -75,7 +75,7 @@
{
/** Holds value of property accesses. */
- private Vector accesses;
+ private Vector accesses = new Vector();
private transient Map accessMap = null;
@@ -95,6 +95,49 @@
public BaseSecurityEntry()
{ }
+
+ /**
+ * Implements the equals operation so that 2 elements are equal if
+ * all their member values are equal.
+ */
+ public boolean equals(Object object)
+ {
+ if (object==null)
+ {
+ return false;
+ }
+
+ BaseSecurityEntry obj = (BaseSecurityEntry)object;
+
+ Iterator i = accesses.iterator();
+ Iterator i2 = obj.accesses.iterator();
+ while(i.hasNext())
+ {
+ BaseSecurityAccess c1 = (BaseSecurityAccess)i.next();
+ BaseSecurityAccess c2 = null;
+
+ if (i2.hasNext())
+ {
+ c2 = (BaseSecurityAccess)i2.next();
+ }
+ else
+ {
+ return false;
+ }
+
+ if (!c1.equals(c2))
+ {
+ return false;
+ }
+ }
+
+ if (i2.hasNext())
+ {
+ return false;
+ }
+
+ return super.equals(object);
+ }
/** Getter for property accesses.
* @return Value of property accesses.
1.2 +65 -22
jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseSkinEntry.java
Index: BaseSkinEntry.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/registry/base/BaseSkinEntry.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BaseSkinEntry.java 29 Jul 2001 13:41:55 -0000 1.1
+++ BaseSkinEntry.java 6 Nov 2002 00:00:05 -0000 1.2
@@ -61,7 +61,7 @@
/**
* The BaseSkinEntry is a bean like implementation of the SkinEntry
* interface suitable for Castor XML serialization
- *
+ *
* @see org.apache.jetspeed.om.registry.SkinEntry
* @author <a href="mailto:raphael@;apache.org">Rapha�l Luta</a>
* @version $Id$
@@ -70,9 +70,52 @@
{
private Vector parameter = new Vector();
-
+
private transient Map nameIdx = null;
-
+
+ /**
+ * Implements the equals operation so that 2 elements are equal if
+ * all their member values are equal.
+ */
+ public boolean equals(Object object)
+ {
+ if (object==null)
+ {
+ return false;
+ }
+
+ BaseSkinEntry obj = (BaseSkinEntry)object;
+
+ Iterator i = parameter.iterator();
+ Iterator i2 = obj.parameter.iterator();
+ while(i.hasNext())
+ {
+ String c1 = (String)i.next();
+ String c2 = null;
+
+ if (i2.hasNext())
+ {
+ c2 = (String)i2.next();
+ }
+ else
+ {
+ return false;
+ }
+
+ if (!c1.equals(c2))
+ {
+ return false;
+ }
+ }
+
+ if (i2.hasNext())
+ {
+ return false;
+ }
+
+ return super.equals(object);
+ }
+
/** @return an enumeration of this entry parameter names */
public Iterator getParameterNames()
{
@@ -83,7 +126,7 @@
buildNameIndex();
}
}
-
+
return nameIdx.keySet().iterator();
}
@@ -112,12 +155,12 @@
return (Parameter)parameter.elementAt(pos.intValue());
}
}
-
+
return null;
}
-
-
- /** Returns a map of parameter values keyed on the parameter names
+
+
+ /** Returns a map of parameter values keyed on the parameter names
* @return the parameter values map
*/
public Map getParameterMap()
@@ -129,9 +172,9 @@
Parameter param = (Parameter)en.nextElement();
params.put(param.getName(),param.getValue());
}
-
+
return params;
-
+
}
/** Adds a new parameter for this entry
@@ -148,11 +191,11 @@
p = new BaseParameter();
p.setName(name);
}
-
+
p.setValue(value);
-
+
addParameter(p);
-
+
}
}
@@ -188,20 +231,20 @@
i.remove();
}
}
-
+
buildNameIndex();
}
}
-
+
/** This method recreates the paramter name index for quick retrieval
* of parameters by name. Shoule be called whenever a complete index
- * of parameter should be rebuilt (eg removing a parameter or setting
+ * of parameter should be rebuilt (eg removing a parameter or setting
* a parameters vector)
*/
private void buildNameIndex()
{
Hashtable idx = new Hashtable();
-
+
Iterator i = parameter.iterator();
int count = 0;
while( i.hasNext() )
@@ -210,13 +253,13 @@
idx.put( p.getName(), new Integer(count) );
count++;
}
-
+
this.nameIdx = idx;
- }
+ }
// Castor serialization accessor methods
-
- /** Needed for Castor 0.8.11 XML serialization for retrieving the
+
+ /** Needed for Castor 0.8.11 XML serialization for retrieving the
* parameters objects associated to this object
*/
public Vector getParameters()
--
To unsubscribe, e-mail: <mailto:jetspeed-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:jetspeed-dev-help@;jakarta.apache.org>