From 6a541a840e14b010daa6b868a0070f9824443419 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Tue, 11 Mar 2008 14:01:39 +0000 Subject: [PATCH] Merged V2.2 to HEAD 8429: Merged V2.1 to V2.2 8387: Fix for WCM-1090 see ACT 1551 8421: Minor typo fix to OpenOffice document formats descriptions 8422: Fixed AR-2145: ContentStore cleaner was not watching out for VM shutdowns 8423: Removal of default root objects responsible git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8510 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../mimetype/openoffice-document-formats.xml | 2 +- .../content/cleanup/ContentStoreCleaner.java | 51 +++++++++++++++++-- .../repo/jscript/RhinoScriptProcessor.java | 5 +- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/config/alfresco/mimetype/openoffice-document-formats.xml b/config/alfresco/mimetype/openoffice-document-formats.xml index 34fcb50e6d..f708828c8b 100644 --- a/config/alfresco/mimetype/openoffice-document-formats.xml +++ b/config/alfresco/mimetype/openoffice-document-formats.xml @@ -115,7 +115,7 @@ Microsoft Excel Spreadsheet - application/application/vnd.excel + application/vnd.excel xls SpreadsheetMS Excel 97 diff --git a/source/java/org/alfresco/repo/content/cleanup/ContentStoreCleaner.java b/source/java/org/alfresco/repo/content/cleanup/ContentStoreCleaner.java index f269ba8166..dd25464925 100644 --- a/source/java/org/alfresco/repo/content/cleanup/ContentStoreCleaner.java +++ b/source/java/org/alfresco/repo/content/cleanup/ContentStoreCleaner.java @@ -45,6 +45,7 @@ import org.alfresco.service.cmr.repository.ContentData; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter; import org.alfresco.service.transaction.TransactionService; import org.alfresco.util.PropertyCheck; +import org.alfresco.util.VmShutdownListener; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -60,6 +61,9 @@ public class ContentStoreCleaner { private static Log logger = LogFactory.getLog(ContentStoreCleaner.class); + /** kept to notify the thread that it should quit */ + private static VmShutdownListener vmShutdownListener = new VmShutdownListener("ContentStoreCleaner"); + private DictionaryService dictionaryService; private NodeDaoService nodeDaoService; private AVMNodeDAO avmNodeDAO; @@ -178,6 +182,10 @@ public class ContentStoreCleaner { public void handle(Node node, Serializable value) { + if (vmShutdownListener.isVmShuttingDown()) + { + throw new VmShutdownException(); + } // Convert the values to ContentData and extract the URLs ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, value); String contentUrl = contentData.getContentUrl(); @@ -204,6 +212,10 @@ public class ContentStoreCleaner { public void handle(String contentUrl) { + if (vmShutdownListener.isVmShuttingDown()) + { + throw new VmShutdownException(); + } contentUrlDAO.deleteContentUrl(contentUrl); } }; @@ -225,6 +237,10 @@ public class ContentStoreCleaner { public void handle(String contentUrl) { + if (vmShutdownListener.isVmShuttingDown()) + { + throw new VmShutdownException(); + } contentUrlDAO.createContentUrl(contentUrl); } }; @@ -251,6 +267,10 @@ public class ContentStoreCleaner { for (ContentStore store : stores) { + if (vmShutdownListener.isVmShuttingDown()) + { + throw new VmShutdownException(); + } if (logger.isDebugEnabled()) { if (store.isWriteSupported()) @@ -280,12 +300,33 @@ public class ContentStoreCleaner return null; }; }; - transactionService.getRetryingTransactionHelper().doInTransaction(executeCallback); - - // Done - if (logger.isDebugEnabled()) + try { - logger.debug(" Content store cleanup completed."); + transactionService.getRetryingTransactionHelper().doInTransaction(executeCallback); + // Done + if (logger.isDebugEnabled()) + { + logger.debug(" Content store cleanup completed."); + } + } + catch (VmShutdownException e) + { + // Aborted + if (logger.isDebugEnabled()) + { + logger.debug(" Content store cleanup aborted."); + } } } + + /** + * Message carrier to break out of loops using the callback. + * + * @author Derek Hulley + * @since 2.1.3 + */ + private class VmShutdownException extends RuntimeException + { + private static final long serialVersionUID = -5876107469054587072L; + } } diff --git a/source/java/org/alfresco/repo/jscript/RhinoScriptProcessor.java b/source/java/org/alfresco/repo/jscript/RhinoScriptProcessor.java index a11a795841..c70daa1919 100644 --- a/source/java/org/alfresco/repo/jscript/RhinoScriptProcessor.java +++ b/source/java/org/alfresco/repo/jscript/RhinoScriptProcessor.java @@ -509,8 +509,9 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess // add the global scripts for (ProcessorExtension ex : this.processorExtensions.values()) { - model.put(ex.getExtensionName(), ex); - } + model.put(ex.getExtensionName(), ex); + } + // insert supplied object model into root of the default scope for (String key : model.keySet())