Java Code Examples for org.alfresco.repo.tenant.TenantUtil#isCurrentDomainDefault()

The following examples show how to use org.alfresco.repo.tenant.TenantUtil#isCurrentDomainDefault() . 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: SiteServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @see org.alfresco.service.cmr.site.SiteService#listSites(java.lang.String, int)
 */
public List<SiteInfo> listSites(final String userName, final int size)
{
    // MT share - for activity service remote system callback (deprecated)
    if (tenantService.isEnabled() &&
        TenantUtil.isCurrentDomainDefault() &&
        (AuthenticationUtil.SYSTEM_USER_NAME.equals(AuthenticationUtil.getRunAsUser())) && 
        tenantService.isTenantUser(userName))
    {
        final String tenantDomain = tenantService.getUserDomain(userName);
        
        return TenantUtil.runAsSystemTenant(new TenantRunAsWork<List<SiteInfo>>()
        {
            public List<SiteInfo> doWork() throws Exception
            {
                return listSitesImpl(userName, size);
            }
        }, tenantDomain);
    }
    else
    {
        return listSitesImpl(userName, size);
    }
}
 
Example 2
Source File: SiteServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * @see org.alfresco.service.cmr.site.SiteService#getSite(java.lang.String)
 */
public SiteInfo getSite(final String shortName)
{
    // MT share - for activity service remote system callback (deprecated)
    if (tenantService.isEnabled() &&
        TenantUtil.isCurrentDomainDefault() &&
        (AuthenticationUtil.SYSTEM_USER_NAME.equals(AuthenticationUtil.getRunAsUser())) &&
        tenantService.isTenantName(shortName))
    {
        final String tenantDomain = tenantService.getDomain(shortName);
        final String sName = tenantService.getBaseName(shortName, true);
        
        return TenantUtil.runAsSystemTenant(new TenantRunAsWork<SiteInfo>()
        {
            public SiteInfo doWork() throws Exception
            {
                SiteInfo site = getSiteImpl(sName);
                return new SiteInfoImpl(site.getSitePreset(), shortName, site.getTitle(), site.getDescription(), site.getVisibility(), site.getCustomProperties(), site.getNodeRef());
            }
        }, tenantDomain);
    }
    else
    {
        return getSiteImpl(shortName);
    }
}
 
Example 3
Source File: SiteServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
public Map<String, String> listMembers(String shortName, final String nameFilter, final String roleFilter, final int size, final boolean collapseGroups)
{
    // MT share - for activity service remote system callback (deprecated)
    if (tenantService.isEnabled() &&
        TenantUtil.isCurrentDomainDefault() &&
        (AuthenticationUtil.SYSTEM_USER_NAME.equals(AuthenticationUtil.getRunAsUser())) &&
        tenantService.isTenantName(shortName))
    {
        final String tenantDomain = tenantService.getDomain(shortName);
        final String sName = tenantService.getBaseName(shortName, true);
        
        return TenantUtil.runAsSystemTenant(new TenantRunAsWork<Map<String, String>>()
        {
            public Map<String, String> doWork() throws Exception
            {
                return listMembersImpl(sName, nameFilter, roleFilter, size, collapseGroups);
            }
        }, tenantDomain);
    }
    else
    {
        return listMembersImpl(shortName, nameFilter, roleFilter, size, collapseGroups);
    }
}
 
Example 4
Source File: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
* {@inheritDoc}
*/
public List<WorkflowDefinition> getAllDefinitions()
{
    try 
    {
        ProcessDefinitionQuery query = repoService.createProcessDefinitionQuery();
        if(activitiUtil.isMultiTenantWorkflowDeploymentEnabled() && !TenantUtil.isCurrentDomainDefault()) 
        {
            query.processDefinitionKeyLike("@" + TenantUtil.getCurrentDomain() + "%");
        }
        return getValidWorkflowDefinitions(query.list());
    } 
    catch (ActivitiException ae)
    {
        String msg = messageService.getMessage(ERR_GET_WORKFLOW_DEF);
        if(logger.isDebugEnabled())
        {
        	logger.debug(msg, ae);
        }
        throw new WorkflowException(msg, ae);
    }
}
 
Example 5
Source File: ActivitiWorkflowEngine.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
* {@inheritDoc}
*/
public List<WorkflowDefinition> getDefinitions()
{
    try 
    {
        ProcessDefinitionQuery query = repoService.createProcessDefinitionQuery().latestVersion();
        if(activitiUtil.isMultiTenantWorkflowDeploymentEnabled() && !TenantUtil.isCurrentDomainDefault()) 
        {
            query.processDefinitionKeyLike("@" + TenantUtil.getCurrentDomain() + "%");
        }
        return getValidWorkflowDefinitions(query.list());
    }
    catch (ActivitiException ae)
    {
        String msg = messageService.getMessage(ERR_GET_WORKFLOW_DEF);
        if(logger.isDebugEnabled())
        {
        	logger.debug(msg, ae);
        }
        throw new WorkflowException(msg, ae);
    }
}
 
Example 6
Source File: TenantRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 6 votes vote down vote up
/**
 *
 * {@inheritDoc}
 */
@Override
protected List<ContentStore> getAllStores()
{
    final List<ContentStore> stores = new ArrayList<>();
    if (!TenantUtil.isCurrentDomainDefault())
    {
        final String currentDomain = TenantUtil.getCurrentDomain();
        final ContentStore tenantStore = this.storeByTenant.get(currentDomain);
        if (tenantStore != null)
        {
            stores.add(tenantStore);
        }
    }
    stores.add(this.fallbackStore);

    return stores;
}
 
Example 7
Source File: TenantRoutingContentStore.java    From alfresco-simple-content-stores with Apache License 2.0 5 votes vote down vote up
/**
 *
 * {@inheritDoc}
 */
@Override
protected ContentStore getStore(final String contentUrl, final boolean mustExist)
{
    ContentStore readStore = null;

    if (!TenantUtil.isCurrentDomainDefault())
    {
        final String currentDomain = TenantUtil.getCurrentDomain();
        if (this.storeByTenant.containsKey(currentDomain))
        {
            readStore = this.storeByTenant.get(currentDomain);

            if (!readStore.isContentUrlSupported(contentUrl) || (mustExist && !readStore.exists(contentUrl)))
            {
                readStore = null;
            }
        }
    }

    if (readStore == null)
    {
        readStore = super.getStore(contentUrl, mustExist);
    }

    return readStore;
}