}
private void testSymbol( char symbol, boolean isGood ) {
DataNode goodNode = new DataNode( "node" );
goodNode.setProperty( "property", "whatever" );
NodeRepositoryFileData goodNodeData = new NodeRepositoryFileData( goodNode );
DataNode badNode = new DataNode( "node" + symbol );
badNode.setProperty( "property", "whatever" );
NodeRepositoryFileData badNodeData = new NodeRepositoryFileData( badNode );
DataNode goodNodeBadProp = new DataNode( "node" );
goodNodeBadProp.setProperty( "property" + symbol, "whatever" );
NodeRepositoryFileData goodNodeBadPropData = new NodeRepositoryFileData( goodNodeBadProp );
final String parentFolderPath =
ClientRepositoryPaths.getUserHomeFolderPath( PentahoSessionHolder.getSession().getName() );
RepositoryFile parentFolder = repo.getFile( parentFolderPath );
try {
final String name = "folder" + symbol;
final RepositoryFile folder =
repo.createFolder( parentFolder.getId(), new RepositoryFile.Builder( name ).folder( true ).build(), null );
failIfTrue( !isGood, symbol );
assertEquals( name, folder.getName() );
} catch ( UnifiedRepositoryMalformedNameException e ) {
failIfTrue( isGood, symbol );
}
try {
final String name = "file" + symbol;
final RepositoryFile file =
repo.createFile( parentFolder.getId(), new RepositoryFile.Builder( name ).build(), goodNodeData, null );
failIfTrue( !isGood, symbol );
assertEquals( name, file.getName() );
} catch ( UnifiedRepositoryMalformedNameException e ) {
failIfTrue( isGood, symbol );
}
try {
final RepositoryFile file = repo.getFile( parentFolder.getPath() + RepositoryFile.SEPARATOR + "file" );
if ( file != null ) {
repo.deleteFile( file.getId(), null );
}
final RepositoryFile file1 =
repo.createFile( parentFolder.getId(), new RepositoryFile.Builder( "file" ).build(), badNodeData, null );
failIfTrue( !isGood, symbol );
assertEquals( badNodeData.getNode().getName(), repo.getDataForRead( file1.getId(), NodeRepositoryFileData.class )
.getNode().getName() );
} catch ( UnifiedRepositoryMalformedNameException e ) {
failIfTrue( isGood, symbol );
}
try {
final RepositoryFile file = repo.getFile( parentFolder.getPath() + RepositoryFile.SEPARATOR + "file" );
if ( file != null ) {
repo.deleteFile( file.getId(), null );
}
final RepositoryFile file1 =
repo.createFile( parentFolder.getId(), new RepositoryFile.Builder( "file" ).build(), goodNodeBadPropData,
null );
failIfTrue( !isGood, symbol );
assertEquals( goodNodeBadPropData.getNode().getProperties().iterator().next().getName(), repo.getDataForRead(
file1.getId(), NodeRepositoryFileData.class ).getNode().getProperties().iterator().next().getName() );
} catch ( UnifiedRepositoryMalformedNameException e ) {
failIfTrue( isGood, symbol );
}
}