@Override public SearchService getSearchService() { return serviceRegistry.getSearchService(); }
@Override public SearchService getSearchService() { return serviceRegistry.getSearchService(); }
/** * Gets the company home node * * @return the company home node ref */ private NodeRef getCompanyHome() { NodeRef companyHomeRef; List<NodeRef> refs = this.serviceRegistry.getSearchService().selectNodes( this.serviceRegistry.getNodeService().getRootNode(storeRef), companyHomePath, null, this.serviceRegistry.getNamespaceService(), false); if (refs.size() != 1) { throw new IllegalStateException("Invalid company home path: " + companyHomePath + " - found: " + refs.size()); } companyHomeRef = refs.get(0); return companyHomeRef; } }
/** * Gets the company home node * * @return the company home node ref */ private NodeRef getCompanyHome() { NodeRef companyHomeRef; List<NodeRef> refs = this.serviceRegistry.getSearchService().selectNodes( this.serviceRegistry.getNodeService().getRootNode(storeRef), companyHomePath, null, this.serviceRegistry.getNamespaceService(), false); if (refs.size() != 1) { throw new IllegalStateException("Invalid company home path: " + companyHomePath + " - found: " + refs.size()); } companyHomeRef = refs.get(0); return companyHomeRef; } }
private ServiceRegistry mockServiceRegistry() { SearchService searchService = mock(SearchService.class); ResultSet results = mock(ResultSet.class); List<Pair<String, Integer>> fieldFacets1 = new ArrayList<>(); fieldFacets1.add(new Pair<>(mimetype1, 1)); fieldFacets1.add(new Pair<>(mimetype2, 2)); List<Pair<String, Integer>> fieldFacets2 = new ArrayList<>(); fieldFacets2.add(new Pair<>(modifier, 1)); when(results.getFieldFacet(fieldFacet1)).thenReturn(fieldFacets1); when(results.getFieldFacet(fieldFacet2)).thenReturn(fieldFacets2); when(results.getFacetQueries()).thenReturn(new HashMap<>()); when(searchService.query((SearchParameters) any())).thenReturn(results); FacetLabelDisplayHandlerRegistry displayHandlerRegistry = mock(FacetLabelDisplayHandlerRegistry.class); ServiceRegistry services = mock(ServiceRegistry.class); when(services.getSearchService()).thenReturn(searchService); when(displayHandlerRegistry.getDisplayHandler(fieldFacet1)).thenReturn(new MimetypeOrderDisplayHandler()); when(displayHandlerRegistry.getDisplayHandler(fieldFacet2)).thenReturn(null); SolrFacetHelper solrFacetHelper = mock(SolrFacetHelper.class); when(solrFacetHelper.getBucketedFieldFacets()).thenReturn(new HashSet<>()); when(services.getSolrFacetHelper()).thenReturn(solrFacetHelper); when(services.getFacetLabelDisplayHandlerRegistry()).thenReturn(displayHandlerRegistry); return services; }
/** * @return ServiceRegistry */ private ServiceRegistry mockServices() { ActionService mockActionService = mockActionService(); NodeService mockNodeService = mockNodeService(); PersonService mockPersonService = mockPersonService(); SearchService mockSearchService = mockSearchService(); SiteService mockSiteService = mockSiteService(); FileFolderService mockFileFolderService = mockFileFolderService(); ServiceRegistry services = mock(ServiceRegistry.class); when(services.getActionService()).thenReturn(mockActionService); when(services.getNodeService()).thenReturn(mockNodeService); when(services.getPersonService()).thenReturn(mockPersonService); when(services.getSearchService()).thenReturn(mockSearchService); when(services.getSiteService()).thenReturn(mockSiteService); when(services.getFileFolderService()).thenReturn(mockFileFolderService); return services; }
public InviteSender(ServiceRegistry services, Repository repository, MessageService messageService) { this.actionService = services.getActionService(); this.nodeService = services.getNodeService(); this.personService = services.getPersonService(); this.searchService = services.getSearchService(); this.siteService = services.getSiteService(); this.fileFolderService = services.getFileFolderService(); this.repoAdminService = services.getRepoAdminService(); this.namespaceService = services.getNamespaceService(); this.repository = repository; this.messageService = messageService; }
protected void setUp() throws Exception { MockitoAnnotations.initMocks(this); ctx = ApplicationContextHelper.getApplicationContext(); people = (People) ctx.getBean("peopleScript"); serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry"); transactionService = serviceRegistry.getTransactionService(); personService = serviceRegistry.getPersonService(); ServiceRegistry mockServiceRegistry = spy(serviceRegistry); people.setServiceRegistry(mockServiceRegistry); doReturn(mockSearchService).when(mockServiceRegistry).getSearchService(); when(mockSearchService.query(any())).thenReturn(mockResultSet); when(mockResultSet.getNodeRefs()).thenReturn(mockResultSetNodeRefs); AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); createUsers(); // Start a transaction txn = transactionService.getUserTransaction(); txn.begin(); }
public InviteSender(ServiceRegistry services, Repository repository, MessageService messageService) { this.actionService = services.getActionService(); this.nodeService = services.getNodeService(); this.personService = services.getPersonService(); this.searchService = services.getSearchService(); this.siteService = services.getSiteService(); this.fileFolderService = services.getFileFolderService(); this.repoAdminService = services.getRepoAdminService(); this.namespaceService = services.getNamespaceService(); this.repository = repository; this.messageService = messageService; }
@Override public void setUp() throws Exception { ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); retryingTransactionHelper = (RetryingTransactionHelper) ctx.getBean("retryingTransactionHelper"); authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); fileFolderService = serviceRegistry.getFileFolderService(); searchService = serviceRegistry.getSearchService(); namespaceService = serviceRegistry.getNamespaceService(); nodeService = getNodeService(); authenticate(USERNAME); rootFolderRef = getOrCreateRootFolder(); dataFile = AbstractContentTransformerTest.loadQuickTestFile("txt"); }
private NodeRef findWorkflowParent() { RepositoryLocation workflowLocation = (RepositoryLocation) applicationContext.getBean("customWorkflowDefsRepositoryLocation"); NodeRef rootNode = nodeService.getRootNode(workflowLocation.getStoreRef()); List<NodeRef> workflowParents = serviceRegistry.getSearchService().selectNodes( rootNode, workflowLocation.getPath(), null, serviceRegistry.getNamespaceService(), false); if (workflowParents.size() == 0) { throw new IllegalStateException("Unable to find workflow location: "+workflowLocation.getPath()); } if (workflowParents.size() > 1) { throw new IllegalStateException("More than one workflow location? ["+workflowLocation.getPath()+"]"); } return workflowParents.get(0); }
public void setUp() { ctx = ApplicationContextHelper.getApplicationContext(); serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); nodeService = serviceRegistry.getNodeService(); searchService = serviceRegistry.getSearchService(); dictionaryService = serviceRegistry.getDictionaryService(); contentService = serviceRegistry.getContentService(); authenticationService = (MutableAuthenticationService) ctx.getBean("authenticationService"); authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); permissionService = serviceRegistry.getPermissionService(); mimetypeService = serviceRegistry.getMimetypeService(); namespaceService = serviceRegistry.getNamespaceService(); transactionService = serviceRegistry.getTransactionService(); authenticationComponent.setSystemUserAsCurrentUser(); StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); rootNodeRef = nodeService.getRootNode(storeRef); }
public void init() { PropertyCheck.mandatory(this, "serviceRegistry", serviceRegistry); PropertyCheck.mandatory(this, "preferenceService", preferenceService); PropertyCheck.mandatory(this, "repositoryHelper", repositoryHelper); PropertyCheck.mandatory(this, "companyHomeChildName", companyHomeChildName); this.nodeService = serviceRegistry.getNodeService(); this.searchService = serviceRegistry.getSearchService(); this.namespaceService = serviceRegistry.getNamespaceService(); this.fileFolderService = serviceRegistry.getFileFolderService(); this.personService = serviceRegistry.getPersonService(); // set the template loader setTemplateLoader(new ClassPathRepoTemplateLoader(nodeService, serviceRegistry.getContentService(), "utf-8")); }
public void init() { PropertyCheck.mandatory(this, "serviceRegistry", serviceRegistry); PropertyCheck.mandatory(this, "preferenceService", preferenceService); PropertyCheck.mandatory(this, "repositoryHelper", repositoryHelper); PropertyCheck.mandatory(this, "companyHomeChildName", companyHomeChildName); this.nodeService = serviceRegistry.getNodeService(); this.searchService = serviceRegistry.getSearchService(); this.namespaceService = serviceRegistry.getNamespaceService(); this.fileFolderService = serviceRegistry.getFileFolderService(); this.personService = serviceRegistry.getPersonService(); // set the template loader setTemplateLoader(new ClassPathRepoTemplateLoader(nodeService, serviceRegistry.getContentService(), "utf-8")); }
@SuppressWarnings("deprecation") @Override public void setUp() throws Exception { auditModelRegistry = (AuditModelRegistryImpl) ctx.getBean("auditModel.modelRegistry"); serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); auditComponent = (AuditComponent) ctx.getBean("auditComponent"); auditService = serviceRegistry.getAuditService(); transactionService = serviceRegistry.getTransactionService(); transactionServiceImpl = (TransactionServiceImpl) ctx.getBean("transactionService"); nodeService = serviceRegistry.getNodeService(); searchService = serviceRegistry.getSearchService(); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); nodeRef = nodeService.getRootNode(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE); // Register the models URL modelUrlMnt11072 = ResourceUtils.getURL("classpath:alfresco/testaudit/alfresco-audit-test-mnt-11072.xml"); URL modelUrlMnt16748 = ResourceUtils.getURL("classpath:alfresco/testaudit/alfresco-audit-test-mnt-16748.xml"); auditModelRegistry.registerModel(modelUrlMnt11072); auditModelRegistry.registerModel(modelUrlMnt16748); auditModelRegistry.loadAuditModels(); }
/** * This method performs a query with a selected searchService. * * @param ql Search services * @param query * @param limit limits the result set to a maximum number. * @return */ public ResultSet query(String ql, String query, Integer limit) { SearchParameters sp = new SearchParameters(); sp.setLanguage(ql); sp.setQueryConsistency(QueryConsistency.TRANSACTIONAL); sp.setQuery(query); sp.addStore(rootNodeRef.getStoreRef()); // set limit parameter if different from null. if (limit != null) { sp.setLimit(limit); sp.setLimitBy(LimitBy.FINAL_SIZE); } return serviceRegistry.getSearchService().query(sp); }
public void testNoRead() { SearchParameters sp; ResultSet results; build1000Nodes("1001", PermissionService.WRITE, true); runAs("1001"); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage(SearchService.LANGUAGE_LUCENE); sp.setQuery("TYPE:\"cm:content\""); sp.setMaxItems(Integer.MAX_VALUE); sp.setMaxPermissionChecks(Integer.MAX_VALUE); sp.setMaxPermissionCheckTimeMillis(Integer.MAX_VALUE); results = serviceRegistry.getSearchService().query(sp); int length = results.length(); results.close(); assertEquals(0, length); }
public void testReadDeny() { SearchParameters sp; ResultSet results; build1000NodesReadDenied("1001"); runAs("1001"); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage(SearchService.LANGUAGE_LUCENE); sp.setQuery("TYPE:\"cm:content\""); sp.setMaxItems(Integer.MAX_VALUE); sp.setMaxPermissionChecks(Integer.MAX_VALUE); sp.setMaxPermissionCheckTimeMillis(Integer.MAX_VALUE); results = serviceRegistry.getSearchService().query(sp); int length = results.length(); results.close(); assertEquals(0, length); }
public void testAdminCanRead() { runAs("Web1"); buildNodes("1001", "Read", 10, true); SearchParameters sp; ResultSet results; runAs("admin"); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage(SearchService.LANGUAGE_LUCENE); sp.setQuery("TYPE:\"cm:content\""); sp.setMaxItems(Integer.MAX_VALUE); sp.setMaxPermissionChecks(Integer.MAX_VALUE); sp.setMaxPermissionCheckTimeMillis(Integer.MAX_VALUE); results = serviceRegistry.getSearchService().query(sp); results.setBulkFetch(false); assertEquals(10, results.length()); results.close(); }
public void testNodeOwner() { SearchParameters sp; ResultSet results; buildOwnedNodes("1001", 0); runAs(AuthenticationUtil.getAdminUserName()); runAs("1001"); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage(SearchService.LANGUAGE_LUCENE); sp.setQuery("PATH:\"//*\""); sp.setMaxItems(Integer.MAX_VALUE); sp.setMaxPermissionChecks(Integer.MAX_VALUE); sp.setMaxPermissionCheckTimeMillis(Integer.MAX_VALUE); results = serviceRegistry.getSearchService().query(sp); int length = results.length(); results.close(); assertEquals(1001, length); // folder + children }