mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Dynamic Models - minor, validate message resource bundle exists in repo
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8055 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -729,18 +729,27 @@ public class RepoAdminServiceImpl implements RepoAdminService
|
||||
|
||||
List<NodeRef> nodeRefs = searchService.selectNodes(rootNode, repoMessagesLocation.getPath()+CRITERIA_ALL, null, namespaceService, false);
|
||||
|
||||
boolean found = false;
|
||||
for (NodeRef nodeRef : nodeRefs)
|
||||
{
|
||||
String customLabelName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
String resourceName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
|
||||
if (customLabelName.startsWith(bundleBaseName))
|
||||
if (bundleBaseName.equals(messageService.getBaseBundleName(resourceName)))
|
||||
{
|
||||
// remove message resource file from the repository
|
||||
nodeService.deleteNode(nodeRef);
|
||||
found = true; // continue to undeploy any others
|
||||
}
|
||||
}
|
||||
|
||||
logger.info("Message resources undeployed: " + bundleBaseName);
|
||||
if (found)
|
||||
{
|
||||
logger.info("Message resources undeployed: " + bundleBaseName);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Could not find message resource bundle " + repoBundlePath);
|
||||
}
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
@@ -771,9 +780,9 @@ public class RepoAdminServiceImpl implements RepoAdminService
|
||||
boolean found = false;
|
||||
for (NodeRef nodeRef : nodeRefs)
|
||||
{
|
||||
String customLabelName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
String resourceName = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
|
||||
if (customLabelName.startsWith(bundleBaseName))
|
||||
if (bundleBaseName.equals(messageService.getBaseBundleName(resourceName)))
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
@@ -807,7 +816,7 @@ public class RepoAdminServiceImpl implements RepoAdminService
|
||||
|
||||
if (bundleBaseName.indexOf("_") != -1)
|
||||
{
|
||||
// currently limited due to parser in DictionaryRepositoryBootstrap
|
||||
// currently limited due to parser in MessageServiceImpl.getBaseBundleName
|
||||
throw new AlfrescoRuntimeException("Message deployment failed - bundle base name '" + bundleBaseName + "' should not contain '_' (underscore)");
|
||||
}
|
||||
|
||||
|
@@ -323,29 +323,14 @@ public class DictionaryRepositoryBootstrap extends AbstractLifecycleBean impleme
|
||||
|
||||
for (NodeRef messageResource : nodeRefs)
|
||||
{
|
||||
String name = (String) nodeService.getProperty(
|
||||
String resourceName = (String) nodeService.getProperty(
|
||||
messageResource, ContentModel.PROP_NAME);
|
||||
|
||||
// convert resource file name to a resource bundle basename
|
||||
// e.g. either 'workflow_fr_FR.properties' or 'workflow.properties' should be converted to 'workflow'
|
||||
// note: this assumes that the baseName itself does not contain underscore !
|
||||
int idx = name.indexOf("_");
|
||||
if (idx > 0)
|
||||
{
|
||||
name = name.substring(0, idx - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int idx1 = name.indexOf(".");
|
||||
if (idx1 > 0)
|
||||
{
|
||||
name = name.substring(0, idx1);
|
||||
}
|
||||
}
|
||||
String bundleBaseName = messageService.getBaseBundleName(resourceName);
|
||||
|
||||
if (!resourceBundleBaseNames.contains(name))
|
||||
if (!resourceBundleBaseNames.contains(bundleBaseName))
|
||||
{
|
||||
resourceBundleBaseNames.add(name);
|
||||
resourceBundleBaseNames.add(bundleBaseName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -153,4 +153,7 @@ public interface MessageService extends TenantDeployer
|
||||
* @param messageDeployer
|
||||
*/
|
||||
public void register(MessageDeployer messageDeployer);
|
||||
|
||||
public String getBaseBundleName(String resourceName);
|
||||
|
||||
}
|
||||
|
@@ -925,4 +925,28 @@ public class MessageServiceImpl implements MessageService
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getBaseBundleName(String resourceName)
|
||||
{
|
||||
// convert resource file name to a resource bundle basename
|
||||
// e.g. either 'workflow_fr_FR.properties' or 'workflow.properties' should be converted to 'workflow'
|
||||
// note: this assumes that the baseName itself does not contain underscore !
|
||||
|
||||
String bundleBaseName = resourceName;
|
||||
int idx = resourceName.indexOf("_");
|
||||
if (idx > 0)
|
||||
{
|
||||
bundleBaseName = resourceName.substring(0, idx - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int idx1 = resourceName.indexOf(".");
|
||||
if (idx1 > 0)
|
||||
{
|
||||
bundleBaseName = resourceName.substring(0, idx1);
|
||||
}
|
||||
}
|
||||
|
||||
return bundleBaseName;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user