You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by ta...@apache.org on 2006/11/07 21:18:01 UTC
svn commit: r472233 - in /portals/jetspeed-2/trunk:
components/capability/src/java/JETSPEED-INF/ojb/
components/capability/src/java/org/apache/jetspeed/capabilities/impl/
components/capability/src/test/org/apache/jetspeed/capabilities/ etc/sql/
jetspee...
Author: taylor
Date: Tue Nov 7 12:18:00 2006
New Revision: 472233
URL: http://svn.apache.org/viewvc?view=rev&rev=472233
Log:
http://issues.apache.org/jira/browse/JS2-461 - Serializer component
patch from Hajo Birthelmer (hajo@bluesunrise.com)
Enhance Capabilities infrastructure to support full DML operations (insert/update/delete) from API
- bi-directional (ojb) support for all objects including deletes and cascade
updates
- bean factory methods for all objects"
- factory methods enforce uniqueness (by name)
- minor bug fixes
Modified:
portals/jetspeed-2/trunk/components/capability/src/java/JETSPEED-INF/ojb/capabilities_repository.xml
portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/CapabilityImpl.java
portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/CapabilityMapImpl.java
portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/ClientImpl.java
portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java
portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/MediaTypeImpl.java
portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/MimeTypeImpl.java
portals/jetspeed-2/trunk/components/capability/src/test/org/apache/jetspeed/capabilities/TestCapability.java
portals/jetspeed-2/trunk/etc/sql/populate-db-default.sql
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/capabilities/Capabilities.java
portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/capabilities/MediaType.java
portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/capabilities.xml
Modified: portals/jetspeed-2/trunk/components/capability/src/java/JETSPEED-INF/ojb/capabilities_repository.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/capability/src/java/JETSPEED-INF/ojb/capabilities_repository.xml?view=diff&rev=472233&r1=472232&r2=472233
==============================================================================
--- portals/jetspeed-2/trunk/components/capability/src/java/JETSPEED-INF/ojb/capabilities_repository.xml (original)
+++ portals/jetspeed-2/trunk/components/capability/src/java/JETSPEED-INF/ojb/capabilities_repository.xml Tue Nov 7 12:18:00 2006
@@ -63,9 +63,10 @@
name="capabilities"
element-class-ref="org.apache.jetspeed.capabilities.impl.CapabilityImpl"
auto-retrieve="true"
- indirection-table="CLIENT_TO_CAPABILITY"
+ auto-update = "object"
+ indirection-table="MEDIATYPE_TO_CAPABILITY"
>
- <fk-pointing-to-this-class column="CLIENT_ID"/>
+ <fk-pointing-to-this-class column="MEDIATYPE_ID"/>
<fk-pointing-to-element-class column="CAPABILITY_ID"/>
</collection-descriptor>
@@ -73,6 +74,7 @@
name="mimetypes"
element-class-ref="org.apache.jetspeed.capabilities.impl.MimeTypeImpl"
auto-retrieve="true"
+ auto-update = "object"
indirection-table="MEDIATYPE_TO_MIMETYPE"
>
<fk-pointing-to-this-class column="MEDIATYPE_ID"/>
@@ -141,6 +143,8 @@
<collection-descriptor
name="capabilities"
element-class-ref="org.apache.jetspeed.capabilities.impl.CapabilityImpl"
+ auto-retrieve="true"
+ auto-update = "object"
indirection-table="CLIENT_TO_CAPABILITY"
>
@@ -151,8 +155,9 @@
<collection-descriptor
name="mimetypes"
element-class-ref="org.apache.jetspeed.capabilities.impl.MimeTypeImpl"
- auto-retrieve="true"
- indirection-table="CLIENT_TO_MIMETYPE"
+ auto-retrieve="true"
+ auto-update = "object"
+ indirection-table="CLIENT_TO_MIMETYPE"
>
<fk-pointing-to-this-class column="CLIENT_ID"/>
<fk-pointing-to-element-class column="MIMETYPE_ID"/>
Modified: portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/CapabilityImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/CapabilityImpl.java?view=diff&rev=472233&r1=472232&r2=472233
==============================================================================
--- portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/CapabilityImpl.java (original)
+++ portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/CapabilityImpl.java Tue Nov 7 12:18:00 2006
@@ -17,6 +17,7 @@
package org.apache.jetspeed.capabilities.impl;
import org.apache.jetspeed.capabilities.Capability;
+import org.apache.jetspeed.capabilities.MimeType;
/**
* Capability implementation class.
@@ -60,6 +61,48 @@
public String getName()
{
return this.name;
+ }
+
+
+ /**
+ * Implements the hashCode calculation so two different objects with the content return the same hashcode....
+ */
+ public int hashCode()
+ {
+ int h = (name != null?capabilityId*31^(name.length()):capabilityId);
+ return name.hashCode(); //ignore id + h;
+ }
+
+ /**
+ * Implements the equals operation so that 2 elements are equal if
+ * all their member values are equal.
+ *
+ *
+ * @param object to compare this one with
+ * @return true if both objects represent the same (logical) content
+ */
+ public boolean equals(Object object)
+ {
+ if (!(object instanceof Capability))
+ {
+ return false;
+ }
+ if (this == object)
+ return true;
+// Don't check the ID - id is only set through OJB so this would not recognize equality correctly
+ /* if (this.capabilityId != ((Capability)object).getCapabilityId())
+ return false;
+ */
+ String oName = ((Capability)object).getName();
+ if (
+ (oName == null) && (name == null)
+ ||
+ (oName == name)
+ ||
+ ((oName != null) && (oName.equals(name)))
+ )
+ return true;
+ return false;
}
}
Modified: portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/CapabilityMapImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/CapabilityMapImpl.java?view=diff&rev=472233&r1=472232&r2=472233
==============================================================================
--- portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/CapabilityMapImpl.java (original)
+++ portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/CapabilityMapImpl.java Tue Nov 7 12:18:00 2006
@@ -68,8 +68,9 @@
Add capability to the CapabilityMap
*/
public void addCapability(Capability capability)
- {
- this.capabilityMap.put(capability.getName(), capability);
+ {
+ if (capability != null) // avoid null due to duplicates in database
+ this.capabilityMap.put(capability.getName(), capability);
}
/**
@@ -77,6 +78,7 @@
*/
public void addMimetype(MimeType mimetype)
{
+ if (mimetype != null) // avoid null due to duplicates in database
this.mimeTypeMap.put(mimetype.getName(), mimetype);
}
@@ -85,6 +87,7 @@
*/
public void addMediaType(MediaType mediatype)
{
+ if (mediatype != null) // avoid null due to duplicates in database
this.mediaTypeMap.put(mediatype.getName(), mediatype);
}
Modified: portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/ClientImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/ClientImpl.java?view=diff&rev=472233&r1=472232&r2=472233
==============================================================================
--- portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/ClientImpl.java (original)
+++ portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/ClientImpl.java Tue Nov 7 12:18:00 2006
@@ -16,6 +16,7 @@
package org.apache.jetspeed.capabilities.impl;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.jetspeed.capabilities.Client;
import java.util.ArrayList;
@@ -53,13 +54,30 @@
*/
public boolean equals(Object object)
{
+ if (object == this)
+ return true;
+
if (object == null)
{
return false;
}
-
+
ClientImpl obj = (ClientImpl) object;
+ if (name != null)
+ {
+ if (!name.equals(obj.name))
+ {
+ return false;
+ }
+ } else
+ {
+ if (obj.name != null)
+ {
+ return false;
+ }
+ }
+
if (userAgentPattern != null)
{
if (!userAgentPattern.equals(obj.userAgentPattern))
@@ -115,18 +133,34 @@
return false;
}
}
-
- if (!mimetypes.contains(obj.mimetypes))
+ if (mimetypes != null)
{
- return false;
+ if (!CollectionUtils.isEqualCollection(mimetypes, obj.mimetypes))
+ {
+ return false;
+ }
}
-
- if (!capabilities.contains(obj.capabilities))
+ else
{
- return false;
+ if (obj.mimetypes != null)
+ {
+ return false;
+ }
}
- return super.equals(object);
+ if (capabilities != null)
+ {
+ if (!(CollectionUtils.isEqualCollection(capabilities,obj.capabilities )))
+ return false;
+ }
+ else
+ {
+ if (obj.capabilities != null)
+ {
+ return false;
+ }
+ }
+ return true;
}
public String getUserAgentPattern()
Modified: portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java?view=diff&rev=472233&r1=472232&r2=472233
==============================================================================
--- portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java (original)
+++ portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/JetspeedCapabilities.java Tue Nov 7 12:18:00 2006
@@ -34,6 +34,9 @@
import org.apache.ojb.broker.query.Criteria;
import org.apache.ojb.broker.query.QueryByCriteria;
import org.apache.ojb.broker.query.QueryFactory;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
/**
* Jetspeed Capabilities
@@ -42,7 +45,7 @@
* @author <a href="mailto:roger.ruttimann@earthlink.net">Roger Ruttimann</a>
* @version $Id$
*/
-public class JetspeedCapabilities extends InitablePersistenceBrokerDaoSupport implements Capabilities
+public class JetspeedCapabilities extends InitablePersistenceBrokerDaoSupport implements Capabilities ,BeanFactoryAware
{
private String originalAlias;
@@ -58,15 +61,31 @@
private Collection clients = null;
- private Class clientClass = ClientImpl.class;
- private Class capabilityClass = CapabilityImpl.class;
- private Class mimeTypeClass = MimeTypeImpl.class;
- private Class mediaTypeClass = MediaTypeImpl.class;
+ /**
+ * added support for bean factory to create profile rules
+ */
+ private BeanFactory beanFactory;
- public JetspeedCapabilities(String repositoryPath)
+ /** named bean references */
+ private String clientBeanName;
+ private String capabilityBeanName;
+ private String mimeTypeBeanName;
+ private String mediaTypeBeanName;
+
+ private Class clientClass;
+ private Class capabilityClass;
+ private Class mimeTypeClass;
+ private Class mediaTypeClass;
+
+
+ public JetspeedCapabilities(String repositoryPath, String clientBeanName, String mediaTypeBeanName, String mimeTypeBeanName, String capabilityBeanName)
{
super(repositoryPath);
- }
+ this.clientBeanName = clientBeanName;
+ this.capabilityBeanName = capabilityBeanName;
+ this.mimeTypeBeanName = mimeTypeBeanName;
+ this.mediaTypeBeanName = mediaTypeBeanName;
+ }
/**
* Create a JetspeedProfiler with properties. Expected properties are:
@@ -80,41 +99,59 @@
*
* @param persistenceStore The persistence persistenceStore
* @param properties Properties for this component described above
+ * @deprecated As of release 2.1, property-based class references replaced
+ * by container managed bean factory
*/
public JetspeedCapabilities(String repositoryPath, Properties properties)
{
super(repositoryPath);
- initModelClasses(properties);
}
-
- private void initModelClasses(Properties properties)
- {
- String modelName = "";
- try
- {
- if ((modelName = properties.getProperty("client.impl")) != null)
- {
- clientClass = Class.forName(modelName);
- }
- if ((modelName = properties.getProperty("capability.impl")) != null)
- {
- capabilityClass = Class.forName(modelName);
- }
- if ((modelName = properties.getProperty("mimetype.impl")) != null)
- {
- mimeTypeClass = Class.forName(modelName);
- }
- if ((modelName = properties.getProperty("mediatype.impl")) != null)
- {
- mediaTypeClass = Class.forName(modelName);
- }
-
- }
- catch (ClassNotFoundException e)
- {
- log.error("Model class not found: " + modelName);
- }
+ /*
+ * Method called automatically by Spring container upon initialization
+ *
+ * @param beanFactory automatically provided by framework @throws
+ * BeansException
+ */
+ public void setBeanFactory(BeanFactory beanFactory) throws BeansException
+ {
+ this.beanFactory = beanFactory;
}
+
+
+ private Class getClientClass() throws ClassNotFoundException
+ {
+ if (clientClass == null)
+ {
+ clientClass = createClient(null).getClass();
+ }
+ return clientClass;
+ }
+
+ private Class getMimeTypeClass() throws ClassNotFoundException
+ {
+ if (mimeTypeClass == null)
+ {
+ mimeTypeClass = this.createMimeType(null).getClass();
+ }
+ return mimeTypeClass;
+ }
+ private Class getCapabilityClass()throws ClassNotFoundException
+ {
+ if (capabilityClass == null)
+ {
+ capabilityClass = this.createCapability(null).getClass();
+ }
+ return capabilityClass;
+ }
+
+ private Class getMediaTypeClass()throws ClassNotFoundException
+ {
+ if (mediaTypeClass == null)
+ {
+ mediaTypeClass = this.createMediaType(null).getClass();
+ }
+ return mediaTypeClass;
+ }
/**
@@ -307,9 +344,19 @@
{
if (null == clients)
{
- QueryByCriteria query = QueryFactory.newQuery(clientClass, new Criteria());
- query.addOrderByAscending("evalOrder");
- this.clients = getPersistenceBrokerTemplate().getCollectionByQuery(query);
+ try
+ {
+ QueryByCriteria query = QueryFactory.newQuery(getClientClass(), new Criteria());
+ query.addOrderByAscending("evalOrder");
+ this.clients = getPersistenceBrokerTemplate().getCollectionByQuery(query);
+ }
+ catch (Exception e)
+ {
+ String message =
+ "CapabilityServiceImpl: getClients query used invalid class ";
+ log.error(message, e);
+ return null;
+ }
}
return this.clients.iterator();
@@ -340,11 +387,20 @@
Collection co = null;
if (temp.size() > 0)
{
- filter.addIn("mimetypes.name", temp);
- QueryByCriteria query = QueryFactory.newQuery(mediaTypeClass, filter);
- co = getPersistenceBrokerTemplate().getCollectionByQuery(query);
+ try
+ {
+ filter.addIn("mimetypes.name", temp);
+ QueryByCriteria query = QueryFactory.newQuery(getMediaTypeClass(), filter);
+ co = getPersistenceBrokerTemplate().getCollectionByQuery(query);
+ }
+ catch (Exception e)
+ {
+ String message =
+ "CapabilityServiceImpl: getMediaTypesForMimeTypes -> getMediaTypeClass query used invalid class ";
+ log.error(message, e);
+
+ }
}
-
if (co == null || co.isEmpty())
{
MediaType mt = getMediaType("html");
@@ -369,10 +425,20 @@
*/
public MediaType getMediaType(String mediaType)
{
- Criteria filter = new Criteria();
- filter.addEqualTo("name", mediaType);
- QueryByCriteria query = QueryFactory.newQuery(mediaTypeClass, filter);
- return (MediaType) getPersistenceBrokerTemplate().getObjectByQuery(query);
+ try
+ {
+ Criteria filter = new Criteria();
+ filter.addEqualTo("name", mediaType);
+ QueryByCriteria query = QueryFactory.newQuery(getMediaTypeClass(), filter);
+ return (MediaType) getPersistenceBrokerTemplate().getObjectByQuery(query);
+ }
+ catch (Exception e)
+ {
+ String message =
+ "CapabilityServiceImpl: getMediaType query used invalid class ";
+ log.error(message, e);
+ return null;
+ }
}
/**
@@ -383,12 +449,22 @@
public MediaType getMediaTypeForMimeType(String mimeTypeName)
{
//Find the MediaType by matching the Mimetype
-
- Criteria filter = new Criteria();
- filter.addEqualTo("mimetypes.name", mimeTypeName);
-
- QueryByCriteria query = QueryFactory.newQuery(mediaTypeClass, filter);
- Collection mediaTypeCollection = getPersistenceBrokerTemplate().getCollectionByQuery(query);
+ Collection mediaTypeCollection = null;
+ try
+ {
+ Criteria filter = new Criteria();
+ filter.addEqualTo("mimetypes.name", mimeTypeName);
+
+ QueryByCriteria query = QueryFactory.newQuery(getMediaTypeClass(), filter);
+ mediaTypeCollection = getPersistenceBrokerTemplate().getCollectionByQuery(query);
+ }
+ catch (Exception e)
+ {
+ String message =
+ "CapabilityServiceImpl: getMediaTypeForMimeType query used invalid class ";
+ log.error(message, e);
+ return null;
+ }
Iterator mtIterator = mediaTypeCollection.iterator();
if (mtIterator.hasNext())
@@ -406,7 +482,18 @@
*/
public Iterator getCapabilities()
{
- QueryByCriteria query = QueryFactory.newQuery(capabilityClass, new Criteria());
+ QueryByCriteria query = null;
+ try
+ {
+ query = QueryFactory.newQuery(getCapabilityClass(), new Criteria());
+ }
+ catch (Exception e)
+ {
+ String message =
+ "CapabilityServiceImpl: getCapabilities query used invalid class ";
+ log.error(message, e);
+ return null;
+ }
query.addOrderByAscending("name");
return getPersistenceBrokerTemplate().getCollectionByQuery(query).iterator();
}
@@ -417,9 +504,19 @@
*/
public Iterator getMimeTypes()
{
- QueryByCriteria query = QueryFactory.newQuery(mimeTypeClass, new Criteria());
- query.addOrderByAscending("name");
- return getPersistenceBrokerTemplate().getCollectionByQuery(query).iterator();
+ try
+ {
+ QueryByCriteria query = QueryFactory.newQuery(getMimeTypeClass(), new Criteria());
+ query.addOrderByAscending("name");
+ return getPersistenceBrokerTemplate().getCollectionByQuery(query).iterator();
+ }
+ catch (Exception e)
+ {
+ String message =
+ "CapabilityServiceImpl: getMimeTypes query used invalid class ";
+ log.error(message, e);
+ return null;
+ }
}
/**
@@ -428,9 +525,359 @@
*/
public Iterator getMediaTypes()
{
- QueryByCriteria query = QueryFactory.newQuery(mediaTypeClass, new Criteria());
- query.addOrderByAscending("name");
- return getPersistenceBrokerTemplate().getCollectionByQuery(query).iterator();
+ try
+ {
+ QueryByCriteria query = QueryFactory.newQuery(getMediaTypeClass(), new Criteria());
+ query.addOrderByAscending("name");
+ return getPersistenceBrokerTemplate().getCollectionByQuery(query).iterator();
+ }
+ catch (Exception e)
+ {
+ String message =
+ "CapabilityServiceImpl: getMediaTypes query used invalid class ";
+ log.error(message, e);
+ return null;
+ }
+ }
+ /*
+ * @see org.apache.jetspeed.capabilities.Capabilities#getMimeTypeBeanName()
+ */
+ public String getMimeTypeBeanName() {
+ return mimeTypeBeanName;
+ }
+
+ /*
+ * @see org.apache.jetspeed.capabilities.Capabilities#setMimeTypeBeanName(String)
+ */
+ public void setMimeTypeBeanName(String mimeTypeBeanName) {
+ this.mimeTypeBeanName = mimeTypeBeanName;
+ }
+
+ /*
+ * @see org.apache.jetspeed.capabilities.Capabilities#getClientBeanName()
+ */
+ public String getClientBeanName() {
+ return clientBeanName;
+ }
+
+ /*
+ * @see org.apache.jetspeed.capabilities.Capabilities#setClientBeanName(String)
+ */
+ public void setClientBeanName(String clientBeanName) {
+ this.clientBeanName = clientBeanName;
+ }
+
+ /*
+ * @see org.apache.jetspeed.capabilities.Capabilities#getMediaTypeBeanName()
+ */
+ public String getMediaTypeBeanName() {
+ return mediaTypeBeanName;
+ }
+
+ /*
+ * @see org.apache.jetspeed.capabilities.Capabilities#setMediaTypeBeanName(String)
+ */
+ public void setMediaTypeBeanName(String mediaTypeBeanName) {
+ this.mediaTypeBeanName = mediaTypeBeanName;
+ }
+
+ /*
+ * @see org.apache.jetspeed.capabilities.Capabilities#getCapabilityBeanName()
+ */
+ public String getCapabilityBeanName() {
+ return capabilityBeanName;
+ }
+
+ /*
+ * @see org.apache.jetspeed.capabilities.Capabilities#setCapabilityBeanName(String)
+ */
+ public void setCapabilityBeanName(String capabilityBeanName) {
+ this.capabilityBeanName = capabilityBeanName;
+ }
+
+ /*
+ * @see org.apache.jetspeed.capabilities.Capabilities#createMimeType(String)
+ */
+ public MimeType createMimeType(String mimeType)
+ throws ClassNotFoundException
+ {
+ MimeType mimeTypeobj = null;
+ if (mimeType != null)
+ {
+ //try to find it in space
+ mimeTypeobj = this.getMimeType(mimeType);
+ if (mimeTypeobj != null)
+ return mimeTypeobj;
+ }
+ try
+ {
+ mimeTypeobj = (MimeType) beanFactory.getBean(
+ this.mimeTypeBeanName, MimeType.class);
+ mimeTypeobj.setName(mimeType);
+ return mimeTypeobj;
+ } catch (Exception e)
+ {
+ log.error("Failed to create capability instance for " + this.mimeTypeBeanName
+ + " error : " + e.getLocalizedMessage());
+ throw new ClassNotFoundException("Spring failed to create the " + this.mimeTypeBeanName
+ + " mimeType bean.", e);
+ }
+ }
+
+
+ /*
+ * @see org.apache.jetspeed.capabilities.Capabilities#createCapability(String)
+ */
+ public Capability createCapability(String capabilityName) throws ClassNotFoundException
+ {
+ Capability capability = null;
+ if (capabilityName != null)
+ {
+ //try to find it in space
+ capability = this.getCapability(capabilityName);
+ if (capability != null)
+ return capability;
+ }
+ try
+ {
+ capability = (Capability) beanFactory.getBean(
+ this.capabilityBeanName, Capability.class);
+ capability.setName(capabilityName);
+ return capability;
+ } catch (Exception e)
+ {
+ log.error("Failed to create capability instance for " + this.capabilityBeanName
+ + " error : " + e.getLocalizedMessage());
+ throw new ClassNotFoundException("Spring failed to create the "
+ + " capability bean.", e);
+ }
+ }
+
+ /*
+ * @see org.apache.jetspeed.capabilities.Capabilities#createMediaType(String)
+ */
+ public MediaType createMediaType(String mediaTypeName) throws ClassNotFoundException
+ {
+ MediaType mediaType = null;
+ if (mediaTypeName != null)
+ {
+ //try to find it in space
+ mediaType = this.getMediaType(mediaTypeName);
+ if (mediaType != null)
+ return mediaType;
+ }
+ try
+ {
+ mediaType = (MediaType) beanFactory.getBean(
+ this.mediaTypeBeanName, MediaType.class);
+ mediaType.setName(mediaTypeName);
+ return mediaType;
+ } catch (Exception e)
+ {
+ log.error("Failed to create mediaType instance for " + this.mediaTypeBeanName
+ + " error : " + e.getLocalizedMessage());
+ throw new ClassNotFoundException("Spring failed to create the "
+ + " mediaType bean.", e);
+ }
+ }
+
+
+ /*
+ * @see org.apache.jetspeed.capabilities.Capabilities#createClient(String)
+ */
+ public Client createClient(String clientName) throws ClassNotFoundException
+ {
+ Client client = null;
+ if (clientName != null)
+ {
+ //try to find it in space
+ client = this.getClient(clientName);
+ if (client != null)
+ return client;
+ }
+ try
+ {
+ client = (Client) beanFactory.getBean(
+ this.clientBeanName, Client.class);
+ client.setName(clientName);
+ return client;
+ } catch (Exception e)
+ {
+ log.error("Failed to create client instance for " + this.clientBeanName
+ + " error : " + e.getLocalizedMessage());
+ throw new ClassNotFoundException("Spring failed to create the "
+ + " client bean.", e);
+ }
+ }
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.capabilities.MimeTypeservice#getCapability(java.lang.String)
+ */
+ public MimeType getMimeType(String mimeType)
+ {
+ try
+ {
+ Criteria filter = new Criteria();
+ filter.addEqualTo("name", mimeType);
+ QueryByCriteria query = QueryFactory.newQuery(getMimeTypeClass(), filter);
+ return (MimeType) getPersistenceBrokerTemplate().getObjectByQuery(query);
+ }
+ catch (Exception e)
+ {
+ String message =
+ "MimeTypeserviceImpl: getCapability - query for getCapabilityClass failed ";
+ log.error(message, e);
+ return null;
+
+ }
+
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.capabilities.MimeTypeservice#getClientjava.lang.String)
+ */
+ public Client getClient(String clientName)
+ {
+ try
+ {
+ Criteria filter = new Criteria();
+ filter.addEqualTo("name", clientName);
+ QueryByCriteria query = QueryFactory.newQuery(getClientClass(), filter);
+ return (Client) getPersistenceBrokerTemplate().getObjectByQuery(query);
+ }
+ catch (Exception e)
+ {
+ String message =
+ "MimeTypeserviceImpl: getClient - query for getClientClass failed ";
+ log.error(message, e);
+ return null;
+
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.jetspeed.capabilities.MimeTypeservice#getCapability(java.lang.String)
+ */
+ public Capability getCapability(String capability)
+ {
+ try
+ {
+
+ Criteria filter = new Criteria();
+ filter.addEqualTo("name", capability);
+ QueryByCriteria query = QueryFactory.newQuery(getCapabilityClass(), filter);
+ return (Capability) getPersistenceBrokerTemplate().getObjectByQuery(query);
+ }
+ catch (Exception e)
+ {
+ String message =
+ "MimeTypeserviceImpl: getCapability - query for getCapabilityClass failed ";
+ log.error(message, e);
+ return null;
+
+ }
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jetspeed.capabilities.Capabilities#storeMediaType(MediaType)
+ */
+ public void storeMediaType(MediaType mediaType) throws Exception
+ {
+
+ //TODO: change exception to better indicate cause
+ getPersistenceBrokerTemplate().store(mediaType);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jetspeed.capabilities.Capabilities#deleteMediaType(MediaType)
+ */
+ public void deleteMediaType(MediaType mediaType)
+ throws Exception
+ {
+ //TODO: change exception to better indicate cause
+ getPersistenceBrokerTemplate().delete(mediaType);
+ }
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jetspeed.capabilities.Capabilities#storeCapability(MediaType)
+ */
+ public void storeCapability(Capability capability) throws Exception
+ {
+
+ //TODO: change exception to better indicate cause
+ getPersistenceBrokerTemplate().store(capability);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jetspeed.capabilities.Capabilities#deleteCapability(Capability)
+ */
+ public void deleteCapability(Capability capability)
+ throws Exception
+ {
+ //TODO: change exception to better indicate cause
+ getPersistenceBrokerTemplate().delete(capability);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jetspeed.capabilities.Capabilities#storeMimeType(MimeType)
+ */
+ public void storeMimeType(MimeType mimeType) throws Exception
+ {
+
+ //TODO: change exception to better indicate cause
+ getPersistenceBrokerTemplate().store(mimeType);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jetspeed.capabilities.Capabilities#deleteMimeType(MimeType)
+ */
+ public void deleteMimeType(MimeType mimeType)
+ throws Exception
+ {
+ //TODO: change exception to better indicate cause
+ getPersistenceBrokerTemplate().delete(mimeType);
+ }
+
+
+
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jetspeed.capabilities.Capabilities#storeClient(MediaType)
+ */
+ public void storeClient(Client client) throws Exception
+ {
+
+ //TODO: change exception to better indicate cause
+ getPersistenceBrokerTemplate().store(client);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.jetspeed.capabilities.Capabilities#deleteClient(Client)
+ */
+ public void deleteClient(Client client)
+ throws Exception
+ {
+ //TODO: change exception to better indicate cause
+ getPersistenceBrokerTemplate().delete(client);
}
}
Modified: portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/MediaTypeImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/MediaTypeImpl.java?view=diff&rev=472233&r1=472232&r2=472233
==============================================================================
--- portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/MediaTypeImpl.java (original)
+++ portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/MediaTypeImpl.java Tue Nov 7 12:18:00 2006
@@ -15,10 +15,15 @@
*/
package org.apache.jetspeed.capabilities.impl;
-import org.apache.jetspeed.capabilities.MediaType;
-import java.util.Vector;
import java.util.Collection;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.jetspeed.capabilities.Capability;
+import org.apache.jetspeed.capabilities.MediaType;
+import org.apache.jetspeed.capabilities.MimeType;
+
+import tyrex.util.ArraySet;
+
/**
* Default bean like implementation of MediaTypeEntry interface
* suitable for serializing with Castor
@@ -30,7 +35,7 @@
implements MediaType
{
protected String characterSet;
- private Vector capabilities;
+ private Collection capabilities;
private Collection mimetypes;
private int mediatypeId;
private String title;
@@ -59,23 +64,39 @@
*/
public boolean equals(Object object)
{
+ if (this == object)
+ return true;
if (object==null)
- {
return false;
- }
-
+
MediaTypeImpl obj = (MediaTypeImpl)object;
- if (mimetypes.isEmpty()!= true)
+
+ if (this.name!=null)
{
- if ( !mimetypes.contains(obj.getMimetypes().iterator().next()) )
+ if (!name.equals(obj.name))
{
return false;
}
}
else
{
- if (obj.getMimetypes().isEmpty() == false)
+ if (obj.name!=null)
+ {
+ return false;
+ }
+ }
+
+ if (this.description!=null)
+ {
+ if (!description.equals(obj.description))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (obj.description!=null)
{
return false;
}
@@ -96,13 +117,53 @@
}
}
- if (!capabilities.equals(obj.capabilities))
+
+ if (this.title!=null)
{
- return false;
+ if (!title.equals(obj.title))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (obj.title!=null)
+ {
+ return false;
+ }
}
- return super.equals(object);
- }
+
+ if (mimetypes != null)
+ {
+ if (!CollectionUtils.isEqualCollection(mimetypes, obj.mimetypes))
+ {
+ return false;
+ }
+ }
+ else
+ {
+ if (obj.mimetypes != null)
+ {
+ return false;
+ }
+ }
+
+ if (capabilities != null)
+ {
+ if (!(CollectionUtils.isEqualCollection(capabilities,obj.capabilities )))
+ return false;
+ }
+ else
+ {
+ if (obj.capabilities != null)
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
/** @return the character set associated with this MediaType */
@@ -118,16 +179,17 @@
}
- public Vector getCapabilities()
+ public Collection getCapabilities()
{
return this.capabilities;
}
- public void setCapabilities(Vector capabilities)
+ public void setCapabilities(Collection capabilities)
{
this.capabilities = capabilities;
}
+
public Collection getMimetypes()
{
return this.mimetypes;
@@ -137,12 +199,25 @@
{
this.mimetypes = mimetypes;
}
-
- public void addMimetype(String name)
+
+ public void addMimetype(MimeType mimeType)
+ {
+ if (mimetypes == null)
+ mimetypes = new ArraySet();
+ if (!mimetypes.contains(mimeType.getName()))
+ {
+ mimetypes.add(mimeType);
+ }
+ }
+
+
+ public void addCapability(Capability capability)
{
- if (!mimetypes.contains(name))
+ if (capabilities == null)
+ capabilities = new ArraySet();
+ if (!capabilities.contains(capability.getName()))
{
- mimetypes.add(name);
+ capabilities.add(capability);
}
}
Modified: portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/MimeTypeImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/MimeTypeImpl.java?view=diff&rev=472233&r1=472232&r2=472233
==============================================================================
--- portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/MimeTypeImpl.java (original)
+++ portals/jetspeed-2/trunk/components/capability/src/java/org/apache/jetspeed/capabilities/impl/MimeTypeImpl.java Tue Nov 7 12:18:00 2006
@@ -62,4 +62,44 @@
return this.name;
}
+ /**
+ * Implements the hashCode calculation so two different objects with the content return the same hashcode....
+ */
+ public int hashCode()
+ {
+ int h = (name != null?mimeTypeId*31^(name.length()):mimeTypeId);
+ return name.hashCode(); //ignore id: + h;
+ }
+ /**
+ * Implements the equals operation so that 2 elements are equal if
+ * all their member values are equal.
+ *
+ *
+ * @param object to compare this one with
+ * @return true if both objects represent the same (logical) content
+ */
+ public boolean equals(Object object)
+ {
+ if (!(object instanceof MimeType))
+ {
+ return false;
+ }
+ if (this == object)
+ return true;
+// Don't check the ID - id is only set through OJB so this would not recognize equality correctly
+/* if (mimeTypeId != ((MimeType)object).getMimetypeId())
+ return false;
+*/
+ String oName = ((MimeType)object).getName();
+ if (
+ (oName == null) && (name == null)
+ ||
+ (oName == name)
+ ||
+ ((oName != null) && (oName.equals(name)))
+ )
+ return true;
+ return false;
+ }
+
}
Modified: portals/jetspeed-2/trunk/components/capability/src/test/org/apache/jetspeed/capabilities/TestCapability.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/components/capability/src/test/org/apache/jetspeed/capabilities/TestCapability.java?view=diff&rev=472233&r1=472232&r2=472233
==============================================================================
--- portals/jetspeed-2/trunk/components/capability/src/test/org/apache/jetspeed/capabilities/TestCapability.java (original)
+++ portals/jetspeed-2/trunk/components/capability/src/test/org/apache/jetspeed/capabilities/TestCapability.java Tue Nov 7 12:18:00 2006
@@ -16,13 +16,18 @@
package org.apache.jetspeed.capabilities;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.Iterator;
-
-import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
+import java.util.Set;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.apache.jetspeed.components.util.DatasourceEnabledSpringTestCase;
+
+import tyrex.util.ArraySet;
+
/**
* Test Capability Service
*
@@ -175,6 +180,339 @@
}
}
+ private HashMap getCapabilities(int howMany)
+ {
+ Capability capability = null;
+ Iterator _it = capabilities.getCapabilities();
+ HashMap _hash = new HashMap();
+ int count = 0;
+ while (_it.hasNext())
+ {
+ capability = (Capability)_it.next();
+ _hash.put(capability.getName(), capability);
+ count++;
+ if (howMany > 0)
+ if (count >= howMany)
+ return _hash;
+ }
+ return _hash;
+ }
+
+ private HashMap getMimeTypes(int howMany)
+ {
+ MimeType mimeType = null;
+ Iterator _it = capabilities.getMimeTypes();
+ HashMap _hash = new HashMap();
+ int count = 0;
+ while (_it.hasNext())
+ {
+ mimeType = (MimeType)_it.next();
+ _hash.put(mimeType.getName(), mimeType);
+ count++;
+ if (howMany > 0)
+ if (count >= howMany)
+ return _hash;
+ }
+ return _hash;
+ }
+
+ public void testNewMimeType() throws Exception
+ {
+ MimeType mimeType = null;
+ Iterator _it = null;
+ HashMap _hash = getMimeTypes(0);
+ int count = _hash.size();
+ assertTrue("MimeTypes do not exist", (count > 0));
+
+ _it = _hash.keySet().iterator();
+
+ int pos = count/2;
+
+ for (int i = 0; i < pos; i++)
+ _it.next();
+
+ String existingKey = (String)_it.next();
+ MimeType existingObject = (MimeType)_hash.get(existingKey);
+ assertNotNull("Couldn't identify existing mime object to run test",existingObject);
+
+
+ // "create" existing one
+ mimeType = capabilities.createMimeType(existingKey);
+ assertNotNull("creating 'existing' mimetype returns null", mimeType);
+ assertTrue("creating 'existing' mimetype didn't return existing object", (mimeType.equals(existingObject)));
+
+ // create a new one:
+ mimeType = capabilities.createMimeType("TEST MIME TYPE");
+ assertNotNull("creating new mimetype returns null", mimeType);
+
+ // ensure it doesn't exist in the capabilities
+ Set existing = _hash.entrySet();
+ assertTrue("creating new mimetype already in existing list", (!(existing.contains(mimeType))));
+
+ existingObject = capabilities.getMimeType("TEST MIME TYPE");
+ assertNull("creating new mimetype already in existing capabilities",existingObject);
+
+ capabilities.storeMimeType(mimeType);
+ existingObject = capabilities.getMimeType("TEST MIME TYPE");
+ assertNotNull("creating and saving new mimetype didn't store object",existingObject);
+
+
+ capabilities.deleteMimeType(mimeType);
+ existingObject = capabilities.getMimeType("TEST MIME TYPE");
+ assertNull("creating new mimetype delete from storage didn't work",existingObject);
+
+ }
+
+
+
+
+
+ public void testNewCapability() throws Exception
+ {
+ Capability capability = null;
+ Iterator _it = null;
+ HashMap _hash = getCapabilities(0);
+ int count = _hash.size();
+ assertTrue("Capabilitys do not exist", (count > 0));
+
+ _it = _hash.keySet().iterator();
+
+ int pos = count/2;
+
+ for (int i = 0; i < pos; i++)
+ _it.next();
+
+ String existingKey = (String)_it.next();
+ Capability existingObject = (Capability)_hash.get(existingKey);
+ assertNotNull("Couldn't identify existing mime object to run test",existingObject);
+
+
+ // "create" existing one
+ capability = capabilities.createCapability(existingKey);
+ assertNotNull("creating 'existing' capability returns null", capability);
+ assertTrue("creating 'existing' capability didn't return existing object", (capability.equals(existingObject)));
+
+ // create a new one:
+ capability = capabilities.createCapability("TEST CAPABILITY TYPE");
+ assertNotNull("creating new capability returns null", capability);
+
+ // ensure it doesn't exist in the capabilities
+ Set existing = _hash.entrySet();
+ assertTrue("creating new capability already in existing list", (!(existing.contains(capability))));
+
+ existingObject = capabilities.getCapability("TEST CAPABILITY TYPE");
+ assertNull("creating new capability already in existing capabilities",existingObject);
+
+ capabilities.storeCapability(capability);
+ existingObject = capabilities.getCapability("TEST CAPABILITY TYPE");
+ assertNotNull("creating and saving new capability didn't store object",existingObject);
+
+
+ capabilities.deleteCapability(capability);
+ existingObject = capabilities.getCapability("TEST CAPABILITY TYPE");
+ assertNull("creating new capability delete from storage didn't work",existingObject);
+
+ }
+
+
+
+ public void testNewMediaType() throws Exception
+ {
+ MediaType mediaType = null;
+ Iterator _it = capabilities.getMediaTypes();
+ HashMap _hash = new HashMap();
+ int count = 0;
+ while (_it.hasNext())
+ {
+ mediaType = (MediaType)_it.next();
+ _hash.put(mediaType.getName(), mediaType);
+ count++;
+ }
+ assertTrue("Mediatypes do not exist", (count > 0));
+
+ _it = _hash.keySet().iterator();
+
+ int pos = count/2;
+
+ for (int i = 0; i < pos; i++)
+ _it.next();
+
+ String existingKey = (String)_it.next();
+ MediaType existingObject = (MediaType)_hash.get(existingKey);
+ assertNotNull("Couldn't identify existing object to run test",existingObject);
+
+
+ // "create" existing one
+ mediaType = capabilities.createMediaType(existingKey);
+ assertNotNull("creating 'existing' mediatype returns null", mediaType);
+ assertTrue("creating 'existing' mediatype didn't return existing object", (mediaType.equals(existingObject)));
+
+
+ // setting fields
+ String name = "TEST MEDIA TYPE";
+ String utf = "UTF-8";
+ String title = "TEST MEDIA TYPE - Title";
+ String description = "TEST MEDIA TYPE - Description";
+
+ int numCapabilities = 2;
+ int numMimeTypes = 3;
+
+ HashMap someCapabilities = getCapabilities(numCapabilities);
+ HashMap someMimeTypes = getMimeTypes(numMimeTypes);
+
+
+
+ // create a new one:
+ mediaType = capabilities.createMediaType(name);
+ assertNotNull("creating new mediatype returns null", mediaType);
+
+ // ensure it doesn't exist in the capabilities
+ Set existing = _hash.entrySet();
+ assertTrue("creating new mediaType already in existing list", (!(existing.contains(mediaType))));
+
+ existingObject = capabilities.getMediaType(name);
+ assertNull("creating new mediaType already in existing capabilities",existingObject);
+
+
+// set object fields
+ mediaType.setCharacterSet(utf);
+ mediaType.setTitle(title);
+ mediaType.setDescription(description);
+
+ _it = someMimeTypes.values().iterator();
+ int added = 0;
+ while (_it.hasNext())
+ {
+ mediaType.addMimetype((MimeType)_it.next());
+ added++;
+ }
+ assertTrue("number of Mimetypes added (" + added + ") not the same as expected ("+numMimeTypes+")",(added==numMimeTypes));
+
+ // setting links:
+
+
+ ArraySet set = new ArraySet(someCapabilities.values());
+ mediaType.setCapabilities(set);
+ assertTrue("number of Capabilities added (" + set.size() + ") not the same as expected ("+numCapabilities+")",(set.size()==numCapabilities));
+
+ capabilities.storeMediaType(mediaType);
+ existingObject = capabilities.getMediaType(name);
+ assertNotNull("creating and saving new mediaType didn't store object",existingObject);
+
+ capabilities.deleteMediaType(mediaType);
+ existingObject = capabilities.getMediaType(name);
+ assertNull("creating new mediaType delete from storage didn't work",existingObject);
+
+
+
+
+
+ }
+
+
+
+ public void testNewClient() throws Exception
+ {
+ Client client = null;
+ Iterator _it = capabilities.getClients();
+ HashMap _hash = new HashMap();
+ int count = 0;
+ while (_it.hasNext())
+ {
+ client = (Client)_it.next();
+ _hash.put(client.getName(), client);
+ count++;
+ }
+ assertTrue("Clients do not exist", (count > 0));
+
+ _it = _hash.keySet().iterator();
+
+ int pos = count/2;
+
+ for (int i = 0; i < pos; i++)
+ _it.next();
+
+ String existingKey = (String)_it.next();
+ Client existingObject = (Client)_hash.get(existingKey);
+ assertNotNull("Couldn't identify existing object to run test",existingObject);
+
+
+ // "create" existing one
+ client = capabilities.createClient(existingKey);
+ assertNotNull("creating 'existing' client returns null", client);
+ assertTrue("creating 'existing' client didn't return existing object", (client.equals(existingObject)));
+
+
+ // setting fields
+
+ String name = "TEST CLIENT";
+ int preferredMimeTypeId = 2;
+
+ int evalOrder = 0;
+
+ int numCapabilities = 3;
+ int numMimeTypes = 4;
+
+ HashMap someCapabilities = getCapabilities(numCapabilities);
+ HashMap someMimeTypes = getMimeTypes(numMimeTypes);
+
+ // create a new one:
+ client = capabilities.createClient(name);
+ assertNotNull("creating new client returns null", client);
+
+ // ensure it doesn't exist in the capabilities
+ Set existing = _hash.entrySet();
+ assertTrue("creating new client already in existing list", (!(existing.contains(client))));
+
+ existingObject = capabilities.getClient(name);
+ assertNull("creating new client already in existing capabilities",existingObject);
+
+ String userAgentPattern = "TEST.*|TESTBROWSER.*";
+ String manufacturer = "Test Manufacturer";
+ String model = "XYZ";
+ String version = "1.0";
+
+// set object fields
+ client.setUserAgentPattern(userAgentPattern);
+ client.setManufacturer(manufacturer);
+ client.setModel(model);
+
+ ArraySet set = new ArraySet(someCapabilities.values());
+ client.setCapabilities(set);
+ assertTrue("number of Capabilities added (" + set.size() + ") not the same as expected ("+numCapabilities+")",(set.size()==numCapabilities));
+
+ set = new ArraySet(someMimeTypes.values());
+ client.setCapabilities(set);
+ assertTrue("number of MimeTypes added (" + set.size() + ") not the same as expected ("+numCapabilities+")",(set.size()==numMimeTypes));
+
+
+ // setting links:
+
+
+
+ capabilities.storeClient(client);
+ existingObject = capabilities.getClient(name);
+ assertNotNull("creating and saving new client didn't store object",existingObject);
+
+ capabilities.deleteClient(client);
+ existingObject = capabilities.getClient(name);
+ assertNull("creating new client delete from storage didn't work",existingObject);
+
+
+
+
+
+ }
+
+
+
+ public void testCapabilityRepeat() throws Exception
+ {
+ capabilities.deleteCapabilityMapCache();
+ testCapability();
+ }
+
+
protected String[] getConfigurations()
{
return new String[]
Modified: portals/jetspeed-2/trunk/etc/sql/populate-db-default.sql
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/etc/sql/populate-db-default.sql?view=diff&rev=472233&r1=472232&r2=472233
==============================================================================
--- portals/jetspeed-2/trunk/etc/sql/populate-db-default.sql (original)
+++ portals/jetspeed-2/trunk/etc/sql/populate-db-default.sql Tue Nov 7 12:18:00 2006
@@ -52,7 +52,6 @@
INSERT INTO CAPABILITY (CAPABILITY_ID, CAPABILITY) VALUES(21,'HTML_PLUGIN');
INSERT INTO CAPABILITY (CAPABILITY_ID, CAPABILITY) VALUES(22,'HTML_ACTIVEX');
-INSERT INTO CAPABILITY (CAPABILITY_ID, CAPABILITY) VALUES(23,'HTML_PLUGIN');
INSERT INTO CAPABILITY (CAPABILITY_ID, CAPABILITY) VALUES(24,'HTML_CSS1');
INSERT INTO CAPABILITY (CAPABILITY_ID, CAPABILITY) VALUES(25,'HTML_CSS2');
@@ -218,7 +217,7 @@
INSERT INTO CLIENT_TO_CAPABILITY(CLIENT_ID,CAPABILITY_ID )VALUES(3,25);
INSERT INTO CLIENT_TO_CAPABILITY(CLIENT_ID,CAPABILITY_ID )VALUES(3,26);
INSERT INTO CLIENT_TO_CAPABILITY(CLIENT_ID,CAPABILITY_ID )VALUES(3,31);
-INSERT INTO CLIENT_TO_CAPABILITY(CLIENT_ID,CAPABILITY_ID )VALUES(3,23);
+INSERT INTO CLIENT_TO_CAPABILITY(CLIENT_ID,CAPABILITY_ID )VALUES(3,21);
INSERT INTO CLIENT_TO_CAPABILITY(CLIENT_ID,CAPABILITY_ID )VALUES(3,40);
INSERT INTO CLIENT_TO_CAPABILITY(CLIENT_ID,CAPABILITY_ID )VALUES(4,3);
@@ -243,7 +242,7 @@
INSERT INTO CLIENT_TO_CAPABILITY(CLIENT_ID,CAPABILITY_ID )VALUES(14,26);
INSERT INTO CLIENT_TO_CAPABILITY(CLIENT_ID,CAPABILITY_ID )VALUES(14,31);
INSERT INTO CLIENT_TO_CAPABILITY(CLIENT_ID,CAPABILITY_ID )VALUES(14,40);
-INSERT INTO CLIENT_TO_CAPABILITY(CLIENT_ID,CAPABILITY_ID )VALUES(14,23);
+INSERT INTO CLIENT_TO_CAPABILITY(CLIENT_ID,CAPABILITY_ID )VALUES(14,21);
INSERT INTO CLIENT_TO_CAPABILITY(CLIENT_ID,CAPABILITY_ID )VALUES(15,1);
INSERT INTO CLIENT_TO_CAPABILITY(CLIENT_ID,CAPABILITY_ID )VALUES(15,8);
Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/capabilities/Capabilities.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/capabilities/Capabilities.java?view=diff&rev=472233&r1=472232&r2=472233
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/capabilities/Capabilities.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/capabilities/Capabilities.java Tue Nov 7 12:18:00 2006
@@ -80,6 +80,29 @@
public MediaType getMediaTypeForMimeType(String mimeTypeName);
/**
+ * Given a capability string, look up the corresponding capability object.
+ *
+ * @param capability The string representation of a capability.
+ * @return The found capability object or if not found, null.
+ */
+ Capability getCapability(String capability);
+
+ /**
+ * Given a mime type string, look up the corresponding mime type object.
+ *
+ * @param mimeType The string representation of a mime type.
+ * @return The found mime type object or if not found, null.
+ */
+ MimeType getMimeType(String mimeType);
+ /**
+ * Given a client name, look up the corresponding client object.
+ *
+ * @param clientName The name of the client.
+ * @return The found client object or if not found, null.
+ */
+ Client getClient(String clientName);
+
+ /**
* Obtain an iterator of all existing capabilities.
* @return Returns an iterator for all existing Capabilities of type <code>Capability</code>
*/
@@ -96,5 +119,152 @@
* @return Returns an iterator for all existing media types of type <code>MediaType</code>
*/
Iterator getMediaTypes();
-
+
+
+ /**
+ * Obtain the name of the CapabilityBean reference
+ * @return ref-id of the capability bean
+ */
+ public String getCapabilityBeanName();
+
+ /**
+ * Set the name of the CapabilityBean reference - used exclusively in IoC
+ * @param capabilityBeanName The ref-id of the capability bean.
+ */
+ public void setCapabilityBeanName(String capabilityBeanName);
+
+
+ /**
+ * Obtain the name of the ClientBean reference
+ * @return ref-id of the client bean
+ */
+ public String getClientBeanName();
+
+ /**
+ * Set the name of the ClientBean reference - used exclusively in IoC
+ * @param clientBeanName The ref-id of the client bean.
+ */
+ public void setClientBeanName(String clientBeanName);
+
+ /**
+ * Obtain the name of the Media Type reference
+ * @return ref-id of the media type bean
+ */
+ public String getMediaTypeBeanName();
+
+ /**
+ * Set the name of the MediaType bean reference - used exclusively in IoC
+ * @param mediaTypeBeanName The ref-id of the mediaType bean.
+ */
+ public void setMediaTypeBeanName(String mediaTypeBeanName);
+
+ /**
+ * Obtain the name of the Mime Type reference
+ * @return ref-id of the mime type bean
+ */
+ public String getMimeTypeBeanName();
+
+ /**
+ * Set the name of the MimeType bean reference - used exclusively in IoC
+ * @param mimeTypeBeanName The ref-id of the mimeType bean.
+ */
+ public void setMimeTypeBeanName(String mimeTypeBeanName);
+
+
+ /**
+ * Create a new capability in the system or return the existing one if already exists
+ * @param capabilityName The string describing the capability
+ * @return A new (or existing) capability
+ */
+ public Capability createCapability(String capabilityName) throws ClassNotFoundException;
+
+
+ /**
+ * Create a new mimetype in the system or return the existing one if already exists
+ * @param mimeTypeName The string describing the mimeType
+ * @return A new (or existing) MimeType
+ */
+ public MimeType createMimeType(String mimeTypeName)throws ClassNotFoundException;
+
+ /**
+ * Create a new mediaType in the system or return the existing one if already exists
+ * @param mediaTypeName The string describing the mediaType
+ * @return A new (or existing) MediaType
+ */
+ public MediaType createMediaType(String mediaTypeName)throws ClassNotFoundException;
+
+ /**
+ * Create a new client in the system or return the existing one if already exists
+ * @param clientName The string describing the client
+ * @return A new (or existing) client
+ */
+ public Client createClient(String clientName)throws ClassNotFoundException;
+
+
+
+ /**
+ * Save media type to backend storage
+ *
+ * @param mediaType valid mediatype object
+ */
+ public void storeMediaType(MediaType mediaType) throws Exception;
+ //TODO: change exception to better indicate cause
+
+ /**
+ * delete existing media type from backend storage
+ *
+ * @param mediaType valid mediatype object
+ */
+ public void deleteMediaType(MediaType mediaType)
+ throws Exception;
+
+
+ /**
+ * Save capability to backend storage
+ *
+ * @param capability valid capability object
+ */
+ public void storeCapability(Capability capability) throws Exception;
+
+ /**
+ * delete existing capability from backend storage
+ *
+ * @param capability valid capability object
+ */
+ public void deleteCapability(Capability capability)
+ throws Exception;
+
+ /**
+ * Save mime type to backend storage
+ *
+ * @param mimeType valid mimetype object
+ */
+ public void storeMimeType(MimeType mimeType) throws Exception;
+ //TODO: change exception to better indicate cause
+
+ /**
+ * delete existing mime type from backend storage
+ *
+ * @param mimeType valid mimetype object
+ */
+ public void deleteMimeType(MimeType mimeType)
+ throws Exception;
+
+
+
+ /**
+ * Save client to backend storage
+ *
+ * @param client valid Client object
+ */
+ public void storeClient(Client client) throws Exception;
+
+ /**
+ * delete existing client from backend storage
+ *
+ * @param client valid client object
+ */
+ public void deleteClient(Client client)
+ throws Exception;
+
}
Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/capabilities/MediaType.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/capabilities/MediaType.java?view=diff&rev=472233&r1=472232&r2=472233
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/capabilities/MediaType.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/capabilities/MediaType.java Tue Nov 7 12:18:00 2006
@@ -53,15 +53,15 @@
* The <CODE>CapabilityMap</CODE> contains all capabilities in arbitrary
* order.
*
- * @return a vector of capabilities
+ * @return a collection of capabilities
*/
- public Vector getCapabilities();
+ public Collection getCapabilities();
/**
* Set the capabilities
* @param vector of capabilities
*/
- public void setCapabilities(Vector capabilities);
+ public void setCapabilities(Collection capabilities);
/**
* Returns all supported mimetypes as <CODE>MimeTypeMap</CODE>.
@@ -89,9 +89,24 @@
/**
* Add MimeType to the MimeType map
* @param name
- */
+
public void addMimetype(String name);
-
+ */
+ /**
+ * Add MimeType to the MimeType map
+ * @param mimeType mimetype object to add
+ */
+ public void addMimetype(MimeType mimeType);
+
+
+ /**
+ * Add Capability to the Capability collection
+ * @param capability capability object to add
+ */
+ public void addCapability(Capability capability);
+
+
+
/**
* Set Name of MediaType
* @param name Name of MediaType
Modified: portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/capabilities.xml
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/capabilities.xml?view=diff&rev=472233&r1=472232&r2=472233
==============================================================================
--- portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/capabilities.xml (original)
+++ portals/jetspeed-2/trunk/src/webapp/WEB-INF/assembly/capabilities.xml Tue Nov 7 12:18:00 2006
@@ -19,9 +19,21 @@
<!-- Capabilities DAO-->
<bean id="capabilitiesImpl" class="org.apache.jetspeed.capabilities.impl.JetspeedCapabilities" init-method="init">
- <constructor-arg>
+ <constructor-arg index="0">
<value>JETSPEED-INF/ojb/capabilities_repository.xml</value>
</constructor-arg>
+ <constructor-arg index="1">
+ <value>Client</value>
+ </constructor-arg>
+ <constructor-arg index="2">
+ <value>MediaType</value>
+ </constructor-arg>
+ <constructor-arg index="3">
+ <value>MimeType</value>
+ </constructor-arg>
+ <constructor-arg index="4">
+ <value>Capability</value>
+ </constructor-arg>
</bean>
<!-- Capabilities -->
@@ -39,4 +51,19 @@
</property>
</bean>
+
+ <!-- Capability related content -->
+
+ <!-- Client -->
+ <bean id="Client" class="org.apache.jetspeed.capabilities.impl.ClientImpl" singleton="false"></bean>
+
+ <!-- MediaType -->
+ <bean id="MediaType" class="org.apache.jetspeed.capabilities.impl.MediaTypeImpl" singleton="false"></bean>
+
+ <!-- MimeType -->
+ <bean id="MimeType" class="org.apache.jetspeed.capabilities.impl.MimeTypeImpl" singleton="false"></bean>
+
+ <!-- Capability -->
+ <bean id="Capability" class="org.apache.jetspeed.capabilities.impl.CapabilityImpl" singleton="false"></bean>
+
</beans>
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org