Re: [xwiki-users] Using HTML5 File Upload Widget for non-XWiki files
On 11/14/2014 11:24 PM, Bryn Jeffries wrote: > I asked: >>> I'd like to upload files through a custom File Upload servlet that runs >>> from the >>> same Tomcat server but is not part of XWiki. > [...] >>> Is it possible to make use of the supplied XWiki UI widgets to upload to >>> this >>> servlet? Any guidance on how to do this would be greatly appreciated. > > Marius said: >> See http://platform.xwiki.org/xwiki/bin/view/DevGuide/HTML5Upload for >> how to use the file upload widget inside XWiki. > > This has been helpful, thanks. Is it possible for me to get hold of any xwiki > session information within my external servlet? I'd like to know the XWiki > name of the user that's uploading the file. > I guess it is possible to do that, but you would have to write a component that is: - a custom XWiki authenticator http://platform.xwiki.org/xwiki/bin/view/AdminGuide/Authentication#HCustomAuthentication to store the session id on login (and remove it at logout) - and maybe a Session listener: https://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpSessionListener.html to handle session timeout - finally has an API to communicate that information to the external servlet, without leaking the session-ids to other "interested" parties Somehow that does not look like a good idea to me. > Presumably one way would be to include the user name in the form request, > though browsing through some of the code > (https://github.com/xwiki/xwiki-platform/blob/stable-6.2.x/xwiki-platform-core/xwiki-platform-web/src/main/webapp/resources/uicomponents/widgets/upload.js) > it looks at first glance that there's no way to add this unless I paste them > as GET variables in the action URL. > The alternative to fiddeling with form action is to use hidden form fields; these should be send to the target in the same way as the form action. To do this you are back in server-side template-land (instead of JavaScript), where you should be able to say something like (cobbled together with the help of http://platform.xwiki.org/xwiki/bin/view/SRD/Navigation?xpage=embed , untested ...) This data then should be send to the upload servlet. Admittedly this is not spoof-proof (anyone e.g. can use a brwoser-dev tool like firebug and edit the values before uploading the file). If you want "safe and secure" method, you might consider "container authentication" (i.e. users come from the servlet container) http://platform.xwiki.org/xwiki/bin/view/AdminGuide/Authentication#HContainerAuthentication then the upload servlet has the same user as XWiki (except for "XWiki-only users, for which the widget will just not work). Oh, and if the servlet really moves to a different server ... well, maybe it works to set up a distributed user authentication like CAS. just a few thoughts as I came along, use at own risk ;) > Alternatively if the file submission has corresponding session data (not sure > whether this is the case) would it be possible for my servlet to request the > user name from XWIki in some way? > ___ > users mailing list > users@xwiki.org > http://lists.xwiki.org/mailman/listinfo/users > ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] How to get The jobExecutor
It depends where you are exactly. org.xwiki.job.JobExecutor is a component role so you need to either inject it if you are yourself in a component or access the ComponentManager (but again it depends it which situation you are exacly), see http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HUsingAnnotations for more details about components. If you created you own jobs you probably seen already how components are working. On Sat, Nov 15, 2014 at 11:47 AM, Stefan Bernsdorf wrote: > Hi, > I wanted to use the snip from page > http://extensions.xwiki.org/xwiki/bin/view/Extension/Job+Module > > >Request jobRequest = new DefaultRequest(); > >// Indicate an id to allow you to access the status of this >unique task, the id is required to save/retrieve the status of >the job >jobRequest.setId("taskid"); >// Allow the job to ask questions during its executing (false by >default) >jobRequest.setInteractive(true); >// [since 5.4] Indicate if the job should log informations about >what is going on (to display it during the process for example, >true by default) >jobRequest.setVerbose(true); >// Put some custom configuration >jobRequest.setProperty("some custom jobtype related parameter", >"value"); > >// Lookup and execute Job with role hint "jobtype" and wait for >it to be finished >jobManager.executeJob("jobtype", request) > >// Lookup and add Job with role hint "jobtype" to the queue >queue and return right away >Job job = jobManager.addJob("jobtype", request) > >// Wait until the job is finished >job.join() > > .. > to be able to create my own job and job request. But how is the jobManager > injected? When I use the snip, the > the jobManager is null. > ___ > users mailing list > users@xwiki.org > http://lists.xwiki.org/mailman/listinfo/users -- Thomas Mortagne ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
[xwiki-users] How to get The jobExecutor
Hi, I wanted to use the snip from page http://extensions.xwiki.org/xwiki/bin/view/Extension/Job+Module Request jobRequest = new DefaultRequest(); // Indicate an id to allow you to access the status of this unique task, the id is required to save/retrieve the status of the job jobRequest.setId("taskid"); // Allow the job to ask questions during its executing (false by default) jobRequest.setInteractive(true); // [since 5.4] Indicate if the job should log informations about what is going on (to display it during the process for example, true by default) jobRequest.setVerbose(true); // Put some custom configuration jobRequest.setProperty("some custom jobtype related parameter", "value"); // Lookup and execute Job with role hint "jobtype" and wait for it to be finished jobManager.executeJob("jobtype", request) // Lookup and add Job with role hint "jobtype" to the queue queue and return right away Job job = jobManager.addJob("jobtype", request) // Wait until the job is finished job.join() .. to be able to create my own job and job request. But how is the jobManager injected? When I use the snip, the the jobManager is null. ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users