@Test( expected = ResourceKeyCreationException.class ) public void deriveKeyInvalidKeyTest() throws Exception { FileObjectResourceLoader fileObjectResourceLoader = new FileObjectResourceLoader(); ResourceKey parent = new ResourceKey( "InvalidSchema", "", null ); fileObjectResourceLoader.deriveKey( parent, "", null ); }
public ResourceKey deriveKey( final ResourceKey parent, final String path, final Map factoryKeys ) throws ResourceKeyCreationException { if ( isSupportedKey( parent ) == false ) { throw new ResourceKeyCreationException( "Assertation: Unsupported parent key type" ); } try { final File target; if ( path != null ) { final File parentResource = new File( parent.getIdentifierAsString() ); final File parentFile = parentResource.getParentFile(); if ( parentFile == null ) { throw new FileNotFoundException( "Parent file does not exist" ); } target = new File( parentFile, path ); } else { return parent; } final Map map; if ( factoryKeys != null ) { map = new HashMap(); map.putAll( parent.getFactoryParameters() ); map.putAll( factoryKeys ); } else { map = parent.getFactoryParameters(); } String targetIdentifier = ( (FileObject) parent.getIdentifier() ).getFileSystem() != null ? target.toString() : "solution:" + target.toString(); return new ResourceKey( parent.getSchema(), VFS.getManager().resolveFile( targetIdentifier ), map ); } catch ( IOException ioe ) { throw new ResourceKeyCreationException( "Failed to create key", ioe ); } }
FileObjectResourceLoader implements ResourceLoader { public ResourceKey deriveKey( final ResourceKey parent, final String path, final Map factoryKeys ) throws ResourceKeyCreationException { if ( isSupportedKey( parent ) == false ) { throw new ResourceKeyCreationException( "Assertation: Unsupported parent key type" ); } try { final File target; if ( path != null ) { final File parentResource = new File( parent.getIdentifierAsString() ); final File parentFile = parentResource.getParentFile(); if ( parentFile == null ) { throw new FileNotFoundException( "Parent file does not exist" ); } target = new File( parentFile, path ); } else { return parent; } final Map map; if ( factoryKeys != null ) { map = new HashMap(); map.putAll( parent.getFactoryParameters() ); map.putAll( factoryKeys ); } else { map = parent.getFactoryParameters(); } String targetIdentifier = ( (FileObject) parent.getIdentifier() ).getFileSystem() != null ? target.toString() : "solution:" + target.toString(); return new ResourceKey( parent.getSchema(), VFS.getManager().resolveFile( targetIdentifier ), map ); } catch ( IOException ioe ) { throw new ResourceKeyCreationException( "Failed to create key", ioe ); } } }
FileObjectResourceLoader implements ResourceLoader { public ResourceKey deriveKey( final ResourceKey parent, final String path, final Map factoryKeys ) throws ResourceKeyCreationException { if ( isSupportedKey( parent ) == false ) { throw new ResourceKeyCreationException( "Assertation: Unsupported parent key type" ); } try { final File target; if ( path != null ) { final File parentResource = new File( parent.getIdentifierAsString() ); final File parentFile = parentResource.getParentFile(); if ( parentFile == null ) { throw new FileNotFoundException( "Parent file does not exist" ); } target = new File( parentFile, path ); } else { return parent; } final Map map; if ( factoryKeys != null ) { map = new HashMap(); map.putAll( parent.getFactoryParameters() ); map.putAll( factoryKeys ); } else { map = parent.getFactoryParameters(); } String targetIdentifier = ( (FileObject) parent.getIdentifier() ).getFileSystem() != null ? target.toString() : "solution:" + target.toString(); return new ResourceKey( parent.getSchema(), VFS.getManager().resolveFile( targetIdentifier ), map ); } catch ( IOException ioe ) { throw new ResourceKeyCreationException( "Failed to create key", ioe ); } } FileObjectResourceLoader(); }
FileObjectResourceLoader implements ResourceLoader { public ResourceKey deriveKey( final ResourceKey parent, final String path, final Map factoryKeys ) throws ResourceKeyCreationException { if ( isSupportedKey( parent ) == false ) { throw new ResourceKeyCreationException( "Assertation: Unsupported parent key type" ); } try { final File target; if ( path != null ) { final File parentResource = new File( parent.getIdentifierAsString() ); final File parentFile = parentResource.getParentFile(); if ( parentFile == null ) { throw new FileNotFoundException( "Parent file does not exist" ); } target = new File( parentFile, path ); } else { return parent; } final Map map; if ( factoryKeys != null ) { map = new HashMap(); map.putAll( parent.getFactoryParameters() ); map.putAll( factoryKeys ); } else { map = parent.getFactoryParameters(); } String targetIdentifier = ( (FileObject) parent.getIdentifier() ).getFileSystem() != null ? target.toString() : "solution:" + target.toString(); return new ResourceKey( parent.getSchema(), VFS.getManager().resolveFile( targetIdentifier ), map ); } catch ( IOException ioe ) { throw new ResourceKeyCreationException( "Failed to create key", ioe ); } } FileObjectResourceLoader(); boolean isSupportedKey( final ResourceKey key ); ResourceKey createKey( final Object value, final Map factoryKeys ); ResourceKey deriveKey( final ResourceKey parent, final String path, final Map factoryKeys ); URL toURL( final ResourceKey key ); ResourceData load( final ResourceKey key ); String serialize( final ResourceKey bundleKey, final ResourceKey key ); ResourceKey deserialize( final ResourceKey bundleKey, final String stringKey ); boolean isSupportedDeserializer( final String data ); }
FileObjectResourceLoader implements ResourceLoader { public ResourceKey deriveKey( final ResourceKey parent, final String path, final Map factoryKeys ) throws ResourceKeyCreationException { if ( isSupportedKey( parent ) == false ) { throw new ResourceKeyCreationException( "Assertation: Unsupported parent key type" ); } try { final File target; if ( path != null ) { final File parentResource = new File( parent.getIdentifierAsString() ); final File parentFile = parentResource.getParentFile(); if ( parentFile == null ) { throw new FileNotFoundException( "Parent file does not exist" ); } target = new File( parentFile, path ); } else { return parent; } final Map map; if ( factoryKeys != null ) { map = new HashMap(); map.putAll( parent.getFactoryParameters() ); map.putAll( factoryKeys ); } else { map = parent.getFactoryParameters(); } String targetIdentifier = ( (FileObject) parent.getIdentifier() ).getFileSystem() != null ? target.toString() : "solution:" + target.toString(); return new ResourceKey( parent.getSchema(), VFS.getManager().resolveFile( targetIdentifier ), map ); } catch ( IOException ioe ) { throw new ResourceKeyCreationException( "Failed to create key", ioe ); } } FileObjectResourceLoader(); boolean isSupportedKey( final ResourceKey key ); ResourceKey createKey( final Object value, final Map factoryKeys ); ResourceKey deriveKey( final ResourceKey parent, final String path, final Map factoryKeys ); URL toURL( final ResourceKey key ); ResourceData load( final ResourceKey key ); String serialize( final ResourceKey bundleKey, final ResourceKey key ); ResourceKey deserialize( final ResourceKey bundleKey, final String stringKey ); boolean isSupportedDeserializer( final String data ); static final String SCHEMA_NAME; }