Re: [xwiki-users] Getting user name with a Java Component

2014-11-28 Thread vinc...@massol.net
 




On 28 Nov 2014 at 07:00:26, Marius Dumitru Florea 
(mariusdumitru.flo...@xwiki.com(mailto:mariusdumitru.flo...@xwiki.com)) wrote:

 On Nov 28, 2014 12:33 AM, Bryn Jeffries  
 wrote:
 
  I wrote:
What's the right way to get the current user from the execution
context within a Java component?
 
  Thomas Mortagne replied:
   For what you need the simplest in a component is usually to use
   org.xwiki.bridge.DocumentAccessBridge component (from
   xwiki-platform-bridge module) until a proper user manager api is
   introduced.
 
  OK, so I should not use ExecutionContext at all?

You’re right, our goal is to have all context information (including the user) 
be put in the Execution Context.

However, currently, we’re in a transition phase, trying to move from the old 
XWikiContext to the new ExecutionContext and thus a lot of information is 
currently still held in the XWikiContext.

See the details here:
http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents#HTheXWikicontext

Thanks
-Vincent


 It looks the the
 approach you're suggesting is:
 
  1) Inject a DocumentAccessBridge instead of an Execution, e.g.:
  @Inject
  private DocumentAccessBridge bridge;
 
  2) Get a reference to the current user
  (According to
 http://maven.xwiki.org/site/docs/xwiki-javadoc-5.0.x/org/xwiki/bridge/DocumentAccessBridge.html
 which might be out of date but I can't find a more recent API doc)
 
  DocumentReference userDoc = bridge.getCurrentUserReference();
 
  
  3) Presumably the document reference captures the full location of the
 user's profile page. The DocumentReference API doesn't appear to have a
 page name accessor, so presumably to extract the user name I need to pull
 it out of userDoc.toString().
  
 What information do you need precisely? The user alias (what the user uses
 to log in)? Or the user pretty name?
  
 The user alias is the name of the user profile document.
  
 bridge.getCurrentUserReference().getName()
  
 For the pretty name you need to get the value of the first_name and
 last_name properties from the user profile document for which you have the
 reference: the user reference.
  
 bridge.getProperty...
  
 Hope this helps,
 Marius
  
 
  Is this right? Conceptually I find this less intuitive than using a
 context object, so it's a pity if that's been deprecated.
 
  Thanks,
 
  Bryn
 
 
  ___
  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
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Handling exceptions from components

2014-11-28 Thread vinc...@massol.net
 




On 28 Nov 2014 at 01:00:37, Bryn Jeffries 
(bryn.jeffr...@sydney.edu.au(mailto:bryn.jeffr...@sydney.edu.au)) wrote:

 What's the preferred way to deal with errors occuring in Java components? Is 
 it OK to throw an exception from within the component,

yes

 and can this be caught within the Velocity or Groovy code that calls it?

errors are automatically caught in the script macros ({{velocity}}, {{groovy}}, 
etc).

Thanks
-Vincent

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] Mocca Calendar Application 2.2.1 released - with a glitch

2014-11-28 Thread Clemens Klein-Robbenhaar
To folks who have the Mocca Calendar[1] application installed in their XWiki 
instances:

I have just released a new version 2.2.1 to which you might want to update to, 
as it contains quite a few bugfixes and improvements, thanks to patches send in 
by several contributors.[2]

However the new release does not show up when you try to update via the 
Extension Updater in your wiki admin; instead the latest version found there 
will be 2.1.9.
This happened due to a glitch when reorganizing the code which changed the 
Extension-Id for that application.

Instead please go to Add extensions, search for Mocca Calendar and when the 
search result comes up, the extension manager should propose you to update to 
the correct version 2.2.1

 Also while upgrading at least in my test instances I got a few spurious 
conflicts.
If you get them too, even while you have made no modifications to the code 
part of the calendar, please choose to keep the new version to get all updates 
installed property.


Best regards and sorry for the hiccup,
Clemens


[1] http://extensions.xwiki.org/xwiki/bin/view/Extension/MoccaCalendar
[2] http://jira.xwiki.org/browse/MOCCACAL-32?filter=13491
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] Migration from 5.4.5 Standalone to 6.3 Tomcat

2014-11-28 Thread D R
Hi,

in our company we used the standalone version of XWiki for testing and are
very satisfied with it so we want to migrate to the new version and a more
robust setup.

The setup is Windows Server 2003 R2 (sadly only 32 bits) with Apache 2.4,
MySQL 5 and Tomcat 7.

XWiki 6.3 is setup now including a Wiki Template so I'd like to migrate the
data I exported as XAR from the 5.4.5 standalone instance.
My approach was exporting data from 5.4.5, creating the Wikis using the
template and importing the spaces and pages from the XAR export.

The issue I'm facing is Java heap size which constantly gets in my way. As
we're on a 32 bits system I can only assign ~1.2 GB of memory (the server
has 4GB).
This limitation makes it impossible to import the data into the new setup.
I tried general export/import via administration page and the various
options using the Admin Tools Application but on one of both ends I always
get the out of memory error.

- Using normal export/import: Export works but import throws the error
- Admin Tools - Export pages and spaces: Export works but import throws the
error
- Admin Tools - Large Export on Disk: the heap size error is thrown

Do you have any suggestions/hints on how I can migrate the spaces and pages
I have in the 5.4.5 setup to the 6.3 one?

Thanks in advance,
Dennis
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] SOLR and object search

2014-11-28 Thread Gerritjan Koekkoek
On Mon, Nov 24, 2014 at 9:46 AM, Gerritjan Koekkoek
gerritjankoekk...@gmail.com wrote:

Hi,

I'm trying to understand the new SOLR search (i did not understand the old

Lucene very well)

My use-case is the following.

We have a special FAQ application where the object has, amongst others, the

following attributes:

- Subject

- Topic-group

- Language

- Question

- Answer


he default search returns page-title/name, but this is in our case a

non-informational, generated by the system code. So instead of Page name we

would like to show: Subject


You have 3 options:

(1) Use Velocity to output the value of the subject property in the
FAQ title. See
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-blog/xwiki-platform-blog-ui/src/main/resources/Blog/BlogPostSheet.xml#L36
Gerritjan: Thanks this is helpful but see below

(2) I doesn't make sense to have a separate String property to store
the subject when you can store it in the document title.
The designer of our FAQ has opted to store multiple objects of same class
in one page. (because XWiki does not support multiple locales
(language-country) on a object level. So the title must pick the subject
name of the object of the current language-country combination. When we
just display the subject we do not need to solve this challenge.

(3) Customize the entire search page just to change the way the search
results are displayed
Yes I fear there is no way around this?


As facets we would like to show Topic-group and Language,


Default (on entering the page with search box) we would like to set the

context-language as a search filter... So when reader is reading french the

result only shows french FAQ (with a french subject title) if english only

english.

By checking and unchecking languages in the facets the user could extend or

reduce the search.


This is already the case with the default search. The context language
is checked by default in the locale facet. See
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-search/xwiki-platform-search-solr/xwiki-platform-search-solr-ui/src/main/resources/Main/SolrSearchConfig.xml#L74
.
It looks the context language is only looking at language attribute of page.
We need to compare with attribute in object.
I think it would be useful if some explanation is how the object-based
facets can be defined.

A challenge is the topic field, this is a list with translation key. So if

user is french-language the list will show french topics, but if he/she

check english as well in facets things get complicated.

We have a business-rule that the english collection of FAQ's is the

baseline, and most comprehensive. The other languages are only translations

of the same. So another languages can not have a question not translated.

So my question is:


How to define the search


http://extensions.xwiki.org/xwiki/bin/view/Extension/Solr+Search+Application#HForDevelopers
http://design.xwiki.org/xwiki/bin/view/Design/SolrSchema
http://extensions.xwiki.org/xwiki/bin/view/Extension/Solr+Search+Query+API
http://lucene.apache.org/solr/

How to modify the output so page-title is no longer showing


How to modify facets so only the two fields can be set


See
https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-faq/xwiki-platform-faq-ui/src/main/resources/FAQCode/FAQSearch.xml#L49
.This helps...

Hope this helps,
Marius

___

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
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Migration from 5.4.5 Standalone to 6.3 Tomcat

2014-11-28 Thread Thomas Mortagne
On Fri, Nov 28, 2014 at 3:02 PM, D R rir@gmail.com wrote:
 Hi,

 in our company we used the standalone version of XWiki for testing and are
 very satisfied with it so we want to migrate to the new version and a more
 robust setup.

 The setup is Windows Server 2003 R2 (sadly only 32 bits) with Apache 2.4,
 MySQL 5 and Tomcat 7.

 XWiki 6.3 is setup now including a Wiki Template so I'd like to migrate the
 data I exported as XAR from the 5.4.5 standalone instance.
 My approach was exporting data from 5.4.5, creating the Wikis using the
 template and importing the spaces and pages from the XAR export.

 The issue I'm facing is Java heap size which constantly gets in my way. As
 we're on a 32 bits system I can only assign ~1.2 GB of memory (the server
 has 4GB).
 This limitation makes it impossible to import the data into the new setup.
 I tried general export/import via administration page and the various
 options using the Admin Tools Application but on one of both ends I always
 get the out of memory error.

 - Using normal export/import: Export works but import throws the error
 - Admin Tools - Export pages and spaces: Export works but import throws the
 error
 - Admin Tools - Large Export on Disk: the heap size error is thrown

Quite frankly the one in Admin Tools should change it's name since
it's far from supporting anything close to large...


 Do you have any suggestions/hints on how I can migrate the spaces and pages
 I have in the 5.4.5 setup to the 6.3 one?

The extensions that have the less memory footprint (probably by far) I
can think of are
http://extensions.xwiki.org/xwiki/bin/view/Extension/Large+Wiki+Export
and http://extensions.xwiki.org/xwiki/bin/view/Extension/Large+XAR+Import
so you might want to try them. Note that at least for export it's
fixed in 6.2 but for import even if it's been improved a lot the way
the UI work you still have to be able to attach your attachment.


 Thanks in advance,
 Dennis
 ___
 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


Re: [xwiki-users] Getting user name with a Java Component

2014-11-28 Thread Bryn Jeffries
From: vinc...@massol.net [vinc...@massol.net]
 OK, so I should not use ExecutionContext at all?

 You’re right, our goal is to have all context information (including the 
 user) be put in the Execution Context.

 However, currently, we’re in a transition phase, trying to move from the old 
 XWikiContext to the new 
 ExecutionContext and thus a lot of information is currently still held in the 
 XWikiContext.
 
 See the details here:
 http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents#HTheXWikicontext

Thanks. I've actually read through that page several times, but it's only now 
making sense to me after having given things a try and getting the help on this 
mailling list. FWIW the problem for a new user is that there is a mix of 
documentation applying to several versions of XWiki (especially when searching 
via Google). This is partly the curse of wikis, since they don't go through 
structured revision control. It's so good that the mailling list is so 
responsive to put us straight.

Thanks,

Bryn
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Getting user name with a Java Component

2014-11-28 Thread Bryn Jeffries

From Marius:
 3) Presumably the document reference captures the full location of the
 user's profile page. The DocumentReference API doesn't appear to have a
 page name accessor, so presumably to extract the user name I need to pull
 it out of userDoc.toString().
 
 What information do you need precisely? The user alias (what the user uses
 to log in)? Or the user pretty name?
 
 The user alias is the name of the user profile document.
 
 bridge.getCurrentUserReference().getName()

I think this is what I need to do. I have a separate database which uses proxy 
authentication so that queries give different results based on the user (as a 
form of ACL). So I need the uid for the current user, which is mapped to the 
wiki 
alias.

Many thanks,

Bryn
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Handling exceptions from components

2014-11-28 Thread Bryn Jeffries
Said Vincent:
  and can this be caught within the Velocity or Groovy code that calls it?

 errors are automatically caught in the script macros ({{velocity}}, 
 {{groovy}}, etc).

OK, looks like Groovy has explicit try/catch 
(http://groovy.codehaus.org/JN3035-Exceptions). I couldn't see anything about 
Velocity catching exceptions (only about Velocity throwing exceptions - 
http://velocity.apache.org/engine/devel/developer-guide.html#exceptions).

So if I have a component that I call from velocity with $mycomponent.foo() and 
the method throws an exception (IOException, for instance), can I control what 
the Velocity script does about this?

___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Handling exceptions from components

2014-11-28 Thread Thomas Mortagne
On Fri, Nov 28, 2014 at 9:17 PM, Bryn Jeffries
bryn.jeffr...@sydney.edu.au wrote:
 Said Vincent:
  and can this be caught within the Velocity or Groovy code that calls it?

 errors are automatically caught in the script macros ({{velocity}}, 
 {{groovy}}, etc).

 OK, looks like Groovy has explicit try/catch 
 (http://groovy.codehaus.org/JN3035-Exceptions). I couldn't see anything about 
 Velocity catching exceptions (only about Velocity throwing exceptions - 
 http://velocity.apache.org/engine/devel/developer-guide.html#exceptions).

Yes there is nothing in standard Velocity but XWiki add some tools to
Velocity and among other things some try/catching support, see
http://extensions.xwiki.org/xwiki/bin/view/Extension/Velocity+Module#HVelocityDirectives.

What Vincent meant by automatically caught is that you get to see the
error in the error where you have put the {{velocity}} macro, it does
not break the whole page.


 So if I have a component that I call from velocity with $mycomponent.foo() 
 and the method throws an exception (IOException, for instance), can I control 
 what the Velocity script does about this?

 ___
 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