org.alfresco.repo.tenant.SingleTServiceImpl Java Examples

The following examples show how to use org.alfresco.repo.tenant.SingleTServiceImpl. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DictionaryDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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();
}
 
Example #2
Source File: RepoDictionaryDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
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();
}
 
Example #3
Source File: PolicyComponentTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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); 
}
 
Example #4
Source File: DictionaryDAOTest.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testBootstrap()
{
    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();
}
 
Example #5
Source File: DictionaryDAOTest.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void testUseImportedNamespaces()
{
    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(TEST_COMMON_NS_PARENT_MODEL);
    bootstrapModels.add(TEST_COMMON_NS_CHILD_MODEL);
    
    bootstrap.setModels(bootstrapModels);
    bootstrap.setDictionaryDAO(dictionaryDAO);
    bootstrap.setTenantService(tenantService);
    bootstrap.bootstrap();
}
 
Example #6
Source File: AbstractModelTest.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
     * Setup
     */
    protected void setUp() throws Exception
    {
        // Initialise the Dictionary
        TenantService tenantService = new SingleTServiceImpl();

//        NamespaceDAOImpl namespaceDAO = new NamespaceDAOImpl();
//        namespaceDAO.setTenantService(tenantService);
//        initNamespaceCaches(namespaceDAO);

        dictionaryDAO = new DictionaryDAOImpl();
        dictionaryDAO.setTenantService(tenantService);

        initDictionaryCaches(dictionaryDAO, tenantService);


        // include Alfresco dictionary model
        List<String> bootstrapModels = new ArrayList<String>();
        bootstrapModels.add("alfresco/model/dictionaryModel.xml");

        DictionaryBootstrap bootstrap = new DictionaryBootstrap();
        bootstrap.setModels(bootstrapModels);
        bootstrap.setDictionaryDAO(dictionaryDAO);
        bootstrap.bootstrap();
    }
 
Example #7
Source File: DictionaryDAOTest.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Before
public void setUp() throws Exception
{   
    // register resource bundles for messages
    I18NUtil.registerResourceBundle(TEST_RESOURCE_MESSAGES);

    // Instantiate Dictionary Service
    TenantService tenantService = new SingleTServiceImpl();

    this.dictionaryDAO = new DictionaryDAOImpl();
    dictionaryDAO.setTenantService(tenantService);
    initDictionaryCaches(dictionaryDAO, tenantService);

    // Populate with appropriate models
    DictionaryBootstrap bootstrap = new DictionaryBootstrap();
    List<String> bootstrapModels = new ArrayList<String>();
    bootstrapModels.add("alfresco/model/dictionaryModel.xml");
    bootstrapModels.add(TEST_MODEL);
    List<String> labels = new ArrayList<String>();
    labels.add(TEST_BUNDLE);
    bootstrap.setModels(bootstrapModels);
    bootstrap.setLabels(labels);
    bootstrap.setDictionaryDAO(dictionaryDAO);
    bootstrap.setTenantService(tenantService);
    bootstrap.bootstrap();

    DictionaryComponent component = new DictionaryComponent();
    component.setDictionaryDAO(dictionaryDAO);
    component.setMessageLookup(new StaticMessageLookup());
    service = component;
}
 
Example #8
Source File: DictionaryDAOTest.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * ACE-5120: Dictionary should not allow duplication of namespace prefixes
 */
@Test
public void testNamespaceClashResultsInSensibleError()
{
    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(TEST_MODEL);
    bootstrapModels.add(TEST_NS_CLASH_MODEL);

    bootstrap.setModels(bootstrapModels);
    bootstrap.setDictionaryDAO(dictionaryDAO);
    bootstrap.setTenantService(tenantService);

    try
    {
        bootstrap.bootstrap();
        fail("Expected "+NamespaceException.class.getName()+" to be thrown, but it was not.");
    }
    catch (NamespaceException e)
    {
        System.out.println(e.getMessage());
        // Good!
    }
}
 
Example #9
Source File: DictionaryDAOTest.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testBootstrapImportModelWithCircularTypes()
{
    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("org/alfresco/repo/dictionary/modelCircularTypes.xml");
    bootstrap.setModels(bootstrapModels);
    bootstrap.setDictionaryDAO(dictionaryDAO);
    bootstrap.setTenantService(tenantService);

    try
    {
        bootstrap.bootstrap();
        fail("Bootstrap should fail as the model contains a cyclic refrence");
    }
    catch(DictionaryException e)
    {
        assertEquals(e.getMsgId(), "d_dictionary.bootstrap.model_not_imported");
    }
}
 
Example #10
Source File: DictionaryDAOTest.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Test
public void testCreateModelWithCircularTypeDependency()
{
    TenantService tenantService = new SingleTServiceImpl();

    DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl();
    dictionaryDAO.setTenantService(tenantService);
    initDictionaryCaches(dictionaryDAO, tenantService);

    //create model
    String testNamespace = "http://www.alfresco.org/model/dictionary/1.0/my";
    M2Model model = M2Model.createModel("my:circularModel");
    model.createNamespace(testNamespace, "my");
    model.setAnalyserResourceBundleName("typeModelResourceBundle");
    M2Type typeA = model.createType("my:circularA");
    typeA.setParentName("my:circularC");
    M2Type typeB = model.createType("my:circularB");
    typeB.setParentName("my:circularA");
    M2Type typeC = model.createType("my:circularC");
    typeC.setParentName("my:circularB");

    try
    {
        dictionaryDAO.putModel(model);
        fail("Model should not be saved successfully because it contains a cyclic reference");
    } catch(DictionaryException e)
    {
        assertEquals(e.getMsgId(), "d_dictionary.compiled_model.err.compile.failure");
    }
}
 
Example #11
Source File: TestModel.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Test model
 * 
 * Java command line client
 * <br />
 * Syntax:
 * <br />
 * TestModel [-h] [model filename]*
 * <p>
 * Returns 0 for success.
 * @throws Exception 
 */
public static void main(String[] args) throws Exception
{
    if (args != null && args.length > 0 && args[0].equals("-h"))
    {
        System.out.println("TestModel [model filename]*");
        System.exit(1);
    }
    
    System.out.println("Testing dictionary model definitions...");

    // construct list of models to test
    // include alfresco defaults
    List<String> bootstrapModels = new ArrayList<String>();
    bootstrapModels.add("alfresco/model/dictionaryModel.xml");
    bootstrapModels.add("alfresco/model/systemModel.xml");
    bootstrapModels.add("org/alfresco/repo/security/authentication/userModel.xml");
    bootstrapModels.add("alfresco/model/contentModel.xml");
    bootstrapModels.add("alfresco/model/applicationModel.xml");
    bootstrapModels.add("alfresco/model/bpmModel.xml");

    // include models specified on command line
    for (String arg: args)
    {
        bootstrapModels.add(arg);
    }
    
    for (String model : bootstrapModels)
    {
        System.out.println(" " + model);
    }
    
    // construct dictionary dao        
    TenantService tenantService = new SingleTServiceImpl();

    DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl();
    dictionaryDAO.setTenantService(tenantService);
    
    initDictionaryCaches(dictionaryDAO, tenantService);

    // bootstrap dao
    try
    {
        DictionaryBootstrap bootstrap = new DictionaryBootstrap();
        bootstrap.setModels(bootstrapModels);
        bootstrap.setDictionaryDAO(dictionaryDAO);
        bootstrap.bootstrap();
        System.out.println("Models are valid.");
        
        System.exit(0); // Success
        
    }
    catch(Exception e)
    {
        System.out.println("Found an invalid model...");
        Throwable t = e;
        while (t != null)
        {
            System.out.println(t.getMessage());
            t = t.getCause();
        }
        System.exit(2); // Not Success
    }
}
 
Example #12
Source File: RepoDictionaryDAOTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void setUp() throws Exception
{
    // Registered the required constraints
    ConstraintRegistry constraintRegistry = ConstraintRegistry.getInstance();
    AbstractConstraint constraintReg1 = new UserNameConstraint();
    constraintReg1.setShortName("cm:reg1");
    constraintReg1.setRegistry(constraintRegistry);
    constraintReg1.initialize();
    AbstractConstraint constraintReg2 = new UserNameConstraint();
    constraintReg2.setShortName("cm:reg2");
    constraintReg2.setRegistry(constraintRegistry);
    constraintReg2.initialize();
    
    // register resource bundles for messages
    I18NUtil.registerResourceBundle(TEST_RESOURCE_MESSAGES);
    
    // Instantiate Dictionary Service
    TenantService tenantService = new SingleTServiceImpl();

    DictionaryDAOImpl dictionaryDAO = new DictionaryDAOImpl();
    dictionaryDAO.setTenantService(tenantService);
    initDictionaryCaches(dictionaryDAO, tenantService);

    // Populate with appropriate models
    DictionaryBootstrap bootstrap = new DictionaryBootstrap();
    List<String> bootstrapModels = new ArrayList<String>();
    bootstrapModels.add("alfresco/model/dictionaryModel.xml");
    bootstrapModels.add(TEST_MODEL);
    List<String> labels = new ArrayList<String>();
    labels.add(TEST_BUNDLE);
    bootstrap.setModels(bootstrapModels);
    bootstrap.setLabels(labels);
    bootstrap.setDictionaryDAO(dictionaryDAO);
    bootstrap.setTenantService(tenantService);
    bootstrap.bootstrap();
    
    DictionaryComponent component = new DictionaryComponent();
    component.setDictionaryDAO(dictionaryDAO);
    component.setMessageLookup(new StaticMessageLookup());
    service = component;
}
 
Example #13
Source File: SOLRAPIClientTest.java    From SearchServices with GNU Lesser General Public License v3.0 4 votes vote down vote up
@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);
        // TODO: use config ....
        dictionaryDAO.setDefaultAnalyserResourceBundleName("alfresco/model/dataTypeAnalyzers");
        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();
    }
}