Package org.pentaho.platform.repository2.unified.webservices

Examples of org.pentaho.platform.repository2.unified.webservices.StringKeyStringValueDto


   *
   * @param pathId
   * @return
   */
  public RepositoryFileDto doGetContentCreator( String pathId ) throws FileNotFoundException {
    RepositoryFileDto file = getRepoWs().getFile( idToPath( pathId ) );
    if ( file == null ) {
      throw new FileNotFoundException();
    }
    Map<String, Serializable> fileMetadata = getRepository().getFileMetadata( file.getId() );
    String creatorId = (String) fileMetadata.get( PentahoJcrConstants.PHO_CONTENTCREATOR );
    if ( creatorId != null && creatorId.length() > 0 ) {
      return getRepoWs().getFileById( creatorId );
    }

View Full Code Here


    } else {
      if ( !pathId.startsWith( FileUtils.PATH_SEPARATOR ) ) {
        path = idToPath( pathId );
      }
    }
    final RepositoryFileDto file = getRepoWs().getFile( path );
    if ( file == null ) {
      throw new FileNotFoundException();
    }

    list = getRepoWs().getFileMetadata( file.getId() );

    if ( list != null ) {
      boolean hasSchedulable = false;
      for ( StringKeyStringValueDto value : list ) {
        if ( value.getKey().equals( "_PERM_SCHEDULABLE" ) ) {
          hasSchedulable = true;
          break;
        }
      }
      if ( !hasSchedulable ) {
        StringKeyStringValueDto schedPerm = new StringKeyStringValueDto( "_PERM_SCHEDULABLE", "true" );
        list.add( schedPerm );
      }

      // check file object for hidden value and add it to the list
      list.add( new StringKeyStringValueDto( "_PERM_HIDDEN", String.valueOf( file.isHidden() ) ) );
    }

    return list;
  }
View Full Code Here

   * @param pathId
   * @param metadata
   * @throws GeneralSecurityException
   */
  public void doSetMetadata( String pathId, List<StringKeyStringValueDto> metadata ) throws GeneralSecurityException {
    RepositoryFileDto file = getRepoWs().getFile( idToPath( pathId ) );
    RepositoryFileAclDto fileAcl = getRepoWs().getAcl( file.getId() );

    boolean canManage =
      getSession().getName().equals( fileAcl.getOwner() )
        || ( getPolicy().isAllowed( RepositoryReadAction.NAME )
        && getPolicy().isAllowed( RepositoryCreateAction.NAME ) && getPolicy().isAllowed(
          AdministerSecurityAction.NAME ) );

    if ( !canManage ) {

      if ( fileAcl.isEntriesInheriting() ) {
        List<RepositoryFileAclAceDto> aces = getRepoWs().getEffectiveAces( file.getId() );
        fileAcl.setAces( aces, fileAcl.isEntriesInheriting() );
      }

      for ( int i = 0; i < fileAcl.getAces().size(); i++ ) {
        RepositoryFileAclAceDto acl = fileAcl.getAces().get( i );
        if ( acl.getRecipient().equals( getSession().getName() ) ) {
          if ( acl.getPermissions().contains( RepositoryFilePermission.ACL_MANAGEMENT.ordinal() )
            || acl.getPermissions().contains( RepositoryFilePermission.ALL.ordinal() ) ) {
            canManage = true;
            break;
          }
        }
      }
    }

    if ( canManage ) {
      Map<String, Serializable> fileMetadata = getRepository().getFileMetadata( file.getId() );
      boolean isHidden = false;

      for ( StringKeyStringValueDto nv : metadata ) {
        // don't add hidden to the list because it is not actually part of the metadata node
        if ( ( nv.getKey().contentEquals( "_PERM_HIDDEN" ) ) ) {
          isHidden = Boolean.parseBoolean( nv.getValue() );
        } else {
          fileMetadata.put( nv.getKey(), nv.getValue() );
        }
      }

      // now update the rest of the metadata
      if ( !file.isFolder() ) {
        getRepository().setFileMetadata( file.getId(), fileMetadata );
      }

      // handle hidden flag if it is different
      if ( file.isHidden() != isHidden ) {
        file.setHidden( isHidden );

          /*
           * Since we cannot simply set the new value, use the RepositoryFileAdapter to create a new instance and then
           * update the original.
           */
        RepositoryFile sourceFile = getRepository().getFileById( file.getId() );
        RepositoryFileDto destFileDto = toFileDto( sourceFile, null, false );

        destFileDto.setHidden( isHidden );

        RepositoryFile destFile = toFile( destFileDto );

        // add the existing acls and file data
        RepositoryFileAcl acl = getRepository().getAcl( sourceFile.getId() );
View Full Code Here

   *   &lt;/repositoryFileAclDto&gt;
   * </pre>
   * @throws FileNotFoundException
   */
  public void doSetContentCreator( String pathId, RepositoryFileDto contentCreator ) throws FileNotFoundException {
    RepositoryFileDto file = getRepoWs().getFile( idToPath( pathId ) );
    if ( file == null ) {
      throw new FileNotFoundException();
    }
    try {
      Map<String, Serializable> fileMetadata = getRepository().getFileMetadata( file.getId() );
      fileMetadata.put( PentahoJcrConstants.PHO_CONTENTCREATOR, contentCreator.getId() );
      getRepository().setFileMetadata( file.getId(), fileMetadata );
    } catch ( Exception e ) {
      throw new InternalError();
    }
  }
View Full Code Here

   *         </pre>
   * @throws FileNotFoundException
   */
  public List<LocaleMapDto> doGetFileLocales( String pathId ) throws FileNotFoundException {
    List<LocaleMapDto> availableLocales = new ArrayList<LocaleMapDto>();
    RepositoryFileDto file = getRepoWs().getFile( idToPath( pathId ) );
    if ( file == null ) {
      throw new FileNotFoundException();
    }
    try {
      List<PentahoLocale> locales = getRepoWs().getAvailableLocalesForFileById( file.getId() );
      if ( locales != null && !locales.isEmpty() ) {
        for ( PentahoLocale locale : locales ) {
          availableLocales.add( new LocaleMapDto( locale.toString(), null ) );
        }
      }
View Full Code Here

   *
   * @param pathId (colon separated path for the repository file)
   * @return <code> RepositoryFileAclDto </code>
   */
  public RepositoryFileAclDto doGetFileAcl( String pathId ) {
    RepositoryFileDto file = getRepoWs().getFile( FileUtils.idToPath( pathId ) );
    RepositoryFileAclDto fileAcl = getRepoWs().getAcl( file.getId() );
    if ( fileAcl.isEntriesInheriting() ) {
      List<RepositoryFileAclAceDto> aces =
        getRepoWs().getEffectiveAcesWithForceFlag( file.getId(), fileAcl.isEntriesInheriting() );
      fileAcl.setAces( aces, fileAcl.isEntriesInheriting() );
    }
    addAdminRole( fileAcl );
    return fileAcl;
  }
View Full Code Here

      collator.setStrength( Collator.PRIMARY ); // ignore case
      sortByLocaleTitle( collator, tree );
    }

    for ( RepositoryFileTreeDto child : tree.getChildren() ) {
      RepositoryFileDto file = child.getFile();
      Map<String, Serializable> fileMeta = getRepository().getFileMetadata( file.getId() );
      boolean isSystemFolder =
        fileMeta.containsKey( IUnifiedRepository.SYSTEM_FOLDER ) ? (Boolean) fileMeta
          .get( IUnifiedRepository.SYSTEM_FOLDER ) : false;
      if ( !isSystemFolder ) {
        filteredChildren.add( child );
View Full Code Here

   * @throws FileNotFoundException
   * @private
   */
  private List<RepositoryFileDto> doGetGeneratedContentForUser( String pathId, String userDir )
    throws FileNotFoundException {
    RepositoryFileDto targetFile = doGetProperties( pathId );
    if ( targetFile != null ) {
      String targetFileId = targetFile.getId();
      return searchGeneratedContent( userDir, targetFileId, PentahoJcrConstants.PHO_CONTENTCREATOR );
    } else {
      logger.error( Messages.getInstance().getString( "FileResource.FILE_NOT_FOUND", pathId ) );
      throw new FileNotFoundException( pathId );
    }
View Full Code Here

   * @return            A jax-rs Response object with the appropriate status code, header, and body.
   */
  public boolean doCreateDir( String pathId ) {
    String path = idToPath( pathId );
    String[] folders = path.split( "[" + FileUtils.PATH_SEPARATOR + "]" ); //$NON-NLS-1$//$NON-NLS-2$
    RepositoryFileDto parentDir = getRepoWs().getFile( FileUtils.PATH_SEPARATOR );
    boolean dirCreated = false;
    for ( String folder : folders ) {
      String currentFolderPath = ( parentDir.getPath() + FileUtils.PATH_SEPARATOR + folder ).substring( 1 );
      if ( !currentFolderPath.startsWith( FileUtils.PATH_SEPARATOR ) ) {
        currentFolderPath = FileUtils.PATH_SEPARATOR + currentFolderPath;
      }
      RepositoryFileDto currentFolder = getRepoWs().getFile( currentFolderPath );
      if ( currentFolder == null ) {
        currentFolder = new RepositoryFileDto();
        currentFolder.setFolder( true );
        currentFolder.setName( decode( folder ) );
        currentFolder.setPath( parentDir.getPath() + FileUtils.PATH_SEPARATOR + folder );
        currentFolder = getRepoWs().createFolder( parentDir.getId(), currentFolder, currentFolderPath );
        dirCreated = true;
      }
      parentDir = currentFolder;
    }
View Full Code Here

  public List<RepositoryFileDto> doGetChildren( String pathId, String filter, Boolean showHidden,
                                                Boolean includeAcls ) {

    List<RepositoryFileDto> repositoryFileDtoList = new ArrayList<RepositoryFileDto>();
    RepositoryFileDto repositoryFileDto = getRepoWs().getFile( FileUtils.idToPath( pathId ) );

    if ( repositoryFileDto != null && isPathValid( repositoryFileDto.getPath() ) ) {
      RepositoryRequest repositoryRequest = getRepositoryRequest( repositoryFileDto, showHidden, filter, includeAcls );
      repositoryFileDtoList = getRepoWs().getChildrenFromRequest( repositoryRequest );

      // BISERVER-9599 - Use special sort order
      if ( isShowingTitle( repositoryRequest ) ) {
View Full Code Here

TOP

Related Classes of org.pentaho.platform.repository2.unified.webservices.StringKeyStringValueDto

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.