Merge remote-tracking branch 'origin/master' into feature/APPS-276_RestrictionsForWORM_no

This commit is contained in:
ehardon
2020-07-24 14:03:17 +03:00
7 changed files with 42 additions and 20 deletions

View File

@@ -57,6 +57,9 @@ public class FilePlanComponentAspects
// retention schedule cut off aspect // retention schedule cut off aspect
public static final String CUT_OFF_ASPECT = "rma:cutOff"; public static final String CUT_OFF_ASPECT = "rma:cutOff";
//declare version as record aspect // declare version as record aspect
public static final String VERSION_AS_RECORD="rmv:versionRecord"; public static final String VERSION_AS_RECORD = "rmv:versionRecord";
// WORM store selector aspect
public static final String ASPECT_STORE_SELECTOR = "cm:storeSelector";
} }

View File

@@ -49,7 +49,8 @@ public enum ActionsOnRule
SET_PROPERTY_VALUE_RM("setPropertyValue"), SET_PROPERTY_VALUE_RM("setPropertyValue"),
HIDE_RECORD("hide-record"), HIDE_RECORD("hide-record"),
DECLARE_VERSION_AS_RECORD("declare-as-version-record"), DECLARE_VERSION_AS_RECORD("declare-as-version-record"),
DECLARE_AS_RECORD("create-record"); DECLARE_AS_RECORD("create-record"),
WORM_LOCK("wormLock");
private String actionValue; private String actionValue;

View File

@@ -102,4 +102,16 @@ public class ActionsExecutionAPI extends RMModelRequest
return getRmRestWrapper().withCoreAPI().usingActions() return getRmRestWrapper().withCoreAPI().usingActions()
.executeAction(ActionsOnRule.DECLARE_VERSION_AS_RECORD.getActionValue(), targetNode); .executeAction(ActionsOnRule.DECLARE_VERSION_AS_RECORD.getActionValue(), targetNode);
} }
/**
* Add WORM lock to a node using v1 actions api
*
* @param targetNode the node on which the action is executed
* @throws Exception
*/
public JSONObject addWORMLock(RepoTestModel targetNode) throws Exception
{
return getRmRestWrapper().withCoreAPI().usingActions()
.executeAction(ActionsOnRule.WORM_LOCK.getActionValue(), targetNode);
}
} }

View File

@@ -27,6 +27,8 @@
package org.alfresco.rest.rm.community.util; package org.alfresco.rest.rm.community.util;
import static org.testng.Assert.assertTrue;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@@ -42,6 +44,7 @@ import com.github.dockerjava.netty.NettyDockerCmdExecFactory;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.alfresco.utility.Utility;
import org.apache.commons.lang.SystemUtils; import org.apache.commons.lang.SystemUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -142,6 +145,22 @@ public class DockerHelper
} }
} }
/**
* Helper method to check if the specified exception is thrown in alfresco logs
*
* @param expectedException the expected exception to be thrown
* @throws Exception
*/
public void checkExceptionIsInAlfrescoLogs(String expectedException) throws Exception
{
//Retry the operation because sometimes it takes few seconds to throw the exception
Utility.sleep(6000, 30000, () ->
{
List<String> alfrescoLogs = getAlfrescoLogs();
assertTrue(alfrescoLogs.stream().anyMatch(logLine -> logLine.contains(expectedException)));
});
}
/** /**
* Method for finding docker containers after the image name * Method for finding docker containers after the image name
* *

View File

@@ -50,8 +50,6 @@ import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse; import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.util.List;
import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil;
import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.base.BaseRMRestTest;
import org.alfresco.rest.rm.community.model.record.Record; import org.alfresco.rest.rm.community.model.record.Record;
@@ -266,12 +264,7 @@ public class DeclareAndFileDocumentAsRecordTests extends BaseRMRestTest
assertStatusCode(ACCEPTED); assertStatusCode(ACCEPTED);
STEP("Check the exception thrown in alfresco logs"); STEP("Check the exception thrown in alfresco logs");
//Retry the operation because sometimes it takes few seconds to throw the exception dockerHelper.checkExceptionIsInAlfrescoLogs(expectedException);
Utility.sleep(6000, 30000, () ->
{
List<String> alfrescoLogs = dockerHelper.getAlfrescoLogs();
assertTrue(alfrescoLogs.stream().anyMatch(logLine -> logLine.contains(expectedException)));
});
STEP("Check that the file is not a record"); STEP("Check that the file is not a record");
assertFalse(hasRecordAspect(testFile), "File should not have record aspect"); assertFalse(hasRecordAspect(testFile), "File should not have record aspect");

View File

@@ -41,7 +41,6 @@ import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue; import static org.testng.Assert.assertTrue;
import java.io.File; import java.io.File;
import java.util.List;
import org.alfresco.dataprep.CMISUtil; import org.alfresco.dataprep.CMISUtil;
import org.alfresco.rest.rm.community.base.BaseRMRestTest; import org.alfresco.rest.rm.community.base.BaseRMRestTest;
@@ -127,7 +126,7 @@ public class FileVersionAsRecordTests extends BaseRMRestTest
} }
@BeforeMethod (alwaysRun = true) @BeforeMethod (alwaysRun = true)
public void createDocument() public void createDocument() throws Exception
{ {
STEP("Create a document in the collaboration site"); STEP("Create a document in the collaboration site");
testFile = dataContent.usingSite(publicSite) testFile = dataContent.usingSite(publicSite)
@@ -215,13 +214,7 @@ public class FileVersionAsRecordTests extends BaseRMRestTest
assertStatusCode(ACCEPTED); assertStatusCode(ACCEPTED);
STEP("Check the exception thrown in alfresco logs"); STEP("Check the exception thrown in alfresco logs");
//Retry the operation because sometimes it takes few seconds to throw the exception dockerHelper.checkExceptionIsInAlfrescoLogs(expectedException);
Utility.sleep(6000, 30000, () ->
{
List<String> alfrescoLogs = dockerHelper.getAlfrescoLogs();
assertTrue(alfrescoLogs.stream().anyMatch(logLine -> logLine.contains(expectedException)));
});
} }
/** /**

View File

@@ -116,6 +116,7 @@ public interface RecordsManagementModel extends RecordsManagementCustomModel
QName ASPECT_RECORD = QName.createQName(RM_URI, "record"); QName ASPECT_RECORD = QName.createQName(RM_URI, "record");
QName PROP_DATE_FILED = QName.createQName(RM_URI, "dateFiled"); QName PROP_DATE_FILED = QName.createQName(RM_URI, "dateFiled");
QName PROP_ORIGIONAL_NAME = QName.createQName(RM_URI, "origionalName"); QName PROP_ORIGIONAL_NAME = QName.createQName(RM_URI, "origionalName");
QName PROP_WORM_STORE = QName.createQName(RM_URI, "wormStore");
// Common record details // Common record details
QName ASPECT_COMMON_RECORD_DETAILS = QName.createQName(RM_URI, "commonRecordDetails"); QName ASPECT_COMMON_RECORD_DETAILS = QName.createQName(RM_URI, "commonRecordDetails");