jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From freak182 <eman.noll...@gmail.com>
Subject Re: UUID
Date Thu, 17 Sep 2009 05:37:44 GMT

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 <eman.nollase@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 <eman.nollase@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.


Mime
View raw message