public Repository getRepository( final String repoId ) throws NoSuchRepositoryException { final Map<String, Repository> repositories = getRepositoriesMap(); if ( repositories.containsKey( repoId ) ) { return repositories.get( repoId ); } else { throw new NoSuchRepositoryException( repoId ); } }
public <T> T getRepositoryWithFacet( final String repoId, final Class<T> f ) throws NoSuchRepositoryException { final Repository r = getRepository( repoId ); if ( r.getRepositoryKind().isFacetAvailable( f ) ) { return r.adaptToFacet( f ); } else { throw new NoSuchRepositoryException( repoId ); } }
throw new NoSuchRepositoryException( id );
protected Repository getRepositoryForPathPrefixOrId( String pathPrefixOrId, Class<? extends Repository> kind ) throws NoSuchRepositoryException { List<? extends Repository> repositories = repositoryRegistry.getRepositoriesWithFacet( kind ); Repository idMatched = null; Repository pathPrefixMatched = null; for ( Repository repository : repositories ) { if ( StringUtils.equals( repository.getId(), pathPrefixOrId ) ) { idMatched = repository; } if ( StringUtils.equals( repository.getPathPrefix(), pathPrefixOrId ) ) { pathPrefixMatched = repository; } } if ( idMatched != null ) { // id wins return idMatched; } if ( pathPrefixMatched != null ) { // if no id found, prefix wins return pathPrefixMatched; } // nothing found throw new NoSuchRepositoryException( "pathPrefixOrId: '" + pathPrefixOrId + "'" ); }