Fixes for dynamic model management: fix delete model validation (in MT case) & fix model restore from archive

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6984 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2007-10-12 16:48:59 +00:00
parent 5d0a520f25
commit 714c7a2b14
7 changed files with 157 additions and 30 deletions

View File

@@ -704,23 +704,54 @@ public class DictionaryDAOImpl implements DictionaryDAO
*/
public Collection<QName> getModels()
{
// get all models - including inherited models, if applicable
return getCompiledModels().keySet();
}
// return all tenant-specific models and all shared (non-overridden) models
// MT-specific
public boolean isModelInherited(QName modelName)
{
String tenantDomain = tenantService.getCurrentUserDomain();
if (tenantDomain != "")
{
// get tenant-specific model (if any)
CompiledModel model = getCompiledModels(tenantDomain).get(modelName);
if (model != null)
{
return false;
}
// else drop down to check for shared (core/system) models ...
}
// get non-tenant model (if any)
CompiledModel model = getCompiledModels("").get(modelName);
if (model == null)
{
throw new DictionaryException("d_dictionary.model.err.no_model", modelName);
}
if (tenantDomain != "")
{
return true;
}
else
{
return false;
}
}
private Map<QName,CompiledModel> getCompiledModels()
{
String tenantDomain = tenantService.getCurrentUserDomain();
if (tenantDomain != "")
{
// return all tenant-specific models and all shared (non-overridden) models
// return all tenant-specific models and all inherited (non-overridden) models
Map<QName, CompiledModel> filteredModels = new HashMap<QName, CompiledModel>();
// get tenant models (if any)
Map<QName,CompiledModel> tenantModels = getCompiledModels(tenantDomain);
// get non-tenant models (if any)
// note: these will be shared, if not overridden - could be core/system model or additional custom model shared between tenants
// get non-tenant models - these will include core/system models and any additional custom models (which are implicitly available to all tenants)
Map<QName,CompiledModel> nontenantModels = getCompiledModels("");
// check for overrides
@@ -744,15 +775,10 @@ public class DictionaryDAOImpl implements DictionaryDAO
}
else
{
// return all (non-tenant) models
return getCompiledModels("");
}
}
// used for clean-up, e.g. when deleting a tenant
protected Collection<QName> getNonSharedModels()
{
return getCompiledModels(tenantService.getCurrentUserDomain()).keySet();
}
/* (non-Javadoc)
* @see org.alfresco.repo.dictionary.impl.DictionaryDAO#getModel(org.alfresco.repo.ref.QName)