/** * Creates a new location for the given parent and directory. * * @param parent the parent location. * @param backend the backend. * @throws ContentIOException if an error occured or the file did not point to a directory. */ public FileObjectContentLocation( final ContentLocation parent, final FileObject backend ) throws ContentIOException { super( parent, backend ); boolean error; try { error = backend.exists() == false || backend.isFolder() == false; } catch ( FileSystemException e ) { throw new RuntimeException( e ); } if ( error ) { throw new ContentIOException( "The given backend-file is not a directory." ); } }
/** * Creates a new root-location for the given repository and directory. * * @param repository the repository for which a location should be created. * @param backend the backend. * @throws ContentIOException if an error occured or the file did not point to a directory. */ public FileObjectContentLocation( final Repository repository, final FileObject backend ) throws ContentIOException { super( repository, backend ); boolean error; try { error = backend.exists() == false || backend.isFolder() == false; } catch ( FileSystemException e ) { throw new RuntimeException( e ); } if ( error ) { throw new ContentIOException( "The given backend-file is not a directory." ); } }
/** * Returns the content entity with the given name. If the entity does not exist, an Exception will be raised. * * @param name the name of the entity to be retrieved. * @return the content entity for this name, never null. * @throws ContentIOException if an repository error occured. */ public ContentEntity getEntry( final String name ) throws ContentIOException { try { if ( RepositoryUtilities.isInvalidPathName( name ) ) { throw new IllegalArgumentException( "The name given is not valid." ); } final FileObject file = getBackend(); final FileObject child = file.resolveFile( name ); if ( child.exists() == false ) { throw new ContentIOException( "Not found:" + child ); } if ( child.isFolder() ) { return new FileObjectContentLocation( this, child ); } else if ( child.isFile() ) { return new FileObjectContentItem( this, child ); } else { throw new ContentIOException( "Not File nor directory." ); } } catch ( FileSystemException e ) { throw new RuntimeException( e ); } }
/** * Returns the content entity with the given name. This always throws the ContentIOException, as this implementation * claims to not know any of its childs. * * @param name the name of the entity to be retrieved. * @return the content entity for this name, never null. * @throws ContentIOException if an repository error occured. */ public ContentEntity getEntry( final String name ) throws ContentIOException { throw new ContentIOException(); }
public InputStream getInputStream() throws ContentIOException, IOException { throw new ContentIOException( "This item is not readable." ); }
public InputStream getInputStream() throws ContentIOException, IOException { throw new ContentIOException( "This item is not readable." ); }
public ContentEntity getEntry( final String name ) throws ContentIOException { final ContentEntity contentEntity = (ContentEntity) entries.get( name ); if ( contentEntity == null ) { throw new ContentIOException( "Not found:" + name ); } return contentEntity; }
public ContentEntity getEntry( final String name ) throws ContentIOException { final ContentEntity contentEntity = (ContentEntity) entries.get( name ); if ( contentEntity == null ) { throw new ContentIOException( "Not found:" + name ); } return contentEntity; }
/** * Creates a new root-location for the given repository and directory. * * @param repository the repository for which a location should be created. * @param backend the backend. * @throws ContentIOException if an error occured or the file did not point to a directory. */ public FileContentLocation( final Repository repository, final File backend ) throws ContentIOException { super( repository, backend ); if ( backend.exists() == false || backend.isDirectory() == false ) { throw new ContentIOException( "The given backend-file is not a directory." ); } }
/** * Creates a new location for the given parent and directory. * * @param parent the parent location. * @param backend the backend. * @throws ContentIOException if an error occured or the file did not point to a directory. */ public FileContentLocation( final ContentLocation parent, final File backend ) throws ContentIOException { super( parent, backend ); if ( backend.exists() == false || backend.isDirectory() == false ) { throw new ContentIOException( "The given backend-file is not a directory." ); } }
public OutputStream getOutputStream() throws ContentIOException, IOException { if ( newItem == false ) { throw new ContentIOException( "This item is no longer writeable." ); } newItem = false; return new ZipEntryOutputStream( this ); }
public void writeEmail( final OutputStream out ) throws ContentIOException { try { htmlEmail.writeTo( out ); } catch ( Exception ex ) { throw new ContentIOException( ex.getMessage(), ex ); } }
public OutputStream getOutputStream() throws ContentIOException, IOException { if ( newItem == false ) { throw new ContentIOException( "This item is no longer writeable." ); } newItem = false; return new EmailEntryOutputStream( this ); }
final File child = new File( file, name ); if ( child.exists() == false ) { throw new ContentIOException( "Not found:" + child ); throw new ContentIOException( "The given entry does not point to a sub-directory of this content-location" ); throw new ContentIOException( "IO Error.", e ); return new FileContentItem( this, child ); } else { throw new ContentIOException( "Not File nor directory." );
/** * Returns the content entity with the given name. If the entity does not exist, an Exception will be raised. * * @param name the name of the entity to be retrieved. * @return the content entity for this name, never null. * @throws ContentIOException if an repository error occured. */ public ContentEntity getEntry( final String name ) throws ContentIOException { final WrappedInputStream in = repository.getInputStream(); if ( in != null && contentItem == null ) { this.contentItem = new StreamContentItem ( repository.getContentName(), this, in, repository.getOutputStream() ); } if ( contentItem == null ) { throw new ContentIOException( "No such item" ); } if ( contentItem.getName().equals( name ) ) { return contentItem; } throw new ContentIOException( "No such item" ); }
/** * Generates a new, unique name for storing resources in the output repository. Assuming that proper synchronization * has been applied, the generated name will be unique within that repository. * * @param nameHint a user defined name for that resource. * @param mimeType the mime type of the resource to be stored in the repository. * @return the generated, fully qualified name. */ public String generateName( final String nameHint, final String mimeType ) throws ContentIOException { final String name; if ( nameHint != null ) { name = nameHint; } else { name = defaultNameHint; } final String suffix; if ( defaultSuffix != null ) { suffix = defaultSuffix; } else { suffix = getSuffixForType( mimeType, location ); } final String filename = name + '-' + counter + '.' + suffix; if ( location.exists( filename ) == false ) { counter += 1; return filename; } throw new ContentIOException( "Unable to generate page-sequence: A file with the next expected name already exists." ); }
/** * Generates a new name for the location. The name-generator may use both the name-hint and mimetype to compute the * new name. * * @param nameHint the name hint, usually a identifier for the new filename (can be null). * @param mimeType the mime type of the new filename. Usually used to compute a suitable file-suffix. * @return the generated name, never null. * @throws org.pentaho.reporting.libraries.repository.ContentIOException if the name could not be generated for any * reason. */ public String generateName( final String nameHint, final String mimeType ) throws ContentIOException { final MimeRegistry mimeRegistry = fileContentLocation.getRepository().getMimeRegistry(); final File targetDirectory = fileContentLocation.getBackend(); final String suffix = mimeRegistry.getSuffix( mimeType ); try { final File tempFile = File.createTempFile( nameHint, "." + suffix, targetDirectory ); return tempFile.getName(); } catch ( IOException e ) { throw new ContentIOException( "Unable to generate a name for the data file", e ); } } }
if ( entry instanceof ContentLocation == false ) { throw new ContentIOException( "No such item." );
if ( entry instanceof ContentLocation == false ) { throw new ContentIOException( "No such item." );
if ( entry instanceof ContentLocation == false ) { throw new ContentIOException( "No such item: " + nameItem + " in " + node.getContentId() );