RepositoryFileImportFileHandler implements IPlatformImportHandler { protected String getTitle( String name ) { if ( !StringUtils.isEmpty( name ) ) { int dotIndex = name.lastIndexOf( '.' ); if ( dotIndex != -1 ) { String extension = name.substring( dotIndex + 1 ); if ( knownExtensions != null && knownExtensions.contains( extension ) ) { return name.substring( 0, dotIndex ); } } } return name; } RepositoryFileImportFileHandler( List<IMimeType> mimeTypes ); Log getLogger(); ImportSession getImportSession(); @Override void importFile( IPlatformImportBundle bnd ); IUnifiedRepository getRepository(); void setRepository( IUnifiedRepository repository ); void setDefaultAclHandler( IRepositoryDefaultAclHandler defaultAclHandler ); RepositoryFile createFolderJustInTime( String folderPath, String manifestKey ); @Override List<IMimeType> getMimeTypes(); Map<String, IMimeType> getMimeTypeMap(); void setKnownExtensions( List<String> knownExtensions ); List<String> getKnownExtensions();  }
@Test public void testExtensionNotTruncated() throws Exception { String name = "file.csv"; setup( MIMENAME, MIME_EXTENSION, "", "", false ); String title = fileHandler.getTitle( name ); assertEquals( name, title ); }
@Test public void testExtensionTruncated() throws Exception { String name = "file.prpt"; setup( MIMENAME, MIME_EXTENSION, "", "", false ); String title = fileHandler.getTitle( name ); assertEquals( "file", title ); }
@Test public void testFileWithoutExtension() throws Exception { String name = "file"; setup( MIMENAME, MIME_EXTENSION, "", "", false ); String title = fileHandler.getTitle( name ); assertEquals( name, title ); }