[Building Sakai] Custom POST Entity Broker

Paul Wando Mungai paulwando at gmail.com
Tue Nov 13 03:12:06 PST 2012


I write an entity broker that will add resources to sakai site resource.
This works when using a get. I then converted it to handle post (
VIEW_NEW ). I create a http post request with the necessary parameters
appended to it:

POST
http://elearn-dev.wits.ac.za/direct/batch?_refs=/direct/addsiteresource/site/OCCT1000_2012HTTP/1.1

However, I get the error bellow and am not sure of the cause;

Failure attempting to process reference
(\/direct\/addsiteresource\/site\/OCCT1000_2012) for url
(\/direct\/addsiteresource\/site\/OCCT1000_2012): Could not parse the
incoming path (\/addsiteresource\/site\/OCCT1000_2012) and no entity
provider could be found to handle the
prefix:org.sakaiproject.entitybroker.exception.EntityException: Could not
parse the incoming path (\/addsiteresource\/site\/OCCT1000_2012) and no
entity provider could be found to handle the prefix


My implementation is as follows:
-----------------------------------------------------------------------------------------------------------------------------------------------------------
public interface WitsEAddSiteResourceEntityProvider extends EntityProvider {

    public final static String ENTITY_PREFIX = "addsiteresource";
}
-----------------------------------------------------------------------------------------------------------------------------------------------------------
public class WitsEAddSiteResourceEntityProviderImpl implements
        WitsEAddSiteResourceEntityProvider, CoreEntityProvider, CRUDable,
        CollectionResolvable, Outputable, Inputable, Describeable,
ActionsExecutable {

    private ContentHostingService contentHostingService;
    private SessionManager sessionManager;


@Override
    public String getEntityPrefix() {
        return ENTITY_PREFIX;
    }

    /**
     * site/siteId
     */
    @EntityCustomAction(action = "site", viewKey = EntityView.VIEW_NEW)
    public List<SiteResource> addSiteResource(EntityView view,
EntityReference ref,
            String prefix, Search search, OutputStream out,
            Map<String, Object> params) {
        //Get site Id
        String siteId = view.getPathSegment(2); //check if null

        List<SiteResource> siteResources = new ArrayList<SiteResource>();
        //Get post params
        String userId = params.get("userId").toString(); // check if null...
        .............................
        return siteResources;
    }

-----------------------------------------------------------------------------------------------------------------------------------------------------------


-- 
Regards,
Paul Mungai

"Ability is what youre capable of doing. Motivation determines what you do.
Attitude determines how well you do it" By Lou Holtz, Notre Dame Football
Coach
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://collab.sakaiproject.org/pipermail/sakai-dev/attachments/20121113/2d6373aa/attachment.html 


More information about the sakai-dev mailing list