mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fix for sample user bootstrap extension (6000 user example for Novell) which failed in enterprise build. Change order of bootstrap so that user store is created first. Also added log flag to importerBootstrap allow debug output for bootstrap without first unpacking war file to adjust log4j properties.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2371 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -23,6 +23,8 @@ import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.security.AccessPermission;
|
||||
import org.alfresco.service.cmr.view.ImporterProgress;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
||||
/**
|
||||
@@ -40,6 +42,25 @@ public class ImportTimerProgress implements ImporterProgress
|
||||
private long aspectAdded = 0;
|
||||
private long permissionCount = 0;
|
||||
|
||||
private Log logger = LogFactory.getLog(ImportTimerProgress.class);;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*/
|
||||
public ImportTimerProgress()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param logger
|
||||
*/
|
||||
public ImportTimerProgress(Log logger)
|
||||
{
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.service.cmr.view.ImporterProgress#started()
|
||||
@@ -53,7 +74,9 @@ public class ImportTimerProgress implements ImporterProgress
|
||||
nodeLinkedCount = 0;
|
||||
aspectAdded = 0;
|
||||
permissionCount = 0;
|
||||
System.out.println("Import started at " + start + " (" + start.getTime() + ")");
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Import started at " + start + " (" + start.getTime() + ")");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -62,9 +85,12 @@ public class ImportTimerProgress implements ImporterProgress
|
||||
*/
|
||||
public void completed()
|
||||
{
|
||||
Date end = new Date();
|
||||
System.out.println("Import completed at " + end + " (" + end.getTime() + ")");
|
||||
dumpStats(end);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
Date end = new Date();
|
||||
logger.debug("Import completed at " + end + " (" + end.getTime() + ")");
|
||||
dumpStats(end);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -73,10 +99,14 @@ public class ImportTimerProgress implements ImporterProgress
|
||||
*/
|
||||
public void error(Throwable e)
|
||||
{
|
||||
Date end = new Date();
|
||||
System.out.println("Error occured at " + end + " (" + end.getTime() + ")");
|
||||
System.out.println("Exception: " + e.toString());
|
||||
dumpStats(end);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
Date end = new Date();
|
||||
logger.debug("Import completed at " + end + " (" + end.getTime() + ")");
|
||||
logger.debug("Error occured at " + end + " (" + end.getTime() + ")");
|
||||
logger.debug("Exception: " + e.toString());
|
||||
dumpStats(end);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -140,13 +170,16 @@ public class ImportTimerProgress implements ImporterProgress
|
||||
*/
|
||||
private void dumpStats(Date end)
|
||||
{
|
||||
System.out.println("Import duration: " + (end.getTime() - start.getTime()) + " ms (Note: excluding commit time)");
|
||||
System.out.println(" Nodes created: " + nodeCreateCount);
|
||||
System.out.println(" Nodes linked: " + nodeLinkedCount);
|
||||
System.out.println(" Aspects Added: " + aspectAdded);
|
||||
System.out.println(" Properties set: " + propCount);
|
||||
System.out.println(" Content set: " + contentCount);
|
||||
System.out.println(" Permissions set: " + permissionCount);
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Import duration: " + (end.getTime() - start.getTime()) + " ms (Note: excluding commit time)");
|
||||
logger.debug(" Nodes created: " + nodeCreateCount);
|
||||
logger.debug(" Nodes linked: " + nodeLinkedCount);
|
||||
logger.debug(" Aspects Added: " + aspectAdded);
|
||||
logger.debug(" Properties set: " + propCount);
|
||||
logger.debug(" Content set: " + contentCount);
|
||||
logger.debug(" Permissions set: " + permissionCount);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -44,6 +44,9 @@ import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.commons.logging.impl.Log4JLogger;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
/**
|
||||
@@ -62,6 +65,7 @@ public class ImporterBootstrap
|
||||
|
||||
// Logger
|
||||
private static final Log logger = LogFactory.getLog(ImporterBootstrap.class);
|
||||
private boolean logEnabled = false;
|
||||
|
||||
// Dependencies
|
||||
private boolean allowWrite = true;
|
||||
@@ -234,6 +238,16 @@ public class ImporterBootstrap
|
||||
return strLocale;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set log
|
||||
*
|
||||
* @param logEnabled
|
||||
*/
|
||||
public void setLog(boolean logEnabled)
|
||||
{
|
||||
this.logEnabled = logEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Boostrap the Repository
|
||||
*/
|
||||
@@ -259,6 +273,14 @@ public class ImporterBootstrap
|
||||
{
|
||||
throw new ImporterException("Store URL must be provided");
|
||||
}
|
||||
|
||||
// initialise log level
|
||||
// note: only supported with Log4J
|
||||
if (logEnabled && logger instanceof Log4JLogger)
|
||||
{
|
||||
Logger log4JLogger = ((Log4JLogger)logger).getLogger();
|
||||
log4JLogger.setLevel(Level.DEBUG);
|
||||
}
|
||||
|
||||
UserTransaction userTransaction = transactionService.getUserTransaction();
|
||||
authenticationComponent.setCurrentUser(authenticationComponent.getSystemUserName());
|
||||
@@ -339,7 +361,7 @@ public class ImporterBootstrap
|
||||
ImporterProgress importProgress = null;
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
importProgress = new ImportTimerProgress();
|
||||
importProgress = new ImportTimerProgress(logger);
|
||||
logger.debug("Importing " + view);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user