diff --git a/config/alfresco/attributes-service-context.xml b/config/alfresco/attributes-service-context.xml index 7b2de4e697..8cef62442e 100644 --- a/config/alfresco/attributes-service-context.xml +++ b/config/alfresco/attributes-service-context.xml @@ -13,7 +13,7 @@ - sessionSizeResourceInterceptor + avmSessionSizeResourceInterceptor diff --git a/config/alfresco/avm-services-context.xml b/config/alfresco/avm-services-context.xml index 28479264d9..64257cb32f 100644 --- a/config/alfresco/avm-services-context.xml +++ b/config/alfresco/avm-services-context.xml @@ -378,4 +378,26 @@ + + + + + + + + 500 + + + 250 + + + + + + + + + 100 + + diff --git a/config/alfresco/extension/index-recovery-context.xml.sample b/config/alfresco/extension/index-recovery-context.xml.sample index 415831e277..76de980518 100644 --- a/config/alfresco/extension/index-recovery-context.xml.sample +++ b/config/alfresco/extension/index-recovery-context.xml.sample @@ -3,12 +3,8 @@ - - - + + @@ -17,7 +13,7 @@ - + @@ -26,12 +22,8 @@ - - - 5 - - - 0 + + 0 0 21 * * ? diff --git a/config/alfresco/index-recovery-context.xml b/config/alfresco/index-recovery-context.xml index 9b8e796172..568c28242a 100644 --- a/config/alfresco/index-recovery-context.xml +++ b/config/alfresco/index-recovery-context.xml @@ -143,10 +143,16 @@ - - + + diff --git a/config/alfresco/messages/system-messages.properties b/config/alfresco/messages/system-messages.properties index 04051ea92d..e3da0b1309 100644 --- a/config/alfresco/messages/system-messages.properties +++ b/config/alfresco/messages/system-messages.properties @@ -16,4 +16,6 @@ system.config_check.warn.starting_with_errors=Alfresco is starting with errors. # OpenOffice system.openoffice.info.connection_verified=The connection to OpenOffice has been established. -system.openoffice.err.connection_failed=A connection to OpenOffice could not be established. \ No newline at end of file +system.openoffice.err.connection_failed=An initial OpenOffice connection could not be established. +system.openoffice.err.connection_lost=The OpenOffice connection has been lost. +system.openoffice.err.connection_remade=The OpenOffice connection was re-established. \ No newline at end of file diff --git a/config/alfresco/public-services-context.xml b/config/alfresco/public-services-context.xml index 5e45bdd3b8..6f375598de 100644 --- a/config/alfresco/public-services-context.xml +++ b/config/alfresco/public-services-context.xml @@ -830,7 +830,7 @@ - sessionSizeResourceInterceptor + avmSessionSizeResourceInterceptor diff --git a/config/alfresco/repository.properties b/config/alfresco/repository.properties index 7d60352d63..c05e8e94e8 100644 --- a/config/alfresco/repository.properties +++ b/config/alfresco/repository.properties @@ -56,6 +56,9 @@ system.bootstrap.config_check.strict=true # 0 prevents further logins, including the ability to enter single-user mode server.maxusers=-1 +# The Cron expression controlling the frequency with which the OpenOffice connection is tested +openOffice.test.cronExpression=0 * * * * ? + # # Properties to limit resources spent on individual searches # diff --git a/config/alfresco/scheduled-jobs-context.xml b/config/alfresco/scheduled-jobs-context.xml index ba04fe140e..0297ce19dc 100644 --- a/config/alfresco/scheduled-jobs-context.xml +++ b/config/alfresco/scheduled-jobs-context.xml @@ -133,6 +133,30 @@ + + + org.alfresco.util.OpenOfficeConnectionTester$OpenOfficeConnectionTesterJob + + + + + + + + + + + + + + + + + + ${openOffice.test.cronExpression} + + + org.alfresco.repo.search.impl.lucene.AbstractLuceneIndexerAndSearcherFactory$LuceneIndexBackupJob diff --git a/source/java/org/alfresco/repo/avm/hibernate/AVMNodeDAOHibernate.java b/source/java/org/alfresco/repo/avm/hibernate/AVMNodeDAOHibernate.java index ddb926cba7..904b6c5b53 100644 --- a/source/java/org/alfresco/repo/avm/hibernate/AVMNodeDAOHibernate.java +++ b/source/java/org/alfresco/repo/avm/hibernate/AVMNodeDAOHibernate.java @@ -245,10 +245,16 @@ class AVMNodeDAOHibernate extends HibernateDaoSupport implements */ public void clear() { - fgLogger.error(getSession().getStatistics()); + if (fgLogger.isDebugEnabled()) + { + fgLogger.debug(getSession().getStatistics()); + } getSession().flush(); getSession().clear(); - fgLogger.error(getSession().getStatistics()); + if (fgLogger.isDebugEnabled()) + { + fgLogger.debug(getSession().getStatistics()); + } } /* (non-Javadoc) diff --git a/source/java/org/alfresco/repo/content/metadata/MetadataExtracterRegistry.java b/source/java/org/alfresco/repo/content/metadata/MetadataExtracterRegistry.java index 01aadbde22..32a055397c 100644 --- a/source/java/org/alfresco/repo/content/metadata/MetadataExtracterRegistry.java +++ b/source/java/org/alfresco/repo/content/metadata/MetadataExtracterRegistry.java @@ -67,6 +67,23 @@ public class MetadataExtracterRegistry extracterCacheReadLock = extractionCacheLock.readLock(); extracterCacheWriteLock = extractionCacheLock.writeLock(); } + + /** + * Force the registry to drop its cache of extractors. This is useful for the case where an extractor + * becomes available only after the registry has initialized the cache. + */ + public void resetCache() + { + extracterCacheWriteLock.lock(); + try + { + extracterCache.clear(); + } + finally + { + extracterCacheWriteLock.unlock(); + } + } /** * Register an instance of an extracter for use diff --git a/source/java/org/alfresco/repo/node/index/MissingContentReindexComponent.java b/source/java/org/alfresco/repo/node/index/MissingContentReindexComponent.java index 653698254a..6d339e5d31 100644 --- a/source/java/org/alfresco/repo/node/index/MissingContentReindexComponent.java +++ b/source/java/org/alfresco/repo/node/index/MissingContentReindexComponent.java @@ -99,7 +99,10 @@ public class MissingContentReindexComponent extends AbstractReindexComponent // search for it in the index, sorting with youngest first sp.setLanguage(SearchService.LANGUAGE_LUCENE); - sp.setQuery("TEXT:" + AbstractLuceneIndexerImpl.NOT_INDEXED_CONTENT_MISSING); + sp.setQuery( + "TEXT:" + AbstractLuceneIndexerImpl.NOT_INDEXED_CONTENT_MISSING + + " TEXT: " + AbstractLuceneIndexerImpl.NOT_INDEXED_TRANSFORMATION_FAILED + + " TEXT: " + AbstractLuceneIndexerImpl.NOT_INDEXED_NO_TRANSFORMATION); sp.addSort(SearchParameters.SORT_IN_DOCUMENT_ORDER_DESCENDING); ResultSet results = null; try @@ -121,6 +124,7 @@ public class MissingContentReindexComponent extends AbstractReindexComponent } }; transactionService.getRetryingTransactionHelper().doInTransaction(reindexWork); + count++; // check if we have to break out if (isShuttingDown()) { diff --git a/source/java/org/alfresco/repo/security/authentication/AbstractAuthenticationComponent.java b/source/java/org/alfresco/repo/security/authentication/AbstractAuthenticationComponent.java index f96954e0a8..0df59f3be3 100644 --- a/source/java/org/alfresco/repo/security/authentication/AbstractAuthenticationComponent.java +++ b/source/java/org/alfresco/repo/security/authentication/AbstractAuthenticationComponent.java @@ -96,7 +96,7 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC { this.transactionService = transactionService; } - + public TransactionService getTransactionService() { return transactionService; @@ -141,13 +141,20 @@ public abstract class AbstractAuthenticationComponent implements AuthenticationC public Authentication execute() throws Throwable { - NodeRef userNode = personService.getPerson(userName); - if (userNode != null) + if (personService.personExists(userName)) { - // Get the person name and use that as the current user to line up with permission checks - String personName = (String) nodeService.getProperty(userNode, ContentModel.PROP_USERNAME); - return setCurrentUserImpl(personName); - + NodeRef userNode = personService.getPerson(userName); + if (userNode != null) + { + // Get the person name and use that as the current user to line up with permission checks + String personName = (String) nodeService.getProperty(userNode, ContentModel.PROP_USERNAME); + return setCurrentUserImpl(personName); + } + else + { + // Set using the user name + return setCurrentUserImpl(userName); + } } else { diff --git a/source/java/org/alfresco/util/OpenOfficeConnectionTester.java b/source/java/org/alfresco/util/OpenOfficeConnectionTester.java index 2be7c6eeec..170cdd381c 100644 --- a/source/java/org/alfresco/util/OpenOfficeConnectionTester.java +++ b/source/java/org/alfresco/util/OpenOfficeConnectionTester.java @@ -30,8 +30,14 @@ import net.sf.jooreports.openoffice.connection.OpenOfficeConnection; import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.i18n.I18NUtil; +import org.alfresco.repo.content.metadata.MetadataExtracterRegistry; +import org.alfresco.repo.content.transform.ContentTransformerRegistry; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.quartz.Job; +import org.quartz.JobDataMap; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; import org.springframework.context.ApplicationEvent; /** @@ -44,6 +50,8 @@ public class OpenOfficeConnectionTester extends AbstractLifecycleBean { private static final String INFO_CONNECTION_VERIFIED = "system.openoffice.info.connection_verified"; private static final String ERR_CONNECTION_FAILED = "system.openoffice.err.connection_failed"; + private static final String ERR_CONNECTION_LOST = "system.openoffice.err.connection_lost"; + private static final String ERR_CONNECTION_REMADE = "system.openoffice.err.connection_remade"; private static Log logger = LogFactory.getLog(OpenOfficeConnectionTester.class); @@ -104,26 +112,15 @@ public class OpenOfficeConnectionTester extends AbstractLifecycleBean */ private synchronized void checkConnection() { - PropertyCheck.mandatory(this, "connection", connection); String connectedMessage = I18NUtil.getMessage(INFO_CONNECTION_VERIFIED); - if (connection.isConnected()) + boolean connected = testAndConnect(); + OpenOfficeConnectionTesterJob.wasConnected = Boolean.valueOf(connected); + if (connected) { // the connection is fine - logger.info(connectedMessage); + logger.debug(connectedMessage); return; } - // attempt to make the connection - try - { - connection.connect(); - // that worked - logger.info(connectedMessage); - return; - } - catch (ConnectException e) - { - // no luck - } // now we have to either fail or report the connection String msg = I18NUtil.getMessage(ERR_CONNECTION_FAILED); if (strict) @@ -135,4 +132,110 @@ public class OpenOfficeConnectionTester extends AbstractLifecycleBean logger.warn(msg); } } + + public boolean testAndConnect() + { + PropertyCheck.mandatory(this, "connection", connection); + if (connection.isConnected()) + { + // the connection is fine + return true; + } + // attempt to make the connection + try + { + connection.connect(); + // that worked + return true; + } + catch (ConnectException e) + { + // No luck + return false; + } + } + + /** + * Quartz job that checks an OpenOffice connection. + * + * @author Derek Hulley + * @since 2.1.2 + */ + public static class OpenOfficeConnectionTesterJob implements Job + { + private static volatile Boolean wasConnected; + + public OpenOfficeConnectionTesterJob() + { + } + + /** + * Check the connection. + * @see OpenOfficeConnectionTester#checkConnection() + */ + public synchronized void execute(JobExecutionContext context) throws JobExecutionException + { + /* + * Synchronized just in case of overzelous triggering. + */ + + JobDataMap jobData = context.getJobDetail().getJobDataMap(); + // Get the connecion tester + Object openOfficeConnectionTesterObj = jobData.get("openOfficeConnectionTester"); + if (openOfficeConnectionTesterObj == null || !(openOfficeConnectionTesterObj instanceof OpenOfficeConnectionTester)) + { + throw new AlfrescoRuntimeException("OpenOfficeConnectionJob data must contain valid 'openOfficeConnectionTester' reference"); + } + OpenOfficeConnectionTester openOfficeConnectionTester = (OpenOfficeConnectionTester) openOfficeConnectionTesterObj; + + // Get the extractor and transformer registries. These are not mandatory. + Object metadataExractorRegistryObj = jobData.get("metadataExractorRegistry"); + MetadataExtracterRegistry metadataExtracterRegistry = null; + if (metadataExractorRegistryObj != null && (metadataExractorRegistryObj instanceof MetadataExtracterRegistry)) + { + metadataExtracterRegistry = (MetadataExtracterRegistry) metadataExractorRegistryObj; + } + Object contentTransformerRegistryObj = jobData.get("contentTransformerRegistry"); + ContentTransformerRegistry contentTransformerRegistry = null; + if (contentTransformerRegistryObj != null && (contentTransformerRegistryObj instanceof ContentTransformerRegistry)) + { + contentTransformerRegistry = (ContentTransformerRegistry) contentTransformerRegistryObj; + } + + // Now ping the connection. It doesn't matter if it fails or not. + boolean connected = openOfficeConnectionTester.testAndConnect(); + // Now log, if necessary + if (OpenOfficeConnectionTesterJob.wasConnected == null) + { + // This is the first pass + } + else if (OpenOfficeConnectionTesterJob.wasConnected.booleanValue() == connected) + { + // Nothing changed since last time + } + else + { + if (connected) + { + // This is reported as a warning as admins must be aware that it is bouncing + logger.info(I18NUtil.getMessage(ERR_CONNECTION_REMADE)); + } + else + { + logger.error(I18NUtil.getMessage(ERR_CONNECTION_LOST)); + } + // The value changed so ensure that the registries are bounced + if (metadataExtracterRegistry != null) + { + metadataExtracterRegistry.resetCache(); + } + if (contentTransformerRegistry != null) + { + contentTransformerRegistry.resetCache(); + } + } + // Record the state + OpenOfficeConnectionTesterJob.wasConnected = Boolean.valueOf(connected); + } + } }