use of org.alfresco.repo.policy.BehaviourFilter in project alfresco-repository by Alfresco.
the class CronScheduledQueryBasedTemplateActionDefinitionTest method createTestContent.
/**
* Creates <code>rootTestFolder</code> test folder as start of test content hierarchy. Then it creates
* {@link CronScheduledQueryBasedTemplateActionDefinitionTest#TEST_DOCUMENTS_AMOUNT} documents in the root folder with "today" creation date and the same amount of documents
* with "yesterday" creation date
*/
private void createTestContent() throws Exception {
FileFolderService fileFolderService = registry.getFileFolderService();
NodeRef companyHomeNodeRef = registry.getNodeLocatorService().getNode(CompanyHomeNodeLocator.NAME, null, null);
rootTestFolder = fileFolderService.create(companyHomeNodeRef, TEST_FOLDER_NAME, ContentModel.TYPE_FOLDER).getNodeRef();
for (int i = 0; i < TEST_DOCUMENTS_AMOUNT; i++) {
String freshDocName = String.format(FRESH_TEST_DOCUMENT_NAME_TEMPLATE, i, System.currentTimeMillis());
FileInfo fileInfo = fileFolderService.create(rootTestFolder, freshDocName, ContentModel.TYPE_CONTENT);
freshNodes.add(fileInfo);
}
Calendar calendar = GregorianCalendar.getInstance();
calendar.setTimeInMillis(System.currentTimeMillis());
calendar.add(Calendar.DAY_OF_YEAR, AMOUNT_OF_DAYS_BEFORE);
Date yesterdayTime = calendar.getTime();
NodeService nodeService = registry.getNodeService();
BehaviourFilter policyBehaviourFilter = (BehaviourFilter) applicationContext.getBean(POLICY_BEHAVIOUR_FILTER_BEAN_NAME);
policyBehaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
try {
for (int i = 0; i < TEST_DOCUMENTS_AMOUNT; i++) {
String yesterdayDocName = String.format(YESTERDAY_TEST_DOCUMENT_NAME_TEMPLATE, i, System.currentTimeMillis());
FileInfo fileInfo = fileFolderService.create(rootTestFolder, yesterdayDocName, ContentModel.TYPE_CONTENT);
nodeService.setProperty(fileInfo.getNodeRef(), ContentModel.PROP_CREATED, yesterdayTime);
yesterdayNodes.add(fileInfo);
}
} finally {
policyBehaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);
}
checkNodes(freshNodes);
checkNodes(yesterdayNodes);
}
use of org.alfresco.repo.policy.BehaviourFilter in project alfresco-repository by Alfresco.
the class MultiTServiceImplTest method deleteTenant.
private void deleteTenant(final String tenantDomain) {
AuthenticationUtil.runAs(new RunAsWork<Object>() {
public Object doWork() throws Exception {
RetryingTransactionHelper.RetryingTransactionCallback<Void> work = new RetryingTransactionHelper.RetryingTransactionCallback<Void>() {
public Void execute() throws Throwable {
// delete tenant (if it exists)
if (tenantAdminService.existsTenant(tenantDomain)) {
// TODO: WARNING: HACK for ALF-19155: MT deleteTenant does not work
// PersonService prevents 'guest' authorities from being deleted
{
BehaviourFilter behaviourFilter = (BehaviourFilter) applicationContext.getBean("policyBehaviourFilter");
behaviourFilter.disableBehaviour(ContentModel.TYPE_PERSON);
behaviourFilter.disableBehaviour(ContentModel.ASPECT_UNDELETABLE);
}
tenantAdminService.deleteTenant(tenantDomain);
}
return null;
}
};
transactionService.getRetryingTransactionHelper().doInTransaction(work);
return null;
}
}, AuthenticationUtil.getSystemUserName());
}
use of org.alfresco.repo.policy.BehaviourFilter in project records-management by Alfresco.
the class BaseRMTestCase method tearDownImpl.
/**
* Tear down implementation
*/
protected void tearDownImpl() {
BehaviourFilter filter = (BehaviourFilter) applicationContext.getBean("policyBehaviourFilter");
filter.disableBehaviour();
try {
if (filePlan != null && nodeService.exists(filePlan)) {
List<NodeRef> holds = holdService.getHolds(filePlan);
for (NodeRef hold : holds) {
holdService.deleteHold(hold);
}
}
if (folder != null && nodeService.exists(folder)) {
// Delete the folder
nodeService.deleteNode(folder);
}
if (siteId != null && siteService.getSite(siteId) != null) {
// Delete the site
siteService.deleteSite(siteId);
}
// delete the collaboration site (if required)
if (isCollaborationSiteTest() && siteService.getSite(collabSiteId) != null) {
siteService.deleteSite(collabSiteId);
}
} finally {
filter.enableBehaviour();
}
}
use of org.alfresco.repo.policy.BehaviourFilter in project alfresco-repository by Alfresco.
the class DiscussionServiceImplTest method deleteTenant.
private static void deleteTenant() {
TRANSACTION_HELPER.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>() {
@Override
public Void execute() throws Throwable {
// TODO: WARNING: HACK for ALF-19155: MT deleteTenant does not work
// PersonService prevents 'guest' authorities from being deleted
{
BehaviourFilter behaviourFilter = (BehaviourFilter) testContext.getBean("policyBehaviourFilter");
behaviourFilter.disableBehaviour(ContentModel.TYPE_PERSON);
behaviourFilter.disableBehaviour(ContentModel.ASPECT_UNDELETABLE);
}
TENANT_ADMIN_SERVICE.deleteTenant(TENANT_DOMAIN);
return null;
}
});
}
use of org.alfresco.repo.policy.BehaviourFilter in project alfresco-repository by Alfresco.
the class VirtualBehaviourFilterExtensionTest method setUp.
@Before
public void setUp() throws Exception {
super.setUp();
behaviourFilter = ctx.getBean("policyBehaviourFilter", BehaviourFilter.class);
smartStore = ctx.getBean("smartStore", VirtualStoreImpl.class);
NodeRef nodeRef = nodeService.getChildByName(virtualFolder1NodeRef, ContentModel.ASSOC_CONTAINS, "Node1");
virtualNodeRef = createContent(nodeRef, "actualContentName", "0", MimetypeMap.MIMETYPE_TEXT_PLAIN, "UTF-8").getChildRef();
}
Aggregations