mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
77084: Merged PLATFORM1 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud) 72906: ACE-956 - Configure Hybrid Sync - step 1 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@77933 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -147,6 +147,7 @@
|
|||||||
<property name="nodeService" ref="nodeService"/>
|
<property name="nodeService" ref="nodeService"/>
|
||||||
<property name="messageService" ref="messageService"/>
|
<property name="messageService" ref="messageService"/>
|
||||||
<property name="tenantAdminService" ref="tenantAdminService"/>
|
<property name="tenantAdminService" ref="tenantAdminService"/>
|
||||||
|
<property name="policyComponent" ref="policyComponent"/>
|
||||||
|
|
||||||
<property name="repositoryModelsLocations">
|
<property name="repositoryModelsLocations">
|
||||||
<list>
|
<list>
|
||||||
|
@@ -251,6 +251,10 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
*/
|
*/
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
|
if(logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("init : bind class behaviours for " + ContentModel.TYPE_DICTIONARY_MODEL);
|
||||||
|
}
|
||||||
// Register interest in the onContentUpdate policy for the dictionary model type
|
// Register interest in the onContentUpdate policy for the dictionary model type
|
||||||
policyComponent.bindClassBehaviour(
|
policyComponent.bindClassBehaviour(
|
||||||
ContentServicePolicies.OnContentUpdatePolicy.QNAME,
|
ContentServicePolicies.OnContentUpdatePolicy.QNAME,
|
||||||
@@ -303,8 +307,12 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
logger.trace("onContentUpdate: nodeRef="+nodeRef+ " ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
logger.trace("onContentUpdate: nodeRef="+nodeRef+ " ["+AlfrescoTransactionSupport.getTransactionId()+"]");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Boolean value = (Boolean)nodeService.getProperty(nodeRef, ContentModel.PROP_MODEL_ACTIVE);
|
||||||
|
if ((value != null) && (value == true))
|
||||||
|
{
|
||||||
queueModel(nodeRef);
|
queueModel(nodeRef);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void queueModel(NodeRef nodeRef)
|
private void queueModel(NodeRef nodeRef)
|
||||||
@@ -679,6 +687,7 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
|
|||||||
props.put(ContentModel.PROP_MODEL_AUTHOR, modelDefinition.getAuthor());
|
props.put(ContentModel.PROP_MODEL_AUTHOR, modelDefinition.getAuthor());
|
||||||
props.put(ContentModel.PROP_MODEL_PUBLISHED_DATE, modelDefinition.getPublishedDate());
|
props.put(ContentModel.PROP_MODEL_PUBLISHED_DATE, modelDefinition.getPublishedDate());
|
||||||
props.put(ContentModel.PROP_MODEL_VERSION, modelDefinition.getVersion());
|
props.put(ContentModel.PROP_MODEL_VERSION, modelDefinition.getVersion());
|
||||||
|
|
||||||
nodeService.setProperties(nodeRef, props);
|
nodeService.setProperties(nodeRef, props);
|
||||||
|
|
||||||
// Validate model against dictionary - could be new, unchanged or updated
|
// Validate model against dictionary - could be new, unchanged or updated
|
||||||
|
@@ -33,6 +33,8 @@ import org.alfresco.model.ContentModel;
|
|||||||
import org.alfresco.repo.content.EmptyContentReader;
|
import org.alfresco.repo.content.EmptyContentReader;
|
||||||
import org.alfresco.repo.i18n.MessageDeployer;
|
import org.alfresco.repo.i18n.MessageDeployer;
|
||||||
import org.alfresco.repo.i18n.MessageService;
|
import org.alfresco.repo.i18n.MessageService;
|
||||||
|
import org.alfresco.repo.policy.ClassPolicyDelegate;
|
||||||
|
import org.alfresco.repo.policy.PolicyComponent;
|
||||||
import org.alfresco.repo.tenant.TenantAdminService;
|
import org.alfresco.repo.tenant.TenantAdminService;
|
||||||
import org.alfresco.repo.tenant.TenantDeployer;
|
import org.alfresco.repo.tenant.TenantDeployer;
|
||||||
import org.alfresco.repo.tenant.TenantService;
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
@@ -51,11 +53,13 @@ import org.alfresco.service.namespace.QName;
|
|||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
|
import org.alfresco.util.PropertyCheck;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.ApplicationEvent;
|
import org.springframework.context.ApplicationEvent;
|
||||||
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
||||||
|
import org.alfresco.repo.dictionary.DynamicModelPolicies.OnLoadDynamicModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bootstrap the dictionary from specified locations within the repository
|
* Bootstrap the dictionary from specified locations within the repository
|
||||||
@@ -94,6 +98,10 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
|
|||||||
/** The transaction service */
|
/** The transaction service */
|
||||||
private TransactionService transactionService;
|
private TransactionService transactionService;
|
||||||
|
|
||||||
|
/** The policy component */
|
||||||
|
private PolicyComponent policyComponent;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the Dictionary DAO
|
* Sets the Dictionary DAO
|
||||||
*
|
*
|
||||||
@@ -186,12 +194,27 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
|
|||||||
this.repositoryMessagesLocations = repositoryLocations;
|
this.repositoryMessagesLocations = repositoryLocations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ClassPolicyDelegate<OnLoadDynamicModel> onLoadDynamicModelDelegate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialise - after bootstrap of schema and tenant admin service
|
* Initialise - after bootstrap of schema and tenant admin service
|
||||||
*/
|
*/
|
||||||
public void init()
|
public void init()
|
||||||
{
|
{
|
||||||
|
PropertyCheck.mandatory(this, "dictionaryDAO", dictionaryDAO);
|
||||||
|
PropertyCheck.mandatory(this, "contentService", contentService);
|
||||||
|
PropertyCheck.mandatory(this, "nodeService", nodeService);
|
||||||
|
PropertyCheck.mandatory(this, "tenantAdminService", tenantAdminService);
|
||||||
|
PropertyCheck.mandatory(this, "namespaceService", namespaceService);
|
||||||
|
PropertyCheck.mandatory(this, "messageService", messageService);
|
||||||
|
PropertyCheck.mandatory(this, "transactionService", transactionService);
|
||||||
|
PropertyCheck.mandatory(this, "policyComponent", policyComponent);
|
||||||
|
|
||||||
|
if(onLoadDynamicModelDelegate == null)
|
||||||
|
{
|
||||||
|
onLoadDynamicModelDelegate = policyComponent.registerClassPolicy(DynamicModelPolicies.OnLoadDynamicModel.class);
|
||||||
|
}
|
||||||
|
|
||||||
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
|
transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>()
|
||||||
{
|
{
|
||||||
public Object execute() throws Exception
|
public Object execute() throws Exception
|
||||||
@@ -215,6 +238,10 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
|
|||||||
@Override
|
@Override
|
||||||
public void onDictionaryInit()
|
public void onDictionaryInit()
|
||||||
{
|
{
|
||||||
|
if(onLoadDynamicModelDelegate == null)
|
||||||
|
{
|
||||||
|
onLoadDynamicModelDelegate = policyComponent.registerClassPolicy(DynamicModelPolicies.OnLoadDynamicModel.class);
|
||||||
|
}
|
||||||
RetryingTransactionCallback<Void> initCallback = new RetryingTransactionCallback<Void>()
|
RetryingTransactionCallback<Void> initCallback = new RetryingTransactionCallback<Void>()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@@ -252,7 +279,8 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
|
|||||||
|
|
||||||
if (this.repositoryModelsLocations != null)
|
if (this.repositoryModelsLocations != null)
|
||||||
{
|
{
|
||||||
Map<String, Pair<RepositoryLocation, M2Model>> modelMap = new HashMap<String, Pair<RepositoryLocation, M2Model>>();
|
// URI to model map
|
||||||
|
Map<String, DynamicModelInfo> modelMap = new HashMap<String, DynamicModelInfo>();
|
||||||
|
|
||||||
if (logger.isTraceEnabled())
|
if (logger.isTraceEnabled())
|
||||||
{
|
{
|
||||||
@@ -300,7 +328,7 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
|
|||||||
|
|
||||||
for (M2Namespace namespace : model.getNamespaces())
|
for (M2Namespace namespace : model.getNamespaces())
|
||||||
{
|
{
|
||||||
modelMap.put(namespace.getUri(), new Pair<RepositoryLocation, M2Model>(repositoryLocation, model));
|
modelMap.put(namespace.getUri(), new DynamicModelInfo(repositoryLocation, model, dictionaryModel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -326,12 +354,12 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load the models ensuring that they are loaded in the correct order
|
// Load the models ensuring that they are loaded in the correct order
|
||||||
for (Map.Entry<String, Pair<RepositoryLocation, M2Model>> entry : modelMap.entrySet())
|
for (Map.Entry<String, DynamicModelInfo> entry : modelMap.entrySet())
|
||||||
{
|
{
|
||||||
RepositoryLocation importedLocation = entry.getValue().getFirst();
|
RepositoryLocation importedLocation = entry.getValue().location;
|
||||||
M2Model importedModel = entry.getValue().getSecond();
|
M2Model importedModel = entry.getValue().model;
|
||||||
|
|
||||||
loadModel(modelMap, loadedModels, importedModel, importedLocation);
|
loadModel(modelMap, loadedModels, importedModel, importedLocation);
|
||||||
|
notifyDynamicModelLoaded(entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -345,6 +373,17 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void notifyDynamicModelLoaded(DynamicModelInfo entry)
|
||||||
|
{
|
||||||
|
if(onLoadDynamicModelDelegate == null)
|
||||||
|
{
|
||||||
|
onLoadDynamicModelDelegate = policyComponent.registerClassPolicy(DynamicModelPolicies.OnLoadDynamicModel.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicModelPolicies.OnLoadDynamicModel policy = onLoadDynamicModelDelegate.get(ContentModel.TYPE_CONTENT);
|
||||||
|
policy.onLoadDynamicModel(entry.model, entry.nodeRef);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
* @see org.alfresco.repo.dictionary.DictionaryListener#afterInit()
|
* @see org.alfresco.repo.dictionary.DictionaryListener#afterInit()
|
||||||
@@ -490,6 +529,21 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
|
|||||||
return nodeRefs;
|
return nodeRefs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class DynamicModelInfo
|
||||||
|
{
|
||||||
|
RepositoryLocation location;
|
||||||
|
M2Model model;
|
||||||
|
NodeRef nodeRef;
|
||||||
|
|
||||||
|
|
||||||
|
DynamicModelInfo(RepositoryLocation location, M2Model model, NodeRef nodeRef)
|
||||||
|
{
|
||||||
|
this.location = location;
|
||||||
|
this.model = model;
|
||||||
|
this.nodeRef = nodeRef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a model (and its dependents) if it does not exist in the list of loaded models.
|
* Loads a model (and its dependents) if it does not exist in the list of loaded models.
|
||||||
*
|
*
|
||||||
@@ -497,18 +551,18 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
|
|||||||
* @param loadedModels the list of models already loaded
|
* @param loadedModels the list of models already loaded
|
||||||
* @param model the model to try and load
|
* @param model the model to try and load
|
||||||
*/
|
*/
|
||||||
private void loadModel(Map<String, Pair<RepositoryLocation, M2Model>> modelMap, List<String> loadedModels, M2Model model, RepositoryLocation modelLocation)
|
private void loadModel(Map<String, DynamicModelInfo> modelMap, List<String> loadedModels, M2Model model, RepositoryLocation modelLocation)
|
||||||
{
|
{
|
||||||
String modelName = model.getName();
|
String modelName = model.getName();
|
||||||
if (loadedModels.contains(modelName) == false)
|
if (loadedModels.contains(modelName) == false)
|
||||||
{
|
{
|
||||||
for (M2Namespace importNamespace : model.getImports())
|
for (M2Namespace importNamespace : model.getImports())
|
||||||
{
|
{
|
||||||
Pair<RepositoryLocation, M2Model> entry = modelMap.get(importNamespace.getUri());
|
DynamicModelInfo entry = modelMap.get(importNamespace.getUri());
|
||||||
if (entry != null)
|
if (entry != null)
|
||||||
{
|
{
|
||||||
RepositoryLocation importedLocation = entry.getFirst();
|
RepositoryLocation importedLocation = entry.location;
|
||||||
M2Model importedModel = entry.getSecond();
|
M2Model importedModel = entry.model;
|
||||||
|
|
||||||
// Ensure that the imported model is loaded first
|
// Ensure that the imported model is loaded first
|
||||||
loadModel(modelMap, loadedModels, importedModel, importedLocation);
|
loadModel(modelMap, loadedModels, importedModel, importedLocation);
|
||||||
@@ -688,4 +742,13 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
|
|||||||
}
|
}
|
||||||
return parentNodeRef;
|
return parentNodeRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PolicyComponent getPolicyComponent() {
|
||||||
|
return policyComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPolicyComponent(PolicyComponent policyComponent) {
|
||||||
|
this.policyComponent = policyComponent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,25 @@
|
|||||||
|
package org.alfresco.repo.dictionary;
|
||||||
|
|
||||||
|
import org.alfresco.repo.policy.ClassPolicy;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
|
||||||
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
|
public class DynamicModelPolicies
|
||||||
|
{
|
||||||
|
|
||||||
|
public interface OnLoadDynamicModel extends ClassPolicy
|
||||||
|
{
|
||||||
|
public static final QName QNAME = QName.createQName(NamespaceService.ALFRESCO_URI, "onLoadDynamicModel");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after a new dynamic model has been loaded.
|
||||||
|
*
|
||||||
|
* @param model the model loaded
|
||||||
|
* @param nodeRef the node ref of the model
|
||||||
|
*/
|
||||||
|
public void onLoadDynamicModel(M2Model model, NodeRef nodeRef);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user