| Author |
Message |
![[Post New]](/rsf/templates/default/images/icon_minipost_new.gif) 24/02/2009 14:05:29
|
jimeng
Request-scope Wrangler
Joined: 11/07/2006 17:41:40
Messages: 84
Offline
|
This isn't an RSF question, so maybe it should be on Sakai-Dev or someplace else. I'm hoping to get help from Aaron or someone else familiar with these issues.
I've followed suggestions from various Confluence pages, passing references in Entity Broker javadocs, and some discussion in RSF's wiki and forum. But I keep getting 404's from the direct servlet when trying to access my entity space.
I have implemented an EntityProvider that is also a CoreEntityProvider, AutoRegisterEntityProvider, and (on Antranig's suggestion) ReferenceParseable. There are some issues I'm unclear about. Here they are:
1) This refers to the required behavior of CoreEntityProvider.entityExists(String) with respect to entity spaces:
http://source.sakaiproject.org/release/2.5.3/apidocs/org/sakaiproject/entitybroker/entityprovider/CoreEntityProvider.html#entityExists(java.lang.String)
My best guess is that for an entity space, CoreEntityProvider.entityExists(String) should return false. Is that right?
2) This refers to the required behavior of EntityReference.makeEntityReference(boolean) for the parsed exemplar returned by ReferenceParseable.getParsedExemplar():
http://source.sakaiproject.org/release/2.5.3/apidocs/org/sakaiproject/entitybroker/entityprovider/capabilities/ReferenceParseable.html#getParsedExemplar()
http://source.sakaiproject.org/release/2.5.3/apidocs/org/sakaiproject/entitybroker/EntityReference.html#makeEntityReference(boolean)
I'm thinking that if spaceOnly is true it returns SEPARATOR + prefix and otherwise it returns null. That's just a wild guess.
I think there may be a few other places where it's unclear how what specific behaviors are required for an entity space vs full RESTful URLs for entities. But getting answers to these two would help a lot.
Thanks for any suggestions.
Jim
|
|
|
 |
![[Post New]](/rsf/templates/default/images/icon_minipost_new.gif) 24/02/2009 15:05:51
|
jimeng
Request-scope Wrangler
Joined: 11/07/2006 17:41:40
Messages: 84
Offline
|
Here's another question. I have fixed a problem in my RSF code (as discussed in another topic on the RSF forum), and now I get a different error from the Direct Servlet:
Request URI: /direct/ccLicense
Path Info: /ccLicense
Context path: /direct
Method: GET
java.lang.RuntimeException: Failed to invoke a constructor which takes a single string (reference=/ccLicense) for class: class org.sakaiproject.rights.impl.CreativeCommonsLicenseReference
at org.sakaiproject.entitybroker.impl.EntityBrokerManagerImpl.parseReference(EntityBrokerManagerImpl.java:25
This points up the need for a constructor when extending EntityReference. Just as a guess, here's what I'm doing:
Code:
public class CreativeCommonsLicenseReference extends EntityReference
{
public CreativeCommonsLicenseReference()
{
}
public CreativeCommonsLicenseReference(String ref)
{
this.originalReference = ref;
}
// leaving out other methods
}
I may know shortly whether that's right. My purpose in asking these questions here is to improve documentation of this code. Maybe someone will answer these questions. If not, at least other people who try to do something like this will see that these are issues they have to deal with.
|
|
|
 |
![[Post New]](/rsf/templates/default/images/icon_minipost_new.gif) 24/02/2009 15:20:25
|
jimeng
Request-scope Wrangler
Joined: 11/07/2006 17:41:40
Messages: 84
Offline
|
Sorry if I'm being too chatty about this.
So that last change moved things along a bit, but I suspect it moved in the wrong direction. Now there's a null pointer in RSF's AccessRegistrar.wrapRequest() method when handling access to my entity space:
2009-02-24 10:13:37,756 ERROR http-8080-Processor25 PonderUtilCore - Error handling access request
java.lang.NullPointerException
at uk.ac.cam.caret.sakai.rsf.entitybroker.AccessRegistrar.wrapRequest(AccessRegistrar.java:70)
at uk.ac.cam.caret.sakai.rsf.entitybroker.AccessRegistrar.access$100(AccessRegistrar.java:24)
at uk.ac.cam.caret.sakai.rsf.entitybroker.AccessRegistrar$2.handleAccess(AccessRegistrar.java:104)
at uk.ac.cam.caret.sakai.rsf.entitybroker.AccessRegistrar.handleAccess(AccessRegistrar.java:83)
at org.sakaiproject.entitybroker.rest.EntityHandlerImpl.handleAccessProvider(EntityHandlerImpl.java:861)
at org.sakaiproject.entitybroker.rest.EntityHandlerImpl.handleEntityAccess(EntityHandlerImpl.java:716)
at org.sakaiproject.entitybroker.util.servlet.DirectServlet.dispatch(DirectServlet.java:186)
at org.sakaiproject.entitybroker.util.servlet.DirectServlet.handleRequest(DirectServlet.java:157)
So I'm again puzzled about what the EntityReference constructor should do with the String passed in by org.sakaiproject.entitybroker.impl.EntityBrokerManagerImpl.parseReference().
|
|
|
 |
![[Post New]](/rsf/templates/default/images/icon_minipost_new.gif) 24/02/2009 15:32:07
|
jimeng
Request-scope Wrangler
Joined: 11/07/2006 17:41:40
Messages: 84
Offline
|
I thought maybe the problem was in the failure to provide a reference in the zero-parameter constructor, so I tried this:
Code:
public CreativeCommonsLicenseReference()
{
this.originalReference = EntityReference.SEPARATOR + CreativeCommonsLicenseProvider.ENTITY_PREFIX;
}
That did not solve the problem. I still get a null pointer at the same point in AccessRegistrar.wrapRequest().
|
|
|
 |
![[Post New]](/rsf/templates/default/images/icon_minipost_new.gif) 24/02/2009 18:15:43
|
antranig
Request-scope Wrangler
Joined: 03/04/2006 13:29:55
Messages: 643
Offline
|
What we think is that now you have the correct Spring context files in your webapp, you do not need the ReferenceParseeable capability, nor your custom EntityReference class. Try removing both of these, and report what happens - also, when/if you get the null pointer exception within AccessRegistrar, could you report what is the full URL and also the pathinfo for the incoming request?
Cheers,
A.
|
|
|
 |
![[Post New]](/rsf/templates/default/images/icon_minipost_new.gif) 24/02/2009 18:26:20
|
jimeng
Request-scope Wrangler
Joined: 11/07/2006 17:41:40
Messages: 84
Offline
|
I will remove the ReferenceParseeable capability and the custom EntityReference. I will mention that the most recent Null Pointer I mentioned was due to the custom EntityReference makeEntityReference(boolean spaceOnly) method returning a null when spaceOnly was null. The return value was dereferenced immediately in the AccessRegistrar, leading to the null pointer.
But I'm still not sure what a correct response would be in that case.
Anyway, I will remove that code and see if I get any further up the hill.
|
|
|
 |
![[Post New]](/rsf/templates/default/images/icon_minipost_new.gif) 24/02/2009 19:41:18
|
jimeng
Request-scope Wrangler
Joined: 11/07/2006 17:41:40
Messages: 84
Offline
|
I get this error when I try to use a URL of "http://localhost:8080/direct/ccLicense" in my browser:
2009-02-24 14:02:29,765 WARN http-8080-Processor25 PonderUtilCore - Got target exception of class uk.org.ponder.rsf.flow.errors.SilentRedirectException
2009-02-24 14:02:29,868 WARN http-8080-Processor25 org.sakaiproject.entitybroker.util.servlet.DirectServlet - Could not process entity: /ccLicense/LicenseDialog (404)[null]: Attempted to access an entity URL path (/ccLicense/LicenseDialog) for an entity (/ccLicense/LicenseDialog) that does not exist
I think what's happening is that Direct Servlet redirects to my handler, which is a ViewParamsInferrer that returns view params with a VIEW_ID of "License Dialog". Then the Direct Servlet throws an exception because "/ccLicense/LicenseDialog" is not a valid address.
|
|
|
 |
![[Post New]](/rsf/templates/default/images/icon_minipost_new.gif) 24/02/2009 20:39:33
|
antranig
Request-scope Wrangler
Joined: 03/04/2006 13:29:55
Messages: 643
Offline
|
No, I think that is looking a lot better. I think all you need to do is now make a return of "true" for entityExists in your provider upstairs (in the case the id is null) and you should be set to go.
|
|
|
 |
![[Post New]](/rsf/templates/default/images/icon_minipost_new.gif) 24/02/2009 21:06:34
|
jimeng
Request-scope Wrangler
Joined: 11/07/2006 17:41:40
Messages: 84
Offline
|
Good. So my first two questions in this thread have been answered.
To recap:
1) For an entity space, CoreEntityProvider.entityExists(String) should return true, no matter what value is passed in. (Maybe there should be some verification that the string is SEPARATOR + prefix or starts with SEPARATOR + prefix + SEPARATOR, but the point is that it should not return false by default).
2) There's no need fror this general case to implement ReferenceParseable, but if you are implementing ReferenceParseable, the EntityReference you return as a parsed exemplar should have constructors as described earlier. A zero-parameter constructor that sets a default value for the originalReference and a one-parameter constructor that gets the value of originalReference from the parameter.
Now I have a new problem I'll describe in the next message.
|
|
|
 |
![[Post New]](/rsf/templates/default/images/icon_minipost_new.gif) 24/02/2009 21:14:31
|
jimeng
Request-scope Wrangler
Joined: 11/07/2006 17:41:40
Messages: 84
Offline
|
Now I'm getting an infinite loop. When the URL comes in as "<base-url>/direct/ccLicense", the Direct Servlet correctly dispatches to my ViewParamsInferrer, which returns ViewParams with a viewID of "LicenseDialog" (the name of the template used by the LicenseDialogProducer, which should handle this request). So far so good. But that seems to send the request back to the DirectServlet, which processes a URL of "<base-url>/direct/ccLicense/LicenseDialog" and dispatches it back to my ViewParamsInferrer, which once again returns view params. So the URL becomes "<base-url>/direct/ccLicense/LicenseDialog/LicenseDialog" and then "<base-url>/direct/ccLicense/LicenseDialog/LicenseDialog/LicenseDialog" and then ... so on until RSF detects the cycle and bails out into the River Cam.
|
|
|
 |
![[Post New]](/rsf/templates/default/images/icon_minipost_new.gif) 24/02/2009 21:25:59
|
jimeng
Request-scope Wrangler
Joined: 11/07/2006 17:41:40
Messages: 84
Offline
|
I may have been wrong about the role of the Direct Servlet. The Direct Servlet definitely dispatches to my ViewParamsInferrer, but then the cycle may be between my ViewParamsInferrer and the AccessRegistrar. And the URL does not seem to be growing like I said, but it keeps coming back to the ViewParamsInferrer, which keeps returning the view params on each cycle. I'll do some debugging, to see if I can tell which RSF component should actually invoke the producer and why it's not doing that....
|
|
|
 |
![[Post New]](/rsf/templates/default/images/icon_minipost_new.gif) 24/02/2009 22:02:23
|
antranig
Request-scope Wrangler
Joined: 03/04/2006 13:29:55
Messages: 643
Offline
|
Is this perhaps that case where you have some "rogue material" on the page, which is trying to render a URL as if from the templates directory of the app? Does your producer get as far as producing any tree?
|
|
|
 |
![[Post New]](/rsf/templates/default/images/icon_minipost_new.gif) 25/02/2009 03:10:57
|
jimeng
Request-scope Wrangler
Joined: 11/07/2006 17:41:40
Messages: 84
Offline
|
It never gets to the producer. It's throwing a SilentRedirectException. That means it can't find the producer and/or template, doesn't it? If so, I'm wondering about the path, which is "/direct/ccLicense", a somewhat fictitious path since the tool's id and the war name is "sakai-rights-tool". But that gets us to the ViewParamsInferrer, which tells us the template is "LicenseDialog". Then the path becomes "/direct/ccLicense/LicenseDialog". Could the problem be the fictitious name? What part of RSF figures out how to find the template and/or producer? How does it know where to look for them? Is there a way I can troubleshoot this?
|
|
|
 |
![[Post New]](/rsf/templates/default/images/icon_minipost_new.gif) 25/02/2009 03:30:22
|
jimeng
Request-scope Wrangler
Joined: 11/07/2006 17:41:40
Messages: 84
Offline
|
"No ViewComponentProducer is registered for view LicenseDialog". There's the problem. LicenseDialogProducer implements ComponentProducer and not ViewComponentProducer. Hmmm. This producer is also a ContentTypeReporter which renders an HTML_FRAGMENT. Should that be a ViewComponentProducer?
|
|
|
 |
![[Post New]](/rsf/templates/default/images/icon_minipost_new.gif) 25/02/2009 05:13:51
|
jimeng
Request-scope Wrangler
Joined: 11/07/2006 17:41:40
Messages: 84
Offline
|
I switched to ViewComponentProducer and that made it all good. There were problems in the producer also, but once the fillComponents() method was called, those were easy to fix. Thanks, once again, Antranig, for all your help.
|
|
|
 |
|
|