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 ); } } }
@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 Reasoning buildReasoning(final Throwable ex) { if (ex instanceof ItemNotFoundException) { final ItemNotFoundReason reason = ((ItemNotFoundException) ex).getReason(); if (reason instanceof ItemNotFoundInRepositoryReason) { return buildReasoning(((ItemNotFoundInRepositoryReason) reason).getRepository().getId(), ex); } } return null; }
@Override public GroupRepository getRepository() { return (GroupRepository) super.getRepository(); }
@SuppressWarnings("deprecation") @Override public void storeItem(ResourceStoreRequest request, InputStream is, Map<String, String> userAttributes) throws UnsupportedStorageOperationException, IllegalOperationException, StorageException, AccessDeniedException { RubygemsFile file = facade.file(request.getRequestPath()); if (file == null) { throw new UnsupportedStorageOperationException("only gem-files can be stored"); } request.setRequestPath(file.storagePath()); // first check permissions, i.e. is redeploy allowed try { checkConditions(request, getResultingActionOnWrite(request)); } catch (ItemNotFoundException e) { throw new AccessDeniedException(request, e.getMessage()); } // now store the gem facade.handleMutation(this, facade.post(is, file)); }
@Override public ProxyRepository getRepository() { return (ProxyRepository) super.getRepository(); } }
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; }
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)); }
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 ); } } }
@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))); } }
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; }
/** * 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)); } } }
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); }
throw new ItemNotFoundException(reasonFor(request, repository, e.getMessage()));
@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 ); }
throw new ItemNotFoundException(reasonFor(request, "View provider keyed \"%s\" did not provide content.", key));
throw new ItemNotFoundException( request, repository );
throw new ItemNotFoundException( ItemNotFoundException.reasonFor(new ResourceStoreRequest(file.remotePath()), repository, "Can not serve path %s for repository %s", file.storagePath(), RepositoryStringUtils.getHumanizedNameString(repository)));
throw new ItemNotFoundException( request, repository );
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 ); } }