public InputStream getEntryAsStream( final String name ) throws IOException { if ( name == null ) { throw new NullPointerException(); } try { final String[] splitName = RepositoryUtilities.split( name, "/" ); final ContentEntity contentEntity = RepositoryUtilities.getEntity( repository, splitName ); if ( contentEntity instanceof ContentItem ) { final ContentItem contentItem = (ContentItem) contentEntity; return contentItem.getInputStream(); } } catch ( ContentIOException cioe ) { if ( logger.isDebugEnabled() ) { logger.debug( "Failed to lookup entry for entry " + name, cioe ); } throw new IOException( "Failure while looking up the stream: " + cioe ); } throw new IOException( "No such stream: " + name ); }
public InputStream getEntryAsStream( final String name ) throws IOException { if ( name == null ) { throw new NullPointerException(); } try { final String[] splitName = RepositoryUtilities.split( name, "/" ); final ContentEntity contentEntity = RepositoryUtilities.getEntity( zipRepository, splitName ); if ( contentEntity instanceof ContentItem ) { final ContentItem contentItem = (ContentItem) contentEntity; return contentItem.getInputStream(); } } catch ( ContentIOException cioe ) { if ( logger.isDebugEnabled() ) { logger.debug( "Failed to lookup entry for entry " + name, cioe ); } throw new IOException( "Failure while looking up the stream: " + cioe ); } throw new IOException( "No such stream: " + name ); }
public InputStream getResourceAsStream( final ResourceManager caller ) throws ResourceLoadingException { if ( caller == null ) { throw new NullPointerException(); } if ( contentItem == null ) { throw new ResourceLoadingException( "Failure: Missing data" ); } try { return contentItem.getInputStream(); } catch ( ContentIOException cioe ) { throw new ResourceLoadingException( "Failure", cioe ); } catch ( IOException e ) { throw new ResourceLoadingException( "Failure", e ); } }
public static String getBundleType( final Repository repository ) { if ( repository == null ) { throw new NullPointerException(); } try { final ContentEntity mimeTypeContentEntity = repository.getRoot().getEntry( "mimetype" ); if ( mimeTypeContentEntity instanceof ContentItem ) { final ContentItem mimeTypeItem = (ContentItem) mimeTypeContentEntity; final ByteArrayOutputStream bout = new ByteArrayOutputStream(); final InputStream in = mimeTypeItem.getInputStream(); try { IOUtils.getInstance().copyStreams( in, bout ); } finally { in.close(); } return bout.toString( "ASCII" ); } return null; } catch ( Exception e ) { return null; } }
final InputStream inputStream = item.getInputStream(); try { IOUtils.getInstance().copyStreams( inputStream, outputStream );