Fixed major issues reported by sonar (If Stmts Must Use Braces)

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/HEAD@63501 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Tuna Aksoy
2014-03-02 22:23:03 +00:00
parent 505e29499a
commit 8c994439be
21 changed files with 355 additions and 271 deletions

View File

@@ -285,10 +285,12 @@ public class BroadcastDispositionActionDefinitionUpdateAction extends RMActionEx
nodeService.removeChild(nextAction.getNodeRef(), event.getNodeRef()); nodeService.removeChild(nextAction.getNodeRef(), event.getNodeRef());
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{
logger.debug("Removed '" + eventName + "' from next action '" + nextAction.getName() + logger.debug("Removed '" + eventName + "' from next action '" + nextAction.getName() +
"' (" + nextAction.getNodeRef() + ")"); "' (" + nextAction.getNodeRef() + ")");
} }
} }
}
// go through the disposition action definition step events and add any new ones // go through the disposition action definition step events and add any new ones
if (stepEvents != null) if (stepEvents != null)

View File

@@ -75,8 +75,10 @@ public class OpenRecordFolderAction extends RMActionExecuterAbstractBase
else else
{ {
if (logger.isWarnEnabled()) if (logger.isWarnEnabled())
{
logger.warn(I18NUtil.getMessage(MSG_NO_OPEN_RECORD_FOLDER, actionedUponNodeRef.toString())); logger.warn(I18NUtil.getMessage(MSG_NO_OPEN_RECORD_FOLDER, actionedUponNodeRef.toString()));
} }
} }
} }
}
} }

View File

@@ -844,7 +844,10 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName)); throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName));
} }
if (newName == null) return propQName; if (newName == null)
{
return propQName;
}
QName newPropQName = getQNameForClientId(newName); QName newPropQName = getQNameForClientId(newName);
if (newPropQName != null) if (newPropQName != null)
@@ -888,7 +891,10 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName)); throw new AlfrescoRuntimeException(I18NUtil.getMessage(MSG_PROP_EXIST, propQName));
} }
if (newLabel == null) return propQName; if (newLabel == null)
{
return propQName;
}
NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI()); NodeRef modelRef = getCustomModelRef(propQName.getNamespaceURI());
M2Model deserializedModel = readCustomContentModel(modelRef); M2Model deserializedModel = readCustomContentModel(modelRef);
@@ -1619,7 +1625,10 @@ public class RecordsManagementAdminServiceImpl implements RecordsManagementAdmin
{ {
try try
{ {
if (contentIn != null) contentIn.close(); if (contentIn != null)
{
contentIn.close();
}
} }
catch (IOException ignored) catch (IOException ignored)
{ {

View File

@@ -277,19 +277,29 @@ public abstract class AbstractCapability extends RMSecurityCommon
public boolean equals(Object obj) public boolean equals(Object obj)
{ {
if (this == obj) if (this == obj)
{
return true; return true;
}
if (obj == null) if (obj == null)
{
return false; return false;
}
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
{
return false; return false;
}
final AbstractCapability other = (AbstractCapability) obj; final AbstractCapability other = (AbstractCapability) obj;
if (getName() == null) if (getName() == null)
{ {
if (other.getName() != null) if (other.getName() != null)
{
return false; return false;
} }
}
else if (!getName().equals(other.getName())) else if (!getName().equals(other.getName()))
{
return false; return false;
}
return true; return true;
} }

View File

@@ -84,11 +84,17 @@ public class CustomMapping
public boolean equals(Object obj) public boolean equals(Object obj)
{ {
if (this == obj) if (this == obj)
{
return true; return true;
}
if (obj == null) if (obj == null)
{
return false; return false;
}
if (getClass() != obj.getClass()) if (getClass() != obj.getClass())
{
return false; return false;
}
final CustomMapping other = (CustomMapping) obj; final CustomMapping other = (CustomMapping) obj;

View File

@@ -301,7 +301,10 @@ public class RecordsManagementEventServiceImpl implements RecordsManagementEvent
String eventDisplayLabel = eventJSON.getString("eventDisplayLabel"); String eventDisplayLabel = eventJSON.getString("eventDisplayLabel");
String translated = I18NUtil.getMessage(eventDisplayLabel); String translated = I18NUtil.getMessage(eventDisplayLabel);
if (translated!=null ) eventDisplayLabel = translated; if (translated != null)
{
eventDisplayLabel = translated;
}
// Check that the eventType is valid // Check that the eventType is valid

View File

@@ -385,6 +385,8 @@ public class RecordsManagementNodeFormFilter extends RecordsManagementFormFilter
} }
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{
logger.debug("Set 'rma:recordLevelDisposition' field to be protected as record folders or records are present"); logger.debug("Set 'rma:recordLevelDisposition' field to be protected as record folders or records are present");
} }
}
} }

View File

@@ -332,9 +332,11 @@ public class RecordsManagementSearchBehaviour implements RecordsManagementModel
nodeService.addAspect(nodeRef, ASPECT_RM_SEARCH , null); nodeService.addAspect(nodeRef, ASPECT_RM_SEARCH , null);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{
logger.debug("Added search aspect to node: " + nodeRef); logger.debug("Added search aspect to node: " + nodeRef);
} }
} }
}
finally finally
{ {
onAddSearchAspect.enable(); onAddSearchAspect.enable();

View File

@@ -179,7 +179,10 @@ public class FilePlanComponentAspect extends BaseBehaviourBean
String expectedScriptName = shortPrefix + "_" + localName + ".js"; String expectedScriptName = shortPrefix + "_" + localName + ".js";
NodeRef nextElement = nodeService.getChildByName(scriptsFolderNodeRef, ContentModel.ASSOC_CONTAINS, expectedScriptName); NodeRef nextElement = nodeService.getChildByName(scriptsFolderNodeRef, ContentModel.ASSOC_CONTAINS, expectedScriptName);
if (nextElement != null) result.add(nextElement); if (nextElement != null)
{
result.add(nextElement);
}
} }
return result; return result;

View File

@@ -307,7 +307,9 @@ public class RecordFolderServiceImpl extends ServiceBaseImpl
else else
{ {
if (logger.isWarnEnabled()) if (logger.isWarnEnabled())
{
logger.warn(I18NUtil.getMessage(MSG_CLOSE_RECORD_FOLDER_NOT_FOLDER, nodeRef.toString())); logger.warn(I18NUtil.getMessage(MSG_CLOSE_RECORD_FOLDER_NOT_FOLDER, nodeRef.toString()));
} }
} }
}
} }

View File

@@ -491,7 +491,10 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
String name = getShortRoleName(groupShortName, rmRootNode); String name = getShortRoleName(groupShortName, rmRootNode);
String displayLabel = authorityService.getAuthorityDisplayName(roleAuthority); String displayLabel = authorityService.getAuthorityDisplayName(roleAuthority);
String translated = I18NUtil.getMessage(displayLabel); String translated = I18NUtil.getMessage(displayLabel);
if (translated!=null ) displayLabel = translated; if (translated != null)
{
displayLabel = translated;
}
Set<Capability> capabilities = getCapabilitiesImpl(rmRootNode, roleAuthority); Set<Capability> capabilities = getCapabilitiesImpl(rmRootNode, roleAuthority);
Role role = new Role(name, displayLabel, capabilities, roleAuthority, groupShortName); Role role = new Role(name, displayLabel, capabilities, roleAuthority, groupShortName);
@@ -534,7 +537,10 @@ public class FilePlanRoleServiceImpl implements FilePlanRoleService,
String name = getShortRoleName(groupShortName, rmRootNode); String name = getShortRoleName(groupShortName, rmRootNode);
String displayLabel = authorityService.getAuthorityDisplayName(roleAuthority); String displayLabel = authorityService.getAuthorityDisplayName(roleAuthority);
String translated = I18NUtil.getMessage(displayLabel); String translated = I18NUtil.getMessage(displayLabel);
if (translated!=null ) displayLabel = translated; if (translated != null)
{
displayLabel = translated;
}
Set<Capability> capabilities = getCapabilitiesImpl(rmRootNode, roleAuthority); Set<Capability> capabilities = getCapabilitiesImpl(rmRootNode, roleAuthority);
Role role = new Role(name, displayLabel, capabilities, roleAuthority, groupShortName); Role role = new Role(name, displayLabel, capabilities, roleAuthority, groupShortName);

View File

@@ -175,7 +175,10 @@ public class ApplyDodCertModelFixesGet extends DeclarativeWebScript
{ {
try try
{ {
if (contentIn != null) contentIn.close(); if (contentIn != null)
{
contentIn.close();
}
} }
catch (IOException ignored) catch (IOException ignored)
{ {

View File

@@ -111,7 +111,10 @@ public class ApplyFixMob1573Get extends DeclarativeWebScript
{ {
try try
{ {
if (contentIn != null) contentIn.close(); if (contentIn != null)
{
contentIn.close();
}
} }
catch (IOException ignored) catch (IOException ignored)
{ {

View File

@@ -62,7 +62,9 @@ public class AuditLogGet extends BaseAuditRetrievalWebScript
auditTrail = this.rmAuditService.getAuditTrailFile(parseQueryParameters(req), parseReportFormat(req)); auditTrail = this.rmAuditService.getAuditTrailFile(parseQueryParameters(req), parseReportFormat(req));
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{
logger.debug("Streaming audit trail from file: " + auditTrail.getAbsolutePath()); logger.debug("Streaming audit trail from file: " + auditTrail.getAbsolutePath());
}
boolean attach = false; boolean attach = false;
String attachFileName = null; String attachFileName = null;
@@ -73,8 +75,10 @@ public class AuditLogGet extends BaseAuditRetrievalWebScript
attachFileName = auditTrail.getName(); attachFileName = auditTrail.getName();
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{
logger.debug("Exporting audit trail using file name: " + attachFileName); logger.debug("Exporting audit trail using file name: " + attachFileName);
} }
}
// stream the file back to the client // stream the file back to the client
contentStreamer.streamContent(req, res, auditTrail, null, attach, attachFileName, null); contentStreamer.streamContent(req, res, auditTrail, null, attach, attachFileName, null);

View File

@@ -103,14 +103,18 @@ public class AuditLogPost extends BaseAuditRetrievalWebScript
} }
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{
logger.debug("Filing audit trail as record in record folder: " + destination); logger.debug("Filing audit trail as record in record folder: " + destination);
}
// parse the other parameters and get a file containing the audit trail // parse the other parameters and get a file containing the audit trail
NodeRef record = this.rmAuditService.fileAuditTrailAsRecord(parseQueryParameters(req), NodeRef record = this.rmAuditService.fileAuditTrailAsRecord(parseQueryParameters(req),
destination, parseReportFormat(req)); destination, parseReportFormat(req));
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{
logger.debug("Filed audit trail as new record: " + record); logger.debug("Filed audit trail as new record: " + record);
}
// return success flag and record noderef as JSON // return success flag and record noderef as JSON
JSONObject responseJSON = new JSONObject(); JSONObject responseJSON = new JSONObject();

View File

@@ -152,15 +152,19 @@ public class BaseAuditRetrievalWebScript extends StreamContent
{ {
// log a warning // log a warning
if (logger.isWarnEnabled()) if (logger.isWarnEnabled())
{
logger.warn("Failed to parse JSON parameters for audit query: " + ioe.getMessage()); logger.warn("Failed to parse JSON parameters for audit query: " + ioe.getMessage());
} }
}
catch (JSONException je) catch (JSONException je)
{ {
// log a warning // log a warning
if (logger.isWarnEnabled()) if (logger.isWarnEnabled())
{
logger.warn("Failed to parse JSON parameters for audit query: " + je.getMessage()); logger.warn("Failed to parse JSON parameters for audit query: " + je.getMessage());
} }
} }
}
else else
{ {
size = req.getParameter(PARAM_SIZE); size = req.getParameter(PARAM_SIZE);
@@ -185,9 +189,11 @@ public class BaseAuditRetrievalWebScript extends StreamContent
catch (NumberFormatException nfe) catch (NumberFormatException nfe)
{ {
if (logger.isWarnEnabled()) if (logger.isWarnEnabled())
{
logger.warn("Ignoring size parameter as '" + size + "' is not a number!"); logger.warn("Ignoring size parameter as '" + size + "' is not a number!");
} }
} }
}
if (from != null && from.length() > 0) if (from != null && from.length() > 0)
{ {
@@ -199,9 +205,11 @@ public class BaseAuditRetrievalWebScript extends StreamContent
catch (ParseException pe) catch (ParseException pe)
{ {
if (logger.isWarnEnabled()) if (logger.isWarnEnabled())
{
logger.warn("Ignoring from parameter as '" + from + "' does not conform to the date pattern: " + DATE_PATTERN); logger.warn("Ignoring from parameter as '" + from + "' does not conform to the date pattern: " + DATE_PATTERN);
} }
} }
}
if (to != null && to.length() > 0) if (to != null && to.length() > 0)
{ {
@@ -213,9 +221,11 @@ public class BaseAuditRetrievalWebScript extends StreamContent
catch (ParseException pe) catch (ParseException pe)
{ {
if (logger.isWarnEnabled()) if (logger.isWarnEnabled())
{
logger.warn("Ignoring to parameter as '" + to + "' does not conform to the date pattern: " + DATE_PATTERN); logger.warn("Ignoring to parameter as '" + to + "' does not conform to the date pattern: " + DATE_PATTERN);
} }
} }
}
if (property != null && property.length() > 0) if (property != null && property.length() > 0)
{ {

View File

@@ -89,7 +89,9 @@ public abstract class BaseTransferWebScript extends StreamACP
NodeRef filePlan = new NodeRef(new StoreRef(storeType, storeId), nodeId); NodeRef filePlan = new NodeRef(new StoreRef(storeType, storeId), nodeId);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{
logger.debug("Retrieving transfer '" + transferId + "' from file plan: " + filePlan); logger.debug("Retrieving transfer '" + transferId + "' from file plan: " + filePlan);
}
// ensure the file plan exists // ensure the file plan exists
if (!this.nodeService.exists(filePlan)) if (!this.nodeService.exists(filePlan))

View File

@@ -158,7 +158,9 @@ public class ExportPost extends StreamACP
if (tempACPFile != null) if (tempACPFile != null)
{ {
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{
logger.debug("Deleting temporary archive: " + tempACPFile.getAbsolutePath()); logger.debug("Deleting temporary archive: " + tempACPFile.getAbsolutePath());
}
tempACPFile.delete(); tempACPFile.delete();
} }

View File

@@ -206,7 +206,9 @@ public class ImportPost extends DeclarativeWebScript
FileCopyUtils.copy(acpContent.getInputStream(), fos); // NOTE: this method closes both streams FileCopyUtils.copy(acpContent.getInputStream(), fos); // NOTE: this method closes both streams
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{
logger.debug("Importing uploaded ACP (" + acpFile.getAbsolutePath() + ") into " + nodeRef); logger.debug("Importing uploaded ACP (" + acpFile.getAbsolutePath() + ") into " + nodeRef);
}
// setup the import handler // setup the import handler
final ACPImportPackageHandler importHandler = new ACPImportPackageHandler(acpFile, "UTF-8"); final ACPImportPackageHandler importHandler = new ACPImportPackageHandler(acpFile, "UTF-8");

View File

@@ -170,7 +170,9 @@ public class TransferReportPost extends BaseTransferWebScript
} }
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{
logger.debug("Filing transfer report as record in record folder: " + destination); logger.debug("Filing transfer report as record in record folder: " + destination);
}
// generate the report (will be in JSON format) // generate the report (will be in JSON format)
report = generateHTMLTransferReport(transferNode); report = generateHTMLTransferReport(transferNode);
@@ -179,7 +181,9 @@ public class TransferReportPost extends BaseTransferWebScript
NodeRef record = fileTransferReport(report, destination); NodeRef record = fileTransferReport(report, destination);
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())
{
logger.debug("Filed transfer report as new record: " + record); logger.debug("Filed transfer report as new record: " + record);
}
// return success flag and record noderef as JSON // return success flag and record noderef as JSON
JSONObject responseJSON = new JSONObject(); JSONObject responseJSON = new JSONObject();

View File

@@ -145,7 +145,10 @@ public class SavedSearchDetails extends ReportDetails
{ {
description = search.getString(DESCRIPTION); description = search.getString(DESCRIPTION);
String translated = I18NUtil.getMessage(description); String translated = I18NUtil.getMessage(description);
if (translated!=null ) description = translated; if (translated != null)
{
description = translated;
}
} }
// Get the query // Get the query