AVM DAO refactor

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16138 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2009-09-08 09:55:22 +00:00
parent bae58d6ee7
commit c2cca0311b
113 changed files with 9654 additions and 3923 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2008 Alfresco Software Limited.
* Copyright (C) 2005-2009 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -38,6 +38,7 @@ import org.alfresco.service.cmr.avm.AVMService;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.remote.AVMRemote;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
/**
* This takes a filesystem directory path and a repository path and name
@@ -88,6 +89,12 @@ public class BulkLoader
* @param repPath
*/
public void recursiveLoad(String fsPath, String repPath)
{
Pair<Integer, Integer> cnts = recursiveLoadImpl(fsPath, repPath, 0, 0);
System.out.println("Loaded: "+cnts.getFirst()+" directories, "+cnts.getSecond()+" files");
}
private Pair<Integer, Integer> recursiveLoadImpl(String fsPath, String repPath, int dirCount, int fileCount)
{
Map<QName, PropertyValue> props = new HashMap<QName, PropertyValue>();
for (int i = 0; i < fPropertyCount; i++)
@@ -99,13 +106,19 @@ public class BulkLoader
if (file.isDirectory())
{
fService.createDirectory(repPath, name);
dirCount++;
String[] children = file.list();
String baseName = repPath.endsWith("/") ? repPath + name : repPath + "/" + name;
fService.setNodeProperties(baseName, props);
for (String child : children)
{
recursiveLoad(fsPath + "/" + child, baseName);
Pair<Integer, Integer> cnts = recursiveLoadImpl(fsPath + "/" + child, baseName, dirCount, fileCount);
dirCount = cnts.getFirst();
fileCount = cnts.getSecond();
}
return new Pair<Integer, Integer>(dirCount, fileCount);
}
else
{
@@ -113,6 +126,7 @@ public class BulkLoader
{
InputStream in = new FileInputStream(file);
OutputStream out = fService.createFile(repPath, name);
fileCount++;
fService.setNodeProperties(repPath + "/" + name, props);
byte[] buff = new byte[8192];
int read = 0;
@@ -122,6 +136,8 @@ public class BulkLoader
}
out.close();
in.close();
return new Pair<Integer, Integer>(dirCount, fileCount);
}
catch (IOException e)
{
@@ -130,4 +146,4 @@ public class BulkLoader
}
}
}
}
}