/** * 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 ); } }
} catch ( ContentCreationException cce ) { logger.warn( "Failed to create the content image: Reason given was: " + cce.getMessage() ); return null; } catch ( URLRewriteException re ) {
throw new ContentCreationException( "File already exists: " + child ); return new FileObjectContentItem( this, child ); } catch ( IOException e ) { throw new ContentCreationException( "IOError while create", e );
/** * This method always throws an exception, as stream-repositories cannot create sub-locations. * * @param name the name. * @return nothing. * @throws ContentCreationException always, as stream-repositories cannot create sub-locations. */ public ContentLocation createLocation( final String name ) throws ContentCreationException { throw new ContentCreationException( "A stream repository never creates sub-locations" ); }
public ContentLocation createLocation( final String name ) throws ContentCreationException { throw new ContentCreationException( "createLocation not Implemented yet" ); }
public OutputStream getOutputStream() throws ContentIOException, IOException { throw new ContentCreationException( "This repository is read-only" ); }
public ContentLocation createLocation( final String name ) throws ContentCreationException { throw new ContentCreationException(); }
public ContentItem createItem( final String name ) throws ContentCreationException { throw new ContentCreationException(); }
public ContentItem createItem( final String name ) throws ContentCreationException { if ( entries.containsKey( name ) ) { throw new ContentCreationException( "An entry with name '" + name + "' already exists." ); } if ( name.indexOf( '/' ) != -1 ) { throw new ContentCreationException( "The entry-name '" + name + "' is invalid." ); } if ( "".equals( name ) || ".".equals( name ) || "..".equals( name ) ) { throw new ContentCreationException( "The entry-name '" + name + "' is invalid." ); } final ZipContentItem value = new ZipContentItem( repository, this, name ); entries.put( name, value ); return value; }
public ContentLocation createLocation( final String name ) throws ContentCreationException { if ( entries.containsKey( name ) ) { throw new ContentCreationException( "An entry with name '" + name + "' already exists." ); } if ( entries.containsKey( name ) ) { throw new ContentCreationException( "An entry with name '" + name + "' already exists." ); } if ( name.indexOf( '/' ) != -1 ) { throw new ContentCreationException( "The entry-name '" + name + "' is invalid." ); } if ( "".equals( name ) || ".".equals( name ) || "..".equals( name ) ) { throw new ContentCreationException( "The entry-name '" + name + "' is invalid." ); } final ZipContentLocation value = new ZipContentLocation( repository, this, name ); entries.put( name, value ); return value; }
/** * Creates a new data item in the current location. This method must never return null. * * @param name * @return * @throws ContentCreationException if the item could not be created. */ public ContentItem createItem( final String name ) throws ContentCreationException { if ( entries.containsKey( name ) ) { throw new ContentCreationException( "Entry already exists" ); } final EmailContentItem item = new EmailContentItem( name, repository, this ); entries.put( name, item ); return item; }
/** * Creates a new data item in the current location. This method must never return null. * * @param name * @return * @throws org.pentaho.reporting.libraries.repository.ContentCreationException if the item could not be created. */ public ContentItem createItem( final String name ) throws ContentCreationException { if ( entries.containsKey( name ) ) { throw new ContentCreationException( "Entry already exists" ); } if ( RepositoryUtilities.isInvalidPathName( name ) ) { throw new ContentCreationException( "Entry-Name is not valid" ); } final ZipContentItem item = new ZipContentItem( name, repository, this ); entries.put( name, item ); return item; }
public ContentLocation createLocation( final String name ) throws ContentCreationException { if ( entries.containsKey( name ) ) { throw new ContentCreationException( "Entry already exists" ); } if ( RepositoryUtilities.isInvalidPathName( name ) ) { throw new ContentCreationException( "Entry-Name is not valid" ); } final ZipContentLocation item = new ZipContentLocation( repository, this, name ); entries.put( name, item ); if ( "/".equals( this.contentId ) == false ) { try { final ZipEntry entry = new ZipEntry( contentId + name + '/' ); repository.writeDirectory( entry ); } catch ( IOException e ) { throw new ContentCreationException( "Failed to create directory.", e ); } } return item; }
/** * 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." ); } final File file = getBackend(); final File child = new File( file, name ); if ( child.exists() ) { throw new ContentCreationException( "File already exists." ); } if ( child.mkdir() == false ) { throw new ContentCreationException( "Unable to create the directory" ); } try { return new FileContentLocation( this, child ); } catch ( ContentIOException e ) { throw new ContentCreationException( "Failed to create the content-location", e ); } }
/** * Creates a new data item 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 ContentItem createItem( final String name ) throws ContentCreationException { if ( RepositoryUtilities.isInvalidPathName( name ) ) { throw new IllegalArgumentException( "The name given is not valid." ); } final File file = getBackend(); final File child = new File( file, name ); if ( child.exists() ) { if ( child.length() == 0 ) { // probably one of the temp files created by the pentaho-system return new FileContentItem( this, child ); } throw new ContentCreationException( "File already exists: " + child ); } try { if ( child.createNewFile() == false ) { throw new ContentCreationException( "Unable to create the file." ); } return new FileContentItem( this, child ); } catch ( IOException e ) { throw new ContentCreationException( "IOError while create", e ); } }
/** * Creates a new data item 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 ContentItem createItem( final String name ) throws ContentCreationException { final WrappedInputStream in = repository.getInputStream(); final WrappedOutputStream outputStream = repository.getOutputStream(); if ( in != null && contentItem == null ) { this.contentItem = new StreamContentItem( repository.getContentName(), this, in, outputStream ); } if ( contentItem == null && outputStream != null ) { contentItem = new StreamContentItem( name, this, in, outputStream ); return contentItem; } throw new ContentCreationException ( "Failed to create the item. Item already exists or the repository is read-only" ); }