mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Provision of simple import statistics - e.g. duration of import, count of nodes/props/etc imported.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2188 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -502,6 +502,36 @@ public class ImporterBootstrap
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Added aspect " + aspect + " to node " + nodeRef);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.ImporterProgress#started()
|
||||
*/
|
||||
public void started()
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Started");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.ImporterProgress#completed()
|
||||
*/
|
||||
public void completed()
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Completed");
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.ImporterProgress#error(java.lang.Exception)
|
||||
*/
|
||||
public void error(Throwable e)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Error: " + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -315,9 +315,10 @@ public class ImporterComponent
|
||||
viewParser.parse(viewReader, nodeImporter);
|
||||
nodeImporter.end();
|
||||
}
|
||||
finally
|
||||
catch(RuntimeException e)
|
||||
{
|
||||
nodeImporter.error(null);
|
||||
nodeImporter.error(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,6 +458,7 @@ public class ImporterComponent
|
||||
*/
|
||||
public void start()
|
||||
{
|
||||
reportStarted();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -695,6 +697,8 @@ public class ImporterComponent
|
||||
behaviourFilter.enableBehaviours(importedRef.context.getNodeRef());
|
||||
}
|
||||
}
|
||||
|
||||
reportCompleted();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -704,6 +708,7 @@ public class ImporterComponent
|
||||
public void error(Throwable e)
|
||||
{
|
||||
behaviourFilter.enableAllBehaviours();
|
||||
reportError(e);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -922,6 +927,41 @@ public class ImporterComponent
|
||||
return objValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to report start of import
|
||||
*/
|
||||
private void reportStarted()
|
||||
{
|
||||
if (progress != null)
|
||||
{
|
||||
progress.started();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to report end of import
|
||||
*/
|
||||
private void reportCompleted()
|
||||
{
|
||||
if (progress != null)
|
||||
{
|
||||
progress.completed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to report error
|
||||
*
|
||||
* @param e
|
||||
*/
|
||||
private void reportError(Throwable e)
|
||||
{
|
||||
if (progress != null)
|
||||
{
|
||||
progress.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to report node created progress
|
||||
*
|
||||
|
@@ -71,9 +71,8 @@ public class ImporterComponentTest extends BaseSpringTest
|
||||
{
|
||||
InputStream test = getClass().getClassLoader().getResourceAsStream("org/alfresco/repo/importer/importercomponent_test.xml");
|
||||
InputStreamReader testReader = new InputStreamReader(test, "UTF-8");
|
||||
TestProgress testProgress = new TestProgress();
|
||||
Location location = new Location(storeRef);
|
||||
importerService.importView(testReader, location, null, testProgress);
|
||||
importerService.importView(testReader, location, null, new ImportTimerProgress());
|
||||
System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, storeRef));
|
||||
}
|
||||
|
||||
@@ -85,45 +84,7 @@ public class ImporterComponentTest extends BaseSpringTest
|
||||
importerBootstrap.bootstrap();
|
||||
authenticationComponent.setSystemUserAsCurrentUser();
|
||||
System.out.println(NodeStoreInspector.dumpNodeStore(nodeService, bootstrapStoreRef));
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static class TestProgress implements ImporterProgress
|
||||
{
|
||||
public void nodeCreated(NodeRef nodeRef, NodeRef parentRef, QName assocName, QName childName)
|
||||
{
|
||||
System.out.println("TestProgress: created node " + nodeRef + " within parent " + parentRef + " named " + childName +
|
||||
" (association " + assocName + ")");
|
||||
}
|
||||
|
||||
public void nodeLinked(NodeRef nodeRef, NodeRef parentRef, QName assocName, QName childName)
|
||||
{
|
||||
System.out.println("TestProgress: linked node " + nodeRef + " within parent " + parentRef + " named " + childName +
|
||||
" (association " + assocName + ")");
|
||||
}
|
||||
|
||||
public void contentCreated(NodeRef nodeRef, String sourceUrl)
|
||||
{
|
||||
System.out.println("TestProgress: created content " + nodeRef + " from url " + sourceUrl);
|
||||
}
|
||||
|
||||
public void propertySet(NodeRef nodeRef, QName property, Serializable value)
|
||||
{
|
||||
System.out.println("TestProgress: set property " + property + " on node " + nodeRef + " to value " + value);
|
||||
}
|
||||
|
||||
public void aspectAdded(NodeRef nodeRef, QName aspect)
|
||||
{
|
||||
System.out.println("TestProgress: added aspect " + aspect + " to node ");
|
||||
}
|
||||
|
||||
public void permissionSet(NodeRef nodeRef, AccessPermission permission)
|
||||
{
|
||||
System.out.println("TestProgress: added permission " + permission.getPermission() + " to node ");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -31,6 +31,12 @@ import org.alfresco.service.namespace.QName;
|
||||
*/
|
||||
public interface ImporterProgress
|
||||
{
|
||||
public void started();
|
||||
|
||||
public void completed();
|
||||
|
||||
public void error(Throwable e);
|
||||
|
||||
/**
|
||||
* Report creation of a node.
|
||||
*
|
||||
|
Reference in New Issue
Block a user