Package org.pentaho.platform.core.mt

Examples of org.pentaho.platform.core.mt.Tenant


  public static ProxyPentahoRole toProxyRole( IPentahoRole role ) {
    ProxyPentahoRole proxyRole = new ProxyPentahoRole( role.getName() );
    proxyRole.setDescription( role.getDescription() );
    ITenant tenant = role.getTenant();
    proxyRole.setTenant( new Tenant( tenant.getId(), tenant.isEnabled() ) );
    return proxyRole;
  }
View Full Code Here


  }

  protected ITenant getCurrentTenant() {
    if ( PentahoSessionHolder.getSession() != null ) {
      String tenantId = (String) PentahoSessionHolder.getSession().getAttribute( IPentahoSession.TENANT_ID_KEY );
      return tenantId != null ? new Tenant( tenantId, true ) : null;
    } else {
      return null;
    }
  }
View Full Code Here

        IPentahoSession pentahoSession = PentahoSessionHolder.getSession();
        String tenantId = (String) pentahoSession.getAttribute( IPentahoSession.TENANT_ID_KEY );
        if ( tenantId == null ) {
          tenantId = getDefaultTenantPath();
        }
        tenant = new Tenant( tenantId, true );
        return getRoleNameUtils().getPrincipleId( tenant, principal );
      } else {
        return principal;
      }
    } else {
View Full Code Here

        IPentahoSession pentahoSession = PentahoSessionHolder.getSession();
        String tenantId = (String) pentahoSession.getAttribute( IPentahoSession.TENANT_ID_KEY );
        if ( tenantId == null ) {
          tenantId = getDefaultTenantPath();
        }
        tenant = new Tenant( tenantId, true );
        return getUserNameUtils().getPrincipleId( tenant, username );
      } else {
        return username;
      }
    } else {
View Full Code Here

  }

  public static ITenant getCurrentTenant() {
    if ( PentahoSessionHolder.getSession() != null ) {
      String tenantId = (String) PentahoSessionHolder.getSession().getAttribute( IPentahoSession.TENANT_ID_KEY );
      return tenantId != null ? new Tenant( tenantId, true ) : null;
    } else
      return null;
  }
View Full Code Here

    return ServerRepositoryPaths.getPentahoRootFolderPath() + RepositoryFile.SEPARATOR
        + TenantUtils.TENANTID_SINGLE_TENANT;
  }

  public static ITenant getDefaultTenant() {
    return new Tenant( getDefaultTenantPath(), true );
  }
View Full Code Here

            getTenantRootFolder( session, parentTenant ).getId(), null );
    for ( RepositoryFile repoFile : allChildren ) {
      Map<String, Serializable> metadata = JcrRepositoryFileUtils.getFileMetadata( session, repoFile.getId() );
      if ( metadata.containsKey( ITenantManager.TENANT_ROOT )
        && (Boolean) metadata.get( ITenantManager.TENANT_ROOT ) ) {
        Tenant tenant = new Tenant( repoFile.getPath(), isTenantEnabled( session, repoFile.getId() ) );
        if ( includeDisabledTenants || tenant.isEnabled() ) {
          children.add( new Tenant( pathConversionHelper.relToAbs(repoFile.getPath()), isTenantEnabled(session, repoFile.getId()) ) );
        }

      }
    }
    return children;
View Full Code Here

  public ITenant getTenant( Session session, String tenantId ) throws RepositoryException {
    ITenant tenant = null;
    RepositoryFile tenantRootFolder =
        JcrRepositoryFileUtils.getFileByAbsolutePath( session, tenantId, pathConversionHelper, null, false, null );
    if ( ( tenantRootFolder != null ) && isTenantRoot( session, tenantRootFolder.getId() ) ) {
      tenant = new Tenant( tenantId, isTenantEnabled( session, tenantRootFolder.getId() ) );
    }
    return tenant;
  }
View Full Code Here

  private RepositoryFile createTenantFolder( final ITenant parentTenant, final String tenantName,
      final String tenantCreatorId ) {
    return (RepositoryFile) jcrTemplate.execute( new JcrCallback() {
      @Override
      public Object doInJcr( final Session session ) throws RepositoryException {
        Tenant tenant = null;
        RepositoryFile parentFolder = null;
        if ( parentTenant == null ) {
          tenant = new Tenant( "/" + tenantName, true );
        } else {
          tenant = new Tenant( parentTenant.getRootFolderAbsolutePath() + "/" + tenantName, true );
          String folderPath = parentTenant.getRootFolderAbsolutePath();
          parentFolder = repositoryFileDao.getFileByAbsolutePath( folderPath );
        }

        RepositoryFileAcl acl = new RepositoryFileAcl.Builder( tenantCreatorId ).entriesInheriting( false ).build();
        RepositoryFile systemTenantFolder =
            repositoryFileDao.createFolder( parentFolder != null ? parentFolder.getId() : null,
                new RepositoryFile.Builder( tenant.getName() ).folder( true ).build(), acl, "" );
        repositoryFileDao.getFileByAbsolutePath( tenant.getId() );

        Map<String, Serializable> fileMeta = repositoryFileDao.getFileMetadata( systemTenantFolder.getId() );
        fileMeta.put( ITenantManager.TENANT_ROOT, true );
        fileMeta.put( ITenantManager.TENANT_ENABLED, true );
        JcrRepositoryFileUtils.setFileMetadata( session, systemTenantFolder.getId(), fileMeta );
View Full Code Here

   * java.lang.String)
   */
  @Override
  public ITenant createTenant( final ITenant parentTenant, final String tenantName, final String tenantAdminRoleName,
      final String authenticatedRoleName, final String anonymousRoleName ) {
    Tenant newTenant;
    String parentTenantFolder;
    if ( parentTenant == null ) {
      if ( repositoryFileDao.getFileByAbsolutePath( "/" + tenantName ) != null ) {
        return null;
      }
    } else {
      if ( repositoryFileDao.getFileByAbsolutePath( parentTenant.getRootFolderAbsolutePath() + "/" + tenantName )
        != null ) {
        return null;
      }
    }
    if ( parentTenant == null ) {
      newTenant = new Tenant( RepositoryFile.SEPARATOR + tenantName, true );
      parentTenantFolder = "/";
    } else {
      newTenant = new Tenant( parentTenant.getRootFolderAbsolutePath() + RepositoryFile.SEPARATOR + tenantName, true );
      parentTenantFolder = parentTenant.getRootFolderAbsolutePath();
    }

    String tenantCreatorId = PentahoSessionHolder.getSession().getName();
    RepositoryFile tenantRootFolder = createTenantFolder( parentTenant, tenantName, tenantCreatorId );

    userRoleDao.createRole( newTenant, tenantAdminRoleName, "", new String[0] );
    userRoleDao.createRole( newTenant, authenticatedRoleName, "", new String[0] );
    userRoleDao.createRole( newTenant, anonymousRoleName, "", new String[0] );
    roleBindingDao
        .setRoleBindings( newTenant, authenticatedRoleName, singleTenantAuthenticatedAuthorityRoleBindingList );

    String tenantAdminRoleId = tenantedRoleNameResolver.getPrincipleId( newTenant, tenantAdminRoleName );
    RepositoryFileSid tenantAdminRoleSid = new RepositoryFileSid( tenantAdminRoleId, Type.ROLE );

    this.jcrTemplate.save();
    // If parent tenant is null then we assume we're creating the system tenant. In which case we'll give the
    // system
    // tenant admin permissions on the root folder.
    if ( parentTenant == null ) {
      repositoryFileAclDao.addAce( tenantRootFolder.getId(), tenantAdminRoleSid, EnumSet
          .of( RepositoryFilePermission.ALL ) );
    } else {

      RepositoryFileAcl acl = repositoryFileAclDao.getAcl( tenantRootFolder.getId() );
      Builder aclBuilder =
          new RepositoryFileAcl.Builder( acl ).ace( tenantAdminRoleSid, EnumSet.of( RepositoryFilePermission.ALL ) );

      IPentahoSession origPentahoSession = PentahoSessionHolder.getSession();
      Authentication origAuthentication = SecurityContextHolder.getContext().getAuthentication();
      login( repositoryAdminUsername, tenantAdminRoleId );
      try {
        // Give all to Tenant Admin of all ancestors
        while ( !parentTenantFolder.equals( "/" ) ) {
          ITenant tenant = new Tenant( parentTenantFolder, true );
          String parentTenantAdminRoleId = tenantedRoleNameResolver.getPrincipleId( tenant, tenantAdminRoleName );
          RepositoryFileSid parentTenantAdminSid = new RepositoryFileSid( parentTenantAdminRoleId, Type.ROLE );
          aclBuilder.ace( parentTenantAdminSid, EnumSet.of( RepositoryFilePermission.ALL ) );
          parentTenantFolder = FilenameUtils.getFullPathNoEndSeparator( parentTenantFolder );
        }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.core.mt.Tenant

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.