DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.setTenantService(tenantService);
private static void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception { CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); compiledModelsCache.setDictionaryDAO(dictionaryDAO); compiledModelsCache.setTenantService(tenantService); compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); ThreadPoolExecutorFactoryBean threadPoolfactory = new ThreadPoolExecutorFactoryBean(); threadPoolfactory.afterPropertiesSet(); compiledModelsCache.setThreadPoolExecutor((ThreadPoolExecutor) threadPoolfactory.getObject()); dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); dictionaryDAO.init(); } }
protected List<CustomModelDefinition> getAllCustomModels() { List<CustomModelDefinition> result = new ArrayList<>(); Collection<QName> models = dictionaryDAO.getModels(true); List<String> dictionaryModels = new ArrayList<>(); for (QName model : models) { dictionaryModels.add(model.toPrefixString()); } List<CompiledModel> compiledModels = getAllCustomM2Models(false); if (compiledModels.size() > 0) { for (CompiledModel model : compiledModels) { // check against models loaded in dictionary boolean isActive = false; if (dictionaryModels.contains(model.getM2Model().getName())) { isActive = true; } result.add(new CustomModelDefinitionImpl(model, isActive, dictionaryService)); } } return result; }
DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.setTenantService(tenantService); initDictionaryCaches(dictionaryDAO, tenantService); DictionaryDAOImpl dictionaryDAO2 = new DictionaryDAOImpl(); dictionaryDAO2.setTenantService(tenantService); initDictionaryCaches(dictionaryDAO2, tenantService); dictionaryDAO.putModel(model); dictionaryDAO2.putModel(model2);
@Override public Void doWork() throws Exception { dictionaryDAO.init(); return null; } }, "user1", "tenant1");
CompiledModel compiledModel = dictionaryDAO.getCompiledModel(modelQName); model = compiledModel.getM2Model();
@Override public Void doWork() throws Exception { M2Model customModel = M2Model.createModel( Thread.currentThread().getContextClassLoader(). getResourceAsStream("dictionary/dictionarydaotest_model1.xml")); dictionaryDAO.putModel(customModel); assertNotNull(service.getType(ContentModel.TYPE_CONTENT)); QName qname = QName.createQName("{http://www.alfresco.org/test/dictionarydaotest1/1.0}type1"); TypeDefinition td = service.getType(qname); assertNotNull(td); return null; } }, "user1", "tenant1");
CompiledModel compiledModel = dictionaryDAO.getCompiledModel(modelQName); model = compiledModel.getM2Model();
DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.setTenantService(tenantService);
private static void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception { CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); compiledModelsCache.setDictionaryDAO(dictionaryDAO); compiledModelsCache.setTenantService(tenantService); compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); ThreadPoolExecutorFactoryBean threadPoolfactory = new ThreadPoolExecutorFactoryBean(); threadPoolfactory.afterPropertiesSet(); compiledModelsCache.setThreadPoolExecutor((ThreadPoolExecutor) threadPoolfactory.getObject()); dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); dictionaryDAO.init(); } }
protected List<CustomModelDefinition> getAllCustomModels() { List<CustomModelDefinition> result = new ArrayList<>(); Collection<QName> models = dictionaryDAO.getModels(true); List<String> dictionaryModels = new ArrayList<>(); for (QName model : models) { dictionaryModels.add(model.toPrefixString()); } List<CompiledModel> compiledModels = getAllCustomM2Models(false); if (compiledModels.size() > 0) { for (CompiledModel model : compiledModels) { // check against models loaded in dictionary boolean isActive = false; if (dictionaryModels.contains(model.getM2Model().getName())) { isActive = true; } result.add(new CustomModelDefinitionImpl(model, isActive, dictionaryService)); } } return result; }
public void testBootstrap() throws Exception { TenantService tenantService = new SingleTServiceImpl(); DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.setTenantService(tenantService); initDictionaryCaches(dictionaryDAO, tenantService); DictionaryBootstrap bootstrap = new DictionaryBootstrap(); List<String> bootstrapModels = new ArrayList<String>(); bootstrapModels.add("alfresco/model/dictionaryModel.xml"); bootstrapModels.add("alfresco/model/systemModel.xml"); bootstrapModels.add("alfresco/model/contentModel.xml"); bootstrapModels.add("alfresco/model/applicationModel.xml"); bootstrapModels.add("org/alfresco/repo/security/authentication/userModel.xml"); bootstrapModels.add("org/alfresco/repo/action/actionModel.xml"); bootstrapModels.add("org/alfresco/repo/rule/ruleModel.xml"); bootstrapModels.add("org/alfresco/repo/version/version_model.xml"); bootstrap.setModels(bootstrapModels); bootstrap.setDictionaryDAO(dictionaryDAO); bootstrap.setTenantService(tenantService); bootstrap.bootstrap(); }
private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception { CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); compiledModelsCache.setDictionaryDAO(dictionaryDAO); compiledModelsCache.setTenantService(tenantService); compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); TraceableThreadFactory threadFactory = new TraceableThreadFactory(); threadFactory.setThreadDaemon(true); threadFactory.setThreadPriority(Thread.NORM_PRIORITY); ThreadPoolExecutor threadPoolExecutor = new DynamicallySizedThreadPoolExecutor(20, 20, 90, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), threadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); compiledModelsCache.setThreadPoolExecutor(threadPoolExecutor); dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); dictionaryDAO.init(); }
@Test public void testBootstrap() throws Exception { TenantService tenantService = new SingleTServiceImpl(); DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.setTenantService(tenantService); initDictionaryCaches(dictionaryDAO, tenantService); DictionaryBootstrap bootstrap = new DictionaryBootstrap(); List<String> bootstrapModels = new ArrayList<String>(); bootstrapModels.add("alfresco/model/dictionaryModel.xml"); bootstrap.setModels(bootstrapModels); bootstrap.setDictionaryDAO(dictionaryDAO); bootstrap.setTenantService(tenantService); bootstrap.bootstrap(); }
private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception { CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); compiledModelsCache.setDictionaryDAO(dictionaryDAO); compiledModelsCache.setTenantService(tenantService); compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); ThreadPoolExecutorFactoryBean threadPoolfactory = new ThreadPoolExecutorFactoryBean(); threadPoolfactory.afterPropertiesSet(); compiledModelsCache.setThreadPoolExecutor((ThreadPoolExecutor) threadPoolfactory.getObject()); dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); dictionaryDAO.init(); }
@Override protected void setUp() throws Exception { TenantService mockTenantService = mock(TenantService.class); when(mockTenantService.isEnabled()).thenReturn(true); when(mockTenantService.getCurrentUserDomain()).thenReturn("test.com"); when(mockTenantService.getDomainUser(any(String.class), any(String.class))).thenReturn("System"); when(mockTenantService.getBaseName(any(NodeRef.class))).thenReturn(new NodeRef(BASE_PROTOCOL, BASE_IDENTIFIER, BASE_ID)); when(mockTenantService.getBaseName(any(StoreRef.class))).thenReturn(new StoreRef(BASE_PROTOCOL, BASE_IDENTIFIER)); DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.setTenantService(mockTenantService); initDictionaryCaches(dictionaryDAO, mockTenantService); DictionaryBootstrap bootstrap = new DictionaryBootstrap(); List<String> bootstrapModels = new ArrayList<String>(); bootstrapModels.add("alfresco/model/dictionaryModel.xml"); bootstrapModels.add("alfresco/model/systemModel.xml"); bootstrapModels.add("org/alfresco/repo/policy/policycomponenttest_model.xml"); bootstrapModels.add(TEST_MODEL); bootstrap.setModels(bootstrapModels); bootstrap.setDictionaryDAO(dictionaryDAO); bootstrap.setTenantService(mockTenantService); bootstrap.bootstrap(); DictionaryComponent dictionary = new DictionaryComponent(); dictionary.setDictionaryDAO(dictionaryDAO); // Instantiate Policy Component PolicyComponentImpl x = new PolicyComponentImpl(dictionary); x.setTenantService(mockTenantService); policyComponent = x; }
private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception { CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); compiledModelsCache.setDictionaryDAO(dictionaryDAO); compiledModelsCache.setTenantService(tenantService); compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); ThreadPoolExecutorFactoryBean threadPoolfactory = new ThreadPoolExecutorFactoryBean(); threadPoolfactory.afterPropertiesSet(); compiledModelsCache.setThreadPoolExecutor((ThreadPoolExecutor) threadPoolfactory.getObject()); dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); dictionaryDAO.init(); }
this.dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.setTenantService(tenantService);
@SuppressWarnings("unchecked") private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService tenantService) throws Exception { CompiledModelsCache compiledModelsCache = new CompiledModelsCache(); compiledModelsCache.setDictionaryDAO(dictionaryDAO); compiledModelsCache.setTenantService(tenantService); compiledModelsCache.setRegistry(new DefaultAsynchronouslyRefreshedCacheRegistry()); ThreadPoolExecutorFactoryBean threadPoolfactory = new ThreadPoolExecutorFactoryBean(); threadPoolfactory.afterPropertiesSet(); compiledModelsCache.setThreadPoolExecutor((ThreadPoolExecutor) threadPoolfactory.getObject()); dictionaryDAO.setDictionaryRegistryCache(compiledModelsCache); dictionaryDAO.init(); }
@Override protected void setUp() throws Exception { // Instantiate Dictionary Service TenantService tenantService = new SingleTServiceImpl(); DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl(); dictionaryDAO.setTenantService(tenantService); initDictionaryCaches(dictionaryDAO, tenantService); DictionaryBootstrap bootstrap = new DictionaryBootstrap(); List<String> bootstrapModels = new ArrayList<String>(); bootstrapModels.add("alfresco/model/dictionaryModel.xml"); bootstrapModels.add("alfresco/model/systemModel.xml"); bootstrapModels.add("org/alfresco/repo/policy/policycomponenttest_model.xml"); bootstrapModels.add(TEST_MODEL); bootstrap.setModels(bootstrapModels); bootstrap.setDictionaryDAO(dictionaryDAO); bootstrap.setTenantService(new SingleTServiceImpl()); bootstrap.bootstrap(); DictionaryComponent dictionary = new DictionaryComponent(); dictionary.setDictionaryDAO(dictionaryDAO); // Instantiate Policy Component policyComponent = new PolicyComponentImpl(dictionary); }