You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Sridhar Raman <sr...@gmail.com> on 2007/06/05 10:23:39 UTC

Changing the primary type of a node?

Hi

Is it possible to change the primary type of a node programmatically?  Or is
the only option is to create a new node with the new primary type, and
transfer the contents?

Thanks,
Sridhar

Re: Changing the primary type of a node?

Posted by Jukka Zitting <ju...@gmail.com>.
Hi,

On 6/6/07, Tako Schotanus <qu...@gmail.com> wrote:
> On 6/6/07, Stefan Guggisberg <st...@gmail.com> wrote:
> > currently there's no easy programmatic way of changing the primary type
> > of a node. jcr 2.0 (jsr-283) will include a new method
> > Node.setPrimaryType(String)
>
> Any idea how that is going to work?
> The types must be compatible somehow?

I guess the cleanest approach would be to re-evaluate the type
constraints during the next save() call. This way the client can
perform any modifications necessary to make the node meet the
constraints of the new type.

BR,

Jukka Zitting

Re: Changing the primary type of a node?

Posted by Stefan Guggisberg <st...@gmail.com>.
On 6/6/07, Tako Schotanus <qu...@gmail.com> wrote:
> On 6/6/07, Stefan Guggisberg <st...@gmail.com> wrote:
> >
> > On 6/5/07, Sridhar Raman <sr...@gmail.com> wrote:
> > > Hi
> > >
> > > Is it possible to change the primary type of a node
> > programmatically?  Or is
> > > the only option is to create a new node with the new primary type, and
> > > transfer the contents?
> >
> > currently there's no easy programmatic way of changing the primary type
> > of a node. jcr 2.0 (jsr-283) will include a new method
> > Node.setPrimaryType(String)
>
>
> Any idea how that is going to work?
> The types must be compatible somehow?

there are basically the same requirements as for the Node.addMixin()
and .removeMixin() methods as those change the effective type of a node.

the resulting effective node type must be compliant with the node type
constraints defined on its parent.

cheers
stefan

>
> Cheers,
>  -Tako
>

Re: Changing the primary type of a node?

Posted by Tako Schotanus <qu...@gmail.com>.
On 6/6/07, Stefan Guggisberg <st...@gmail.com> wrote:
>
> On 6/5/07, Sridhar Raman <sr...@gmail.com> wrote:
> > Hi
> >
> > Is it possible to change the primary type of a node
> programmatically?  Or is
> > the only option is to create a new node with the new primary type, and
> > transfer the contents?
>
> currently there's no easy programmatic way of changing the primary type
> of a node. jcr 2.0 (jsr-283) will include a new method
> Node.setPrimaryType(String)


Any idea how that is going to work?
The types must be compatible somehow?

Cheers,
 -Tako

Re: Changing the primary type of a node?

Posted by Stefan Guggisberg <st...@gmail.com>.
On 6/5/07, Sridhar Raman <sr...@gmail.com> wrote:
> Hi
>
> Is it possible to change the primary type of a node programmatically?  Or is
> the only option is to create a new node with the new primary type, and
> transfer the contents?

currently there's no easy programmatic way of changing the primary type
of a node. jcr 2.0 (jsr-283) will include a new method
Node.setPrimaryType(String)
but for the time being you'll have to use some workaround.

cheers
stefan

>
> Thanks,
> Sridhar
>