RM-5345: Fixed review comments

This commit is contained in:
Tuna Aksoy
2017-06-28 16:03:38 +01:00
parent 0ff080f305
commit f86440be72
5 changed files with 23 additions and 85 deletions

View File

@@ -773,14 +773,12 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
{ {
ParameterCheck.mandatory("params", params); ParameterCheck.mandatory("params", params);
Writer fileWriter = null; File auditTrailFile = TempFileProvider.createTempFile(AUDIT_TRAIL_FILE_PREFIX,
FileOutputStream fileOutputStream = null; format == ReportFormat.HTML ? AUDIT_TRAIL_HTML_FILE_SUFFIX : AUDIT_TRAIL_JSON_FILE_SUFFIX);
try
try (FileOutputStream fileOutputStream = new FileOutputStream(auditTrailFile);
Writer fileWriter = new BufferedWriter(new OutputStreamWriter(fileOutputStream,"UTF8"));)
{ {
File auditTrailFile = TempFileProvider.createTempFile(AUDIT_TRAIL_FILE_PREFIX,
format == ReportFormat.HTML ? AUDIT_TRAIL_HTML_FILE_SUFFIX : AUDIT_TRAIL_JSON_FILE_SUFFIX);
fileOutputStream = new FileOutputStream(auditTrailFile);
fileWriter = new BufferedWriter(new OutputStreamWriter(fileOutputStream,"UTF8"));
// Get the results, dumping to file // Get the results, dumping to file
getAuditTrailImpl(params, null, fileWriter, format); getAuditTrailImpl(params, null, fileWriter, format);
// Done // Done
@@ -790,19 +788,6 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
{ {
throw new AlfrescoRuntimeException(MSG_TRAIL_FILE_FAIL, e); throw new AlfrescoRuntimeException(MSG_TRAIL_FILE_FAIL, e);
} }
finally
{
// close the file output stream
if (fileOutputStream != null)
{
try { fileOutputStream.close(); } catch (IOException closeEx) {}
}
// close the writer
if (fileWriter != null)
{
try { fileWriter.close(); } catch (IOException closeEx) {}
}
}
} }
/** /**

View File

@@ -214,7 +214,7 @@ public class RMAfterInvocationProvider extends RMSecurityCommon
} }
else else
{ {
if (logger.isDebugEnabled() && object.getClass() != null) if (logger.isDebugEnabled() && object != null)
{ {
logger.debug("Uncontrolled object - access allowed for " + object.getClass().getName()); logger.debug("Uncontrolled object - access allowed for " + object.getClass().getName());
} }

View File

@@ -51,8 +51,8 @@ import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.ContentWriter; import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeRef; import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.NamespaceService; import org.alfresco.service.namespace.NamespaceService;
import org.apache.commons.logging.Log; import org.slf4j.Logger;
import org.apache.commons.logging.LogFactory; import org.slf4j.LoggerFactory;
import org.springframework.extensions.webscripts.Cache; import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.DeclarativeWebScript; import org.springframework.extensions.webscripts.DeclarativeWebScript;
import org.springframework.extensions.webscripts.Status; import org.springframework.extensions.webscripts.Status;
@@ -81,7 +81,7 @@ public class ApplyDodCertModelFixesGet extends DeclarativeWebScript
private static final String RMC_CUSTOM_RECORD_PROPERTIES = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customRecordProperties"; private static final String RMC_CUSTOM_RECORD_PROPERTIES = RecordsManagementCustomModel.RM_CUSTOM_PREFIX + ":customRecordProperties";
/** Logger */ /** Logger */
private static Log logger = LogFactory.getLog(ApplyDodCertModelFixesGet.class); private static final Logger LOGGER = LoggerFactory.getLogger(ApplyDodCertModelFixesGet.class);
private ContentService contentService; private ContentService contentService;
private NamespaceService namespaceService; private NamespaceService namespaceService;
@@ -99,19 +99,13 @@ public class ApplyDodCertModelFixesGet extends DeclarativeWebScript
@Override @Override
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{ {
if (logger.isInfoEnabled()) LOGGER.info("Applying webscript-based patches to RM custom model in the repo.");
{
logger.info("Applying webscript-based patches to RM custom model in the repo.");
}
M2Model customModel = readCustomContentModel(); M2Model customModel = readCustomContentModel();
if (customModel == null) if (customModel == null)
{ {
final String msg = "Custom content model could not be read"; final String msg = "Custom content model could not be read";
if (logger.isErrorEnabled()) LOGGER.error(msg);
{
logger.error(msg);
}
throw new AlfrescoRuntimeException(msg); throw new AlfrescoRuntimeException(msg);
} }
@@ -121,19 +115,12 @@ public class ApplyDodCertModelFixesGet extends DeclarativeWebScript
if (customAssocsAspect == null) if (customAssocsAspect == null)
{ {
final String msg = "Unknown aspect: " + customAspectName; final String msg = "Unknown aspect: " + customAspectName;
if (logger.isErrorEnabled()) LOGGER.error(msg);
{
logger.error(msg);
}
throw new AlfrescoRuntimeException(msg); throw new AlfrescoRuntimeException(msg);
} }
// MOB-1573. All custom references should have many-many multiplicity. // MOB-1573. All custom references should have many-many multiplicity.
if (logger.isInfoEnabled()) LOGGER.info("MOB-1573. All custom references should have many-many multiplicity.");
{
logger.info("MOB-1573. All custom references should have many-many multiplicity.");
}
for (M2ClassAssociation classAssoc : customAssocsAspect.getAssociations()) for (M2ClassAssociation classAssoc : customAssocsAspect.getAssociations())
{ {
@@ -143,10 +130,7 @@ public class ApplyDodCertModelFixesGet extends DeclarativeWebScript
} }
//MOB-1621. Custom fields should be created as untokenized by default. //MOB-1621. Custom fields should be created as untokenized by default.
if (logger.isInfoEnabled()) LOGGER.info("MOB-1621. Custom fields should be created as untokenized by default.");
{
logger.info("MOB-1621. Custom fields should be created as untokenized by default.");
}
List<String> allCustomPropertiesAspects = new ArrayList<String>(4); List<String> allCustomPropertiesAspects = new ArrayList<String>(4);
allCustomPropertiesAspects.add(RMC_CUSTOM_RECORD_SERIES_PROPERTIES); allCustomPropertiesAspects.add(RMC_CUSTOM_RECORD_SERIES_PROPERTIES);
@@ -169,10 +153,7 @@ public class ApplyDodCertModelFixesGet extends DeclarativeWebScript
writeCustomContentModel(customModel); writeCustomContentModel(customModel);
if (logger.isInfoEnabled()) LOGGER.info("Completed application of webscript-based patches to RM custom model in the repo.");
{
logger.info("Completed application of webscript-based patches to RM custom model in the repo.");
}
Map<String, Object> model = new HashMap<String, Object>(1, 1.0f); Map<String, Object> model = new HashMap<String, Object>(1, 1.0f);
model.put("success", true); model.put("success", true);

View File

@@ -126,9 +126,10 @@ public class TransferReportGet extends BaseTransferWebScript
File generateJSONTransferReport(NodeRef transferNode) throws IOException File generateJSONTransferReport(NodeRef transferNode) throws IOException
{ {
File report = TempFileProvider.createTempFile(REPORT_FILE_PREFIX, REPORT_FILE_SUFFIX); File report = TempFileProvider.createTempFile(REPORT_FILE_PREFIX, REPORT_FILE_SUFFIX);
Writer writer = null;
FileOutputStream fileOutputStream = null; // create the writer
try try (FileOutputStream fileOutputStream = new FileOutputStream(report);
Writer writer = new OutputStreamWriter(fileOutputStream, Charset.forName("UTF-8"));)
{ {
// get all 'transferred' nodes // get all 'transferred' nodes
NodeRef[] itemsToTransfer = getTransferNodes(transferNode); NodeRef[] itemsToTransfer = getTransferNodes(transferNode);
@@ -139,10 +140,6 @@ public class TransferReportGet extends BaseTransferWebScript
" items into file: " + report.getAbsolutePath()); " items into file: " + report.getAbsolutePath());
} }
// create the writer
fileOutputStream = new FileOutputStream(report);
writer = new OutputStreamWriter(fileOutputStream, Charset.forName("UTF-8"));
// use RMService to get disposition authority // use RMService to get disposition authority
String dispositionAuthority = null; String dispositionAuthority = null;
if (itemsToTransfer.length > 0) if (itemsToTransfer.length > 0)
@@ -172,17 +169,6 @@ public class TransferReportGet extends BaseTransferWebScript
// write the JSON footer // write the JSON footer
writer.write("\n\t\t]\n\t}\n}"); writer.write("\n\t\t]\n\t}\n}");
} }
finally
{
if (fileOutputStream != null)
{
try { fileOutputStream.close(); } catch (IOException ioe) {}
}
if (writer != null)
{
try { writer.close(); } catch (IOException ioe) {}
}
}
return report; return report;
} }

View File

@@ -234,9 +234,10 @@ public class TransferReportPost extends BaseTransferWebScript
File generateHTMLTransferReport(NodeRef transferNode) throws IOException File generateHTMLTransferReport(NodeRef transferNode) throws IOException
{ {
File report = TempFileProvider.createTempFile(REPORT_FILE_PREFIX, REPORT_FILE_SUFFIX); File report = TempFileProvider.createTempFile(REPORT_FILE_PREFIX, REPORT_FILE_SUFFIX);
Writer writer = null;
FileOutputStream fileOutputStream = null; // create the writer
try try (FileOutputStream fileOutputStream = new FileOutputStream(report) ;
Writer writer = new OutputStreamWriter(fileOutputStream, Charset.forName("UTF-8"));)
{ {
// get all 'transferred' nodes // get all 'transferred' nodes
NodeRef[] itemsToTransfer = getTransferNodes(transferNode); NodeRef[] itemsToTransfer = getTransferNodes(transferNode);
@@ -247,10 +248,6 @@ public class TransferReportPost extends BaseTransferWebScript
" items into file: " + report.getAbsolutePath()); " items into file: " + report.getAbsolutePath());
} }
// create the writer
fileOutputStream = new FileOutputStream(report);
writer = new OutputStreamWriter(fileOutputStream, Charset.forName("UTF-8"));
// use RMService to get disposition authority // use RMService to get disposition authority
String dispositionAuthority = null; String dispositionAuthority = null;
if (itemsToTransfer.length > 0) if (itemsToTransfer.length > 0)
@@ -324,17 +321,6 @@ public class TransferReportPost extends BaseTransferWebScript
// write the HTML footer // write the HTML footer
writer.write("</body></html>"); writer.write("</body></html>");
} }
finally
{
if (fileOutputStream != null)
{
try { fileOutputStream.close(); } catch (IOException ioe) {}
}
if (writer != null)
{
try { writer.close(); } catch (IOException ioe) {}
}
}
return report; return report;
} }