I have added a servlet to the BASE webapp that does the following: SessionControl sc = Application.newSessionControl("net.sf.basedb.clients.web", request.getRemoteAddr(), null); sc.login(username, password, null, false); DbControl dc = sc.newDbControl(); sc.setActiveProject(Project.getById(dc, projectId)); dc.close(); response.sendRedirect(String.format("/base/views/experiments/index.jsp?ID=%s&cmd=ViewItem&item_id=%s", sc.getId(), experimentId));
Haven't done much testing, but seems to work so far. I'm passing in the project ID because an experiment can be shared with more than one project (as previously discussed). I could make more of an effort to avoid creating unnecessary sessions, but not sure if this is worthwhile. Presumably I could avoid passing the user's password by putting the root password in the servlet and impersonating the real user. Thanks for all the help, Mark. ________________________________________ From: basedb-devel-boun...@lists.sourceforge.net [basedb-devel-boun...@lists.sourceforge.net] On Behalf Of Bob MacCallum [r.maccal...@imperial.ac.uk] Sent: 08 January 2010 14:48 To: lefev...@yahoo.com; BASE dev Subject: Re: [basedb-devel] Setting active project via API A long time ago now, I remember having problems with experiments/projects. You would think it would be enough to add "Everyone" group to the project and then it would be visible, but as others have pointed out, the project has to be active before the expt is visible. We decided to just share all project items to Everyone and be done with it(*). You might get the granularity you need by sharing to groups instead. (* thanks to the BASE developers, we got a much increased max items limit in list view to make this easy to do) Olivier Lefevre writes: > >> Disregarding that, do you have any ideas about how to > >> link directly to an Experiment without getting the > >> 'permission denied' error caused by the wrong project > >> being selected? > > > > You can't link directly. You need to set the active > > project first. > > ?? AFAIK this is the first time this comes up. Why isn't > it enough to be logged and to have permission to view > the experiments in questions. Direct links to experiments > are possible: they have the form > http://localhost:8080/base2/views/experiments/index.jsp?ID=xxx&cmd=ViewItem&item_id=nnn > > -- O.L. > > > ------------------------------------------------------------------------------ > This SF.Net email is sponsored by the Verizon Developer Community > Take advantage of Verizon's best-in-class app development support > A streamlined, 14 day to market process makes app distribution fast and easy > Join now and get one step closer to millions of Verizon customers > http://p.sf.net/sfu/verizon-dev2dev > _______________________________________________ > basedb-devel mailing list > basedb-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/basedb-devel -- Bob MacCallum | VectorBase Developer | Kafatos/Christophides Groups | Division of Cell and Molecular Biology | Imperial College London | Phone +442075941945 | Email r.maccal...@imperial.ac.uk ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ basedb-devel mailing list basedb-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/basedb-devel ------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev _______________________________________________ basedb-devel mailing list basedb-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/basedb-devel