mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-3960: did most of the review mentioned improvements
This commit is contained in:
@@ -55,4 +55,5 @@ log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=info
|
|||||||
#
|
#
|
||||||
# Job debug
|
# Job debug
|
||||||
#
|
#
|
||||||
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug
|
#log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug
|
||||||
|
log4j.logger.org.alfresco.repo.web.scripts.roles.DynamicAuthoritiesGet=info
|
@@ -39,6 +39,7 @@ import org.alfresco.service.cmr.security.PermissionService;
|
|||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.transaction.TransactionService;
|
import org.alfresco.service.transaction.TransactionService;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.extensions.webscripts.Cache;
|
import org.springframework.extensions.webscripts.Cache;
|
||||||
@@ -103,14 +104,11 @@ public class DynamicAuthoritiesGet extends DeclarativeWebScript implements Recor
|
|||||||
String totalToBeProcessedRecordsStr = req.getParameter(TOTAL_NUMBER_TO_PROCESS);
|
String totalToBeProcessedRecordsStr = req.getParameter(TOTAL_NUMBER_TO_PROCESS);
|
||||||
|
|
||||||
Long size = 0L;
|
Long size = 0L;
|
||||||
if (batchSizeStr == null || batchSizeStr.length() == 0)
|
if (StringUtils.isBlank(batchSizeStr))
|
||||||
{
|
{
|
||||||
model.put(MODEL_STATUS, FAILED_STATUS);
|
model.put(MODEL_STATUS, FAILED_STATUS);
|
||||||
model.put(MODEL_MESSAGE, MESSAGE_BATCHSIZE_IS_MANDATORY);
|
model.put(MODEL_MESSAGE, MESSAGE_BATCHSIZE_IS_MANDATORY);
|
||||||
if (logger.isDebugEnabled())
|
logger.info(MESSAGE_BATCHSIZE_IS_MANDATORY);
|
||||||
{
|
|
||||||
logger.debug(MESSAGE_BATCHSIZE_IS_MANDATORY);
|
|
||||||
}
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
@@ -121,10 +119,7 @@ public class DynamicAuthoritiesGet extends DeclarativeWebScript implements Recor
|
|||||||
{
|
{
|
||||||
model.put(MODEL_STATUS, FAILED_STATUS);
|
model.put(MODEL_STATUS, FAILED_STATUS);
|
||||||
model.put(MODEL_MESSAGE, MESSAGE_BATCHSIZE_IS_INVALID);
|
model.put(MODEL_MESSAGE, MESSAGE_BATCHSIZE_IS_INVALID);
|
||||||
if (logger.isDebugEnabled())
|
logger.info(MESSAGE_BATCHSIZE_IS_INVALID);
|
||||||
{
|
|
||||||
logger.debug(MESSAGE_BATCHSIZE_IS_INVALID);
|
|
||||||
}
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
final Long batchSize = size;
|
final Long batchSize = size;
|
||||||
@@ -135,15 +130,12 @@ public class DynamicAuthoritiesGet extends DeclarativeWebScript implements Recor
|
|||||||
{
|
{
|
||||||
model.put(MODEL_STATUS, SUCCESS_STATUS);
|
model.put(MODEL_STATUS, SUCCESS_STATUS);
|
||||||
model.put(MODEL_MESSAGE, MESSAGE_NO_RECORDS_TO_PROCESS);
|
model.put(MODEL_MESSAGE, MESSAGE_NO_RECORDS_TO_PROCESS);
|
||||||
if (logger.isDebugEnabled())
|
logger.info(MESSAGE_NO_RECORDS_TO_PROCESS);
|
||||||
{
|
|
||||||
logger.debug(MESSAGE_NO_RECORDS_TO_PROCESS);
|
|
||||||
}
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
Long totalNumberOfRecordsToProcess = 0L;
|
Long totalNumberOfRecordsToProcess = 0L;
|
||||||
if (totalToBeProcessedRecordsStr != null && totalToBeProcessedRecordsStr.length() != 0)
|
if (StringUtils.isNotBlank(totalToBeProcessedRecordsStr))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -157,10 +149,7 @@ public class DynamicAuthoritiesGet extends DeclarativeWebScript implements Recor
|
|||||||
|
|
||||||
final Long maxRecordsToProcess = totalNumberOfRecordsToProcess;
|
final Long maxRecordsToProcess = totalNumberOfRecordsToProcess;
|
||||||
final List<NodeRef> processedNodes = new ArrayList<NodeRef>();
|
final List<NodeRef> processedNodes = new ArrayList<NodeRef>();
|
||||||
if (logger.isDebugEnabled())
|
logger.info(MESSAGE_PROCESSING_BEGIN);
|
||||||
{
|
|
||||||
logger.debug(MESSAGE_PROCESSING_BEGIN);
|
|
||||||
}
|
|
||||||
// by batch size
|
// by batch size
|
||||||
for (Long i = 0L; i < maxNodeId; i+=batchSize)
|
for (Long i = 0L; i < maxNodeId; i+=batchSize)
|
||||||
{
|
{
|
||||||
@@ -185,15 +174,10 @@ public class DynamicAuthoritiesGet extends DeclarativeWebScript implements Recor
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
NodeRef record = nodeDAO.getNodePair(nodeId).getSecond();
|
NodeRef record = nodeDAO.getNodePair(nodeId).getSecond();
|
||||||
if (logger.isDebugEnabled())
|
String recordName = (String) nodeService.getProperty(record, ContentModel.PROP_NAME);
|
||||||
{
|
logger.info(MessageFormat.format(MESSAGE_PROCESSING_RECORD_BEGIN_TEMPLATE, recordName));
|
||||||
logger.debug(MessageFormat.format(MESSAGE_PROCESSING_RECORD_BEGIN_TEMPLATE, (String) nodeService.getProperty(record, ContentModel.PROP_NAME)));
|
|
||||||
}
|
|
||||||
processNode(record);
|
processNode(record);
|
||||||
if (logger.isDebugEnabled())
|
logger.info(MessageFormat.format(MESSAGE_PROCESSING_RECORD_END_TEMPLATE, recordName));
|
||||||
{
|
|
||||||
logger.debug(MessageFormat.format(MESSAGE_PROCESSING_RECORD_END_TEMPLATE, (String) nodeService.getProperty(record, ContentModel.PROP_NAME)));
|
|
||||||
}
|
|
||||||
processedNodes.add(record);
|
processedNodes.add(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,10 +187,7 @@ public class DynamicAuthoritiesGet extends DeclarativeWebScript implements Recor
|
|||||||
false, // read only
|
false, // read only
|
||||||
true); // requires new
|
true); // requires new
|
||||||
}
|
}
|
||||||
if (logger.isDebugEnabled())
|
logger.info(MESSAGE_PROCESSING_END);
|
||||||
{
|
|
||||||
logger.debug(MESSAGE_PROCESSING_END);
|
|
||||||
}
|
|
||||||
int processedNodesSize = processedNodes.size();
|
int processedNodesSize = processedNodes.size();
|
||||||
String message = "";
|
String message = "";
|
||||||
if(totalNumberOfRecordsToProcess == 0 || (totalNumberOfRecordsToProcess > 0 && processedNodesSize < totalNumberOfRecordsToProcess))
|
if(totalNumberOfRecordsToProcess == 0 || (totalNumberOfRecordsToProcess > 0 && processedNodesSize < totalNumberOfRecordsToProcess))
|
||||||
@@ -219,10 +200,7 @@ public class DynamicAuthoritiesGet extends DeclarativeWebScript implements Recor
|
|||||||
}
|
}
|
||||||
model.put(MODEL_STATUS, SUCCESS_STATUS);
|
model.put(MODEL_STATUS, SUCCESS_STATUS);
|
||||||
model.put(MODEL_MESSAGE, message);
|
model.put(MODEL_MESSAGE, message);
|
||||||
if (logger.isDebugEnabled())
|
logger.info(message);
|
||||||
{
|
|
||||||
logger.debug(message);
|
|
||||||
}
|
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user