org.alfresco.service.cmr.site.SiteService Java Examples
The following examples show how to use
org.alfresco.service.cmr.site.SiteService.
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: CustomRoleTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void testCustomRole() { try { // Create a site siteService.createSite("customrolessite", "customrolessite", "Test custom role", "Test custom role", SiteVisibility.PUBLIC); this.siteService.setMembership("customrolessite", USER_TWO, "SiteCoordinator"); // Get the members of the site final List<Pair<SiteService.SortFields, Boolean>> sort = new ArrayList<Pair<SiteService.SortFields, Boolean>>(); sort.add(new Pair<SiteService.SortFields, Boolean>(SiteService.SortFields.SiteTitle, Boolean.TRUE)); sort.add(new Pair<SiteService.SortFields, Boolean>(SiteService.SortFields.Role, Boolean.TRUE)); PagingResults<SiteMembership> sites = siteService.listSitesPaged(USER_TWO, sort, new PagingRequest(0, 100)); assertNotNull(sites); assertEquals(sites.getPage().size(), 1); } catch (Exception ex) { fail("Custom role breaks sites API. Take a look on MNT-12873\n" + ex.getMessage()); } }
Example #2
Source File: BlogServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@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 #3
Source File: LinksServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@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 #4
Source File: InviteSenderTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * @return ServiceRegistry */ private ServiceRegistry mockServices() { ActionService mockActionService = mockActionService(); NodeService mockNodeService = mockNodeService(); PersonService mockPersonService = mockPersonService(); SearchService mockSearchService = mockSearchService(); SiteService mockSiteService = mockSiteService(); FileFolderService mockFileFolderService = mockFileFolderService(); RepoAdminService mockRepoAdminService = mockRepoAdminService(); SysAdminParams sysAdminParams = new SysAdminParamsImpl(); 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); when(services.getSysAdminParams()).thenReturn(sysAdminParams); when(services.getRepoAdminService()).thenReturn(mockRepoAdminService); return services; }
Example #5
Source File: WebDAVHelper.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
public String determineSiteId(NodeRef rootNodeRef, String path) { SiteService siteService = getServiceRegistry().getSiteService(); String siteId; try { FileInfo fileInfo = getNodeForPath(rootNodeRef, path); siteId = siteService.getSiteShortName(fileInfo.getNodeRef()); if (siteId == null) { throw new RuntimeException("Node is not contained by a site: " + path); } } catch (Exception error) { siteId = EMPTY_SITE_ID; } return siteId; }
Example #6
Source File: QuickShareRestApiTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 6 votes |
private SiteInfo createSite(final String shortName) { return transactionHelper.doInTransaction(new RetryingTransactionCallback<SiteInfo>() { @Override public SiteInfo execute() throws Throwable { SiteInfo siteInfo = siteService.getSite(shortName); if (siteInfo != null) { // Tidy up after failed earlier run siteService.deleteSite(shortName); } // Do the create SiteInfo site = siteService.createSite("Testing", shortName, shortName, "myDescription", SiteVisibility.PUBLIC); // Ensure we have a doclib siteService.createContainer(shortName, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null); // All done return site; } }, false, true ); }
Example #7
Source File: CustomRoleTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Before public void before() throws Exception { super.before(); // Get the required services this.authenticationComponent = (AuthenticationComponent) this.applicationContext.getBean("authenticationComponent"); this.siteService = (SiteService) this.applicationContext.getBean("SiteService"); this.personService = (PersonService) this.applicationContext.getBean("PersonService"); // Create the test users createUser(USER_ONE, "UserOne"); createUser(USER_TWO, "UserTwo"); // Set the current authentication this.authenticationComponent.setCurrentUser(USER_ONE); }
Example #8
Source File: QuickShareServiceIntegrationTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
private static void findServices() { ApplicationContext ctx = testContext.getApplicationContext(); copyService = ctx.getBean("CopyService", CopyService.class); nodeService = ctx.getBean("NodeService", NodeService.class); directQuickShareService = ctx.getBean("quickShareService", QuickShareService.class); quickShareService = ctx.getBean("QuickShareService", QuickShareService.class); repository = ctx.getBean("repositoryHelper", Repository.class); attributeService = ctx.getBean("AttributeService", AttributeService.class); permissionService = ctx.getBean("PermissionService", PermissionService.class); nodeArchiveService = ctx.getBean("nodeArchiveService", NodeArchiveService.class); scheduledPersistedActionService = ctx.getBean("scheduledPersistedActionService", ScheduledPersistedActionService.class); quickShareLinkExpiryActionPersister = ctx.getBean("quickShareLinkExpiryActionPersister", QuickShareLinkExpiryActionPersister.class); transactionHelper = ctx.getBean("retryingTransactionHelper", RetryingTransactionHelper.class); globalProperties = ctx.getBean("global-properties", Properties.class); siteService = (SiteService) ctx.getBean("SiteService"); }
Example #9
Source File: SiteServiceImplMoreTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
@Test public void testSiteMembersPaged() { // Choose a site name that will link back to this test case... final String siteShortName = testName.getMethodName(); log.debug("Creating test site called: " + siteShortName); TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<Void>() { public Void execute() throws Throwable { // ...and create the site final TestSiteAndMemberInfo testSiteAndMemberInfo = perMethodTestSites.createTestSiteWithUserPerRole(siteShortName, "sitePreset", SiteVisibility.PUBLIC, AuthenticationUtil.getAdminUserName()); List<Pair<SiteService.SortFields, Boolean>> sortProps = new ArrayList<Pair<SiteService.SortFields, Boolean>>(1); sortProps.add(new Pair<SiteService.SortFields, Boolean>(SiteService.SortFields.FirstName, true)); PagingResults<SiteMembership> pagedMembers = SITE_SERVICE.listMembersPaged(siteShortName, true, sortProps, new PagingRequest(100)); assertNotNull(pagedMembers); assertNotNull(pagedMembers.getPage()); assertNotNull(pagedMembers.getQueryExecutionId()); assertFalse(pagedMembers.hasMoreItems()); log.debug("About to delete site completely."); SITE_SERVICE.deleteSite(siteShortName); return null; } }); }
Example #10
Source File: DocLibNodeLocator.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
/** * Finds the site in which the source {@link NodeRef} resides and returns the Document Library container for that site. * If no site can be found or the site does not have a Document Library then the Company Home is returned. * * @param source the starting point for locating the site Document Library. * @param params Not used. * @return the Document Library or the Company Home. */ @Override public NodeRef getNode(NodeRef source, Map<String, Serializable> params) { NodeRef docLib = null; if (source != null) { String siteName = siteService.getSiteShortName(source); if (siteName != null) { String containerId = SiteService.DOCUMENT_LIBRARY; docLib = siteService.getContainer(siteName, containerId); } } if (docLib == null) { docLib = repositoryHelper.getCompanyHome(); } return docLib; }
Example #11
Source File: SiteMembersCannedQuery.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
protected SiteMembersCannedQuery(SiteService siteService, PersonService personService, NodeService nodeService, CannedQueryParameters parameters) { super(parameters); this.personService = personService; this.nodeService = nodeService; this.siteService = siteService; }
Example #12
Source File: SurfConfigTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); this.siteService = (SiteService) getServer().getApplicationContext().getBean("SiteService"); this.nodeService = (NodeService) getServer().getApplicationContext().getBean("NodeService"); this.permissionService = (PermissionService) getServer().getApplicationContext().getBean("PermissionService"); this.fileFolderService = (FileFolderService) getServer().getApplicationContext().getBean("FileFolderService"); createUser(USER_ONE); createUser(USER_TWO); createUser(USER_THREE); AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE); }
Example #13
Source File: ActivityServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void setUp() throws Exception { activityService = (ActivityService)ctx.getBean("activityService"); scriptService = (ScriptService)ctx.getBean("ScriptService"); siteService = (SiteService)ctx.getBean("SiteService"); nodeArchiveService = (NodeArchiveService)ctx.getBean("nodeArchiveService"); transactionService = (TransactionService)ctx.getBean("TransactionService"); postDAO = (ActivityPostDAO)ctx.getBean("postDAO"); authenticationService = (MutableAuthenticationService)ctx.getBean("AuthenticationService"); authenticationService.authenticate(AuthenticationUtil.getAdminUserName(), ADMIN_PW.toCharArray()); }
Example #14
Source File: MkcolMethod.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
/** * Create a folder added activity post. * * @throws WebDAVServerException */ private void postActivity(FileInfo fileInfo) throws WebDAVServerException { WebDavService davService = getDAVHelper().getServiceRegistry().getWebDavService(); if (!davService.activitiesEnabled()) { // Don't post activities if this behaviour is disabled. return; } String siteId = getSiteId(); String tenantDomain = getTenantDomain(); // Check there is enough information to publish site activity. if (!siteId.equals(WebDAVHelper.EMPTY_SITE_ID)) { SiteService siteService = getServiceRegistry().getSiteService(); NodeRef documentLibrary = siteService.getContainer(siteId, SiteService.DOCUMENT_LIBRARY); String path = "/"; try { path = getDAVHelper().getPathFromNode(documentLibrary, fileInfo.getNodeRef()); } catch (FileNotFoundException error) { if (logger.isDebugEnabled()) { logger.debug("No " + SiteService.DOCUMENT_LIBRARY + " container found."); } } activityPoster.postFileFolderAdded(siteId, tenantDomain, path, fileInfo); } }
Example #15
Source File: SiteServiceImplMoreTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@BeforeClass public static void initStaticData() throws Exception { AUTHORITY_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("AuthorityService", AuthorityService.class); NAMESPACE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("namespaceService", NamespaceService.class); NODE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("NodeService", NodeService.class); NODE_ARCHIVE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("nodeArchiveService", NodeArchiveService.class); SITE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("siteService", SiteService.class); COCI_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("checkOutCheckInService", CheckOutCheckInService.class); TRANSACTION_HELPER = APP_CONTEXT_INIT.getApplicationContext().getBean("retryingTransactionHelper", RetryingTransactionHelper.class); PERMISSION_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("permissionServiceImpl", PermissionService.class); AUTHENTICATION_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("authenticationService", MutableAuthenticationService.class); PERSON_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("PersonService", PersonService.class); FILE_FOLDER_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("FileFolderService",FileFolderService.class); AUTHENTICATION_COMPONENT = APP_CONTEXT_INIT.getApplicationContext().getBean("authenticationComponent",AuthenticationComponent.class); LOCK_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("lockService",LockService.class); // We'll create this test content as admin. final String admin = AuthenticationUtil.getAdminUserName(); TEST_SITE_NAME = GUID.generate(); TEST_SUB_SITE_NAME = GUID.generate(); final QName subSiteType = QName.createQName("testsite", "testSubsite", NAMESPACE_SERVICE); STATIC_TEST_SITES.createSite("sitePreset", TEST_SITE_NAME, "siteTitle", "siteDescription", SiteVisibility.PUBLIC, admin); STATIC_TEST_SITES.createSite("sitePreset", TEST_SUB_SITE_NAME, "siteTitle", "siteDescription", SiteVisibility.PUBLIC, subSiteType, admin); TEST_SITE_WITH_MEMBERS = STATIC_TEST_SITES.createTestSiteWithUserPerRole(SiteServiceImplMoreTest.class.getSimpleName(), "sitePreset", SiteVisibility.PUBLIC, admin); }
Example #16
Source File: QuickShareRestApiTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); authenticationService = (MutableAuthenticationService) getServer().getApplicationContext().getBean("AuthenticationService"); authenticationComponent = (AuthenticationComponent) getServer().getApplicationContext().getBean("AuthenticationComponent"); nodeService = (NodeService) getServer().getApplicationContext().getBean("NodeService"); contentService = (ContentService) getServer().getApplicationContext().getBean("ContentService"); personService = (PersonService) getServer().getApplicationContext().getBean("PersonService"); permissionService = (PermissionService) getServer().getApplicationContext().getBean("PermissionService"); siteService = (SiteService) getServer().getApplicationContext().getBean("SiteService"); repositoryHelper = (Repository) getServer().getApplicationContext().getBean("repositoryHelper"); transactionHelper = (RetryingTransactionHelper)getServer().getApplicationContext().getBean("retryingTransactionHelper"); fileFolderService = (FileFolderService)getServer().getApplicationContext().getBean("FileFolderService"); synchronousTransformClient = (SynchronousTransformClient) getServer().getApplicationContext().getBean("synchronousTransformClient"); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); createUser(USER_ONE); createUser(USER_TWO); AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE); userOneHome = repositoryHelper.getUserHome(personService.getPerson(USER_ONE)); // no pun intended quickFile = AbstractContentTransformerTest.loadQuickTestFile("jpg"); TEST_CONTENT = new byte[new Long(quickFile.length()).intValue()]; new FileInputStream(quickFile).read(TEST_CONTENT); testNode = createTestFile(userOneHome, TEST_NAME, quickFile); AuthenticationUtil.setFullyAuthenticatedUser(USER_TWO); assertEquals(AccessStatus.DENIED, permissionService.hasPermission(testNode, PermissionService.READ)); AuthenticationUtil.clearCurrentSecurityContext(); }
Example #17
Source File: Site.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Constructor * * @param siteInfo site information */ /*package*/ Site(SiteInfo siteInfo, ServiceRegistry serviceRegistry, SiteService siteService, Scriptable scope) { this.serviceRegistry = serviceRegistry; this.siteService = siteService; this.siteInfo = siteInfo; this.scope = scope; this.invitationService = serviceRegistry.getInvitationService(); NodeService nodeService = serviceRegistry.getNodeService(); PersonService personService = serviceRegistry.getPersonService(); this.scriptInvitationFactory = new ScriptInvitationFactory(invitationService, nodeService, personService); }
Example #18
Source File: SubscriptionServiceActivitiesTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@BeforeClass public static void setUp() throws Exception { final ApplicationContext ctx = APP_CONTEXT_INIT.getApplicationContext(); // Let's shut down the scheduler so that we aren't competing with the // scheduled versions of the post lookup and // feed generator jobs // Note that to ensure this test class can be run within a suite, that we do not want to actually 'shutdown' the scheduler. // It may be needed by other test classes and must be restored to life after this class has run. QUARTZ_SCHEDULER = ctx.getBean("schedulerFactory", Scheduler.class); QUARTZ_SCHEDULER.standby(); // Get the required services subscriptionService = (SubscriptionService) ctx.getBean("SubscriptionService"); personService = (PersonService) ctx.getBean("PersonService"); siteService = (SiteService) ctx.getBean("SiteService"); activityService = (ActivityService) ctx.getBean("activityService"); nodeService = (NodeService) ctx.getBean("NodeService"); contentService = (ContentService) ctx.getBean("ContentService"); nodeArchiveService = (NodeArchiveService)ctx.getBean("nodeArchiveService"); transactionHelper = (RetryingTransactionHelper) ctx.getBean("retryingTransactionHelper"); ChildApplicationContextFactory activitiesFeed = (ChildApplicationContextFactory) ctx.getBean("ActivitiesFeed"); ApplicationContext activitiesFeedCtx = activitiesFeed.getApplicationContext(); postLookup = (PostLookup) activitiesFeedCtx.getBean("postLookup"); feedGenerator = (FeedGenerator) activitiesFeedCtx.getBean("feedGenerator"); LocalFeedTaskProcessor feedProcessor = (LocalFeedTaskProcessor) activitiesFeedCtx.getBean("feedTaskProcessor"); List<String> templateSearchPaths = new ArrayList<String>(1); templateSearchPaths.add(TEST_TEMPLATES_LOCATION); feedProcessor.setTemplateSearchPaths(templateSearchPaths); feedProcessor.setUseRemoteCallbacks(false); }
Example #19
Source File: NodeWebScripTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); AbstractRefreshableApplicationContext ctx = (AbstractRefreshableApplicationContext)getServer().getApplicationContext(); this.retryingTransactionHelper = (RetryingTransactionHelper)ctx.getBean("retryingTransactionHelper"); this.authenticationService = (MutableAuthenticationService)ctx.getBean("AuthenticationService"); this.personService = (PersonService)ctx.getBean("PersonService"); this.siteService = (SiteService)ctx.getBean("SiteService"); this.nodeService = (NodeService)ctx.getBean("NodeService"); this.nodeArchiveService = (NodeArchiveService)ctx.getBean("nodeArchiveService"); this.checkOutCheckInService = (CheckOutCheckInService)ctx.getBean("checkOutCheckInService"); this.permissionService = (PermissionService)ctx.getBean("permissionService"); // Do the setup as admin AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser(); // Create a site TEST_SITE = createSite(TEST_SITE_NAME); // Create two users, one who's a site member createUser(USER_ONE, true); createUser(USER_TWO, false); // Do our tests by default as the first user who is a contributor AuthenticationUtil.setFullyAuthenticatedUser(USER_ONE); }
Example #20
Source File: InviteSenderTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Mocks up a SiteService that returns appropriate SiteInfo. * * @return SiteService */ private SiteService mockSiteService() { SiteService siteService = mock(SiteService.class); when(siteInfo.getShortName()).thenReturn(siteShortName); when(siteService.getSite(siteName)).thenReturn(siteInfo); return siteService; }
Example #21
Source File: BlogServiceTest.java From alfresco-remote-api with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); this.authenticationService = (MutableAuthenticationService)getServer().getApplicationContext().getBean("AuthenticationService"); this.authenticationComponent = (AuthenticationComponent)getServer().getApplicationContext().getBean("authenticationComponent"); this.personService = (PersonService)getServer().getApplicationContext().getBean("PersonService"); this.siteService = (SiteService)getServer().getApplicationContext().getBean("SiteService"); 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_BLOG); if (siteInfo == null) { this.siteService.createSite("BlogSitePreset", SITE_SHORT_NAME_BLOG, "BlogSiteTitle", "BlogSiteDescription", SiteVisibility.PUBLIC); } // Create users createUser(USER_ONE, SiteModel.SITE_COLLABORATOR, SITE_SHORT_NAME_BLOG); createUser(USER_TWO, SiteModel.SITE_COLLABORATOR, SITE_SHORT_NAME_BLOG); // Blank our lists used to track things the test creates posts = new ArrayList<String>(5); drafts = new ArrayList<String>(5); // Do tests as inviter user this.authenticationComponent.setCurrentUser(USER_ONE); }
Example #22
Source File: InviteModeratedSenderTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
/** * Mocks up a SiteService that returns appropriate SiteInfo. * * @return SiteService */ private SiteService mockSiteService() { SiteService siteService = mock(SiteService.class); when(siteInfo.getTitle()).thenReturn(fullSiteName); when(siteService.getSite(shortSiteName)).thenReturn(siteInfo); return siteService; }
Example #23
Source File: InvitationCleanupTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@BeforeClass public static void initStaticData() throws Exception { INVITATION_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("InvitationService", InvitationService.class); SITE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("SiteService", SiteService.class); TRANSACTION_HELPER = APP_CONTEXT_INIT.getApplicationContext().getBean("retryingTransactionHelper", RetryingTransactionHelper.class); WORKFLOW_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("WorkflowService", WorkflowService.class); NODE_ARCHIVE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("nodeArchiveService", NodeArchiveService.class); }
Example #24
Source File: MultiTDemoTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void setUp() throws Exception { super.setUp(); ctx = ApplicationContextHelper.getApplicationContext(new String[] { ApplicationContextHelper.CONFIG_LOCATIONS[0], "classpath:tenant/mt-*context.xml" }); nodeService = (NodeService) ctx.getBean("NodeService"); nodeArchiveService = (NodeArchiveService) ctx.getBean("nodeArchiveService"); namespaceService = (NamespaceService) ctx.getBean("NamespaceService"); authenticationService = (MutableAuthenticationService) ctx.getBean("AuthenticationService"); tenantAdminService = (TenantAdminService) ctx.getBean("tenantAdminService"); tenantService = (TenantService) ctx.getBean("tenantService"); personService = (PersonService) ctx.getBean("PersonService"); searchService = (SearchService) ctx.getBean("SearchService"); contentService = (ContentService) ctx.getBean("ContentService"); permissionService = (PermissionService) ctx.getBean("PermissionService"); ownableService = (OwnableService) ctx.getBean("OwnableService"); authorityService = (AuthorityService) ctx.getBean("AuthorityService"); categoryService = (CategoryService) ctx.getBean("CategoryService"); cociService = (CheckOutCheckInService) ctx.getBean("CheckoutCheckinService"); repoAdminService = (RepoAdminService) ctx.getBean("RepoAdminService"); dictionaryService = (DictionaryService) ctx.getBean("DictionaryService"); usageService = (UsageService) ctx.getBean("usageService"); transactionService = (TransactionService) ctx.getBean("TransactionService"); fileFolderService = (FileFolderService) ctx.getBean("FileFolderService"); ownableService = (OwnableService) ctx.getBean("OwnableService"); repositoryHelper = (Repository) ctx.getBean("repositoryHelper"); siteService = (SiteService) ctx.getBean("SiteService"); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getAdminUserName()); // authenticate as super-admin createTenants(); createUsers(); }
Example #25
Source File: MultiTDemoTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
private SiteInfo createSite(String siteId) { SiteInfo siteInfo = siteService.createSite(null, siteId, "title - "+siteId, "description - "+siteId, SiteVisibility.PRIVATE); // ensure that the Document Library folder is pre-created so that test code can start creating content straight away. // At the time of writing V4.1 does not create this folder automatically, but Thor does. NodeRef result = siteService.getContainer(siteId, SiteService.DOCUMENT_LIBRARY); if (result == null) { result = siteService.createContainer(siteId, SiteService.DOCUMENT_LIBRARY, ContentModel.TYPE_FOLDER, null); } return siteInfo; }
Example #26
Source File: MultiTDemoTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
public void test20_ALF_12732() { final String tenantDomain1 = TEST_RUN+".one.alf12732"; createTenant(tenantDomain1); String tenantAdminName = tenantService.getDomainUser(AuthenticationUtil.getAdminUserName(), tenantDomain1); try { AuthenticationUtil.setFullyAuthenticatedUser(tenantAdminName); // note: since SiteServiceImpl.setupSitePermissions currently uses getCurrentUserName (rather than runAs) TenantUtil.runAsUserTenant(new TenantRunAsWork<Object>() { public Object doWork() throws Exception { createSite("site1"); NodeRef docLib1Ref = siteService.getContainer("site1", SiteService.DOCUMENT_LIBRARY); NodeRef contentRef = addContent(docLib1Ref, "tqbfjotld.txt", "The quick brown fox jumps over the lazy dog", MimetypeMap.MIMETYPE_TEXT_PLAIN); createSite("site2"); NodeRef docLib2Ref = siteService.getContainer("site2", SiteService.DOCUMENT_LIBRARY); nodeService.moveNode(contentRef, docLib2Ref, ContentModel.ASSOC_CONTAINS, QName.createQName("tqbfjotld.txt")); // for Share, called via "move-to.post.json.js" -> ScriptSiteService.cleanSitePermissions siteService.cleanSitePermissions(contentRef, null); return null; } }, tenantAdminName, tenantDomain1); } finally { AuthenticationUtil.clearCurrentSecurityContext(); } }
Example #27
Source File: DiscussionServiceImplTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@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 #28
Source File: TemporarySitesTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@BeforeClass public static void initStaticData() throws Exception { NAMESPACE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("namespaceService", NamespaceService.class); NODE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("nodeService", NodeService.class); SITE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("siteService", SiteService.class); TRANSACTION_HELPER = APP_CONTEXT_INIT.getApplicationContext().getBean("retryingTransactionHelper", RetryingTransactionHelper.class); }
Example #29
Source File: TemporarySitesTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@Test public void ensureTestSitesWereCreatedOk() throws Exception { TRANSACTION_HELPER.doInTransaction(new RetryingTransactionCallback<Void>() { public Void execute() throws Throwable { final SiteInfo recoveredSite1 = SITE_SERVICE.getSite(testSite1.getShortName()); final SiteInfo recoveredSite2 = SITE_SERVICE.getSite(testSite2.getShortName()); assertNotNull("Test site does not exist", recoveredSite1); assertNotNull("Test site does not exist", recoveredSite2); assertEquals("cm:title was wrong", "t", recoveredSite1.getTitle()); assertEquals("cm:description was wrong", "d", recoveredSite1.getDescription()); assertEquals("preset was wrong", "sitePreset", recoveredSite1.getSitePreset()); assertEquals("site visibility was wrong", SiteVisibility.PUBLIC, recoveredSite1.getVisibility()); for (String siteShortName : new String[] { testSite1.getShortName(), testSite2.getShortName() }) { assertNotNull("site had no doclib container node", SITE_SERVICE.getContainer(siteShortName, SiteService.DOCUMENT_LIBRARY)); } return null; } }); }
Example #30
Source File: TemporaryNodesTest.java From alfresco-repository with GNU Lesser General Public License v3.0 | 5 votes |
@BeforeClass public static void initStaticData() throws Exception { COCI_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("checkOutCheckInService", CheckOutCheckInService.class); CONTENT_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("ContentService", ContentService.class); NODE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("NodeService", NodeService.class); SITE_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("SiteService", SiteService.class); TRANSACTION_HELPER = APP_CONTEXT_INIT.getApplicationContext().getBean("retryingTransactionHelper", RetryingTransactionHelper.class); VERSION_SERVICE = APP_CONTEXT_INIT.getApplicationContext().getBean("VersionService", VersionService.class); Repository repositoryHelper = APP_CONTEXT_INIT.getApplicationContext().getBean("repositoryHelper", Repository.class); COMPANY_HOME = repositoryHelper.getCompanyHome(); }