[xwiki-users] Server SQL error

2016-02-21 Thread gervwyk
After importing a large number of spaces in my wiki, my server through the
following error when browsing which causes browsing delays.

22016-02-19 17:11:04,982
[http://192.168.0.35:8080/xwiki/bin/view/SDomain/HW_DEV/0_LIB/Components-CommercialPC/Library+Description/]
WARN  o.h.u.JDBCExceptionReporter- SQL Error: 1406, SQLState: 22001
2016-02-19 17:11:04,983
[http://192.168.0.35:8080/xwiki/bin/view/SDomain/HW_DEV/0_LIB/Components-CommercialPC/Library+Description/]
ERROR o.h.u.JDBCExceptionReporter- Data truncation: Data too long for
column 'XWS_VALUE' at row 1
com.xpn.xwiki.XWikiException: Error number 3201 in 3: Exception while saving
document xwiki:XWiki.Admin
at
com.xpn.xwiki.store.XWikiHibernateStore.saveXWikiDoc(XWikiHibernateStore.java:658)
at
com.xpn.xwiki.store.XWikiCacheStore.saveXWikiDoc(XWikiCacheStore.java:167)
at
com.xpn.xwiki.store.XWikiCacheStore.saveXWikiDoc(XWikiCacheStore.java:160)
at com.xpn.xwiki.XWiki.saveDocument(XWiki.java:1564)
at com.xpn.xwiki.XWiki.saveDocument(XWiki.java:1508)
at com.xpn.xwiki.XWiki.saveDocument(XWiki.java:1503)
at
org.xwiki.commons._CMP_WikiV3.script.PageBuilder.recentVisitedMiciUpdate(PageBuilder.java:2419)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at
org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:395)
at
org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:384)
at
org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:173)
at
org.apache.velocity.runtime.parser.node.ASTReference.execute(ASTReference.java:280)
at
org.apache.velocity.runtime.parser.node.ASTReference.render(ASTReference.java:369)
at
org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:342)
at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluateInternal(DefaultVelocityEngine.java:256)
at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:222)
at
org.xwiki.velocity.internal.DefaultVelocityEngine.evaluate(DefaultVelocityEngine.java:198)
at
org.xwiki.rendering.internal.macro.velocity.VelocityMacro.evaluateString(VelocityMacro.java:124)
at
org.xwiki.rendering.internal.macro.velocity.VelocityMacro.evaluateString(VelocityMacro.java:50)
at
org.xwiki.rendering.macro.script.AbstractScriptMacro.evaluateBlock(AbstractScriptMacro.java:286)
at
org.xwiki.rendering.macro.script.AbstractScriptMacro.execute(AbstractScriptMacro.java:182)
at
org.xwiki.rendering.macro.script.AbstractScriptMacro.execute(AbstractScriptMacro.java:58)
at
org.xwiki.rendering.internal.transformation.macro.MacroTransformation.transform(MacroTransformation.java:269)
at
org.xwiki.rendering.internal.transformation.DefaultRenderingContext.transformInContext(DefaultRenderingContext.java:183)
at
org.xwiki.rendering.internal.transformation.DefaultTransformationManager.performTransformations(DefaultTransformationManager.java:95)
at
org.xwiki.display.internal.DocumentContentDisplayer.display(DocumentContentDisplayer.java:253)
at
org.xwiki.display.internal.DocumentContentDisplayer.display(DocumentContentDisplayer.java:126)
at
org.xwiki.display.internal.DocumentContentDisplayer.display(DocumentContentDisplayer.java:56)
at
org.xwiki.display.internal.DefaultDocumentDisplayer.display(DefaultDocumentDisplayer.java:96)
at
org.xwiki.display.internal.DefaultDocumentDisplayer.display(DefaultDocumentDisplayer.java:39)
at
org.xwiki.sheet.internal.SheetDocumentDisplayer.display(SheetDocumentDisplayer.java:113)
at
org.xwiki.sheet.internal.SheetDocumentDisplayer.display(SheetDocumentDisplayer.java:50)
at
org.xwiki.display.internal.ConfiguredDocumentDisplayer.display(ConfiguredDocumentDisplayer.java:68)
at
org.xwiki.display.internal.ConfiguredDocumentDisplayer.display(ConfiguredDocumentDisplayer.java:42)
at
com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:1164)
at
com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:1127)
at
com.xpn.xwiki.doc.XWikiDocument.getRenderedContent(XWikiDocument.java:1179)
at com.xpn.xwiki.api.Document.getRenderedContent(Document.java:692)
at sun.reflect.GeneratedMethodAccessor362.invoke(Unknown Source)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at

[xwiki-users] calling a java component from JavaScriptExtension

2016-01-28 Thread gervwyk
Is it possible to call a java component from a JavaScriptExtension? like
this:

In javascript:

require(['jquery'], function ($) {
   $('#ToJava').click(function(){
  var returnValue = $services.mycomponent.mymethod( someNumber );
  // use return value
   });
});

In java: 

 public int mymethod(int num){
   return num +1;
}

I know that I can do the ajax round trip and invoke the method through
velocity:
http://extensions.xwiki.org/xwiki/bin/view/Extension/AJAX+example

-- just wondering if there is a way to shortcut this process by avoiding
velocity and only working in js?
or is my logic flawed?




--
View this message in context: 
http://xwiki.475771.n2.nabble.com/calling-a-java-component-from-JavaScriptExtension-tp7597705.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] calling a java component from JavaScriptExtension

2016-01-28 Thread gervwyk
Thanks Jean.

Yes, I understand. I think what would be useful, is a JS function to invoke
a java method server-side, since I find myself doing this ajax round trip
all the time. So what I'm proposing a JS function call, say:

JavaServer.call("mycomponent.mymethod", {JSON data input}, "(return type)'
);

Which runs the ajax in JS required calling a generic xwiki page url with a
velocity script maybe which invokes the java component passed with the JS
parameter and return the "html/text" or "application/json" data as
specified.

Currently I have like 50 static terminal pages which is only used to pass
data from the JS with ajax to a velocity script to a java component and
back. Basically, the only difference in those velocity scripts is the
method name. So kinda feel that it might be possible to "short-cut' this
velocity page, with a standard velocity macro which invokes the passed
method. I'm pretty sure this will add client side "reactive"-like
functionality to xwiki as you can invoke server-side functions from JS
events. In principle like in Meteor.js were you do a
Method.call("methodname",function(){}), although the underlying
architecture differs greatly.

Keep up the good work
Gerrie van wyk


On Thu, Jan 28, 2016 at 11:56 AM, Jean SIMARD [via XWiki] <
ml-node+s475771n7597706...@n2.nabble.com> wrote:

> Dear gervwyk,
>
> From what I understand of components and Javascript, it will not be
> possible.  Components are Java code and therefore are executed on
> server-side.  Velocity, is also script that is executed server-side.
> And Javascript is client-side, so it doesn't have the logic for
> components.  As far as I know, we don't have any possibility to execute
> server-side Javascript in XWiki at the moment.  So a component doesn't
> have much sense for Javascript.
>
> However, instead of following [1], you may also create a REST component
> on server-side (which will also allow AJAX).  Look [2] for documentation
> about writing new REST components.  You'll loose a bit of flexibility
> (because you'll have to build JAR and restart the wiki each time you
> change source code) but you won't have to deal with Velocity.
>
> Note there is also a new extension that may fill your need but I'm not
> sure it's exactly what you need [3].
>
> Hope it helps.
>
> [1] http://extensions.xwiki.org/xwiki/bin/view/Extension/AJAX+example
> [2]
>
> http://platform.xwiki.org/xwiki/bin/view/Features/XWikiRESTfulAPI#HCustomresources
> [2]
>
> http://extensions.xwiki.org/xwiki/bin/view/Extension/Structured+data+access+JS+API
>
> On 28/01/2016 10:30, gervwyk wrote:
>
> > Is it possible to call a java component from a JavaScriptExtension? like
> > this:
> >
> > In javascript:
> >
> > require(['jquery'], function ($) {
> >$('#ToJava').click(function(){
> >  var returnValue = $services.mycomponent.mymethod( someNumber );
> >   // use return value
> >});
> > });
> >
> > In java:
> >
> >  public int mymethod(int num){
> >return num +1;
> > }
> >
> > I know that I can do the ajax round trip and invoke the method through
> > velocity:
> > http://extensions.xwiki.org/xwiki/bin/view/Extension/AJAX+example
> >
> > -- just wondering if there is a way to shortcut this process by avoiding
> > velocity and only working in js?
> > or is my logic flawed?
> >
> >
> >
> >
> > --
> > View this message in context:
> http://xwiki.475771.n2.nabble.com/calling-a-java-component-from-JavaScriptExtension-tp7597705.html
> > Sent from the XWiki- Users mailing list archive at Nabble.com.
> > ___
> > users mailing list
> > [hidden email] <http:///user/SendEmail.jtp?type=node=7597706=0>
> > http://lists.xwiki.org/mailman/listinfo/users
> >
>
> --
> Jean Simard
> [hidden email] <http:///user/SendEmail.jtp?type=node=7597706=1>
> Research engineer at XWiki SAS
> http://www.xwiki.com
> Committer on the XWiki.org project
> http://www.xwiki.org
> ___
> users mailing list
> [hidden email] <http:///user/SendEmail.jtp?type=node=7597706=2>
> http://lists.xwiki.org/mailman/listinfo/users
>
>
> --
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://xwiki.475771.n2.nabble.com/calling-a-java-component-from-JavaScriptExtension-tp7597705p7597706.html
> To unsubscribe from calling a java component from JavaScriptExtension, click
> here
> <http://xwiki.475771.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code=7597705=Z2V

[xwiki-users] Returning JSON data from a java component

2016-01-27 Thread gervwyk
What is the best way to get JSON data from a java component. In my java
component I'm compiling JSONObjects and JSONArrays, I would like to return
this data to my velocity script in JSON format, is this possible? 

something like:

{{velocity wiki="false"}}
#if("$!request.outputSyntax" != '')
  $response.setContentType('application/json')
#end
#set($map = [])
#set ($rightIN =  ${request.rightIN}) 
#set ($spacenameIN =  ${request.spacenameIN}) 
#set($disgard =
$map.add($services.g_pagebuilder.userAccessFindPages($spacenameIN,$rightIN
)))
$jsontool.serialize($map)
{{/velocity}}

and the Java:

  public JSONObject javacomp(String spacenameIN, String rightIN ){
  JSONObject obj = new JSONObject();
  try {
obj.put("spacenameIN ", spacenameIN );
obj.put("rightIN", rightIN );
} catch (JSONException e) {
e.printStackTrace();
}
  return obj;
  }

At the end I would like to access this json object as a data return from an
ajax call. Is this possible?

Thanks
Gerrie






--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Returning-JSON-data-from-a-java-component-tp7597700.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] XWikiRights for groups on page and children

2016-01-25 Thread gervwyk
Good day.

I'm trying to write a java component to set rights to a space and the space
children. Normally, the user would set this on the space when clicking on
administer page>users and groups>Rights: page and children, where the user
can set access rights for a group to effect the space and its children. 

I'm trying to achieve this with a java component and currently I'm attaching
an XWikiRights object with the specified group and rights to the
.WebHome page. However, this only effects the one page and not the
children, also view rights only leaves comment and page creating rights
which is not desired. Am I understanding the rights objects wrong? How do I
achieve this in Java, currently I have:

XWikiDocument doc = xwiki.getDocument(docref, xcontext); //
referance to the .WebHome
DocumentReference classdoc =
createDocumentReference(xwikiName,"XWiki","XWikiRights",false);
BaseObject DSErightsobj = doc.newXObject(classdoc, xcontext);
DSErightsobj.set("groups", DSEname, xcontext);
DSErightsobj.set("users", "", xcontext);
DSErightsobj.set("levels", "view", xcontext); // space right
DSErightsobj.set("allow", 1, xcontext);
xwiki.saveDocument(doc, xcontext); 



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/XWikiRights-for-groups-on-page-and-children-tp7597689.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] Adding users to a user list form a java component

2015-12-11 Thread gervwyk
Good day.

I'm trying to add users to a users list within a object. After I have
instanciated the object on the document which I want to ammend, how do I
"set" and "get" the user list property in a java component? I have:

BaseObject domainObject = doc.getXObject(referenceClass);
domainObj.set("lisfOfUsers", ??user?? , xcontext);

domainObj is of a class where the "lisfOfUsers" is a List of Users property.
Currently I have the username as a string. I have tried creating a User or
XWikiUser object and setting the property with the object but with no
success. 



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Adding-users-to-a-user-list-form-a-java-component-tp7597177.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] Xwiki html parsing of user list

2015-12-10 Thread gervwyk
I'm creating a form but I prefer using HTML and bootstrap rather than only
velocity syntax. I have the following problem:

 

I want to insert user selection list into the form. By doing the following:

{{velocity}}
{{html velocity="true" }}

 #set( $tempobj = $doc.newObject('Classes.USR'))
 $tempobj.display('userslist','edit') 


{{html velocity="true" }}
{{/velocity}}

however I get the {{html}} tag around the search box which I don't want. How
can I remove this?
closing and opening the html before and after the call gives rendering
errors. Is there a way to all the  $tempobj.display('userslist','edit')
function without rendering the {{html}} tags?
Which function in java lib will give me a simular output? maybe I can do
this through a java component? 
What output does thedisplayEdit() method in BaseObject class give? 

I tried something like this, but did not work, I might be totally wrong..

  XWikiContext xcontext = this.xwikiContextProvider.get();
  DocumentReference referenceClass = 
resolver.resolve("Classes.USR");
  XWikiDocument doc = xcontext.getDoc();
  BaseObject domainObject = doc.getXObject(referenceClass);
  String disp = domainObject.displayEdit("userslist", xcontext);
  return disp



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Xwiki-html-parsing-of-user-list-tp7597164.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] New Javadoc API Reference

2015-12-09 Thread gervwyk
I there a new JavaDoc API reference availible somewhere?
I'm currently using version 5:
http://maven.xwiki.org/site/docs/xwiki-javadoc-5.0.x/

However I'm finding it really outdated on methods such as
xwiki.checkAccess() and xwiki.getSpaces()

I'm not finding my way to it on the API reference page:
http://platform.xwiki.org/xwiki/bin/view/DevGuide/API

Any advice where to find javadoc for xwiki 7.3?



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/New-Javadoc-API-Reference-tp7597148.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] spaces for which the current user has access in a java component

2015-12-09 Thread gervwyk
Ok. So what I'm trying to achieve is the following:
We have spaces which has user (view/edit) groups and an admin group for that
space. 
I'm currently writing a rights admin tool which shows the admin group users
the spaces which they are the admin of, and they can then select a space to
which they can assign a user group.

In normal workflow terms: We have managers of departments, and project
teams, and we want the managers to give rights to a team within their
department to assign the to a project through a admin tool/ webform, instead
of going to each page and attaching the objects and making mistakes. 

So:
1. I want the managers to see the spaces for which they are admin
2. I what them to assign a group to that space.

I can successfully assign the group to the space, however, having trouble to
let the managers see only the spaces for which they are the admin.



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/spaces-for-which-the-current-user-has-access-in-a-java-component-tp7597147p7597152.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] spaces for which the current user has access in a java component

2015-12-08 Thread gervwyk
How do I get all the spaces for which the current user has access in a java
component?

I have the following:

List lstSpaces = new ArrayList();
XWikiContext xcontext = this.xwikiContextProvider.get();
XWiki xwiki = xcontext.getWiki();
lstSpaces = xwiki.getSpaces(xcontext);

Although this successfully returns all the spaces, it also returns the
spaces for which the current user has no "view" or other access rights. Also
it seems that the Java .getSpaces is deprecated and I can't seem to find the
new method for this. http://maven.xwiki.org/site/docs/xwiki-javadoc-5.0.x/
seems outdated as xwiki.getSpaces() is still active in this javadoc, with no
alternative. Is there a new javadoc availible?



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/spaces-for-which-the-current-user-has-access-in-a-java-component-tp7597147.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] Get all children from current document in Java component

2015-12-01 Thread gervwyk
Hello
I'm trying to get all the documents that list the current document as the
perant using:
List  childDocs = doc.getChildrenReferences(xcontext);

where doc is the parent XWikiDocument.

However the function only return an empty list, althoug there is documents
in the space. 

If I print doc.getFullName() its AAA.WebHome.. And all the chldren spaces is
listed under AAA.. how should I reference doc to get say AAA.BBB.WebHome in
the list? or where am I going wrong?



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Get-all-children-from-current-document-in-Java-component-tp7597043.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


Re: [xwiki-users] Create spaces and page in toplevel space via Java component

2015-11-25 Thread gervwyk
Thanks this was exactly what I was looking for. The new structure did cause
some confusion. The "WebHome" concept was confusing until I read the links. 

Thank for clarifying that. 
-Gerrie



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Create-spaces-and-page-in-toplevel-space-via-Java-component-tp7596969p7596980.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users


[xwiki-users] Create spaces and page in toplevel space via Java component

2015-11-25 Thread gervwyk
Hello.
How would I create a new space under Main or the toplevel entity from a java
component. So far I'm doing this, but not sure.. 

DocumentReference docref = new
DocumentReference(serverName,pageSpace,pageName);
if(xwiki.exists( docref, xcontext)){
//skip create do other stuff
}else{ 
   XWikiDocument doc = new XWikiDocument(docref);
   doc.setTitle(pageName);
   DocumentReference docrefparent = new
DocumentReference(serverName,pageSpace,"WebHome");
   doc.setParentReference(docrefparent);
   xwiki.saveDocument(doc, xcontext);
}
Where:
serverName = $request.serverName
pageSpace = "Main"
pageName = "NewPage"

is there anything else I need to set on the document or am I referencing
wrong? Not sure why it is not creating the page..



--
View this message in context: 
http://xwiki.475771.n2.nabble.com/Create-spaces-and-page-in-toplevel-space-via-Java-component-tp7596969.html
Sent from the XWiki- Users mailing list archive at Nabble.com.
___
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users