Search in sources :

Example 11 with Repository

use of org.alfresco.repo.model.Repository in project alfresco-remote-api by Alfresco.

the class DownloadRestApiTest method setUp.

public void setUp() {
    // Resolve required services
    authenticationService = getServer().getApplicationContext().getBean("AuthenticationService", MutableAuthenticationService.class);
    authenticationComponent = getServer().getApplicationContext().getBean("authenticationComponent", AuthenticationComponent.class);
    contentService = getServer().getApplicationContext().getBean("ContentService", ContentService.class);
    nodeService = getServer().getApplicationContext().getBean("NodeService", NodeService.class);
    personService = getServer().getApplicationContext().getBean("PersonService", PersonService.class);
    // Authenticate as user
    this.authenticationComponent.setCurrentUser(AuthenticationUtil.getAdminUserName());
    // if user with given user name doesn't already exist then create user
    if (this.authenticationService.authenticationExists(TEST_USERNAME) == false) {
        // create user
        this.authenticationService.createAuthentication(TEST_USERNAME, "password".toCharArray());
        // create person properties
        PropertyMap personProps = new PropertyMap();
        personProps.put(ContentModel.PROP_USERNAME, TEST_USERNAME);
        personProps.put(ContentModel.PROP_FIRSTNAME, "FirstName123");
        personProps.put(ContentModel.PROP_LASTNAME, "LastName123");
        personProps.put(ContentModel.PROP_EMAIL, "FirstName123.LastName123@email.com");
        personProps.put(ContentModel.PROP_JOBTITLE, "JobTitle123");
        personProps.put(ContentModel.PROP_JOBTITLE, "Organisation123");
        // create person node for user
        this.personService.createPerson(personProps);
    }
    Repository repositoryHelper = (Repository) getServer().getApplicationContext().getBean("repositoryHelper");
    NodeRef companyHome = repositoryHelper.getCompanyHome();
    // Create some static test content
    rootFolder = createNode(companyHome, "rootFolder", ContentModel.TYPE_FOLDER, AuthenticationUtil.getAdminUserName());
    rootFile = createNodeWithTextContent(companyHome, "rootFile", ContentModel.TYPE_CONTENT, AuthenticationUtil.getAdminUserName(), "Root file content");
    level1File = createNodeWithTextContent(rootFolder, "level1File", ContentModel.TYPE_CONTENT, AuthenticationUtil.getAdminUserName(), "Level 1 file content");
    level1Folder = createNode(rootFolder, "level1Folder", ContentModel.TYPE_FOLDER, AuthenticationUtil.getAdminUserName());
    level2File = createNodeWithTextContent(level1Folder, "level2File", ContentModel.TYPE_CONTENT, AuthenticationUtil.getAdminUserName(), "Level 2 file content");
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Repository(org.alfresco.repo.model.Repository) PropertyMap(org.alfresco.util.PropertyMap) AuthenticationComponent(org.alfresco.repo.security.authentication.AuthenticationComponent) NodeService(org.alfresco.service.cmr.repository.NodeService) PersonService(org.alfresco.service.cmr.security.PersonService) ContentService(org.alfresco.service.cmr.repository.ContentService) MutableAuthenticationService(org.alfresco.service.cmr.security.MutableAuthenticationService)

Example 12 with Repository

use of org.alfresco.repo.model.Repository in project alfresco-repository by Alfresco.

the class InviteSenderTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    ServiceRegistry services = mockServices();
    Repository repository = mockRepository();
    sender = new InviteNominatedSender(services, repository, messageService);
    lastSetMailModel = null;
}
Also used : Repository(org.alfresco.repo.model.Repository) ServiceRegistry(org.alfresco.service.ServiceRegistry)

Example 13 with Repository

use of org.alfresco.repo.model.Repository in project alfresco-repository by Alfresco.

the class TemporaryNodesTest method initStaticData.

@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();
}
Also used : Repository(org.alfresco.repo.model.Repository) CheckOutCheckInService(org.alfresco.service.cmr.coci.CheckOutCheckInService) SiteService(org.alfresco.service.cmr.site.SiteService) RetryingTransactionHelper(org.alfresco.repo.transaction.RetryingTransactionHelper) NodeService(org.alfresco.service.cmr.repository.NodeService) VersionService(org.alfresco.service.cmr.version.VersionService) ContentService(org.alfresco.service.cmr.repository.ContentService) BeforeClass(org.junit.BeforeClass)

Example 14 with Repository

use of org.alfresco.repo.model.Repository in project alfresco-repository by Alfresco.

the class InviteModeratedSenderTest method mockRepository.

/**
 * Mocks up a Repository that will return the inviter as the current user.
 *
 * @return Repository
 */
private Repository mockRepository() {
    Repository repository = mock(Repository.class);
    when(repository.getPerson()).thenReturn(requesterNodeRef);
    return repository;
}
Also used : Repository(org.alfresco.repo.model.Repository)

Example 15 with Repository

use of org.alfresco.repo.model.Repository in project alfresco-repository by Alfresco.

the class ScriptNodeTest method testGetQnamePath.

/**
 * ALF-21962: Webscripts - node.qnamePath incorrectly returns ":" for items without namespace prefix
 */
@Test
public void testGetQnamePath() {
    Repository repositoryHelper = (Repository) APP_CONTEXT_INIT.getApplicationContext().getBean("repositoryHelper");
    NodeRef companyHome = repositoryHelper.getCompanyHome();
    {
        // test nodes with namespace
        NodeRef newNode1 = testNodes.createNode(companyHome, "theTestContent198", ContentModel.TYPE_CONTENT, AuthenticationUtil.getFullyAuthenticatedUser());
        // test on content data
        ScriptNode sn = new ScriptNode(newNode1, SERVICE_REGISTRY);
        sn.setScope(getScope());
        ContentData contentData = (ContentData) NODE_SERVICE.getProperty(newNode1, ContentModel.PROP_CONTENT);
        assertNull(contentData);
        String path = sn.getQnamePath();
        assertEquals("/app:company_home/app:theTestContent198", path);
    }
    {
        // test nodes without namespace
        QName childName = QName.createQName(null, "theTestContent199");
        NodeRef newNodeWithNoNamespace = testNodes.createNodeWithTextContent(companyHome, childName, "theTestContent199", ContentModel.TYPE_CONTENT, AuthenticationUtil.getFullyAuthenticatedUser(), "some content");
        // test on content data
        ScriptNode sn = new ScriptNode(newNodeWithNoNamespace, SERVICE_REGISTRY);
        sn.setScope(getScope());
        ContentData contentData = (ContentData) NODE_SERVICE.getProperty(newNodeWithNoNamespace, ContentModel.PROP_CONTENT);
        assertNotNull(contentData);
        String path = sn.getQnamePath();
        assertEquals("/app:company_home/theTestContent199", path);
    }
}
Also used : NodeRef(org.alfresco.service.cmr.repository.NodeRef) Repository(org.alfresco.repo.model.Repository) ContentData(org.alfresco.service.cmr.repository.ContentData) ScriptContentData(org.alfresco.repo.jscript.ScriptNode.ScriptContentData) QName(org.alfresco.service.namespace.QName) ActivitiScriptNode(org.alfresco.repo.workflow.activiti.ActivitiScriptNode) Test(org.junit.Test)

Aggregations

Repository (org.alfresco.repo.model.Repository)24 NodeRef (org.alfresco.service.cmr.repository.NodeRef)10 Before (org.junit.Before)6 Test (org.junit.Test)6 ActivitiScriptNode (org.alfresco.repo.workflow.activiti.ActivitiScriptNode)5 NodeService (org.alfresco.service.cmr.repository.NodeService)4 BeforeClass (org.junit.BeforeClass)4 RetryingTransactionHelper (org.alfresco.repo.transaction.RetryingTransactionHelper)3 ServiceRegistry (org.alfresco.service.ServiceRegistry)3 ContentService (org.alfresco.service.cmr.repository.ContentService)3 PersonService (org.alfresco.service.cmr.security.PersonService)3 QName (org.alfresco.service.namespace.QName)3 ScriptContentData (org.alfresco.repo.jscript.ScriptNode.ScriptContentData)2 AuthenticationComponent (org.alfresco.repo.security.authentication.AuthenticationComponent)2 AccessDeniedException (org.alfresco.repo.security.permissions.AccessDeniedException)2 ScriptException (org.alfresco.scripts.ScriptException)2 FileFolderService (org.alfresco.service.cmr.model.FileFolderService)2 ContentData (org.alfresco.service.cmr.repository.ContentData)2 MutableAuthenticationService (org.alfresco.service.cmr.security.MutableAuthenticationService)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1