/** On setup in transaction implementation */ @Override protected void onSetUpInTransaction() throws Exception { // Set the services this.nodeService = (NodeService) this.applicationContext.getBean("nodeService"); this.cociService = (CheckOutCheckInService) this.applicationContext.getBean("checkOutCheckInService"); this.contentService = (ContentService) this.applicationContext.getBean("contentService"); this.versionService = (VersionService) this.applicationContext.getBean("versionService"); this.authenticationService = (MutableAuthenticationService) this.applicationContext.getBean("authenticationService"); this.lockService = (LockService) this.applicationContext.getBean("lockService"); this.transactionService = (TransactionService) this.applicationContext.getBean("transactionComponent"); this.permissionService = (PermissionService) this.applicationContext.getBean("permissionService"); this.copyService = (CopyService) this.applicationContext.getBean("copyService"); // Authenticate as system to create initial test data set AuthenticationComponent authenticationComponent = (AuthenticationComponent) this.applicationContext.getBean("authenticationComponent"); authenticationComponent.setSystemUserAsCurrentUser(); // Create the store and get the root node reference this.storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); this.rootNodeRef = nodeService.getRootNode(storeRef); // Create the node used for tests ChildAssociationRef childAssocRef = nodeService.createNode( rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("test"), ContentModel.TYPE_CONTENT); this.nodeRef = childAssocRef.getChildRef(); nodeService.addAspect(this.nodeRef, ContentModel.ASPECT_TITLED, null); nodeService.setProperty(this.nodeRef, ContentModel.PROP_NAME, TEST_VALUE_NAME); nodeService.setProperty(this.nodeRef, PROP2_QNAME, TEST_VALUE_2); // Add the initial content to the node ContentWriter contentWriter = this.contentService.getWriter(this.nodeRef, ContentModel.PROP_CONTENT, true); contentWriter.setMimetype("text/plain"); contentWriter.setEncoding("UTF-8"); contentWriter.putContent(CONTENT_1); // Add the lock and version aspects to the created node nodeService.addAspect(this.nodeRef, ContentModel.ASPECT_VERSIONABLE, null); nodeService.addAspect(this.nodeRef, ContentModel.ASPECT_LOCKABLE, null); // Create and authenticate the user this.userName = "******" + GUID.generate(); TestWithUserUtils.createUser( this.userName, PWD, this.rootNodeRef, this.nodeService, this.authenticationService); TestWithUserUtils.authenticateUser( this.userName, PWD, this.rootNodeRef, this.authenticationService); this.userNodeRef = TestWithUserUtils.getCurrentUser(this.authenticationService); permissionService.setPermission( this.rootNodeRef, this.userName, PermissionService.ALL_PERMISSIONS, true); permissionService.setPermission( this.nodeRef, this.userName, PermissionService.ALL_PERMISSIONS, true); folderNodeRef = nodeService .createNode( rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("test"), ContentModel.TYPE_FOLDER, Collections.<QName, Serializable>singletonMap(ContentModel.PROP_NAME, "folder")) .getChildRef(); fileNodeRef = nodeService .createNode( folderNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName("test"), ContentModel.TYPE_CONTENT, Collections.<QName, Serializable>singletonMap(ContentModel.PROP_NAME, "file")) .getChildRef(); contentWriter = this.contentService.getWriter(fileNodeRef, ContentModel.PROP_CONTENT, true); contentWriter.setMimetype("text/plain"); contentWriter.setEncoding("UTF-8"); contentWriter.putContent(CONTENT_1); }