Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.guvnor.structure.backend;
  
  import java.util.Date;
  import java.util.List;
  import javax.inject.Named;
 
 import  org.guvnor.structure.repositories.Repository;
 import  org.guvnor.structure.repositories.RepositoryService;
 import  org.ocpsoft.prettytime.PrettyTime;
 import  org.uberfire.backend.server.util.Paths;
 import  org.uberfire.io.IOService;
 import  org.uberfire.java.nio.base.version.VersionAttributeView;
 import  org.uberfire.java.nio.file.DirectoryStream;
 import  org.uberfire.java.nio.file.Files;
 import  org.uberfire.java.nio.file.Path;
 import  org.guvnor.structure.navigator.DataContent;
 import  org.guvnor.structure.navigator.FileNavigatorService;
 import  org.guvnor.structure.navigator.NavigatorContent;
 
 import static java.util.Collections.*;
 
 public class FileNavigatorServiceImpl implements FileNavigatorService {
 
     @Inject
     @Named("ioStrategy")
     private IOService ioService;
 
     @Inject
     private RepositoryService repositoryService;
 
     private final PrettyTime p = new PrettyTime();
 
     @Override
     public NavigatorContent listContentfinal org.uberfire.backend.vfs.Path _path ) {
         final ArrayList<DataContent> result = new ArrayList<DataContent>();
         final ArrayList<org.uberfire.backend.vfs.Path> breadcrumbs = new ArrayList<org.uberfire.backend.vfs.Path>();
 
         Path path = Paths.convert( _path );
         final DirectoryStream<Path> stream = .newDirectoryStream( path );
 
         for ( final Path activePath : stream ) {
             final VersionAttributeView versionAttributeView = .getFileAttributeView( activePath, VersionAttributeView.class );
             int index = versionAttributeView.readAttributes().history().records().size() - 1;
 
             final String authorEmail = versionAttributeView.readAttributes().history().records().get( index ).email();
             final String author = versionAttributeView.readAttributes().history().records().get( index ).author();
             final String comment = versionAttributeView.readAttributes().history().records().get( index ).comment();
 
             final String time = .format( new Date( Files.getLastModifiedTime( activePath ).toMillis() ) );
             result.add( new DataContent( Files.isDirectory( activePath ), commentauthorauthorEmailtime, Paths.convert( activePath ) ) );
         }
 
         sortresultnew Comparator<DataContent>() {
             @Override
             public int comparefinal DataContent dataContent,
                                 final DataContent dataContent2 ) {
 
                 int fileCompare = dataContent.getPath().getFileName().toLowerCase().compareTo( dataContent2.getPath().getFileName().toLowerCase() );
                 if ( dataContent.isDirectory() && dataContent2.isDirectory() ) {
                     return fileCompare;
                 }
 
                 if ( dataContent.isDirectory() ) {
                     return -1;
                 }
 
                 if ( dataContent2.isDirectory() ) {
                     return 1;
                 }
 
                 return fileCompare;
 
             }
         } );
 
         if ( !path.equals( path.getRoot() ) ) {
             while ( !path.getParent().equals( path.getRoot() ) ) {
                 path = path.getParent();
                 breadcrumbs.add( Paths.convert( path ) );
             }
 
             reversebreadcrumbs );
         }
         final org.uberfire.backend.vfs.Path root = Paths.convert( path.getRoot() );
 
         return new NavigatorContent( .getRepository( root ).getAlias(), rootbreadcrumbsresult );
     }
 
     @Override
     public List<Repository> listRepositories() {
         return new ArrayList<Repository>( .getRepositories() );
     }
New to GrepCode? Check out our FAQ X