@Override public void onHandle(final Repository repository, final ResourceStoreRequest request, final Action action) throws ItemNotFoundException, IllegalOperationException { if (request.getRequestPath().matches("/" + Yum.PATH_OF_REPODATA + "/.*\\.sqlite\\.bz2")) { throw new ItemNotFoundException( ItemNotFoundException.reasonFor(request, repository, "Yum sqlite metadata databases are not supported") ); } }
private DefaultStorageFileItem doRetriveRemoteChecksumItem( ProxyRepository proxy, ResourceStoreRequest request ) throws ItemNotFoundException { try { return (DefaultStorageFileItem) proxy.getRemoteStorage().retrieveItem( proxy, request, proxy.getRemoteUrl() ); } catch ( RemoteAccessException e ) { throw new ItemNotFoundException( request, proxy, e ); } catch ( RemoteStorageException e ) { throw new ItemNotFoundException( request, proxy, e ); } } }
public Collection<StorageItem> list( ResourceStoreRequest request ) throws IllegalOperationException, ItemNotFoundException, StorageException, AccessDeniedException { if ( !checkConditions( request, Action.read ) ) { throw new ItemNotFoundException( request, this ); } Collection<StorageItem> items = null; if ( isBrowseable() ) { items = list( false, request ); } else { throw new ItemNotFoundException( request, this ); } return items; }
protected StorageItem doRetrieveItemFromMaster( final ResourceStoreRequest request ) throws IllegalOperationException, ItemNotFoundException, StorageException { try { return getMasterRepository().retrieveItem( request ); } catch ( AccessDeniedException e ) { // if client has no access to content over shadow, we just hide the fact throw new ItemNotFoundException( request, this, e ); } } }
public StorageItem retrieveItem( ResourceStoreRequest request ) throws IllegalOperationException, ItemNotFoundException, StorageException, AccessDeniedException { if ( !checkConditions( request, Action.read ) ) { throw new ItemNotFoundException( request, this ); } StorageItem item = retrieveItem( false, request ); if ( StorageCollectionItem.class.isAssignableFrom( item.getClass() ) && !isBrowseable() ) { getLogger().debug( getId() + " retrieveItem() :: FOUND a collection on " + request.toString() + " but repository is not Browseable." ); throw new ItemNotFoundException( request, this ); } if ( !checkPostConditions( request, item ) ) { throw new ItemNotFoundException( request, this ); } return item; }
protected AbstractStorageItem doRetrieveLocalItem(final ResourceStoreRequest request, final E repository) throws LocalStorageException, ItemNotFoundException { if (repository.getLocalStorage() != null) { final AbstractStorageItem localItem = repository.getLocalStorage().retrieveItem(repository, request); return localItem; } throw new ItemNotFoundException(request, repository); }
private StorageFileItem getMirrorsItemRemote(final String mirrorsURL) throws MalformedURLException, RemoteAccessException, RemoteStorageException, ItemNotFoundException { final URL url = new URL(mirrorsURL); final ResourceStoreRequest request = new ResourceStoreRequest(url.getFile()); final String baseUrl = getBaseMirrorsURL(url); final AbstractStorageItem mirrorsItem = getRemoteStorage().retrieveItem(this, request, baseUrl); if (mirrorsItem instanceof StorageFileItem) { return (StorageFileItem) mirrorsItem; } throw new ItemNotFoundException( ItemNotFoundException.reasonFor(request, this, "URL %s does not contain valid mirrors", mirrorsURL)); }
@Override protected StorageItem doRetrieveItem( ResourceStoreRequest request ) throws IllegalOperationException, ItemNotFoundException, StorageException { if ( !shouldServeByPolicies( request ) ) { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "The serving of item " + request.toString() + " is forbidden by Maven repository policy." ); } throw new ItemNotFoundException( request, this ); } return super.doRetrieveItem( request ); }
public Gav resolveArtifact( ArtifactStoreRequest gavRequest ) throws IllegalOperationException, ItemNotFoundException, StorageException, AccessDeniedException { checkRequest( gavRequest ); try { Gav gav = repository.getMetadataManager().resolveArtifact( gavRequest ); if ( gav == null ) { throw new ItemNotFoundException( gavRequest, repository ); } return gav; } catch ( IOException e ) { throw new LocalStorageException( "Could not maintain metadata!", e ); } }
setRemoteStatus( RemoteStatus.UNAVAILABLE, new ItemNotFoundException( request, AbstractProxyRepository.this ) ); autoBlockProxying( new ItemNotFoundException( request, AbstractProxyRepository.this ) );
@Override protected StorageItem doRetrieveItem(final ResourceStoreRequest request) throws IllegalOperationException, ItemNotFoundException, StorageException { fixRemoteUrl(request); if (P2Constants.SITE_XML.equals(request.getRequestPath())) { throw new ItemNotFoundException(request, this); } if (AbstractP2MetadataSource.isP2MetadataItem(request.getRequestPath())) { if (!isItemValid(P2Constants.SITE_XML)) { UpdateSiteMirrorTask.submit(scheduler, this, false); } } return super.doRetrieveItem(request); }
/** * Dereferences the passed in link completely (following link-to-links too) as long as non-link item is found as * target. This method will detect cycles, and will fail if such link constellation is found. If any target during * dereference is not found, the usual {@link ItemNotFoundException} will be thrown (by the method used to * dereference). */ protected StorageItem dereferenceLink(final StorageLinkItem link) throws Exception { final List<String> hops = Lists.newArrayList(); StorageLinkItem currentLink = link; while (true) { final String hop = currentLink.getRepositoryItemUid().getKey(); if (!hops.contains(hop)) { hops.add(hop); final StorageItem item = repositoryRouter.dereferenceLink(currentLink); if (!(item instanceof StorageLinkItem)) { return item; } else { currentLink = (StorageLinkItem) item; } } else { // cycle detected, current link already processed throw new ItemNotFoundException(ItemNotFoundException.reasonFor(link.getResourceStoreRequest(), link .getRepositoryItemUid().getRepository(), "Link item %s introduced a cycle while referencing it, cycle is %s", link.getRepositoryItemUid(), hops)); } } }
@SuppressWarnings("deprecation") public StorageItem retrieveDirectItem(ResourceStoreRequest request) throws IllegalOperationException, ItemNotFoundException, IOException { for (Repository repo : getMemberRepositories()) { try { return repo.retrieveItem(false, request); } catch (ItemNotFoundException e) { // ignore } } throw new ItemNotFoundException(reasonFor(request, this, "Could not find content for path %s in local storage of repository %s", request.getRequestPath(), RepositoryStringUtils.getHumanizedNameString(this))); } }
@Override protected StorageItem doRetrieveItem(final ResourceStoreRequest request) throws IllegalOperationException, ItemNotFoundException, StorageException { final String requestPath = request.getRequestPath(); log.debug("Repository " + getId() + ": doRetrieveItem:" + requestPath); if (P2Constants.ARTIFACT_MAPPINGS_XML.equals(requestPath)) { if (getLocalStorage() == null) { throw new ItemNotFoundException(request); } final StorageItem item = getLocalStorage().retrieveItem(this, request); return item; } final StorageItem item; try { item = metadataSource.doRetrieveItem(request, this); } catch (IOException e) { throw new StorageException(e); } if (item != null) { return item; } // note this method can potentially go retrieve new mirrors, but it is using locking, so no // need to worry about multiples getting in configureMirrors(request); return super.doRetrieveItem(request); }
public Collection<StorageItem> list( boolean fromTask, ResourceStoreRequest request ) throws IllegalOperationException, ItemNotFoundException, StorageException { if ( getLogger().isDebugEnabled() ) { getLogger().debug( getId() + ".list() :: " + request.toString() ); } if ( !getLocalStatus().shouldServiceRequest() ) { throw new RepositoryNotAvailableException( this ); } request.addProcessedRepository( this ); StorageItem item = retrieveItem( fromTask, request ); if ( item instanceof StorageCollectionItem ) { return list( fromTask, (StorageCollectionItem) item ); } else { throw new ItemNotFoundException( request, this ); } }
public InputStream retrieve(String name) throws IOException { TaskUtil.checkInterruption(); ResourceStoreRequest req = new ResourceStoreRequest(PUBLISHING_PATH_PREFIX + "/" + name); try { StorageFileItem item = null; // XXX: ensure it goes to remote only and throws FileNotFoundException if nothing found on remote // kinda turn off transparent proxying for this method // We need to use ProxyRepository and get it's RemoteStorage stuff to completely // avoid "transparent" proxying, and even the slightest possibility to return // some stale file from cache to the updater. if (ISPROXY(repository) && REMOTEACCESSALLOWED(repository)) { item = (StorageFileItem) repository.getRemoteStorage() .retrieveItem(repository, req, repository.getRemoteUrl()); } else { throw new ItemNotFoundException(req, repository); } return item.getInputStream(); } catch (ItemNotFoundException ex) { final FileNotFoundException fne = new FileNotFoundException(name + " (remote item not found)"); fne.initCause(ex); throw fne; } } });
throw new ItemNotFoundException( request, this );
throw new ItemNotFoundException(reasonFor(request, repository, e.getMessage()));
throw new ItemNotFoundException(reasonFor(request, "View provider keyed \"%s\" did not provide content.", key));
throw new ItemNotFoundException( ItemNotFoundException.reasonFor(new ResourceStoreRequest(file.remotePath()), repository, "Can not serve path %s for repository %s", file.storagePath(),