Package org.pentaho.platform.api.repository2.unified.data.simple

Examples of org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData


     */

    String etcMondrian =
      ClientRepositoryPaths.getEtcFolderPath() + RepositoryFile.SEPARATOR + MONDRIAN_DATASOURCE_FOLDER;

    RepositoryFile etcMondrianFolder = unifiedRepository.getFile( etcMondrian );
    if ( etcMondrianFolder != null ) {
      List<RepositoryFile> mondrianCatalogs = unifiedRepository.getChildren( etcMondrianFolder.getId() );

      for ( RepositoryFile catalog : mondrianCatalogs ) {

        String catalogName = catalog.getName();
        RepositoryFile metadata =
          unifiedRepository.getFile( etcMondrian + RepositoryFile.SEPARATOR + catalogName + RepositoryFile.SEPARATOR
            + "metadata" ); //$NON-NLS-1$

        if ( metadata != null ) {
          DataNode metadataNode =
            unifiedRepository.getDataForRead( metadata.getId(), NodeRepositoryFileData.class ).getNode();
          String datasourceInfo = metadataNode.getProperty( "datasourceInfo" ).getString(); //$NON-NLS-1$
          String definition = metadataNode.getProperty( "definition" ).getString(); //$NON-NLS-1$

          datasourcesXML.append( "<Catalog name=\"" + encoder.encodeForXML( catalogName ) + "\">\n" ); //$NON-NLS-1$ //$NON-NLS-2$
          datasourcesXML
View Full Code Here


      throw new MondrianCatalogServiceException( Messages.getInstance().getErrorString(
        "MondrianCatalogHelper.ERROR_0003_INSUFFICIENT_PERMISSION" ), Reason.ACCESS_DENIED ); //$NON-NLS-1$
    }

    IUnifiedRepository solutionRepository = PentahoSystem.get( IUnifiedRepository.class );
    RepositoryFile deletingFile = solutionRepository.getFile( RepositoryFile.SEPARATOR + "etc" //$NON-NLS-1$
      + RepositoryFile.SEPARATOR + "mondrian" + RepositoryFile.SEPARATOR + catalog.getName() ); //$NON-NLS-1$
    solutionRepository.deleteFile( deletingFile.getId(), true, "" ); //$NON-NLS-1$
    reInit( pentahoSession );
  }
View Full Code Here

      }
      if ( file != null ) {
        return file.lastModified();
      }
    } else {
      RepositoryFile repositoryFile = null;
      if ( locale == null ) {
        repositoryFile = getRepository().getFile( filePath );
      } else {
        String extension = FilenameUtils.getExtension( filePath );
        String baseName = FilenameUtils.removeExtension( filePath );
        if ( extension.length() > 0 ) {
          extension = "." + extension; //$NON-NLS-1$
        }
        String language = locale.getLanguage();
        String country = locale.getCountry();
        String variant = locale.getVariant();
        if ( !variant.equals( "" ) ) { //$NON-NLS-1$
          repositoryFile =
              getRepository().getFile( baseName + "_" + language + "_" + country + "_" + variant + extension ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        }
        if ( repositoryFile == null ) {
          repositoryFile = getRepository().getFile( baseName + "_" + language + "_" + country + extension ); //$NON-NLS-1$//$NON-NLS-2$
        }
        if ( repositoryFile == null ) {
          repositoryFile = getRepository().getFile( baseName + "_" + language + extension ); //$NON-NLS-1$
        }
        if ( repositoryFile == null ) {
          repositoryFile = getRepository().getFile( filePath );
        }
      }
      if ( repositoryFile != null ) {
        return repositoryFile.getLastModifiedDate().getTime();
      }
    }
    return -1L;
  }
View Full Code Here

      }
    } else {
      // This is not a file from the system folder. User is trying to access a resource in the repository.
      // Get the RepositoryContentConverterHandler
      IRepositoryContentConverterHandler converterHandler = PentahoSystem.get( IRepositoryContentConverterHandler.class);
      RepositoryFile repositoryFile = null;
      if ( locale == null ) {
        repositoryFile = getRepository().getFile( filePath );
        String extension = FilenameUtils.getExtension( filePath );
        try {
          // Try to get the converter for the extension. If there is not converter available then we will
          //assume simple type and will get the data that way
          if(converterHandler != null) {
            Converter converter = converterHandler.getConverter( extension );
            if(converter != null) {
              inputStream = converter.convert( repositoryFile.getId() );
            }
          }
          if(inputStream == null) {
            inputStream =
              getRepository().getDataForRead( repositoryFile.getId(), SimpleRepositoryFileData.class ).getStream();
          }
        } catch ( UnifiedRepositoryException ure ) {
          //ignored
        }
      } else {
        String extension = FilenameUtils.getExtension( filePath );
        String baseName = FilenameUtils.removeExtension( filePath );
        if ( extension.length() > 0 ) {
          extension = "." + extension; //$NON-NLS-1$
        }
        String language = locale.getLanguage();
        String country = locale.getCountry();
        String variant = locale.getVariant();
        if ( !variant.equals( "" ) ) { //$NON-NLS-1$
          repositoryFile =
              getRepository().getFile( baseName + "_" + language + "_" + country + "_" + variant + extension ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
          try {
            if ( repositoryFile != null ) {
              // Try to get the converter for the extension. If there is not converter available then we will
              //assume simple type and will get the data that way
              if(converterHandler != null) {
                Converter converter = converterHandler.getConverter( FilenameUtils.getExtension( filePath ) );
                if(converter != null) {
                  inputStream = converter.convert( repositoryFile.getId() );
                }
              }
              if(inputStream == null) {
                inputStream =
                  getRepository().getDataForRead( repositoryFile.getId(), SimpleRepositoryFileData.class ).getStream();
              }
            }
          } catch ( UnifiedRepositoryException ure ) {
            //ignored
          }
        }
        if ( inputStream == null ) {
          repositoryFile = getRepository().getFile( baseName + "_" + language + "_" + country + extension ); //$NON-NLS-1$//$NON-NLS-2$
          try {
            if ( repositoryFile != null ) {
              // Try to get the converter for the extension. If there is not converter available then we will
              //assume simple type and will get the data that way
              if(converterHandler != null) {
                Converter converter = converterHandler.getConverter( FilenameUtils.getExtension( filePath ) );
                if(converter != null) {
                  inputStream = converter.convert( repositoryFile.getId() );
                }
              }
              if(inputStream == null) {
                inputStream =
                  getRepository().getDataForRead( repositoryFile.getId(), SimpleRepositoryFileData.class ).getStream();
              }             }
          } catch ( UnifiedRepositoryException ure ) {
            //ignored
          }
        }
        if ( inputStream == null ) {
          repositoryFile = getRepository().getFile( baseName + "_" + language + extension ); //$NON-NLS-1$
          try {
            if ( repositoryFile != null ) {
              // Try to get the converter for the extension. If there is not converter available then we will
              //assume simple type and will get the data that way
              if(converterHandler != null) {
                Converter converter = converterHandler.getConverter( FilenameUtils.getExtension( filePath ) );
                if(converter != null) {
                  inputStream = converter.convert( repositoryFile.getId() );
                }
              }
              if(inputStream == null) {
                inputStream =
                  getRepository().getDataForRead( repositoryFile.getId(), SimpleRepositoryFileData.class ).getStream();
              }
            }
          } catch ( UnifiedRepositoryException ure ) {
            //ignored
          }
        }
        if ( inputStream == null ) {
          repositoryFile = getRepository().getFile( filePath );
          try {
            if ( repositoryFile != null ) {
              // Try to get the converter for the extension. If there is not converter available then we will
              //assume simple type and will get the data that way
              if(converterHandler != null) {
                Converter converter = converterHandler.getConverter( FilenameUtils.getExtension( filePath ) );
                if(converter != null) {
                  inputStream = converter.convert( repositoryFile.getId() );
                }
              }
              if(inputStream == null) {
                inputStream =
                  getRepository().getDataForRead( repositoryFile.getId(), SimpleRepositoryFileData.class ).getStream();
              }
            }
          } catch ( UnifiedRepositoryException ure ) {
            //ignored
          }
View Full Code Here

    return actionSequence;
  }

  public Document getSolutionDocument( final String documentPath, final RepositoryFilePermission actionOperation ) {

    RepositoryFile file = repository.getFile( documentPath );

    Document document = null;
    SimpleRepositoryFileData data = null;
    if ( file != null ) {
      data = repository.getDataForRead( file.getId(), SimpleRepositoryFileData.class );
      if ( data != null ) {
        try {
          document = XmlDom4JHelper.getDocFromStream( data.getStream() );
        } catch ( Throwable t ) {
          logger.error( Messages.getInstance().getErrorString(
              "ActionSequenceJCRHelper.ERROR_0017_INVALID_XML_DOCUMENT", documentPath ), t ); //$NON-NLS-1$
          return null;
        }
      } else {
        logger.error( Messages.getInstance().getErrorString(
            "ActionSequenceJCRHelper.ERROR_0019_NO_DATA_IN_FILE", file.getName() ) ); //$NON-NLS-1$
        return null;
      }
      if ( ( document == null ) && ( file != null ) && ( data != null ) ) {
        // the document exists but cannot be parsed
        logger.error( Messages.getInstance().getErrorString(
View Full Code Here

    return document;
  }

  public String getURL( String filePath ) {
    RepositoryFile file = repository.getFile( filePath );
    if ( file == null || !file.getName().endsWith( ".url" ) ) { //$NON-NLS-1$
      return ""; //$NON-NLS-1$
    }
    SimpleRepositoryFileData data = null;

    data = repository.getDataForRead( file.getId(), SimpleRepositoryFileData.class );
    StringWriter writer = new StringWriter();
    try {
      IOUtils.copy( data.getStream(), writer );
    } catch ( IOException e ) {
      return ""; //$NON-NLS-1$
View Full Code Here

  protected String getLocaleString( final String key, String baseName, final RepositoryFile baseFile,
      boolean marchUpParents ) {

    String parentPath = FilenameUtils.getFullPathNoEndSeparator( baseFile.getPath() );

    RepositoryFile searchDir = repository.getFile( parentPath );
    if ( baseFile.isFolder() ) {
      searchDir = baseFile;
    }
    try {
      boolean searching = true;
      while ( searching ) {

        RepositoryFile[] propertyFiles = listFiles( searchDir, new IFileFilter() {
          public boolean accept( RepositoryFile file ) {
            return file.getName().toLowerCase().endsWith( PROPERTIES_SUFFIX );
          }
        } );
        RepositoryFile blcv = null;
        RepositoryFile blc = null;
        RepositoryFile bl = null;
        RepositoryFile b = null;
        for ( RepositoryFile element : propertyFiles ) {
          if ( element.getName().equalsIgnoreCase(
              baseName + '_' + getLocale().getLanguage() + '_' + getLocale().getCountry() + '_'
                  + getLocale().getVariant() + PROPERTIES_SUFFIX ) ) {
            blcv = element;
View Full Code Here

              sourcePath =
              sourceFile.getPath().substring( 0, sourceFile.getPath().lastIndexOf( FileUtils.PATH_SEPARATOR ) );
          if ( !sourcePath.equals( destDir.getPath() ) ) { // We're saving to a different folder than we're copying
            // from
            IRepositoryFileData data = getData( sourceFile );
            RepositoryFileAcl acl = getRepository().getAcl( sourceFileId );
            RepositoryFile
                destFile =
                getRepository().getFile( destDir.getPath() + FileUtils.PATH_SEPARATOR + fileName );
            if ( destFile == null ) { // destFile doesn't exist so we'll create it.
              RepositoryFile duplicateFile =
                  new RepositoryFile.Builder( fileName ).hidden( sourceFile.isHidden() ).versioned(
                      sourceFile.isVersioned() ).build();
              final RepositoryFile repositoryFile =
                  getRepository().createFile( destDir.getId(), duplicateFile, data, acl, null );
              getRepository()
                  .setFileMetadata( repositoryFile.getId(), getRepository().getFileMetadata( sourceFileId ) );
            } else if ( mode == MODE_OVERWRITE ) { // destFile exists so check to see if we want to overwrite it.
              RepositoryFileDto destFileDto = toFileDto( destFile, null, false );
              destFileDto.setHidden( sourceFile.isHidden() );
              destFile = toFile( destFileDto );
              final RepositoryFile repositoryFile = getRepository().updateFile( destFile, data, null );
              getRepository().updateAcl( acl );
              getRepository()
                  .setFileMetadata( repositoryFile.getId(), getRepository().getFileMetadata( sourceFileId ) );
            }
          }
        }
      }
    } else {
      for ( String sourceFileId : sourceFileIds ) {
        RepositoryFile sourceFile = getRepository().getFileById( sourceFileId );
        if ( destDir != null && destDir.isFolder() && sourceFile != null && !sourceFile.isFolder() ) {

          // First try to see if regular name is available
          String fileName = sourceFile.getName();
          String copyText = "";
          String rootCopyText = "";
          String nameNoExtension = fileName;
          String extension = "";
          int indexOfDot = fileName.lastIndexOf( '.' );
          if ( !( indexOfDot == -1 ) ) {
            nameNoExtension = fileName.substring( 0, indexOfDot );
            extension = fileName.substring( indexOfDot );
          }

          RepositoryFileDto
              testFile =
              getRepoWs().getFile( path + FileUtils.PATH_SEPARATOR + nameNoExtension + extension ); //$NON-NLS-1$
          if ( testFile != null ) {
            // Second try COPY_PREFIX, If the name already ends with a COPY_PREFIX don't append twice
            if ( !nameNoExtension
                .endsWith( Messages.getInstance().getString( "FileResource.COPY_PREFIX" ) ) ) { //$NON-NLS-1$
              copyText = rootCopyText = Messages.getInstance().getString( "FileResource.COPY_PREFIX" );
              fileName = nameNoExtension + copyText + extension;
              testFile = getRepoWs().getFile( path + FileUtils.PATH_SEPARATOR + fileName );
            }
          }

          // Third try COPY_PREFIX + DUPLICATE_INDICATOR
          Integer nameCount = 1;
          while ( testFile != null ) {
            nameCount++;
            copyText =
                rootCopyText + Messages.getInstance().getString( "FileResource.DUPLICATE_INDICATOR", nameCount );
            fileName = nameNoExtension + copyText + extension;
            testFile = getRepoWs().getFile( path + FileUtils.PATH_SEPARATOR + fileName );
          }
          IRepositoryFileData data = getData( sourceFile );
          RepositoryFileAcl acl = getRepository().getAcl( sourceFileId );
          RepositoryFile duplicateFile = null;

          // If the title is different than the source file, copy it separately
          if ( !sourceFile.getName().equals( sourceFile.getTitle() ) ) {
            duplicateFile =
View Full Code Here

        destFileDto.setHidden( isHidden );

        RepositoryFile destFile = toFile( destFileDto );

        // add the existing acls and file data
        RepositoryFileAcl acl = getRepository().getAcl( sourceFile.getId() );
        if ( !file.isFolder() ) {
          IRepositoryFileData data = getData( sourceFile );

          getRepository().updateFile( destFile, data, null );
          getRepository().updateAcl( acl );
View Full Code Here

      path = FileUtils.PATH_SEPARATOR;
    } else if ( !pathId.startsWith( FileUtils.PATH_SEPARATOR ) ) {
      path = idToPath( pathId );
    }

    RepositoryRequest repositoryRequest = getRepositoryRequest( path, showHidden, depth, filter );
    repositoryRequest.setIncludeAcls( includeAcls );

    RepositoryFileTreeDto tree = getRepoWs().getTreeFromRequest( repositoryRequest );
    List<RepositoryFileTreeDto> filteredChildren = new ArrayList<RepositoryFileTreeDto>();

    // BISERVER-9599 - Use special sort order
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.repository2.unified.data.simple.SimpleRepositoryFileData

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.