mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fix AR-2179
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8556 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -44,6 +44,9 @@
|
||||
<property name="path">
|
||||
<value>/app:company_home/app:dictionary/app:models</value>
|
||||
</property>
|
||||
<property name="queryLanguage">
|
||||
<value>lucene</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="customMessagesRepositoryLocation" class="org.alfresco.repo.dictionary.RepositoryLocation">
|
||||
@@ -51,6 +54,9 @@
|
||||
<property name="path">
|
||||
<value>/app:company_home/app:dictionary/app:messages</value>
|
||||
</property>
|
||||
<property name="queryLanguage">
|
||||
<value>lucene</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -43,6 +43,7 @@ import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.search.ResultSet;
|
||||
import org.alfresco.service.cmr.search.SearchService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.transaction.TransactionService;
|
||||
@@ -233,40 +234,40 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
|
||||
{
|
||||
logger.warn("StoreRef '"+ storeRef+"' does not exist");
|
||||
continue; // skip this location
|
||||
}
|
||||
}
|
||||
|
||||
if (repositoryLocation.getQueryLanguage().equals(
|
||||
SearchService.LANGUAGE_XPATH))
|
||||
if (repositoryLocation.getQueryLanguage().equals(SearchService.LANGUAGE_LUCENE))
|
||||
{
|
||||
NodeRef rootNode = nodeService.getRootNode(storeRef);
|
||||
|
||||
List<NodeRef> nodeRefs = searchService.selectNodes(rootNode,
|
||||
repositoryLocation.getXPathQueryStatement(ContentModel.TYPE_DICTIONARY_MODEL.getPrefixedQName(namespaceService)),
|
||||
null,
|
||||
namespaceService,
|
||||
false);
|
||||
|
||||
for (NodeRef dictionaryModel : nodeRefs)
|
||||
{
|
||||
// Ignore if the node is a working copy or if its inactive
|
||||
if (nodeService.hasAspect(dictionaryModel, ContentModel.ASPECT_WORKING_COPY) == false)
|
||||
ResultSet rs = searchService.query(storeRef,
|
||||
SearchService.LANGUAGE_LUCENE,
|
||||
repositoryLocation.getLuceneQueryStatement(ContentModel.TYPE_DICTIONARY_MODEL.getPrefixedQName(namespaceService)));
|
||||
if (rs.length() > 0)
|
||||
{
|
||||
for (NodeRef dictionaryModel : rs.getNodeRefs())
|
||||
{
|
||||
Boolean isActive = (Boolean)nodeService.getProperty(dictionaryModel, ContentModel.PROP_MODEL_ACTIVE);
|
||||
|
||||
if ((isActive != null) && (isActive.booleanValue() == true))
|
||||
{
|
||||
M2Model model = createM2Model(dictionaryModel);
|
||||
if (model != null)
|
||||
{
|
||||
for (M2Namespace namespace : model.getNamespaces())
|
||||
{
|
||||
modelMap.put(namespace.getUri(), model);
|
||||
}
|
||||
}
|
||||
// Ignore if the node is a working copy or if its inactive
|
||||
if (nodeService.hasAspect(dictionaryModel, ContentModel.ASPECT_WORKING_COPY) == false)
|
||||
{
|
||||
Boolean isActive = (Boolean)nodeService.getProperty(dictionaryModel, ContentModel.PROP_MODEL_ACTIVE);
|
||||
if ((isActive != null) && (isActive.booleanValue() == true))
|
||||
{
|
||||
M2Model model = createM2Model(dictionaryModel);
|
||||
if (model != null)
|
||||
{
|
||||
for (M2Namespace namespace : model.getNamespaces())
|
||||
{
|
||||
modelMap.put(namespace.getUri(), model);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.error("Unsupported query language for models location: " + repositoryLocation.getQueryLanguage());
|
||||
}
|
||||
}
|
||||
|
||||
// Load the models ensuring that they are loaded in the correct order
|
||||
@@ -292,43 +293,43 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
|
||||
{
|
||||
logger.warn("StoreRef '"+ storeRef+"' does not exist");
|
||||
continue; // skip this location
|
||||
}
|
||||
|
||||
if (repositoryLocation.getQueryLanguage().equals(
|
||||
SearchService.LANGUAGE_XPATH))
|
||||
}
|
||||
|
||||
if (repositoryLocation.getQueryLanguage().equals(SearchService.LANGUAGE_LUCENE))
|
||||
{
|
||||
NodeRef rootNode = nodeService.getRootNode(storeRef);
|
||||
|
||||
List<NodeRef> nodeRefs = searchService.selectNodes(rootNode,
|
||||
repositoryLocation.getXPathQueryStatement(ContentModel.TYPE_CONTENT.getPrefixedQName(namespaceService)),
|
||||
null,
|
||||
namespaceService,
|
||||
false);
|
||||
|
||||
List<String> resourceBundleBaseNames = new ArrayList<String>();
|
||||
|
||||
for (NodeRef messageResource : nodeRefs)
|
||||
{
|
||||
String resourceName = (String) nodeService.getProperty(
|
||||
messageResource, ContentModel.PROP_NAME);
|
||||
|
||||
String bundleBaseName = messageService.getBaseBundleName(resourceName);
|
||||
|
||||
if (!resourceBundleBaseNames.contains(bundleBaseName))
|
||||
ResultSet rs = searchService.query(storeRef,
|
||||
SearchService.LANGUAGE_LUCENE,
|
||||
repositoryLocation.getLuceneQueryStatement(ContentModel.TYPE_CONTENT.getPrefixedQName(namespaceService)));
|
||||
if (rs.length() > 0)
|
||||
{
|
||||
List<String> resourceBundleBaseNames = new ArrayList<String>();
|
||||
for (NodeRef messageResource : rs.getNodeRefs())
|
||||
{
|
||||
resourceBundleBaseNames.add(bundleBaseName);
|
||||
String resourceName = (String) nodeService.getProperty(
|
||||
messageResource, ContentModel.PROP_NAME);
|
||||
|
||||
String bundleBaseName = messageService.getBaseBundleName(resourceName);
|
||||
|
||||
if (!resourceBundleBaseNames.contains(bundleBaseName))
|
||||
{
|
||||
resourceBundleBaseNames.add(bundleBaseName);
|
||||
}
|
||||
}
|
||||
|
||||
// Only need to register resource bundle names
|
||||
for (String resourceBundleBaseName : resourceBundleBaseNames)
|
||||
{
|
||||
logger.info("Register bundle: " + resourceBundleBaseName);
|
||||
|
||||
messageService.registerResourceBundle(storeRef.toString() + path + "/cm:" + resourceBundleBaseName);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Only need to register resource bundle names
|
||||
for (String resourceBundleBaseName : resourceBundleBaseNames)
|
||||
{
|
||||
logger.info("Register bundle: " + resourceBundleBaseName);
|
||||
|
||||
messageService.registerResourceBundle(storeRef.toString() + path + "/cm:" + resourceBundleBaseName);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.error("Unsupported query language for messages location: " + repositoryLocation.getQueryLanguage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -110,6 +110,7 @@ public class DictionaryRepositoryBootstrapTest extends BaseAlfrescoSpringTest
|
||||
RepositoryLocation location = new RepositoryLocation();
|
||||
location.setStoreProtocol(this.storeRef.getProtocol());
|
||||
location.setStoreId(this.storeRef.getIdentifier());
|
||||
location.setQueryLanguage(SearchService.LANGUAGE_LUCENE);
|
||||
// NOTE: we are not setting the path for now .. in doing so we are searching the whole dictionary
|
||||
|
||||
List<RepositoryLocation> locations = new ArrayList<RepositoryLocation>();
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@@ -104,7 +104,7 @@ public class RepositoryLocation
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the queru language
|
||||
* Set the query language
|
||||
*
|
||||
* @param path the search language
|
||||
*/
|
||||
@@ -159,7 +159,7 @@ public class RepositoryLocation
|
||||
{
|
||||
String result = "+TYPE:\"" + contentModelType.toString() + "\"";
|
||||
|
||||
if (this.path != null)
|
||||
if ((this.path != null) && (! this.path.equals("")))
|
||||
{
|
||||
result += " +PATH:\"" + this.path + "\"";
|
||||
}
|
||||
@@ -176,7 +176,7 @@ public class RepositoryLocation
|
||||
{
|
||||
String result = "/*[subtypeOf('" + prefixResolvedContentModelType.toPrefixString() + "')]"; // immediate children only
|
||||
|
||||
if (this.path != null)
|
||||
if ((this.path != null) && (! this.path.equals("")))
|
||||
{
|
||||
result = this.path + result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user