@Override public void store( String content, String path ) throws IOException { ContentLocator contentLocator = new StringContentLocator( content ); putStorageItem( path, contentLocator ); }
public StringContentLocator( String content, String mimeType ) { super( toByteArray( content ), StringUtils.isBlank( mimeType ) ? "text/plain" : mimeType ); this.content = content; }
result = new StringContentLocator( body.replace( "@rootUrl@", appRootUrl ) ); result = new StringContentLocator( body.replace( "@rootUrl@", "" ) ); item.setLength( result.getByteArray().length );
protected void writeMetadata( RepositoryItemUid uid, Map<String, Object> ctx, Metadata md ) throws IllegalOperationException, UnsupportedStorageOperationException, MetadataException, IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); MetadataBuilder.write( md, outputStream ); String mdString = outputStream.toString( "UTF-8" ); outputStream.close(); DefaultStorageFileItem file = new DefaultStorageFileItem( uid.getRepository(), new ResourceStoreRequest( uid.getPath() ), true, true, new StringContentLocator( mdString ) ); ( (MavenRepository) uid.getRepository() ).storeItemWithChecksums( false, file ); }
private void createVirtualYumConfigFile(final MavenRepository repository) { DefaultStorageFileItem file = new DefaultStorageFileItem( repository, new ResourceStoreRequest(YumConfigContentGenerator.configFilePath(repository.getId())), true, false, new StringContentLocator(YumConfigContentGenerator.ID) ); file.setContentGeneratorId(YumConfigContentGenerator.ID); try { repository.storeItem(false, file); } catch (Exception e) { LOG.warn("Could not install yum.repo file '{}' due to {}/{}", file, e.getClass().getName(), e.getMessage()); } }
@Override public ContentLocator generateContent( Repository repository, String path, StorageFileItem item ) throws IllegalOperationException, ItemNotFoundException, LocalStorageException { InputStreamReader isr = null; try { StringWriter sw = new StringWriter(); VelocityContext vctx = new VelocityContext( item.getItemContext() ); isr = new InputStreamReader( item.getInputStream(), "UTF-8" ); velocity.getEngine().evaluate( vctx, sw, item.getRepositoryItemUid().toString(), isr ); return new StringContentLocator( sw.toString() ); } catch ( Exception e ) { throw new LocalStorageException( "Could not expand the template: " + item.getRepositoryItemUid().toString(), e ); } finally { IOUtil.close( isr ); } } }
final DefaultStorageFileItem file = new DefaultStorageFileItem(repository, new ResourceStoreRequest(ARCHETYPE_PATH), true, false, new StringContentLocator(ArchetypeContentGenerator.ID)); file.setContentGeneratorId(ArchetypeContentGenerator.ID); repository.storeItem(false, file);
storeItem( fromTask, new DefaultStorageFileItem( this, req, true, true, new StringContentLocator( sha1Hash ) ) ); storeItem( fromTask, new DefaultStorageFileItem( this, req, true, true, new StringContentLocator( md5Hash ) ) );
storeItem( false, new DefaultStorageFileItem( this, request, true, true, new StringContentLocator( sha1Hash ) ) ); storeItem( false, new DefaultStorageFileItem( this, request, true, true, new StringContentLocator( md5Hash ) ) );
new DefaultStorageFileItem( getMavenRepository(), req, true, true, new StringContentLocator( sha1Hash ) ) ); new DefaultStorageFileItem( getMavenRepository(), req, true, true, new StringContentLocator( md5Hash ) ) );
new DefaultStorageFileItem( getMavenRepository(), request, true, true, new StringContentLocator( sha1Hash ) ) ); new DefaultStorageFileItem( getMavenRepository(), request, true, true, new StringContentLocator( md5Hash ) ) );