Merge release/V2.5 into merge-2.5/MNT-18082_HotFixV2.5.0.4.

This commit is contained in:
Tom Page
2017-07-19 09:00:28 +01:00
11 changed files with 82 additions and 106 deletions

View File

@@ -4,7 +4,7 @@
<groupId>org.alfresco</groupId> <groupId>org.alfresco</groupId>
<artifactId>alfresco-rm</artifactId> <artifactId>alfresco-rm</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<version>2.5.2-SNAPSHOT</version> <version>2.5.3-SNAPSHOT</version>
<name>Alfresco Records Management</name> <name>Alfresco Records Management</name>
<parent> <parent>

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.alfresco</groupId> <groupId>org.alfresco</groupId>
<artifactId>alfresco-rm</artifactId> <artifactId>alfresco-rm</artifactId>
<version>2.5.2-SNAPSHOT</version> <version>2.5.3-SNAPSHOT</version>
</parent> </parent>
<properties> <properties>

View File

@@ -8,7 +8,7 @@
<parent> <parent>
<groupId>org.alfresco</groupId> <groupId>org.alfresco</groupId>
<artifactId>alfresco-rm</artifactId> <artifactId>alfresco-rm</artifactId>
<version>2.5.2-SNAPSHOT</version> <version>2.5.3-SNAPSHOT</version>
</parent> </parent>
<licenses> <licenses>

View File

@@ -9,7 +9,7 @@
<parent> <parent>
<groupId>org.alfresco</groupId> <groupId>org.alfresco</groupId>
<artifactId>alfresco-rm-community</artifactId> <artifactId>alfresco-rm-community</artifactId>
<version>2.5.2-SNAPSHOT</version> <version>2.5.3-SNAPSHOT</version>
</parent> </parent>
<properties> <properties>

View File

@@ -274,8 +274,8 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
*/ */
public void setFilePlanService(FilePlanService filePlanService) public void setFilePlanService(FilePlanService filePlanService)
{ {
this.filePlanService = filePlanService; this.filePlanService = filePlanService;
} }
/** /**
* @param namespaceService namespace service * @param namespaceService namespace service
@@ -377,8 +377,8 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
@Override @Override
public boolean isAuditLogEnabled(NodeRef filePlan) public boolean isAuditLogEnabled(NodeRef filePlan)
{ {
ParameterCheck.mandatory("filePlan", filePlan); ParameterCheck.mandatory("filePlan", filePlan);
// TODO use file plan to scope audit log // TODO use file plan to scope audit log
return auditService.isAuditEnabled( return auditService.isAuditEnabled(
RM_AUDIT_APPLICATION_NAME, RM_AUDIT_APPLICATION_NAME,
@@ -391,8 +391,8 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
@Override @Override
public void startAuditLog(NodeRef filePlan) public void startAuditLog(NodeRef filePlan)
{ {
ParameterCheck.mandatory("filePlan", filePlan); ParameterCheck.mandatory("filePlan", filePlan);
// TODO use file plan to scope audit log // TODO use file plan to scope audit log
auditService.enableAudit( auditService.enableAudit(
RM_AUDIT_APPLICATION_NAME, RM_AUDIT_APPLICATION_NAME,
@@ -412,8 +412,8 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
@Override @Override
public void stopAuditLog(NodeRef filePlan) public void stopAuditLog(NodeRef filePlan)
{ {
ParameterCheck.mandatory("filePlan", filePlan); ParameterCheck.mandatory("filePlan", filePlan);
// TODO use file plan to scope audit log // TODO use file plan to scope audit log
auditEvent(filePlan, AUDIT_EVENT_STOP, null, null, true); auditEvent(filePlan, AUDIT_EVENT_STOP, null, null, true);
@@ -433,8 +433,8 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
@Override @Override
public void clearAuditLog(NodeRef filePlan) public void clearAuditLog(NodeRef filePlan)
{ {
ParameterCheck.mandatory("filePlan", filePlan); ParameterCheck.mandatory("filePlan", filePlan);
// TODO use file plan to scope audit log // TODO use file plan to scope audit log
auditService.clearAudit(RM_AUDIT_APPLICATION_NAME, null, null); auditService.clearAudit(RM_AUDIT_APPLICATION_NAME, null, null);
if (logger.isInfoEnabled()) if (logger.isInfoEnabled())
@@ -451,8 +451,8 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
@Override @Override
public Date getDateAuditLogLastStarted(NodeRef filePlan) public Date getDateAuditLogLastStarted(NodeRef filePlan)
{ {
ParameterCheck.mandatory("filePlan", filePlan); ParameterCheck.mandatory("filePlan", filePlan);
// TODO use file plan to scope audit log // TODO use file plan to scope audit log
// TODO: return proper date, for now it's today's date // TODO: return proper date, for now it's today's date
return getStartOfDay(new Date()); return getStartOfDay(new Date());
@@ -464,8 +464,8 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
@Override @Override
public Date getDateAuditLogLastStopped(NodeRef filePlan) public Date getDateAuditLogLastStopped(NodeRef filePlan)
{ {
ParameterCheck.mandatory("filePlan", filePlan); ParameterCheck.mandatory("filePlan", filePlan);
// TODO use file plan to scope audit log // TODO use file plan to scope audit log
// TODO: return proper date, for now it's today's date // TODO: return proper date, for now it's today's date
return getEndOfDay(new Date()); return getEndOfDay(new Date());
@@ -495,7 +495,7 @@ public class RecordsManagementAuditServiceImpl extends AbstractLifecycleBean
@Override @Override
public void auditEvent(NodeRef nodeRef, String eventName, Map<QName, Serializable> before, Map<QName, Serializable> after, boolean immediate) public void auditEvent(NodeRef nodeRef, String eventName, Map<QName, Serializable> before, Map<QName, Serializable> after, boolean immediate)
{ {
auditEvent(nodeRef, eventName, before, after, immediate, false); auditEvent(nodeRef, eventName, before, after, immediate, false);
} }
/** /**
@@ -773,12 +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,
try format == ReportFormat.HTML ? AUDIT_TRAIL_HTML_FILE_SUFFIX : AUDIT_TRAIL_JSON_FILE_SUFFIX);
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);
fileWriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(auditTrailFile),"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
@@ -788,14 +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 writer
if (fileWriter != null)
{
try { fileWriter.close(); } catch (IOException closeEx) {}
}
}
} }
/** /**

View File

@@ -37,6 +37,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel; import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.search.SimpleResultSetMetaData; import org.alfresco.repo.search.SimpleResultSetMetaData;
import org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet; import org.alfresco.repo.search.impl.lucene.PagingLuceneResultSet;
@@ -172,7 +173,12 @@ public class RMAfterInvocationProvider extends RMSecurityCommon
} }
else if (StoreRef.class.isAssignableFrom(returnedObject.getClass())) else if (StoreRef.class.isAssignableFrom(returnedObject.getClass()))
{ {
return decide(authentication, object, config, nodeService.getRootNode((StoreRef) returnedObject)).getStoreRef(); NodeRef rootNodeRef = decide(authentication, object, config, nodeService.getRootNode((StoreRef) returnedObject));
if (rootNodeRef == null)
{
throw new AlfrescoRuntimeException("Root node reference of '" + returnedObject + "' is null.");
}
return rootNodeRef.getStoreRef();
} }
else if (NodeRef.class.isAssignableFrom(returnedObject.getClass())) else if (NodeRef.class.isAssignableFrom(returnedObject.getClass()))
{ {
@@ -208,7 +214,7 @@ public class RMAfterInvocationProvider extends RMSecurityCommon
} }
else else
{ {
if (logger.isDebugEnabled()) 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());
} }
@@ -515,33 +521,33 @@ public class RMAfterInvocationProvider extends RMSecurityCommon
if (!nodeService.exists(returnedObject.getNodeRef(i))) if (!nodeService.exists(returnedObject.getNodeRef(i)))
{ {
inclusionMask.set(i, false); inclusionMask.set(i, false);
} }
else else
{ {
int parentCheckRead = checkRead(returnedObject.getChildAssocRef(i).getParentRef()); int parentCheckRead = checkRead(returnedObject.getChildAssocRef(i).getParentRef());
int childCheckRead = checkRead(returnedObject.getNodeRef(i)); int childCheckRead = checkRead(returnedObject.getNodeRef(i));
for (ConfigAttributeDefintion cad : supportedDefinitions) for (ConfigAttributeDefintion cad : supportedDefinitions)
{ {
NodeRef testNodeRef = returnedObject.getNodeRef(i); NodeRef testNodeRef = returnedObject.getNodeRef(i);
int checkRead = childCheckRead; int checkRead = childCheckRead;
if (cad.parent) if (cad.parent)
{ {
testNodeRef = returnedObject.getChildAssocRef(i).getParentRef(); testNodeRef = returnedObject.getChildAssocRef(i).getParentRef();
checkRead = parentCheckRead; checkRead = parentCheckRead;
} }
if (isUnfiltered(testNodeRef)) if (isUnfiltered(testNodeRef))
{ {
continue; continue;
} }
if (inclusionMask.get(i) && (testNodeRef != null) && (checkRead != AccessDecisionVoter.ACCESS_GRANTED)) if (inclusionMask.get(i) && (testNodeRef != null) && (checkRead != AccessDecisionVoter.ACCESS_GRANTED))
{ {
inclusionMask.set(i, false); inclusionMask.set(i, false);
} }
} }
} }
// Bug out if we are limiting by size // Bug out if we are limiting by size

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,12 +99,15 @@ 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)
{
final String msg = "Custom content model could not be read";
LOGGER.error(msg);
throw new AlfrescoRuntimeException(msg);
}
String customAspectName = ASPECT_CUSTOM_ASSOCIATIONS.toPrefixString(namespaceService); String customAspectName = ASPECT_CUSTOM_ASSOCIATIONS.toPrefixString(namespaceService);
M2Aspect customAssocsAspect = customModel.getAspect(customAspectName); M2Aspect customAssocsAspect = customModel.getAspect(customAspectName);
@@ -112,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())
{ {
@@ -134,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);
@@ -160,13 +153,10 @@ 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);
return model; return model;
} }

View File

@@ -83,6 +83,10 @@ public class ApplyFixMob1573Get extends DeclarativeWebScript
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{ {
M2Model customModel = readCustomContentModel(); M2Model customModel = readCustomContentModel();
if (customModel == null)
{
throw new AlfrescoRuntimeException("Custom content model could not be read");
}
// Go through every custom reference defined in the custom model and make sure that it // Go through every custom reference defined in the custom model and make sure that it
// has many-to-many multiplicity // has many-to-many multiplicity

View File

@@ -126,8 +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;
try // create the writer
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);
@@ -138,9 +140,6 @@ public class TransferReportGet extends BaseTransferWebScript
" items into file: " + report.getAbsolutePath()); " items into file: " + report.getAbsolutePath());
} }
// create the writer
writer = new OutputStreamWriter(new FileOutputStream(report), 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)
@@ -170,13 +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 (writer != null)
{
try { writer.close(); } catch (IOException ioe) {}
}
}
return report; return report;
} }

View File

@@ -234,8 +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;
try // create the writer
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);
@@ -246,9 +248,6 @@ public class TransferReportPost extends BaseTransferWebScript
" items into file: " + report.getAbsolutePath()); " items into file: " + report.getAbsolutePath());
} }
// create the writer
writer = new OutputStreamWriter(new FileOutputStream(report), 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)
@@ -322,13 +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 (writer != null)
{
try { writer.close(); } catch (IOException ioe) {}
}
}
return report; return report;
} }

View File

@@ -59,7 +59,7 @@ public final class PoliciesUtil
*/ */
public static Set<QName> getTypeAndAspectQNames(final NodeService nodeService, final NodeRef nodeRef) public static Set<QName> getTypeAndAspectQNames(final NodeService nodeService, final NodeRef nodeRef)
{ {
return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Set<QName>>() return AuthenticationUtil.runAsSystem(new AuthenticationUtil.RunAsWork<Set<QName>>()
{ {
public Set<QName> doWork() public Set<QName> doWork()
{ {
@@ -81,6 +81,6 @@ public final class PoliciesUtil
// done // done
return qnames; return qnames;
} }
}, AuthenticationUtil.getAdminUserName()); });
} }
} }