Re: [xwiki-users] Blog application Document creator
Hi, Most of your advise was accurate and has helped, Thank you, XWikiDocument articleDoc = vArticle.getDocument(); articleDoc.setAuthor(user); articleDoc.setCreator(user); aticleDoc.setContentDirty(false); aticleDoc.setMetaDataDirty(false); xwiki.getXWiki().saveDocument(articleDoc, xcontext.getContext); In Groovy; should I add the semicolon at the end of each line? Should I add this piece of code after the vArticle.save() statement? When I did I get the following error: Script22.groovy: 73: unable to resolve class XWikiDocument @ line 73, column 15. XWikiDocument articleDoc = vArticle.getDocument(); ^ the category and hidden tip did work Op 6 apr 2010, om 21:45 heeft Sergiu Dumitriu het volgende geschreven: On 04/03/2010 01:34 PM, Gerritjan Koekkoek wrote: Hi, I try to convert a website in xwiki.blog application For each page I create a groovy script that creates a blog post The script is successful with three exceptions; 1) Would like to maintain the original author So I create a xwiki.user (this works) Then I would like to set the document property with {{groovy}} ... (the first part of the script) vArticle.set(creator,'XWiki.FamilievandenMeulengraaf') vArticle.save() {{/groovy}} But looking at the post it still has creator as the user running the code Using the public API it's impossible to set a different creator/author than the current user. You need to get into the internal objects, and do something like: XWikiDocument articleDoc = vArticle.getDocument(); articleDoc.setAuthor(user); articleDoc.setCreator(user); aticleDoc.setContentDirty(false); aticleDoc.setMetaDataDirty(false); xwiki.getXWiki().saveDocument(articleDoc, xcontext.getContext); 2) Categories I've created a few categories in the blog application So I would like to set the category attribute, where the class-attribute definition of the post = Database Tree {{groovy}} ... vObjArticle.set(Category,'???') ... {{/groovy}} Does any body know what to put in '???', since a category can be multiple entries ??? If you want to put just one category, you can use the document name where the category is defined (in the blog each category is a document, look at the existing categories to see how they look like): vObjArticle.set('Category', 'Blog.MyNiceCategory') If you want to put multiple entries, you can use an array: vObjArticle.set('Category', ['Blog.Cat1', 'Blog.Cat2']) 3) When I run the script a postpage is created, I see a link in the new documents frame. When I go to it it displays OK, but when I go to the blog application it does not show in the blog indexes (recently, categories (explained under 2)) or historical) Only when I go to the page, click edit object and directly click save it will show up in he blog What could be the reason for this, Try also setting a value for the 'isHidden' property. The code looks like ( = title of the post) {{groovy}} vArticle = xwiki.getDocument(CdlsArticle.XX) vArticle.setContent('{{include document=CdlsArticle.ArticlePostSheet/}}') vArticle.setParent(CdlsArticle.WebHome) vArticle.set(language,nl) vArticle.set(translation,1) vObjArticle = vArticle.getObject(CdlsArticle.ArticlePostClass,true) ... def vTitle = X vObjArticle.set(title,vTitle) ... def vExtractHeader = '' def vExtractText = '' def vExtractPicture = 'image:photo.cdl...@.jpg vObjArticle.set(extract,vExtractHeader + vExtractText + vExtractPicture) .. etcetera .. vObjArticle.set(published,'1') vArticle.save() {{/groovy}} -- Sergiu Dumitriu http://purl.org/net/sergiu/ ___ 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] Blog application Document creator
On 04/10/2010 10:41 PM, Gerritjan Koekkoek wrote: Hi, Most of your advise was accurate and has helped, Thank you, XWikiDocument articleDoc = vArticle.getDocument(); articleDoc.setAuthor(user); articleDoc.setCreator(user); aticleDoc.setContentDirty(false); aticleDoc.setMetaDataDirty(false); xwiki.getXWiki().saveDocument(articleDoc, xcontext.getContext); In Groovy; should I add the semicolon at the end of each line? I think it's optional. I prefer adding them. Should I add this piece of code after the vArticle.save() statement? You should not keep the vArticle.save() line, since the block that I gave you is exactly for saving the document. When I did I get the following error: Script22.groovy: 73: unable to resolve class XWikiDocument @ line 73, column 15. XWikiDocument articleDoc = vArticle.getDocument(); You should import com.xpn.xwiki.doc.XWikiDocument; ^ the category and hidden tip did work Op 6 apr 2010, om 21:45 heeft Sergiu Dumitriu het volgende geschreven: On 04/03/2010 01:34 PM, Gerritjan Koekkoek wrote: Hi, I try to convert a website in xwiki.blog application For each page I create a groovy script that creates a blog post The script is successful with three exceptions; 1) Would like to maintain the original author So I create a xwiki.user (this works) Then I would like to set the document property with {{groovy}} ... (the first part of the script) vArticle.set(creator,'XWiki.FamilievandenMeulengraaf') vArticle.save() {{/groovy}} But looking at the post it still has creator as the user running the code Using the public API it's impossible to set a different creator/author than the current user. You need to get into the internal objects, and do something like: XWikiDocument articleDoc = vArticle.getDocument(); articleDoc.setAuthor(user); articleDoc.setCreator(user); aticleDoc.setContentDirty(false); aticleDoc.setMetaDataDirty(false); xwiki.getXWiki().saveDocument(articleDoc, xcontext.getContext); 2) Categories I've created a few categories in the blog application So I would like to set the category attribute, where the class-attribute definition of the post = Database Tree {{groovy}} ... vObjArticle.set(Category,'???') ... {{/groovy}} Does any body know what to put in '???', since a category can be multiple entries ??? If you want to put just one category, you can use the document name where the category is defined (in the blog each category is a document, look at the existing categories to see how they look like): vObjArticle.set('Category', 'Blog.MyNiceCategory') If you want to put multiple entries, you can use an array: vObjArticle.set('Category', ['Blog.Cat1', 'Blog.Cat2']) 3) When I run the script a postpage is created, I see a link in the new documents frame. When I go to it it displays OK, but when I go to the blog application it does not show in the blog indexes (recently, categories (explained under 2)) or historical) Only when I go to the page, click edit object and directly click save it will show up in he blog What could be the reason for this, Try also setting a value for the 'isHidden' property. The code looks like ( = title of the post) {{groovy}} vArticle = xwiki.getDocument(CdlsArticle.XX) vArticle.setContent('{{include document=CdlsArticle.ArticlePostSheet/}}') vArticle.setParent(CdlsArticle.WebHome) vArticle.set(language,nl) vArticle.set(translation,1) vObjArticle = vArticle.getObject(CdlsArticle.ArticlePostClass,true) ... def vTitle = X vObjArticle.set(title,vTitle) ... def vExtractHeader = '' def vExtractText = '' def vExtractPicture = 'image:photo.cdl...@.jpg vObjArticle.set(extract,vExtractHeader + vExtractText + vExtractPicture) .. etcetera .. vObjArticle.set(published,'1') vArticle.save() {{/groovy}} -- Sergiu Dumitriu http://purl.org/net/sergiu/ ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] Flash video files over 20MB errors
On 04/10/2010 01:28 AM, Meng Wu wrote: Dear XWiki developers and users, Some of our users are having trouble uploading flash video files larger than 20MB on pages in the wiki. We've noticed either of two things happening: 1) When clicking the file attachment, it leads to a page that says template does not exist Or 2) When clicking the file attachment, you are prompted to download it. However, the download file is 0KB. These symptoms are only happening for flv files larger than 20MB. For more clarification, here is a timeline of what happens: · User uploads these files · Big files return “template does not exist” error and most flash video files larger than 20MB gets cut down to 0KB · User re-uploads these files · These files work, are able to be downloaded with all the content, are able to be played by the jw player, and the problem, at least for a while, seems to be fixed · A little while later, these files start to fail, seemingly in the order they were uploaded in (somefiles bigger than 20MB get the error message and some files, when downloaded, have 0KB, even though the attachment display says otherwise) We checked that the maximum attachment size for us was set to 1GB, so we're not really sure what the problem is. Any insight would be greatly appreciated. You should try to: - increase the memory available to XWiki (attachments take up LOTS of memory, this is a known problem which will be fixed at some time) - increase the max_allowed_packet setting for mysql (assuming you're using mysql) -- Sergiu Dumitriu http://purl.org/net/sergiu/ ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users