Index: main/plugin-flipbook/pages/flashpageflip/book.xsl
===================================================================
--- main/plugin-flipbook/pages/flashpageflip/book.xsl	(revision 40091)
+++ main/plugin-flipbook/pages/flashpageflip/book.xsl	(working copy)
@@ -27,7 +27,7 @@
     
     <xsl:param name="contextPath"/>
     <xsl:param name="fileUri"/>
-    <xsl:variable name="filename" select="urlcodec:decode(stringutils:substringAfterLast($fileUri, '/'))"/>
+    <xsl:param name="fileName"/>
     
     <xsl:template match="/">
         <html>
@@ -35,7 +35,7 @@
                 <title>
                     <i18n:translate>
                         <i18n:text i18n:key="PLUGINS_FLIPBOOK_BOOK_TITLE"/>
-                        <i18n:param name="filename"><xsl:value-of select="$filename"/></i18n:param>
+                        <i18n:param name="filename"><xsl:value-of select="$fileName"/></i18n:param>
                     </i18n:translate>
                 </title>
                 <xsl:call-template name="head-js-jquery" ></xsl:call-template>
Index: main/plugin-flipbook/sitemap.xmap
===================================================================
--- main/plugin-flipbook/sitemap.xmap	(revision 40091)
+++ main/plugin-flipbook/sitemap.xmap	(working copy)
@@ -45,20 +45,21 @@
     <map:pipelines>
         <map:pipeline>
 
-            <!-- <siteName>/_attachments-flipbook/<contentName>/(<path>/)<fileName>.html -->
-            <map:match pattern="*/_attachments-flipbook/*/**/book.html">
+            <!-- <siteName>/_attachments-flipbook/<fileName>/<metadatapath>/_contents/<content-path>/book.html -->
+            <map:match pattern="*/_attachments-flipbook/*/**/_contents/**/book.html">
                 <map:act type="set-header">
                     <map:parameter name="X-Ametys-Cacheable" value="true" />
                 </map:act>
                 <!-- Only get site to be able to use service:// source resolver. -->
                 <map:act type="get-site" src="{1}">
                     <map:act type="content-2-images">
-                        <map:parameter name="path" value="{jcrSitePath}/ametys-internal:contents/{../2}/ametys-internal:attachments/{../3}" />
+                        <map:parameter name="path" value="{../4}" />
                         <map:parameter name="contentName" value="{../2}" />
 
                         <map:generate type="images" />
                         <map:transform src="service://pages/flashpageflip/book.xsl">
-                            <map:parameter name="fileUri" value="{../../1}/_attachments-flipbook/{../../2}/{../../3}" />
+                            <map:parameter name="fileUri" value="{../../1}/_attachments/{../../2}/{../../3}" />
+                            <map:parameter name="fileName" value="{../../2}" />
                             <map:parameter name="contextPath" value="{request:contextPath}" />
                         </map:transform>
                         <map:transform type="i18n" label="xml">
@@ -82,7 +83,8 @@
 
                         <map:generate type="images" />
                         <map:transform src="service://pages/flashpageflip/book.xsl">
-                            <map:parameter name="fileUri" value="{../../1}/_resource-flipbook/{../../2}" />
+                            <map:parameter name="fileUri" value="{../../1}/_resources/{../../2}" />
+                            <map:parameter name="fileName" value="{../../2}" />
                             <map:parameter name="contextPath" value="{request:contextPath}" />
                         </map:transform>
                         <map:transform type="i18n" label="xml">
@@ -106,7 +108,8 @@
 
                         <map:generate type="images" />
                         <map:transform src="service://pages/flashpageflip/book.xsl">
-                            <map:parameter name="fileUri" value="{../../1}/_shared-resource-flipbook/{../../2}" />
+                            <map:parameter name="fileUri" value="{../../1}/_shared-resources/{../../2}" />
+                            <map:parameter name="fileName" value="{../../2}" />
                             <map:parameter name="contextPath" value="{request:contextPath}" />
                         </map:transform>
                         <map:transform type="i18n" label="xml">
@@ -118,20 +121,21 @@
                 </map:act>
             </map:match>
 
-            <!-- <siteName>/_metadata-flipbook/(<path>/)<fileName>.html -->
-            <map:match pattern="*/_metadata-flipbook/*/**/book.html">
+            <!-- <siteName>/_metadata-flipbook/<fileName>/<metadatapath>/_contents/<content-path>/book.html -->
+            <map:match pattern="*/_metadata-flipbook/*/**/_contents/**/book.html">
                 <map:act type="set-header">
                     <map:parameter name="X-Ametys-Cacheable" value="true" />
                 </map:act>
                 <!-- Only get site to be able to use service:// source resolver. -->
                 <map:act type="get-site" src="{1}">
                     <map:act type="metadata-2-images">
-                        <map:parameter name="content-path" value="{jcrSitePath}/ametys-internal:contents/{../2}" />
+                        <map:parameter name="content-path" value="{../4}" />
                         <map:parameter name="metadata-path" value="{../3}" />
 
                         <map:generate type="images" />
                         <map:transform src="service://pages/flashpageflip/book.xsl">
-                            <map:parameter name="fileUri" value="{../../1}/_metadata-flipbook/{../../2}" />
+                            <map:parameter name="fileUri" value="_contents/{../../4}/_metadata/{../../2}/{../../3}" />
+                            <map:parameter name="fileName" value="{../../2}" />
                             <map:parameter name="contextPath" value="{request:contextPath}" />
                         </map:transform>
                         <map:transform type="i18n" label="xml">
Index: main/plugin-flipbook/src/org/ametys/plugins/flipbook/Attachment2FlipbookUriResolver.java
===================================================================
--- main/plugin-flipbook/src/org/ametys/plugins/flipbook/Attachment2FlipbookUriResolver.java	(revision 40091)
+++ main/plugin-flipbook/src/org/ametys/plugins/flipbook/Attachment2FlipbookUriResolver.java	(working copy)
@@ -21,6 +21,7 @@
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.components.ContextHelper;
@@ -29,6 +30,7 @@
 import org.ametys.cms.repository.Content;
 import org.ametys.cms.transformation.URIResolver;
 import org.ametys.plugins.explorer.resources.Resource;
+import org.ametys.plugins.repository.AmetysObjectResolver;
 import org.ametys.plugins.repository.UnknownAmetysObjectException;
 import org.ametys.runtime.plugin.component.PluginAware;
 import org.ametys.web.editor.AttachmentURIResolver;
@@ -113,6 +115,8 @@
                 + "/_attachments-flipbook/"
                 + contentName 
                 + _encodePath(path.substring(1))
+                + "/_contents"
+                + _encodePath(resource.getPath().substring(1))
                 + "/book.html";
         
         if (!_attachmentComponent.isMimeTypeSupported(resource.getMimeType()))
@@ -120,7 +124,7 @@
             return super.resolve(uri, download, absolute, internal);
         }
         
-        new CacheThread(resource, contentName, siteName).start();
+        new CacheThread(resource.getId(), contentName, siteName, _resolver, getLogger()).start();
         
         try
         {
@@ -177,6 +181,8 @@
                 return new URI(null, null, defaultPath, null, null).toASCIIString();
             }
 
+            new CacheThread(resource.getId(), contentName, siteName, _resolver, getLogger()).start();
+            
             String result = (absolute ? _prefixHandler.getAbsoluteUriPrefix(siteName) : _prefixHandler.getUriPrefix(siteName))
                     + "/_plugins/" + _pluginName + "/" + siteName
                     + "/contents/"
@@ -246,6 +252,8 @@
                 return new URI(null, null, defaultPath, null, null).toASCIIString();
             }
 
+            new CacheThread(resource.getId(), contentName, siteName, _resolver, getLogger()).start();
+            
             String result = (absolute ? _prefixHandler.getAbsoluteUriPrefix(siteName) : _prefixHandler.getUriPrefix(siteName))
                     + "/_plugins/" + _pluginName + "/" + siteName
                     + "/contents/"
@@ -267,15 +275,19 @@
     
     private class CacheThread extends Thread 
     {
-        private Resource _resource;
-        private String _contentName;
+        private String _resourceId;
         private String _siteName;
+        private String _contentName;
+        private Logger _cacheLogger;
+        private AmetysObjectResolver _cacheResolver;
         
-        public CacheThread(Resource resource, String contentName, String siteName) 
+        public CacheThread(String resourceId, String contentName, String siteName, AmetysObjectResolver cacheResolver, Logger cacheLogger) 
         {
-            _resource = resource;
-            _contentName = contentName;
+            _resourceId = resourceId;
             _siteName = siteName;
+            _cacheLogger = cacheLogger;
+            _cacheResolver = cacheResolver;
+            _contentName = contentName;
             setDaemon(true);
             setName("FlipbookCacheAttachmentCreator");
         }
@@ -285,11 +297,12 @@
         {
             try
             {
-                _attachmentComponent.doCache(_resource, _contentName, _siteName);
+                Resource resource = _cacheResolver.resolveById(_resourceId);
+                _attachmentComponent.doCache(resource, _contentName, _siteName);
             }
             catch (Exception e)
             {
-                e.printStackTrace();
+                _cacheLogger.error("An error occurred during creating cache for resource : " + _resourceId);
             }
         }
     }
Index: main/plugin-flipbook/src/org/ametys/plugins/flipbook/ConvertContentAttachment2ImagesAction.java
===================================================================
--- main/plugin-flipbook/src/org/ametys/plugins/flipbook/ConvertContentAttachment2ImagesAction.java	(revision 40091)
+++ main/plugin-flipbook/src/org/ametys/plugins/flipbook/ConvertContentAttachment2ImagesAction.java	(working copy)
@@ -15,13 +15,13 @@
  */
 package org.ametys.plugins.flipbook;
 
-import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
 import java.util.Map;
 
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.acting.ServiceableAction;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Redirector;
@@ -58,30 +58,21 @@
         
         // Get the resource.
         String resourcePath = parameters.getParameter("path", request.getParameter("path"));
-        Resource resource = _resolver.resolve(_decodePath(resourcePath.substring(1)));
         
-        String cachePath = _attachmentComponent.doCache(resource, parameters.getParameter("contentName", null), siteName);
-        request.setAttribute(ImagesGenerator.IMAGES_DIRECTORY_PATH_REQUEST_ATTR, cachePath);
+        try
+        {
+            resourcePath = URLDecoder.decode(resourcePath, "utf-8");
+            Resource resource = _resolver.resolve(resourcePath);
+            
+            String cachePath = _attachmentComponent.doCache(resource, parameters.getParameter("contentName", null), siteName);
+            request.setAttribute(ImagesGenerator.IMAGES_DIRECTORY_PATH_REQUEST_ATTR, cachePath);
+        }
+        catch (Exception e)
+        {
+            throw new ProcessingException("An error occurred during resolving resource path " + resourcePath, e);
+        }
 
         return EMPTY_MAP;
     }
     
-    /**
-     * Decode the resource path
-     * @param path the resource path
-     * @return the decoded resource path
-     * @throws UnsupportedEncodingException if UTF-8 encoding is not supported
-     */
-    protected String _decodePath (String path) throws UnsupportedEncodingException
-    {
-        StringBuffer sb = new StringBuffer();
-        
-        String[] parts = path.split("/");
-        for (String part : parts)
-        {
-            sb.append("/");
-            sb.append(URLDecoder.decode(part, "utf-8"));
-        }
-        return sb.toString();
-    }
 }
Index: main/plugin-flipbook/src/org/ametys/plugins/flipbook/ConvertMetadata2ImagesAction.java
===================================================================
--- main/plugin-flipbook/src/org/ametys/plugins/flipbook/ConvertMetadata2ImagesAction.java	(revision 40091)
+++ main/plugin-flipbook/src/org/ametys/plugins/flipbook/ConvertMetadata2ImagesAction.java	(working copy)
@@ -20,6 +20,7 @@
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.acting.ServiceableAction;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Redirector;
@@ -54,13 +55,22 @@
         Request request = ObjectModelHelper.getRequest(objectModel);
         String siteName = (String) request.getAttribute("site");
         String contentPath = parameters.getParameter("content-path", null);
-
-        Content content = _resolver.resolve(contentPath);
-        String metadataPath = parameters.getParameter("metadata-path", null);
         
-        String cachePath = _metadataComponent.doCache(content, metadataPath, siteName);
-        // Set the directory path in request attribute
-        request.setAttribute(ImagesGenerator.IMAGES_DIRECTORY_PATH_REQUEST_ATTR, cachePath);
+        try
+        {
+            //Decode contentPath as the metadataUriResolver does
+            contentPath = contentPath.replaceAll("%3A", ":");
+            Content content = _resolver.resolve(contentPath);
+            String metadataPath = parameters.getParameter("metadata-path", null);
+            
+            String cachePath = _metadataComponent.doCache(content, metadataPath, siteName);
+            // Set the directory path in request attribute
+            request.setAttribute(ImagesGenerator.IMAGES_DIRECTORY_PATH_REQUEST_ATTR, cachePath);
+        }
+        catch (Exception e)
+        {
+            throw new ProcessingException("An error occurred during resolving content path " + contentPath, e);
+        }
         
         return EMPTY_MAP;
     }
Index: main/plugin-flipbook/src/org/ametys/plugins/flipbook/Metadata2FlipbookUriResolver.java
===================================================================
--- main/plugin-flipbook/src/org/ametys/plugins/flipbook/Metadata2FlipbookUriResolver.java	(revision 40091)
+++ main/plugin-flipbook/src/org/ametys/plugins/flipbook/Metadata2FlipbookUriResolver.java	(working copy)
@@ -21,6 +21,8 @@
 import java.util.Iterator;
 import java.util.List;
 
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.components.ContextHelper;
@@ -28,6 +30,7 @@
 
 import org.ametys.cms.repository.Content;
 import org.ametys.cms.transformation.URIResolver;
+import org.ametys.plugins.repository.AmetysObjectResolver;
 import org.ametys.plugins.repository.UnknownAmetysObjectException;
 import org.ametys.plugins.repository.metadata.BinaryMetadata;
 import org.ametys.plugins.repository.metadata.CompositeMetadata;
@@ -40,12 +43,15 @@
  * {@link URIResolver} for type "resource-pdf2flash".<br> TODO
  * These links point to a document file from the resource explorer converted to flash. 
  */
-public class Metadata2FlipbookUriResolver extends MetadataURIResolver implements PluginAware
+public class Metadata2FlipbookUriResolver extends MetadataURIResolver implements PluginAware, LogEnabled
 {
     /** The plugin name. */
     protected String _pluginName;
     
-    /** The ametys object resolver. */
+    /** The logger . */
+    protected Logger _logger;
+    
+    /** The metadata to images component. */
     protected ConvertMetadata2ImagesComponent _metadataComponent;
     
     @Override
@@ -56,6 +62,12 @@
     }
     
     @Override
+    public void enableLogging(Logger logger)
+    {
+        _logger = logger;
+    }
+    
+    @Override
     public void setPluginInfo(String pluginName, String featureName)
     {
         _pluginName = pluginName;
@@ -90,21 +102,24 @@
             return "";
         }
 
+        Content content = (Content) object;
         String resultPath = (absolute ? _prefixHandler.getAbsoluteUriPrefix(siteName) : _prefixHandler.getUriPrefix(siteName))
                 + "/_plugins/" + _pluginName + "/" + siteName
                 + "/_metadata-flipbook/"
                 + _encode(fileName)
                 + _encodePath(metadataPath)
+                + "/_contents"
+                + _encodePath(content.getPath().substring(1))
                 + "/book.html";
         
-        BinaryMetadata binary = _getBinaryMetadata(metadataPath, ((Content) object).getMetadataHolder());
+        BinaryMetadata binary = _getBinaryMetadata(metadataPath, content.getMetadataHolder());
         
         if (!_metadataComponent.isMimeTypeSupported(binary.getMimeType()))
         {
             return super.resolve(uri, download, absolute, internal);
         }
        
-        new CacheThread((Content) object, metadataPath, siteName).start();
+        new CacheThread(content.getId(), metadataPath, siteName, _resolver, _logger).start();
         
         try
         {
@@ -154,6 +169,8 @@
                 return new URI(null, null, defaultPath, null, null).toASCIIString();
             }
 
+            new CacheThread(content.getId(), metadataPath, siteName, _resolver, _logger).start();
+            
             String result = (absolute ? _prefixHandler.getAbsoluteUriPrefix(siteName) : _prefixHandler.getUriPrefix(siteName))
                     + "/_plugins/" + _pluginName + "/" + siteName
                     + "/contents/"
@@ -217,7 +234,9 @@
                 
                 return new URI(null, null, defaultPath, null, null).toASCIIString();
             }
-
+            
+            new CacheThread(content.getId(), metadataPath, siteName, _resolver, _logger).start();
+            
             String result = (absolute ? _prefixHandler.getAbsoluteUriPrefix(siteName) : _prefixHandler.getUriPrefix(siteName))
                     + "/_plugins/" + _pluginName + "/" + siteName
                     + "/contents/"
@@ -271,15 +290,19 @@
     
     private class CacheThread extends Thread 
     {
-        private Content _content;
+        private String _contentId;
         private String _metadataPath;
         private String _siteName;
+        private Logger _cacheLogger;
+        private AmetysObjectResolver _cacheResolver;
         
-        public CacheThread(Content content, String metadataPath, String siteName) 
+        public CacheThread(String contentId, String metadataPath, String siteName, AmetysObjectResolver cacheResolver, Logger cacheLogger) 
         {
-            _content = content;
+            _contentId = contentId;
             _metadataPath = metadataPath;
             _siteName = siteName;
+            _cacheLogger = cacheLogger;
+            _cacheResolver = cacheResolver;
             setDaemon(true);
             setName("FlipbookCacheMetadataCreator");
         }
@@ -289,13 +312,13 @@
         {
             try
             {
-                _metadataComponent.doCache(_content, _metadataPath, _siteName);
+                Content content = _cacheResolver.resolveById(_contentId);
+                _metadataComponent.doCache(content, _metadataPath, _siteName);
             }
             catch (Exception e)
             {
-                e.printStackTrace();
+                _cacheLogger.error("An error occurred during creating cache for content : " + _contentId);
             }
         }
     }
-
 }
Index: main/plugin-flipbook/src/org/ametys/plugins/flipbook/Resource2FlipbookUriResolver.java
===================================================================
--- main/plugin-flipbook/src/org/ametys/plugins/flipbook/Resource2FlipbookUriResolver.java	(revision 40091)
+++ main/plugin-flipbook/src/org/ametys/plugins/flipbook/Resource2FlipbookUriResolver.java	(working copy)
@@ -21,6 +21,7 @@
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.components.ContextHelper;
@@ -28,6 +29,7 @@
 
 import org.ametys.cms.transformation.URIResolver;
 import org.ametys.plugins.explorer.resources.Resource;
+import org.ametys.plugins.repository.AmetysObjectResolver;
 import org.ametys.plugins.repository.UnknownAmetysObjectException;
 import org.ametys.runtime.plugin.component.PluginAware;
 import org.ametys.web.editor.ResourceURIResolver;
@@ -125,7 +127,7 @@
                     + _encodePath(path.substring(1))
                     + "/book.html";
             
-            new CacheThread(resource, siteName).start();
+            new CacheThread(resource.getId(), siteName, _resolver, getLogger()).start();
             
             return new URI(null, null, result, null, null).toASCIIString();
         }
@@ -181,6 +183,8 @@
                 return new URI(null, null, defaultPath, null, null).toASCIIString();
             }
 
+            new CacheThread(resource.getId(), siteName, _resolver, getLogger()).start();
+            
             String result = (absolute ? _prefixHandler.getAbsoluteUriPrefix(siteName) : _prefixHandler.getUriPrefix(siteName))
                     + "/_plugins/" + _pluginName + "/" + siteName
                     + prefix
@@ -250,6 +254,8 @@
                 return new URI(null, null, defaultPath, null, null).toASCIIString();
             }
 
+            new CacheThread(resource.getId(), siteName, _resolver, getLogger()).start();
+            
             String result = (absolute ? _prefixHandler.getAbsoluteUriPrefix(siteName) : _prefixHandler.getUriPrefix(siteName))
                     + "/_plugins/" + _pluginName + "/" + siteName
                     + prefix
@@ -270,13 +276,17 @@
 
     private class CacheThread extends Thread 
     {
-        private Resource _resource;
+        private String _resourceId;
         private String _siteName;
+        private Logger _cacheLogger;
+        private AmetysObjectResolver _cacheResolver;
         
-        public CacheThread(Resource resource, String siteName) 
+        public CacheThread(String resourceId, String siteName, AmetysObjectResolver cacheResolver, Logger cacheLogger) 
         {
-            _resource = resource;
+            _resourceId = resourceId;
             _siteName = siteName;
+            _cacheLogger = cacheLogger;
+            _cacheResolver = cacheResolver;
             setDaemon(true);
             setName("FlipbookCacheResourceCreator");
         }
@@ -286,11 +296,12 @@
         {
             try
             {
-                _resourceComponent.doCache(_resource, _siteName);
+                Resource resource = _cacheResolver.resolveById(_resourceId);
+                _resourceComponent.doCache(resource, _siteName);
             }
             catch (Exception e)
             {
-                e.printStackTrace();
+                _cacheLogger.error("An error occurred during creating cache for resource : " + _resourceId);
             }
         }
     }
