Re: Slide locks lost with upgrade to Jahia 4.1
Thomas Draier <[email protected]>
| Newsgroups | gmane.comp.cms.jahia.install |
|---|---|
| Message-ID | <[email protected]> |
Hi Fabrice,
the script looks good to me - just be careful on the fact that you
iterate on all sites, but you check that the user is an administrator
of the current site only. you may rather use isRoot() instead of
isAdminMember(). but anyway, this should work.
thomas
Le 26 juil. 06 à 07:27, Fabrice Marchon a écrit :
> Hi,
>
> Thanks for the informations ; I has confirmed my first idea.
>
> I have written a draft for the script (a jsp file) that restores
> the locks
> on webdav files, and I think it may look like the following code :
>
> <%!/** lock a WevDAV file if any usage is found */
> private void lockDAVFile(DAVFileAccess file, ParamBean jParams) {
> if (file != null && jParams != null) {
> synchronized (file) {
> if (!file.isLocked()) {
> if (!file.isCollection()) {
> //get usages
> List usages =
> JahiaWebdavBaseService.getInstance()
>
> .findUsages(file.getPath(), jParams, true);
> if (usages != null &&
> !usages.isEmpty()) {
> //lock file
> file.lockFile(true);
> } else {
> //no usage
> }
> } else {
> //file is a collection
> }
> } else {
> //file is already locked
> }
> }
> }//null
> }
>
> /** lock a WevDAV file tree */
> private void lockDAVCollection(DAVFileAccess file, ParamBean
> jParams) {
> if (file != null && jParams != null) {
> //top-down and left-right approach to traverse the file tree
> if (!file.isCollection()) {
> //dav file is a real one => try to lock it
> lockDAVFile(file, jParams);
> } else {
> //file is a collection => get its children
> List children = file.getChildren();
> if (children != null && !children.isEmpty()) {
> //iterate over children
> Iterator iterator = children.iterator();
> while (iterator.hasNext()) {
> DAVFileAccess child =
> (DAVFileAccess) iterator.next();
> //recursive call over the child
> lockDAVCollection(child, jParams);
> }
> } else {
> //no children
> }
> }
> }//null
> }
> %><%//title
> out.write("Fix for slide locks on active/published files \n");
> out.write("-----------------------------------------------\n");
> //jData
> JahiaData jData = (JahiaData) request
> .getAttribute("org.jahia.data.JahiaData");
> if (jData == null) {
> HashMap tempEngineMap = (HashMap) request
> .getAttribute("org.jahia.engines.EngineHashMap");
> jData = (JahiaData) tempEngineMap.get("jData");
> }
> //param bean
> ParamBean jParams = jData.params();
> //user
> JahiaUser user = jParams.getUser();
>
> boolean isUserAdmin = user.isAdminMember(jParams.getSiteID());
> if (isUserAdmin) {
> //gets all sites
> Enumeration enumSites = ServicesRegistry.getInstance()
> .getJahiaSitesService().getSites();
> try {
> while (enumSites.hasMoreElements()) {
> JahiaSite site = (JahiaSite)
> enumSites.nextElement();
> //create dav file for "/shared" folder
> DAVFileAccess shared = new DAVFileAccess(jParams,
> site,
> user, "/shared");
> //try to lock the tree
> lockDAVCollection(shared, jParams);
> }
> out.write("Script successfully ended!\n");
>
> } catch (Exception e) {
> out.write("Exception during processing : \n");
> e.printStackTrace(new PrintWriter(out));
> }
>
> } else {
> //no action
> out
> .write("User is not an administrator. The script is
> not started.\n");
> }
> %>
>
>
> Regards,
> Fabrice Marchon
>
>> -----Message d'origine-----
>> De : Thomas Draier [mailto:[email protected]]
>> Envoyé : vendredi, 21. juillet 2006 11:45
>> À : [email protected]
>> Objet : Re: Slide locks lost with upgrade to Jahia 4.1
>>
>> Hi,
>> You're right, publication locks are not copied during the
>> migration process. There is no option to restore all locks in
>> jahia 4.1 , but we can help you writing a simple script that
>> recreates them. On each file, you can call
>> JahiaWebdavBaseService.getInstance ().findUsages
>> (file.getPath (), jParams, true), and the just call file.lockFile
>> (true) if some usages are found. This can be quite long on
>> 8Gb of files, but this should recreate all locks on published files.
>> Thomas
>>
>> Le 21 juil. 06 à 10:53, Fabrice Marchon a écrit :
>>
>>> Hi!
>>>
>>> I am trying to upgrade from jahia version 4.0.7_01 to
>> 4.1.1_01 using
>>> the official patch. I have to migrate 8 Go of files for our
>> production
>>> server, so that I try to be carefull as much as possible.
>>>
>>> The patch has been applied successfully after some modifications of
>>> the original Slide 1 tables structure into our jahia
>> database (running
>>> on MySQL 4.0.27). In fact, there were some integrity
>> problems that I
>>> have corrected.
>>>
>>> Full of motivation, I try the new Jahia 4.1, but when I use
>> the Jahia
>>> filemanager, I see that all locks on webdav files that are
>> published
>>> on pages are gone, so that I (and all other users) can delete all
>>> files without any protection! I test the case of uploading some new
>>> files and the latter are locked after I have published them
>> on a page.
>>>
>>> So my question is how to restore the lost locks or how to
>> create them
>>> again with the new slide 2 ?
>>>
>>> It seems that the offical Jahia 4.1 patch simply drops the
>>> jahia_slide_lock table from the previous Slide 1.
>>>
>>>
>>> Waiting for some help...
>>>
>>> Regards,
>>>
>>> Fabrice Marchon
>
>