You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Michal Hybler <m....@email.cz> on 2007/03/22 16:13:42 UTC
UUID
I have question is the property jcr:uuid same as node.getUUID()?
because if I ask for uuid by this method node.getUUID() and after that If I
request for UUID by this way:
HashMap<String,String> properties = new HashMap<String,String>();
PropertyIterator iter = node.getProperties();
while(iter.hasNext()){
Property prop = iter.nextProperty();
if (!prop.getDefinition().isMultiple()) {
properties.put(prop.getName(), prop.getValue().getString());
}
}
and after that If I write the properties from this map on the console the
UUID has different value than the previous one.
Is it u bug or where can I make a fault.
Thanks for explantion. Michal
--
View this message in context: http://www.nabble.com/UUID-tf3448236.html#a9616867
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: UUID
Posted by Michal Hybler <m....@email.cz>.
tahnks i have missed this method Michal
Brian Thompson-5 wrote:
>
> Why are you creating a query to look for the uuid? Why not just use
> session.getNodeByUUID()?
>
> -Brian
>
>
>
> On 3/22/07, Michal Hybler <m....@email.cz> wrote:
>>
>> <snip>
>> >
>>
>> I have this method
>>
>> ws = session.getWorkspace();
>> manager = ws.getQueryManager();
>> query = manager.createQuery("select * from
>> nt:unstructured where jcr:uuid
>> = '"+id+"'",Query.SQL);
>> QueryResult result = query.execute();
>> NodeIterator it = result.getNodes();
>> return it.nextNode();
>> with Id which I remembered when I insert file into jackrabbit.
>>
>> after that I run this code
>>
>> HashMap<String,String> properties = new HashMap<String,String>();
>> try {
>> PropertyIterator iter = node.getProperties();
>> while(iter.hasNext()){
>> Property prop = iter.nextProperty();
>> if (!prop.getDefinition().isMultiple()) {
>> properties.put(prop.getName(),
>> prop.getValue().getString());
>> }
>>
>> }
>> if (getResNode(node) != null) {
>> Node resNode = getResNode(node);
>> iter = resNode.getProperties();
>> while(iter.hasNext()){
>> Property prop = iter.nextProperty
>> ();
>> if
>> (!prop.getDefinition().isMultiple()) {
>> properties.put(
>> prop.getName(), prop.getValue().getString());
>> }
>> }
>> }
>> } catch (RepositoryException e) {
>> // TODO Auto-generated catch block
>> e.printStackTrace();
>> }
>>
>> and write map on console
>>
>> Set keys = properties.keySet();
>> Iterator iter = keys.iterator();
>> while (iter.hasNext()) {
>> String key = (String) iter.next();
>> String value = properties.get(key);
>> System.out.println("property "+key+" with value
>> "+value);
>> }
>>
>>
>> UUID which this code writes on the console is distinct from id which I
>> insert on the start of code. If I insert This id which is shown on the
>> console the repository returns no file.
>>
>> --
>> View this message in context:
>> http://www.nabble.com/UUID-tf3448236.html#a9618986
>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/UUID-tf3448236.html#a9687101
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: UUID
Posted by Michal Hybler <m....@email.cz>.
OK there is problem on my side. Thanks for help Michal
Brian Thompson-5 wrote:
>
> Why are you creating a query to look for the uuid? Why not just use
> session.getNodeByUUID()?
>
> -Brian
>
>
>
> On 3/22/07, Michal Hybler <m....@email.cz> wrote:
>>
>> <snip>
>> >
>>
>> I have this method
>>
>> ws = session.getWorkspace();
>> manager = ws.getQueryManager();
>> query = manager.createQuery("select * from
>> nt:unstructured where jcr:uuid
>> = '"+id+"'",Query.SQL);
>> QueryResult result = query.execute();
>> NodeIterator it = result.getNodes();
>> return it.nextNode();
>> with Id which I remembered when I insert file into jackrabbit.
>>
>> after that I run this code
>>
>> HashMap<String,String> properties = new HashMap<String,String>();
>> try {
>> PropertyIterator iter = node.getProperties();
>> while(iter.hasNext()){
>> Property prop = iter.nextProperty();
>> if (!prop.getDefinition().isMultiple()) {
>> properties.put(prop.getName(),
>> prop.getValue().getString());
>> }
>>
>> }
>> if (getResNode(node) != null) {
>> Node resNode = getResNode(node);
>> iter = resNode.getProperties();
>> while(iter.hasNext()){
>> Property prop = iter.nextProperty
>> ();
>> if
>> (!prop.getDefinition().isMultiple()) {
>> properties.put(
>> prop.getName(), prop.getValue().getString());
>> }
>> }
>> }
>> } catch (RepositoryException e) {
>> // TODO Auto-generated catch block
>> e.printStackTrace();
>> }
>>
>> and write map on console
>>
>> Set keys = properties.keySet();
>> Iterator iter = keys.iterator();
>> while (iter.hasNext()) {
>> String key = (String) iter.next();
>> String value = properties.get(key);
>> System.out.println("property "+key+" with value
>> "+value);
>> }
>>
>>
>> UUID which this code writes on the console is distinct from id which I
>> insert on the start of code. If I insert This id which is shown on the
>> console the repository returns no file.
>>
>> --
>> View this message in context:
>> http://www.nabble.com/UUID-tf3448236.html#a9618986
>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/UUID-tf3448236.html#a9687105
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: UUID
Posted by Brian Thompson <el...@gmail.com>.
Why are you creating a query to look for the uuid? Why not just use
session.getNodeByUUID()?
-Brian
On 3/22/07, Michal Hybler <m....@email.cz> wrote:
>
> <snip>
> >
>
> I have this method
>
> ws = session.getWorkspace();
> manager = ws.getQueryManager();
> query = manager.createQuery("select * from
> nt:unstructured where jcr:uuid
> = '"+id+"'",Query.SQL);
> QueryResult result = query.execute();
> NodeIterator it = result.getNodes();
> return it.nextNode();
> with Id which I remembered when I insert file into jackrabbit.
>
> after that I run this code
>
> HashMap<String,String> properties = new HashMap<String,String>();
> try {
> PropertyIterator iter = node.getProperties();
> while(iter.hasNext()){
> Property prop = iter.nextProperty();
> if (!prop.getDefinition().isMultiple()) {
> properties.put(prop.getName(),
> prop.getValue().getString());
> }
>
> }
> if (getResNode(node) != null) {
> Node resNode = getResNode(node);
> iter = resNode.getProperties();
> while(iter.hasNext()){
> Property prop = iter.nextProperty
> ();
> if
> (!prop.getDefinition().isMultiple()) {
> properties.put(
> prop.getName(), prop.getValue().getString());
> }
> }
> }
> } catch (RepositoryException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> and write map on console
>
> Set keys = properties.keySet();
> Iterator iter = keys.iterator();
> while (iter.hasNext()) {
> String key = (String) iter.next();
> String value = properties.get(key);
> System.out.println("property "+key+" with value
> "+value);
> }
>
>
> UUID which this code writes on the console is distinct from id which I
> insert on the start of code. If I insert This id which is shown on the
> console the repository returns no file.
>
> --
> View this message in context:
> http://www.nabble.com/UUID-tf3448236.html#a9618986
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>
Re: UUID
Posted by freak182 <em...@gmail.com>.
Hello,
Sorry, is hould do this instead to get uuid:
Node file = folder.addNode(name, "nt:file");
file.addMixin(JcrConstants.MIX_REFERENCEABLE);
not the other way around.
thanks a lot.
cheers.
Stefan Guggisberg wrote:
>
> On Wed, Sep 16, 2009 at 12:39 PM, freak182 <em...@gmail.com> wrote:
>>
>> Hello,
>>
>> it does not fail on the assert becuase i set this before saving:
>> fileContent.addMixin(JcrConstants.MIX_REFERENCEABLE);
>> and i wonder why now it is not working? still when i access this:
>> nodeToRemove.getUUID(); throws an exception.
>
> can you provide a simple test case?
> please also provide detailed information about your environment.
>
> cheers
> stefan
>
>
>>
>> cheers.
>>
>>
>> Stefan Guggisberg wrote:
>>>
>>> On Wed, Sep 16, 2009 at 9:19 AM, freak182 <em...@gmail.com>
>>> wrote:
>>>>
>>>> Hello,
>>>>
>>>> I have problem retreiving the uuid?
>>>> here is the scenario:
>>>>
>>>> when i save the file, here is the code:
>>>>
>>>> .................................
>>>>
>>>> Node file = folder.addNode(name, "nt:file");
>>>> Node fileContent = file.addNode("jcr:content",
>>>> "nt:resource");
>>>> fileContent.addMixin(JcrConstants.MIX_REFERENCEABLE);
>>>>
>>>> session.save();
>>>> uuid = fileContent.getUUID();
>>>>
>>>> ..this save fine and some metadata save in DB also including the uuid.
>>>>
>>>> Now i want to delete the file:
>>>>
>>>> Node nodeToRemove = session.getRootNode().getNode(path.substring(1));
>>>> String uuid = nodeToRemove.getUUID(); ---> error here
>>>> if (nodeToRemove != null)
>>>> {
>>>> nodeToRemove.remove();
>>>> session.save();
>>>>
>>>> //
>>>> jcrFileStorageDao.delete(jcrFileStorageDao.loadByUUID(uuid));
>>>> }
>>>>
>>>> javax.jcr.UnsupportedRepositoryOperationException
>>>> at
>>>> org.apache.jackrabbit.core.NodeImpl.getUUID(NodeImpl.java:3040)
>>>
>>> nodeToRemove is probably not mix:referenceable. you can test this by
>>> adding
>>>
>>> assert(node.isNodeType(JcrConstants.MIX_REFERENCEABLE));
>>>
>>> cheers
>>> stefan
>>>
>>>>
>>>> how can i resolve this?
>>>>
>>>> thanks a lot.
>>>> cheers.
>>>>
>>>>
>>>> Christoph Kiehl-3 wrote:
>>>>>
>>>>> Michal Hybler wrote:
>>>>>
>>>>>> I have this method
>>>>>>
>>>>>> ws = session.getWorkspace();
>>>>>> manager = ws.getQueryManager();
>>>>>> query = manager.createQuery("select * from
>>>>>> nt:unstructured where
>>>>>> jcr:uuid
>>>>>> = '"+id+"'",Query.SQL);
>>>>>> QueryResult result = query.execute();
>>>>>> NodeIterator it = result.getNodes();
>>>>>> return it.nextNode();
>>>>>> with Id which I remembered when I insert file into jackrabbit.
>>>>>>
>>>>>> after that I run this code
>>>>>>
>>>>>> HashMap<String,String> properties = new HashMap<String,String>();
>>>>>> try {
>>>>>> PropertyIterator iter = node.getProperties();
>>>>>> while(iter.hasNext()){
>>>>>> Property prop = iter.nextProperty();
>>>>>> if (!prop.getDefinition().isMultiple())
>>>>>> {
>>>>>> properties.put(prop.getName(),
>>>>>> prop.getValue().getString());
>>>>>> }
>>>>>>
>>>>>> }
>>>>>> if (getResNode(node) != null) {
>>>>>> Node resNode = getResNode(node);
>>>>>> iter = resNode.getProperties();
>>>>>> while(iter.hasNext()){
>>>>>> Property prop =
>>>>>> iter.nextProperty();
>>>>>> if
>>>>>> (!prop.getDefinition().isMultiple()) {
>>>>>>
>>>>>> properties.put(prop.getName(), prop.getValue().getString());
>>>>>> }
>>>>>> }
>>>>>> }
>>>>>
>>>>> I don't know what getResNode(node) does, but I suppose it loads some
>>>>> other
>>>>> node
>>>>> which is different to the one retrieved by the query. If you remove
>>>>> this
>>>>> if-block the uuids should be equal as far as I can see.
>>>>> And as Brian already wrote: you should be better off using
>>>>> session.getNodeByUUID() instead of using a query. This method performs
>>>>> much
>>>>> faster than a query.
>>>>>
>>>>> Cheers,
>>>>> Christoph
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/UUID-tp9616867p25467222.html
>>>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/UUID-tp9616867p25469884.html
>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/UUID-tp9616867p25485428.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: UUID
Posted by freak182 <em...@gmail.com>.
Hello,
I will provide a test case tommorow because i left my laptop in the office.
thanks a lot.
cheers.
Stefan Guggisberg wrote:
>
> On Wed, Sep 16, 2009 at 12:39 PM, freak182 <em...@gmail.com> wrote:
>>
>> Hello,
>>
>> it does not fail on the assert becuase i set this before saving:
>> fileContent.addMixin(JcrConstants.MIX_REFERENCEABLE);
>> and i wonder why now it is not working? still when i access this:
>> nodeToRemove.getUUID(); throws an exception.
>
> can you provide a simple test case?
> please also provide detailed information about your environment.
>
> cheers
> stefan
>
>
>>
>> cheers.
>>
>>
>> Stefan Guggisberg wrote:
>>>
>>> On Wed, Sep 16, 2009 at 9:19 AM, freak182 <em...@gmail.com>
>>> wrote:
>>>>
>>>> Hello,
>>>>
>>>> I have problem retreiving the uuid?
>>>> here is the scenario:
>>>>
>>>> when i save the file, here is the code:
>>>>
>>>> .................................
>>>>
>>>> Node file = folder.addNode(name, "nt:file");
>>>> Node fileContent = file.addNode("jcr:content",
>>>> "nt:resource");
>>>> fileContent.addMixin(JcrConstants.MIX_REFERENCEABLE);
>>>>
>>>> session.save();
>>>> uuid = fileContent.getUUID();
>>>>
>>>> ..this save fine and some metadata save in DB also including the uuid.
>>>>
>>>> Now i want to delete the file:
>>>>
>>>> Node nodeToRemove = session.getRootNode().getNode(path.substring(1));
>>>> String uuid = nodeToRemove.getUUID(); ---> error here
>>>> if (nodeToRemove != null)
>>>> {
>>>> nodeToRemove.remove();
>>>> session.save();
>>>>
>>>> //
>>>> jcrFileStorageDao.delete(jcrFileStorageDao.loadByUUID(uuid));
>>>> }
>>>>
>>>> javax.jcr.UnsupportedRepositoryOperationException
>>>> at
>>>> org.apache.jackrabbit.core.NodeImpl.getUUID(NodeImpl.java:3040)
>>>
>>> nodeToRemove is probably not mix:referenceable. you can test this by
>>> adding
>>>
>>> assert(node.isNodeType(JcrConstants.MIX_REFERENCEABLE));
>>>
>>> cheers
>>> stefan
>>>
>>>>
>>>> how can i resolve this?
>>>>
>>>> thanks a lot.
>>>> cheers.
>>>>
>>>>
>>>> Christoph Kiehl-3 wrote:
>>>>>
>>>>> Michal Hybler wrote:
>>>>>
>>>>>> I have this method
>>>>>>
>>>>>> ws = session.getWorkspace();
>>>>>> manager = ws.getQueryManager();
>>>>>> query = manager.createQuery("select * from
>>>>>> nt:unstructured where
>>>>>> jcr:uuid
>>>>>> = '"+id+"'",Query.SQL);
>>>>>> QueryResult result = query.execute();
>>>>>> NodeIterator it = result.getNodes();
>>>>>> return it.nextNode();
>>>>>> with Id which I remembered when I insert file into jackrabbit.
>>>>>>
>>>>>> after that I run this code
>>>>>>
>>>>>> HashMap<String,String> properties = new HashMap<String,String>();
>>>>>> try {
>>>>>> PropertyIterator iter = node.getProperties();
>>>>>> while(iter.hasNext()){
>>>>>> Property prop = iter.nextProperty();
>>>>>> if (!prop.getDefinition().isMultiple())
>>>>>> {
>>>>>> properties.put(prop.getName(),
>>>>>> prop.getValue().getString());
>>>>>> }
>>>>>>
>>>>>> }
>>>>>> if (getResNode(node) != null) {
>>>>>> Node resNode = getResNode(node);
>>>>>> iter = resNode.getProperties();
>>>>>> while(iter.hasNext()){
>>>>>> Property prop =
>>>>>> iter.nextProperty();
>>>>>> if
>>>>>> (!prop.getDefinition().isMultiple()) {
>>>>>>
>>>>>> properties.put(prop.getName(), prop.getValue().getString());
>>>>>> }
>>>>>> }
>>>>>> }
>>>>>
>>>>> I don't know what getResNode(node) does, but I suppose it loads some
>>>>> other
>>>>> node
>>>>> which is different to the one retrieved by the query. If you remove
>>>>> this
>>>>> if-block the uuids should be equal as far as I can see.
>>>>> And as Brian already wrote: you should be better off using
>>>>> session.getNodeByUUID() instead of using a query. This method performs
>>>>> much
>>>>> faster than a query.
>>>>>
>>>>> Cheers,
>>>>> Christoph
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/UUID-tp9616867p25467222.html
>>>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/UUID-tp9616867p25469884.html
>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/UUID-tp9616867p25471938.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: UUID
Posted by Stefan Guggisberg <st...@gmail.com>.
On Wed, Sep 16, 2009 at 12:39 PM, freak182 <em...@gmail.com> wrote:
>
> Hello,
>
> it does not fail on the assert becuase i set this before saving:
> fileContent.addMixin(JcrConstants.MIX_REFERENCEABLE);
> and i wonder why now it is not working? still when i access this:
> nodeToRemove.getUUID(); throws an exception.
can you provide a simple test case?
please also provide detailed information about your environment.
cheers
stefan
>
> cheers.
>
>
> Stefan Guggisberg wrote:
>>
>> On Wed, Sep 16, 2009 at 9:19 AM, freak182 <em...@gmail.com> wrote:
>>>
>>> Hello,
>>>
>>> I have problem retreiving the uuid?
>>> here is the scenario:
>>>
>>> when i save the file, here is the code:
>>>
>>> .................................
>>>
>>> Node file = folder.addNode(name, "nt:file");
>>> Node fileContent = file.addNode("jcr:content", "nt:resource");
>>> fileContent.addMixin(JcrConstants.MIX_REFERENCEABLE);
>>>
>>> session.save();
>>> uuid = fileContent.getUUID();
>>>
>>> ..this save fine and some metadata save in DB also including the uuid.
>>>
>>> Now i want to delete the file:
>>>
>>> Node nodeToRemove = session.getRootNode().getNode(path.substring(1));
>>> String uuid = nodeToRemove.getUUID(); ---> error here
>>> if (nodeToRemove != null)
>>> {
>>> nodeToRemove.remove();
>>> session.save();
>>>
>>> //
>>> jcrFileStorageDao.delete(jcrFileStorageDao.loadByUUID(uuid));
>>> }
>>>
>>> javax.jcr.UnsupportedRepositoryOperationException
>>> at org.apache.jackrabbit.core.NodeImpl.getUUID(NodeImpl.java:3040)
>>
>> nodeToRemove is probably not mix:referenceable. you can test this by
>> adding
>>
>> assert(node.isNodeType(JcrConstants.MIX_REFERENCEABLE));
>>
>> cheers
>> stefan
>>
>>>
>>> how can i resolve this?
>>>
>>> thanks a lot.
>>> cheers.
>>>
>>>
>>> Christoph Kiehl-3 wrote:
>>>>
>>>> Michal Hybler wrote:
>>>>
>>>>> I have this method
>>>>>
>>>>> ws = session.getWorkspace();
>>>>> manager = ws.getQueryManager();
>>>>> query = manager.createQuery("select * from
>>>>> nt:unstructured where
>>>>> jcr:uuid
>>>>> = '"+id+"'",Query.SQL);
>>>>> QueryResult result = query.execute();
>>>>> NodeIterator it = result.getNodes();
>>>>> return it.nextNode();
>>>>> with Id which I remembered when I insert file into jackrabbit.
>>>>>
>>>>> after that I run this code
>>>>>
>>>>> HashMap<String,String> properties = new HashMap<String,String>();
>>>>> try {
>>>>> PropertyIterator iter = node.getProperties();
>>>>> while(iter.hasNext()){
>>>>> Property prop = iter.nextProperty();
>>>>> if (!prop.getDefinition().isMultiple()) {
>>>>> properties.put(prop.getName(),
>>>>> prop.getValue().getString());
>>>>> }
>>>>>
>>>>> }
>>>>> if (getResNode(node) != null) {
>>>>> Node resNode = getResNode(node);
>>>>> iter = resNode.getProperties();
>>>>> while(iter.hasNext()){
>>>>> Property prop =
>>>>> iter.nextProperty();
>>>>> if
>>>>> (!prop.getDefinition().isMultiple()) {
>>>>>
>>>>> properties.put(prop.getName(), prop.getValue().getString());
>>>>> }
>>>>> }
>>>>> }
>>>>
>>>> I don't know what getResNode(node) does, but I suppose it loads some
>>>> other
>>>> node
>>>> which is different to the one retrieved by the query. If you remove this
>>>> if-block the uuids should be equal as far as I can see.
>>>> And as Brian already wrote: you should be better off using
>>>> session.getNodeByUUID() instead of using a query. This method performs
>>>> much
>>>> faster than a query.
>>>>
>>>> Cheers,
>>>> Christoph
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/UUID-tp9616867p25467222.html
>>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/UUID-tp9616867p25469884.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>
Re: UUID
Posted by freak182 <em...@gmail.com>.
Hello,
it does not fail on the assert becuase i set this before saving:
fileContent.addMixin(JcrConstants.MIX_REFERENCEABLE);
and i wonder why now it is not working? still when i access this:
nodeToRemove.getUUID(); throws an exception.
cheers.
Stefan Guggisberg wrote:
>
> On Wed, Sep 16, 2009 at 9:19 AM, freak182 <em...@gmail.com> wrote:
>>
>> Hello,
>>
>> I have problem retreiving the uuid?
>> here is the scenario:
>>
>> when i save the file, here is the code:
>>
>> .................................
>>
>> Node file = folder.addNode(name, "nt:file");
>> Node fileContent = file.addNode("jcr:content", "nt:resource");
>> fileContent.addMixin(JcrConstants.MIX_REFERENCEABLE);
>>
>> session.save();
>> uuid = fileContent.getUUID();
>>
>> ..this save fine and some metadata save in DB also including the uuid.
>>
>> Now i want to delete the file:
>>
>> Node nodeToRemove = session.getRootNode().getNode(path.substring(1));
>> String uuid = nodeToRemove.getUUID(); ---> error here
>> if (nodeToRemove != null)
>> {
>> nodeToRemove.remove();
>> session.save();
>>
>> //
>> jcrFileStorageDao.delete(jcrFileStorageDao.loadByUUID(uuid));
>> }
>>
>> javax.jcr.UnsupportedRepositoryOperationException
>> at org.apache.jackrabbit.core.NodeImpl.getUUID(NodeImpl.java:3040)
>
> nodeToRemove is probably not mix:referenceable. you can test this by
> adding
>
> assert(node.isNodeType(JcrConstants.MIX_REFERENCEABLE));
>
> cheers
> stefan
>
>>
>> how can i resolve this?
>>
>> thanks a lot.
>> cheers.
>>
>>
>> Christoph Kiehl-3 wrote:
>>>
>>> Michal Hybler wrote:
>>>
>>>> I have this method
>>>>
>>>> ws = session.getWorkspace();
>>>> manager = ws.getQueryManager();
>>>> query = manager.createQuery("select * from
>>>> nt:unstructured where
>>>> jcr:uuid
>>>> = '"+id+"'",Query.SQL);
>>>> QueryResult result = query.execute();
>>>> NodeIterator it = result.getNodes();
>>>> return it.nextNode();
>>>> with Id which I remembered when I insert file into jackrabbit.
>>>>
>>>> after that I run this code
>>>>
>>>> HashMap<String,String> properties = new HashMap<String,String>();
>>>> try {
>>>> PropertyIterator iter = node.getProperties();
>>>> while(iter.hasNext()){
>>>> Property prop = iter.nextProperty();
>>>> if (!prop.getDefinition().isMultiple()) {
>>>> properties.put(prop.getName(),
>>>> prop.getValue().getString());
>>>> }
>>>>
>>>> }
>>>> if (getResNode(node) != null) {
>>>> Node resNode = getResNode(node);
>>>> iter = resNode.getProperties();
>>>> while(iter.hasNext()){
>>>> Property prop =
>>>> iter.nextProperty();
>>>> if
>>>> (!prop.getDefinition().isMultiple()) {
>>>>
>>>> properties.put(prop.getName(), prop.getValue().getString());
>>>> }
>>>> }
>>>> }
>>>
>>> I don't know what getResNode(node) does, but I suppose it loads some
>>> other
>>> node
>>> which is different to the one retrieved by the query. If you remove this
>>> if-block the uuids should be equal as far as I can see.
>>> And as Brian already wrote: you should be better off using
>>> session.getNodeByUUID() instead of using a query. This method performs
>>> much
>>> faster than a query.
>>>
>>> Cheers,
>>> Christoph
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/UUID-tp9616867p25467222.html
>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>
>>
>
>
--
View this message in context: http://www.nabble.com/UUID-tp9616867p25469884.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: UUID
Posted by Stefan Guggisberg <st...@gmail.com>.
On Wed, Sep 16, 2009 at 9:19 AM, freak182 <em...@gmail.com> wrote:
>
> Hello,
>
> I have problem retreiving the uuid?
> here is the scenario:
>
> when i save the file, here is the code:
>
> .................................
>
> Node file = folder.addNode(name, "nt:file");
> Node fileContent = file.addNode("jcr:content", "nt:resource");
> fileContent.addMixin(JcrConstants.MIX_REFERENCEABLE);
>
> session.save();
> uuid = fileContent.getUUID();
>
> ..this save fine and some metadata save in DB also including the uuid.
>
> Now i want to delete the file:
>
> Node nodeToRemove = session.getRootNode().getNode(path.substring(1));
> String uuid = nodeToRemove.getUUID(); ---> error here
> if (nodeToRemove != null)
> {
> nodeToRemove.remove();
> session.save();
>
> // jcrFileStorageDao.delete(jcrFileStorageDao.loadByUUID(uuid));
> }
>
> javax.jcr.UnsupportedRepositoryOperationException
> at org.apache.jackrabbit.core.NodeImpl.getUUID(NodeImpl.java:3040)
nodeToRemove is probably not mix:referenceable. you can test this by
adding
assert(node.isNodeType(JcrConstants.MIX_REFERENCEABLE));
cheers
stefan
>
> how can i resolve this?
>
> thanks a lot.
> cheers.
>
>
> Christoph Kiehl-3 wrote:
>>
>> Michal Hybler wrote:
>>
>>> I have this method
>>>
>>> ws = session.getWorkspace();
>>> manager = ws.getQueryManager();
>>> query = manager.createQuery("select * from nt:unstructured where
>>> jcr:uuid
>>> = '"+id+"'",Query.SQL);
>>> QueryResult result = query.execute();
>>> NodeIterator it = result.getNodes();
>>> return it.nextNode();
>>> with Id which I remembered when I insert file into jackrabbit.
>>>
>>> after that I run this code
>>>
>>> HashMap<String,String> properties = new HashMap<String,String>();
>>> try {
>>> PropertyIterator iter = node.getProperties();
>>> while(iter.hasNext()){
>>> Property prop = iter.nextProperty();
>>> if (!prop.getDefinition().isMultiple()) {
>>> properties.put(prop.getName(), prop.getValue().getString());
>>> }
>>>
>>> }
>>> if (getResNode(node) != null) {
>>> Node resNode = getResNode(node);
>>> iter = resNode.getProperties();
>>> while(iter.hasNext()){
>>> Property prop = iter.nextProperty();
>>> if (!prop.getDefinition().isMultiple()) {
>>> properties.put(prop.getName(), prop.getValue().getString());
>>> }
>>> }
>>> }
>>
>> I don't know what getResNode(node) does, but I suppose it loads some other
>> node
>> which is different to the one retrieved by the query. If you remove this
>> if-block the uuids should be equal as far as I can see.
>> And as Brian already wrote: you should be better off using
>> session.getNodeByUUID() instead of using a query. This method performs
>> much
>> faster than a query.
>>
>> Cheers,
>> Christoph
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/UUID-tp9616867p25467222.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>
Re: UUID
Posted by freak182 <em...@gmail.com>.
Hello,
I have problem retreiving the uuid?
here is the scenario:
when i save the file, here is the code:
.................................
Node file = folder.addNode(name, "nt:file");
Node fileContent = file.addNode("jcr:content", "nt:resource");
fileContent.addMixin(JcrConstants.MIX_REFERENCEABLE);
session.save();
uuid = fileContent.getUUID();
..this save fine and some metadata save in DB also including the uuid.
Now i want to delete the file:
Node nodeToRemove = session.getRootNode().getNode(path.substring(1));
String uuid = nodeToRemove.getUUID(); ---> error here
if (nodeToRemove != null)
{
nodeToRemove.remove();
session.save();
// jcrFileStorageDao.delete(jcrFileStorageDao.loadByUUID(uuid));
}
javax.jcr.UnsupportedRepositoryOperationException
at org.apache.jackrabbit.core.NodeImpl.getUUID(NodeImpl.java:3040)
how can i resolve this?
thanks a lot.
cheers.
Christoph Kiehl-3 wrote:
>
> Michal Hybler wrote:
>
>> I have this method
>>
>> ws = session.getWorkspace();
>> manager = ws.getQueryManager();
>> query = manager.createQuery("select * from nt:unstructured where
>> jcr:uuid
>> = '"+id+"'",Query.SQL);
>> QueryResult result = query.execute();
>> NodeIterator it = result.getNodes();
>> return it.nextNode();
>> with Id which I remembered when I insert file into jackrabbit.
>>
>> after that I run this code
>>
>> HashMap<String,String> properties = new HashMap<String,String>();
>> try {
>> PropertyIterator iter = node.getProperties();
>> while(iter.hasNext()){
>> Property prop = iter.nextProperty();
>> if (!prop.getDefinition().isMultiple()) {
>> properties.put(prop.getName(), prop.getValue().getString());
>> }
>>
>> }
>> if (getResNode(node) != null) {
>> Node resNode = getResNode(node);
>> iter = resNode.getProperties();
>> while(iter.hasNext()){
>> Property prop = iter.nextProperty();
>> if (!prop.getDefinition().isMultiple()) {
>> properties.put(prop.getName(), prop.getValue().getString());
>> }
>> }
>> }
>
> I don't know what getResNode(node) does, but I suppose it loads some other
> node
> which is different to the one retrieved by the query. If you remove this
> if-block the uuids should be equal as far as I can see.
> And as Brian already wrote: you should be better off using
> session.getNodeByUUID() instead of using a query. This method performs
> much
> faster than a query.
>
> Cheers,
> Christoph
>
>
>
--
View this message in context: http://www.nabble.com/UUID-tp9616867p25467222.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: UUID
Posted by Christoph Kiehl <ch...@sulu3000.de>.
Michal Hybler wrote:
> I have this method
>
> ws = session.getWorkspace();
> manager = ws.getQueryManager();
> query = manager.createQuery("select * from nt:unstructured where jcr:uuid
> = '"+id+"'",Query.SQL);
> QueryResult result = query.execute();
> NodeIterator it = result.getNodes();
> return it.nextNode();
> with Id which I remembered when I insert file into jackrabbit.
>
> after that I run this code
>
> HashMap<String,String> properties = new HashMap<String,String>();
> try {
> PropertyIterator iter = node.getProperties();
> while(iter.hasNext()){
> Property prop = iter.nextProperty();
> if (!prop.getDefinition().isMultiple()) {
> properties.put(prop.getName(), prop.getValue().getString());
> }
>
> }
> if (getResNode(node) != null) {
> Node resNode = getResNode(node);
> iter = resNode.getProperties();
> while(iter.hasNext()){
> Property prop = iter.nextProperty();
> if (!prop.getDefinition().isMultiple()) {
> properties.put(prop.getName(), prop.getValue().getString());
> }
> }
> }
I don't know what getResNode(node) does, but I suppose it loads some other node
which is different to the one retrieved by the query. If you remove this
if-block the uuids should be equal as far as I can see.
And as Brian already wrote: you should be better off using
session.getNodeByUUID() instead of using a query. This method performs much
faster than a query.
Cheers,
Christoph
Re: UUID
Posted by Michal Hybler <m....@email.cz>.
Christoph Kiehl-3 wrote:
>
> Michal Hybler wrote:
>> I have question is the property jcr:uuid same as node.getUUID()?
>>
>> because if I ask for uuid by this method node.getUUID() and after that If
>> I
>> request for UUID by this way:
>>
>> HashMap<String,String> properties = new HashMap<String,String>();
>>
>> PropertyIterator iter = node.getProperties();
>> while(iter.hasNext()){
>> Property prop = iter.nextProperty();
>> if (!prop.getDefinition().isMultiple()) {
>> properties.put(prop.getName(), prop.getValue().getString());
>> }
>>
>> }
>
> Could you please provide more of your source code, especially the part
> where you
> call node.getUUID() and the part where your console output happens?
>
> Thanks,
> Christoph
>
>
>
>
I have this method
ws = session.getWorkspace();
manager = ws.getQueryManager();
query = manager.createQuery("select * from nt:unstructured where jcr:uuid
= '"+id+"'",Query.SQL);
QueryResult result = query.execute();
NodeIterator it = result.getNodes();
return it.nextNode();
with Id which I remembered when I insert file into jackrabbit.
after that I run this code
HashMap<String,String> properties = new HashMap<String,String>();
try {
PropertyIterator iter = node.getProperties();
while(iter.hasNext()){
Property prop = iter.nextProperty();
if (!prop.getDefinition().isMultiple()) {
properties.put(prop.getName(), prop.getValue().getString());
}
}
if (getResNode(node) != null) {
Node resNode = getResNode(node);
iter = resNode.getProperties();
while(iter.hasNext()){
Property prop = iter.nextProperty();
if (!prop.getDefinition().isMultiple()) {
properties.put(prop.getName(), prop.getValue().getString());
}
}
}
} catch (RepositoryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
and write map on console
Set keys = properties.keySet();
Iterator iter = keys.iterator();
while (iter.hasNext()) {
String key = (String) iter.next();
String value = properties.get(key);
System.out.println("property "+key+" with value "+value);
}
UUID which this code writes on the console is distinct from id which I
insert on the start of code. If I insert This id which is shown on the
console the repository returns no file.
--
View this message in context: http://www.nabble.com/UUID-tf3448236.html#a9618986
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: UUID
Posted by Christoph Kiehl <ch...@sulu3000.de>.
Michal Hybler wrote:
> I have question is the property jcr:uuid same as node.getUUID()?
>
> because if I ask for uuid by this method node.getUUID() and after that If I
> request for UUID by this way:
>
> HashMap<String,String> properties = new HashMap<String,String>();
>
> PropertyIterator iter = node.getProperties();
> while(iter.hasNext()){
> Property prop = iter.nextProperty();
> if (!prop.getDefinition().isMultiple()) {
> properties.put(prop.getName(), prop.getValue().getString());
> }
>
> }
Could you please provide more of your source code, especially the part where you
call node.getUUID() and the part where your console output happens?
Thanks,
Christoph