Dynamic Models - fix AR-1953

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8015 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2008-01-18 12:25:24 +00:00
parent b4b6f0181c
commit 087b2a1b2a
10 changed files with 135 additions and 32 deletions

View File

@@ -148,6 +148,10 @@
</property>
</bean>
<bean id="spacesModelsBootstrap" parent="storeImporter">
<!-- NOOP for fresh bootstrap (will skip store creation) - provides ordering when performing a repo restore (bootstrap import) -->
</bean>
<bean id="spacesBootstrap" parent="spacesStoreImporter">
<property name="bootstrapViews">
<list>

View File

@@ -56,12 +56,26 @@
</property>
</bean>
<bean id="spacesModelsBootstrap" parent="spacesStoreImporter">
<property name="bootstrapViews">
<list>
<props>
<prop key="path"></prop>
<prop key="location">alfresco/extension/restore/export_models.acp</prop>
</props>
</list>
</property>
<property name="log"><value>true</value></property>
</bean>
<bean id="spacesBootstrap" parent="spacesStoreImporter">
<property name="useExistingStore"><value>true</value></property>
<property name="bootstrapViews">
<list>
<props>
<prop key="path">/</prop>
<prop key="location">alfresco/extension/restore/export_spaces.acp</prop>
<prop key="uuidBinding">UPDATE_EXISTING</prop>
</props>
</list>
</property>

View File

@@ -151,6 +151,11 @@
<prop key="storeRef">${alfresco_user_store.store}</prop>
<prop key="packageName">users</prop>
</props>
<props>
<prop key="storeRef">${spaces.store}</prop>
<prop key="packageName">models</prop>
<prop key="includedPaths">/app:company_home/app:dictionary/app:models</prop>
</props>
<props>
<prop key="storeRef">${spaces.store}</prop>
<prop key="packageName">spaces</prop>

View File

@@ -43,4 +43,25 @@
</property>
</bean>
<!-- for restore, needs to be before bootstrap-context -->
<bean id="dictionaryModelType" class="org.alfresco.repo.dictionary.DictionaryModelType" init-method="init">
<property name="dictionaryDAO" ref="dictionaryDAO"/>
<property name="namespaceDAO" ref="namespaceDAO"/>
<property name="nodeService" ref="NodeService"/>
<property name="contentService" ref="contentService"/>
<property name="policyComponent" ref="policyComponent"/>
<property name="workflowService" ref="WorkflowService"/>
<property name="searchService" ref="SearchService"/>
<property name="namespaceService" ref="namespaceService"/>
<property name="tenantService" ref="tenantService"/>
<property name="tenantDeployerService" ref="tenantAdminService"/>
<property name="storeUrls">
<list>
<value>${spaces.store}</value>
<value>${spaces.archive.store}</value>
</list>
</property>
</bean>
</beans>

View File

@@ -79,24 +79,4 @@
</bean>
<bean id="dictionaryModelType" class="org.alfresco.repo.dictionary.DictionaryModelType" init-method="init">
<property name="dictionaryDAO" ref="dictionaryDAO"/>
<property name="namespaceDAO" ref="namespaceDAO"/>
<property name="nodeService" ref="NodeService"/>
<property name="contentService" ref="contentService"/>
<property name="policyComponent" ref="policyComponent"/>
<property name="workflowService" ref="WorkflowService"/>
<property name="searchService" ref="SearchService"/>
<property name="namespaceService" ref="namespaceService"/>
<property name="tenantService" ref="tenantService"/>
<property name="tenantDeployerService" ref="tenantAdminService"/>
<property name="storeUrls">
<list>
<value>${spaces.store}</value>
<value>${spaces.archive.store}</value>
</list>
</property>
</bean>
</beans>

View File

@@ -265,7 +265,7 @@ public class DictionaryModelType implements ContentServicePolicies.OnContentUpda
// Register interest in the onCreateNode policy for the dictionary model type
policyComponent.bindClassBehaviour(
QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"),
ContentModel.TYPE_DICTIONARY_MODEL,
this,
new JavaBehaviour(this, "onCreateNode"));
// Create the transaction listener

View File

@@ -362,6 +362,16 @@ public class ExporterComponent
return;
}
// explicitly included ?
if (parameters.getIncludedPaths() != null)
{
String nodePathPrefixString = nodeService.getPath(nodeRef).toPrefixString(namespaceService);
if (! (isIncludedPath(parameters.getIncludedPaths(), nodePathPrefixString)))
{
return;
}
}
// export node as reference to node, or as the actual node
if (exportAsRef)
{
@@ -740,6 +750,22 @@ public class ExporterComponent
return false;
}
private boolean isIncludedPath(String[] includedPaths, String path)
{
for (String includePath : includedPaths)
{
// note: allow parents or children - e.g. if included path is /a/b/c then /, /a, /a/b, /a/b/c, /a/b/c/d, /a/b/c/d/e are all included
if (includePath.startsWith(path) || path.startsWith(includePath))
{
return true;
}
}
return false;
}
/**
* Is the aspect unexportable?
*

View File

@@ -68,6 +68,7 @@ public class RepositoryExporterComponent implements RepositoryExporterService
{
private static final String STOREREF_KEY = "storeRef";
private static final String PACKAGENAME_KEY = "packageName";
private static final String INCLUDED_PATHS = "includedPaths";
// component dependencies
private ExporterService exporterService;
@@ -291,9 +292,14 @@ public class RepositoryExporterComponent implements RepositoryExporterService
}
String completePackageName = (packageName == null) ? storePackageName : packageName + "_" + storePackageName;
// retrieve included paths (optional)
// note: the default exporter will currently include parents and children, relative to the path (to support bootstrap import of Dynamic Models)
String includedPathsStr = (String)store.get(INCLUDED_PATHS);
String[] includedPaths = (includedPathsStr != null ? includedPathsStr.split(",\\s*") : null);
// now export
// NOTE: For now, do not provide exporter progress
ExporterCrawlerParameters exportParameters = getExportParameters(storeRef);
ExporterCrawlerParameters exportParameters = getExportParameters(storeRef, includedPaths);
ExportHandleType exportHandle = exportStore.exportStore(exportParameters, completePackageName, null);
exportHandles.add(exportHandle);
}
@@ -308,7 +314,7 @@ public class RepositoryExporterComponent implements RepositoryExporterService
* @param storeRef store reference to export
* @return the parameters for exporting the complete store
*/
private ExporterCrawlerParameters getExportParameters(StoreRef storeRef)
private ExporterCrawlerParameters getExportParameters(StoreRef storeRef, String[] includedPaths)
{
ExporterCrawlerParameters parameters = new ExporterCrawlerParameters();
parameters.setExportFrom(new Location(storeRef));
@@ -318,6 +324,7 @@ public class RepositoryExporterComponent implements RepositoryExporterService
parameters.setCrawlAssociations(true);
parameters.setCrawlNullProperties(true);
parameters.setExcludeNamespaceURIs(new String[] {});
parameters.setIncludedPaths(includedPaths);
parameters.setReferenceType(ReferenceType.NODEREF);
return parameters;
}

View File

@@ -53,6 +53,7 @@ import org.alfresco.service.cmr.view.ImporterException;
import org.alfresco.service.cmr.view.ImporterProgress;
import org.alfresco.service.cmr.view.ImporterService;
import org.alfresco.service.cmr.view.Location;
import org.alfresco.service.cmr.view.ImporterBinding.UUID_BINDING;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
@@ -60,9 +61,6 @@ import org.alfresco.util.AbstractLifecycleBean;
import org.alfresco.util.TempFileProvider;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.impl.Log4JLogger;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationEvent;
import org.springframework.util.FileCopyUtils;
@@ -79,6 +77,7 @@ public class ImporterBootstrap extends AbstractLifecycleBean
public static final String VIEW_MESSAGES_PROPERTY = "messages";
public static final String VIEW_LOCATION_VIEW = "location";
public static final String VIEW_ENCODING = "encoding";
public static final String VIEW_UUID_BINDING = "uuidBinding";
// Logger
private static final Log logger = LogFactory.getLog(ImporterBootstrap.class);
@@ -317,9 +316,12 @@ public class ImporterBootstrap extends AbstractLifecycleBean
}
if (storeRef == null)
{
throw new ImporterException("Store URL must be provided");
if (logger.isDebugEnabled())
{
logger.debug("No Store URL - bootstrap import ignored");
}
return;
}
UserTransaction userTransaction = transactionService.getUserTransaction();
Authentication authentication = authenticationComponent.getCurrentAuthentication();
@@ -410,6 +412,19 @@ public class ImporterBootstrap extends AbstractLifecycleBean
binding.setResourceBundle(bundle);
}
String uuidBinding = bootstrapView.getProperty(VIEW_UUID_BINDING);
if (uuidBinding != null && uuidBinding.length() > 0)
{
try
{
binding.setUUIDBinding(UUID_BINDING.valueOf(UUID_BINDING.class, uuidBinding));
}
catch(IllegalArgumentException e)
{
throw new ImporterException("The value " + uuidBinding + " is an invalid uuidBinding");
}
}
// Now import...
ImporterProgress importProgress = null;
if (logger.isDebugEnabled())
@@ -522,6 +537,8 @@ public class ImporterBootstrap extends AbstractLifecycleBean
private static final String IMPORT_LOCATION_NODEREF = "bootstrap.location.noderef";
private static final String IMPORT_LOCATION_PATH = "bootstrap.location.path";
// by default, use create new strategy for bootstrap import
private UUID_BINDING uuidBinding = UUID_BINDING.CREATE_NEW_WITH_UUID;
/**
* Set Import Configuration
@@ -602,8 +619,17 @@ public class ImporterBootstrap extends AbstractLifecycleBean
*/
public UUID_BINDING getUUIDBinding()
{
// always use create new strategy for bootstrap import
return UUID_BINDING.CREATE_NEW_WITH_UUID;
return uuidBinding;
}
/**
* Allow bootstrap to override default Node UUID Binding
*
* @param uuidBinding UUID_BINDING
*/
private void setUUIDBinding(UUID_BINDING uuidBinding)
{
this.uuidBinding = uuidBinding;
}
/*

View File

@@ -45,7 +45,7 @@ public class ExporterCrawlerParameters
private boolean crawlNullProperties = true;
private ReferenceType referenceType = ReferenceType.PATHREF;
private String[] excludeNamespaceURIs = new String[] { NamespaceService.REPOSITORY_VIEW_1_0_URI };
private String[] includedPaths = null;
/**
* Crawl and export child nodes
@@ -167,6 +167,26 @@ public class ExporterCrawlerParameters
this.excludeNamespaceURIs = excludeNamespaceURIs;
}
/**
* Gets the list of included paths to explicitly include in the Export
*
* @return the list of included paths
*/
public String[] getIncludedPaths()
{
return includedPaths;
}
/**
* Sets the list of included paths to explicitly include in the Export
*
* @param includedPaths
*/
public void setIncludedPaths(String[] includedPaths)
{
this.includedPaths = includedPaths;
}
/**
* Gets the path to export from
*