use of org.alfresco.repo.tenant.TenantService in project alfresco-repository by Alfresco.
the class DictionaryLoadDAOTest method setUp.
@Before
public void setUp() throws Exception {
// register resource bundles for messages
I18NUtil.registerResourceBundle(TEST_RESOURCE_MESSAGES);
// Instantiate Dictionary Service
TenantService tenantService = new MultiTServiceImpl();
this.dictionaryDAO = new DictionaryDAOImpl();
dictionaryDAO.setTenantService(tenantService);
// TenantUtil.runAsUserTenant(new TenantRunAsWork<Void>()
// {
// @Override
// public Void doWork() throws Exception
// {
// dictionaryDAO.init();
// return null;
// }
// }, "user1", "tenant1");
initDictionaryCaches(dictionaryDAO, tenantService);
new AuthenticationUtil().afterPropertiesSet();
// Populate with appropriate models
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("org/alfresco/repo/security/authentication/userModel.xml");
bootstrapModels.add("alfresco/model/bpmModel.xml");
bootstrapModels.add("alfresco/model/wcmModel.xml");
bootstrapModels.add("alfresco/model/forumModel.xml");
bootstrapModels.add("alfresco/model/imapModel.xml");
bootstrapModels.add("alfresco/model/transferModel.xml");
bootstrapModels.add("alfresco/model/applicationModel.xml");
bootstrapModels.add("alfresco/model/wcmAppModel.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");
bootstrapModels.add("org/alfresco/repo/version/version2_model.xml");
bootstrapModels.add("alfresco/model/emailServerModel.xml");
bootstrapModels.add("alfresco/model/calendarModel.xml");
bootstrapModels.add("alfresco/model/deprecated/blogIntegrationModel.xml");
bootstrapModels.add("alfresco/model/linksModel.xml");
bootstrapModels.add("alfresco/model/remoteCredentialsModel.xml");
bootstrapModels.add("alfresco/model/datalistModel.xml");
bootstrapModels.add("alfresco/model/quickShareModel.xml");
bootstrapModels.add("alfresco/model/surfModel.xml");
bootstrapModels.add("alfresco/model/siteModel.xml");
List<String> labels = new ArrayList<String>();
bootstrap.setModels(bootstrapModels);
bootstrap.setLabels(labels);
bootstrap.setDictionaryDAO(dictionaryDAO);
bootstrap.setTenantService(tenantService);
bootstrap.bootstrap();
}
use of org.alfresco.repo.tenant.TenantService in project alfresco-repository by Alfresco.
the class RepoDictionaryDAOTest method testADB159.
public void testADB159() throws Exception {
// source dictionary
TenantService tenantService = new SingleTServiceImpl();
DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl();
dictionaryDAO.setTenantService(tenantService);
initDictionaryCaches(dictionaryDAO, tenantService);
// destination dictionary
DictionaryDAOImpl dictionaryDAO2 = new DictionaryDAOImpl();
dictionaryDAO2.setTenantService(tenantService);
initDictionaryCaches(dictionaryDAO2, tenantService);
List<String> models = new ArrayList<String>();
models.add("alfresco/model/dictionaryModel.xml");
models.add("alfresco/model/systemModel.xml");
models.add("alfresco/model/contentModel.xml");
models.add("alfresco/model/applicationModel.xml");
models.add("org/alfresco/repo/security/authentication/userModel.xml");
models.add("org/alfresco/repo/action/actionModel.xml");
models.add("org/alfresco/repo/rule/ruleModel.xml");
models.add("org/alfresco/repo/version/version_model.xml");
// round-trip default models
for (String bootstrapModel : models) {
InputStream modelStream = getClass().getClassLoader().getResourceAsStream(bootstrapModel);
if (modelStream == null) {
throw new DictionaryException("Could not find bootstrap model " + bootstrapModel);
}
try {
// parse model from xml
M2Model model = M2Model.createModel(modelStream);
dictionaryDAO.putModel(model);
// regenerate xml from model
ByteArrayOutputStream xml1 = new ByteArrayOutputStream();
model.toXML(xml1);
// register regenerated xml with other dictionary
M2Model model2 = M2Model.createModel(new ByteArrayInputStream(xml1.toByteArray()));
dictionaryDAO2.putModel(model2);
} catch (DictionaryException e) {
throw new DictionaryException("Could not import bootstrap model " + bootstrapModel, e);
}
}
// specific test case
M2Model model = M2Model.createModel("test:adb25");
model.createNamespace(TEST_URL, "test");
model.createImport(NamespaceService.DICTIONARY_MODEL_1_0_URI, NamespaceService.DICTIONARY_MODEL_PREFIX);
model.createImport(NamespaceService.SYSTEM_MODEL_1_0_URI, NamespaceService.SYSTEM_MODEL_PREFIX);
model.createImport(NamespaceService.CONTENT_MODEL_1_0_URI, NamespaceService.CONTENT_MODEL_PREFIX);
M2Type testType = model.createType("test:adb25");
testType.setParentName("cm:" + ContentModel.TYPE_CONTENT.getLocalName());
M2Property prop1 = testType.createProperty("test:prop1");
prop1.setMandatory(false);
prop1.setType("d:" + DataTypeDefinition.TEXT.getLocalName());
prop1.setMultiValued(false);
ByteArrayOutputStream xml1 = new ByteArrayOutputStream();
model.toXML(xml1);
}
use of org.alfresco.repo.tenant.TenantService in project SearchServices by Alfresco.
the class SOLRAPIClientTest method setUp.
@Override
public void setUp() throws Exception {
if (client == null) {
TenantService tenantService = new SingleTServiceImpl();
dictionaryDAO = new DictionaryDAOImpl();
NamespaceDAO namespaceDAO = dictionaryDAO;
dictionaryDAO.setTenantService(tenantService);
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.setResourceClassLoader(getResourceClassLoader());
dictionaryDAO.init();
DictionaryComponent dictionaryComponent = new DictionaryComponent();
dictionaryComponent.setDictionaryDAO(dictionaryDAO);
dictionaryComponent.setMessageLookup(new StaticMessageLookup());
// cmis dictionary
CMISMapping cmisMapping = new CMISMapping();
cmisMapping.setCmisVersion(CmisVersion.CMIS_1_0);
DictionaryNamespaceComponent namespaceService = new DictionaryNamespaceComponent();
namespaceService.setNamespaceDAO(namespaceDAO);
cmisMapping.setNamespaceService(namespaceService);
cmisMapping.setDictionaryService(dictionaryComponent);
cmisMapping.afterPropertiesSet();
cmisDictionaryService = new CMISStrictDictionaryService();
cmisDictionaryService.setCmisMapping(cmisMapping);
cmisDictionaryService.setDictionaryService(dictionaryComponent);
cmisDictionaryService.setDictionaryDAO(dictionaryDAO);
cmisDictionaryService.setSingletonCache(new MemoryCache<String, CMISDictionaryRegistry>());
cmisDictionaryService.setTenantService(tenantService);
cmisDictionaryService.init();
RuntimePropertyLuceneBuilderMapping luceneBuilderMapping = new RuntimePropertyLuceneBuilderMapping();
luceneBuilderMapping.setDictionaryService(dictionaryComponent);
luceneBuilderMapping.setCmisDictionaryService(cmisDictionaryService);
cmisDictionaryService.setPropertyLuceneBuilderMapping(luceneBuilderMapping);
luceneBuilderMapping.afterPropertiesSet();
// Load the key store from the classpath
ClasspathKeyResourceLoader keyResourceLoader = new ClasspathKeyResourceLoader();
client = new SOLRAPIClient(getRepoClient(keyResourceLoader), dictionaryComponent, dictionaryDAO);
trackModels();
}
}
use of org.alfresco.repo.tenant.TenantService in project alfresco-repository by Alfresco.
the class MTPolicyComponentTest method setUp.
@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;
}
Aggregations