Examples of IUserContentAccess


Examples of pt.webdetails.cpf.repository.api.IUserContentAccess

    try {
//      if (path != null && (path.startsWith("/") || path.startsWith("."))) {
//        throw new IllegalArgumentException("Path cannot be null or start with \"/\" or \".\" - Illegal Path: " + path);
//      }
     
      IUserContentAccess access = contentAccessFactory.getUserContentAccess("/");
      String root = (StringUtils.isBlank(path)) ? "/" : path;
      return getRepositoryObjects(access, root, type, hidden);
    } catch (Exception e) {
      log.error(this.getClass().getName(),e);
      e.printStackTrace();
View Full Code Here

Examples of pt.webdetails.cpf.repository.api.IUserContentAccess

      }
            file = file.replaceAll(":", "/");

      log.debug("Get repository file: " + file);

      IUserContentAccess access = contentAccessFactory.getUserContentAccess(null);

      if( !access.fileExists(file) && access.hasAccess(file, FileAccess.READ)) {
        log.error("Access to Repository has failed File does not exist: " + file);
        throw new NullPointerException("Access to Repository has failed");
      }
      IBasicFile bf = access.fetchFile(file);

      String doc = IOUtils.toString(bf.getContents());
      if (doc == null) {
        throw new SaikuServiceException("Error retrieving saiku document from solution repository: " + file);
      }
View Full Code Here

Examples of pt.webdetails.cpf.repository.api.IUserContentAccess

        throw new IllegalArgumentException("Cannot save empty file to: " + file);

      }
      log.debug("Save repository file: " + file);

      IUserContentAccess access = contentAccessFactory.getUserContentAccess(null);

      boolean ok = access.saveFile(file, IOUtils.toInputStream(content));
      if (!ok) {
        throw new SaikuServiceException("Failed to write file: " + file);
      }
      return Response.ok().build();
    }
View Full Code Here

Examples of pt.webdetails.cpf.repository.api.IUserContentAccess

        throw new IllegalArgumentException("Path cannot be null  - Illegal Path: " + file);
      }

      log.debug("Delete repository file: " + file);

      IUserContentAccess access = contentAccessFactory.getUserContentAccess(null);

      if( !access.fileExists(file) && access.hasAccess(file, FileAccess.DELETE)) {
        throw new SaikuServiceException("Access to Repository has failed File does not exist or no delete right: " + file);
      }
      boolean ok = access.deleteFile(file);
      if (!ok) {
        throw new SaikuServiceException("Failed to write file: " + file);
      }
      return Response.ok().build();
    }
View Full Code Here

Examples of pt.webdetails.cpf.repository.api.IUserContentAccess

    try {
      if (StringUtils.isBlank(directory))
        return Response.ok().build();

      final String fileType = type;
      IUserContentAccess access = contentAccessFactory.getUserContentAccess(null);
     
      if( !access.fileExists(directory) && access.hasAccess(directory, FileAccess.READ)) {
        throw new SaikuServiceException("Access to Repository has failed File does not exist or no read right: " + directory);
      }
     
      IBasicFileFilter txtFilter = StringUtils.isBlank(type) ? null : new IBasicFileFilter() {
        public boolean accept(IBasicFile file) {
          return file.isDirectory() || file.getExtension().equals(fileType);
        }
      };
     
      ByteArrayOutputStream bos = new ByteArrayOutputStream();
      ZipOutputStream zos = new ZipOutputStream(bos);

      List<IBasicFile> basicFiles = access.listFiles(directory, txtFilter);
     
      for (IBasicFile basicFile : basicFiles) {
        if (!basicFile.isDirectory()) {
          String entry = basicFile.getName();
          byte[] doc = IOUtils.toByteArray(basicFile.getContents());
View Full Code Here

Examples of pt.webdetails.cpf.repository.api.IUserContentAccess

      public boolean accept(IBasicFile file) {
        return file.isDirectory() || file.getExtension().equals(type);
      }
    };
    List<IBasicFile> files = new ArrayList<IBasicFile>();
    IUserContentAccess access = contentAccessFactory.getUserContentAccess(null);
        path = path.replace(":", "/");
    if (access.fileExists(path)) {
      IBasicFile bf = access.fetchFile(path);
      if (!bf.isDirectory()) {
        files.add(bf);
        log.debug("Found file in " + path);
      } else {
        files = root.listFiles(path, txtFilter, 0, true, hidden);
View Full Code Here

Examples of pt.webdetails.cpf.repository.api.IUserContentAccess

 
  private List<AclMethod> getAcl(String file, boolean folder) {
    List<AclMethod> acls = new ArrayList<AclMethod>();
      IAuthorizationPolicy policy = PentahoSystem.get( IAuthorizationPolicy.class );
    boolean isAdmin = policy.isAllowed( AdministerSecurityAction.NAME );
    IUserContentAccess access = contentAccessFactory.getUserContentAccess(null);
    if (access.fileExists(file)) {
      acls.add(AclMethod.READ);
      if (isAdmin || access.hasAccess(file, FileAccess.WRITE)) {
        acls.add(AclMethod.WRITE);
      }
      if (isAdmin) {
        acls.add(AclMethod.GRANT);
      }
View Full Code Here

Examples of pt.webdetails.cpf.repository.api.IUserContentAccess

    if ( allowedFormats.indexOf( extension ) < 0 ) {
      // We can't provide this type of file
      throw new SecurityException( "Not allowed" );
    }

    IUserContentAccess contentAccess = CdfEngine.getUserContentReader( null );
    IReadAccess systemAccess = CdfEngine.getPluginSystemReader( null );

    if ( contentAccess.fileExists( resourcePath ) && contentAccess.hasAccess( resourcePath, FileAccess.EXECUTE ) ) {
      PluginIOUtils.writeOutAndFlush( out, contentAccess.getFileInputStream( resourcePath ) );
    } else if ( systemAccess.fileExists( resourcePath ) ) {
      PluginIOUtils.writeOutAndFlush( out, systemAccess.getFileInputStream( resourcePath ) );
    } else {
      logger.info( " resource not found: " + resourcePath );
    }
View Full Code Here

Examples of pt.webdetails.cpf.repository.api.IUserContentAccess

  public boolean determineDashboardTemplating( final String dashboard, String defaultTemplate )
    throws InvalidCdfOperationException {

    boolean success = false;

    IUserContentAccess access = CdfEngine.getUserContentReader( null );

    if ( access.fileExists( dashboard ) ) {

      // Check for access permissions
      if ( !access.hasAccess( dashboard, FileAccess.EXECUTE ) ) {
        throw new InvalidCdfOperationException( "Access denied" );
      }

      try {

        Document doc = XmlDom4JUtils.getDocumentFromFile( access.fetchFile( dashboard ) );

        if ( doc.selectSingleNode( NODE_TEMPLATE ) != null ) {
          template = XmlDom4JUtils.getNodeText( NODE_TEMPLATE, doc, "" );
        }else{
          template = defaultTemplate;
View Full Code Here

Examples of pt.webdetails.cpf.repository.api.IUserContentAccess

  public static IBasicFile getDashboardTemplate( String templatePath ) {

    templatePath = FilenameUtils.separatorsToUnix( templatePath );

    IUserContentAccess repoAccess = CdfEngine.getUserContentReader( null );
    IReadAccess systemAccess = CdfEngine.getPluginSystemReader( null );
    IBasicFile dashboardTemplateFile = null;

    if ( !StringUtils.isEmpty( templatePath ) && repoAccess.fileExists( templatePath ) ) {

      // Check for access permissions
      if ( repoAccess.hasAccess( templatePath, FileAccess.EXECUTE ) ) {
        dashboardTemplateFile = repoAccess.fetchFile( templatePath );
      } else {
        logger.error( "Access Denied to " + templatePath );
      }
    } else {
      dashboardTemplateFile = systemAccess.fetchFile( CdfConstants.DEFAULT_DASHBOARD_TEMPLATE_HTML );
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.