Package org.pentaho.platform.plugin.action.olap

Examples of org.pentaho.platform.plugin.action.olap.IOlapServiceException


          SecurityHelper.getInstance().runAsSystem( call );
      } else {
        return call.call();
      }
    } catch ( Exception e ) {
      throw new IOlapServiceException( e );
    }
  }
View Full Code Here


        LOG.error(
          "Failed to initialize the connection cache",
          t );

        throw new IOlapServiceException( t );

      } finally {
        writeLock.unlock();
      }
    }
View Full Code Here

    IPentahoSession session ) {

    // Access
    if ( !hasAccess( name, EnumSet.of( RepositoryFilePermission.WRITE ), session ) ) {
      LOG.debug( "user does not have access; throwing exception" ); //$NON-NLS-1$
      throw new IOlapServiceException(
        Messages.getInstance().getErrorString(
          "OlapServiceImpl.ERROR_0003_INSUFFICIENT_PERMISSION" ), //$NON-NLS-1$
        IOlapServiceException.Reason.ACCESS_DENIED );
    }

    // check for existing vs. the overwrite flag.
    if ( getCatalogNames( session ).contains( name ) && !overwrite ) {
      throw new IOlapServiceException(
        Messages.getInstance().getErrorString(
          "OlapServiceImpl.ERROR_0004_ALREADY_EXISTS" ), //$NON-NLS-1$
        IOlapServiceException.Reason.ALREADY_EXISTS );
    }

    try {
      MondrianCatalogRepositoryHelper helper =
        new MondrianCatalogRepositoryHelper( getRepository() );
      helper.addHostedCatalog( inputStream, name, dataSourceInfo );
    } catch ( Exception e ) {
      throw new IOlapServiceException(
        e,
        IOlapServiceException.Reason.convert( e ) );
    }
  }
View Full Code Here

    IPentahoSession session ) {

    // Access
    if ( !hasAccess( name, EnumSet.of( RepositoryFilePermission.WRITE ), session ) ) {
      LOG.debug( "user does not have access; throwing exception" ); //$NON-NLS-1$
      throw new IOlapServiceException(
        Messages.getInstance().getErrorString(
          "OlapServiceImpl.ERROR_0003_INSUFFICIENT_PERMISSION" ), //$NON-NLS-1$
        IOlapServiceException.Reason.ACCESS_DENIED );
    }

    // check for existing vs. the overwrite flag.
    if ( getCatalogNames( session ).contains( name ) && !overwrite ) {
      throw new IOlapServiceException(
        Messages.getInstance().getErrorString(
          "OlapServiceImpl.ERROR_0004_ALREADY_EXISTS" ), //$NON-NLS-1$
        IOlapServiceException.Reason.ALREADY_EXISTS );
    }
View Full Code Here

  public void removeCatalog( String name, IPentahoSession session ) {

    // Check Access
    if ( !hasAccess( name, EnumSet.of( RepositoryFilePermission.DELETE ), session ) ) {
      LOG.debug( "user does not have access; throwing exception" ); //$NON-NLS-1$
      throw new IOlapServiceException(
        Messages.getInstance().getErrorString(
          "OlapServiceImpl.ERROR_0003_INSUFFICIENT_PERMISSION" ), //$NON-NLS-1$
        IOlapServiceException.Reason.ACCESS_DENIED );
    }

    if ( !getCatalogNames( session ).contains( name ) ) {
      throw new IOlapServiceException(
        Messages.getInstance().getErrorString(
          "MondrianCatalogHelper.ERROR_0015_CATALOG_NOT_FOUND",
          name ) );
    }
View Full Code Here

      // Start by flushing the local cache.
      resetCache( session );

      flushHostedAndRemote( session );
    } catch ( Exception e ) {
      throw new IOlapServiceException( e );
    } finally {
      writeLock.unlock();
    }
  }
View Full Code Here

          DATASOURCE_NAME,
          null,
          null,
          new Properties() );
      } catch ( Exception e ) {
        throw new IOlapServiceException( e );
      }
    }

    // Check Access
    if ( !hasAccess( catalogName, EnumSet.of( RepositoryFilePermission.READ ), session ) ) {
      LOG.debug( "user does not have access; throwing exception" ); //$NON-NLS-1$
      throw new IOlapServiceException(
        Messages.getInstance().getErrorString(
          "OlapServiceImpl.ERROR_0003_INSUFFICIENT_PERMISSION" ), //$NON-NLS-1$
        IOlapServiceException.Reason.ACCESS_DENIED );
    }

    // Check its existence.
    if ( !getCatalogNames( session ).contains( catalogName ) ) {
      throw new IOlapServiceException(
        Messages.getInstance().getErrorString(
          "MondrianCatalogHelper.ERROR_0015_CATALOG_NOT_FOUND",
          catalogName ) );
    }

    // Check if it is a remote server
    if ( getHelper().getOlap4jServers().contains( catalogName ) ) {
      return makeOlap4jConnection( catalogName );
    }

    final StringBuilder roleName = new StringBuilder();
    Entry roleMonikor = null;
    if ( this.role != null ) {
      // We must use a custom role implementation.
      // Register the instance with the mondrian server.
      roleMonikor = getServer().getLockBox().register( this.role );
      roleName.append( roleMonikor.getMoniker() );
    } else {
      final IConnectionUserRoleMapper mapper =
          PentahoSystem.get(
              IConnectionUserRoleMapper.class,
              MDXConnection.MDX_CONNECTION_MAPPER_KEY,
              null ); // Don't use the user session here yet.

      String[] effectiveRoles = new String[0];

      /*
       * If Catalog/Schema are null (this happens with high level metadata requests,
       * like DISCOVER_DATASOURCES) we can't use the role mapper, even if it
       * is present and configured.
       */
      if ( session != null
        && mapper != null ) {
        // Use the role mapper.
        try {
          effectiveRoles =
              mapper
              .mapConnectionRoles(
                  session,
                  catalogName );
          if ( effectiveRoles == null ) {
            effectiveRoles = new String[0];
          }
        } catch ( PentahoAccessControlException e ) {
          throw new IOlapServiceException( e );
        }
      }

      // Now we tokenize that list.
      boolean addComma = false;
      for ( String role : effectiveRoles ) {
        if ( addComma ) {
          roleName.append( "," ); //$NON-NLS-1$
        }
        roleName.append( role );
        addComma = true;
      }
    }

    // Populate some properties, like locale.
    final Properties properties = new Properties();
    properties.put(
      RolapConnectionProperties.Locale.name(),
      getLocale().toString() );

    // Return a connection
    try {
      return getServer().getConnection(
        DATASOURCE_NAME,
        catalogName,
        Util.isEmpty( roleName.toString() )
          ? null
          : roleName.toString(),
        properties );
    } catch ( Exception e ) {
      throw new IOlapServiceException( e );
    } finally {
      // Cleanup our lockbox entry.
      if ( roleMonikor != null ) {
        getServer().getLockBox().deregister( roleMonikor );
      }
View Full Code Here

    // Make sure the driver is present
    try {
      Class.forName( olapServerInfo.className );
    } catch ( ClassNotFoundException e ) {
      throw new IOlapServiceException( e );
    }

    // As per the JDBC specs, we can set the user/pass into
    // connection properties called 'user' and 'password'.
    final Properties newProps =
      new Properties( olapServerInfo.properties );

    // First, apply the filters.
    for ( IOlapConnectionFilter filter : this.filters ) {
      filter.filterProperties( newProps );
    }

    // Then override the user and password. We do this after the filters
    // so as not to expose this.
    if ( olapServerInfo.user != null ) {
      newProps.put(
        "user", olapServerInfo.user );
    }
    if ( olapServerInfo.password != null ) {
      newProps.put(
        "password", olapServerInfo.password );
    }

    try {
      final Connection conn =
        DriverManager.getConnection(
          olapServerInfo.URL, newProps );
      return conn.unwrap( OlapConnection.class );
    } catch ( SQLException e ) {
      throw new IOlapServiceException( e );
    }
  }
View Full Code Here

    try {
      return repository.hasAccess(
          path,
          perms );
    } catch ( Exception e ) {
      throw new IOlapServiceException( e );
    } finally {
      PentahoSessionHolder.setSession( origSession );
    }
  }
View Full Code Here

TOP

Related Classes of org.pentaho.platform.plugin.action.olap.IOlapServiceException

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.