mirror of
				https://github.com/Alfresco/alfresco-community-repo.git
				synced 2025-10-29 15:21:53 +00:00 
			
		
		
		
	6466: Xml metadata.  Support for pulling collections of values from XML
   6470: Fix for AWC-1321 - Using zero as items per page gives error for Alfresco repos in OpenSearch
   6471: Fix for AWC-1496 - OpenSearch dashlet can get in a state where search queries are not executed
   6472: Fix for AWC-1495. Searching additional attributes now working correctly for folders.
   6473: Fix for AR-1251 (Version error when saving new content via CIFS)
   6474: Updated bundles and installers - added missing files back into Linux bundle
   6475: LDAP and chainging authentication
          Resolved conflicted state of 'root\projects\repository\source\java\org\alfresco\repo\security\authentication\AuthenticationUtil.java'
   6477: XForms WCM-696.
   6478: Fix for WCM-567 (IndexOutOfBoundsException when stepping through wizard rapidly)
   6480: Fix to issue when removing locks on directories.
   6481: Updated installer and config wizard to fix download option and config behaviour when called from installer.
   6482: Fix for WCM-1229 (properties sheet does not refresh)
   6483: Fix for AR-1511
   6484: Fix for AR-1351
   6485: Missed a unit test update
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@6737 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
		
	
		
			
				
	
	
		
			149 lines
		
	
	
		
			7.1 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			149 lines
		
	
	
		
			7.1 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
| /*
 | |
|  * Copyright (C) 2005-2007 Alfresco Software Limited.
 | |
|  *
 | |
|  * This program is free software; you can redistribute it and/or
 | |
|  * modify it under the terms of the GNU General Public License
 | |
|  * as published by the Free Software Foundation; either version 2
 | |
|  * of the License, or (at your option) any later version.
 | |
| 
 | |
|  * This program is distributed in the hope that it will be useful,
 | |
|  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | |
|  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | |
|  * GNU General Public License for more details.
 | |
| 
 | |
|  * You should have received a copy of the GNU General Public License
 | |
|  * along with this program; if not, write to the Free Software
 | |
|  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 | |
| 
 | |
|  * As a special exception to the terms and conditions of version 2.0 of 
 | |
|  * the GPL, you may redistribute this Program in connection with Free/Libre 
 | |
|  * and Open Source Software ("FLOSS") applications as described in Alfresco's 
 | |
|  * FLOSS exception.  You should have recieved a copy of the text describing 
 | |
|  * the FLOSS exception, and it is also available here: 
 | |
|  * http://www.alfresco.com/legal/licensing"
 | |
|  */
 | |
| package org.alfresco.jcr.test;
 | |
| 
 | |
| import java.util.ArrayList;
 | |
| import java.util.List;
 | |
| import java.util.Properties;
 | |
| 
 | |
| import org.alfresco.repo.importer.ImporterBootstrap;
 | |
| import org.alfresco.repo.security.authentication.AuthenticationComponent;
 | |
| import org.alfresco.repo.security.authentication.MutableAuthenticationDao;
 | |
| import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
 | |
| import org.alfresco.service.ServiceRegistry;
 | |
| import org.alfresco.service.cmr.repository.NodeService;
 | |
| import org.alfresco.service.cmr.repository.StoreRef;
 | |
| import org.alfresco.service.cmr.security.PermissionService;
 | |
| import org.alfresco.service.cmr.view.ImporterService;
 | |
| import org.alfresco.service.namespace.NamespaceService;
 | |
| import org.alfresco.service.transaction.TransactionService;
 | |
| import org.springframework.context.ApplicationContext;
 | |
| import org.springframework.context.support.ClassPathXmlApplicationContext;
 | |
| 
 | |
| 
 | |
| 
 | |
| public class TestData
 | |
| {
 | |
|     public static final String TEST_WORKSPACE = "test";
 | |
| 
 | |
|     /**
 | |
|      * Generate Test Workspace within Repository
 | |
|      * 
 | |
|      * @param args
 | |
|      */
 | |
|     public static void main(String[] args)
 | |
|     {
 | |
|         ApplicationContext context = new ClassPathXmlApplicationContext("org/alfresco/jcr/test/test-context.xml");
 | |
|         generateTestData(context, TEST_WORKSPACE);
 | |
|         System.out.println("Generated TCK test data to workspace: " + TEST_WORKSPACE);
 | |
|         System.exit(0);
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Bootstrap Repository with JCR Test Data
 | |
|      * 
 | |
|      * @param applicationContext
 | |
|      * @param workspaceName
 | |
|      */
 | |
|     public static void generateTestData(final ApplicationContext applicationContext, String workspaceName)
 | |
|     {
 | |
|         final ServiceRegistry serviceRegistry = (ServiceRegistry) applicationContext.getBean(ServiceRegistry.SERVICE_REGISTRY);
 | |
|         TransactionService transactionService = serviceRegistry.getTransactionService();
 | |
|         RetryingTransactionCallback<Object> createUserWork = new RetryingTransactionCallback<Object>()
 | |
|         {
 | |
|             public Object execute() throws Exception
 | |
|             {
 | |
|                 // Bootstrap Users
 | |
|                 MutableAuthenticationDao authDAO = (MutableAuthenticationDao) applicationContext.getBean("authenticationDao");
 | |
|                 if (authDAO.userExists("superuser") == false)
 | |
|                 {
 | |
|                     authDAO.createUser("superuser", "".toCharArray());
 | |
|                 }
 | |
|                 if (authDAO.userExists("user") == false)
 | |
|                 {
 | |
|                     authDAO.createUser("user", "".toCharArray());
 | |
|                 }
 | |
|                 if (authDAO.userExists("anonymous") == false)
 | |
|                 {
 | |
|                     authDAO.createUser("anonymous", "".toCharArray());
 | |
|                 }
 | |
|                 return null;
 | |
|             }
 | |
|         };
 | |
|         transactionService.getRetryingTransactionHelper().doInTransaction(createUserWork);
 | |
| 
 | |
|         try
 | |
|         {
 | |
|             AuthenticationComponent authenticationComponent = (AuthenticationComponent)applicationContext.getBean("authenticationComponent");
 | |
|             authenticationComponent.setSystemUserAsCurrentUser();
 | |
| 
 | |
|             try
 | |
|             {
 | |
|                 // Bootstrap Workspace Test Data
 | |
|                 StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, workspaceName);
 | |
| 
 | |
|                 ImporterBootstrap bootstrap = new ImporterBootstrap();
 | |
|                 bootstrap.setAuthenticationComponent((AuthenticationComponent) applicationContext.getBean("authenticationComponent"));
 | |
|                 bootstrap.setImporterService((ImporterService) applicationContext.getBean(ServiceRegistry.IMPORTER_SERVICE.getLocalName()));
 | |
|                 bootstrap.setNodeService((NodeService) applicationContext.getBean(ServiceRegistry.NODE_SERVICE.getLocalName()));
 | |
|                 bootstrap.setNamespaceService((NamespaceService) applicationContext.getBean(ServiceRegistry.NAMESPACE_SERVICE.getLocalName()));
 | |
|                 bootstrap.setTransactionService((TransactionService) applicationContext.getBean(ServiceRegistry.TRANSACTION_SERVICE.getLocalName()));
 | |
|                 bootstrap.setStoreUrl(storeRef.toString());
 | |
| 
 | |
|                 List<Properties> views = new ArrayList<Properties>();
 | |
|                 Properties testView = new Properties();
 | |
|                 testView.setProperty("path", "/");
 | |
|                 testView.setProperty("location", "org/alfresco/jcr/test/testData.xml");
 | |
|                 views.add(testView);
 | |
|                 bootstrap.setBootstrapViews(views);
 | |
|                 bootstrap.bootstrap();
 | |
| 
 | |
|                 // Bootstrap clears security context
 | |
|                 authenticationComponent.setSystemUserAsCurrentUser();
 | |
|                 
 | |
|                 PermissionService permissionService = (PermissionService)applicationContext.getBean(ServiceRegistry.PERMISSIONS_SERVICE.getLocalName());
 | |
|                 NodeService nodeService = (NodeService)applicationContext.getBean(ServiceRegistry.NODE_SERVICE.getLocalName());
 | |
| 
 | |
| //                permissionService.setPermission(nodeService.getRootNode(storeRef), PermissionService.ALL_AUTHORITIES, PermissionService.ALL_PERMISSIONS, true);
 | |
|                 permissionService.setPermission(nodeService.getRootNode(storeRef), "superuser", PermissionService.ALL_PERMISSIONS, true);
 | |
|                 permissionService.setPermission(nodeService.getRootNode(storeRef), "anonymous", PermissionService.READ, true);
 | |
|                 permissionService.setPermission(nodeService.getRootNode(storeRef), "user", PermissionService.READ, true);
 | |
|                 permissionService.setPermission(nodeService.getRootNode(storeRef), "user", PermissionService.WRITE, true);
 | |
|             }
 | |
|             finally
 | |
|             {
 | |
|                 authenticationComponent.clearCurrentSecurityContext();
 | |
|             }
 | |
|         }
 | |
|         catch (RuntimeException e)
 | |
|         {
 | |
|             System.out.println("Exception: " + e);
 | |
|             e.printStackTrace();
 | |
|             throw e;
 | |
|         }
 | |
|     }
 | |
| 
 | |
| }
 |