I have a problem with importing attachments. After few minutes of creating attachment files in .../data/storage I get 'failed to execute macro' error. In catalina.out I get exceptions:
I had to modify your script. Here is the diff: 277c277,279 <for(XWikiAttachmentattach : doc.getAttachmentList()) { --- >//for(XWikiAttachmentattach : doc.getAttachmentList()) { //http://jira.xwiki.org/browse/XWIKI-7936 >defhql="select att from XWikiAttachment att WHERE att.docId=?"; >for(XWikiAttachmentattach : xwiki.search(hql, [doc.getId()])) { attach.setDoc(doc);
It's important, otherwise some attachments will not be stored on FS and some bugs happen.
Integrated in 2.1, thanks for the patch and sorry it took so long.
GanesanM, 2013/07/30 15:03
While I try to Switch from database attachment to File system I got error 'failed to execute macro'. Then I opened the code and changed " private void main()" to " public void main()" It exported almost all the attachments to my hard disk. Can you please try to change this bug?
Hi Ganesan, If you're getting a 'failed to execute macro' error, you can click on it and it will expand to show the actual error and stack trace. Also this is not a good place to ask for help, it's better to ask on the users mailing list MailingLists because it will be seen by more people.
Hello all! I faced the same problem as Ganesan! When I run the script I got a error:
"Script4.groovy: 62: Mixing private and public/protected methods of the same name causes multimethods to be disabled and is forbidden to avoid surprising behaviour. Renaming the private methods will solve the problem. @ line 62, column 1. private void main()" Then I changed the private fucntion "main" to public!
Hello. My experience is when running this on 6.0.1.
When run in dry run mode a large number of attachments are listed. When run with dry run disabled, fewer attachments appear to be processed (are listed). Icon attachments (eg avatar PNGs) were lost as well as some documents.
I don't see a way to repeat the db->file system move - which I can understand because I wouldn't want attachments duplicated - but it would be nice to be able to see the full list of attachments again in order to know what was omitted. This experience was on an evaluation wiki (prior to planned use) so this is throwaway content, but it doesn't seem like intended behavior.
Addendum to my comment above: while reloading the page with the script *did not* allow me to repeat the dry run, switching to edit mode and then exiting did reset the page so that I could repeat the dry run, confirming that many more files were listed in that mode. Reviewing the jira link in Vincent's post of 2013/11/12 I believe that the issue described there is still present (attachments that come with the default wiki pages aren't processed) but other attachments were also omitted. User beware.
Snippets are a "snippet" of code that runs within a page on your wiki. To run the Snippet, copy and paste the most recent version of the snippet into a newly-created page on your wiki. I pasted it into the editor with "Source" mode enabled, it may work in WYSIWYG mode as well. After saving the page, you will see instructions on how to run the script.
I have a problem with importing attachments. After few minutes of creating attachment files in .../data/storage I get 'failed to execute macro' error.
In catalina.out I get exceptions:
Wrapped Exception: Error number 2002 in 2: Error parsing xml
Wrapped Exception: Error on line 1 of document : Content is not allowed in prolog. Nested exception: Content is not allowed in prolog.
at com.xpn.xwiki.doc.XWikiAttachmentArchive.getRevision(XWikiAttachmentArchive.java:285)
at com.xpn.xwiki.store.AttachmentArchiveSaveRunnable.<init>(AttachmentArchiveSaveRunnable.java:81)
at com.xpn.xwiki.store.FilesystemAttachmentVersioningStore.getArchiveSaveRunnable(FilesystemAttachmentVersioningStore.java:202)
at com.xpn.xwiki.store.FilesystemAttachmentStore$AttachmentSaveTransactionRunnable.<init>(FilesystemAttachmentStore.java:363)
at com.xpn.xwiki.store.FilesystemAttachmentStore.getAttachmentContentSaveRunnable(FilesystemAttachmentStore.java:145)
at sun.reflect.GeneratedMethodAccessor294.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoCachedMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:229)
at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:52)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:132)
at Script7.doIt(Script7.groovy:140)
at Script7.this$4$doIt(Script7.groovy)
It seems there is such an exception for every one of my attachments.
Can you help me?
TIA
R.
Hi Ryszard, please use JIRA to report issues and the Mailing Lists/Forum to ask questions.
Fred Blabla reported an issue with this extension here: http://jira.xwiki.org/browse/XWIKI-7638
I've closed it since it's not the right place.
Upgraded to work with 3.4 and newer, thanks for bringing the issue to my attention.
When switching to Filesystem attachment storage and running under a security manager I had to adjust my policy file.
The following were added to the default Web Application Permissions section of the policy file.
I didn't test if these simply needed adding to the xwiki codebase section only.
(grant codeBase "file:${catalina.home}/webapps/xwiki/-")
permission java.util.PropertyPermission "office.*", "read";
permission java.util.PropertyPermission "file.encoding", "read";
permission java.util.PropertyPermission "java.io.tmpdir", "read";
permission java.util.PropertyPermission "org.apache.commons.logging.LogFactory.HashtableImpl", "read";
permission java.util.PropertyPermission "org.quartz.properties", "read";
permission java.util.PropertyPermission "ANTLR_DO_NOT_EXIT", "read";
permission java.util.PropertyPermission "ANTLR_USE_DIRECT_CLASS_LOADING", "read";
permission java.util.PropertyPermission "org.apache.xerces.xni.parser.XMLParserConfiguration", "read";
permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
permission java.lang.RuntimePermission "getClassLoader";
permission java.lang.RuntimePermission "createClassLoader";
permission java.lang.RuntimePermission "setContextClassLoader";
permission java.lang.RuntimePermission "accessClassInPackage.org.apache.catalina";
permission java.lang.RuntimePermission "accessClassInPackage.sun.reflect";
permission java.lang.RuntimePermission "accessDeclaredMembers";
permission java.lang.RuntimePermission "getenv.ProgramFiles";
permission java.lang.RuntimePermission "getenv.APPDATA";
//Allow file storage directory reading - for directory and everything underneath
permission java.io.FilePermission "${catalina.home}${file.separator}xwikidata${file.separator}", "read,write,delete";
permission java.io.FilePermission "${catalina.home}${file.separator}xwikidata${file.separator}-", "read,write,delete";
//Allow file storage directory reading - temporary directory and everything underneath
permission java.io.FilePermission "${catalina.home}${file.separator}temp${file.separator}", "read,write,delete";
permission java.io.FilePermission "${catalina.home}${file.separator}temp${file.separator}-", "read,write,delete";
Added these to the security manager template. Thanks for the tip.
Hi, because of this bug:
http://jira.xwiki.org/browse/XWIKI-7936
I had to modify your script. Here is the diff:
277c277,279
< for (XWikiAttachment attach : doc.getAttachmentList()) {
---
> //for (XWikiAttachment attach : doc.getAttachmentList()) { // http://jira.xwiki.org/browse/XWIKI-7936
> def hql = "select att from XWikiAttachment att WHERE att.docId=?";
> for (XWikiAttachment attach : xwiki.search(hql, [doc.getId()])) { attach.setDoc(doc);
It's important, otherwise some attachments will not be stored on FS and some bugs happen.
Integrated in 2.1, thanks for the patch and sorry it took so long.
While I try to Switch from database attachment to File system I got error 'failed to execute macro'.
Then I opened the code and changed " private void main()" to " public void main()" It exported almost all the attachments to my hard disk. Can you please try to change this bug?
Thanks.
Hi Ganesan,
If you're getting a 'failed to execute macro' error, you can click on it and it will expand to show the actual error and stack trace. Also this is not a good place to ask for help, it's better to ask on the users mailing list MailingLists because it will be seen by more people.
Hello all!
I faced the same problem as Ganesan! When I run the script I got a error:
"Script4.groovy: 62: Mixing private and public/protected methods of the same name causes multimethods to be disabled and is forbidden to avoid surprising behaviour. Renaming the private methods will solve the problem. @ line 62, column 1. private void main()"
Then I changed the private fucntion "main" to public!
Then, it worked perfectly!
Bye
A problem that needs to be fixed was reported by Matthias Wegner at http://jira.xwiki.org/browse/XWIKI-9657
Hello. My experience is when running this on 6.0.1.
When run in dry run mode a large number of attachments are listed. When run with dry run disabled, fewer attachments appear to be processed (are listed). Icon attachments (eg avatar PNGs) were lost as well as some documents.
I don't see a way to repeat the db->file system move - which I can understand because I wouldn't want attachments duplicated - but it would be nice to be able to see the full list of attachments again in order to know what was omitted. This experience was on an evaluation wiki (prior to planned use) so this is throwaway content, but it doesn't seem like intended behavior.
Addendum to my comment above: while reloading the page with the script *did not* allow me to repeat the dry run, switching to edit mode and then exiting did reset the page so that I could repeat the dry run, confirming that many more files were listed in that mode. Reviewing the jira link in Vincent's post of 2013/11/12 I believe that the issue described there is still present (attachments that come with the default wiki pages aren't processed) but other attachments were also omitted. User beware.
FOR THOSE NEW TO XWIKI:
Snippets are a "snippet" of code that runs within a page on your wiki. To run the Snippet, copy and paste the most recent version of the snippet into a newly-created page on your wiki. I pasted it into the editor with "Source" mode enabled, it may work in WYSIWYG mode as well. After saving the page, you will see instructions on how to run the script.