use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class AbstractContentManagementTest method getPhysicalStorageFile.
protected File getPhysicalStorageFile(Location location, String path) {
String homeDir = fixture.getBootOptions().getHomeDir();
String storageDir = "var/lib/indy/storage";
StoreKey storeKey = ((KeyedLocation) location).getKey();
File ret = cacheProvider.asAdminView().getDetachedFile(new ConcreteResource(location, path));
// if ( !isPathMappedStorageEnabled() )
// {
// ret = Paths.get( homeDir, storageDir, storeKey.getPackageType(),
// storeKey.getType().singularEndpointName() + "-" + storeKey.getName(), path ).toFile();
// }
// else
// {
// ret = ( (PathMappedCacheProvider) cacheProvider ).getDetachedFile( new ConcreteResource( location, path ) );
// }
logger.debug("Get physical storage file: {}", ret);
return ret;
}
use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class DeleteHostedRepoWithContentTest method run.
@Test
public void run() throws Exception {
final HostedRepository repo = new HostedRepository(MAVEN_PKG_KEY, "build_perftest-20200229T021845");
final StoreKey key = repo.getKey();
final HostedRepository result = client.stores().create(repo, name.getMethodName(), HostedRepository.class);
assertThat(result.getName(), equalTo(repo.getName()));
assertThat(result.equals(repo), equalTo(true));
// Store files
client.content().store(repo.getKey(), path_1, new ByteArrayInputStream(content.getBytes()));
client.content().store(repo.getKey(), path_2, new ByteArrayInputStream(content.getBytes()));
ConcreteResource r1 = new ConcreteResource(LocationUtils.toLocation(repo), path_1);
ConcreteResource r2 = new ConcreteResource(LocationUtils.toLocation(repo), path_2);
// Verify files exist
assertTrue(cacheProvider.exists(r1));
assertTrue(cacheProvider.exists(r2));
// Delete repo with deleteContent flag
client.stores().delete(key, "Delete", true);
assertThat(client.stores().exists(key), equalTo(false));
// Verify files were deleted
assertFalse(cacheProvider.exists(r1));
assertFalse(cacheProvider.exists(r2));
}
use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class DeleteGroupWithContentTest method run.
@Test
@Category(EventDependent.class)
public void run() throws Exception {
// Create hosted repo
final HostedRepository repo = new HostedRepository(MAVEN_PKG_KEY, "test_1");
assertThat(client.stores().create(repo, name.getMethodName(), HostedRepository.class), notNullValue());
// Store pom file in hosted repo
client.content().store(repo.getKey(), pomPath, new ByteArrayInputStream(pomContent.getBytes()));
// Generate metadata file in hosted repo
try (InputStream in = client.content().get(repo.getKey(), metadataPath)) {
IOUtils.toString(in);
}
// Verify the hosted meta file exists
ConcreteResource r_meta_hosted = new ConcreteResource(LocationUtils.toLocation(repo), metadataPath);
assertTrue(cacheProvider.exists(r_meta_hosted));
// Create group with hosted member
final Group group = new Group(MAVEN_PKG_KEY, "test_1", repo.getKey());
assertThat(client.stores().create(group, name.getMethodName(), Group.class), notNullValue());
// Generate group metadata file
try (InputStream in = client.content().get(group.getKey(), metadataPath)) {
IOUtils.toString(in);
}
// Verify the group meta file exists
ConcreteResource r_meta = new ConcreteResource(LocationUtils.toLocation(group), metadataPath);
assertTrue(cacheProvider.exists(r_meta));
// Delete group
client.stores().delete(group.getKey(), "Delete", true);
assertThat(client.stores().exists(group.getKey()), equalTo(false));
// Verify the group meta file gone
assertFalse(cacheProvider.exists(r_meta));
// Verify hosted files not change (delete group not affect the files in hosted repo)
ConcreteResource r1 = new ConcreteResource(LocationUtils.toLocation(repo), pomPath);
assertTrue(cacheProvider.exists(r1));
assertTrue(cacheProvider.exists(r_meta_hosted));
}
use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class FoloPomDownloadListener method onFileUpload.
public void onFileUpload(@Observes final FileStorageEvent event) {
// check for a TransferOperation of DOWNLOAD
final TransferOperation op = event.getType();
if (op != TransferOperation.DOWNLOAD) {
logger.trace("Not a download transfer operation. No pom existence check performed.");
return;
}
// check if it is a path that doesn't end in with ".pom"
final Transfer transfer = event.getTransfer();
if (transfer == null) {
logger.trace("No transfer. No pom existence check performed.");
return;
}
String txfrPath = transfer.getPath();
if (txfrPath.endsWith(".pom")) {
logger.trace("This is a pom download.");
return;
}
// use ArtifactPathInfo to parse into a GAV, just to verify that it's looking at an artifact download
ArtifactPathInfo artPathInfo = ArtifactPathInfo.parse(txfrPath);
if (artPathInfo == null) {
logger.trace("Not an artifact download ({}). No pom existence check performed.", txfrPath);
return;
}
// verify that the associated .pom file exists
String pomFilename = String.format("%s-%s.pom", artPathInfo.getArtifactId(), artPathInfo.getVersion());
ConcreteResource pomResource = transfer.getResource().getParent().getChild(pomFilename);
if (cacheProvider.exists(pomResource)) {
logger.trace("Pom {} already exists.", cacheProvider.getFilePath(pomResource));
return;
}
// trigger pom download by requesting it from the same repository as the original artifact
StoreKey storeKey = StoreKey.fromString(transfer.getLocation().getName());
ArtifactStore store;
try {
store = storeManager.getArtifactStore(storeKey);
} catch (final IndyDataException ex) {
logger.error("Error retrieving artifactStore with key " + storeKey, ex);
return;
}
try {
logger.debug("Downloading POM as automatic response to associated artifact download: {}/{}", storeKey, pomResource.getPath());
contentManager.retrieve(store, pomResource.getPath(), event.getEventMetadata());
} catch (final IndyWorkflowException ex) {
logger.error("Error while retrieving pom artifact " + pomResource.getPath() + " from store " + store, ex);
return;
}
}
use of org.commonjava.maven.galley.model.ConcreteResource in project indy by Commonjava.
the class ScheduleDBManager method setProxyTimeouts.
public void setProxyTimeouts(final StoreKey key, final String path) throws IndySchedulerException {
if (!schedulerConfig.isEnabled()) {
logger.debug("Scheduler disabled.");
return;
}
RemoteRepository repo = null;
try {
repo = (RemoteRepository) dataManager.getArtifactStore(key);
} catch (final IndyDataException e) {
logger.error(String.format("Failed to retrieve store for: %s. Reason: %s", key, e.getMessage()), e);
}
if (repo == null) {
return;
}
int timeout = config.getPassthroughTimeoutSeconds();
final ConcreteResource resource = new ConcreteResource(LocationUtils.toLocation(repo), path);
final SpecialPathInfo info = specialPathManager.getSpecialPathInfo(resource, key.getPackageType());
if (!repo.isPassthrough()) {
if ((info != null && info.isMetadata()) && repo.getMetadataTimeoutSeconds() >= 0) {
if (repo.getMetadataTimeoutSeconds() == 0) {
logger.debug("Using default metadata timeout for: {}", resource);
timeout = config.getRemoteMetadataTimeoutSeconds();
} else {
logger.debug("Using metadata timeout for: {}", resource);
timeout = repo.getMetadataTimeoutSeconds();
}
} else {
if (info == null) {
logger.debug("No special path info for: {}", resource);
} else {
logger.debug("{} is a special path, but not metadata.", resource);
}
timeout = repo.getCacheTimeoutSeconds();
}
}
if (timeout > 0) {
// logger.info( "[PROXY TIMEOUT SET] {}/{}; {}", repo.getKey(), path, new Date( System.currentTimeMillis()
// + timeout ) );
scheduleContentExpiration(key, path, timeout);
}
}
Aggregations