@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 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)); }
/** * 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))); } }
throw new ItemNotFoundException(reasonFor(request, repository, e.getMessage()));
throw new ItemNotFoundException(reasonFor(request, "View provider keyed \"%s\" did not provide content.", key));
ItemNotFoundException.reasonFor(new ResourceStoreRequest(file.remotePath()), repository, "Can not serve path %s for repository %s", file.storagePath(), RepositoryStringUtils.getHumanizedNameString(repository)));