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;
|
int changed = 0;
|
||||||
String query = "TYPE:\"" + typeName.toString() + "\"";
|
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
|
ResultSet results = null;
|
||||||
if (results.length() > 0)
|
try
|
||||||
{
|
{
|
||||||
for (NodeRef node : results.getNodeRefs())
|
results = this.searchService.query(this.importerBootstrap.getStoreRef(),
|
||||||
{
|
SearchService.LANGUAGE_LUCENE, query);
|
||||||
String icon = (String)this.nodeService.getProperty(node, ContentModel.PROP_ICON);
|
|
||||||
if (icon != null && icon.length() > 0)
|
// 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 (this.nodeService.exists(node))
|
||||||
if (idx != -1)
|
|
||||||
{
|
{
|
||||||
String newIcon = icon.substring(0, idx);
|
String icon = (String)this.nodeService.getProperty(node, ContentModel.PROP_ICON);
|
||||||
this.nodeService.setProperty(node, ContentModel.PROP_ICON, (Serializable)newIcon);
|
if (icon != null && icon.length() > 0)
|
||||||
changed++;
|
{
|
||||||
|
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;
|
return changed;
|
||||||
|
Reference in New Issue
Block a user