[opencms-dev] manual backup of resources

Florian Kleedorfer florian.kleedorfer at austria.fm
Tue Apr 20 16:10:02 CEST 2004


What I would like to do is exactly what the OpenCms version control 
mechanism does, but
I would like to trigger it in my java code (which has a reference to a 
CmsObject Object).
Maybe I should restate my example:

I have some String data, which is kept in a CmsFile object, accessed 
using the getContents/setContents methods.

Now, prior to overwriting the contents of the CmsFile object with 
setContents(). here's what
I would like to do:
*) create an entry in the CMS_BACKUP_RESOURCES / CMS_BACKUP_FILES tables
(which I would like OpenCms to do for me)
*) get the versionid  of the newly created BackupResource which I will 
use later on
 
Note that I would like to avoid publishing the resource if possible. (I 
don't use the publishing mechanism of OpenCms, just in case you were 
going to ask.)

On some other occasion I would like to access a backed up version of the 
CmsFile object, i.e. with a specific versionId. According to what 
methods I found in the OpenCms sources, this should work. 
(CmsObject.readFileForHist(String filename, int versionId))

I have spent quite some time searching the OpenCms sourcecode, but 
unfortunately I haven't found
the method I need. Everything that has to do with versioning involves 
publishing and I don't want to believe that these mechanisms are so 
closely coupled.

thanks for your help!
Flo
M Butcher wrote:

>
> What do you want to back it up to? Disk? Some other database?
>
> OpenCms uses a version control mechanism, so there is a built-in 
> backup mechanism in the database already (for instance, look at the 
> CMS_BACKUP_* tables in the DB). Skim through the CmsResourceBroker 
> class  for your database (e.g. 
> com.opencms.file.myslq.CmsResourceBroker) -- I'm pretty sure the code 
> is in there.
>
> Matt
>
> Florian Kleedorfer wrote:
>
>> hi all!
>>
>> Does anyone know how you can "manually" backup a single CmsResource
>> without publishing it and  without having to backup the whole project?
>>
>> Here's a sketch of the lifecycle that I would like to implement:
>>
>> [creation]
>>
>> public void CreateFile(CmsObject cms,  String filename, byte[]
>> myModifiedByteContent) {
>>     ...
>>    CmsResource newResource = cms.createResource( folder, name ,
>> "plain", null,     myNewByteContent);
>>    ...
>> }
>>
>> [manipulation]
>> public void manipulateFile(CmsObject cms,  String filename, byte[]
>> myModifiedByteContent) {
>>    ...
>>    CmsFile file = cms.readFile(filename);
>>    <backup the CmsResource (i.e. the CmsFile),  need help here!>
>>    file.setContents(myModifiedByteContent);
>>    cms.writeFile(file);
>>    ...
>> }
>>
>> [restoring]
>> public void restoreVersion(CmsObject cms,  String filename, int 
>> versionId) {
>>    <need help here!>
>> }
>>
>>
>> thx for your help!
>> flo
>>
>> _______________________________________________
>> This mail is send to you from the opencms-dev mailing list
>> To change your list options, or to unsubscribe from the list, please 
>> visit
>> http://mail.opencms.org/mailman/listinfo/opencms-dev
>
>
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please 
> visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev
>
>




More information about the opencms-dev mailing list