org.alfresco.repo.tenant.TenantService Java Examples

The following examples show how to use org.alfresco.repo.tenant.TenantService. 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: DBQueryTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Before
public void setup() throws Exception
{
    nodeService = (NodeService) ctx.getBean("dbNodeService");
    dictionaryService = (DictionaryService) ctx.getBean("dictionaryService");
    dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO");
    namespacePrefixResolver = (DictionaryNamespaceComponent) ctx.getBean("namespaceService");
    transactionService = (TransactionService) ctx.getBean("transactionComponent");
    retryingTransactionHelper = (RetryingTransactionHelper) ctx.getBean("retryingTransactionHelper");
    tenantService = (TenantService) ctx.getBean("tenantService");
    serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
    namespaceDao = (NamespaceDAO) ctx.getBean("namespaceDAO");
    authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent");
    contentService = (ContentService) ctx.getBean("contentService");

    loadTestModel();
    createTestData();
}
 
Example #2
Source File: GetPeopleCannedQuery.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public GetPeopleCannedQuery(
        NodeDAO nodeDAO,
        QNameDAO qnameDAO,
        CannedQueryDAO cannedQueryDAO,
        TenantService tenantService,
        NodeService nodeService,
        AuthorityService authorityService,
        CannedQueryParameters params)
{
    super(params);
    
    this.nodeDAO = nodeDAO;
    this.qnameDAO = qnameDAO;
    this.cannedQueryDAO = cannedQueryDAO;
    this.tenantService = tenantService;
    this.nodeService = nodeService;
    this.authorityService = authorityService;
    
}
 
Example #3
Source File: AuthenticationTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Test for ALF-20680
 * Test of the {@link RepositoryAuthenticationDao#getUserFolderLocation(String)} in multitenancy
 */
public void testAuthenticateMultiTenant()
{
    // Create a tenant domain
    TenantUtil.runAsSystemTenant(new TenantUtil.TenantRunAsWork<Object>()
    {
        public Object doWork() throws Exception
        {
            if (!tenantAdminService.existsTenant(TEST_TENANT_DOMAIN))
            {
                tenantAdminService.createTenant(TEST_TENANT_DOMAIN, TENANT_ADMIN_PW.toCharArray(), null);
            }
            return null;
        }
    }, TenantService.DEFAULT_DOMAIN);

    // Use default admin
    authenticateMultiTenantWork(AuthenticationUtil.getAdminUserName(), DEFAULT_ADMIN_PW);

    // Use tenant admin
    authenticateMultiTenantWork(AuthenticationUtil.getAdminUserName() + TenantService.SEPARATOR + TEST_TENANT_DOMAIN, TENANT_ADMIN_PW);
}
 
Example #4
Source File: DictionaryDAOTest.java    From alfresco-data-model with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void initDictionaryCaches(DictionaryDAOImpl dictionaryDAO, TenantService 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.init();
}
 
Example #5
Source File: PublicApiAlfrescoCmisService.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
private RepositoryInfo getRepositoryInfo(final Network network)
{
	final String networkId = network.getTenantDomain();
    final String tenantDomain = (networkId.equals(TenantUtil.SYSTEM_TENANT) || networkId.equals(TenantUtil.DEFAULT_TENANT)) ? TenantService.DEFAULT_DOMAIN : networkId;

    return TenantUtil.runAsSystemTenant(new TenantRunAsWork<RepositoryInfo>()
    {
        public RepositoryInfo doWork()
        {
            RepositoryInfoImpl repoInfo = (RepositoryInfoImpl)connector.getRepositoryInfo(getContext().getCmisVersion());

            repoInfo.setId(!networkId.equals("") ? networkId : TenantUtil.SYSTEM_TENANT);
            repoInfo.setName(tenantDomain);
            repoInfo.setDescription(tenantDomain);

            return repoInfo;
        }
    }, tenantDomain);
}
 
Example #6
Source File: AbstractBaseApiTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * TODO implement as remote api call
 */
protected String getOrCreateUser(String usernameIn, String password, TestNetwork network)
{
    final String tenantDomain = (network != null ? network.getId() : TenantService.DEFAULT_DOMAIN);

    return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<String>()
    {
        @Override
        public String doWork() throws Exception
        {
            return TenantUtil.runAsTenant(new TenantUtil.TenantRunAsWork<String>()
            {
                public String doWork() throws Exception
                {
                    String username = repoService.getPublicApiContext().createUserName(usernameIn, tenantDomain);
                    PersonInfo personInfo = new PersonInfo(username, username, username, password, null, null, null, null, null, null, null);
                    RepoService.TestPerson person = repoService.getOrCreateUser(personInfo, username, network);
                    return person.getId();
                }
            }, tenantDomain);
        }
    }, networkAdmin);
}
 
Example #7
Source File: WebDAVMethodTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void setUpApplicationContext()
{
    ApplicationContext appContext = ApplicationContextHelper.getApplicationContext(new String[]
            {
                    "classpath:alfresco/application-context.xml", "classpath:alfresco/web-scripts-application-context.xml",
                    "classpath:alfresco/remote-api-context.xml"
            });

    this.nodeService = (NodeService) appContext.getBean("NodeService");
    this.searchService = (SearchService) appContext.getBean("SearchService");
    this.namespaceService = (NamespaceService) appContext.getBean("NamespaceService");
    this.tenantService = (TenantService) appContext.getBean("tenantService");
    this.transactionService = (TransactionService) appContext.getBean("transactionService");
    this.webDAVHelper = (WebDAVHelper) appContext.getBean("webDAVHelper");
    this.tenantAdminService = (TenantAdminService) appContext.getBean("tenantAdminService");

    // Authenticate as system to create initial test data set
    AuthenticationComponent authenticationComponent = (AuthenticationComponent) appContext.getBean("authenticationComponent");
    authenticationComponent.setSystemUserAsCurrentUser();
}
 
Example #8
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 #9
Source File: WebDAVMethodTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Test
public void checkLockedNodeTenantTest()
{
    setUpApplicationContext();

    // Create a tenant domain
    TenantUtil.runAsSystemTenant(new TenantUtil.TenantRunAsWork<Object>() {
        public Object doWork() throws Exception {
            if (!tenantAdminService.existsTenant(TEST_TENANT_DOMAIN))
            {
                tenantAdminService.createTenant(TEST_TENANT_DOMAIN, (DEFAULT_ADMIN_PW + " " + TEST_TENANT_DOMAIN).toCharArray(), null);
            }
            return null;
        }
    }, TenantService.DEFAULT_DOMAIN);
    
    TenantUtil.runAsUserTenant(new TenantUtil.TenantRunAsWork<Object>()
    {
        @Override
        public Object doWork() throws Exception
        {
            checkLockedNodeTestTenantWork();
            return null;
        }
    }, AuthenticationUtil.getAdminUserName(), TEST_TENANT_DOMAIN);
}
 
Example #10
Source File: ModelValidatorImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void validateDeleteProperty(QName modelName, QName propertyQName, boolean sharedModel)
{
    String tenantDomain = TenantService.DEFAULT_DOMAIN;
    if (sharedModel)
    {
        tenantDomain = " for tenant [" + tenantService.getCurrentUserDomain() + "]";
    }

    PropertyDefinition prop = dictionaryDAO.getProperty(propertyQName);
    if(prop != null && prop.getName().equals(propertyQName) && prop.getModel().getName().equals(modelName))
    {
        validateDeleteProperty(tenantDomain, prop);
    }
    else
    {
        throw new AlfrescoRuntimeException("Cannot delete model " + modelName + " in tenant " + tenantDomain
                + " - property definition '" + propertyQName + "' not defined in model '" + modelName + "'");
    }
}
 
Example #11
Source File: AuthorityBridgeTableAsynchronouslyRefreshedCacheTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void setUp() throws Exception
{
    if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
    {
        throw new AlfrescoRuntimeException(
                "A previous tests did not clean up transaction: " +
                AlfrescoTransactionSupport.getTransactionId());
    }
    
    transactionService = (TransactionService) ctx.getBean(ServiceRegistry.TRANSACTION_SERVICE.getLocalName());
    authorityService = (AuthorityService) ctx.getBean(ServiceRegistry.AUTHORITY_SERVICE.getLocalName());
    tenantAdminService = ctx.getBean("tenantAdminService", TenantAdminService.class);
    personService = (PersonService) ctx.getBean(ServiceRegistry.PERSON_SERVICE.getLocalName());
    tenantService = (TenantService) ctx.getBean("tenantService");
    authorityBridgeTableCache = (AuthorityBridgeTableAsynchronouslyRefreshedCache) ctx.getBean("authorityBridgeTableCache");
}
 
Example #12
Source File: TestCMIS.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Before
  public void before() throws Exception
  {
      ctx = getTestFixture().getApplicationContext();
      this.dictionaryDAO = (DictionaryDAO)ctx.getBean("dictionaryDAO");
      this.lockService = (LockService) ctx.getBean("lockService");
      this.tenantService = (TenantService)ctx.getBean("tenantService");
      this.cmisDictionary = (CMISStrictDictionaryService)ctx.getBean("OpenCMISDictionaryService");
      this.cmisTypeExclusions = (QNameFilter)ctx.getBean("cmisTypeExclusions");
this.nodeService = (NodeService) ctx.getBean("NodeService");
      this.fileFolderService = (FileFolderService) ctx.getBean("FileFolderService");
  	this.contentService = (ContentService)applicationContext.getBean("ContentService");
this.permissionService = (PermissionService) ctx.getBean("permissionService");
      
this.globalProperties = (Properties) ctx.getBean("global-properties");
this.globalProperties.setProperty(VersionableAspectTest.AUTO_VERSION_PROPS_KEY, "true");
  }
 
Example #13
Source File: LazyActivitiWorkflowTask.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
public LazyActivitiWorkflowTask(HistoricTaskInstance historicTask, ActivitiTypeConverter typeConverter, TenantService tenantService) 
{
	super(BPMEngineRegistry.createGlobalId(ActivitiConstants.ENGINE_ID, historicTask.getId()), null, null, null, null, null, null, null);
	this.historicTask = historicTask;
	this.activitiTypeConverter = typeConverter;
	this.lazyPropertiesMap = new LazyPropertiesMap();
	
	// Fetch task-definition and a partially-initialized WorkflowTask (not including properties and path)
	WorkflowTaskDefinition taskDefinition = activitiTypeConverter.getTaskDefinition(historicTask.getTaskDefinitionKey(), historicTask.getProcessDefinitionId());
	
	String workflowDefinitionName = activitiTypeConverter.getWorkflowDefinitionName(historicTask.getProcessDefinitionId());
	workflowDefinitionName = tenantService.getBaseName(workflowDefinitionName);
	
	WorkflowTask partiallyInitialized = typeConverter.getWorkflowObjectFactory().createTask(historicTask.getId(), taskDefinition, taskDefinition.getId(), historicTask.getName(),
			historicTask.getDescription(), WorkflowTaskState.COMPLETED, null, workflowDefinitionName , lazyPropertiesMap);
	
	this.definition = taskDefinition;
	this.name = taskDefinition.getId();
	this.title = partiallyInitialized.getTitle();
	this.description = partiallyInitialized.getDescription();
	this.state = partiallyInitialized.getState();
}
 
Example #14
Source File: FileFolderActivityPosterImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Create JSON suitable for create, modify or delete activity posts.
 * 
 * @param tenantDomain String
 * @param path String
 * @param parentNodeRef NodeRef
 * @param nodeRef NodeRef
 * @param fileName String
 * @throws JSONException
 * @return JSONObject
 */
protected JSONObject createActivityJSON(
            String tenantDomain,
            String path,
            NodeRef parentNodeRef,
            NodeRef nodeRef,
            String fileName) throws JSONException
{
        JSONObject json = new JSONObject();

        json.put("nodeRef", nodeRef);
        
        if (parentNodeRef != null)
        {
            // Used for deleted files.
            json.put("parentNodeRef", parentNodeRef);
        }
        
        if (path != null)
        {
            // Used for deleted files and folders (added or deleted)
            json.put("page", "documentlibrary?path=" + path);
        }
        else
        {
            // Used for added or modified files.
            json.put("page", "document-details?nodeRef=" + nodeRef);
        }
        json.put("title", fileName);
        
        if (tenantDomain!= null && !tenantDomain.equals(TenantService.DEFAULT_DOMAIN))
        {
            // Only used in multi-tenant setups.
            json.put("tenantDomain", tenantDomain);
        }
    
    return json;
}
 
Example #15
Source File: DBChild.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void prepare(NamespaceService namespaceService, DictionaryService dictionaryService, QNameDAO qnameDAO, NodeDAO nodeDAO, TenantService tenantService, Set<String> selectors, Map<String, Argument> functionArgs, FunctionEvaluationContext functionContext, boolean supportBooleanFloatAndDouble)
{
   
    Argument argument = functionArgs.get(ARG_PARENT);
    String id = (String) argument.getValue(functionContext);
    argument = functionArgs.get(ARG_SELECTOR);
    if(argument != null)
    {
        String selector = (String) argument.getValue(functionContext);
        if(!selectors.contains(selector))
        {
            throw new QueryModelException("Unkown selector "+selector); 
        }
    }
    else
    {
        if(selectors.size() > 1)
        {
            throw new QueryModelException("Selector must be specified for child constraint (IN_FOLDER) and join"); 
        }
    }
    ParentSupport parentSupport = new ParentSupport();
    parentSupport.setDbid(DBQuery.getDbid(id, nodeDAO, tenantService));
    parentSupport.setCommandType(DBQueryBuilderPredicatePartCommandType.EQUALS);
    builderSupport = parentSupport;
}
 
Example #16
Source File: AuthenticationTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Tests creating a user with a Hashed password
 */
public void testCreateUserWithHashedPassword() throws Exception
{
    String SOME_PASSWORD = "1 passw0rd";
    String defaultencoding = compositePasswordEncoder.getPreferredEncoding();
    String user1 = "uzer"+GUID.generate();
    String user2 = "uzer"+GUID.generate();
    List<String> encs = Arrays.asList("bcrypt10", "md4");

    final String myTestDomain = TEST_TENANT_DOMAIN+"my.test";

    TenantUtil.runAsSystemTenant(new TenantUtil.TenantRunAsWork<Object>() {
        public Object doWork() throws Exception {
            if (!tenantAdminService.existsTenant(myTestDomain)) {
                tenantAdminService.createTenant(myTestDomain, TENANT_ADMIN_PW.toCharArray(), null);
            }
            return null;
        }
    }, TenantService.DEFAULT_DOMAIN);

    for (String enc : encs)
    {
        compositePasswordEncoder.setPreferredEncoding(enc);
        String hash = compositePasswordEncoder.encodePreferred(SOME_PASSWORD,null);
        assertCreateHashed(SOME_PASSWORD, hash, null, user1+ TenantService.SEPARATOR + myTestDomain);
        assertCreateHashed(SOME_PASSWORD, null, SOME_PASSWORD.toCharArray(), user2+ TenantService.SEPARATOR + myTestDomain);
    }
    compositePasswordEncoder.setPreferredEncoding(defaultencoding);
}
 
Example #17
Source File: MTPolicyComponentTest.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@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();
}
 
Example #18
Source File: DBUpper.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void prepare(NamespaceService namespaceService, DictionaryService dictionaryService, QNameDAO qnameDAO, NodeDAO nodeDAO, TenantService tenantService, Set<String> selectors,
        Map<String, Argument> functionArgs, FunctionEvaluationContext functionContext, boolean supportBooleanFloatAndDouble)
{
    // TODO Auto-generated method stub
    
}
 
Example #19
Source File: DBFTSPrefixTerm.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void prepare(NamespaceService namespaceService, DictionaryService dictionaryService, QNameDAO qnameDAO, NodeDAO nodeDAO, TenantService tenantService, Set<String> selectors,
        Map<String, Argument> functionArgs, FunctionEvaluationContext functionContext, boolean supportBooleanFloatAndDouble)
{
    Argument argument = functionArgs.get(ARG_TERM);
    String term = (String) argument.getValue(functionContext);
    // strip trailing wildcard *
    term = term.substring(0, term.length() - 1);
    PropertyArgument propertyArgument = (PropertyArgument) functionArgs.get(ARG_PROPERTY);

    argument = functionArgs.get(ARG_TOKENISATION_MODE);
    AnalysisMode mode = (AnalysisMode) argument.getValue(functionContext);
    if (mode != AnalysisMode.IDENTIFIER)
    {
        throw new QueryModelException("Analysis mode not supported for DB " + mode);
    }

    PropertySupport propertySupport = new PropertySupport();
    propertySupport.setValue(term + "%");

    QName propertyQName = QName.createQName(DBQuery.expandQName(functionContext.getAlfrescoPropertyName(propertyArgument.getPropertyName()), namespaceService));
    propertySupport.setPropertyQName(propertyQName);
    propertySupport.setPropertyDataType(DBQuery.getDataTypeDefinition(dictionaryService, propertyQName));
    propertySupport.setPair(qnameDAO.getQName(propertyQName));
    propertySupport.setJoinCommandType(DBQuery.getJoinCommandType(propertyQName));
    propertySupport.setFieldName(DBQuery.getFieldName(dictionaryService, propertyQName, supportBooleanFloatAndDouble));
    propertySupport.setCommandType(DBQueryBuilderPredicatePartCommandType.LIKE);
    builderSupport = propertySupport;

}
 
Example #20
Source File: HomeFolderProviderSynchronizer.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected void onBootstrap(ApplicationEvent event)
{
    if (enabled())
    {
        final String overrideProviderName = getOverrideHomeFolderProviderName();
        
        // Scan users in default and each Tenant
        
        scanPeople(AuthenticationUtil.getSystemUserName(), TenantService.DEFAULT_DOMAIN, overrideProviderName);
        
        if (tenantAdminService.isEnabled())
        {
            List<Tenant> tenants = tenantAdminService.getAllTenants();
            for (Tenant tenant : tenants)
            {
                if (tenant.isEnabled())
                {
                    final String tenantDomain = tenant.getTenantDomain();
                    TenantUtil.runAsSystemTenant(new TenantRunAsWork<Object>()
                    {
                        public NodeRef doWork() throws Exception
                        {
                            scanPeople(AuthenticationUtil.getSystemUserName(), tenantDomain, overrideProviderName);
                            return null;
                        }
                    }, tenantDomain);
                    
                }
            }
       }
    }
}
 
Example #21
Source File: PublicApiTestContext.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public String createUserName(String alias, String tenant)
{
	StringBuilder sb = new StringBuilder();
	sb.append(alias);
	if ((tenant != null) && (! tenant.equals(TenantService.DEFAULT_DOMAIN)) && (! alias.contains(TenantService.SEPARATOR)))
	{
		sb.append(TenantService.SEPARATOR);
		sb.append(tenant);
	}
	return sb.toString();
}
 
Example #22
Source File: NodesGet.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WebNodeQueryCallback(int count, StoreRef storeRef, TenantService tenantService, QNameDAO qnameDAO)
{
    super();
    
    this.storeRef = storeRef;
    this.tenantService = tenantService;
    this.qnameDAO = qnameDAO;
   
    nodes = new ArrayList<NodeRecord>(count == 0 || count == Integer.MAX_VALUE ? 100 : count);
}
 
Example #23
Source File: WorkflowObjectFactory.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WorkflowObjectFactory(WorkflowQNameConverter qNameConverter,
        TenantService tenantService,
        MessageService messageService,
        DictionaryService dictionaryService,
        String engineId, QName defaultStartTaskType)
{
    this.tenantService = tenantService;
    this.messageService = messageService;
    this.dictionaryService = dictionaryService;
    this.engineId = engineId;
    this.qNameConverter = qNameConverter;
    this.defaultStartTaskType = defaultStartTaskType;
}
 
Example #24
Source File: DBPropertyAccessor.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void prepare(NamespaceService namespaceService, DictionaryService dictionaryService, QNameDAO qnameDAO, NodeDAO nodeDAO, TenantService tenantService, Set<String> selectors,
        Map<String, Argument> functionArgs, FunctionEvaluationContext functionContext, boolean supportBooleanFloatAndDouble)
{
    // TODO Auto-generated method stub
    
}
 
Example #25
Source File: CMISAbstractDictionaryService.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected CMISDictionaryRegistry createDictionaryRegistry(String tenant)
{
    CMISDictionaryRegistry cmisRegistry = null;

    if (tenant.equals(TenantService.DEFAULT_DOMAIN))
    {
        cmisRegistry = createCoreDictionaryRegistry();
    }
    else
    {
        cmisRegistry = createTenantDictionaryRegistry(tenant);
    }

    return cmisRegistry;
}
 
Example #26
Source File: LuceneResultSet.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Wrap a lucene seach result with node support
 * 
 * @param hits Hits
 * @param searcher Searcher
 * @param nodeService nodeService
 * @param tenantService tenant service
 * @param searchParameters SearchParameters
 * @param config - lucene config
 */
public LuceneResultSet(Hits hits, Searcher searcher, NodeService nodeService, TenantService tenantService, SearchParameters searchParameters,
        LuceneConfig config)
{
    super();
    this.hits = hits;
    this.searcher = searcher;
    this.nodeService = nodeService;
    this.tenantService = tenantService;
    this.searchParameters = searchParameters;
    this.config = config;
    prefetch = new BitSet(hits.length());
}
 
Example #27
Source File: DictionaryDAOTest.java    From alfresco-repository 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 MultiTServiceImpl();

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

    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");
    List<String> labels = new ArrayList<String>();
    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 #28
Source File: DictionaryDAOImpl.java    From alfresco-data-model with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * For cache use only.
 * 
 * @param tenantDomain String
 * @return constructed DictionaryRegistry
 */
public DictionaryRegistry initDictionaryRegistry(final String tenantDomain)
{
    return AuthenticationUtil.runAs(
            new RunAsWork<DictionaryRegistry>()
            {
                public DictionaryRegistry doWork()
                {
                    DictionaryRegistry dictionaryRegistry = null;
                    if (tenantDomain.equals(TenantService.DEFAULT_DOMAIN))
                    {
                        dictionaryRegistry = createCoreDictionaryRegistry();
                    }
                    else
                    {
                        dictionaryRegistry = createTenantDictionaryRegistry(tenantDomain);
                    }

                    getThreadLocal().put(tenantDomain, dictionaryRegistry);
                    dictionaryRegistry.init();
                    getThreadLocal().remove(tenantDomain);

                    return dictionaryRegistry;
                }
            },
            tenantService.getDomainUser(
                    AuthenticationUtil.getSystemUserName(), tenantDomain));
}
 
Example #29
Source File: NodeArchiveServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
public void setTenantService(TenantService tenantService)
{
    this.tenantService = tenantService;
}
 
Example #30
Source File: AbstractBaseApiTest.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
@Before
public void setup() throws Exception
{
    jacksonUtil = new JacksonUtil(applicationContext.getBean("jsonHelper", JacksonHelper.class));

    if (networkOne == null)
    {
        // note: populateTestData/createTestData will be called (which currently creates 2 tenants, 9 users per tenant, 10 sites per tenant, ...)
        networkOne = getTestFixture().getRandomNetwork();
    }
    
    //userOneN1 = networkN1.createUser();
    //userTwoN1 = networkN1.createUser();

    String tenantDomain = networkOne.getId();
    
    if (! TenantService.DEFAULT_DOMAIN.equals(tenantDomain))
    {
        networkAdmin = DEFAULT_ADMIN+"@"+tenantDomain;
    }

    // to enable admin access via test calls - eg. via PublicApiClient -> AbstractTestApi -> findUserByUserName
    getOrCreateUser(networkAdmin, "admin", networkOne);
    
    setRequestContext(networkOne.getId(), networkAdmin, DEFAULT_ADMIN_PWD);
    
    // note: createUser currently relies on repoService
    user1 = createUser("user1-" + RUNID, "user1Password", networkOne);
    user2 = createUser("user2-" + RUNID, "user2Password", networkOne);

    // used-by teardown to cleanup
    authenticationService = applicationContext.getBean("authenticationService", MutableAuthenticationService.class);
    personService = applicationContext.getBean("personService", PersonService.class);
    users.add(user1);
    users.add(user2);

    setRequestContext(networkOne.getId(), user1, null);
    
    tSiteId = createSite("TestSite A - " + RUNID, SiteVisibility.PRIVATE).getId();
    tDocLibNodeId = getSiteContainerNodeId(tSiteId, "documentLibrary");

    setRequestContext(null, null, null);
}