private ContentLocator gunzipContentLocator(StorageFileItem item) throws IOException { try (InputStream in = item.getInputStream()) { ByteArrayInputStream gzipped = IOUtil.toGunzipped(in); return new PreparedContentLocator(gzipped, "application/x-marshal-ruby", gzipped.available()); } }
public static void storeItem(final Repository repository, final ResourceStoreRequest request, final InputStream in, final String mimeType, final Map<String, String> userAttributes) throws Exception { final DefaultStorageFileItem fItem = new DefaultStorageFileItem(repository, request, true, true, new PreparedContentLocator(in, mimeType, ContentLocator.UNKNOWN_LENGTH)); if (userAttributes != null) { fItem.getRepositoryItemAttributes().putAll(userAttributes); } repository.storeItem(false, fItem); }
private StorageItem storeSpecsIndex(SpecsIndexZippedFile file, InputStream content) throws Exception { ByteArrayOutputStream gzipped = new ByteArrayOutputStream(); try (OutputStream out = new GZIPOutputStream(gzipped)) { IOUtil.copy(content, out); } ContentLocator cl = new PreparedContentLocator(new ByteArrayInputStream(gzipped.toByteArray()), "application/x-gzip", gzipped.size()); DefaultStorageFileItem item = new DefaultStorageFileItem(repository, new ResourceStoreRequest(file.storagePath()), true, true, cl); repository.storeItem(false, item); return item; }
/** * Store repository item. * * @param repository containing item to be stored * @param path of item to be stored * @param content of item to be stored * @param mimeType of item to be stored */ private static void storeItem(final Repository repository, final String path, final byte[] content, final String mimeType) throws Exception { log.debug("Storing {}:{}", repository.getId(), path); DefaultStorageFileItem item = new DefaultStorageFileItem( repository, new ResourceStoreRequest("/" + path), true, true, new PreparedContentLocator(new ByteArrayInputStream(content), mimeType, ContentLocator.UNKNOWN_LENGTH) ); repository.storeItem(false, item); }
public StorageItem newStorageItem(RubygemsFile file, InputStream is){ ResourceStoreRequest request = new ResourceStoreRequest(file.storagePath()); ContentLocator contentLocator = new PreparedContentLocator(is, file.type().mime(), ContentLocator.UNKNOWN_LENGTH); return new DefaultStorageFileItem(repository, request, true, true, contentLocator); } }
public void storeItem( ResourceStoreRequest request, InputStream is, Map<String, String> userAttributes ) throws UnsupportedStorageOperationException, IllegalOperationException, StorageException, AccessDeniedException { if ( !checkConditions( request, getResultingActionOnWrite( request ) ) ) { throw new AccessDeniedException( request, "Operation does not fills needed requirements!" ); } DefaultStorageFileItem fItem = new DefaultStorageFileItem( this, request, true, true, new PreparedContentLocator( is, getMimeSupport().guessMimeTypeFromPath( getMimeRulesSource(), request.getRequestPath() ) ) ); if ( userAttributes != null ) { fItem.getRepositoryItemAttributes().putAll( userAttributes ); } storeItem( false, fItem ); }
new DefaultStorageFileItem( repository, path, true, true, new PreparedContentLocator( fis, mimeUtil.getMimeType( file ) ) );
new DefaultStorageFileItem( repository, request, CAN_READ, CAN_WRITE, new PreparedContentLocator( is, mimeType ) );
@Override public void update(InputStream is, RubygemsFile file) { log.debug("update :: {}", file); ResourceStoreRequest request = new ResourceStoreRequest(file.storagePath()); ContentLocator contentLocator = new PreparedContentLocator(is, file.type().mime(), ContentLocator.UNKNOWN_LENGTH); DefaultStorageFileItem fileItem = new DefaultStorageFileItem(repository, request, true, true, contentLocator); try { // we need to bypass access control here !!! repository.storeItem(false, fileItem); file.set(fileItem); } catch (IOException | UnsupportedStorageOperationException | IllegalOperationException e) { file.setException(e); } }
private void memory(InputStream data, RubygemsFile file, long length) { ContentLocator cl = new PreparedContentLocator(data, file.type().mime(), length); file.set(new DefaultStorageFileItem(repository, new ResourceStoreRequest(file.storagePath()), true, false, cl)); }
private StorageItem mergeDependency(DependencyFile file, List<StorageItem> dependencies) throws Exception { log.debug("mergeDependency :: {} :: {}", file, dependencies); DependencyHelper deps = gateway.newDependencyHelper(); for (StorageItem item : dependencies) { try (InputStream is = ((StorageFileItem) item).getInputStream()) { deps.add(is); } } ContentLocator cl = new PreparedContentLocator(deps.getInputStream(true), file.type().mime(), PreparedContentLocator.UNKNOWN_LENGTH); DefaultStorageFileItem item = new DefaultStorageFileItem(repository, new ResourceStoreRequest(file.storagePath()), true, true, cl); repository.storeItem(false, item); return item; }
final StorageFileItem remoteMirrorsItem = getMirrorsItemRemote(mirrorsURL); final ContentLocator content = new PreparedContentLocator(((StorageFileItem) remoteMirrorsItem).getInputStream(), "text/xml", remoteMirrorsItem.getLength()); mirrorsItem =
new DefaultStorageFileItem( repository, request, true, true, new PreparedContentLocator( new HttpClientInputStream( get, is ), mimeType ) );
new DefaultStorageFileItem( this, to, true, true, new PreparedContentLocator( ( (StorageFileItem) item ).getInputStream(), ( (StorageFileItem) item ).getMimeType() ) );
PreparedContentLocator contentLocator = new PreparedContentLocator( ris, response.getContentType() );