You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lenya.apache.org by Thorsten Scherler <th...@apache.org> on 2006/03/17 10:49:00 UTC

Register extension with resource types

El jue, 16-03-2006 a las 13:51 +0000, thorsten@apache.org escribió:

...
> -
> -                    // TODO allow to create other docs than xhtml
> -                    resourceType = (ResourceType) selector.select("xhtml");
> -                    documentManager.add(document, resourceType, "xml", doc.getName(), true, null);
> +                    
> +                    if("xml".equals(extension)){
> +                        // FIXME allow to create other docs than xhtml - but how?
> +                        resourceType = (ResourceType) selector.select("xhtml");
> +                    }else{
> +                        // FIXME the following works only if the resource typ is called like the extension but normally 
> +                        // that is not the case maybe there is a way to store which extension a resource type is 
> +                        // treating and lookup a hashMap to get the real name via the extension
> +                        if (selector.isSelectable(extension)){
> +                            resourceType = (ResourceType) selector.select(extension);
> +                        }else{
> +                            //using a fallback resource type
> +                            // FIXME this resource tye should be a more generic one like "media-assets" or "bin"
> +                            resourceType = (ResourceType) selector.select("xhtml");
> +                        }
> +                      }
> +                    documentManager.add(document, resourceType, extension, doc.getName(), true, null);
>  

wdyt?

salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Register extension with resource types

Posted by Andreas Hartmann <an...@apache.org>.
Thorsten Scherler wrote:
> El lun, 20-03-2006 a las 11:23 +0100, Andreas Hartmann escribió:
>> Thorsten Scherler wrote:
>>> El lun, 20-03-2006 a las 10:28 +0100, Andreas Hartmann escribió:
>>>> Michael Wechner wrote:
>>>>> Thorsten Scherler wrote:
>>>> [...]
>>>>
>>>>
>>>>>> I came up with nearly the same config, so yeah +1 to add it in the
>>>>>> config, but the only problem is that one need to patch the conf when
>>>>>> adding a new resource type. That is not that nice.
>>>> Why?
>>> http://svn.apache.org/viewcvs?rev=386656&view=rev
>>> You would need to add new resource types here.
>> Hmmm, why would you need to add resource types there?
>> Isn't it sufficient to reference registered resource types?
> 
> Are they registered with extension? If so, how can I lookup the resource
> type with an extension ?

I don't think that it makes sense to define a global mapping from
extensions to resource types. For instance, a lot of resource types
might support the extension ".xml". We could add a method

     ResourceType.getSourceExtensions()

but I'd discourage even that.

IMO resource types and source extensions should be completely
separated. The internal storage of a document is entirely up
to the repo implementation. Recognizing WebDAV documents is a
different story.


>>> Is there a simpler way?
>>>
>>> Could be overcome with a centralized registration.
>>>
>>>>> at the moment it's a problem recognizing resource types anyway ;-)
>>>> What is the problem with recognizing resource types?
>>>>
>>> Well, webDAV PUT is adding just a file e.g. index.xml, that could be a
>>> forrest xdoc or a xhtml or ... How can we determine this?
>> Well, that's a general problem, it is not related to the resource
>> type recognition. You can't determine the type of a file in a
>> generic way without meta information. I see two options:
>>
>> 1) explicit mapping (that's what you do)
>>
>> 2) ask all resource types: Does this file belong to you?
>>
>> The second option has the advantage that it doesn't require any
>> special WebDAV configuration. But I guess it is hard to implement.
>>
> 
> Well one could use something like the resource type action to determine
> it for xml files.

What do you mean with "resource type action"?

I imagine something like

ResourceType[] types = resourceTypeManager.getResourceTypes();

for (int i = 0; i < types.length; i++) {

     if (types[i].isSource(webdavSource)) {
         import(webdavSource, types[i]);
     }

}


-- Andreas

-- 
Andreas Hartmann
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
andreas.hartmann@wyona.com                     andreas@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Register extension with resource types

Posted by Thorsten Scherler <th...@apache.org>.
El lun, 20-03-2006 a las 11:23 +0100, Andreas Hartmann escribió:
> Thorsten Scherler wrote:
> > El lun, 20-03-2006 a las 10:28 +0100, Andreas Hartmann escribió:
> >> Michael Wechner wrote:
> >>> Thorsten Scherler wrote:
> >> [...]
> >>
> >>
> >>>> I came up with nearly the same config, so yeah +1 to add it in the
> >>>> config, but the only problem is that one need to patch the conf when
> >>>> adding a new resource type. That is not that nice.
> >> Why?
> > 
> > http://svn.apache.org/viewcvs?rev=386656&view=rev
> > You would need to add new resource types here.
> 
> Hmmm, why would you need to add resource types there?
> Isn't it sufficient to reference registered resource types?

Are they registered with extension? If so, how can I lookup the resource
type with an extension ?

> 
> > Is there a simpler way?
> > 
> > Could be overcome with a centralized registration.
> > 
> >>
> >>> at the moment it's a problem recognizing resource types anyway ;-)
> >> What is the problem with recognizing resource types?
> >>
> > 
> > Well, webDAV PUT is adding just a file e.g. index.xml, that could be a
> > forrest xdoc or a xhtml or ... How can we determine this?
> 
> Well, that's a general problem, it is not related to the resource
> type recognition. You can't determine the type of a file in a
> generic way without meta information. I see two options:
> 
> 1) explicit mapping (that's what you do)
> 
> 2) ask all resource types: Does this file belong to you?
> 
> The second option has the advantage that it doesn't require any
> special WebDAV configuration. But I guess it is hard to implement.
> 

Well one could use something like the resource type action to determine
it for xml files. 

> 
> >>> and I think we should change this.
> >>>
> >>> But centralized registration makes sense in order to avoid conflicts.
> >> IMO we need a centralized registration.
> >>
> > 
> > Yeah, that makes perfect sense.
> > +1
> 
> Does that mean you don't want to change anything? We already
> have a centralized registration ...
> 

See above questions.

> -- Andreas
> 

-- 
Thorsten Scherler
COO Spain
Wyona Inc.  -  Open Source Content Management  -  Apache Lenya
http://www.wyona.com                   http://lenya.apache.org
thorsten.scherler@wyona.com                thorsten@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Register extension with resource types

Posted by Andreas Hartmann <an...@apache.org>.
Thorsten Scherler wrote:
> El lun, 20-03-2006 a las 10:28 +0100, Andreas Hartmann escribió:
>> Michael Wechner wrote:
>>> Thorsten Scherler wrote:
>> [...]
>>
>>
>>>> I came up with nearly the same config, so yeah +1 to add it in the
>>>> config, but the only problem is that one need to patch the conf when
>>>> adding a new resource type. That is not that nice.
>> Why?
> 
> http://svn.apache.org/viewcvs?rev=386656&view=rev
> You would need to add new resource types here.

Hmmm, why would you need to add resource types there?
Isn't it sufficient to reference registered resource types?


> Is there a simpler way?
> 
> Could be overcome with a centralized registration.
> 
>>
>>> at the moment it's a problem recognizing resource types anyway ;-)
>> What is the problem with recognizing resource types?
>>
> 
> Well, webDAV PUT is adding just a file e.g. index.xml, that could be a
> forrest xdoc or a xhtml or ... How can we determine this?

Well, that's a general problem, it is not related to the resource
type recognition. You can't determine the type of a file in a
generic way without meta information. I see two options:

1) explicit mapping (that's what you do)

2) ask all resource types: Does this file belong to you?

The second option has the advantage that it doesn't require any
special WebDAV configuration. But I guess it is hard to implement.


>>> and I think we should change this.
>>>
>>> But centralized registration makes sense in order to avoid conflicts.
>> IMO we need a centralized registration.
>>
> 
> Yeah, that makes perfect sense.
> +1

Does that mean you don't want to change anything? We already
have a centralized registration ...

-- Andreas


-- 
Andreas Hartmann
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
andreas.hartmann@wyona.com                     andreas@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Register extension with resource types

Posted by Thorsten Scherler <th...@apache.org>.
El lun, 20-03-2006 a las 10:28 +0100, Andreas Hartmann escribió:
> Michael Wechner wrote:
> > Thorsten Scherler wrote:
> 
> [...]
> 
> 
> >> I came up with nearly the same config, so yeah +1 to add it in the
> >> config, but the only problem is that one need to patch the conf when
> >> adding a new resource type. That is not that nice.
> 
> Why?

http://svn.apache.org/viewcvs?rev=386656&view=rev
You would need to add new resource types here. 
Is there a simpler way?

Could be overcome with a centralized registration.

> 
> 
> > at the moment it's a problem recognizing resource types anyway ;-)
> 
> What is the problem with recognizing resource types?
> 

Well, webDAV PUT is adding just a file e.g. index.xml, that could be a
forrest xdoc or a xhtml or ... How can we determine this?


> 
> > and I think we should change this.
> > 
> > But centralized registration makes sense in order to avoid conflicts.
> 
> IMO we need a centralized registration.
> 

Yeah, that makes perfect sense.
+1

> -- Andreas

salu2
-- 
Thorsten Scherler
COO Spain
Wyona Inc.  -  Open Source Content Management  -  Apache Lenya
http://www.wyona.com                   http://lenya.apache.org
thorsten.scherler@wyona.com                thorsten@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Register extension with resource types

Posted by Andreas Hartmann <an...@apache.org>.
Michael Wechner wrote:
> Thorsten Scherler wrote:

[...]


>> I came up with nearly the same config, so yeah +1 to add it in the
>> config, but the only problem is that one need to patch the conf when
>> adding a new resource type. That is not that nice.

Why?


> at the moment it's a problem recognizing resource types anyway ;-)

What is the problem with recognizing resource types?


> and I think we should change this.
> 
> But centralized registration makes sense in order to avoid conflicts.

IMO we need a centralized registration.

-- Andreas

-- 
Andreas Hartmann
Wyona Inc.  -   Open Source Content Management   -   Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
andreas.hartmann@wyona.com                     andreas@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Register extension with resource types

Posted by Michael Wechner <mi...@wyona.com>.
Thorsten Scherler wrote:

>El vie, 17-03-2006 a las 11:23 +0100, Michael Wechner escribió:
>  
>
>>Thorsten Scherler wrote:
>>
>>    
>>
>>>El jue, 16-03-2006 a las 13:51 +0000, thorsten@apache.org escribió:
>>>
>>>...
>>> 
>>>
>>>      
>>>
>>>>-
>>>>-                    // TODO allow to create other docs than xhtml
>>>>-                    resourceType = (ResourceType) selector.select("xhtml");
>>>>-                    documentManager.add(document, resourceType, "xml", doc.getName(), true, null);
>>>>+                    
>>>>+                    if("xml".equals(extension)){
>>>>+                        // FIXME allow to create other docs than xhtml - but how?
>>>>+                        resourceType = (ResourceType) selector.select("xhtml");
>>>>+                    }else{
>>>>+                        // FIXME the following works only if the resource typ is called like the extension but normally 
>>>>+                        // that is not the case maybe there is a way to store which extension a resource type is 
>>>>+                        // treating and lookup a hashMap to get the real name via the extension
>>>>+                        if (selector.isSelectable(extension)){
>>>>+                            resourceType = (ResourceType) selector.select(extension);
>>>>+                        }else{
>>>>+                            //using a fallback resource type
>>>>+                            // FIXME this resource tye should be a more generic one like "media-assets" or "bin"
>>>>+                            resourceType = (ResourceType) selector.select("xhtml");
>>>>+                        }
>>>>+                      }
>>>>+                    documentManager.add(document, resourceType, extension, doc.getName(), true, null);
>>>>
>>>>   
>>>>
>>>>        
>>>>
>>>wdyt?
>>> 
>>>
>>>      
>>>
>>I think we need a registry configuration file (for WebDAV), where we can 
>>say which suffix corresponds to which resource type creator
>>and also what resource type is being used if there is no suffix (e.g. 
>>XHTML or Folder resource type).
>>
>><config no-suffix="folder">
>>  <suffix resource-type="opendocument">odt</suffix>
>>  <suffix resource-type="html">xhtml</suffix> <!-- What happens if it 
>>isn't well-formed or not valid??? -->
>>    
>>
>
>We have discussed that this should not be the problem of webdav but
>rather delegated. 
>
>Until now we are doing validation of all files since we assume all are
>xhtml but this needs to change.
>
>  
>
>>  <suffix resource-type="*"></suffix>
>></config>
>>
>>WDYT?
>>    
>>
>
>I came up with nearly the same config, so yeah +1 to add it in the
>config, but the only problem is that one need to patch the conf when
>adding a new resource type. That is not that nice.
>  
>

at the moment it's a problem recognizing resource types anyway ;-)
and I think we should change this.

But centralized registration makes sense in order to avoid conflicts.

Michi

>salu2
>  
>


-- 
Michael Wechner
Wyona      -   Open Source Content Management   -    Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
michael.wechner@wyona.com                        michi@apache.org
+41 44 272 91 61


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Register extension with resource types

Posted by Thorsten Scherler <th...@wyona.com>.
El vie, 17-03-2006 a las 11:23 +0100, Michael Wechner escribió:
> Thorsten Scherler wrote:
> 
> >El jue, 16-03-2006 a las 13:51 +0000, thorsten@apache.org escribió:
> >
> >...
> >  
> >
> >>-
> >>-                    // TODO allow to create other docs than xhtml
> >>-                    resourceType = (ResourceType) selector.select("xhtml");
> >>-                    documentManager.add(document, resourceType, "xml", doc.getName(), true, null);
> >>+                    
> >>+                    if("xml".equals(extension)){
> >>+                        // FIXME allow to create other docs than xhtml - but how?
> >>+                        resourceType = (ResourceType) selector.select("xhtml");
> >>+                    }else{
> >>+                        // FIXME the following works only if the resource typ is called like the extension but normally 
> >>+                        // that is not the case maybe there is a way to store which extension a resource type is 
> >>+                        // treating and lookup a hashMap to get the real name via the extension
> >>+                        if (selector.isSelectable(extension)){
> >>+                            resourceType = (ResourceType) selector.select(extension);
> >>+                        }else{
> >>+                            //using a fallback resource type
> >>+                            // FIXME this resource tye should be a more generic one like "media-assets" or "bin"
> >>+                            resourceType = (ResourceType) selector.select("xhtml");
> >>+                        }
> >>+                      }
> >>+                    documentManager.add(document, resourceType, extension, doc.getName(), true, null);
> >> 
> >>    
> >>
> >
> >wdyt?
> >  
> >
> 
> I think we need a registry configuration file (for WebDAV), where we can 
> say which suffix corresponds to which resource type creator
> and also what resource type is being used if there is no suffix (e.g. 
> XHTML or Folder resource type).
> 
> <config no-suffix="folder">
>   <suffix resource-type="opendocument">odt</suffix>
>   <suffix resource-type="html">xhtml</suffix> <!-- What happens if it 
> isn't well-formed or not valid??? -->

We have discussed that this should not be the problem of webdav but
rather delegated. 

Until now we are doing validation of all files since we assume all are
xhtml but this needs to change.

>   <suffix resource-type="*"></suffix>
> </config>
> 
> WDYT?

I came up with nearly the same config, so yeah +1 to add it in the
config, but the only problem is that one need to patch the conf when
adding a new resource type. That is not that nice.

salu2
-- 
Thorsten Scherler
COO Spain
Wyona Inc.  -  Open Source Content Management  -  Apache Lenya
http://www.wyona.com                   http://lenya.apache.org
thorsten.scherler@wyona.com                thorsten@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org


Re: Register extension with resource types

Posted by Michael Wechner <mi...@wyona.com>.
Thorsten Scherler wrote:

>El jue, 16-03-2006 a las 13:51 +0000, thorsten@apache.org escribió:
>
>...
>  
>
>>-
>>-                    // TODO allow to create other docs than xhtml
>>-                    resourceType = (ResourceType) selector.select("xhtml");
>>-                    documentManager.add(document, resourceType, "xml", doc.getName(), true, null);
>>+                    
>>+                    if("xml".equals(extension)){
>>+                        // FIXME allow to create other docs than xhtml - but how?
>>+                        resourceType = (ResourceType) selector.select("xhtml");
>>+                    }else{
>>+                        // FIXME the following works only if the resource typ is called like the extension but normally 
>>+                        // that is not the case maybe there is a way to store which extension a resource type is 
>>+                        // treating and lookup a hashMap to get the real name via the extension
>>+                        if (selector.isSelectable(extension)){
>>+                            resourceType = (ResourceType) selector.select(extension);
>>+                        }else{
>>+                            //using a fallback resource type
>>+                            // FIXME this resource tye should be a more generic one like "media-assets" or "bin"
>>+                            resourceType = (ResourceType) selector.select("xhtml");
>>+                        }
>>+                      }
>>+                    documentManager.add(document, resourceType, extension, doc.getName(), true, null);
>> 
>>    
>>
>
>wdyt?
>  
>

I think we need a registry configuration file (for WebDAV), where we can 
say which suffix corresponds to which resource type creator
and also what resource type is being used if there is no suffix (e.g. 
XHTML or Folder resource type).

<config no-suffix="folder">
  <suffix resource-type="opendocument">odt</suffix>
  <suffix resource-type="html">xhtml</suffix> <!-- What happens if it 
isn't well-formed or not valid??? -->
  <suffix resource-type="*"></suffix>
</config>

WDYT?

Michi

>salu2
>  
>


-- 
Michael Wechner
Wyona      -   Open Source Content Management   -    Apache Lenya
http://www.wyona.com                      http://lenya.apache.org
michael.wechner@wyona.com                        michi@apache.org
+41 44 272 91 61


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lenya.apache.org
For additional commands, e-mail: dev-help@lenya.apache.org