jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fabián Mandelbaum <fmandelb...@gmail.com>
Subject Re: David's Model question : nt:unstructured and SNS
Date Sun, 15 Nov 2009 23:14:19 GMT
It's simpler than fiddling around with this low-level stuff actually:

Just create a DAO to abstract all JCR operations (as you should be
doing already), and in that DAO's store() (or whatever is called)
method make a check for node existence before storing the new node, et
voilà !

Something like:

public void store(Object o) throws RespositoryException {
  String path = getStoragePathFromObject(o); // The absolute path
where o should be stored based on o's key fields
  if (!session.itemExists(path)) {
     // Code to store Object o here
  } else {
    throw new ItemExistsException(String.format("There already exists
an object stored at %s", path));
  }
}

That is, a variation on the "wrapper" suggestion you got 1st. Even
more, you can do other things instead of throwing an exception, you
can try to store the object at another place, or whatever your
application needs.

On Sat, Nov 14, 2009 at 7:35 AM, Guo Du <mrduguo@gmail.com> wrote:
> 2009/11/14 François Cassistat <f@maya-systems.com>:
>> I was looking for something like changing the default behavior of
>> nt:structured, but I think it may cause problems since /jcr:system & friends
>> use SNS.
> The build in node types such as nt:unstructured are protected at
> runtime, so you cannot delete or update them. But didn't try to update
> builtin_nodtypes.cnd before repository start. It's not recommend
> anyway.
>
> Just another notes on my previous sample, the childNodeDefinition
> onParentVersion="IGNORE" is different from nt:unstructured.
>
> Good luck!
>
> --Guo
>



-- 
Fabián Mandelbaum
IS Engineer

Mime
View raw message