org.alfresco.repo.policy.BehaviourFilter Java Examples

The following examples show how to use org.alfresco.repo.policy.BehaviourFilter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AuditableAspectTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void setUp() throws Exception
{
    ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    // Set the services
    this.transactionService = serviceRegistry.getTransactionService();
    this.nodeService = serviceRegistry.getNodeService();
    this.contentService = serviceRegistry.getContentService();
    this.behaviourFilter = (BehaviourFilter) ctx.getBean("policyBehaviourFilter");
    
    AuthenticationUtil.setRunAsUserSystem();
    
    // Create the store and get the root node reference
    this.storeRef = this.nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
    this.rootNodeRef = this.nodeService.getRootNode(storeRef);
}
 
Example #2
Source File: LinksServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@BeforeClass public static void initTestsContext() throws Exception
{
    AUTHENTICATION_SERVICE = (MutableAuthenticationService)testContext.getBean("authenticationService");
    BEHAVIOUR_FILTER       = (BehaviourFilter)testContext.getBean("policyBehaviourFilter");
    LINKS_SERVICE          = (LinksService)testContext.getBean("LinksService");
    NODE_SERVICE           = (NodeService)testContext.getBean("nodeService");
    PUBLIC_NODE_SERVICE    = (NodeService)testContext.getBean("NodeService");
    PERSON_SERVICE         = (PersonService)testContext.getBean("personService");
    TRANSACTION_HELPER     = (RetryingTransactionHelper)testContext.getBean("retryingTransactionHelper");
    PERMISSION_SERVICE     = (PermissionService)testContext.getBean("permissionService");
    SITE_SERVICE           = (SiteService)testContext.getBean("siteService");
    CONTENT_SERVICE        = (ContentService)testContext.getBean("ContentService");

    // Do the setup as admin
    AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER);
    createUser(TEST_USER);
    
    // We need to create the test site as the test user so that they can contribute content to it in tests below.
    AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER);
    createTestSites();
}
 
Example #3
Source File: CommentsTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@BeforeClass public static void initBasicServices() throws Exception
{
    behaviourFilter = (BehaviourFilter)APP_CONTEXT_INIT.getApplicationContext().getBean("policyBehaviourFilter");
    contentService = (ContentService)APP_CONTEXT_INIT.getApplicationContext().getBean("ContentService");
    nodeService = (NodeService)APP_CONTEXT_INIT.getApplicationContext().getBean("NodeService");
    repositoryHelper = (Repository)APP_CONTEXT_INIT.getApplicationContext().getBean("repositoryHelper");
    siteService = (SiteService)APP_CONTEXT_INIT.getApplicationContext().getBean("SiteService");
    transactionHelper = (RetryingTransactionHelper)APP_CONTEXT_INIT.getApplicationContext().getBean("retryingTransactionHelper");

    authenticationComponent = (AuthenticationComponent)APP_CONTEXT_INIT.getApplicationContext().getBean("authenticationComponent");
    commentService = (CommentService)APP_CONTEXT_INIT.getApplicationContext().getBean("commentService");
    authenticationService = (MutableAuthenticationService)APP_CONTEXT_INIT.getApplicationContext().getBean("AuthenticationService");
    personService = (PersonService)APP_CONTEXT_INIT.getApplicationContext().getBean("PersonService");
    postDAO = (ActivityPostDAO)APP_CONTEXT_INIT.getApplicationContext().getBean("postDAO");
    permissionServiceImpl = (PermissionServiceImpl)APP_CONTEXT_INIT.getApplicationContext().getBean("permissionServiceImpl");
    permissionModelDAO = (ModelDAO)APP_CONTEXT_INIT.getApplicationContext().getBean("permissionsModelDAO");
    lockService = (LockService)APP_CONTEXT_INIT.getApplicationContext().getBean("lockService");

    COMPANY_HOME = repositoryHelper.getCompanyHome();
}
 
Example #4
Source File: BlogServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Before
public void before() throws Exception
{
    AUTHENTICATION_SERVICE = (MutableAuthenticationService)applicationContext.getBean("authenticationService");
    BEHAVIOUR_FILTER       = (BehaviourFilter)applicationContext.getBean("policyBehaviourFilter");
    BLOG_SERVICE           = (BlogService)applicationContext.getBean("blogService");
    DICTIONARY_SERVICE     = (DictionaryService)applicationContext.getBean("dictionaryService");
    NODE_SERVICE           = (NodeService)applicationContext.getBean("nodeService");
    PERSON_SERVICE         = (PersonService)applicationContext.getBean("personService");
    TRANSACTION_HELPER     = (RetryingTransactionHelper)applicationContext.getBean("retryingTransactionHelper");
    SITE_SERVICE           = (SiteService)applicationContext.getBean("siteService");
    TAGGING_SERVICE        = (TaggingService)applicationContext.getBean("TaggingService");

    AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER);
    createUser(TEST_USER);

    // We need to create the test site as the test user so that they can contribute content to it in tests below.
    AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER);
    createTestSiteWithBlogContainer();
    AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER);
}
 
Example #5
Source File: FileFolderUtil.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Same as above, with option to disable parent behaviour(s) when creating sub-folder
 * 
 * @param service FileFolderService
 * @param parentNodeRef NodeRef
 * @param folderTypeQName QName
 * @param behaviourFilter BehaviourFilter
 * @return FileInfo
 */
public static FileInfo makeFolders(FileFolderService service, NodeRef parentNodeRef, List<String> pathElements,
            QName folderTypeQName, BehaviourFilter behaviourFilter, Set<QName> parentBehavioursToDisable)
{
    validate(pathElements, service, folderTypeQName);

    List<PathElementDetails> list = new ArrayList<>(pathElements.size());
    for (String pathElement : pathElements)
    {
        list.add(new PathElementDetails(pathElement, null));
    }

    FileInfo fileInfo = makeFolders(service, null, parentNodeRef, list, folderTypeQName, behaviourFilter, parentBehavioursToDisable);

    // Should we check the type?
    return fileInfo;
}
 
Example #6
Source File: RepoAdminServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected void setUp() throws Exception
{
    super.setUp();
    
    repoAdminService = (RepoAdminService) ctx.getBean("RepoAdminService");
    dictionaryService = (DictionaryService) ctx.getBean("DictionaryService");
    transactionService = (TransactionService) ctx.getBean("TransactionService");
    nodeService = (NodeService) ctx.getBean("NodeService");
    contentService = (ContentService) ctx.getBean("ContentService");
    searchService = (SearchService) ctx.getBean("SearchService");
    namespaceService = (NamespaceService) ctx.getBean("NamespaceService");
    behaviourFilter = (BehaviourFilter)ctx.getBean("policyBehaviourFilter");
    dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
    
    DbNodeServiceImpl dbNodeService = (DbNodeServiceImpl)ctx.getBean("dbNodeService");
    dbNodeService.setEnableTimestampPropagation(false);
    
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
}
 
Example #7
Source File: DiscussionServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
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;
       }
    });
}
 
Example #8
Source File: BatchImporterImpl.java    From alfresco-bulk-import with Apache License 2.0 6 votes vote down vote up
public BatchImporterImpl(final ServiceRegistry          serviceRegistry,
                         final BehaviourFilter          behaviourFilter,
                         final WritableBulkImportStatus importStatus)
{
    // PRECONDITIONS
    assert serviceRegistry != null : "serviceRegistry must not be null.";
    assert behaviourFilter != null : "behaviourFilter must not be null.";
    assert importStatus    != null : "importStatus must not be null.";
    
    // Body
    this.serviceRegistry = serviceRegistry;
    this.behaviourFilter = behaviourFilter;
    this.importStatus    = importStatus;
    
    this.nodeService    = serviceRegistry.getNodeService();
    this.versionService = serviceRegistry.getVersionService();
    this.contentService = serviceRegistry.getContentService();
}
 
Example #9
Source File: TaskFormPersister.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public TaskFormPersister(ContentModelItemData<WorkflowTask> itemData,
            NamespaceService namespaceService,
            DictionaryService dictionaryService,
            WorkflowService workflowService,
            NodeService nodeService,
            AuthenticationService authenticationService,
            BehaviourFilter behaviourFilter, Log logger)
{
    super(itemData, namespaceService, dictionaryService, logger);
    WorkflowTask item = itemData.getItem();

    // make sure that the task is not already completed
    if (item.getState().equals(WorkflowTaskState.COMPLETED))
    {
        throw new AlfrescoRuntimeException("workflowtask.already.done.error");
    }

    // make sure the current user is able to edit the task
    if (!workflowService.isTaskEditable(item, authenticationService.getCurrentUserName()))
    {
        throw new AccessDeniedException("Failed to update task with id '" + item.getId() + "'.");
    }
    
    this.updater = new TaskUpdater(item.getId(), workflowService, nodeService, behaviourFilter);
}
 
Example #10
Source File: FileFolderLoader.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @param repoState             keep track of repository readiness
 * @param transactionService    ensure proper rollback, where required
 * @param repositoryHelper      access standard repository paths
 * @param fileFolderService     perform actual file-folder manipulation
 */
public FileFolderLoader(
        RepositoryState repoState,
        TransactionService transactionService,
        Repository repositoryHelper,
        FileFolderService fileFolderService,
        NodeService nodeService,
        ContentService contentService,
        BehaviourFilter policyBehaviourFilter)
{
    this.repoState = repoState;
    this.transactionService = transactionService;
    this.repositoryHelper = repositoryHelper;
    this.fileFolderService = fileFolderService;
    this.nodeService = nodeService;
    this.contentService = contentService;
    this.policyBehaviourFilter = policyBehaviourFilter;
    
    this.normalDistribution = new NormalDistributionHelper();
}
 
Example #11
Source File: VirtualBehaviourFilterExtensionTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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();
}
 
Example #12
Source File: NodeStringLengthWorker.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public NodeStringLengthWorker(
        NodeDAO nodeDAO, JobLockService jobLockService, TransactionService transactionService, QNameDAO qnameDAO,
        BehaviourFilter behaviourFilter,
        int queryRange, int threadCount)
{
    this.nodeDAO = nodeDAO;
    this.jobLockService = jobLockService;
    this.transactionService = transactionService;
    this.qnameDAO = qnameDAO;
    this.behaviourFilter = behaviourFilter;
    
    this.queryRange = queryRange;
    this.threadCount = threadCount;
    this.batchSize = 100;
}
 
Example #13
Source File: TaskUpdater.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public TaskUpdater(String taskId,
            WorkflowService workflowService,
            NodeService nodeService,
            BehaviourFilter behaviourFilter)
{
    this.taskId = taskId;
    this.workflowService = workflowService;
    this.packageMgr = new PackageManager(workflowService, nodeService, behaviourFilter, LOGGER);
}
 
Example #14
Source File: DiscussionServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@BeforeClass public static void initTestsContext() throws Exception
{
    testContext = ApplicationContextHelper.getApplicationContext();
    AUTHENTICATION_SERVICE = (MutableAuthenticationService)testContext.getBean("authenticationService");
    BEHAVIOUR_FILTER       = (BehaviourFilter)testContext.getBean("policyBehaviourFilter");
    DISCUSSION_SERVICE     = (DiscussionService)testContext.getBean("DiscussionService");
    NODE_SERVICE           = (NodeService)testContext.getBean("nodeService");
    PUBLIC_NODE_SERVICE    = (NodeService)testContext.getBean("NodeService");
    PERSON_SERVICE         = (PersonService)testContext.getBean("personService");
    TRANSACTION_HELPER     = (RetryingTransactionHelper)testContext.getBean("retryingTransactionHelper");
    PERMISSION_SERVICE     = (PermissionService)testContext.getBean("permissionService");
    SITE_SERVICE           = (SiteService)testContext.getBean("SiteService");
    TENANT_ADMIN_SERVICE   = testContext.getBean("tenantAdminService", TenantAdminService.class);

    ADMIN_USER = AuthenticationUtil.getAdminUserName() + "@" + TENANT_DOMAIN;

    createTenant();
    
    // Do the setup as admin
    AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER);
    TenantContextHolder.setTenantDomain(TENANT_DOMAIN);
    createUser(TEST_USER);
    
    // We need to create the test site as the test user so that they can contribute content to it in tests below.
    AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER);
    TenantContextHolder.setTenantDomain(TENANT_DOMAIN);
    createTestSites();
}
 
Example #15
Source File: WorkflowFormPersister.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WorkflowFormPersister(ContentModelItemData<?> itemData,
            NamespaceService namespaceService,
            DictionaryService dictionaryService,
            WorkflowService workflowService,
            NodeService nodeService,
            BehaviourFilter behaviourFilter, Log logger)
{
    super(itemData, namespaceService, dictionaryService, logger);
    WorkflowDefinition definition = (WorkflowDefinition) itemData.getItem();
    this.builder = new WorkflowBuilder(definition, workflowService, nodeService, behaviourFilter);
}
 
Example #16
Source File: CalendarServiceImplTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@BeforeClass public static void initTestsContext() throws Exception
{
    AUTHENTICATION_SERVICE = (MutableAuthenticationService)testContext.getBean("authenticationService");
    BEHAVIOUR_FILTER       = (BehaviourFilter)testContext.getBean("policyBehaviourFilter");
    CALENDAR_SERVICE       = (CalendarService)testContext.getBean("CalendarService");
    DICTIONARY_SERVICE     = (DictionaryService)testContext.getBean("dictionaryService");
    NODE_SERVICE           = (NodeService)testContext.getBean("nodeService");
    PUBLIC_NODE_SERVICE    = (NodeService)testContext.getBean("NodeService");
    PERSON_SERVICE         = (PersonService)testContext.getBean("personService");
    TRANSACTION_HELPER     = (RetryingTransactionHelper)testContext.getBean("retryingTransactionHelper");
    PERMISSION_SERVICE     = (PermissionService)testContext.getBean("permissionService");
    SITE_SERVICE           = (SiteService)testContext.getBean("SiteService");
    // Get the canned query registry, and from that the factory
    @SuppressWarnings("unchecked")
    NamedObjectRegistry<CannedQueryFactory<? extends Object>> calendarCannedQueryRegistry =
       (NamedObjectRegistry<CannedQueryFactory<? extends Object>>)testContext.getBean("calendarCannedQueryRegistry");
    CALENDAR_CQ_FACTORY = (GetCalendarEntriesCannedQueryFactory)
       calendarCannedQueryRegistry.getNamedObject(CalendarServiceImpl.CANNED_QUERY_GET_ENTRIES);
    
    // Do the setup as admin
    AuthenticationUtil.setFullyAuthenticatedUser(ADMIN_USER);
    createUser(TEST_USER);
    
    // We need to create the test site as the test user so that they can contribute content to it in tests below.
    AuthenticationUtil.setFullyAuthenticatedUser(TEST_USER);
    createTestSites();
}
 
Example #17
Source File: FormProcessorTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected AbstractWorkflowFormProcessor makeTaskFormProcessor(AbstractWorkflowFormProcessor processor1, DictionaryService dictionaryService,
        MockFieldProcessorRegistry fieldProcessorRegistry, DefaultFieldProcessor defaultProcessor)
{
    processor1.setWorkflowService(workflowService);
    processor1.setNodeService(nodeService);
    processor1.setNamespaceService(namespaceService);
    processor1.setDictionaryService(dictionaryService);
    processor1.setFieldProcessorRegistry(fieldProcessorRegistry);
    processor1.setBehaviourFilter(mock(BehaviourFilter.class));
    // MNT-11809 Activiti losses data with large Aspect or Type property values
    FilterRegistry filterRegistry = new FilterRegistry();
    filterRegistry.addFilter(new WorkflowFormFilter());
    processor1.setFilterRegistry(filterRegistry);
    return processor1;
}
 
Example #18
Source File: DeleteSpaceWebScript.java    From alfresco-bulk-import with Apache License 2.0 5 votes vote down vote up
public DeleteSpaceWebScript(final ServiceRegistry serviceRegistry,
                            final BehaviourFilter behaviourFilter,
                            final NodeService     unauditedNodeService)
{
    // PRECONDITIONS
    assert serviceRegistry      != null : "serviceRegistry must not be null.";
    assert behaviourFilter      != null : "behaviourFilter must not be null.";
    assert unauditedNodeService != null : "unauditedNodeService must not be null.";
    
    // Body
    this.serviceRegistry      = serviceRegistry;
    this.behaviourFilter      = behaviourFilter;
    this.unauditedNodeService = unauditedNodeService;
}
 
Example #19
Source File: AbstractRenderingEngineTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception
{
    super.setUp();

    this.contentService = mock(ContentService.class);
    this.nodeService = mock(NodeService.class);
    engine = new TestRenderingEngine();
    engine.setContentService(contentService);
    engine.setNodeService(nodeService);
    engine.setBehaviourFilter(mock(BehaviourFilter.class));
}
 
Example #20
Source File: RenditionNodeManager.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 
 * @param sourceNode the source node which is being rendered.
 * @param tempRenditionNode the temporary rendition
 * @param location the proposed location of the rendition node.
 * @param renditionDefinition RenditionDefinition
 * @param nodeService NodeService
 * @param renditionService RenditionService
 * @param behaviourFilter BehaviourFilter
 */
public RenditionNodeManager(NodeRef sourceNode, NodeRef tempRenditionNode, RenditionLocation location,
            RenditionDefinition renditionDefinition, NodeService nodeService, RenditionService renditionService,
            BehaviourFilter behaviourFilter)
{
    this.sourceNode = sourceNode;
    this.tempRenditionNode = tempRenditionNode;
    this.location = location;
    this.renditionDefinition = renditionDefinition;
    this.nodeService = nodeService;
    this.renditionService = renditionService;
    this.behaviourFilter = behaviourFilter;
    
    this.existingLinkedRendition = getExistingRendition();

    if (logger.isDebugEnabled())
    {
        StringBuilder msg = new StringBuilder();
        msg.append("Creating/updating rendition based on:").append(LINE_BREAK)
           .append("    sourceNode: ").append(sourceNode).append(LINE_BREAK)
           .append("    tempRendition: ").append(tempRenditionNode).append(LINE_BREAK)
           .append("    parentNode: ").append(location.getParentRef()).append(LINE_BREAK)
           .append("    childNode: ").append(location.getChildRef()).append(LINE_BREAK)
           .append("    childName: ").append(location.getChildName()).append(LINE_BREAK)
           .append("    renditionDefinition.name: ").append(renditionDefinition.getRenditionName());
        logger.debug(msg.toString());
    }
}
 
Example #21
Source File: WorkflowBuilder.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WorkflowBuilder(WorkflowDefinition definition,
            WorkflowService workflowService,
            NodeService nodeService,
            BehaviourFilter behaviourFilter)
{
    this.workflowService = workflowService;
    this.packageMgr = new PackageManager(workflowService, nodeService, behaviourFilter, null);
    this.definition = definition;
}
 
Example #22
Source File: PackageManager.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public PackageManager(WorkflowService workflowService,
            NodeService nodeService,
            BehaviourFilter behaviourFilter,
            Log logger)
{
    this.workflowService = workflowService;
    this.nodeService = nodeService;
    this.behaviourFilter =behaviourFilter;
    this.logger = logger ==null ? LOGGER : logger;
}
 
Example #23
Source File: RenditionServiceIntegrationTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Loads this executor into the ApplicationContext, if it
 *  isn't already there
 */
public static void registerIfNeeded(ApplicationContext ctx)
{
   if(!ctx.containsBean(ENGINE_NAME))
   {
      // Create, and do dependencies
      DummyHelloWorldRenditionEngine hw = new DummyHelloWorldRenditionEngine();
      hw.setRuntimeActionService(
            (RuntimeActionService)ctx.getBean("actionService")
      );
      hw.setNodeService(
            (NodeService)ctx.getBean("NodeService")
      );
      hw.setContentService(
            (ContentService)ctx.getBean("ContentService")
      );
      hw.setRenditionService(
            (RenditionService)ctx.getBean("RenditionService")
      );
      hw.setBehaviourFilter(
            (BehaviourFilter)ctx.getBean("policyBehaviourFilter")
      );
      hw.setRenditionLocationResolver(
            (RenditionLocationResolver)ctx.getBean("renditionLocationResolver")
      );
      
      // Register
       ((ConfigurableApplicationContext) ctx).getBeanFactory().registerSingleton(
            ENGINE_NAME, hw
      );
      hw.init();
   }
}
 
Example #24
Source File: AuthenticationTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setUp() throws Exception
{
    if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
    {
        throw new AlfrescoRuntimeException(
                "A previous tests did not clean up transaction: " +
                AlfrescoTransactionSupport.getTransactionId());
    }
    
    dialect = (Dialect) ctx.getBean("dialect");
    nodeService = (NodeService) ctx.getBean("nodeService");
    authorityService = (AuthorityService) ctx.getBean("authorityService");
    tenantService = (TenantService) ctx.getBean("tenantService");
    tenantAdminService = (TenantAdminService) ctx.getBean("tenantAdminService");
    compositePasswordEncoder = (CompositePasswordEncoder) ctx.getBean("compositePasswordEncoder");
    ticketComponent = (TicketComponent) ctx.getBean("ticketComponent");
    authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService");
    pubAuthenticationService = (MutableAuthenticationService) ctx.getBean("AuthenticationService");
    authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
    authenticationComponentImpl = (AuthenticationComponent) ctx.getBean("authenticationComponent");
    pubPersonService =  (PersonService) ctx.getBean("PersonService");
    personService =  (PersonService) ctx.getBean("personService");
    policyComponent = (PolicyComponent) ctx.getBean("policyComponent");
    behaviourFilter = (BehaviourFilter) ctx.getBean("policyBehaviourFilter");
    authenticationCache = (SimpleCache<String, CacheEntry>) ctx.getBean("authenticationCache");
    immutableSingletonCache = (SimpleCache<String, NodeRef>) ctx.getBean("immutableSingletonCache");
    // permissionServiceSPI = (PermissionServiceSPI)
    // ctx.getBean("permissionService");
    ticketsCache = (SimpleCache<String, Ticket>) ctx.getBean("ticketsCache");
    usernameToTicketIdCache = (SimpleCache<String, String>) ctx.getBean("usernameToTicketIdCache");

    ChildApplicationContextFactory sysAdminSubsystem = (ChildApplicationContextFactory) ctx.getBean("sysAdmin");
    assertNotNull("sysAdminSubsystem", sysAdminSubsystem);
    ApplicationContext sysAdminCtx  = sysAdminSubsystem.getApplicationContext();
    sysAdminParams = (SysAdminParamsImpl) sysAdminCtx.getBean("sysAdminParams");

    dao = (MutableAuthenticationDao) ctx.getBean("authenticationDao");
    
    // Let's look inside the alfresco authentication subsystem to get the DAO-wired authentication manager
    ChildApplicationContextManager authenticationChain = (ChildApplicationContextManager) ctx.getBean("Authentication");
    ApplicationContext subsystem = authenticationChain.getApplicationContext(authenticationChain.getInstanceIds().iterator().next());
    authenticationManager = (AuthenticationManager) subsystem.getBean("authenticationManager");

    transactionService = (TransactionService) ctx.getBean(ServiceRegistry.TRANSACTION_SERVICE.getLocalName());
    
    // Clean up before we start trying to create the test user
    transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Void>()
    {
        @Override
        public Void execute() throws Throwable
        {
            AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
            try
            {
                deleteAndy();
                return null;
            }
            finally
            {
                authenticationComponent.clearCurrentSecurityContext();
            }
        }
    }, false, true);
    
    userTransaction = transactionService.getUserTransaction();
    userTransaction.begin();

    StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
    rootNodeRef = nodeService.getRootNode(storeRef);

    QName children = ContentModel.ASSOC_CHILDREN;
    QName system = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "system");
    QName container = ContentModel.TYPE_CONTAINER;
    QName types = QName.createQName(NamespaceService.SYSTEM_MODEL_1_0_URI, "people");

    systemNodeRef = nodeService.createNode(rootNodeRef, children, system, container).getChildRef();
    typesNodeRef = nodeService.createNode(systemNodeRef, children, types, container).getChildRef();
    Map<QName, Serializable> props = createPersonProperties("Andy");
    personAndyNodeRef = nodeService.createNode(typesNodeRef, children, ContentModel.TYPE_PERSON, container, props).getChildRef();
    assertNotNull(personAndyNodeRef);
    
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName());
    
    authenticationComponent.clearCurrentSecurityContext();
}
 
Example #25
Source File: LockServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
{
    this.behaviourFilter = behaviourFilter;
}
 
Example #26
Source File: LinksRestApiTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void setUp() throws Exception
{
    super.setUp();
    
    this.authenticationService = (MutableAuthenticationService)getServer().getApplicationContext().getBean("AuthenticationService");
    this.authenticationComponent = (AuthenticationComponent)getServer().getApplicationContext().getBean("authenticationComponent");
    this.policyBehaviourFilter = (BehaviourFilter)getServer().getApplicationContext().getBean("policyBehaviourFilter");
    this.transactionService = (TransactionService)getServer().getApplicationContext().getBean("transactionService");
    this.personService = (PersonService)getServer().getApplicationContext().getBean("PersonService");
    this.nodeService = (NodeService)getServer().getApplicationContext().getBean("NodeService");
    this.siteService = (SiteService)getServer().getApplicationContext().getBean("SiteService");
    this.internalNodeService = (NodeService)getServer().getApplicationContext().getBean("nodeService");
    this.nodeArchiveService = (NodeArchiveService)getServer().getApplicationContext().getBean("nodeArchiveService");
    this.activityService = (ActivityService)getServer().getApplicationContext().getBean("activityService");
    ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory)getServer().getApplicationContext().getBean("ActivitiesFeed");
    ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext();
    this.feedGenerator = (FeedGenerator)activitiesFeedCtx.getBean("feedGenerator");
    this.postLookup = (PostLookup)activitiesFeedCtx.getBean("postLookup");


    // Authenticate as user
    this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
    
    // Create test site
    // - only create the site if it doesn't already exist
    SiteInfo siteInfo = this.siteService.getSite(SITE_SHORT_NAME_LINKS);
    if (siteInfo == null)
    {
        this.siteService.createSite("CalendarSitePreset", SITE_SHORT_NAME_LINKS, "LinksSiteTitle", "TestDescription", SiteVisibility.PUBLIC);
    }
    
    // Ensure the links container is there
    if (!siteService.hasContainer(SITE_SHORT_NAME_LINKS, "links"))
    {
        siteService.createContainer(SITE_SHORT_NAME_LINKS, "links", null, null);
    }
    
    // Create users
    createUser(USER_ONE, SiteModel.SITE_COLLABORATOR, SITE_SHORT_NAME_LINKS);
    createUser(USER_TWO, SiteModel.SITE_COLLABORATOR, SITE_SHORT_NAME_LINKS);

    // Do tests as inviter user
    this.authenticationComponent.setCurrentUser(USER_ONE);
}
 
Example #27
Source File: WebDAVHelper.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
public BehaviourFilter getPolicyBehaviourFilter()
{
    return m_policyBehaviourFilter;
}
 
Example #28
Source File: WorkingCopyAspect.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * @param policyBehaviourFilter BehaviourFilter
 */
public void setPolicyBehaviourFilter(BehaviourFilter policyBehaviourFilter)
{
    this.policyBehaviourFilter = policyBehaviourFilter;
}
 
Example #29
Source File: PersonTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public void setUp() throws Exception
{
    AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName());
    
    if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
    {
        throw new AlfrescoRuntimeException(
                "A previous tests did not clean up transaction: " +
                AlfrescoTransactionSupport.getTransactionId());
    }
    
    transactionService = (TransactionService) ctx.getBean("transactionService");
    personService = (PersonService) ctx.getBean("personService");
    userNameMatcher = (UserNameMatcherImpl) ctx.getBean("userNameMatcher");
    nodeService = (NodeService) ctx.getBean("nodeService");
    permissionService = (PermissionService) ctx.getBean("permissionService");
    authorityService = (AuthorityService) ctx.getBean("authorityService");
    authenticationDAO = (MutableAuthenticationDao) ctx.getBean("authenticationDao");
    policyBehaviourFilter = (BehaviourFilter) ctx.getBean("policyBehaviourFilter");

    testTX = transactionService.getUserTransaction();
    testTX.begin();

    //Set a max number of users.
    RepoUsageComponentImpl repoUsageComponent = (RepoUsageComponentImpl) ctx.getBean("repoUsageComponent");
    RepoUsage r = repoUsageComponent.getRestrictions();
    repoUsageComponent.setRestrictions(
            new RepoUsage(r.getLastUpdate(),
                    10000l,
                    r.getDocuments(),
                    r.getLicenseMode(),
                    r.getLicenseExpiryDate(),
                    r.isReadOnly()));
    
    StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis());
    rootNodeRef = nodeService.getRootNode(storeRef);
    
    for (NodeRef nodeRef : personService.getAllPeople())
    {
        String uid = DefaultTypeConverter.INSTANCE.convert(String.class, nodeService.getProperty(nodeRef, ContentModel.PROP_USERNAME));
        if (!uid.equals(AuthenticationUtil.getAdminUserName()) && !uid.equals(AuthenticationUtil.getGuestUserName()))
        {
            personService.deletePerson(nodeRef);
        }
    }
    
    personService.setCreateMissingPeople(true);
    
    testTX.commit();
    testTX = transactionService.getUserTransaction();
    testTX.begin();
}
 
Example #30
Source File: DeleteRenditionActionExecuter.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
{
    this.behaviourFilter = behaviourFilter;
}