@Override public boolean isReachable( final ProxyRepository repository, final ResourceStoreRequest request ) throws RemoteStorageException { boolean result = false; try { request.pushRequestPath( RepositoryItemUid.PATH_ROOT ); try { result = checkRemoteAvailability( 0, repository, request, false ); } catch ( RemoteAccessDeniedException e ) { return true; } } finally { request.popRequestPath(); } return result; }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { ResourceStoreRequest request = findRequest(args); if (request != null) { // rewrite path, but only for scope of remote storage RubygemsFile file = facade.file(request.getRequestPath()); request.pushRequestPath(file.remotePath()); } try { return method.invoke(remoteStorage, args); } catch (InvocationTargetException e) { throw e.getCause(); // unwrap and throw the real exception } finally { if (request != null) { request.popRequestPath(); } } }
@Override public void storeItem(ResourceStoreRequest request, InputStream is, Map<String, String> userAttributes) throws UnsupportedStorageOperationException, IllegalOperationException, StorageException, AccessDeniedException { // collapse any '.' or '..' segments from the path request.pushRequestPath(normalize(request.getRequestPath())); try { super.storeItem(request, is, userAttributes); } finally { request.popRequestPath(); } }
public Collection<StorageItem> list( ResourceStoreRequest request ) throws ItemNotFoundException, IllegalOperationException, StorageException, AccessDeniedException { RequestRoute route = getRequestRouteForRequest( request ); if ( route.isRepositoryHit() ) { // it hits a repository, mangle path and call it Collection<StorageItem> items; try { request.pushRequestPath( route.getRepositoryPath() ); items = route.getTargetedRepository().list( request ); } finally { request.popRequestPath(); } ArrayList<StorageItem> result = new ArrayList<StorageItem>( items.size() ); for ( StorageItem item : items ) { result.add( mangle( true, request, route, item ) ); } return result; } else { // this is "above" repositories return listVirtualPath( request, route ); } }
request.popRequestPath(); request.popRequestPath();
@Override public AbstractStorageItem retrieveItem(final Repository repository, final ResourceStoreRequest request) throws ItemNotFoundException, LocalStorageException { if (!request.getRequestPath().startsWith("/.nexus")) { RubygemsFile file = fileSystem.file(request); if (file.type() == FileType.BUNDLER_API || file.type() == FileType.DEPENDENCY) { request.pushRequestPath(file.storagePath()); try { return super.retrieveItem(repository, request); } finally { request.popRequestPath(); } } } return super.retrieveItem(repository, request); }
@Override public boolean containsItem(final Repository repository, final ResourceStoreRequest request) throws LocalStorageException { if (!request.getRequestPath().startsWith("/.nexus")) { RubygemsFile file = fileSystem.file(request); if (file.type() == FileType.BUNDLER_API || file.type() == FileType.DEPENDENCY) { request.pushRequestPath(file.storagePath()); try { return super.containsItem(repository, request); } finally { request.popRequestPath(); } } } return super.containsItem(repository, request); } }
request.popRequestPath(); request.popRequestPath();
remoteStoreRequest.popRequestPath();
try request.popRequestPath();
public StorageItem retrieveItem( ResourceStoreRequest request ) throws ItemNotFoundException, IllegalOperationException, StorageException, AccessDeniedException { RequestRoute route = getRequestRouteForRequest( request ); if ( route.isRepositoryHit() ) { // it hits a repository, mangle path and call it StorageItem item; try { request.pushRequestPath( route.getRepositoryPath() ); item = route.getTargetedRepository().retrieveItem( request ); } finally { request.popRequestPath(); } return mangle( false, request, route, item ); } else { // this is "above" repositories return retrieveVirtualPath( request, route ); } }
public void storeItem( ResourceStoreRequest request, InputStream is, Map<String, String> userAttributes ) throws UnsupportedStorageOperationException, ItemNotFoundException, IllegalOperationException, StorageException, AccessDeniedException { RequestRoute route = getRequestRouteForRequest( request ); if ( route.isRepositoryHit() ) { // it hits a repository, mangle path and call it try { request.pushRequestPath( route.getRepositoryPath() ); route.getTargetedRepository().storeItem( request, is, userAttributes ); } finally { request.popRequestPath(); } } else { // this is "above" repositories throw new IllegalRequestException( request, "The path '" + request.getRequestPath() + "' does not points to any repository!" ); } }
public void deleteItem( ResourceStoreRequest request ) throws UnsupportedStorageOperationException, ItemNotFoundException, IllegalOperationException, StorageException, AccessDeniedException { RequestRoute route = getRequestRouteForRequest( request ); if ( route.isRepositoryHit() ) { // it hits a repository, mangle path and call it try { request.pushRequestPath( route.getRepositoryPath() ); route.getTargetedRepository().deleteItem( request ); } finally { request.popRequestPath(); } } else { // this is "above" repositories throw new IllegalRequestException( request, "The path '" + request.getRequestPath() + "' does not points to any repository!" ); } }
public TargetSet getTargetsForRequest( ResourceStoreRequest request ) { TargetSet result = new TargetSet(); try { RequestRoute route = getRequestRouteForRequest( request ); if ( route.isRepositoryHit() ) { // it hits a repository, mangle path and call it try { request.pushRequestPath( route.getRepositoryPath() ); result.addTargetSet( route.getTargetedRepository().getTargetsForRequest( request ) ); } finally { request.popRequestPath(); } } } catch ( ItemNotFoundException e ) { // nothing, empty set will be returned } return result; }
public void createCollection( ResourceStoreRequest request, Map<String, String> userAttributes ) throws UnsupportedStorageOperationException, ItemNotFoundException, IllegalOperationException, StorageException, AccessDeniedException { RequestRoute route = getRequestRouteForRequest( request ); if ( route.isRepositoryHit() ) { // it hits a repository, mangle path and call it try { request.pushRequestPath( route.getRepositoryPath() ); route.getTargetedRepository().createCollection( request, userAttributes ); } finally { request.popRequestPath(); } } else { // this is "above" repositories throw new IllegalRequestException( request, "The path '" + request.getRequestPath() + "' does not points to any repository!" ); } }