@Override public FileFolderService getFileFolderService() { return serviceRegistry.getFileFolderService(); }
/** * Avoid injection issues: Look it up from the Service Registry as required */ private FileFolderService getFileFolderService() { return serviceRegistry.getFileFolderService(); }
@Override public FileFolderService getFileFolderService() { return serviceRegistry.getFileFolderService(); }
/** * Avoid injection issues: Look it up from the Service Registry as required */ private FileFolderService getFileFolderService() { return serviceRegistry.getFileFolderService(); }
private static NodeRef newFolder(NodeRef parent, String name) { return serviceRegistry.getFileFolderService().create( parent, name, ContentModel.TYPE_FOLDER).getNodeRef(); }
/** * Create a new folder (cm:folder) node as a child of this node. * * Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call {@link #save()} first. * * @param name Name of the folder to create * @param type Type of the folder to create (if null, defaults to ContentModel.TYPE_FOLDER) * * @return Newly created Node or null if failed to create. */ public ScriptNode createFolder(String name, String type) { ParameterCheck.mandatoryString("Node Name", name); FileInfo fileInfo = this.services.getFileFolderService().create( this.nodeRef, name, type == null ? ContentModel.TYPE_FOLDER : createQName(type)); reset(); return newInstance(fileInfo.getNodeRef(), this.services, this.scope); }
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; }
/** * @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; }
/** * Create a new folder (cm:folder) node as a child of this node. * * Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call {@link #save()} first. * * @param name Name of the folder to create * @param type Type of the folder to create (if null, defaults to ContentModel.TYPE_FOLDER) * * @return Newly created Node or null if failed to create. */ public ScriptNode createFolder(String name, String type) { ParameterCheck.mandatoryString("Node Name", name); FileInfo fileInfo = this.services.getFileFolderService().create( this.nodeRef, name, type == null ? ContentModel.TYPE_FOLDER : createQName(type)); reset(); return newInstance(fileInfo.getNodeRef(), this.services, this.scope); }
@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"); }
@Test public final void test03OnCopyCompleteAndNewName() throws Exception { serviceRegistry.getFileFolderService().copy(content2, folder1, "newName1"); txn.commit(); txn = null; // TODO do we record the parent or the full path? Do we need to? assertEquals(1, auditMapList.size()); Map<String, Serializable> auditMap = auditMapList.get(0); assertEquals("COPY", auditMap.get("action")); assertContains("createNode", auditMap.get("sub-actions")); assertContains("updateNodeProperties", auditMap.get("sub-actions")); assertContains("addNodeAspect", auditMap.get("sub-actions")); assertContains("copyNode", auditMap.get("sub-actions")); assertEquals("/cm:homeFolder/cm:folder1/cm:newName1", auditMap.get("path")); assertEquals("/cm:homeFolder/cm:folder2/cm:content2", auditMap.get("copy/from/path")); assertEquals("cm:content", auditMap.get("type")); }
/** * Helper to set the 'name' property for the node. * * @param name Name to set */ public void setName(String name) { if (name != null) { QName typeQName = getQNameType(); if ((services.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_FOLDER) && !services.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_SYSTEM_FOLDER)) || services.getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_CONTENT)) { try { this.services.getFileFolderService().rename(this.nodeRef, name); } catch (FileNotFoundException e) { throw new AlfrescoRuntimeException("Failed to rename node " + nodeRef + " to " + name, e); } } this.getProperties().put(ContentModel.PROP_NAME.toString(), name.toString()); } }
@Test public final void test02OnCopyComplete() throws Exception { serviceRegistry.getFileFolderService().copy(content2, folder1, null); // keep leaf name txn.commit(); txn = null; // TODO do we record the parent or the full path? Do we need to? assertEquals(1, auditMapList.size()); Map<String, Serializable> auditMap = auditMapList.get(0); assertEquals("COPY", auditMap.get("action")); assertContains("createNode", auditMap.get("sub-actions")); assertContains("updateNodeProperties", auditMap.get("sub-actions")); assertContains("addNodeAspect", auditMap.get("sub-actions")); assertContains("copyNode", auditMap.get("sub-actions")); assertEquals("/cm:homeFolder/cm:folder1/cm:content2", auditMap.get("path")); assertEquals("/cm:homeFolder/cm:folder2/cm:content2", auditMap.get("copy/from/path")); assertEquals("cm:content", auditMap.get("type")); }
@Override public void setUp() throws Exception { ctx = ApplicationContextHelper.getApplicationContext(); ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); txnHelper = serviceRegistry.getTransactionService().getRetryingTransactionHelper(); fileFolderService = serviceRegistry.getFileFolderService(); repository = (Repository) ctx.getBean("repositoryHelper"); fixedAclUpdater = (FixedAclUpdater) ctx.getBean("fixedAclUpdater"); permissionsDaoComponent = (PermissionsDaoComponent) ctx.getBean("admPermissionsDaoComponent"); permissionService = (PermissionService) ctx.getBean("permissionService"); nodeDAO = (NodeDAO) ctx.getBean("nodeDAO"); AuthenticationUtil.setFullyAuthenticatedUser(AuthenticationUtil.getSystemUserName()); NodeRef home = repository.getCompanyHome(); // create a folder hierarchy for which will change permission inheritance int[] filesPerLevel = { 5, 5, 10 }; RetryingTransactionCallback<NodeRef> cb = createFolderHierchyCallback(home, fileFolderService, "ROOT", filesPerLevel); folderNodeRef = txnHelper.doInTransaction(cb); // change setFixedAclMaxTransactionTime to lower value so setInheritParentPermissions on created folder hierarchy require async call setFixedAclMaxTransactionTime(permissionsDaoComponent, home, 50); }
@Override public void setUp() throws Exception { ctx = ApplicationContextHelper.getApplicationContext(); ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean("ServiceRegistry"); nodeService = serviceRegistry.getNodeService(); fileFolderService = serviceRegistry.getFileFolderService(); nodeArchiveService = (NodeArchiveService) ctx.getBean("nodeArchiveService"); authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); transactionService = serviceRegistry.getTransactionService(); try { authenticationComponent.setSystemUserAsCurrentUser(); // create a test store StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore"); rootNodeRef = nodeService.getRootNode(storeRef); } finally { authenticationComponent.clearCurrentSecurityContext(); } }
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")); }
/** * Create a new File (cm:content) node as a child of this node. * <p> * Once created the file should have content set using the <code>content</code> property. * * Beware: Any unsaved property changes will be lost when this is called. To preserve property changes call {@link #save()} first. * * @param name Name of the file to create * @param type Type of the file to create (if null, defaults to ContentModel.TYPE_CONTENT) * * @return Newly created Node or null if failed to create. */ public ScriptNode createFile(String name, String type) { ParameterCheck.mandatoryString("Node Name", name); FileInfo fileInfo = this.services.getFileFolderService().create( this.nodeRef, name, type == null ? ContentModel.TYPE_CONTENT : createQName(type)); reset(); ScriptNode file = newInstance(fileInfo.getNodeRef(), this.services, this.scope); file.setMimetype(this.services.getMimetypeService().guessMimetype(name)); return file; }
public void test_AR_2055() { runAs(AuthenticationUtil.getAdminUserName()); NodeRef folder = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}one"), ContentModel.TYPE_FOLDER).getChildRef(); runAs("andy"); List<String> pathElements = new ArrayList<String>(); pathElements.add("monkey"); try { FileFolderServiceImpl.makeFolders(serviceRegistry.getFileFolderService(), folder, pathElements, ContentModel.TYPE_FOLDER); fail(); } catch (AccessDeniedException ade) { } runAs(AuthenticationUtil.getAdminUserName()); permissionService.setPermission(folder, "andy", PermissionService.ALL_PERMISSIONS, true); FileFolderServiceImpl.makeFolders(serviceRegistry.getFileFolderService(), folder, pathElements, ContentModel.TYPE_FOLDER); }
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")); }