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

Examples of org.pentaho.platform.api.repository2.unified.RepositoryFileSid


    this.inputFilePath = filePath;
  }

  public InputStream getInputStream() throws Exception {
    IUnifiedRepository repository = PentahoSystem.get( IUnifiedRepository.class );
    RepositoryFile repositoryFile = repository.getFile( inputFilePath );
    if ( ( repositoryFile == null ) || repositoryFile.isFolder() ) {
      throw new FileNotFoundException();
    }
    return new RepositoryFileInputStream( repositoryFile );
  }
View Full Code Here


  @Override
  public void createContent( OutputStream out ) throws Exception {
    IParameterProvider pathParams = parameterProviders.get( "path" ); //$NON-NLS-1$
    IParameterProvider requestParams = parameterProviders.get( IParameterProvider.SCOPE_REQUEST );

    RepositoryFile file = (RepositoryFile) pathParams.getParameter( "file" ); //$NON-NLS-1$

    ActionHarness harness = new ActionHarness( this );

    Iterator<?> iter = requestParams.getParameterNames();
View Full Code Here

        .decode( pathParams.getStringParameter( "path", "" ), "UTF-8" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }

    if ( path != null && path.length() > 0 ) {
      IUnifiedRepository unifiedRepository = PentahoSystem.get( IUnifiedRepository.class, null );
      RepositoryFile file = unifiedRepository.getFile( path );
      HttpServletRequest httpRequest = (HttpServletRequest) pathParams.getParameter( "httprequest" ); //$NON-NLS-1$
      HttpServletResponse httpResponse = (HttpServletResponse) pathParams.getParameter( "httpresponse" ); //$NON-NLS-1$
      String buffer =
        XactionUtil.executeScheduleUi( file, httpRequest, httpResponse, PentahoSessionHolder.getSession(),
          outputHandler.getMimeTypeListener() );
View Full Code Here

      contentType = pathParams.getStringParameter( "contentType", TEXT_HTML ); //$NON-NLS-1$
    }

    if ( path != null && path.length() > 0 ) {
      IUnifiedRepository unifiedRepository = PentahoSystem.get( IUnifiedRepository.class, null );
      RepositoryFile file = unifiedRepository.getFile( path );

      HttpServletRequest httpRequest = (HttpServletRequest) pathParams.getParameter( "httprequest" ); //$NON-NLS-1$

      HttpServletResponse httpResponse = (HttpServletResponse) pathParams.getParameter( "httpresponse" ); //$NON-NLS-1$
View Full Code Here

        .decode( pathParams.getStringParameter( "path", "" ), "UTF-8" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }

    if ( path != null && path.length() > 0 ) {
      IUnifiedRepository unifiedRepository = PentahoSystem.get( IUnifiedRepository.class, null );
      RepositoryFile file = unifiedRepository.getFile( path );
      String buffer = XactionUtil.doParameter( file, requestParams, PentahoSessionHolder.getSession() );
      outputStream.write( buffer.toString().getBytes( LocaleHelper.getSystemEncoding() ) );
    }
  }
View Full Code Here

  public GeneratedContentCleaner() {
    repository = PentahoSystem.get( IUnifiedRepository.class );
  }

  private void findGeneratedContent( List<RepositoryFile> generatedContentList, RepositoryFileTree parent ) {
    RepositoryFile parentFile = parent.getFile();
    if ( !parentFile.isFolder() ) {
      long createTime = parentFile.getCreatedDate().getTime();
      if ( createTime <= ( System.currentTimeMillis() - ( age * 1000 ) ) ) {
        // now check metadata for RESERVEDMAPKEY_LINEAGE_ID (all generated content has)
        Map<String, Serializable> metadata = repository.getFileMetadata( parentFile.getId() );
        if ( metadata.containsKey( QuartzScheduler.RESERVEDMAPKEY_LINEAGE_ID ) ) {
          generatedContentList.add( parentFile );
        }
      }
    } else {
View Full Code Here

    repository = new MockUnifiedRepository( new MockUserProvider() );
    repositoryWS = new DefaultUnifiedRepositoryWebService( repository );
  }

  public void testFileMetadata() throws Exception {
    final RepositoryFile testfile =
        repository.createFile( repository.getFile( "/etc" ).getId(), new RepositoryFile.Builder( "testfile" ).build(),
            new SimpleRepositoryFileData( new ByteArrayInputStream( "test".getBytes() ),
              "UTF-8", "text/plain" ), null );
    //CHECKSTYLE IGNORE AvoidNestedBlocks FOR NEXT 3 LINES
    {
      // Make sure the repository is setup correctly
      assertNotNull( testfile );
      assertNotNull( testfile.getId() );
      final Map<String, Serializable> fileMetadata = repository.getFileMetadata( testfile.getId() );
      assertNotNull( fileMetadata );
      assertEquals( 0, fileMetadata.size() );
    }

    final List<StringKeyStringValueDto> metadata = new ArrayList<StringKeyStringValueDto>();
    metadata.add( new StringKeyStringValueDto( "sample key", "sample value" ) );
    metadata.add( new StringKeyStringValueDto( "complex key?", "\"an even more 'complex' value\"! {and them some}" ) );

    repositoryWS.setFileMetadata( testfile.getId().toString(), metadata );
    //CHECKSTYLE IGNORE AvoidNestedBlocks FOR NEXT 3 LINES
    {
      // Make sure the repository sees the metadata
      assertNotNull( testfile );
      assertNotNull( testfile.getId() );
      final Map<String, Serializable> fileMetadata = repository.getFileMetadata( testfile.getId() );
      assertNotNull( fileMetadata );
      assertEquals( 2, fileMetadata.size() );
    }
    //CHECKSTYLE IGNORE AvoidNestedBlocks FOR NEXT 3 LINES
    {
      // Make sure we can get the same metadata back via the web service
      final List<StringKeyStringValueDto> fileMetadata = repositoryWS.getFileMetadata( testfile.getId().toString() );
      assertNotNull( fileMetadata );
      assertEquals( 2, fileMetadata.size() );
      assertTrue( metadata.get( 0 ).equals( fileMetadata.get( 0 ) ) || metadata.get( 0 )
        .equals( fileMetadata.get( 1 ) ) );
      assertTrue( metadata.get( 1 ).equals( fileMetadata.get( 0 ) ) || metadata.get( 1 )
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

    login( USERNAME_ADMIN, tenantAcme, new String[] { tenantAdminRoleName, tenantAuthenticatedRoleName } );
    userRoleDao.createUser( tenantAcme, USERNAME_SUZY, PASSWORD, "", null );

    login( USERNAME_SUZY, tenantAcme, new String[] { tenantAuthenticatedRoleName } );

    final RepositoryFileSid suzySid = new RepositoryFileSid( USERNAME_SUZY, RepositoryFileSid.Type.USER );
    final RepositoryFileSid acmeAuthenticatedAuthoritySid =
        new RepositoryFileSid( tenantAuthenticatedRoleName, RepositoryFileSid.Type.ROLE );
    final RepositoryFileSid sysAdminSid = new RepositoryFileSid( sysAdminUserName, RepositoryFileSid.Type.USER );
    final RepositoryFileSid tenantAdminSid = new RepositoryFileSid( USERNAME_ADMIN, RepositoryFileSid.Type.USER );
    final RepositoryFileSid tenantCreatorSid = new RepositoryFileSid( sysAdminUserName, RepositoryFileSid.Type.USER );

    RepositoryFile file = tenantManager.getTenantRootFolder( tenantAcme );
    String tenantRootFolderAbsPath = pathConversionHelper.relToAbs( file.getPath() );
    // pentaho root folder
    assertTrue( SimpleJcrTestUtils.hasPrivileges( testJcrTemplate, tenantRootFolderAbsPath, Privilege.JCR_READ ) );
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.repository2.unified.RepositoryFileSid

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.