Hi,

The best approach depends on what exactly do you want to do. Is the SVN 
the only place where you want attachments, or should the SVN be just a 
"backup", or alternate storage.

If you want to completely replace the database with SVN for attachments, 
then implementing XWikiAttachmentStoreInterface is the way to go.

If you want to use the DB inside XWiki, but have a mirror on an SVN 
server, then the notification mechanism is better.

Read below.

Artem Melentyev wrote:
> Hi.
> 
> Kamna Jain wrote:
>> I want to refer back to my thread on adding XWiki attachments to SVN.
>> Artem and Vincent both suggested  implementing the
>>
>> XWikiAttachmentStoreInterface.
>>
>> In this regard, I have a few Questions:
>>
>> 1)If I chose this option, do I have to follow the implementaion as done 
>> for 
>>
>> XWikiHibernateAttachmentStore (Is this the class that handles adding the 
>> attachments to the DB?)
> Yes.
> You can just extend this class and override needed methods.

You also have to register your implementation as the attachment storage 
in xwiki.cfg:

xwiki.store.attachment.class=some.package.SvnAttachmentStorage

>> 2) would that be enough - just implementing the interface, so that the 
>> functions like saveAttachementContent() will add it to SVN and 
>> loadAttachmentContent() will load it into XWiki from SVN. or would I 
>> have to do something with other classes like the XWikiAction class (in 
>> the Web package)
> Yes. It would be enough.
> 
>> 3) Sergiu suggested that I could also use the notification mechanism for 
>> the Fileupload action. Is this referring to the UploadAction class in 
>> the Web ackage or the fileupload plugin?
> 
> I'm not much familiar with notification mechanism in xwiki, but I think 
> it is more simpler and better way than writing AttachmentStore.

The notification mechanism will allow you to also store the attachment 
in SVN, but the attachment will go in the database, as it is done now. 
If you want to also update the wiki when the SVN is changed, you can 
write a SVN hook that notifies XWiki of the change. If you need more 
details, ask.

>> I am sorry if I am being naive, I am just trying to undertsand the code 
>> structure and dependencies, call hierarchies etc. Is there any place 
>> where I can go in to understand the code better?

Yes, the code :p

>> 4) Also, my understanding is that the API package has all the classes 
>> whose objects can be used in the velocity scripts at the presentation 
>> layer. Am I right?
> yes

Almost, there is also the request, response and different plugin APIs 
that you can use. Also, using programming rights you can get to the 
internal objects behind the API, as each API class has a method that 
allows getting the wrapped object. But for the start the main API should 
be enough, playing with the internal stuff is dangerous and not recommended.

>> 5) Can the SVN integration be done at the presentation layer (with 
>> velocity scripts...I doubt it, but just wanted to confirm)
> I think no.

Not directly. You can put a svn client jar in the lib directory, and 
write a Groovy class that acts as a Notification Listener and uses that 
svn client to perform the changes. It is the same as writing a java 
class, just that it is written in a wiki document, and uses the 
(simpler?) Groovy language instead of Java. You cannot write an 
attachment storage in Groovy, though.

>> 6) this is something to do with Eclispe and Subclipse I guess. I used 
>> subclipse to download the xwiki core and then checked it out into my 
>> workspace. The first time I did it, I had the Lucene plugin class in 
>> there. The second time I re-did it, the plugin class was no more there. 
>> (That is just one of the classes I noticed). could you think of 
>> something I might have missed out?
> try to clean, update eclipse projects.
> no ideas more.
> 

The Lucene plugin was recently moved to another place, so this is normal.

-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to