You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by "Harding, Christopher (Student Assistant)" <Ch...@softwareag.com> on 2000/11/24 13:50:41 UTC

Content Helper - .create method

Hi,
  I'm creating access to a database and I need to create collections and
resources. I can create the collections fine, but not the resources. I'm
using the content helper to create the descriptor information for a
resource. I create and polpulate a NodeRevisionDescriptor
(revisondescriptor) with NodeProperty(s) set within.

  I use the following code to call the create method of the ContentHelper.
	path is a Uri set earler in the code

	CredentialsToken credtoken = new CredentialsToken (new String("/"));
	Content content = token.getContentHelper();
	
content.create(credtoken,path.toString().trim(),revisondescriptor,null);

But I get the following exception thrown.

java.lang.NullPointerException 	
at org.apache.slide.structure.StructureImpl.retrieve(StructureImpl.java,
Compiled Code) 	
at org.apache.slide.structure.StructureImpl.retrieve(StructureImpl.java,
Compiled Code) 	
at org.apache.slide.content.ContentImpl.create(ContentImpl.java, Compiled
Code) 	
at
com.softwareag.xdav.taminoStore.TaminoRevisionDescriptorsStore.retrieveRevis
ionDescriptors(TaminoRevisionDescriptorsStore.java, Compiled Code) 	
at
org.apache.slide.store.StandardDescriptorsStore.retrieveRevisionDescriptors(
StandardDescriptorsStore.java:695) 	
at org.apache.slide.content.ContentImpl.retrieve(ContentImpl.java:171) 	
at
org.apache.slide.webdav.method.PropFindMethod.parsePropertiesOfObject(PropFi
ndMethod.java, Compiled Code) 	
at
org.apache.slide.webdav.method.PropFindMethod.executeRequest(PropFindMethod.
java, Compiled Code) 	
at org.apache.slide.webdav.method.WebdavMethod.run(WebdavMethod.java:320)

at org.apache.slide.webdav.WebdavServlet.service(WebdavServlet.java:279)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) 	
at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:387)

at org.apache.tomcat.core.Handler.service(Handler.java:263) 	
at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:371)

at
org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:74
9) 	
at org.apache.tomcat.core.ContextManager.service(ContextManager.java:695)

at
org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
onnectionHandler.java:207) 	
at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java,
Compiled Code) 	
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java,
Compiled Code) 	
at java.lang.Thread.run(Thread.java:479)

I have tracked it down and it's throw in the StructureImpl class (line 274)

securityHelper.checkCredentials
                    (token, courObject,
namespaceConfig.getReadObjectAction());

	namespaceConfig = null. 

If I use a CredentialsToken from say PropFindMethod this works without any
problems. So I guess I not creating a valid CredentialsToken. If this is
true what should I use to create a valid CredentialsToken?

Thanxs for any help

Chris Harding

                                  | | | | | | | | |
                 --------
                 ( o  o )
|-----------oo0---(    )---0oo-----------|
|  Chris Harding                         |
|     Christopher.Harding@sotwareag.com  |
|                                        |
| "Be very very quite, I'm hunting       |
|    wrabbit" - Elmer Fudd               |
|----------------------------------------|


Re: Content Helper - .create method

Posted by Remy Maucherat <re...@apache.org>.
> Hi,
>   I'm creating access to a database and I need to create collections and
> resources. I can create the collections fine, but not the resources. I'm
> using the content helper to create the descriptor information for a
> resource. I create and polpulate a NodeRevisionDescriptor
> (revisondescriptor) with NodeProperty(s) set within.
>
>   I use the following code to call the create method of the ContentHelper.
> path is a Uri set earler in the code
>
> CredentialsToken credtoken = new CredentialsToken (new String("/"));
> Content content = token.getContentHelper();
>
> content.create(credtoken,path.toString().trim(),revisondescriptor,null);
>
> But I get the following exception thrown.
>
> java.lang.NullPointerException
> at org.apache.slide.structure.StructureImpl.retrieve(StructureImpl.java,
> Compiled Code)
> at org.apache.slide.structure.StructureImpl.retrieve(StructureImpl.java,
> Compiled Code)
> at org.apache.slide.content.ContentImpl.create(ContentImpl.java, Compiled
> Code)
> at
>
com.softwareag.xdav.taminoStore.TaminoRevisionDescriptorsStore.retrieveRevis
> ionDescriptors(TaminoRevisionDescriptorsStore.java, Compiled Code)

Why are you doing that, BTW ?
A store is not supposed to access a helper. When you are down at the store
level, both security and locking should have been properly checked (if they
haven't, it's a bug). If you really need to access other objects at that
point, you should do a
Uri newUri = uri.getNamespace().getUri("the_object_you_want");
ObjectNode node = newUri.getStore().retrieveObject(newUri);

Here's what I think you should be doing in that method :
- If it would be an error if there was no content and metadata on the node,
and you expect that at least one revision is present, return a new blank
NodeRevisionDescriptors
        return new NodeRevisionDescriptors(uri.toString(), initialRevision,
                                           workingRevisions,
                                           latestRevisionNumbers,
                                           branches, isVersioned);
The isVersioned flag needs to be properly set (true is multiple revisions
are allowed, false otherwise).
- If the store is not versioned, but you want to wait for the user to create
a revision, or if the store is versioned, but there are no revisions (and no
revisionDescriptors), then don't return anything, but throw a
RevisionDescriptorNotFoundException. That shouldn't break PROPFIND, which
will use a set of default properties. The user should at some point create a
revision. All DAV methods should behave correctly (if they don't, it's a
bug).

> I have tracked it down and it's throw in the StructureImpl class (line
274)
>
> securityHelper.checkCredentials
>                     (token, courObject,
> namespaceConfig.getReadObjectAction());
>
> namespaceConfig = null.
>
> If I use a CredentialsToken from say PropFindMethod this works without any
> problems. So I guess I not creating a valid CredentialsToken. If this is
> true what should I use to create a valid CredentialsToken?

No the token should be ok.
However, if namespaceConfig is null, then there's a big problem. Perhaps
there's some sort of initialization bug (could you send me your config file,
if it's different from the default one ?).
Since you're using the NAT which has been handed out by the initialize
method, then perhaps it wasn't properly initialized. I don't think this
token is valid after the initialization is complete (I'll check).

Remy