Java Code Examples for org.sonatype.nexus.repository.Repository#getConfiguration()

The following examples show how to use org.sonatype.nexus.repository.Repository#getConfiguration() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RoutingRuleCacheTest.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void invalidateRepoCacheOnUpdate() throws Exception {
  mockRule("rule-a");
  Repository repository = createRepository("repo-a", "rule-a");

  // prime the cache
  assertNotNull(routingRuleCache.getRoutingRule(repository));

  // Clear the cache
  routingRuleCache.handle(new RepositoryUpdatedEvent(repository, null));

  // update the assigned rule
  RoutingRule rule = mockRule("rule-b");
  Configuration configuration = repository.getConfiguration();
  when(configuration.getRoutingRuleId()).thenReturn(new DetachedEntityId("rule-b"));

  assertThat(routingRuleCache.getRoutingRule(repository), is(rule));
}
 
Example 2
Source File: RoutingRuleCacheTest.java    From nexus-public with Eclipse Public License 1.0 6 votes vote down vote up
@Test
public void invalidateRepoCacheOnDelete() throws Exception {
  mockRule("rule-a");
  Repository repository = createRepository("repo-a", "rule-a");

  // prime the cache
  assertNotNull(routingRuleCache.getRoutingRule(repository));

  // Clear the cache
  routingRuleCache.handle(new RepositoryDeletedEvent(repository));

  // update the assigned rule
  RoutingRule rule = mockRule("rule-b");
  Configuration configuration = repository.getConfiguration();
  when(configuration.getRoutingRuleId()).thenReturn(new DetachedEntityId("rule-b"));

  assertThat(routingRuleCache.getRoutingRule(repository), is(rule));
}
 
Example 3
Source File: MavenITSupport.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Nonnull
protected Repository redirectProxy(final String repositoryName, final String remoteUrl) throws Exception {
  checkNotNull(repositoryName);
  Repository proxy = repositoryManager.get(repositoryName);
  checkNotNull(proxy);
  checkArgument(ProxyType.NAME.equals(proxy.getType().getValue()));
  org.sonatype.nexus.repository.config.Configuration proxyConfiguration = proxy.getConfiguration();
  proxyConfiguration.attributes("proxy").set("remoteUrl", remoteUrl);
  proxyConfiguration.attributes(STORAGE).set(STRICT_CONTENT_TYPE_VALIDATION, true);
  return repositoryManager.update(proxyConfiguration);
}
 
Example 4
Source File: GenericRepositoryITSupport.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Sets the content max age and metadata max age on a proxy repository.
 */
protected void setContentAndMetadataMaxAge(final Repository proxyRepository,
                                           final int contentMaxAge,
                                           final int metadataMaxAge) throws Exception
{
  Configuration configuration = proxyRepository.getConfiguration();
  configuration.attributes("proxy").set("contentMaxAge", Integer.toString(contentMaxAge));
  configuration.attributes("proxy").set("metadataMaxAge", Integer.toString(metadataMaxAge));
  repositoryManager.update(configuration);
}
 
Example 5
Source File: RepositoryManagerImpl.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
@Guarded(by = STARTED)
public void delete(final String name) throws Exception {
  checkNotNull(name);
  freezeService.checkWritable("Unable to delete repository when database is frozen.");

  log.info("Deleting repository: {}", name);

  Repository repository = repository(name);
  Configuration configuration = repository.getConfiguration();

  removeRepositoryFromAllGroups(repository);

  repository.stop();
  repository.delete();
  repository.destroy();

  if (!EventHelper.isReplicating()) {
    store.delete(configuration);
  }

  untrack(repository);

  eventManager.post(new RepositoryDeletedEvent(repository));

  log.info("Deleted repository: {}", name);
}
 
Example 6
Source File: SimpleApiRepositoryAdapter.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
protected CleanupPolicyAttributes getCleanupPolicyAttributes(final Repository repository) {
  Configuration configuration = repository.getConfiguration();
  if (!configuration.getAttributes().containsKey("cleanup")) {
    return null;
  }

  Collection<String> policyNames =
      configuration.attributes("cleanup").get("policyName", new TypeToken<Collection<String>>()
      {
      }, Collections.emptyList());

  return new CleanupPolicyAttributes(policyNames);
}
 
Example 7
Source File: P2RoutingRuleITSupport.java    From nexus-repository-p2 with Eclipse Public License 1.0 4 votes vote down vote up
protected void attachRuleToRepository(final Repository repository, final EntityId routingRuleId) throws Exception {
  org.sonatype.nexus.repository.config.Configuration configuration = repository.getConfiguration();
  configuration.setRoutingRuleId(routingRuleId);
  repositoryManager.update(configuration);
}
 
Example 8
Source File: HelmRoutingRuleIT.java    From nexus-repository-helm with Eclipse Public License 1.0 4 votes vote down vote up
private void attachRuleToRepository(final Repository repository, final EntityId routingRuleId) throws Exception {
  org.sonatype.nexus.repository.config.Configuration configuration = repository.getConfiguration();
  configuration.setRoutingRuleId(routingRuleId);
  repositoryManager.update(configuration);
}
 
Example 9
Source File: RRoutingRuleITSupport.java    From nexus-repository-r with Eclipse Public License 1.0 4 votes vote down vote up
protected void attachRuleToRepository(final Repository repository, final EntityId routingRuleId) throws Exception {
  org.sonatype.nexus.repository.config.Configuration configuration = repository.getConfiguration();
  configuration.setRoutingRuleId(routingRuleId);
  repositoryManager.update(configuration);
}
 
Example 10
Source File: ConanRoutingRuleIT.java    From nexus-repository-conan with Eclipse Public License 1.0 4 votes vote down vote up
private void attachRuleToRepository(final Repository repository, final EntityId routingRuleId) throws Exception {
  org.sonatype.nexus.repository.config.Configuration configuration = repository.getConfiguration();
  configuration.setRoutingRuleId(routingRuleId);
  repositoryManager.update(configuration);
}