/** * Creates a new content-entity for the given file using the given content location as parent. * * @param parent the content location representing the parent directory. * @param backend the file representing this entity. */ protected FileObjectContentEntity( final ContentLocation parent, final FileObject backend ) { if ( backend == null ) { throw new NullPointerException( "Backend file must be given." ); } if ( parent == null ) { throw new NullPointerException( "Parent file must be given." ); } this.repository = parent.getRepository(); this.parent = parent; this.backend = backend; }
public ContentItem createItem( final String name, final String mimeType ) throws ContentIOException { return dataLocation.createItem( dataNameGenerator.generateName( name, mimeType ) ); }
for ( int i = 0; i < length - 1; i++ ) { final String nameItem = name[ i ]; if ( node.exists( nameItem ) == false ) { node = node.createLocation( nameItem ); } else { final ContentEntity entry = node.getEntry( nameItem ); if ( entry instanceof ContentLocation == false ) { return node.createItem( name[ length - 1 ] );
for ( int i = 0; i < length - 1; i++ ) { final String nameItem = name[ i ]; if ( node.exists( nameItem ) == false ) { node = node.createLocation( nameItem ); } else { final ContentEntity entry = node.getEntry( nameItem ); if ( entry instanceof ContentLocation == false ) { return node.createLocation( name[ length - 1 ] );
private String buildPath( final ContentEntity entity ) { final ArrayList entityNames = new ArrayList(); entityNames.add( entity.getName() ); ContentLocation location = entity.getParent(); int size = 0; while ( location != null ) { final ContentLocation parent = location.getParent(); if ( parent != null ) { final String locationName = location.getName(); size += locationName.length(); size += 1; entityNames.add( locationName ); } location = location.getParent(); } final StringBuffer b = new StringBuffer( size ); for ( int i = entityNames.size() - 1; i >= 0; i-- ) { final String name = (String) entityNames.get( i ); b.append( name ); if ( i != 0 ) { b.append( '/' ); } } return b.toString(); } }
for ( int i = 0; i < length - 1; i++ ) { final String nameItem = name[ i ]; final ContentEntity entry = node.getEntry( nameItem ); if ( entry instanceof ContentLocation == false ) { throw new ContentIOException( "No such item: " + nameItem + " in " + node.getContentId() ); return node.getEntry( name[ length - 1 ] );
/** * Returns a unique identifier. This can be canonical filename or a database key. It must be guaranteed that within * the same repository the key will be unique. * * @return the unique content ID. */ public Object getContentId() { return parent.getName() + '/' + name; }
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; } }
dataLocation.createItem( dataNameGenerator.generateName( extractFilename( resourceData ), mimeType ) ); if ( item.isWriteable() ) { item.setAttribute( LibRepositoryBoot.REPOSITORY_DOMAIN, LibRepositoryBoot.CONTENT_TYPE, mimeType );
/** * 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." ); }
/** * Returns the current repository, to which tis entity belongs. * * @return the repository. */ public Repository getRepository() { return parent.getRepository(); }
dataLocation.createItem( dataNameGenerator.generateName( filename, data.getMimeType() ) ); final String contentURL = rewriterService.rewriteContentDataItem( dataFile );
/** * Returns the parent repository for this location. * * @return the repository. */ public Repository getRepository() { return parent.getRepository(); }
documentContentItem = contentLocation.createItem( contentNameGenerator.generateName( "content", "text/csv" ) ); final OutputStream out = documentContentItem.getOutputStream();
/** * Creates a new DummyContentLocation with the given parent and name. The location will inherit the repository from * its parent. * * @param parent the parent location. * @param name the name of this location. */ public DummyContentLocation( final ContentLocation parent, final String name ) { if ( parent == null ) { throw new NullPointerException( "Parent must not be null" ); } this.repository = parent.getRepository(); this.parent = parent; this.name = name; }
final ContentItem contentItem = contentLocation.createItem( nameGenerator.generateName( null, "text/xml" ) ); final OutputStream outputStream = contentItem.getOutputStream();
/** * Creates a new content-entity for the given file using the given content location as parent. * * @param parent the content location representing the parent directory. * @param backend the file representing this entity. */ protected FileContentEntity( final ContentLocation parent, final File backend ) { if ( backend == null ) { throw new NullPointerException( "Backend file must be given." ); } if ( parent == null ) { throw new NullPointerException( "Parent file must be given." ); } this.repository = parent.getRepository(); this.parent = parent; this.backend = backend; }