/** * Checks, whether an content entity with the given name exists in this content location. This method will report * invalid filenames as non-existent. * * @param name the name of the new entity. * @return true, if an entity exists with this name, false otherwise. */ public boolean exists( final String name ) { if ( RepositoryUtilities.isInvalidPathName( name ) ) { return false; } try { final FileObject file = getBackend(); final FileObject child = file.resolveFile( name ); return child.exists(); } catch ( FileSystemException e ) { throw new RuntimeException( e ); } } }
public void createDirectoryEntry( final String name, final String mimeType ) throws IOException { if ( name == null ) { throw new NullPointerException(); } if ( mimeType == null ) { throw new NullPointerException(); } try { RepositoryUtilities.createLocation( zipRepository, RepositoryUtilities.splitPath( name, "/" ) ); if ( ( name.length() > 0 && name.charAt( name.length() - 1 ) == '/' ) == false ) { metaData.setEntryMimeType( name + '/', mimeType ); } else { metaData.setEntryMimeType( name, mimeType ); } } catch ( ContentIOException e ) { throw new IOException( "Failed to create content-location " + name ); } }
logger.warn( "Document-Bundle has no bundle-type declared." ); } else { final ContentItem contentItem = RepositoryUtilities.createItem ( repository, RepositoryUtilities.splitPath( "mimetype", "/" ) ); contentItem.setAttribute ( LibRepositoryBoot.ZIP_DOMAIN, LibRepositoryBoot.ZIP_METHOD_ATTRIBUTE, LibRepositoryBoot.ZIP_METHOD_STORED ); final ContentItem manifestItem = RepositoryUtilities.createItem ( repository, RepositoryUtilities.splitPath( "META-INF/manifest.xml", "/" ) ); final OutputStream manifestStream = manifestItem.getOutputStream(); try { final ContentItem metaDataItem = RepositoryUtilities.createItem ( repository, RepositoryUtilities.splitPath( "meta.xml", "/" ) ); final OutputStream metaDataStream = metaDataItem.getOutputStream(); try { final String[] entityNameArray = RepositoryUtilities.splitPath( entryName, "/" ); if ( entryName.length() > 0 && entryName.charAt( entryName.length() - 1 ) == '/' ) { if ( RepositoryUtilities.isExistsEntity( repository, entityNameArray ) ) { continue; RepositoryUtilities.createLocation( repository, entityNameArray ); continue; final ContentItem dataItem = RepositoryUtilities.createItem ( repository, entityNameArray ); final OutputStream dataStream = dataItem.getOutputStream();
public OutputStream createEntry( final String path, final String mimetype ) throws IOException { if ( path == null ) { throw new NullPointerException(); } if ( mimetype == null ) { throw new NullPointerException( "Invalid Bundle: There is no mime-type for entry " + path ); } final String[] name = RepositoryUtilities.splitPath( path, "/" ); try { final ContentItem contentItem = RepositoryUtilities.createItem( zipRepository, name ); metaData.setEntryMimeType( path, mimetype ); return contentItem.getOutputStream(); } catch ( ContentIOException cioe ) { logger.warn( "Failed to create content item " + path, cioe ); throw new IOException( "Failed to create content item " + path ); } }
final String[] buildName = RepositoryUtilities.splitPath( nextEntry.getName(), "/" ); if ( nextEntry.isDirectory() ) { root.updateDirectoryEntry( buildName, 0, nextEntry );
public boolean isEntryReadable( final String name ) { if ( name == null ) { throw new NullPointerException(); } try { final String[] splitName = RepositoryUtilities.split( name, "/" ); final ContentEntity contentEntity = RepositoryUtilities.getEntity( repository, splitName ); return ( contentEntity instanceof ContentItem ); } catch ( ContentIOException cioe ) { return false; } }
for ( int i = 0; i < contentEntities.length; i++ ) { final ContentEntity entity = contentEntities[ i ]; final String fullName = RepositoryUtilities.buildName( entity, "/" ); if ( entity instanceof ContentLocation ) { final ContentLocation childlocation = (ContentLocation) entity; writeLocation( childlocation, outputStream ); } else if ( entity instanceof ContentItem ) { final ContentItem item = (ContentItem) entity; itemEntry.setSize( sizeLong.longValue() ); itemEntry.setCrc( crc32Long.longValue() ); final int method = getZipMethod( item ); final int compression = getZipLevel( item ); outputStream.setMethod( method ); outputStream.setLevel( compression );
this.root = repository.getRoot(); final String identifier = (String) mainKey.getIdentifier(); final String[] name = RepositoryUtilities.split( identifier, "/" ); if ( RepositoryUtilities.isExistsEntity( repository, name ) == false ) { if ( failOnMissingData ) { throw new UnrecognizedLoaderException( "This bundle data does not point to readable content: " + identifier ); final ContentEntity contentEntity = RepositoryUtilities.getEntity( repository, name ); if ( contentEntity instanceof ContentItem == false ) { if ( failOnMissingData ) {
/** * Returns the full pathname of the location. * * @return the full pathname. */ public Object getContentId() { return RepositoryUtilities.buildName( this, "/" ); }
final int zipMethod = RepositoryUtilities.getZipMethod( item ); zipEntry.setCrc( crc32.getValue() ); if ( zipMethod == Deflater.NO_COMPRESSION ) { zipEntry.setSize( size ); repository.writeContent( zipEntry, infi, zipMethod, RepositoryUtilities.getZipLevel( item ) ); infi.close();
public ZipEntryOutputStream( final ZipContentItem item ) { if ( item == null ) { throw new NullPointerException(); } this.item = item; this.outputStream = new ByteArrayOutputStream(); this.deflater = new Deflater( RepositoryUtilities.getZipLevel( item ) ); this.deflaterOutputStream = new DeflaterOutputStream( outputStream, deflater ); this.crc32 = new CRC32(); this.size = 0; }
final ContentLocation root = zipRepository.getRoot(); final ContentLocation data = RepositoryUtilities.createLocation( zipRepository, RepositoryUtilities.splitPath( "data", "/" ) );
ZipEntry nextEntry = zipIn.getNextEntry(); while ( nextEntry != null ) { final String[] buildName = RepositoryUtilities.splitPath( nextEntry.getName(), "/" ); if ( nextEntry.isDirectory() ) { root.updateDirectoryEntry( buildName, 0, nextEntry );
public boolean isEntryReadable( final String name ) { if ( name == null ) { throw new NullPointerException(); } try { final String[] splitName = RepositoryUtilities.split( name, "/" ); final ContentEntity contentEntity = RepositoryUtilities.getEntity( zipRepository, splitName ); return ( contentEntity instanceof ContentItem ); } catch ( ContentIOException cioe ) { return false; } }
public EmailContentItem( final String name, final EmailRepository repository, final EmailContentLocation parent ) { this.name = name; this.repository = repository; this.parent = parent; this.contentId = RepositoryUtilities.buildName( this, "/" ); this.newItem = true; }
final ContentLocation root = zipRepository.getRoot(); final ContentLocation data = RepositoryUtilities.createLocation( zipRepository, RepositoryUtilities.splitPath( dataDirectory, "/" ) ); //$NON-NLS-1$
/** * Creates a new content location in the current location. This method must never return null. This method will fail * if an entity with the same name exists in this location. * * @param name the name of the new entity. * @return the newly created entity, never null. * @throws ContentCreationException if the item could not be created. */ public ContentLocation createLocation( final String name ) throws ContentCreationException { if ( RepositoryUtilities.isInvalidPathName( name ) ) { throw new IllegalArgumentException( "The name given is not valid." ); } try { final FileObject file = getBackend(); final FileObject child = file.resolveFile( name ); if ( child.exists() ) { throw new ContentCreationException( "File already exists." ); } child.createFile(); try { return new FileObjectContentLocation( this, child ); } catch ( ContentIOException e ) { throw new ContentCreationException( "Failed to create the content-location", e ); } } catch ( FileSystemException e ) { throw new RuntimeException( e ); } }
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 ); }
/** * Returns the full pathname of the location. * * @return the full pathname. */ public Object getContentId() { return RepositoryUtilities.buildName( this, "/" ); }
final ContentLocation root = zipRepository.getRoot(); final ContentLocation data = RepositoryUtilities.createLocation( zipRepository, RepositoryUtilities.splitPath( "data", "/" ) );