diff --git a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml
index 4657373e41..e1deb70752 100644
--- a/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml
+++ b/rm-server/config/alfresco/module/org_alfresco_module_rm/rm-webscript-context.xml
@@ -597,6 +597,7 @@
+
diff --git a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/roles/rm-dynamicauthorities.get.desc.xml b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/roles/rm-dynamicauthorities.get.desc.xml
index 7f77ed80ab..6cf7174dff 100644
--- a/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/roles/rm-dynamicauthorities.get.desc.xml
+++ b/rm-server/config/alfresco/templates/webscripts/org/alfresco/repository/roles/rm-dynamicauthorities.get.desc.xml
@@ -2,12 +2,13 @@
Removes dynamic authorities
- URL parameter batchsize is mandatory, and represents the number of records that are processed in one transaction.
+ URL parameter batchsize is mandatory, and represents the maximum number of records that can be processed in one transaction.
URL parameter maxProcessedRecords is optional, and represents the maximum number of records that will be processed in one request.
- URL parameter export is optional, and if the it's value is true, will export the processed records into a csv file.
+ URL parameter export is optional, and if the it's value is true, will export the processed records into a csv file.
+ URL parameter parentNodeRef is optional, and represents the nodeRef of the folder that contains the records to be processed.
]]>
- /api/rm/rm-dynamicauthorities?batchsize={batchsize}&maxProcessedRecords={maxProcessedRecords?}&export={export?}
+ /api/rm/rm-dynamicauthorities?batchsize={batchsize}&maxProcessedRecords={maxProcessedRecords?}&export={export?}&parentNodeRef={parentNodeRef?}
argument
admin
required
diff --git a/rm-server/source/java/org/alfresco/repo/web/scripts/roles/DynamicAuthoritiesGet.java b/rm-server/source/java/org/alfresco/repo/web/scripts/roles/DynamicAuthoritiesGet.java
index d957ccdd1b..78014bbdb3 100644
--- a/rm-server/source/java/org/alfresco/repo/web/scripts/roles/DynamicAuthoritiesGet.java
+++ b/rm-server/source/java/org/alfresco/repo/web/scripts/roles/DynamicAuthoritiesGet.java
@@ -25,12 +25,13 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
import javax.servlet.http.HttpServletResponse;
import org.alfresco.model.ContentModel;
@@ -43,121 +44,131 @@ import org.alfresco.repo.domain.patch.PatchDAO;
import org.alfresco.repo.domain.qname.QNameDAO;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.web.scripts.content.ContentStreamer;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.repository.NodeService;
-import org.alfresco.service.cmr.security.PermissionService;
-import org.alfresco.service.namespace.QName;
-import org.alfresco.service.transaction.TransactionService;
-import org.alfresco.util.Pair;
+import org.alfresco.service.cmr.model.FileFolderService;
+import org.alfresco.service.cmr.model.FileInfo;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.repository.NodeService;
+import org.alfresco.service.cmr.security.PermissionService;
+import org.alfresco.service.namespace.QName;
+import org.alfresco.service.transaction.TransactionService;
+import org.alfresco.util.Pair;
import org.alfresco.util.TempFileProvider;
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.webscripts.AbstractWebScript;
-import org.springframework.extensions.webscripts.Cache;
+import org.springframework.extensions.webscripts.Cache;
import org.springframework.extensions.webscripts.Format;
-import org.springframework.extensions.webscripts.Status;
+import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptException;
-import org.springframework.extensions.webscripts.WebScriptRequest;
+import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
-
-/**
- * Webscript used for removing dynamic authorities from the records.
- *
- * @author Silviu Dinuta
- * @since 2.3.0.7
- */
-@SuppressWarnings("deprecation")
+
+/**
+ * Webscript used for removing dynamic authorities from the records.
+ *
+ * @author Silviu Dinuta
+ * @since 2.3.0.7
+ */
+@SuppressWarnings("deprecation")
public class DynamicAuthoritiesGet extends AbstractWebScript implements RecordsManagementModel
-{
- private static final String MESSAGE_PARAMETER_BATCHSIZE_GREATER_THAN_ZERO = "Parameter batchsize should be a number greater than 0.";
- private static final String MESSAGE_PROCESSING_BEGIN = "Processing - BEGIN";
- private static final String MESSAGE_PROCESSING_END = "Processing - END";
- private static final String MESSAGE_PROCESSING_RECORD_END_TEMPLATE = "Processing record {0} - END";
- private static final String MESSAGE_PROCESSING_RECORD_BEGIN_TEMPLATE = "Processing record {0} - BEGIN";
- private static final String MESSAGE_BATCHSIZE_IS_INVALID = "Parameter batchsize is invalid.";
- private static final String MESSAGE_BATCHSIZE_IS_MANDATORY = "Parameter batchsize is mandatory";
- private static final String SUCCESS_STATUS = "success";
- /**
- * The logger
- */
- private static Log logger = LogFactory.getLog(DynamicAuthoritiesGet.class);
- private static final String BATCH_SIZE = "batchsize";
- private static final String TOTAL_NUMBER_TO_PROCESS = "maxProcessedRecords";
+{
+ private static final String MESSAGE_PARAMETER_BATCHSIZE_GREATER_THAN_ZERO = "Parameter batchsize should be a number greater than 0.";
+ private static final String MESSAGE_PROCESSING_BEGIN = "Processing - BEGIN";
+ private static final String MESSAGE_PROCESSING_END = "Processing - END";
+ private static final String MESSAGE_PROCESSING_RECORD_END_TEMPLATE = "Processing record {0} - END";
+ private static final String MESSAGE_PROCESSING_RECORD_BEGIN_TEMPLATE = "Processing record {0} - BEGIN";
+ private static final String MESSAGE_BATCHSIZE_IS_INVALID = "Parameter batchsize is invalid.";
+ private static final String MESSAGE_BATCHSIZE_IS_MANDATORY = "Parameter batchsize is mandatory";
+ private static final String MESSAGE_NODE_REF_DOES_NOT_EXIST_TEMPLATE = "Parameter parentNodeRef = {0} does not exist.";
+ private static final String SUCCESS_STATUS = "success";
+ /**
+ * The logger
+ */
+ private static Log logger = LogFactory.getLog(DynamicAuthoritiesGet.class);
+ private static final String BATCH_SIZE = "batchsize";
+ private static final String TOTAL_NUMBER_TO_PROCESS = "maxProcessedRecords";
private static final String PARAM_EXPORT = "export";
- private static final String MODEL_STATUS = "responsestatus";
- private static final String MODEL_MESSAGE = "message";
- private static final String MESSAGE_ALL_TEMPLATE = "Processed {0} records.";
- private static final String MESSAGE_PARTIAL_TEMPLATE = "Processed first {0} records.";
- private static final String MESSAGE_NO_RECORDS_TO_PROCESS = "There where no records to be processed.";
-
-
- /** services */
- private PatchDAO patchDAO;
- private NodeDAO nodeDAO;
- private QNameDAO qnameDAO;
- private NodeService nodeService;
- private PermissionService permissionService;
- private ExtendedSecurityService extendedSecurityService;
- private TransactionService transactionService;
+ private static final String PARAM_PARENT_NODE_REF = "parentNodeRef";
+ private static final String MODEL_STATUS = "responsestatus";
+ private static final String MODEL_MESSAGE = "message";
+ private static final String MESSAGE_ALL_TEMPLATE = "Processed {0} records.";
+ private static final String MESSAGE_PARTIAL_TEMPLATE = "Processed first {0} records.";
+ private static final String MESSAGE_NO_RECORDS_TO_PROCESS = "There where no records to be processed.";
+
+ /** services */
+ private PatchDAO patchDAO;
+ private NodeDAO nodeDAO;
+ private QNameDAO qnameDAO;
+ private NodeService nodeService;
+ private PermissionService permissionService;
+ private ExtendedSecurityService extendedSecurityService;
+ private TransactionService transactionService;
/** Content Streamer */
protected ContentStreamer contentStreamer;
+ private FileFolderService fileFolderService;
+
/** service setters */
public void setPatchDAO(PatchDAO patchDAO)
{
this.patchDAO = patchDAO;
}
-
+
public void setNodeDAO(NodeDAO nodeDAO)
{
this.nodeDAO = nodeDAO;
}
-
+
public void setQnameDAO(QNameDAO qnameDAO)
- {
+ {
this.qnameDAO = qnameDAO;
}
-
+
public void setNodeService(NodeService nodeService)
- {
+ {
this.nodeService = nodeService;
- }
+ }
public void setPermissionService(PermissionService permissionService)
- {
+ {
this.permissionService = permissionService;
}
public void setExtendedSecurityService(ExtendedSecurityService extendedSecurityService)
- {
+ {
this.extendedSecurityService = extendedSecurityService;
- }
+ }
public void setTransactionService(TransactionService transactionService)
{
this.transactionService = transactionService;
- }
+ }
public void setContentStreamer(ContentStreamer contentStreamer)
- {
+ {
this.contentStreamer = contentStreamer;
- }
+ }
+
+ public void setFileFolderService(FileFolderService fileFolderService)
+ {
+ this.fileFolderService = fileFolderService;
+ }
protected Map buildModel(WebScriptRequest req, WebScriptResponse res) throws IOException
{
Map model = new HashMap();
final Long batchSize = getBatchSizeParameter(req);
- // get the max node id and the extended security aspect
- Long maxNodeId = patchDAO.getMaxAdmNodeID();
- final Pair recordAspectPair = qnameDAO.getQName(ASPECT_EXTENDED_SECURITY);
- if(recordAspectPair == null)
- {
- model.put(MODEL_STATUS, SUCCESS_STATUS);
- model.put(MODEL_MESSAGE, MESSAGE_NO_RECORDS_TO_PROCESS);
- logger.info(MESSAGE_NO_RECORDS_TO_PROCESS);
- return model;
- }
-
+ // get the max node id and the extended security aspect
+ Long maxNodeId = patchDAO.getMaxAdmNodeID();
+ final Pair recordAspectPair = qnameDAO.getQName(ASPECT_EXTENDED_SECURITY);
+ if (recordAspectPair == null)
+ {
+ model.put(MODEL_STATUS, SUCCESS_STATUS);
+ model.put(MODEL_MESSAGE, MESSAGE_NO_RECORDS_TO_PROCESS);
+ logger.info(MESSAGE_NO_RECORDS_TO_PROCESS);
+ return model;
+ }
+
Long totalNumberOfRecordsToProcess = getMaxToProccessParameter(req, batchSize);
boolean attach = getExportParameter(req);
@@ -168,8 +179,17 @@ public class DynamicAuthoritiesGet extends AbstractWebScript implements RecordsM
List processedNodes = new ArrayList();
try
{
- processedNodes = processNodes(batchSize, maxNodeId, recordAspectPair, totalNumberOfRecordsToProcess, out,
- attach);
+ NodeRef parentNodeRef = getParentNodeRefParameter(req);
+ if (parentNodeRef != null)
+ {
+ processedNodes = processChildrenNodes(parentNodeRef, batchSize.intValue(), recordAspectPair,
+ totalNumberOfRecordsToProcess.intValue(), out, attach);
+ }
+ else
+ {
+ processedNodes = processNodes(batchSize, maxNodeId, recordAspectPair, totalNumberOfRecordsToProcess,
+ out, attach);
+ }
}
finally
{
@@ -213,6 +233,7 @@ public class DynamicAuthoritiesGet extends AbstractWebScript implements RecordsM
/**
* Get export parameter from the request
+ *
* @param req
* @return
*/
@@ -241,19 +262,14 @@ public class DynamicAuthoritiesGet extends AbstractWebScript implements RecordsM
try
{
String mimetype = getContainer().getFormatRegistry().getMimeType(req.getAgent(), format);
- if (mimetype == null)
- {
- throw new WebScriptException("Web Script format '" + format + "' is not registered");
- }
+ if (mimetype == null) { throw new WebScriptException(
+ "Web Script format '" + format + "' is not registered"); }
// construct model for script / template
Status status = new Status();
Cache cache = new Cache(getDescription().getRequiredCache());
Map model = buildModel(req, res);
- if (model == null)
- {
- return;
- }
+ if (model == null) { return; }
model.put("status", status);
model.put("cache", cache);
@@ -346,19 +362,19 @@ public class DynamicAuthoritiesGet extends AbstractWebScript implements RecordsM
protected Long getMaxToProccessParameter(WebScriptRequest req, final Long batchSize)
{
String totalToBeProcessedRecordsStr = req.getParameter(TOTAL_NUMBER_TO_PROCESS);
- //default total number of records to be processed to batch size value
- Long totalNumberOfRecordsToProcess = batchSize;
- if (StringUtils.isNotBlank(totalToBeProcessedRecordsStr))
- {
- try
- {
- totalNumberOfRecordsToProcess = Long.parseLong(totalToBeProcessedRecordsStr);
- }
- catch(NumberFormatException ex)
- {
- //do nothing here, the value will remain 0L in this case
- }
- }
+ // default total number of records to be processed to batch size value
+ Long totalNumberOfRecordsToProcess = batchSize;
+ if (StringUtils.isNotBlank(totalToBeProcessedRecordsStr))
+ {
+ try
+ {
+ totalNumberOfRecordsToProcess = Long.parseLong(totalToBeProcessedRecordsStr);
+ }
+ catch (NumberFormatException ex)
+ {
+ // do nothing here, the value will remain 0L in this case
+ }
+ }
return totalNumberOfRecordsToProcess;
}
@@ -393,7 +409,30 @@ public class DynamicAuthoritiesGet extends AbstractWebScript implements RecordsM
}
return size;
}
-
+
+ /**
+ * Get parentNodeRef parameter from the request
+ *
+ * @param req
+ * @return
+ */
+ protected NodeRef getParentNodeRefParameter(WebScriptRequest req)
+ {
+ String parentNodeRefStr = req.getParameter(PARAM_PARENT_NODE_REF);
+ NodeRef parentNodeRef = null;
+ if (StringUtils.isNotBlank(parentNodeRefStr))
+ {
+ parentNodeRef = new NodeRef(parentNodeRefStr);
+ if(!nodeService.exists(parentNodeRef))
+ {
+ String message = MessageFormat.format(MESSAGE_NODE_REF_DOES_NOT_EXIST_TEMPLATE, parentNodeRef.toString());
+ logger.info(message);
+ throw new WebScriptException(Status.STATUS_BAD_REQUEST, message);
+ }
+ }
+ return parentNodeRef;
+ }
+
/**
* Process nodes all nodes or the maximum number of nodes specified by batchsize or totalNumberOfRecordsToProcess
* parameters
@@ -407,81 +446,146 @@ public class DynamicAuthoritiesGet extends AbstractWebScript implements RecordsM
protected List processNodes(final Long batchSize, Long maxNodeId, final Pair recordAspectPair,
Long totalNumberOfRecordsToProcess, final BufferedWriter out, final boolean attach)
{
- final Long maxRecordsToProcess = totalNumberOfRecordsToProcess;
- final List processedNodes = new ArrayList();
- logger.info(MESSAGE_PROCESSING_BEGIN);
- // by batch size
- for (Long i = 0L; i < maxNodeId; i+=batchSize)
- {
- if(maxRecordsToProcess != 0 && processedNodes.size() >= maxRecordsToProcess)
- {
- break;
- }
- final Long currentIndex = i;
-
- transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback()
- {
- public Void execute() throws Throwable
- {
- // get the nodes with the extended security aspect applied
+ final Long maxRecordsToProcess = totalNumberOfRecordsToProcess;
+ final List processedNodes = new ArrayList();
+ logger.info(MESSAGE_PROCESSING_BEGIN);
+ // by batch size
+ for (Long i = 0L; i < maxNodeId; i += batchSize)
+ {
+ if (maxRecordsToProcess != 0 && processedNodes.size() >= maxRecordsToProcess)
+ {
+ break;
+ }
+ final Long currentIndex = i;
+
+ transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback()
+ {
+ public Void execute() throws Throwable
+ {
+ // get the nodes with the extended security aspect applied
List nodeIds = patchDAO.getNodesByAspectQNameId(recordAspectPair.getFirst(), currentIndex,
currentIndex + batchSize);
-
- // process each one
- for (Long nodeId : nodeIds)
- {
- if(maxRecordsToProcess != 0 && processedNodes.size() >= maxRecordsToProcess)
- {
- break;
- }
- NodeRef record = nodeDAO.getNodePair(nodeId).getSecond();
- String recordName = (String) nodeService.getProperty(record, ContentModel.PROP_NAME);
- logger.info(MessageFormat.format(MESSAGE_PROCESSING_RECORD_BEGIN_TEMPLATE, recordName));
- processNode(record);
- logger.info(MessageFormat.format(MESSAGE_PROCESSING_RECORD_END_TEMPLATE, recordName));
- processedNodes.add(record);
+
+ // process each one
+ for (Long nodeId : nodeIds)
+ {
+ if (maxRecordsToProcess != 0 && processedNodes.size() >= maxRecordsToProcess)
+ {
+ break;
+ }
+ NodeRef record = nodeDAO.getNodePair(nodeId).getSecond();
+ String recordName = (String) nodeService.getProperty(record, ContentModel.PROP_NAME);
+ logger.info(MessageFormat.format(MESSAGE_PROCESSING_RECORD_BEGIN_TEMPLATE, recordName));
+ processNode(record);
+ logger.info(MessageFormat.format(MESSAGE_PROCESSING_RECORD_END_TEMPLATE, recordName));
+ processedNodes.add(record);
if (attach)
{
out.write(recordName);
out.write(",");
out.write(record.toString());
out.write("\n");
- }
+ }
}
-
- return null;
- }
+
+ return null;
+ }
}, false, // read only
- true); // requires new
- }
- logger.info(MESSAGE_PROCESSING_END);
+ true); // requires new
+ }
+ logger.info(MESSAGE_PROCESSING_END);
return processedNodes;
- }
-
- /**
- * Process each node
- *
- * @param nodeRef
- */
- @SuppressWarnings({ "unchecked"})
- protected void processNode(NodeRef nodeRef)
- {
- // get the reader/writer data
- Map readers = (Map)nodeService.getProperty(nodeRef, PROP_READERS);
- Map writers = (Map)nodeService.getProperty(nodeRef, PROP_WRITERS);
-
- // remove extended security aspect
- nodeService.removeAspect(nodeRef, ASPECT_EXTENDED_SECURITY);
-
- // remove dynamic authority permissions
- permissionService.clearPermission(nodeRef, ExtendedReaderDynamicAuthority.EXTENDED_READER);
- permissionService.clearPermission(nodeRef, ExtendedWriterDynamicAuthority.EXTENDED_WRITER);
-
- // if record then ...
- if (nodeService.hasAspect(nodeRef, ASPECT_RECORD) && readers != null && writers != null)
- {
- // re-set extended security via API
- extendedSecurityService.set(nodeRef, readers.keySet(), writers.keySet());
- }
- }
-}
+ }
+
+ protected List processChildrenNodes(NodeRef parentNodeRef, final int batchSize,
+ final Pair recordAspectPair, final int maxRecordsToProcess, final BufferedWriter out,
+ final boolean attach)
+ {
+ final List processedNodes = new ArrayList();
+ final List children = fileFolderService.search(parentNodeRef, "*", /*filesSearch*/true, /*folderSearch*/true, /*includeSubfolders*/true);
+ logger.info(MESSAGE_PROCESSING_BEGIN);
+ // by batch size
+ for (int i = 0; i < children.size(); i += batchSize)
+ {
+ if (maxRecordsToProcess != 0 && processedNodes.size() >= maxRecordsToProcess)
+ {
+ break;
+ }
+ final int currentIndex = i;
+
+ transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback()
+ {
+ public Void execute() throws Throwable
+ {
+ List nodes = children.subList(currentIndex, Math.min(currentIndex + batchSize, children.size()));
+ // process each one
+ for (FileInfo node : nodes)
+ {
+ if (maxRecordsToProcess != 0 && processedNodes.size() >= maxRecordsToProcess)
+ {
+ break;
+ }
+ NodeRef record = node.getNodeRef();
+ if (nodeService.hasAspect(record, recordAspectPair.getSecond()))
+ {
+ String recordName = (String) nodeService.getProperty(record, ContentModel.PROP_NAME);
+ logger.info(MessageFormat.format(MESSAGE_PROCESSING_RECORD_BEGIN_TEMPLATE, recordName));
+ processNode(record);
+ logger.info(MessageFormat.format(MESSAGE_PROCESSING_RECORD_END_TEMPLATE, recordName));
+ processedNodes.add(record);
+ if (attach)
+ {
+ out.write(recordName);
+ out.write(",");
+ out.write(record.toString());
+ out.write("\n");
+ }
+ }
+ }
+
+ return null;
+ }
+ }, false, // read only
+ true); // requires new
+ }
+ logger.info(MESSAGE_PROCESSING_END);
+ return processedNodes;
+ }
+
+ /**
+ * Process each node
+ *
+ * @param nodeRef
+ */
+ @SuppressWarnings({ "unchecked" })
+ protected void processNode(NodeRef nodeRef)
+ {
+ // get the reader/writer data
+ Map readers = (Map) nodeService.getProperty(nodeRef, PROP_READERS);
+ Map writers = (Map) nodeService.getProperty(nodeRef, PROP_WRITERS);
+
+ // remove extended security aspect
+ nodeService.removeAspect(nodeRef, ASPECT_EXTENDED_SECURITY);
+
+ // remove dynamic authority permissions
+ permissionService.clearPermission(nodeRef, ExtendedReaderDynamicAuthority.EXTENDED_READER);
+ permissionService.clearPermission(nodeRef, ExtendedWriterDynamicAuthority.EXTENDED_WRITER);
+
+ // if record then ...
+ if (nodeService.hasAspect(nodeRef, ASPECT_RECORD))
+ {
+ Set readersKeySet = null;
+ if (readers != null)
+ {
+ readersKeySet = readers.keySet();
+ }
+ Set writersKeySet = null;
+ if (writers != null)
+ {
+ writersKeySet = writers.keySet();
+ }
+ // re-set extended security via API
+ extendedSecurityService.set(nodeRef, readersKeySet, writersKeySet);
+ }
+ }
+}
diff --git a/rm-server/unit-test/java/org/alfresco/repo/web/scripts/roles/DynamicAuthoritiesGetUnitTest.java b/rm-server/unit-test/java/org/alfresco/repo/web/scripts/roles/DynamicAuthoritiesGetUnitTest.java
index 421286bc1a..46d38000a0 100644
--- a/rm-server/unit-test/java/org/alfresco/repo/web/scripts/roles/DynamicAuthoritiesGetUnitTest.java
+++ b/rm-server/unit-test/java/org/alfresco/repo/web/scripts/roles/DynamicAuthoritiesGetUnitTest.java
@@ -1,433 +1,278 @@
-/*
- * Copyright (C) 2005-2014 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-
-package org.alfresco.repo.web.scripts.roles;
-
-import static java.util.Collections.emptyMap;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+/*
+ * Copyright (C) 2005-2014 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+
+package org.alfresco.repo.web.scripts.roles;
+
+import static java.util.Collections.emptyMap;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.never;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.io.File;
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.ImmutableMap;
-
-import org.alfresco.model.ContentModel;
-import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
-import org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamicAuthority;
-import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
-import org.alfresco.module.org_alfresco_module_rm.security.ExtendedWriterDynamicAuthority;
-import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
-import org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest;
-import org.alfresco.repo.domain.node.NodeDAO;
-import org.alfresco.repo.domain.patch.PatchDAO;
-import org.alfresco.repo.domain.qname.QNameDAO;
-import org.alfresco.repo.transaction.RetryingTransactionHelper;
-import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyBoolean;
+import static org.mockito.Matchers.anyLong;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.io.File;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.common.collect.ImmutableMap;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
+import org.alfresco.module.org_alfresco_module_rm.security.ExtendedReaderDynamicAuthority;
+import org.alfresco.module.org_alfresco_module_rm.security.ExtendedSecurityService;
+import org.alfresco.module.org_alfresco_module_rm.security.ExtendedWriterDynamicAuthority;
+import org.alfresco.module.org_alfresco_module_rm.test.util.AlfMock;
+import org.alfresco.module.org_alfresco_module_rm.test.util.BaseWebScriptUnitTest;
+import org.alfresco.repo.domain.node.NodeDAO;
+import org.alfresco.repo.domain.patch.PatchDAO;
+import org.alfresco.repo.domain.qname.QNameDAO;
+import org.alfresco.repo.transaction.RetryingTransactionHelper;
+import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.web.scripts.content.ContentStreamer;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.repository.NodeService;
-import org.alfresco.service.cmr.security.PermissionService;
-import org.alfresco.service.namespace.QName;
-import org.alfresco.service.transaction.TransactionService;
-import org.alfresco.util.Pair;
-import org.json.JSONObject;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.mockito.invocation.InvocationOnMock;
-import org.mockito.stubbing.Answer;
+import org.alfresco.service.cmr.model.FileFolderService;
+import org.alfresco.service.cmr.model.FileInfo;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.repository.NodeService;
+import org.alfresco.service.cmr.security.PermissionService;
+import org.alfresco.service.namespace.QName;
+import org.alfresco.service.transaction.TransactionService;
+import org.alfresco.util.Pair;
+import org.json.JSONObject;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
import org.springframework.extensions.webscripts.AbstractWebScript;
import org.springframework.extensions.webscripts.Status;
-import org.springframework.extensions.webscripts.WebScriptException;
-import org.springframework.extensions.webscripts.WebScriptRequest;
+import org.springframework.extensions.webscripts.WebScriptException;
+import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
-
-/**
- * DynamicAuthoritiesGet Unit Test
- *
- * @author Silviu Dinuta
- */
-@SuppressWarnings("deprecation")
-public class DynamicAuthoritiesGetUnitTest extends BaseWebScriptUnitTest implements RecordsManagementModel
-{
- /** test data */
- private static final Long ASPECT_ID = 123l;
- private static final QName ASPECT = AlfMock.generateQName();
-
- /** mocks */
- @Mock
- private PatchDAO mockedPatchDAO;
- @Mock
- private NodeDAO mockedNodeDAO;
- @Mock
- private QNameDAO mockedQnameDAO;
- @Mock
- private NodeService mockedNodeService;
- @Mock
- private PermissionService mockedPermissionService;
- @Mock
- private ExtendedSecurityService mockedExtendedSecurityService;
- @Mock
- private TransactionService mockedTransactionService;
- @Mock
- private RetryingTransactionHelper mockedRetryingTransactionHelper;
+
+/**
+ * DynamicAuthoritiesGet Unit Test
+ *
+ * @author Silviu Dinuta
+ */
+@SuppressWarnings("deprecation")
+public class DynamicAuthoritiesGetUnitTest extends BaseWebScriptUnitTest implements RecordsManagementModel
+{
+ /** test data */
+ private static final Long ASPECT_ID = 123l;
+ private static final QName ASPECT = AlfMock.generateQName();
+
+ /** mocks */
+ @Mock
+ private PatchDAO mockedPatchDAO;
+ @Mock
+ private NodeDAO mockedNodeDAO;
+ @Mock
+ private QNameDAO mockedQnameDAO;
+ @Mock
+ private NodeService mockedNodeService;
+ @Mock
+ private PermissionService mockedPermissionService;
+ @Mock
+ private ExtendedSecurityService mockedExtendedSecurityService;
+ @Mock
+ private TransactionService mockedTransactionService;
+ @Mock
+ private RetryingTransactionHelper mockedRetryingTransactionHelper;
@Mock
private ContentStreamer contentStreamer;
-
- /** test component */
- @InjectMocks
- private DynamicAuthoritiesGet webScript;
-
- @Override
- protected AbstractWebScript getWebScript()
- {
- return webScript;
- }
-
- @Override
- protected String getWebScriptTemplate()
- {
- return "alfresco/templates/webscripts/org/alfresco/repository/roles/rm-dynamicauthorities.get.json.ftl";
- }
-
- /**
- * Before test
- */
- @SuppressWarnings("unchecked")
- @Before
- public void before()
- {
- MockitoAnnotations.initMocks(this);
- webScript.setNodeService(mockedNodeService);
- webScript.setPermissionService(mockedPermissionService);
- webScript.setExtendedSecurityService(mockedExtendedSecurityService);
- // setup retrying transaction helper
- Answer