cancel
Showing results for 
Search instead for 
Did you mean: 

'Super' Administrator for Multi Tenant Alfresco

softbless
Champ in-the-making
Champ in-the-making
Hi Guys,

We use Multi Tenant feature in Alfresco Community Edition 3.2r2. Everything works fine, but we need to have a kind of "super" Administrator for our Alfresco. For example, i create tenant "FinanceTeam" and "ProjectTeam"

My question is :
# Could "admin" (not admin@FinanceTeam) access all the content/space in tenant FinanceTeam? By default, I think it cannot be done. Anyone could share some tips about this?
# Could we make a User Group, such as User Group AdminLevel1, and could we give the users in that group access to all content and space in Alfresco?

Please kindly advise guys.
11 REPLIES 11

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
in order tho know tenants repository size you can calculate size of company's home.

public static class ClassA implements RunAsWork<Object> {
dowork….
{
calculate size of CompanyHome directory.
}
}

AuthenticationUtil.setRunAsUser('"admin@tenant";

classA .doWork();
this concept lets you get access to tenant you like, and where calculate size of … stands you add code for calculating space sice. I hope it is more clear now.

chandu7ee
Champ in-the-making
Champ in-the-making
the following code working fine to get space occupied by the tenant. but if tenant which is already created with out specified <root contentstore dir> gives the same space usage as shown below, so that i am trying to get the size of the company home for each tenant ., but how can i calculate it.

package org.example;

import java.io.File;
import java.io.IOException;
import java.util.List;
import org.alfresco.repo.tenant.Tenant;
import org.alfresco.repo.tenant.TenantAdminService;
import org.alfresco.service.cmr.attributes.AttributeService;
import org.alfresco.web.scripts.AbstractWebScript;
import org.alfresco.web.scripts.WebScriptException;
import org.alfresco.web.scripts.WebScriptRequest;
import org.alfresco.web.scripts.WebScriptResponse;
import org.apache.commons.io.FileUtils;

public class TenantDetails extends AbstractWebScript
{
   private TenantAdminService tenantAdminService; 
    private static final long  MEGABYTE = 1024L * 1024L;
   
   public TenantAdminService getTenantAdminService()
   {
      return tenantAdminService;
   }

   public void setTenantAdminService(TenantAdminService tenantAdminService)
   {
      this.tenantAdminService = tenantAdminService;
   }
   
   @Override
   public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
   {
      List<Tenant> tenants = tenantAdminService.getAllTenants();
      File directory;

       for (Tenant tenant : tenants)
       {
          res.getWriter().write(tenant.getTenantDomain());
          directory = new File(tenant.getRootContentStoreDir());
         res.getWriter().write(bytesToMeg(FileUtils.sizeOfDirectory(directory))+"MB");            
       }   
   }
   
   public static long bytesToMeg(long bytes)
   {
        return bytes / MEGABYTE ;
   }
   
   public static long getMegabyte() {
      return MEGABYTE;
   }   
   
   
}

here i am the super admin want to calculate size for the each company home of the tenant. 

please let me know what i need to do to get each tenant comp home size.

[img]http://img824.imageshack.us/img824/6462/captureql.jpg[/img]

here i got the code to get company home but how can i use this in above code.

public NodeRef getCompanyHome()
    {
        String tenantDomain = tenantAdminService.getCurrentUserDomain();
        NodeRef companyHomeRef = companyHomeRefs.get(tenantDomain);
        if (companyHomeRef == null)
        {
           companyHomeRef = AuthenticationUtil.runAs(new RunAsWork<NodeRef>()
           {
                public NodeRef doWork() throws Exception
                {
                    return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<NodeRef>()
                    {
                        public NodeRef execute() throws Exception
                        {
                            List<NodeRef> refs = searchService.selectNodes(nodeService.getRootNode(companyHomeStore), companyHomePath, null, namespaceService, false);
                            if (refs.size() != 1)
                            {
                                throw new IllegalStateException("Invalid company home path: " + companyHomePath + " - found: " + refs.size());
                                }
                                return refs.get(0);
                            }
                        }, true);
                    }
                }, AuthenticationUtil.getSystemUserName());
           companyHomeRefs.put(tenantDomain, companyHomeRef);
        }
        return companyHomeRef;
    }





Thanks
Chandu