Java Code Examples for org.sonatype.nexus.repository.routing.RoutingRule#name()

The following examples show how to use org.sonatype.nexus.repository.routing.RoutingRule#name() . 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: RoutingRulesResource.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@PUT
@Path("/{name}")
@RequiresAuthentication
@RequiresPermissions("nexus:*")
public void updateRoutingRule(@PathParam("name") final String name, RoutingRuleXO routingRuleXO) {
  RoutingRule routingRule = routingRuleStore.getByName(name);
  if (null == routingRule) {
    throw new WebApplicationException(Status.NOT_FOUND);
  }
  routingRule.name(routingRuleXO.getName());
  routingRule.description(routingRuleXO.getDescription());
  routingRule.mode(routingRuleXO.getMode());
  routingRule.matchers(routingRuleXO.getMatchers());
  routingRuleStore.update(routingRule);
}
 
Example 2
Source File: RoutingRulesResource.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
private RoutingRule fromXO(RoutingRuleXO routingRuleXO) {
  final RoutingRule routingRule = routingRuleStore.newRoutingRule();
  routingRule.name(routingRuleXO.getName());
  routingRule.description(routingRuleXO.getDescription());
  routingRule.mode(routingRuleXO.getMode());
  routingRule.matchers(routingRuleXO.getMatchers());
  return routingRule;
}
 
Example 3
Source File: SimpleApiRepositoryAdapter.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
protected String getRoutingRuleName(final Repository repository) {
  EntityId routingRuleId = repository.getConfiguration().getRoutingRuleId();
  if (routingRuleId == null) {
    return null;
  }
  RoutingRule routingRule = routingRuleStore.getById(routingRuleId.getValue());
  return routingRule != null ? routingRule.name() : null;
}
 
Example 4
Source File: RoutingRulesApiResource.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Override
@POST
@RequiresAuthentication
@RequiresPermissions("nexus:*")
public void createRoutingRule(@NotNull final RoutingRuleXO routingRuleXO)
{
  final RoutingRule routingRule = routingRuleStore.newRoutingRule();
  routingRule.name(routingRuleXO.getName());
  routingRule.description(routingRuleXO.getDescription());
  routingRule.mode(routingRuleXO.getMode());
  routingRule.matchers(routingRuleXO.getMatchers());

  routingRuleStore.create(routingRule);
}
 
Example 5
Source File: OrientRoutingRuleStoreTest.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testUpdate_duplicateName() throws Exception {
  underTest.start();
  createRoutingRule("dup", "bar");
  RoutingRule routingRule = createRoutingRule("foo", "bar");
  routingRule.name("dup");
  thrown.expect(ValidationErrorsException.class);
  thrown.expectMessage("A rule with the same name already exists. Name must be unique.");
  underTest.update(routingRule);
}
 
Example 6
Source File: OrientRoutingRuleStoreTest.java    From nexus-public with Eclipse Public License 1.0 5 votes vote down vote up
@Test(expected = ValidationErrorsException.class)
public void testValidate_onUpdate() throws Exception {
  underTest.start();
  RoutingRule rule = null;
  try {
    rule = createRoutingRule("name", "asdf");
    rule.name("a   a");
  }
  catch (Exception e) {
    fail("Unexpected exception occurred");
  }

  underTest.update(rule);
}