Fixing findbugs errors: "Method checks the result of a new allocation" and "Overzealous casting".

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@113200 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Neil McErlean
2015-09-28 12:02:26 +00:00
parent 1a71eafaf5
commit 773f964620
2 changed files with 41 additions and 44 deletions

View File

@@ -578,10 +578,10 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
// Apply the search aspect // Apply the search aspect
applySearchAspect(record); applySearchAspect(record);
Collection<String> events = (List<String>)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS); Collection<String> events = (Collection<String>)nodeService.getProperty(record, PROP_RS_DISPOSITION_EVENTS);
if (events == null) if (events == null)
{ {
events = new ArrayList<String>(1); events = new ArrayList<>(1);
} }
events.add((String)nodeService.getProperty(eventExecution, PROP_EVENT_EXECUTION_NAME)); events.add((String)nodeService.getProperty(eventExecution, PROP_EVENT_EXECUTION_NAME));
nodeService.setProperty(record, PROP_RS_DISPOSITION_EVENTS, (Serializable)events); nodeService.setProperty(record, PROP_RS_DISPOSITION_EVENTS, (Serializable)events);

View File

@@ -116,54 +116,51 @@ public class RecordsManagementSearchServiceImpl implements RecordsManagementSear
try try
{ {
JSONArray jsonArray = new JSONArray(reportsJSON); JSONArray jsonArray = new JSONArray(reportsJSON);
if (jsonArray != null) for (int i=0; i < jsonArray.length(); i++)
{ {
for (int i=0; i < jsonArray.length(); i++) JSONObject report = jsonArray.getJSONObject(i);
{
JSONObject report = jsonArray.getJSONObject(i);
// Get the name // Get the name
if (!report.has(SavedSearchDetails.NAME)) if (!report.has(SavedSearchDetails.NAME))
{ {
throw new AlfrescoRuntimeException("Unable to load report details because name has not been specified. \n" + reportsJSON); throw new AlfrescoRuntimeException("Unable to load report details because name has not been specified. \n" + reportsJSON);
} }
String name = report.getString(SavedSearchDetails.NAME); String name = report.getString(SavedSearchDetails.NAME);
String translatedName = I18NUtil.getMessage(name); String translatedName = I18NUtil.getMessage(name);
if (translatedName != null) if (translatedName != null)
{ {
name = translatedName; name = translatedName;
} }
// Get the query // Get the query
if (!report.has(SavedSearchDetails.SEARCH)) if (!report.has(SavedSearchDetails.SEARCH))
{
throw new AlfrescoRuntimeException("Unable to load report details because search has not been specified for report " + name + ". \n" + reportsJSON);
}
String query = report.getString(SavedSearchDetails.SEARCH);
// Get the description
String description = "";
if (report.has(SavedSearchDetails.DESCRIPTION))
{
description = report.getString(SavedSearchDetails.DESCRIPTION);
String translatedDescription = I18NUtil.getMessage(description);
if (translatedDescription != null)
{ {
throw new AlfrescoRuntimeException("Unable to load report details because search has not been specified for report " + name + ". \n" + reportsJSON); description = translatedDescription;
} }
String query = report.getString(SavedSearchDetails.SEARCH); }
// Get the description RecordsManagementSearchParameters searchParameters = new RecordsManagementSearchParameters();
String description = ""; if (report.has("searchparams"))
if (report.has(SavedSearchDetails.DESCRIPTION)) {
{ searchParameters = RecordsManagementSearchParameters.createFromJSON(report.getJSONObject("searchparams"), namespaceService);
description = report.getString(SavedSearchDetails.DESCRIPTION); }
String translatedDescription = I18NUtil.getMessage(description);
if (translatedDescription != null)
{
description = translatedDescription;
}
}
RecordsManagementSearchParameters searchParameters = new RecordsManagementSearchParameters(); // Create the report details and add to list
if (report.has("searchparams")) ReportDetails reportDetails = new ReportDetails(name, description, query, searchParameters);
{ reports.add(reportDetails);
searchParameters = RecordsManagementSearchParameters.createFromJSON(report.getJSONObject("searchparams"), namespaceService); }
}
// Create the report details and add to list
ReportDetails reportDetails = new ReportDetails(name, description, query, searchParameters);
reports.add(reportDetails);
}
}
} }
catch (JSONException exception) catch (JSONException exception)
{ {