Author: tdraier
Date: Fri Feb 15 19:46:20 2008
New Revision: 19726

URL: https://svndev.jahia.net/websvn/listing.php?sc=3D1&rev=3D19726&repname=
=3Djahia
Log:
path mapping when importing with different sitekey /or import from older ve=
rsion

Modified:
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/content/JCRStoreProvider.java
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/content/JCRStoreService.java
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/importexport/DocumentViewImportHandler.java
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/importexport/ImportExportBaseService.java
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/importexport/ImportExportService.java
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/importexport/ImportHandler.java
    branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/importexport/ImportJob.java

Modified: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahi=
a/services/content/JCRStoreProvider.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-3-=
DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/services/content/JCRStoreProv=
ider.java&rev=3D19726&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/content/JCRStoreProvider.java (original)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/content/JCRStoreProvider.java Fri Feb 15 19:46:20 2008
@@ -299,8 +299,8 @@
         }
     }
 =

-    public List getAvailableTypes() throws RepositoryException {
-        List types =3D new ArrayList();
+    public List<String> getAvailableTypes() throws RepositoryException {
+        List<String> types =3D new ArrayList<String>();
         Session session =3D getSystemSession();
         try {
             NodeTypeIterator nti =3D session.getWorkspace().getNodeTypeMan=
ager().getMixinNodeTypes();
@@ -421,14 +421,14 @@
         return result;
     }
 =

-    public List getImportDropBoxes(String site, JahiaUser user) throws Rep=
ositoryException {
+    public List<FileNode> getImportDropBoxes(String site, JahiaUser user) =
throws RepositoryException {
         Session session =3D getThreadSession(user);
         String xp =3D "//element("+user.getUsername()+", jnt:userFolder)//=
element(*, jnt:importDropBox)";
 =

         if (site !=3D null) {
             xp =3D "//element("+site+", jnt:virtualsite)" + xp;
         }
-        List results =3D new ArrayList();
+        List<FileNode> results =3D new ArrayList<FileNode>();
         QueryManager queryManager =3D session.getWorkspace().getQueryManag=
er();
         if (queryManager !=3D null) {
             Query q =3D queryManager.createQuery(xp, Query.XPATH);
@@ -445,11 +445,11 @@
         return results;
     }
 =

-    public List getSiteFolders(String site, JahiaUser user) throws Reposit=
oryException {
+    public List<FileNode> getSiteFolders(String site, JahiaUser user) thro=
ws RepositoryException {
         Session session =3D getThreadSession(user);
         String xp =3D "//element("+site+", jnt:virtualsite)";
 =

-        List results =3D new ArrayList();
+        List<FileNode> results =3D new ArrayList<FileNode>();
         QueryManager queryManager =3D session.getWorkspace().getQueryManag=
er();
         if (queryManager !=3D null) {
             Query q =3D queryManager.createQuery(xp, Query.XPATH);

Modified: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahi=
a/services/content/JCRStoreService.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-3-=
DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/services/content/JCRStoreServ=
ice.java&rev=3D19726&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/content/JCRStoreService.java (original)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/content/JCRStoreService.java Fri Feb 15 19:46:20 2008
@@ -39,8 +39,8 @@
     private static org.apache.log4j.Logger logger =3D
         org.apache.log4j.Logger.getLogger(JCRStoreService.class);
 =

-    private Map providers =3D new HashMap();
-    private SortedMap mountPoints =3D new TreeMap();
+    private Map<String,StoreProvider> providers =3D new HashMap<String,Sto=
reProvider>();
+    private SortedMap<String,StoreProvider> mountPoints =3D new TreeMap<St=
ring,StoreProvider>();
 =

     static private JCRStoreService instance =3D null;
 =

@@ -60,7 +60,7 @@
 =

             for (Iterator iterator =3D mountPoints.keySet().iterator(); it=
erator.hasNext();) {
                 String mp =3D (String) iterator.next();
-                StoreProvider sp =3D (StoreProvider) mountPoints.get(mp);
+                StoreProvider sp =3D mountPoints.get(mp);
                 providers.put(sp.getKey(), sp);
                 sp.setMountPoint(mp);
             }
@@ -80,10 +80,10 @@
         return mountPoints;
     }
 =

-    public void setMountPoints(Map mountPoints) {
-        this.mountPoints =3D new TreeMap(new Comparator() {
-            public int compare(Object o1, Object o2) {
-                return ((Comparable)o2).compareTo(o1);
+    public void setMountPoints(Map<String,StoreProvider> mountPoints) {
+        this.mountPoints =3D new TreeMap<String,StoreProvider>(new Compara=
tor<String>() {
+            public int compare(String s1, String s2) {
+                return s2.compareTo(s1);
             }
         });
         this.mountPoints.putAll(mountPoints);
@@ -98,7 +98,7 @@
                     if (!mp.equals("/")) {
                         localPath =3D path.substring(mp.length());
                     }
-                    StoreProvider provider =3D (StoreProvider) mountPoints=
.get(mp);
+                    StoreProvider provider =3D mountPoints.get(mp);
                     return provider.getFileNodeWrapper(localPath, user);
                 }
             }
@@ -107,7 +107,7 @@
             int index =3D path.indexOf(":");
             String key =3D path.substring(0,index);
             String localPath =3D path.substring(index+1);
-            StoreProvider provider =3D (StoreProvider) providers.get(key);
+            StoreProvider provider =3D providers.get(key);
             if (provider !=3D null) {
                 return provider.getFileNodeWrapper(localPath, user);
             }
@@ -119,7 +119,7 @@
         for (Iterator iterator =3D mountPoints.keySet().iterator(); iterat=
or.hasNext();) {
             String mp =3D (String) iterator.next();
             if (mp.equals("/") || path.equals(mp) || path.startsWith(mp+"/=
")) {
-                return (StoreProvider) mountPoints.get(mp);
+                return mountPoints.get(mp);
             }
         }
         return null;
@@ -129,8 +129,8 @@
         getProvider(path).export(path, ch , user);
     }
 =

-    public List getImportDropBoxes(String site, JahiaUser user) {
-        List r =3D new ArrayList();
+    public List<FileNode> getImportDropBoxes(String site, JahiaUser user) {
+        List<FileNode> r =3D new ArrayList<FileNode>();
         Collection c =3D getMountPoints().values();
         for (Iterator iterator =3D c.iterator(); iterator.hasNext();) {
             StoreProvider storeProvider =3D (StoreProvider) iterator.next(=
);
@@ -145,8 +145,8 @@
         return r;
     }
 =

-    public List getSiteFolders(String site, JahiaUser user) {
-        List r =3D new ArrayList();
+    public List<FileNode> getSiteFolders(String site, JahiaUser user) {
+        List<FileNode> r =3D new ArrayList<FileNode>();
         Collection c =3D getMountPoints().values();
         for (Iterator iterator =3D c.iterator(); iterator.hasNext();) {
             StoreProvider storeProvider =3D (StoreProvider) iterator.next(=
);

Modified: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahi=
a/services/importexport/DocumentViewImportHandler.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-3-=
DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/services/importexport/Documen=
tViewImportHandler.java&rev=3D19726&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/importexport/DocumentViewImportHandler.java (original)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/importexport/DocumentViewImportHandler.java Fri Feb 15 19:46:20 2008
@@ -7,19 +7,14 @@
 import org.jahia.services.content.FileNode;
 import org.jahia.services.content.JCRFileNodeWrapper;
 import org.jahia.utils.zip.ZipEntry;
-import org.jahia.utils.zip.ZipInputStream;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
 import org.xml.sax.helpers.DefaultHandler;
 =

-import javax.jcr.RepositoryException;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Stack;
-import java.util.StringTokenizer;
+import java.util.*;
 =

 /**
  * Created by IntelliJ IDEA.
@@ -40,6 +35,9 @@
     private Stack<FileNode> nodes =3D new Stack<FileNode>();
     private Stack<String> pathes =3D new Stack<String>();
 =

+    private Map<String,String> uuidMapping =3D new HashMap<String,String>(=
);
+    private Map<String,String> pathMapping =3D new HashMap<String,String>(=
);
+
     public DocumentViewImportHandler(ProcessingContext jParams, File archi=
ve, List<String> fileList) {
         this.jParams =3D jParams;
 =

@@ -56,19 +54,27 @@
             String decodedLocalName =3D ISO9075.decode(localName);
             pathes.push(pathes.peek() + "/" + decodedLocalName);
 =

+            String path;
+            if (nodes.peek().getPath().equals("/")) {
+                path =3D"/" + decodedLocalName;
+            } else {
+                path =3D nodes.peek().getPath() + "/" + decodedLocalName;
+            }
+
             String pt =3D atts.getValue("jcr:primaryType");
             if ("jnt:virtualsite".equals(pt)) {
                 decodedLocalName =3D jParams.getSiteKey();
+                String newpath;
+                if (nodes.peek().getPath().equals("/")) {
+                    newpath =3D"/" + decodedLocalName;
+                } else {
+                    newpath =3D nodes.peek().getPath() + "/" + decodedLoca=
lName;
+                }
+                pathMapping.put(path + "/",newpath +"/");
+                path =3D newpath;
             }
 =

-            String s;
-            if (nodes.peek().getPath().equals("/")) {
-                s =3D"/" + decodedLocalName;
-            } else {
-                s =3D nodes.peek().getPath() + "/" + decodedLocalName;
-            }
-
-            FileNode child =3D ServicesRegistry.getInstance().getJCRStoreS=
ervice().getFileNode(s, jParams.getUser());
+            FileNode child =3D ServicesRegistry.getInstance().getJCRStoreS=
ervice().getFileNode(path, jParams.getUser());
             nodes.peek().beginTransaction();
             if (!child.isValid()) {
                 boolean isFile =3D findFile();
@@ -102,7 +108,11 @@
                 } else if (attrName.equals(Constants.JCR_MIXINTYPES)) {
 =

                 } else if (attrName.equals(Constants.JCR_UUID)) {
-
+                    if (child instanceof JCRFileNodeWrapper) {
+                        uuidMapping.put(attrValue, ((JCRFileNodeWrapper)ch=
ild).getObjectNode().getUUID());
+                    } else {
+                        uuidMapping.put(attrValue, child.getPath());
+                    }
                 } else if (attrName.equals(Constants.JCR_CREATED)) {
 =

                 } else if (attrName.equals(Constants.JCR_MIMETYPE)) {
@@ -154,4 +164,12 @@
             zis =3D null;
         }
     }
+
+    public Map<String, String> getUuidMapping() {
+        return uuidMapping;
+    }
+
+    public Map<String, String> getPathMapping() {
+        return pathMapping;
+    }
 }

Modified: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahi=
a/services/importexport/ImportExportBaseService.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-3-=
DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/services/importexport/ImportE=
xportBaseService.java&rev=3D19726&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/importexport/ImportExportBaseService.java (original)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/importexport/ImportExportBaseService.java Fri Feb 15 19:46:20 2008
@@ -90,7 +90,6 @@
 import org.jahia.utils.LanguageCodeConverters;
 import org.jahia.utils.zip.FilteredDirectoryWalker;
 import org.jahia.utils.zip.ZipEntry;
-import org.jahia.utils.zip.ZipInputStream;
 import org.jahia.utils.zip.ZipOutputStream;
 import org.quartz.CronTrigger;
 import org.quartz.JobDataMap;
@@ -141,6 +140,12 @@
     public static final SimpleDateFormat DATE_FORMAT =3D new SimpleDateFor=
mat("yyyyMMddHHmmss");
     private static final String GHOST =3D "GHOST";
     private static final String CDATA =3D "CDATA";
+    private static final String FILESACL_XML =3D "filesacl.xml";
+    private static final String REPOSITORY_XML =3D "repository.xml";
+    private static final String CATEGORIES_XML =3D "categories.xml";
+    private static final String SITE_PERMISSIONS_XML =3D "sitePermissions.=
xml";
+    private static final String USERS_XML =3D "users.xml";
+    private static final String SITE_PROPERTIES =3D "site.properties";
 =

     private JahiaSitesService sitesService;
     private JahiaUserManagerService userManagerService;
@@ -317,7 +322,7 @@
             if (object.getParent(null) =3D=3D null) {
                 // site export
                 if (params.containsKey(INCLUDE_SITE_INFOS)) {
-                    zout.putNextEntry(new ZipEntry("site.properties"));
+                    zout.putNextEntry(new ZipEntry(SITE_PROPERTIES));
                     exportSiteInfos(zout, jParams, jParams.getSite());
                 }
 =

@@ -326,15 +331,15 @@
                     exportTpl(zout, jParams, jParams.getSite());
                 }
 =

-                zout.putNextEntry(new ZipEntry("categories.xml"));
+                zout.putNextEntry(new ZipEntry(CATEGORIES_XML));
                 exportCategories(dw, jParams.getUser());
                 dw.flush();
 =

-                zout.putNextEntry(new ZipEntry("users.xml"));
+                zout.putNextEntry(new ZipEntry(USERS_XML));
                 exportUsers(dw, jParams.getSite());
                 dw.flush();
 =

-                zout.putNextEntry(new ZipEntry("sitePermissions.xml"));
+                zout.putNextEntry(new ZipEntry(SITE_PERMISSIONS_XML));
                 exportSitePermissions(dw, jParams.getSite());
                 dw.flush();
             }
@@ -353,7 +358,7 @@
         sorted.addAll(files);
 =

         DataWriter dw =3D new DataWriter(new OutputStreamWriter(zout, "UTF=
-8"));
-        zout.putNextEntry(new ZipEntry("repository.xml"));
+        zout.putNextEntry(new ZipEntry(REPOSITORY_XML));
         exportFilesInfo(dw, sorted, typesToIgnore);
         dw.flush();
         exportFilesBinary(sorted, zout, typesToIgnore);
@@ -1352,6 +1357,9 @@
                     FileNode file =3D ServicesRegistry.getInstance().getJC=
RStoreService().getFileNode(value, jParams.getUser());
                     if (file.isValid() && !files.contains(file)) {
                         files.add(file);
+                        value =3D file.getPath();
+                    } else {
+                        value =3D "";
                     }
                 }
                 return value;
@@ -1464,22 +1472,36 @@
         zis.reallyClose();
 =

         boolean hasRepositoryFile =3D false;
+        Map<String, String> pathMapping =3D null;
+
         zis =3D new NoCloseZipInputStream(new FileInputStream(file));
         while (true) {
             ZipEntry zipentry =3D zis.getNextEntry();
             if (zipentry =3D=3D null) break;
             String name =3D zipentry.getName();
-            if (name.equals("users.xml")) {
+            if (name.equals(USERS_XML)) {
                 userProps =3D importUsersAndGetUuidProps(zis, usersImportH=
andler);
             }
-            if (name.equals("repository.xml")) {
+            if (name.equals(REPOSITORY_XML)) {
                 hasRepositoryFile =3D true;
-                importRepositoryFile(jParams, file, fileList, zis);
+                DocumentViewImportHandler documentViewImportHandler =3D ne=
w DocumentViewImportHandler(jParams, file, fileList);
+                handleImport(zis, documentViewImportHandler);
+                pathMapping =3D documentViewImportHandler.getPathMapping();
             }
             zis.closeEntry();
         }
         zis.reallyClose();
 =

+        if (!hasRepositoryFile) {
+            pathMapping =3D new HashMap<String,String>();
+            List<FileNode> sitesFolder =3D JCRStoreService.getInstance().g=
etSiteFolders(jParams.getSiteKey(), jParams.getUser());
+            if (!sitesFolder.isEmpty()) {
+                pathMapping.put("/", sitesFolder.iterator().next().getPath=
()+"/");
+            } else {
+                pathMapping.put("/", "/content/");
+            }
+        }
+
         zis =3D new NoCloseZipInputStream(new FileInputStream(file));
         while (true) {
             ZipEntry zipentry =3D zis.getNextEntry();
@@ -1492,9 +1514,7 @@
                     name =3D "/" + name;
                     if (!zipentry.isDirectory()) {
                         try {
-                            if (!name.startsWith("/content")) {
-                                name =3D "/content/" + site.getSiteKey() +=
 name;
-                            }
+                            name =3D pathMapping.get("/") + name.substring=
(1);
                             String filename =3D name.substring(name.lastIn=
dexOf('/') + 1);
                             String contentType =3D Jahia.getStaticServletC=
onfig().getServletContext().getMimeType(filename);
                             ensureFile(name, zis, contentType, jParams,sit=
e);
@@ -1524,7 +1544,7 @@
                     logger.error("Cannot import templates",e);
                 }
                 f.delete();
-            } else if (name.equals("site.properties")) {
+            } else if (name.equals(SITE_PROPERTIES)) {
                 Properties p =3D new Properties();
                 p.load(zis);
                 zis.closeEntry();
@@ -1590,9 +1610,9 @@
                         listManager.addSiteLanguageSettings(set);
                     }
                 }
-            } else if (name.equals("categories.xml")) {
+            } else if (name.equals(CATEGORIES_XML)) {
                 catProps =3D importCategoriesAndGetUuidProps(zis, categori=
esImportHandler);
-            } else if (name.equals("sitePermissions.xml")) {
+            } else if (name.equals(SITE_PERMISSIONS_XML)) {
                 importSitePermissions(jParams, zis);
             }
             zis.closeEntry();
@@ -1604,9 +1624,8 @@
             ZipEntry zipentry =3D zis.getNextEntry();
             if (zipentry =3D=3D null) break;
             String name =3D zipentry.getName();
-            if (name.equals("filesacl.xml")) {
+            if (name.equals(FILESACL_XML)) {
                 importFilesAcl(jParams, zis);
-            } else if (name.equals("repository.xml")) {
             } else if (name.startsWith("export")) {
                 String locale;
                 if (name.indexOf("_") !=3D -1) {
@@ -1616,9 +1635,9 @@
                 }
                 zipentry.getSize();
                 if (obj =3D=3D null) {
-                    obj =3D importDocument(parent, locale, jParams, zis, f=
alse, setUuid, result);
+                    obj =3D importDocument(parent, locale, jParams, zis, f=
alse, setUuid, result, pathMapping);
                 } else {
-                    importDocument(obj, locale, jParams, zis, true, setUui=
d, result);
+                    importDocument(obj, locale, jParams, zis, true, setUui=
d, result, pathMapping);
                 }
             }
             zis.closeEntry();
@@ -1713,15 +1732,8 @@
         }
     }
 =

-    public ContentObject importDocument(ContentObject parent, String lang,=
 ProcessingContext jParams, Reader reader, boolean updateOnly, boolean setU=
uid, ExtendedImportResult result) {
-        return importDocument(parent, lang, jParams, new InputSource(reade=
r), updateOnly, setUuid, result);
-    }
-
-    public ContentObject importDocument(ContentObject parent, String lang,=
 ProcessingContext jParams, InputStream inputStream, boolean updateOnly, bo=
olean setUuid, ExtendedImportResult result) {
-        return importDocument(parent, lang, jParams, new InputSource(input=
Stream), updateOnly, setUuid, result);
-    }
-
-    public ContentObject importDocument(ContentObject parent, String lang,=
 ProcessingContext jParams, InputSource is, boolean updateOnly, boolean set=
Uuid, ExtendedImportResult result) {
+    public ContentObject importDocument(ContentObject parent, String lang,=
 ProcessingContext jParams, InputStream inputStream, boolean updateOnly, bo=
olean setUuid, ExtendedImportResult result, Map<String,String> pathMapping)=
 {
+        InputSource is =3D new InputSource(inputStream);
         JahiaUser oldUser =3D jParams.getUser();
         try {
             SAXParserFactory factory;
@@ -1740,6 +1752,7 @@
             ImportHandler handler =3D new ImportHandler(parent, jParams, l=
ang, result);
             handler.setUpdateOnly(updateOnly);
             handler.setCopyUuid(setUuid);
+            handler.setPathMapping(pathMapping);
 =

             parser.parse(is, handler);
             return handler.getLastObject();
@@ -2034,10 +2047,6 @@
         handleImport(is,new FilesAclImportHandler(jParams));
     }
 =

-    private void importRepositoryFile(ProcessingContext jParams, File arch=
ive, List<String> fileList, InputStream is) {
-        handleImport(is,new DocumentViewImportHandler(jParams, archive, fi=
leList));
-    }
-
     private List importCategoriesAndGetUuidProps(InputStream is, Categorie=
sImportHandler importHandler) {
         handleImport(is, importHandler);
         return importHandler.getUuidProps();

Modified: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahi=
a/services/importexport/ImportExportService.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-3-=
DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/services/importexport/ImportE=
xportService.java&rev=3D19726&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/importexport/ImportExportService.java (original)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/importexport/ImportExportService.java Fri Feb 15 19:46:20 2008
@@ -109,11 +109,7 @@
 =

     ContentObject importFile(ContentObject parent, ProcessingContext jPara=
ms, File file, boolean setUuid, ExtendedImportResult result) throws IOExcep=
tion;
 =

-    ContentObject importDocument(ContentObject parent, String lang, Proces=
singContext jParams, Reader reader, boolean updateOnly, boolean setUuid, Ex=
tendedImportResult result);
-
-    ContentObject importDocument(ContentObject parent, String lang, Proces=
singContext jParams, InputStream inputStream, boolean updateOnly, boolean s=
etUuid, ExtendedImportResult result);
-
-    ContentObject importDocument(ContentObject parent, String lang, Proces=
singContext jParams, InputSource inputSource, boolean updateOnly, boolean s=
etUuid, ExtendedImportResult result);
+    ContentObject importDocument(ContentObject parent, String lang, Proces=
singContext jParams, InputStream inputStream, boolean updateOnly, boolean s=
etUuid, ExtendedImportResult result, Map<String,String> pathMapping);
 =

     void importCategories(ProcessingContext jParams, InputStream is);
 =


Modified: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahi=
a/services/importexport/ImportHandler.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-3-=
DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/services/importexport/ImportH=
andler.java&rev=3D19726&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/importexport/ImportHandler.java (original)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/importexport/ImportHandler.java Fri Feb 15 19:46:20 2008
@@ -71,6 +71,7 @@
 import org.jahia.services.version.StateModificationContext;
 import org.jahia.services.version.VersioningDifferenceStatus;
 import org.jahia.services.content.FileNode;
+import org.jahia.services.content.JCRStoreService;
 import org.jahia.services.webdav.JahiaWebdavBaseService;
 import org.jahia.services.workflow.WorkflowEvent;
 import org.jahia.services.workflow.WorkflowService;
@@ -127,6 +128,7 @@
     protected boolean copyUuid =3D false;
     protected boolean copyReadAccessOnly =3D false;
     protected int count =3D 0;
+    protected Map<String,String> pathMapping;
     private Locator locator;
 =

     public static final String JAHIA_LINK =3D "jahiaLink";
@@ -1254,8 +1256,13 @@
         }
 =

         if (fieldType =3D=3D FieldTypes.FILE) {
-            if (!value.startsWith("/content")) {
-                value =3D "/content/"+site.getSiteKey()+value;
+            if (pathMapping !=3D null) {
+                for (String map : pathMapping.keySet()) {
+                    if (value.startsWith(map)) {
+                        value =3D pathMapping.get(map) + value.substring(m=
ap.length());
+                        break;
+                    }
+                }
             }
             FileNode object =3D JahiaWebdavBaseService.getInstance().getDA=
VFileAccess(value, jParams.getUser());
             JahiaFileField fField =3D object.getJahiaFileField();
@@ -1967,6 +1974,10 @@
         this.restoreAcl =3D restoreAcl;
     }
 =

+    public void setPathMapping(Map<String, String> pathMapping) {
+        this.pathMapping =3D pathMapping;
+    }
+
     public ContentObject getLastObject() {
         return lastObject;
     }

Modified: branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahi=
a/services/importexport/ImportJob.java
URL: https://svndev.jahia.net/websvn/diff.php?path=3D/branches/JAHIA-5-0-3-=
DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/services/importexport/ImportJ=
ob.java&rev=3D19726&repname=3Djahia
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/importexport/ImportJob.java (original)
+++ branches/JAHIA-5-0-3-DMS-JACKRABBIT-BRANCH/core/src/java/org/jahia/serv=
ices/importexport/ImportJob.java Fri Feb 15 19:46:20 2008
@@ -70,7 +70,7 @@
                     imported =3D ServicesRegistry.getInstance().getImportE=
xportService().importFile(target, context, inputStream, true, result);
                 } else if ("text/xml".equals(contentType) || "application/=
xml".equals(contentType)) {
                     ServicesRegistry.getInstance().getSchedulerService().s=
tartRequest();
-                    imported =3D ServicesRegistry.getInstance().getImportE=
xportService().importDocument(target, context.getLocale().toString(), conte=
xt, inputStream, false, true, result);
+                    imported =3D ServicesRegistry.getInstance().getImportE=
xportService().importDocument(target, context.getLocale().toString(), conte=
xt, inputStream, false, true, result, null);
                 }
             } catch ( Throwable t ){
             } finally {

_______________________________________________
cvs_list mailing list
[email protected]
http://lists.jahia.org/cgi-bin/mailman/listinfo/cvs_list

Reply via email to