Hi Eduard,
thanks a lot for your prompt reply. The URL I pass directly into
browser's setUrl method is correct. The problem is this is somehow
corrupted xwiki server reply -- I'm talking about this attempt to load
login page. I really set just
http://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/....
Thanks to your help with authentication in setUrl, I've used that and
now I see the browser correctly load the page. Now the problem appears
when I click on<save and view> (or<preview>,<save and continue>), the
result of this is always redirection to the login page which fails with
the same result like before:
HTTP Status 404 -
/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWikiLogin;jsessionid=7001CAC3C899FC78CA5481E87AA82D06
There are still some problems when the webapp name contains dashes. Try
to rename the application to something without dashes, like simply "xwiki".
type Status report
message
/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWikiLogin;jsessionid=7001CAC3C899FC78CA5481E87AA82D06
description The requested resource
(/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWikiLogin;jsessionid=7001CAC3C899FC78CA5481E87AA82D06)
is not available.
Apache Tomcat/7.0.12
Now my question is how to get the session cookie back from the browser
after displaying the page? It seems I can use .getCookie method, but I
don't know cookie's name in this case.
Also I've submitted
http://jira.xwiki.org/jira/browse/XECLIPSE-153 -- as
per your advice.
Thanks!
Karel
On 06/14/11 11:21 AM, Eduard Moraru wrote:
> Hi Karel,
>
> On 06/13/2011 04:17 PM, Karel Gardas wrote:
>>
>> Hi Eduard,
>>
>> thanks a lot for your advices given below. At this project state I'm
>> going with as simple as possible solution so I created special simple
>> web page for listing all the template providers as per your advice and
>> this runs well. On the other hand I do have some issue running running
>> SWT browser as part of new page wizard. The problem is authentication,
>> or better its lack of. Although I pass to the browser correct page
>> URL, the output of the browser is always:
>>
>> HTTP Status 404 -
>>
/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWikiLogin
>>
>> type Status report
>>
>> message
>>
/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWikiLogin
>>
>> description The requested resource
>>
(/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWikiLogin)
>> is not available.
>> Apache Tomcat/7.0.12
> Well, from what I can see, you are trying to access a malformed URL.
>
"/xwiki-enterprise-web-3.1-SNAPSHOThttp://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWikiLogin"
> seems to have 2 problems:
> 1) the first part "/xwiki-enterprise-web-3.1-SNAPSHOT" does not belong
here.
> 2) the webapp part of the URL:
>
"http://localhost:8080/xwiki-enterprise-web-3.1-SNAPSHOT/bin/login/XWiki/XWikiLogin",
> more exactly "xwiki-enterprise-web-3.1-SNAPSHOT", if you did not modify
> the default db in xwiki.cfg, should be just "xwiki".
> So, the correct URL should be:
> "http://localhost:8080/xwiki/bin/login/XWiki/XWikiLogin"
>
> Now, regarding authentication... A solution is to send, with each HTTP
> request that you do, a HTTP Auth header providing user/password. You can
> also choose to send it only once per session and reuse the session
> cookie that XWiki will return after the first request that contains the
> HTTP auth header.
>
> If you use the SWT Browser to directly access an XWiki page, you can
> pass the HTTP Auth header by using the setUrl(...) method trough
> something like this:
> browser.setUrl("http://localhost:8080/xwiki/bin/view/XWiki/APrivatePage",
> null,
> new String[] {"Authorization: Basic QWRtaW46YWRtaW4="});
> the QWRtaW46YWRtaW4= is the Base64 encoding of Admin:admin. You can
> generate you own Base64 encoding of a user:password combination and pass
> that instead. If you choose to use a simple HTTP client to retrieve the
> HTML of a page and the render it with a browser, you`ll have to pass the
> user:password to that client instead.
>>
>> Anyway, I tested the URL in external browser and it's working fine
>> there -- please note I'm logged in in this browser.
>>
>> I've attempted to hack the code to convince browser to authenticate by
>> using authentication listener:
>>
>> browser = new Browser(browserComposite, SWT.NONE);
>> browser.addAuthenticationListener(new AuthenticationListener() {
>>
>> public void authenticate(AuthenticationEvent event) {
>> // TODO Auto-generated method stub
>>
>> System.err.println("AuthenticationListener::authenticate: " +
>> event.toString());
>> event.user = "Admin";
>> event.password = "admin";
>> event.doit = true;
>> }
>> });
>>
>>
>> but this is not even invoked. Do you have any idea how to solve this?
> The authentication listener would not trigger because XWiki does not
> return 401 Unauthorized when tryin to access a restricted page, but
> instead provides it's own authentication ui/page. However, passing an
> Authorization header to a restricted page will automatically perform the
> login and you can then reuse the session token instead of passing the
> user/password for each request.
>> I see that preview browser is always running in non-authenticated mode
>> (or what I've researched so far) although connection in Explorer is
>> authenticated...
>>
> Yes, it might be a nice to have feature (authenticated preview window).
> Could you please add a jira issue for it?
>
http://jira.xwiki.org/jira/browse/XECLIPSE
>
> Thanks,
> Eduard
>> If you are curious I'm free to submit all changes in a form of
>> preferred diff to the original RFE, especially if it helps you advice
>> me how to proceed from here...
>>
>> Thanks!
>> Karel
>>
>> On 06/ 2/11 10:14 PM, Eduard Moraru wrote:
>>> Hi Karel,
>>>
>>> On 06/02/2011 07:54 PM, Karel Gardas wrote:
>>>> Hello,
>>>>
>>>> I'm back to this task. I've searched JIRA for related RFE/BUG but
have
>>>> not found anything so I created my own:
>>>>
http://jira.xwiki.org/jira/browse/XECLIPSE-152
>>>>
>>>> My basic idea about UI is that XEclipse New Page wizard will be
>>>> enhanced
>>>> to provide a field "Template" where user will be able to
select
>>>> appropriate template provider (as they are set in Administration>
>>>> Content> Templates).
>>> In order to get the list of templates in XEclipse, you would need a
>>> service that does internally a HQL like this:
>>>
>>> #set($availableProviders = $xwiki.searchDocuments(", BaseObject obj
>>> where doc.fullName=obj.name and
>>> obj.className='XWiki.TemplateProviderClass' and
>>> doc.fullName!='XWiki.TemplateProviderTemplate'"))
>>> (taken from XWiki.AdminTemplatesSheet, the page that displays the
>>> content in Administration> Content> Templates)
>>>
>>> The service can be either a REST extension (java component) or a wiki
>>> page called with ?xpage=plain (to return the result in some custom xml
>>> or just csv).
>>>> If he/she sets some, then while clicking on Next
>>>> button (to be added) it'll render the page of the template provider
>>>> form
>>>> to the wizard window, the user will be able to fill it and then hit
>>>> Finish button to actually save the page.
>>> Both to avoid reimplementing the template mechanism and the rendering of
>>> the template form, one rather simple solution would be to display in an
>>> SWT Browser control the result of a page like
>>>
http://localhost:8080/xwiki/bin/inline/Main/MyNewPage?parent=Main.AParentPa…
>>>
>>> (the type of link generated by the create page dialog in XWiki).
>>> Basically you show the XWiki page inside your wizard.
>>> The problem with this approach is that you end up with unnecessary
>>> header, panels and footer when you`re only interested in the page
>>> content. Besides that, you also have the save, save&continue and cancel
>>> buttons that are kind of conflicting with your wizard's buttons and
>>> flow.
>>>
>>> Not sure about this, but one solution may be to extract from the big
>>> HTML, only the document content, excluding the bottom buttons. You`d
>>> better inspect (with firebug) the structure of the page to see what you
>>> need and what you don`t.
>>>
>>> A second partial solution would be to append ?xpage=plain to the above
>>> link and you will end up only with the rendered document content in
>>> inline mode (so you can have inputs and such). The only disadvantage I
>>> see here is that, if your template uses non-inline javascript (trough a
>>> JavaScriptExtension for example or the js already available in XWiki),
>>> it will not be available in the rendered version.
>>>
>>> Whichever you choose from the two solutions, you can then implement the
>>> Finish button of the wizard to launch a HTTP request and simulate the
>>> Save button from XWiki's page (passing all the needed parameters,
>>> including the parameters in the page the user just filled in).
>>>
>>> You can additionally stylize the displayed HTML so that it better
>>> integrates with the Eclipse wizard.
>>>> Now the question is how to achieve it? Any idea where to start hacking
>>>> or where to look for more information is highly appreciated here.
>>> This is the only thing I can think of right now. Hope it helps.
>>>
>>> Thanks,
>>> Eduard
>>>> Thanks,
>>>> Karel
>>>>
>>>> On 04/26/11 05:38 PM, Karel Gardas wrote:
>>>>> Hello,
>>>>>
>>>>> I'm currently reading about XWiki and XEclipse and would like to
>>>>> ask if
>>>>> there is any consensus about XWiki pages templates which might also
be
>>>>> usable from XEclipse probably after some code hacking on its
plugins.
>>>>>
>>>>> I'm currently working on some project for my client (source code
>>>>> will be
>>>>> contributed/available later in the project stage) where there is a
>>>>> need
>>>>> to use XEclipse and enhance it to support some predefined
>>>>> forms/templates for web pages creation. So far I've found just
>>>>> XWiki FAQ
>>>>> tutorial on
>>>>>
http://platform.xwiki.org/xwiki/bin/view/DevGuide/FAQTutorial which
>>>>> tries to deals with some kind of templates. However this looks quite
>>>>> general at least so far to me and so I would like to ask the
question
>>>>> above about consensus where and how to go with templates in
>>>>> xwiki/xeclipse.
>>>>>
>>>>> My current idea is to stick with the XWiki server as a provider of
>>>>> templates to preserve ability to use templates from both browser and
>>>>> xeclipse and to enhance xeclipse new page creation wizard to provide
a
>>>>> list of available templates on the server side...
>>>>>
>>>>> Thanks for any idea where to start or where to look for more
>>>>> information
>>>>> with regarding to this project task.
>>>>>
>>>>> Karel
>>>>>