You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by Jean-Philippe Courson <co...@noos.fr> on 2002/04/18 16:26:37 UTC
[PATCH] SLIDE_1_0 : ContentInterceptors enhancements
Hi,
To facilitate their review/commit, I have put in one email the
generic ContentInterceptor enhancements I posted earlier and I will
try to explain them.
These patches need to be applied successively.
Patch 1 : ContentInterceptors parameters support
(file 1-contentInterceptorsParameters.diff)
This patch :
- Makes ContentInterceptor class abstract
- Modifies ContentInterceptor class to add a new property (Hashtable
parameters) and its accessor and modifier to store optionnal parameters.
- Modifies at the same time NamespaceConfig class to read these
optionnal ContentInterceptor parameters from Domain.xml.
Syntax to add parameters to a ContentInterceptor in Domain.xml is the
following :
<content-interceptor class="...">
<parameter name="...">...</parameter>
...
</content-interceptor>
Patch 2 : ContentInterceptors postRemove() method
(file 2-contentInterceptorsPostRemove.diff)
This patch adds a new postRemove() method to ContentInterceptor class
and its calls from ContentImpl class
Patch 3 : ContentInterceptors namespace access
(file 3-contentInterceptorsNamespaceArg.diff)
This patch adds a Namespace object to ContentInterceptors methods to
allow them namespace access.
Patch 4 : ContentInterceptors exceptions support
(file 4-contentInterceptorsExceptions.diff)
This patch adds ContentInterceptors the ability to throw exceptions if a
problem occurs
I think that these enhancements feet with Slide's extendability which
seems to be one of the project goal.
If I can do something else to facilitate their review/commit, do not
hesitate to ask me.
Regards
JP
ps : tomorrow, I will send user-quota support patches
Re: [PATCH] SLIDE_1_0 : ContentInterceptors enhancements
Posted by Jean-Philippe Courson <co...@noos.fr>.
Please ignore in my last patch
diff -r -u
slide_1_0_Quota_3_add_namespace_arg/src/share/org/apache/slide/content/UserQuotaContentInterceptor.java
slide_1_0_Quota_4_exceptions/src/share/org/apache/slide/content/UserQuotaContentInterceptor.java
which was a test ContentInterceptor
Sorry
JP
Jean-Philippe Courson wrote:
> Hi,
>
> To facilitate their review/commit, I have put in one email the
> generic ContentInterceptor enhancements I posted earlier and I will
> try to explain them.
>
> These patches need to be applied successively.
>
>
> Patch 1 : ContentInterceptors parameters support
> (file 1-contentInterceptorsParameters.diff)
>
> This patch :
> - Makes ContentInterceptor class abstract
> - Modifies ContentInterceptor class to add a new property (Hashtable
> parameters) and its accessor and modifier to store optionnal parameters.
> - Modifies at the same time NamespaceConfig class to read these
> optionnal ContentInterceptor parameters from Domain.xml.
>
> Syntax to add parameters to a ContentInterceptor in Domain.xml is the
> following :
>
> <content-interceptor class="...">
> <parameter name="...">...</parameter>
> ...
> </content-interceptor>
>
>
> Patch 2 : ContentInterceptors postRemove() method
> (file 2-contentInterceptorsPostRemove.diff)
>
> This patch adds a new postRemove() method to ContentInterceptor class
> and its calls from ContentImpl class
>
>
> Patch 3 : ContentInterceptors namespace access
> (file 3-contentInterceptorsNamespaceArg.diff)
>
> This patch adds a Namespace object to ContentInterceptors methods to
> allow them namespace access.
>
>
> Patch 4 : ContentInterceptors exceptions support
> (file 4-contentInterceptorsExceptions.diff)
>
> This patch adds ContentInterceptors the ability to throw exceptions if a
> problem occurs
>
>
> I think that these enhancements feet with Slide's extendability which
> seems to be one of the project goal.
>
> If I can do something else to facilitate their review/commit, do not
> hesitate to ask me.
>
> Regards
>
> JP
>
> ps : tomorrow, I will send user-quota support patches
>
>
> ------------------------------------------------------------------------
>
> diff -r -u slide_1_0/src/share/org/apache/slide/common/NamespaceConfig.java slide_1_0_Quota_1_parameters/src/share/org/apache/slide/common/NamespaceConfig.java
> --- slide_1_0/src/share/org/apache/slide/common/NamespaceConfig.java Thu Apr 18 14:23:54 2002
> +++ slide_1_0_Quota_1_parameters/src/share/org/apache/slide/common/NamespaceConfig.java Mon Apr 8 09:40:03 2002
> @@ -820,12 +820,26 @@
> Configuration contentInterceptorDef =
> (Configuration) contentInteceptorsDef.nextElement();
> String classname = contentInterceptorDef.getAttribute("class");
> +
> + // Load contentInterceptor parameters
> + Enumeration contentInterceptorParametersDef =
> + contentInterceptorDef.getConfigurations("parameter");
> + Hashtable contentInterceptorParameters = new Hashtable();
> + while (contentInterceptorParametersDef.hasMoreElements()) {
> + Configuration parameterDefinition = (Configuration)
> + contentInterceptorParametersDef.nextElement();
> + String parameterName = parameterDefinition.getAttribute("name");
> + String parameterValue = parameterDefinition.getValue();
> + contentInterceptorParameters.put(parameterName, parameterValue);
> + }
> +
> try {
> Class contentInterceptorClass =
> Class.forName(classname);
> ContentInterceptor contentInterceptor =
> (ContentInterceptor)
> contentInterceptorClass.newInstance();
> + contentInterceptor.setParameters(contentInterceptorParameters);
> ContentInterceptor[] tempArray =
> new ContentInterceptor[contentInterceptors.length + 1];
> for (int i = 0; i < contentInterceptors.length; i++) {
> diff -r -u slide_1_0/src/share/org/apache/slide/content/ContentInterceptor.java slide_1_0_Quota_1_parameters/src/share/org/apache/slide/content/ContentInterceptor.java
> --- slide_1_0/src/share/org/apache/slide/content/ContentInterceptor.java Thu Apr 18 14:23:54 2002
> +++ slide_1_0_Quota_1_parameters/src/share/org/apache/slide/content/ContentInterceptor.java Mon Apr 8 09:40:03 2002
> @@ -71,9 +71,42 @@
> *
> * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
> */
> -public class ContentInterceptor {
> +public abstract class ContentInterceptor {
>
>
> + // ----------------------------------------------------- Instance Variables
> +
> +
> + /**
> + * ContentInterceptor's parameters.
> + */
> + private Hashtable parameters;
> +
> +
> + // ------------------------------------------------------------- Properties
> +
> +
> + /**
> + * Parameters accessor.
> + *
> + * @return Hashtable Parameters
> + */
> + public Hashtable getParameters() {
> + return parameters;
> + }
> +
> +
> + /**
> + * Parameters modifier.
> + *
> + * @param parameters Hashtable containing the parameters' name
> + * and associated value
> + */
> + public void setParameters(Hashtable parameters) {
> + this.parameters = parameters;
> + }
> +
> +
> // ---------------------------------------------------------------- Methods
>
>
>
>
> ------------------------------------------------------------------------
>
> diff -r -u slide_1_0_Quota_1_parameters/src/share/org/apache/slide/content/ContentImpl.java slide_1_0_Quota_2_postRemove/src/share/org/apache/slide/content/ContentImpl.java
> --- slide_1_0_Quota_1_parameters/src/share/org/apache/slide/content/ContentImpl.java Mon Apr 8 09:40:03 2002
> +++ slide_1_0_Quota_2_postRemove/src/share/org/apache/slide/content/ContentImpl.java Mon Apr 8 13:48:33 2002
> @@ -88,7 +88,8 @@
> protected static final int PRE_STORE = 0;
> protected static final int POST_STORE = 1;
> protected static final int POST_RETRIEVE = 2;
> -
> + protected static final int POST_REMOVE = 3;
> +
>
> // ----------------------------------------------------------- Constructors
>
> @@ -982,6 +983,9 @@
>
> objectUri.getStore().removeRevisionDescriptors(objectUri);
>
> + // Invoke interceptors
> + invokeInterceptors(token, revisionDescriptors, null, null, POST_REMOVE);
> +
> }
>
>
> @@ -1041,6 +1045,9 @@
> (objectUri, revisionDescriptor);
> objectUri.getStore()
> .removeRevisionDescriptor(objectUri, revisionNumber);
> +
> + // Invoke interceptors
> + invokeInterceptors(token, null, revisionDescriptor, null, POST_REMOVE);
>
> }
>
> @@ -1206,6 +1213,11 @@
> contentInterceptors[i].postRetrieveContent
> (token, revisionDescriptors,
> revisionDescriptor, revisionContent);
> + break;
> + case POST_REMOVE:
> + contentInterceptors[i].postRemoveContent
> + (token, revisionDescriptors,
> + revisionDescriptor);
> break;
> }
> }
> diff -r -u slide_1_0_Quota_1_parameters/src/share/org/apache/slide/content/ContentInterceptor.java slide_1_0_Quota_2_postRemove/src/share/org/apache/slide/content/ContentInterceptor.java
> --- slide_1_0_Quota_1_parameters/src/share/org/apache/slide/content/ContentInterceptor.java Mon Apr 8 09:40:03 2002
> +++ slide_1_0_Quota_2_postRemove/src/share/org/apache/slide/content/ContentInterceptor.java Mon Apr 8 13:35:08 2002
> @@ -141,6 +141,18 @@
> NodeRevisionDescriptor revisionDescriptor,
> NodeRevisionContent revisionContent) {
> }
> -
> +
> +
> + /**
> + * That method will be called just after removing content.
> + *
> + * @param revisionDescriptors null when a specified revision is removed
> + * @param revisionDescriptor null when all revisions are removed
> + */
> + public void postRemoveContent
> + (SlideToken token, NodeRevisionDescriptors revisionDescriptors,
> + NodeRevisionDescriptor revisionDescriptor) {
> + }
> +
>
> }
>
>
> ------------------------------------------------------------------------
>
> diff -r -u slide_1_0_Quota_2_postRemove/src/share/org/apache/slide/content/ContentImpl.java slide_1_0_Quota_3_add_namespace_arg/src/share/org/apache/slide/content/ContentImpl.java
> --- slide_1_0_Quota_2_postRemove/src/share/org/apache/slide/content/ContentImpl.java Mon Apr 8 13:48:33 2002
> +++ slide_1_0_Quota_3_add_namespace_arg/src/share/org/apache/slide/content/ContentImpl.java Mon Apr 8 13:53:11 2002
> @@ -1202,22 +1202,25 @@
> case PRE_STORE:
> contentInterceptors[i].preStoreContent
> (token, revisionDescriptors,
> - revisionDescriptor, revisionContent);
> + revisionDescriptor, revisionContent,
> + namespace);
> break;
> case POST_STORE:
> contentInterceptors[i].postStoreContent
> (token, revisionDescriptors,
> - revisionDescriptor, revisionContent);
> + revisionDescriptor, revisionContent,
> + namespace);
> break;
> case POST_RETRIEVE:
> contentInterceptors[i].postRetrieveContent
> (token, revisionDescriptors,
> - revisionDescriptor, revisionContent);
> + revisionDescriptor, revisionContent,
> + namespace);
> break;
> case POST_REMOVE:
> contentInterceptors[i].postRemoveContent
> (token, revisionDescriptors,
> - revisionDescriptor);
> + revisionDescriptor, namespace);
> break;
> }
> }
> diff -r -u slide_1_0_Quota_2_postRemove/src/share/org/apache/slide/content/ContentInterceptor.java slide_1_0_Quota_3_add_namespace_arg/src/share/org/apache/slide/content/ContentInterceptor.java
> --- slide_1_0_Quota_2_postRemove/src/share/org/apache/slide/content/ContentInterceptor.java Mon Apr 8 13:35:08 2002
> +++ slide_1_0_Quota_3_add_namespace_arg/src/share/org/apache/slide/content/ContentInterceptor.java Mon Apr 8 13:58:04 2002
> @@ -64,6 +64,7 @@
> package org.apache.slide.content;
>
> import java.util.Hashtable;
> +import org.apache.slide.common.Namespace;
> import org.apache.slide.common.SlideToken;
>
> /**
> @@ -116,7 +117,8 @@
> public void preStoreContent(SlideToken token,
> NodeRevisionDescriptors revisionDescriptors,
> NodeRevisionDescriptor revisionDescriptor,
> - NodeRevisionContent revisionContent) {
> + NodeRevisionContent revisionContent,
> + Namespace namespace) {
> }
>
>
> @@ -126,7 +128,8 @@
> public void postStoreContent(SlideToken token,
> NodeRevisionDescriptors revisionDescriptors,
> NodeRevisionDescriptor revisionDescriptor,
> - NodeRevisionContent revisionContent) {
> + NodeRevisionContent revisionContent,
> + Namespace namespace) {
> }
>
>
> @@ -139,7 +142,7 @@
> public void postRetrieveContent
> (SlideToken token, NodeRevisionDescriptors revisionDescriptors,
> NodeRevisionDescriptor revisionDescriptor,
> - NodeRevisionContent revisionContent) {
> + NodeRevisionContent revisionContent, Namespace namespace) {
> }
>
>
> @@ -151,7 +154,7 @@
> */
> public void postRemoveContent
> (SlideToken token, NodeRevisionDescriptors revisionDescriptors,
> - NodeRevisionDescriptor revisionDescriptor) {
> + NodeRevisionDescriptor revisionDescriptor, Namespace namespace) {
> }
>
>
>
> ------------------------------------------------------------------------
>
> diff -r -u slide_1_0_Quota_3_add_namespace_arg/src/share/org/apache/slide/content/ContentImpl.java slide_1_0_Quota_4_exceptions/src/share/org/apache/slide/content/ContentImpl.java
> --- slide_1_0_Quota_3_add_namespace_arg/src/share/org/apache/slide/content/ContentImpl.java Mon Apr 8 13:53:11 2002
> +++ slide_1_0_Quota_4_exceptions/src/share/org/apache/slide/content/ContentImpl.java Mon Apr 8 16:45:52 2002
> @@ -1194,7 +1194,10 @@
> protected void invokeInterceptors
> (SlideToken token, NodeRevisionDescriptors revisionDescriptors,
> NodeRevisionDescriptor revisionDescriptor,
> - NodeRevisionContent revisionContent, int type) {
> + NodeRevisionContent revisionContent, int type)
> + throws AccessDeniedException, ObjectNotFoundException,
> + LinkedObjectNotFoundException, ObjectLockedException,
> + ServiceAccessException {
> ContentInterceptor[] contentInterceptors =
> namespace.getContentInterceptors();
> for (int i = 0; i < contentInterceptors.length; i++) {
> diff -r -u slide_1_0_Quota_3_add_namespace_arg/src/share/org/apache/slide/content/ContentInterceptor.java slide_1_0_Quota_4_exceptions/src/share/org/apache/slide/content/ContentInterceptor.java
> --- slide_1_0_Quota_3_add_namespace_arg/src/share/org/apache/slide/content/ContentInterceptor.java Mon Apr 8 13:58:04 2002
> +++ slide_1_0_Quota_4_exceptions/src/share/org/apache/slide/content/ContentInterceptor.java Mon Apr 8 16:59:55 2002
> @@ -66,6 +66,11 @@
> import java.util.Hashtable;
> import org.apache.slide.common.Namespace;
> import org.apache.slide.common.SlideToken;
> +import org.apache.slide.lock.ObjectLockedException;
> +import org.apache.slide.common.ServiceAccessException;
> +import org.apache.slide.security.AccessDeniedException;
> +import org.apache.slide.structure.ObjectNotFoundException;
> +import org.apache.slide.structure.LinkedObjectNotFoundException;
>
> /**
> * Slide content interceptor class.
> @@ -118,7 +123,10 @@
> NodeRevisionDescriptors revisionDescriptors,
> NodeRevisionDescriptor revisionDescriptor,
> NodeRevisionContent revisionContent,
> - Namespace namespace) {
> + Namespace namespace)
> + throws AccessDeniedException, ObjectNotFoundException,
> + LinkedObjectNotFoundException, ObjectLockedException,
> + ServiceAccessException {
> }
>
>
> @@ -129,7 +137,10 @@
> NodeRevisionDescriptors revisionDescriptors,
> NodeRevisionDescriptor revisionDescriptor,
> NodeRevisionContent revisionContent,
> - Namespace namespace) {
> + Namespace namespace)
> + throws AccessDeniedException, ObjectNotFoundException,
> + LinkedObjectNotFoundException, ObjectLockedException,
> + ServiceAccessException {
> }
>
>
> @@ -142,7 +153,10 @@
> public void postRetrieveContent
> (SlideToken token, NodeRevisionDescriptors revisionDescriptors,
> NodeRevisionDescriptor revisionDescriptor,
> - NodeRevisionContent revisionContent, Namespace namespace) {
> + NodeRevisionContent revisionContent, Namespace namespace)
> + throws AccessDeniedException, ObjectNotFoundException,
> + LinkedObjectNotFoundException, ObjectLockedException,
> + ServiceAccessException {
> }
>
>
> @@ -154,7 +168,10 @@
> */
> public void postRemoveContent
> (SlideToken token, NodeRevisionDescriptors revisionDescriptors,
> - NodeRevisionDescriptor revisionDescriptor, Namespace namespace) {
> + NodeRevisionDescriptor revisionDescriptor, Namespace namespace)
> + throws AccessDeniedException, ObjectNotFoundException,
> + LinkedObjectNotFoundException, ObjectLockedException,
> + ServiceAccessException {
> }
>
>
> diff -r -u slide_1_0_Quota_3_add_namespace_arg/src/share/org/apache/slide/content/UserQuotaContentInterceptor.java slide_1_0_Quota_4_exceptions/src/share/org/apache/slide/content/UserQuotaContentInterceptor.java
> --- slide_1_0_Quota_3_add_namespace_arg/src/share/org/apache/slide/content/UserQuotaContentInterceptor.java Mon Apr 8 13:59:35 2002
> +++ slide_1_0_Quota_4_exceptions/src/share/org/apache/slide/content/UserQuotaContentInterceptor.java Mon Apr 8 16:56:01 2002
> @@ -65,6 +65,11 @@
>
> import org.apache.slide.common.Namespace;
> import org.apache.slide.common.SlideToken;
> +import org.apache.slide.lock.ObjectLockedException;
> +import org.apache.slide.common.ServiceAccessException;
> +import org.apache.slide.security.AccessDeniedException;
> +import org.apache.slide.structure.ObjectNotFoundException;
> +import org.apache.slide.structure.LinkedObjectNotFoundException;
>
> /**
> * Slide user quota content interceptor class.
> @@ -84,8 +89,11 @@
> NodeRevisionDescriptors revisionDescriptors,
> NodeRevisionDescriptor revisionDescriptor,
> NodeRevisionContent revisionContent,
> - Namespace namespace) {
> - //System.err.println("---------------- UserQuotaContentInterceptor parameters ----------------");
> + Namespace namespace)
> + throws AccessDeniedException, ObjectNotFoundException,
> + LinkedObjectNotFoundException, ObjectLockedException,
> + ServiceAccessException {
> + //System.err.println("---------------- UserQuotaContentInterceptor parameters ----------------");
> //System.err.println("allowUnknownSizeContent:"+getParameters().get("allowUnknownSizeContent"));
> //System.err.println("allowQuotaToBeExceeded:"+getParameters().get("allowQuotaToBeExceeded"));
> //System.err.println("------------------------------------------------------------------------");
> @@ -99,12 +107,30 @@
> NodeRevisionDescriptors revisionDescriptors,
> NodeRevisionDescriptor revisionDescriptor,
> NodeRevisionContent revisionContent,
> - Namespace namespace) {
> + Namespace namespace)
> + throws AccessDeniedException, ObjectNotFoundException,
> + LinkedObjectNotFoundException, ObjectLockedException,
> + ServiceAccessException {
> //System.err.println("---------------- UserQuotaContentInterceptor parameters ----------------");
> //System.err.println("allowUnknownSizeContent:"+getParameters().get("allowUnknownSizeContent"));
> //System.err.println("allowQuotaToBeExceeded:"+getParameters().get("allowQuotaToBeExceeded"));
> //System.err.println("------------------------------------------------------------------------");
> }
> +
>
> -
> + /**
> + * That method will be called just after removing content.
> + *
> + * @param revisionDescriptors null when a specified revision is removed
> + * @param revisionDescriptor null when all revisions are removed
> + */
> + public void postRemoveContent
> + (SlideToken token, NodeRevisionDescriptors revisionDescriptors,
> + NodeRevisionDescriptor revisionDescriptor, Namespace namespace)
> + throws AccessDeniedException, ObjectNotFoundException,
> + LinkedObjectNotFoundException, ObjectLockedException,
> + ServiceAccessException {
> + }
> +
> +
> }
>
>
>
> ------------------------------------------------------------------------
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [PATCH] SLIDE_1_0 : ContentInterceptors enhancements
Posted by Jean-Philippe Courson <co...@noos.fr>.
Christopher Lenz wrote:
> Am 18.04.2002 16:26:37, schrieb Jean-Philippe Courson <co...@noos.fr>:
>
>>Patch 3 : ContentInterceptors namespace access
>> (file 3-contentInterceptorsNamespaceArg.diff)
>>
>>This patch adds a Namespace object to ContentInterceptors methods to
>>allow them namespace access.
>
>
> Two more things:
>
> 1. Wouldn't access to the NamespaceAccessToken suffice ?
Yes in fact.
The need is to access NamespaceConfig and Helpers. Both can be retrieved
from NamespaceAccessToken.
> 2. How about adding a setNamespace(NamespaceAccessToken) method to the
> ContentInterceptor interface, so it doesn't have to be specified at each call,
> but rather would be called at the beginning of the ContentInterceptors life
> cycle ?
It would be smarter. And add a call to it from NamespaceConfig arround
line 840 just before my added
contentInterceptor.setParameters(contentInterceptorParameters).
JP
>
> -chris
> _______________________________________________
> /=/ cmlenz at gmx.de
>
>
>
>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: [PATCH] SLIDE_1_0 : ContentInterceptors enhancements
Posted by Christopher Lenz <cm...@gmx.de>.
Am 18.04.2002 16:26:37, schrieb Jean-Philippe Courson <co...@noos.fr>:
>Patch 3 : ContentInterceptors namespace access
> (file 3-contentInterceptorsNamespaceArg.diff)
>
>This patch adds a Namespace object to ContentInterceptors methods to
>allow them namespace access.
Two more things:
1. Wouldn't access to the NamespaceAccessToken suffice ?
2. How about adding a setNamespace(NamespaceAccessToken) method to the
ContentInterceptor interface, so it doesn't have to be specified at each call,
but rather would be called at the beginning of the ContentInterceptors life
cycle ?
-chris
_______________________________________________
/=/ cmlenz at gmx.de
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>