@Test public void testWithoutServerName() { ServerNameRequiredMatch serverNameMatch = new ServerNameRequiredMatch("server1"); try { serverNameMatch.validate(new PrivilegeValidatorContext("connector=c1->action=read")); Assert.fail("Expected ConfigurationException"); } catch (ConfigurationException ex) { } }
@Override public void validate(PrivilegeValidatorContext context) throws ConfigurationException { Iterable<SqoopAuthorizable> authorizables = parsePrivilege(context.getPrivilege()); boolean match = false; for (SqoopAuthorizable authorizable : authorizables) { if (authorizable instanceof Server && authorizable.getName().equalsIgnoreCase(sqoopServerName)) { match = true; break; } } if (!match) { String msg = "server=[name] in " + context.getPrivilege() + " is required. The name is expected " + sqoopServerName; throw new ConfigurationException(msg); } }
ServerNameRequiredMatch implements PrivilegeValidator { @Override public void validate(PrivilegeValidatorContext context) throws ConfigurationException { Iterable<SqoopAuthorizable> authorizables = parsePrivilege(context.getPrivilege()); boolean match = false; for (SqoopAuthorizable authorizable : authorizables) { if (authorizable instanceof Server && authorizable.getName().equalsIgnoreCase(sqoopServerName)) { match = true; break; } } if (!match) { String msg = "server=[name] in " + context.getPrivilege() + " is required. The name is expected " + sqoopServerName; throw new ConfigurationException(msg); } } }
ServerNameRequiredMatch implements PrivilegeValidator { @Override public void validate(PrivilegeValidatorContext context) throws ConfigurationException { Iterable<SqoopAuthorizable> authorizables = parsePrivilege(context.getPrivilege()); boolean match = false; for (SqoopAuthorizable authorizable : authorizables) { if (authorizable instanceof Server && authorizable.getName().equalsIgnoreCase(sqoopServerName)) { match = true; break; } } if (!match) { String msg = "server=[name] in " + context.getPrivilege() + " is required. The name is expected " + sqoopServerName; throw new ConfigurationException(msg); } } ServerNameRequiredMatch(String sqoopServerName); }
ServerNameRequiredMatch implements PrivilegeValidator { @Override public void validate(PrivilegeValidatorContext context) throws ConfigurationException { Iterable<SqoopAuthorizable> authorizables = parsePrivilege(context.getPrivilege()); boolean match = false; for (SqoopAuthorizable authorizable : authorizables) { if (authorizable instanceof Server && authorizable.getName().equalsIgnoreCase(sqoopServerName)) { match = true; break; } } if (!match) { String msg = "server=[name] in " + context.getPrivilege() + " is required. The name is expected " + sqoopServerName; throw new ConfigurationException(msg); } } ServerNameRequiredMatch(String sqoopServerName); @Override void validate(PrivilegeValidatorContext context); }
ServerNameRequiredMatch implements PrivilegeValidator { @Override public void validate(PrivilegeValidatorContext context) throws ConfigurationException { Iterable<SqoopAuthorizable> authorizables = parsePrivilege(context.getPrivilege()); boolean match = false; for (SqoopAuthorizable authorizable : authorizables) { if (authorizable instanceof Server && authorizable.getName().equalsIgnoreCase(sqoopServerName)) { match = true; break; } } if (!match) { String msg = "server=[name] in " + context.getPrivilege() + " is required. The name is expected " + sqoopServerName; throw new ConfigurationException(msg); } } ServerNameRequiredMatch(String sqoopServerName); @Override void validate(PrivilegeValidatorContext context);  }