public static File getBaseDir(Repository repository) throws URISyntaxException, MalformedURLException { String localUrl = repository.getLocalUrl(); if (isFile(localUrl)) { return new File(localUrl); } return new File(new URL(localUrl).toURI()); }
if ( repository.getLocalUrl() != null && repository.getLocalStorage() instanceof DefaultFSLocalRepositoryStorage ) URL url = new URL( repository.getLocalUrl() ); try repoRoot = new File( repository.getLocalUrl() );
public void cleanRepositoryFolders( final Repository repository, boolean deleteForever ) throws IOException { File defaultStorageFolder = new File( new File( getApplicationConfiguration().getWorkingDirectory(), "storage" ), repository.getId() ); String defaultStorageURI = defaultStorageFolder.toURI().toURL().toString(); defaultStorageURI = defaultStorageURI.endsWith( "/" ) ? defaultStorageURI : defaultStorageURI + "/"; String localURI = repository.getLocalUrl(); localURI = localURI.endsWith( "/" ) ? localURI : localURI + "/"; boolean defaultLocation = defaultStorageURI.equals( localURI ); // we do this _only_ if storage is not user-customized if ( defaultLocation ) { delete( defaultStorageFolder, deleteForever ); } } }
throws LocalStorageException StringBuilder urlStr = new StringBuilder( repository.getLocalUrl() );
@Nullable private File getRepositoryLocalStorageFile(final Repository repository, final String path) { if (repository.getLocalUrl() != null && repository.getLocalStorage() instanceof DefaultFSLocalRepositoryStorage) { try { return ((DefaultFSLocalRepositoryStorage) repository.getLocalStorage()) .getBaseDir(repository, new ResourceStoreRequest(path)); } catch (LocalStorageException e) { log.warn("Cannot get {} file from {} repository's LS", path, repository.getId(), e); } } return null; } }
/** * Extracts the repo root on local FS as File. It may return null! */ protected File getRepositoryLocalStorageAsFile(Repository repository) { if (repository.getLocalUrl() != null && repository.getLocalStorage() instanceof DefaultFSLocalRepositoryStorage) { try { File baseDir = ((DefaultFSLocalRepositoryStorage) repository.getLocalStorage()).getBaseDir(repository, new ResourceStoreRequest(RepositoryItemUid.PATH_ROOT)); return baseDir; } catch (LocalStorageException e) { log.warn(String.format("Cannot determine \"%s\" (ID=%s) repository's basedir:", repository.getName(), repository.getId()), e); } } return null; }
static File localStorageOfRepositoryAsFile(final Repository repository) throws LocalStorageException { if (repository.getLocalUrl() != null && repository.getLocalStorage() instanceof DefaultFSLocalRepositoryStorage) { final File baseDir = ((DefaultFSLocalRepositoryStorage) repository.getLocalStorage()).getBaseDir(repository, new ResourceStoreRequest( RepositoryItemUid.PATH_ROOT)); return baseDir; } throw new LocalStorageException(String.format("Repository [%s] does not have an local storage", repository.getId())); }
public Collection<GAV> resolveDependencies(GAV artifact) throws IOException { Collection<GAV> artifactDependencies = new ArrayList<GAV>(); ArtifactDescriptorRequest descriptorRequest = new ArtifactDescriptorRequest(); descriptorRequest.setArtifact(new DefaultArtifact(artifact.toString())); for (Repository repo : this.repositoryRegistry.getRepositories()) { if (repo.getLocalUrl() != null) { descriptorRequest.addRepository(new RemoteRepository(repo .getId(), "default", repo.getLocalUrl())); } } try { ArtifactDescriptorResult descriptorResult = this .getRepositorySystem().readArtifactDescriptor( this.getRepositorySession(), descriptorRequest); for (org.sonatype.aether.graph.Dependency dependency : descriptorResult .getDependencies()) { getLogger().debug("{} depends on {}", artifact, dependency.getArtifact()); artifactDependencies.add(new GAV(dependency.getArtifact() .getGroupId(), dependency.getArtifact().getArtifactId(), dependency .getArtifact().getVersion())); } } catch (ArtifactDescriptorException e) { throw new IOException(e); } return artifactDependencies; }
repoRes.setEffectiveLocalStorageUrl(repository.getLocalUrl());
repoRes.setEffectiveLocalStorageUrl( repository.getLocalUrl() );