public boolean removeMapping( String id ) { for ( Iterator<CPathMappingItem> i = getCurrentConfiguration( true ).getPathMappings().iterator(); i.hasNext(); ) { CPathMappingItem mapping = i.next(); if ( mapping.getId().equals( id ) ) { i.remove(); return true; } } return false; }
public CPathMappingItem getRoute(String id) throws IOException { List<CPathMappingItem> routes = getNexusConfig().getRepositoryGrouping().getPathMappings(); for (Iterator<CPathMappingItem> iter = routes.iterator(); iter.hasNext(); ) { CPathMappingItem groupsSettingPathMappingItem = iter.next(); if (groupsSettingPathMappingItem.getId().equals(id)) { return groupsSettingPathMappingItem; } } return null; }
protected RepositoryPathMapping convert( CPathMappingItem item ) throws IllegalArgumentException { MappingType type = null; if ( CPathMappingItem.BLOCKING_RULE_TYPE.equals( item.getRouteType() ) ) { type = MappingType.BLOCKING; } else if ( CPathMappingItem.INCLUSION_RULE_TYPE.equals( item.getRouteType() ) ) { type = MappingType.INCLUSION; } else if ( CPathMappingItem.EXCLUSION_RULE_TYPE.equals( item.getRouteType() ) ) { type = MappingType.EXCLUSION; } else { logger.warn( "Unknown route type: " + item.getRouteType() ); throw new IllegalArgumentException( "Unknown route type: " + item.getRouteType() ); } return new RepositoryPathMapping( item.getId(), type, item.getGroupId(), item.getRoutePatterns(), item.getRepositories() ); }
if ( StringUtils.isEmpty( item.getId() ) || "0".equals( item.getId() ) || ( context.getExistingPathMappingIds() != null && context.getExistingPathMappingIds().contains( item.getId() ) ) ) response.addValidationWarning( "Fixed wrong route ID from '" + item.getId() + "' to '" + newId + "'" ); + item.getId() + "'." ); response.addValidationError( "The Route with ID='" + item.getId() + "' must contain at least one Route Pattern." ); response.addValidationError( "The regexp in Route with ID='" + item.getId() + "' is not valid: " + regexp ); context.getExistingPathMappingIds().add( item.getId() ); && !CPathMappingItem.BLOCKING_RULE_TYPE.equals( item.getRouteType() ) ) response.addValidationError( "The groupMapping pattern with ID=" + item.getId() + " have invalid routeType='" + item.getRouteType() + "'. Valid route types are '" + CPathMappingItem.INCLUSION_RULE_TYPE + "', '" + CPathMappingItem.EXCLUSION_RULE_TYPE + "' and '" response.addValidationError( "The groupMapping pattern with ID=" + item.getId() + " refers to a nonexistent repository with repoID = " + repoId );
if ( StringUtils.isEmpty( item.getId() ) || "0".equals( item.getId() ) || ( context.getExistingPathMappingIds() != null && context.getExistingPathMappingIds().contains( item.getId() ) ) ) response.addValidationWarning( "Fixed wrong route ID from '" + item.getId() + "' to '" + newId + "'" ); + item.getId() + "'." ); response.addValidationError( "The Route with ID='" + item.getId() + "' must contain at least one Route Pattern." ); response.addValidationError( "The regexp in Route with ID='" + item.getId() + "' is not valid: " + regexp ); context.getExistingPathMappingIds().add( item.getId() ); && !CPathMappingItem.BLOCKING_RULE_TYPE.equals( item.getRouteType() ) ) response.addValidationError( "The groupMapping pattern with ID=" + item.getId() + " have invalid routeType='" + item.getRouteType() + "'. Valid route types are '" + CPathMappingItem.INCLUSION_RULE_TYPE + "', '" + CPathMappingItem.EXCLUSION_RULE_TYPE + "' and '" response.addValidationError( "The groupMapping pattern with ID=" + item.getId() + " refers to a nonexistent repository with repoID = " + repoId );
public void validateRoutesConfig(RepositoryRouteResource resource) throws IOException { CPathMappingItem cRoute = getTest().getNexusConfigUtil().getRoute(resource.getId()); String msg = "Should be the same route. \n Expected:\n" + new XStream().toXML(resource) + " \n \n Got: \n" + new XStream().toXML(cRoute); Assert.assertEquals(msg, cRoute.getId(), resource.getId()); Assert.assertEquals(msg, cRoute.getGroupId(), resource.getGroupId()); Assert.assertEquals(msg, cRoute.getRoutePatterns(), Collections.singletonList(resource.getPattern())); Assert.assertEquals(msg, cRoute.getRouteType(), resource.getRuleType()); this.validateSameRepoIds(resource.getRepositories(), cRoute.getRepositories()); }