diff --git a/.travis.yml b/.travis.yml index d46dc0f5bf..887038834c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ --- import: - - source: .travis.env-vars.yml - - source: .travis.tests-stage.yml - - source: .travis.release-stage.yml - - source: .travis.publish-stage.yml + - source: travis/.travis.env-vars.yml + - source: travis/.travis.tests-stage.yml + - source: travis/.travis.integration-test-MySQL.yml + - source: travis/.travis.release-stage.yml + - source: travis/.travis.publish-stage.yml dist: xenial sudo: required language: java diff --git a/rm-automation/rm-automation-community-rest-api/pom.xml b/rm-automation/rm-automation-community-rest-api/pom.xml index 08b8b1bf57..f178cc8d3b 100644 --- a/rm-automation/rm-automation-community-rest-api/pom.xml +++ b/rm-automation/rm-automation-community-rest-api/pom.xml @@ -17,7 +17,7 @@ alfresco-governance-services-community-repo 1.38 2.0.0 - 2.7.7 + 2.7.9.1 @@ -90,10 +90,10 @@ docker-java 3.0.14 - - com.fasterxml.jackson.core - jackson-databind - ${jackson.databind.version} - + + com.fasterxml.jackson.core + jackson-databind + ${jackson.databind.version} + diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditAddToHoldTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditAddToHoldTests.java index b6be5b3c9d..7d454ec3d4 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditAddToHoldTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditAddToHoldTests.java @@ -41,6 +41,7 @@ import static org.apache.commons.httpclient.HttpStatus.SC_INTERNAL_SERVER_ERROR; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; +import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -94,6 +95,7 @@ public class AuditAddToHoldTests extends BaseRMRestTest private RecordCategoryChild recordFolder; private List auditEntries; private List holdsList = asList(HOLD1, HOLD2); + private List holdsListRef = new ArrayList<>(); private String hold1NodeRef; @BeforeClass (alwaysRun = true) @@ -102,7 +104,8 @@ public class AuditAddToHoldTests extends BaseRMRestTest STEP("Create 2 holds."); hold1NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD1, HOLD_REASON, HOLD_DESCRIPTION); - holdsAPI.createHold(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD2, HOLD_REASON, HOLD_DESCRIPTION); + String hold2NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD2, HOLD_REASON, HOLD_DESCRIPTION); + holdsListRef = asList(hold1NodeRef, hold2NodeRef); STEP("Create a new record category with a record folder."); recordCategory = createRootCategory(getRandomName("recordCategory")); @@ -302,7 +305,7 @@ public class AuditAddToHoldTests extends BaseRMRestTest @AfterClass (alwaysRun = true) public void cleanUpAuditAddToHoldTests() { - holdsList.forEach(hold -> holdsAPI.deleteHold(getAdminUser().getUsername(), getAdminUser().getPassword(), hold)); + holdsListRef.forEach(holdRef -> holdsAPI.deleteHold(getAdminUser(), holdRef)); dataSite.usingAdmin().deleteSite(privateSite); asList(rmAdmin, rmManagerNoReadOnHold, rmManagerNoReadOnNode).forEach(user -> getDataUser().usingAdmin().deleteUser(user)); getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(recordCategory.getId()); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditCreateHoldTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditCreateHoldTests.java index d349de3bce..cf3654d816 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditCreateHoldTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditCreateHoldTests.java @@ -37,6 +37,7 @@ import static org.apache.commons.httpclient.HttpStatus.SC_INTERNAL_SERVER_ERROR; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; +import java.util.ArrayList; import java.util.List; import com.google.common.collect.ImmutableMap; @@ -67,6 +68,7 @@ public class AuditCreateHoldTests extends BaseRMRestTest private final String HOLD1 = PREFIX + "createHold"; private final String HOLD2 = PREFIX + "createHold2"; private final String HOLD3 = PREFIX + "createHold3"; + private List holdsListRef = new ArrayList<>(); @Autowired private RMAuditService rmAuditService; @@ -100,8 +102,9 @@ public class AuditCreateHoldTests extends BaseRMRestTest rmAuditService.clearAuditLog(); STEP("Create a new hold."); - holdsAPI.createHold(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD1, HOLD_REASON, HOLD_DESCRIPTION); - + String hold1NodeRef = holdsAPI.createHoldAndGetNodeRef(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD1, + HOLD_REASON, HOLD_DESCRIPTION); + holdsListRef.add(hold1NodeRef); STEP("Check the audit log contains the entry for the created hold with the hold details."); rmAuditService.checkAuditLogForEvent(getAdminUser(), CREATE_HOLD, rmAdmin, HOLD1, asList(ImmutableMap.of("new", HOLD_REASON, "previous", "", "name", "Hold Reason"), @@ -117,8 +120,8 @@ public class AuditCreateHoldTests extends BaseRMRestTest public void createHoldEventIsNotAuditedForExistingHold() { STEP("Create a new hold."); - holdsAPI.createHold(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD2, HOLD_REASON, HOLD_DESCRIPTION); - + String hold2NodeRef = holdsAPI.createHoldAndGetNodeRef(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD2, HOLD_REASON, HOLD_DESCRIPTION); + holdsListRef.add(hold2NodeRef); rmAuditService.clearAuditLog(); STEP("Try to create again the same hold and expect action to fail."); @@ -168,7 +171,9 @@ public class AuditCreateHoldTests extends BaseRMRestTest rmAuditService.clearAuditLog(); STEP("Create a new hold."); - holdsAPI.createHold(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD3, HOLD_REASON, HOLD_DESCRIPTION); + String hold3NodeRef = holdsAPI.createHoldAndGetNodeRef(rmAdmin.getUsername(), rmAdmin.getPassword(), HOLD3, + HOLD_REASON, HOLD_DESCRIPTION); + holdsListRef.add(hold3NodeRef); STEP("Check that an user with no Read permissions over the hold can't see the entry for the create hold event"); assertTrue("The list of events should not contain Create Hold entry ", @@ -178,8 +183,7 @@ public class AuditCreateHoldTests extends BaseRMRestTest @AfterClass (alwaysRun = true) public void cleanUpAuditCreateHoldTests() { - asList(HOLD1, HOLD2, HOLD3).forEach(hold -> - holdsAPI.deleteHold(getAdminUser().getUsername(), getAdminUser().getPassword(), hold)); + holdsListRef.forEach(holdRef -> holdsAPI.deleteHold(getAdminUser(), holdRef)); asList(rmAdmin, rmManager).forEach(user -> getDataUser().usingAdmin().deleteUser(user)); } } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditDeleteHoldTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditDeleteHoldTests.java index 9af4732fce..bfa791e677 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditDeleteHoldTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditDeleteHoldTests.java @@ -133,7 +133,7 @@ public class AuditDeleteHoldTests extends BaseRMRestTest @AfterClass (alwaysRun = true) public void cleanUpAuditDeleteHoldTests() { - holdsAPI.deleteHold(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD); + holdsAPI.deleteHold(getAdminUser(), holdNodeRef); asList(rmAdmin, rmManager).forEach(user -> getDataUser().usingAdmin().deleteUser(user)); } } diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditRemoveFromHoldTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditRemoveFromHoldTests.java index 743ca7387d..18f56f8925 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditRemoveFromHoldTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/audit/AuditRemoveFromHoldTests.java @@ -41,6 +41,8 @@ import static org.apache.commons.httpclient.HttpStatus.SC_INTERNAL_SERVER_ERROR; import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertTrue; +import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -97,6 +99,7 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest private Record heldRecord; private List auditEntries; private List holdsList = asList(HOLD1, HOLD2, HOLD3); + private List holdsListRef = new ArrayList<>(); private FileModel heldContent; private String hold1NodeRef; @@ -112,9 +115,10 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest STEP("Create new holds."); hold1NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD1, HOLD_REASON, HOLD_DESCRIPTION); - holdsAPI.createHold(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD2, HOLD_REASON, HOLD_DESCRIPTION); - holdsAPI.createHold(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD3, HOLD_REASON, HOLD_DESCRIPTION); - holdsAPI.createHold(getAdminUser().getUsername(), getAdminUser().getPassword(), DELETED_HOLD, HOLD_REASON, HOLD_DESCRIPTION); + String hold2NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD2, HOLD_REASON, HOLD_DESCRIPTION); + String hold3NodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD3, HOLD_REASON, HOLD_DESCRIPTION); + String deleteNodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), DELETED_HOLD, HOLD_REASON, HOLD_DESCRIPTION); + holdsListRef = asList(hold1NodeRef, hold2NodeRef, hold3NodeRef); STEP("Create a new record category with a record folder."); recordCategory = createRootCategory(getRandomName("recordCategory")); @@ -317,7 +321,7 @@ public class AuditRemoveFromHoldTests extends BaseRMRestTest @AfterClass (alwaysRun = true) public void cleanUpAuditRemoveFromHoldTests() { - holdsList.forEach(hold -> holdsAPI.deleteHold(getAdminUser().getUsername(), getAdminUser().getPassword(), hold)); + holdsListRef.forEach(holdRef -> holdsAPI.deleteHold(getAdminUser(), holdRef)); dataSite.usingAdmin().deleteSite(privateSite); asList(rmAdmin, rmManagerNoReadOnHold, rmManagerNoReadOnNode).forEach(user -> getDataUser().usingAdmin().deleteUser(user)); getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(recordCategory.getId()); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java index 61e91f4517..b9bf38e61d 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/DeclareAndFileDocumentAsRecordTests.java @@ -97,6 +97,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest private RecordCategory recordCategory; private RecordCategoryChild recordFolder, subcategoryRecordFolder, subCategory, closedRecordFolder, recordFolderWithSpacesInName; private UnfiledContainerChild unfiledContainerFolder; + private String holdNodeRef; @Autowired private DockerHelper dockerHelper; @@ -406,7 +407,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest public void declareAndFileToHeldRecordFolderUsingFilesAPI() throws Exception { RecordCategoryChild heldRecordFolder = createFolder(recordCategory.getId(), getRandomName("heldRecordFolder")); - holdsAPI.createHold(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD_NAME, HOLD_REASON, HOLD_DESCRIPTION); + holdNodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD_NAME, HOLD_REASON, HOLD_DESCRIPTION); holdsAPI.addItemToHold(getAdminUser().getUsername(), getAdminUser().getPassword(), heldRecordFolder.getId(), HOLD_NAME); @@ -457,7 +458,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest public void declareAndFileDocumentAsRecordCleanup() { //delete rm items - holdsAPI.deleteHold(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD_NAME); + holdsAPI.deleteHold(getAdminUser(), holdNodeRef); deleteRecordCategory(recordCategory.getId()); getRestAPIFactory().getUnfiledRecordFoldersAPI().deleteUnfiledRecordFolder(unfiledContainerFolder.getId()); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/FileVersionAsRecordTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/FileVersionAsRecordTests.java index dd6d0e453c..630be5e72e 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/FileVersionAsRecordTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/files/FileVersionAsRecordTests.java @@ -89,6 +89,7 @@ public class FileVersionAsRecordTests extends BaseRMRestTest private RecordCategory recordCategory; private RecordCategoryChild recordFolder, closedRecordFolder, heldRecordFolder; private UnfiledContainerChild unfiledContainerFolder; + private String holdNodeRef; @Autowired private RoleService roleService; @@ -114,7 +115,7 @@ public class FileVersionAsRecordTests extends BaseRMRestTest unfiledContainerFolder = createUnfiledContainerChild(UNFILED_RECORDS_CONTAINER_ALIAS, "Unfiled Folder " + getRandomAlphanumeric(), UNFILED_RECORD_FOLDER_TYPE); heldRecordFolder = createFolder(recordCategory.getId(), getRandomName("heldRecordFolder")); - holdsAPI.createHold(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD_NAME, HOLD_REASON, HOLD_DESCRIPTION); + holdNodeRef = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD_NAME, HOLD_REASON, HOLD_DESCRIPTION); holdsAPI.addItemToHold(getAdminUser().getUsername(), getAdminUser().getPassword(), heldRecordFolder.getId(), HOLD_NAME); @@ -284,7 +285,7 @@ public class FileVersionAsRecordTests extends BaseRMRestTest @AfterClass (alwaysRun = true) public void declareAndFileVersionAsRecordCleanUp() { - holdsAPI.deleteHold(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD_NAME); + holdsAPI.deleteHold(getAdminUser(), holdNodeRef); deleteRecordCategory(recordCategory.getId()); //delete created collaboration site diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/AddToHoldsTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/AddToHoldsTests.java index 20fb9fa802..97c4157fa0 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/AddToHoldsTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/AddToHoldsTests.java @@ -357,7 +357,7 @@ public class AddToHoldsTests extends BaseRMRestTest @AfterClass (alwaysRun = true) public void cleanUpAddContentToHold() { - holdsAPI.deleteHold(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD); + holdsAPI.deleteHold(getAdminUser(), holdNodeRef); dataSite.usingAdmin().deleteSite(testSite); users.forEach(user -> getDataUser().usingAdmin().deleteUser(user)); nodesToBeClean.forEach( category -> getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(category)); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/PreventActionsOnFrozenContentTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/PreventActionsOnFrozenContentTests.java index b2082940dc..903771257c 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/PreventActionsOnFrozenContentTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/PreventActionsOnFrozenContentTests.java @@ -324,7 +324,7 @@ public class PreventActionsOnFrozenContentTests extends BaseRMRestTest @AfterClass (alwaysRun = true) public void cleanUpPreventActionsOnFrozenContent() { - holdsAPI.deleteHold(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD_ONE); + holdsAPI.deleteHold(getAdminUser(), holdNodeRef); dataSite.usingAdmin().deleteSite(testSite); getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(recordFolder.getParentId()); getRestAPIFactory().getRecordCategoryAPI().deleteRecordCategory(categoryWithRS.getId()); diff --git a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/RemoveFromHoldsTests.java b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/RemoveFromHoldsTests.java index 66cbd3f480..49621f0bd0 100644 --- a/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/RemoveFromHoldsTests.java +++ b/rm-automation/rm-automation-community-rest-api/src/test/java/org/alfresco/rest/rm/community/hold/RemoveFromHoldsTests.java @@ -86,6 +86,7 @@ public class RemoveFromHoldsTests extends BaseRMRestTest private SiteModel testSite, privateSite; private String holdNodeRefOne; + private String holdNodeRefTwo; private FileModel contentHeld, contentAddToManyHolds; private Set usersToBeClean = new HashSet<>(); private Set nodesToBeClean = new HashSet<>(); @@ -100,7 +101,7 @@ public class RemoveFromHoldsTests extends BaseRMRestTest STEP("Create two holds."); holdNodeRefOne = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser().getUsername(), HOLD_ONE, HOLD_REASON, HOLD_DESCRIPTION); - holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser() + holdNodeRefTwo = holdsAPI.createHoldAndGetNodeRef(getAdminUser().getUsername(), getAdminUser() .getUsername(), HOLD_TWO, HOLD_REASON, HOLD_DESCRIPTION); STEP("Create test files."); @@ -326,8 +327,8 @@ public class RemoveFromHoldsTests extends BaseRMRestTest @AfterClass (alwaysRun = true) public void cleanUpRemoveContentFromHold() { - holdsAPI.deleteHold(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD_ONE); - holdsAPI.deleteHold(getAdminUser().getUsername(), getAdminUser().getPassword(), HOLD_TWO); + holdsAPI.deleteHold(getAdminUser(), holdNodeRefOne); + holdsAPI.deleteHold(getAdminUser(), holdNodeRefTwo); dataSite.usingAdmin().deleteSite(testSite); dataSite.usingAdmin().deleteSite(privateSite); usersToBeClean.forEach(user -> getDataUser().usingAdmin().deleteUser(user)); diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java index 74491189f0..8c54c80c26 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImpl.java @@ -28,6 +28,7 @@ package org.alfresco.module.org_alfresco_module_rm.hold; import static org.alfresco.model.ContentModel.ASPECT_LOCKABLE; +import static org.alfresco.model.ContentModel.ASSOC_CONTAINS; import static org.alfresco.model.ContentModel.PROP_NAME; import java.io.Serializable; @@ -312,7 +313,7 @@ public class HoldServiceImpl extends ServiceBaseImpl if (holdContainer != null) { // get the children of the root hold container - List holdsAssocs = nodeService.getChildAssocs(holdContainer, ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); + List holdsAssocs = nodeService.getChildAssocs(holdContainer, ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL); for (ChildAssociationRef holdAssoc : holdsAssocs) { NodeRef hold = holdAssoc.getChildRef(); @@ -405,7 +406,7 @@ public class HoldServiceImpl extends ServiceBaseImpl NodeRef holdContainer = filePlanService.getHoldContainer(filePlan); // get the hold by name - NodeRef hold = nodeService.getChildByName(holdContainer, ContentModel.ASSOC_CONTAINS, name); + NodeRef hold = nodeService.getChildByName(holdContainer, ASSOC_CONTAINS, name); if (hold != null && !isHold(hold)) { throw new AlfrescoRuntimeException("Can not get hold, because the named node reference isn't a hold."); @@ -468,7 +469,7 @@ public class HoldServiceImpl extends ServiceBaseImpl QName assocName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, name); // create hold - ChildAssociationRef childAssocRef = nodeService.createNode(holdContainer, ContentModel.ASSOC_CONTAINS, assocName, TYPE_HOLD, properties); + ChildAssociationRef childAssocRef = nodeService.createNode(holdContainer, ASSOC_CONTAINS, assocName, TYPE_HOLD, properties); NodeRef holdNodeRef = childAssocRef.getChildRef(); @@ -658,6 +659,9 @@ public class HoldServiceImpl extends ServiceBaseImpl //set in transaction cache in order not to trigger update policy when adding the association transactionalResourceHelper.getSet("frozen").add(nodeRef); nodeService.addChild(hold, nodeRef, ASSOC_FROZEN_CONTENT, ASSOC_FROZEN_CONTENT); + // get the documents primary parent assoc + ChildAssociationRef parentAssoc = nodeService.getPrimaryParent(nodeRef); + nodeService.addChild(hold, nodeRef, ASSOC_CONTAINS, parentAssoc.getQName()); // Mark all the folders contents as frozen if (isRecordFolder(nodeRef)) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java index 9b144b016e..25d03ad145 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/model/rma/aspect/RecordAspect.java @@ -435,7 +435,7 @@ public class RecordAspect extends AbstractDisposableItem { if (contentBefore != null && !contentBefore.equals(contentAfter)) { - throw new IntegrityException(MSG_WORM_RECORD_LOCKED, null); + throw new IntegrityException(I18NUtil.getMessage(MSG_WORM_RECORD_LOCKED), null); } } if (contentAfter != null) diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/report/HoldReportTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/report/HoldReportTest.java index b0332bdac2..6f18e5af82 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/report/HoldReportTest.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/integration/report/HoldReportTest.java @@ -126,7 +126,7 @@ public class HoldReportTest extends BaseRMTestCase implements ReportModel { // crate a hold hold = holdService.createHold(filePlan, HOLD_NAME, HOLD_REASON, HOLD_DESCRIPTION); - + // add some items to the hold folder1 = recordFolderService.createRecordFolder(rmContainer, FOLDER1_NAME); holdService.addToHold(hold, folder1); @@ -168,8 +168,7 @@ public class HoldReportTest extends BaseRMTestCase implements ReportModel public void after() { holdService.deleteHold(hold); - nodeService.deleteNode(folder1); } - }); + }); } } diff --git a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/capabilities/DeclarativeCapabilityTest.java b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/capabilities/DeclarativeCapabilityTest.java index 36d690d3b2..4b66fb6b80 100644 --- a/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/capabilities/DeclarativeCapabilityTest.java +++ b/rm-community/rm-community-repo/test/java/org/alfresco/module/org_alfresco_module_rm/test/legacy/capabilities/DeclarativeCapabilityTest.java @@ -131,14 +131,9 @@ public class DeclarativeCapabilityTest extends BaseRMTestCase } @Override - protected void tearDownImpl() + protected void tearDown() throws Exception { - // Unfreeze stuff so it can be deleted - holdService.removeFromHold(hold, frozenRecord); - holdService.removeFromHold(hold, frozenRecordFolder); - holdService.removeFromHold(hold, frozenRecord2); - - super.tearDownImpl(); + super.tearDown(); } @Override diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java index b2f1314a3d..f4d1246027 100644 --- a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/hold/HoldServiceImplUnitTest.java @@ -98,6 +98,9 @@ public class HoldServiceImplUnitTest extends BaseUnitTest @Mock private CapabilityService mockedCapabilityService; + @Mock + private ChildAssociationRef mockChildAssociationRef; + @Spy @InjectMocks HoldServiceImpl holdService; @Before @@ -120,7 +123,9 @@ public class HoldServiceImplUnitTest extends BaseUnitTest QName contentSubtype = QName.createQName("contentSubtype", "contentSubtype"); when(mockedNodeService.getType(activeContent)).thenReturn(contentSubtype); when(mockedNodeTypeUtility.instanceOf(contentSubtype, ContentModel.TYPE_CONTENT)).thenReturn(true); + when(mockedNodeService.getPrimaryParent(activeContent)).thenReturn(mockChildAssociationRef); + when(mockedNodeService.getPrimaryParent(recordFolder)).thenReturn(mockChildAssociationRef); // setup interactions doReturn(holdContainer).when(mockedFilePlanService).getHoldContainer(filePlan); } @@ -353,6 +358,7 @@ public class HoldServiceImplUnitTest extends BaseUnitTest public void addToHoldNotInHold() { mockPoliciesForAddToHold(); + when(mockedNodeService.getPrimaryParent(record)).thenReturn(mockChildAssociationRef); holdService.addToHold(hold, recordFolder); diff --git a/scripts/getLogs.sh b/scripts/getLogs.sh new file mode 100644 index 0000000000..930440b4cb --- /dev/null +++ b/scripts/getLogs.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -x + +alfrescoContainerId=$(docker ps -a | grep '_alfresco_' | awk '{print $1}') +shareContainerId=$(docker ps -a | grep '_share_' | awk '{print $1}') +solrContainerId=$(docker ps -a | grep '_search_' | awk '{print $1}') + +docker logs $alfrescoContainerId > alfresco.log +if [ -n "$shareContainerId" ]; then + docker logs $shareContainerId > share.log +fi +docker logs $solrContainerId > solr.log diff --git a/.travis.env-vars.yml b/travis/.travis.env-vars.yml similarity index 100% rename from .travis.env-vars.yml rename to travis/.travis.env-vars.yml diff --git a/travis/.travis.integration-test-MySQL.yml b/travis/.travis.integration-test-MySQL.yml new file mode 100644 index 0000000000..05934be796 --- /dev/null +++ b/travis/.travis.integration-test-MySQL.yml @@ -0,0 +1,22 @@ +### Integration tests on MySQL are running: +## - on stable branch +## - on demand with commit message [execute tests on MySQL] + +jobs: + include: + - &integration_test_on_MYSQL + name: "Community Integrations Tests on MySQL" + services: docker + stage: Tests + if: branch =~ /(release\/.*$|master)/ OR commit_message =~ /\[execute tests on MySQL\]/ + install: + - docker run -d -p 3307:3306 -e MYSQL_ROOT_PASSWORD=alfresco -e MYSQL_USER=alfresco -e MYSQL_DATABASE=alfresco -e MYSQL_PASSWORD=alfresco mysql:5.7.23 --transaction-isolation='READ-COMMITTED' + - docker run -d -p 61617:61617 -p 5673:5673 alfresco/alfresco-activemq:5.15.8 + script: + - travis_retry travis_wait 80 mvn -B -q clean install -Puse-mysql -DskipTests -Dskip.integrationtests=false -Dmy.db.name=alfresco -Dmy.db.port=3307 -Dcommunity -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn + + - <<: *integration_test_on_MYSQL + name: "Enterprise Integrations Tests on MySQL" + install: + - travis_retry travis_wait 60 mvn -B -q clean install ${MVN_SKIP} -f rm-community/pom.xml -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -am + script: travis_retry travis_wait 80 mvn -B -q clean install ${MVN_SKIP} -Puse-mysql -Dskip.integrationtests=false -Dmy.db.name=alfresco -Dmy.db.port=3307 -f rm-enterprise/pom.xml -amd -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn diff --git a/.travis.publish-stage.yml b/travis/.travis.publish-stage.yml similarity index 100% rename from .travis.publish-stage.yml rename to travis/.travis.publish-stage.yml diff --git a/.travis.release-stage.yml b/travis/.travis.release-stage.yml similarity index 100% rename from .travis.release-stage.yml rename to travis/.travis.release-stage.yml diff --git a/.travis.tests-stage.yml b/travis/.travis.tests-stage.yml similarity index 96% rename from .travis.tests-stage.yml rename to travis/.travis.tests-stage.yml index 5f231e5ce2..b33840846a 100644 --- a/.travis.tests-stage.yml +++ b/travis/.travis.tests-stage.yml @@ -1,14 +1,5 @@ jobs: include: - - name: "Community Integrations Tests on MySQL" - stage: Tests - script: - - echo "Community Integrations Tests on MySQL" - - name: "Enterprise Integrations Tests on MySQL" - stage: Tests - script: - - echo "Enterprise Integrations Tests on MySQL" - - name: "Community Rest API Tests" stage: Tests install: @@ -67,6 +58,9 @@ jobs: - ./rm-automation/rm-automation-ui/target/surefire-reports - ./rm-automation/rm-automation-ui/target/reports - ./rm-automation/rm-automation-ui/target/screenshots + - alfresco.log + - solr.log + - share.log target_paths: $TRAVIS_BUILD_NUMBER/$TRAVIS_JOB_NUMBER install: - | @@ -84,6 +78,7 @@ jobs: - travis_retry travis_wait 30 mvn -B -U -q clean install ${MVN_SKIP} -pl :alfresco-governance-services-automation-ui -am script: - travis_wait 90 xvfb-run --server-args="-screen 0 1920x1080x24" mvn -B test -pl :alfresco-governance-services-automation-ui -Dskip.automationtests=false -DsuiteXmlFile=communitySmokeRecords.xml -Dshare.url=${SHARE_URL} -Dalfresco.url=${ALFRESCO_URL} ${WEBDRIVER_ARGUMENTS} + after_failure: bash scripts/getLogs.sh - <<: *community_shared_UI_configuration name: "Community Smoke UI Tests for actions in RM site" @@ -94,7 +89,7 @@ jobs: name: "Community Level 2: Disposition Schedules, Holds, Records UI Tests" script: - travis_wait 90 xvfb-run --server-args="-screen 0 1920x1080x24" mvn -B test -pl :alfresco-governance-services-automation-ui -Dskip.automationtests=false -DsuiteXmlFile=communityLevel2Tests.xml -Dshare.url=${SHARE_URL} -Dalfresco.url=${ALFRESCO_URL} ${WEBDRIVER_ARGUMENTS} - + - <<: *community_shared_UI_configuration name: "Community Level 2: Audit, Rules, User Dashboard and Node Browser UI Tests" script: @@ -111,6 +106,9 @@ jobs: - ./rm-automation/rm-automation-ui/target/surefire-reports - ./rm-automation/rm-automation-ui/target/reports - ./rm-automation/rm-automation-ui/target/screenshots + - alfresco.log + - solr.log + - share.log target_paths: $TRAVIS_BUILD_NUMBER/$TRAVIS_JOB_NUMBER install: - travis_retry travis_wait 90 mvn -B -q install $MVN_SKIP -PbuildDockerImage -pl :alfresco-governance-services-enterprise-repo,:alfresco-governance-services-enterprise-share -am @@ -121,6 +119,7 @@ jobs: - sudo free -m -t script: - travis_wait 90 xvfb-run --server-args="-screen 0 1920x1080x24" mvn -B test -pl :alfresco-governance-services-automation-ui -Dskip.automationtests=false -DsuiteXmlFile=enterpriseLevel2Tests.xml -Dshare.url=${SHARE_URL} -Dalfresco.url=${ALFRESCO_URL} ${WEBDRIVER_ARGUMENTS} + after_failure: bash scripts/getLogs.sh - <<: *enterprise_shared_UI_configuration name: "Enterprise Classification Level 2 UI Tests" @@ -164,4 +163,3 @@ jobs: script: - travis_wait 90 xvfb-run --server-args="-screen 0 1920x1080x24" mvn -B test -pl :alfresco-governance-services-automation-ui -DsuiteXmlFile=wormTestSuite.xml -Dskip.automationtests=false -Dshare.url=${SHARE_URL} -Dalfresco.url=${ALFRESCO_URL} ${WEBDRIVER_ARGUMENTS} after_script: bash scripts/cleanup.sh - after_failure: docker ps -a | grep '_alfresco_1' | awk '{print $1}' | xargs docker logs | tail -5000