@Deprecated public DefaultStorageFileItem( RepositoryRouter router, String path, boolean canRead, boolean canWrite, ContentLocator contentLocator ) { this( router, new ResourceStoreRequest( path, true, false ), canRead, canWrite, contentLocator ); }
static StorageItem retrieveItem(final Repository repository, final String path) throws Exception { final ResourceStoreRequest request = new ResourceStoreRequest(path); final StorageItem item = repository.retrieveItem(request); return item; }
@Deprecated public void addToNotFoundCache( String path ) { addToNotFoundCache( new ResourceStoreRequest( path ) ); }
@Deprecated public void removeFromNotFoundCache( String path ) { removeFromNotFoundCache( new ResourceStoreRequest( path ) ); }
private AbstractStorageItem getStorageItem( final String path, final boolean localOnly ) throws IOException { try { return repository.getLocalStorage().retrieveItem( repository, new ResourceStoreRequest( path, localOnly ) ); } catch ( ItemNotFoundException e ) { throw new IOException( "Item not found!", e ); } }
private void storeItemFromFile(final String path, final File file, final P2ProxyRepository repository) throws LocalStorageException, UnsupportedStorageOperationException { final ContentLocator content = new FileContentLocator(file, "text/xml"); final DefaultStorageFileItem storageItem = new DefaultStorageFileItem(repository, new ResourceStoreRequest(path), true /* isReadable */, false /* isWritable */, content); repository.getLocalStorage().storeItem(repository, storageItem); } }
private StorageItem setup(RubygemsFile file) throws Exception { ResourceStoreRequest req = new ResourceStoreRequest(file.storagePath()); // TODO is synchronized really needed synchronized (repository) { List<StorageItem> items = repository.doRetrieveItems(req); if (items.size() == 1) { return items.get(0); } return store(file, items); } }
public void writeRawData( String path, byte[] data ) throws Exception { DefaultStorageFileItem file = new DefaultStorageFileItem( repository, new ResourceStoreRequest( path ), true, true, new ByteArrayContentLocator( data, "text/xml" ) ); repository.storeItem( false, file ); lastWriteFile = file; }
private ResourceStoreRequest createResourceStoreRequest( final StorageCollectionItem item, final DeleteOperation operation ) { ResourceStoreRequest request = new ResourceStoreRequest( item ); request.getRequestContext().put( DeleteOperation.DELETE_OPERATION_CTX_KEY, operation ); return request; }
@Override public void doDelete( WalkerContext ctx, StorageFileItem item ) throws StorageException, UnsupportedStorageOperationException, IllegalOperationException, ItemNotFoundException { MavenRepository repository = (MavenRepository) getRepository( ctx ); repository.deleteItemWithChecksums( false, new ResourceStoreRequest( item ) ); }
@Override public boolean exists( String path ) throws IOException { return repository.getLocalStorage().containsItem( repository, new ResourceStoreRequest( path, true ) ); }
protected void doDelete( WalkerContext ctx, StorageFileItem item ) throws StorageException, UnsupportedStorageOperationException, IllegalOperationException, ItemNotFoundException { getRepository( ctx ).deleteItem( false, new ResourceStoreRequest( item ) ); }
private ResourceStoreRequest createResourceStoreRequest( final StorageItem item, final WalkerContext ctx ) { ResourceStoreRequest request = new ResourceStoreRequest( item ); if ( ctx.getContext().containsKey( DeleteOperation.DELETE_OPERATION_CTX_KEY ) ) { request.getRequestContext().put( DeleteOperation.DELETE_OPERATION_CTX_KEY, ctx.getContext().get( DeleteOperation.DELETE_OPERATION_CTX_KEY ) ); } return request; }
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 ); }
@Override public void retrieve(BundlerApiFile file) { try { log.debug("retrieve :: {}", file); file.set(repository.retrieveDirectItem(new ResourceStoreRequest(file.remotePath(), false, false))); } catch (IOException | IllegalOperationException | ItemNotFoundException e) { file.setException(e); } }
protected ResourceStoreRequest getResourceStoreRequest( ServletRequest request, boolean localOnly ) { ResourceStoreRequest rsr = new ResourceStoreRequest( getResourceStorePath( request ), localOnly ); rsr.getRequestContext().put( RequestContext.CTX_AUTH_CHECK_ONLY, true ); return rsr; }
@Override public void retrieve(BundlerApiFile file) { try { // mimic request as coming directly to ProxyRepository repository.doRetrieveItems(new ResourceStoreRequest(file.remotePath())); file.set(null); } catch (GroupItemNotFoundException | IOException e) { file.setException(e); } }
protected StorageItem retrieveVirtualPath( ResourceStoreRequest request, RequestRoute route ) throws ItemNotFoundException { ResourceStoreRequest req = new ResourceStoreRequest( route.getOriginalRequestPath() ); DefaultStorageCollectionItem result = new DefaultStorageCollectionItem( this, req, true, false ); result.getItemContext().putAll( request.getRequestContext() ); return result; }
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 StorageItem dereferenceLink( StorageLinkItem link, boolean localOnly, boolean remoteOnly ) throws AccessDeniedException, ItemNotFoundException, IllegalOperationException, StorageException { logger.debug( "Dereferencing link {}", link.getTarget() ); ResourceStoreRequest req = new ResourceStoreRequest( link.getTarget().getPath(), localOnly, remoteOnly ); req.getRequestContext().setParentContext( link.getItemContext() ); return link.getTarget().getRepository().retrieveItem( req ); }