mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Fix to Forum Icons Patch - now checks for missing nodes (in search results) and closes search ResultSet
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2738 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -57,26 +57,41 @@ public class ForumsIconsPatch extends AbstractPatch
|
||||
{
|
||||
int changed = 0;
|
||||
String query = "TYPE:\"" + typeName.toString() + "\"";
|
||||
ResultSet results = this.searchService.query(this.importerBootstrap.getStoreRef(),
|
||||
SearchService.LANGUAGE_LUCENE, query);
|
||||
|
||||
// if there are any results iterate through nodes and update icon property
|
||||
if (results.length() > 0)
|
||||
ResultSet results = null;
|
||||
try
|
||||
{
|
||||
for (NodeRef node : results.getNodeRefs())
|
||||
{
|
||||
String icon = (String)this.nodeService.getProperty(node, ContentModel.PROP_ICON);
|
||||
if (icon != null && icon.length() > 0)
|
||||
results = this.searchService.query(this.importerBootstrap.getStoreRef(),
|
||||
SearchService.LANGUAGE_LUCENE, query);
|
||||
|
||||
// if there are any results iterate through nodes and update icon property
|
||||
if (results.length() > 0)
|
||||
{
|
||||
for (NodeRef node : results.getNodeRefs())
|
||||
{
|
||||
int idx = icon.indexOf("_large");
|
||||
if (idx != -1)
|
||||
if (this.nodeService.exists(node))
|
||||
{
|
||||
String newIcon = icon.substring(0, idx);
|
||||
this.nodeService.setProperty(node, ContentModel.PROP_ICON, (Serializable)newIcon);
|
||||
changed++;
|
||||
String icon = (String)this.nodeService.getProperty(node, ContentModel.PROP_ICON);
|
||||
if (icon != null && icon.length() > 0)
|
||||
{
|
||||
int idx = icon.indexOf("_large");
|
||||
if (idx != -1)
|
||||
{
|
||||
String newIcon = icon.substring(0, idx);
|
||||
this.nodeService.setProperty(node, ContentModel.PROP_ICON, (Serializable)newIcon);
|
||||
changed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (results != null)
|
||||
{
|
||||
results.close();
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
|
Reference in New Issue
Block a user