mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V3.0 to HEAD
12185: Fix 3.0 SP1 installation on non-Oracle databases. Removed creation of indexes in AlfrescoPostCreate-2.2-MappedFKIndexes.sql that were also in AlfrescoPostCreate-2.2-Extra.sql 12186: Performance improvements to HibernateNodeDaoServiceImpl 12188: Multi user tests: enable graceful web script recovery on optimistic locking failure (...) 12191: Improve Javascript execution performance in Web Scripts & Improve error presentation (...) thrown by JavaScript 12192: Share performance improvements: stop AbstractFeedGenerator from 'choking' the repository with too many web script requests 12193: Multi user testing: don't suppress all exceptions during Wiki Move. 12194: Multi user testing. Don't suppress all runtime exceptions in script site node object. 12195: Multi user testing. Convert User bean object to use a retrying transaction so that optimistic locking failures are handled. 12196: Multi user testing: Configuration changes to support concurrent access by 20 users git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12522 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -57,6 +57,8 @@ import org.mozilla.javascript.ImporterTopLevel;
|
||||
import org.mozilla.javascript.Scriptable;
|
||||
import org.mozilla.javascript.ScriptableObject;
|
||||
import org.mozilla.javascript.WrapFactory;
|
||||
import org.mozilla.javascript.WrappedException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
/**
|
||||
@@ -64,7 +66,7 @@ import org.springframework.util.FileCopyUtils;
|
||||
*
|
||||
* @author Kevin Roast
|
||||
*/
|
||||
public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcessor, ScriptResourceLoader
|
||||
public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcessor, ScriptResourceLoader, InitializingBean
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(RhinoScriptProcessor.class);
|
||||
|
||||
@@ -82,6 +84,12 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess
|
||||
/** Store root path to resolve cm:name based scripts path from */
|
||||
private String storePath;
|
||||
|
||||
/** Pre initialized secure scope object. */
|
||||
private Scriptable secureScope;
|
||||
|
||||
/** Pre initialized non secure scope object. */
|
||||
private Scriptable nonSecureScope;
|
||||
|
||||
/**
|
||||
* Set the default store reference
|
||||
*
|
||||
@@ -340,27 +348,12 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess
|
||||
Context cx = Context.enter();
|
||||
try
|
||||
{
|
||||
// The easiest way to embed Rhino is just to create a new scope this way whenever
|
||||
// you need one. However, initStandardObjects is an expensive method to call and it
|
||||
// allocates a fair amount of memory.
|
||||
// Create a thread-specific scope from one of the shared scopes. See http://www.mozilla.org/rhino/scopes.html
|
||||
cx.setWrapFactory(wrapFactory);
|
||||
Scriptable scope;
|
||||
if (!secure)
|
||||
{
|
||||
scope = cx.initStandardObjects();
|
||||
// remove security issue related objects - this ensures the script may not access
|
||||
// unsecure java.* libraries or import any other classes for direct access - only
|
||||
// the configured root host objects will be available to the script writer
|
||||
scope.delete("Packages");
|
||||
scope.delete("getClass");
|
||||
scope.delete("java");
|
||||
}
|
||||
else
|
||||
{
|
||||
// allow access to all libraries and objects, including the importer
|
||||
// @see http://www.mozilla.org/rhino/ScriptingJava.html
|
||||
scope = new ImporterTopLevel(cx);
|
||||
}
|
||||
Scriptable sharedScope = secure ? this.nonSecureScope : this.secureScope;
|
||||
Scriptable scope = cx.newObject(sharedScope);
|
||||
scope.setPrototype(sharedScope);
|
||||
scope.setParentScope(null);
|
||||
|
||||
// there's always a model, if only to hold the util objects
|
||||
if (model == null)
|
||||
@@ -398,6 +391,15 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess
|
||||
// extract java object result if wrapped by Rhino
|
||||
return valueConverter.convertValueForRepo((Serializable)result);
|
||||
}
|
||||
catch (WrappedException w)
|
||||
{
|
||||
Throwable err = w.getWrappedException();
|
||||
if (err instanceof RuntimeException)
|
||||
{
|
||||
throw (RuntimeException) err;
|
||||
}
|
||||
throw new AlfrescoRuntimeException(err.getMessage(), err);
|
||||
}
|
||||
catch (Throwable err)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(err.getMessage(), err);
|
||||
@@ -464,4 +466,50 @@ public class RhinoScriptProcessor extends BaseProcessor implements ScriptProcess
|
||||
return super.wrapAsJavaObject(cx, scope, javaObject, staticType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pre initializes two scope objects (one secure and one not) with the standard objects preinitialised. This saves
|
||||
* on very expensive calls to reinitialize a new scope on every web script execution. See
|
||||
* http://www.mozilla.org/rhino/scopes.html
|
||||
*
|
||||
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
|
||||
*/
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
// Initialise the secure scope
|
||||
Context cx = Context.enter();
|
||||
try
|
||||
{
|
||||
cx.setWrapFactory(wrapFactory);
|
||||
this.secureScope = cx.initStandardObjects();
|
||||
|
||||
// remove security issue related objects - this ensures the script may not access
|
||||
// unsecure java.* libraries or import any other classes for direct access - only
|
||||
// the configured root host objects will be available to the script writer
|
||||
this.secureScope.delete("Packages");
|
||||
this.secureScope.delete("getClass");
|
||||
this.secureScope.delete("java");
|
||||
}
|
||||
finally
|
||||
{
|
||||
Context.exit();
|
||||
}
|
||||
|
||||
// Initialise the non-secure scope
|
||||
cx = Context.enter();
|
||||
try
|
||||
{
|
||||
cx.setWrapFactory(wrapFactory);
|
||||
|
||||
// allow access to all libraries and objects, including the importer
|
||||
// @see http://www.mozilla.org/rhino/ScriptingJava.html
|
||||
this.nonSecureScope = new ImporterTopLevel(cx);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
Context.exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -55,7 +55,6 @@ import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.lock.LockStatus;
|
||||
import org.alfresco.service.cmr.model.FileExistsException;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.model.FileNotFoundException;
|
||||
import org.alfresco.service.cmr.repository.AssociationRef;
|
||||
@@ -348,10 +347,6 @@ public class ScriptNode implements Serializable, Scopeable
|
||||
{
|
||||
this.services.getFileFolderService().rename(this.nodeRef, name);
|
||||
}
|
||||
catch (FileExistsException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to rename node " + nodeRef + " to " + name, e);
|
||||
}
|
||||
catch (FileNotFoundException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Failed to rename node " + nodeRef + " to " + name, e);
|
||||
|
Reference in New Issue
Block a user