return this.getUebTopicSource(topicName);
case DMAAP:
return this.getDmaapTopicSource(topicName);
- case REST:
default:
throw new UnsupportedOperationException("Unsupported " + commType.name());
}
return this.getDmaapTopicSink(topicName);
case NOOP:
return this.getNoopTopicSink(topicName);
- case REST:
default:
throw new UnsupportedOperationException("Unsupported " + commType.name());
}
final List<String> sinkTopicList =
new ArrayList<>(Arrays.asList(sinkTopics.split("\\s*,\\s*")));
- final List<NoopTopicSink> newSinks = new ArrayList<NoopTopicSink>();
+ final List<NoopTopicSink> newSinks = new ArrayList<>();
synchronized (this) {
for (final String topic : sinkTopicList) {
if (this.noopTopicSinks.containsKey(topic)) {
@Override
public NoopTopicSink build(List<String> servers, String topic, boolean managed) {
- if (servers == null) {
- servers = new ArrayList<>();
+
+ List<String> noopSinkServers = servers;
+ if (noopSinkServers == null) {
+ noopSinkServers = new ArrayList<>();
}
- if (servers.isEmpty()) {
- servers.add("noop");
+ if (noopSinkServers.isEmpty()) {
+ noopSinkServers.add("noop");
}
if (topic == null || topic.isEmpty()) {
return this.noopTopicSinks.get(topic);
}
- final NoopTopicSink sink = new NoopTopicSink(servers, topic);
+ final NoopTopicSink sink = new NoopTopicSink(noopSinkServers, topic);
if (managed)
this.noopTopicSinks.put(topic, sink);
* UEB Topic Name Index
*/
protected HashMap<String, UebTopicSink> uebTopicSinks =
- new HashMap<String, UebTopicSink>();
+ new HashMap<>();
@Override
public UebTopicSink build(List<String> servers,
String readTopics = properties.getProperty(PolicyProperties.PROPERTY_UEB_SOURCE_TOPICS);
if (readTopics == null || readTopics.isEmpty()) {
logger.info("{}: no topic for UEB Source", this);
- return new ArrayList<UebTopicSource>();
+ return new ArrayList<>();
}
List<String> readTopicList = new ArrayList<>(Arrays.asList(readTopics.split("\\s*,\\s*")));
logger.debug("DMaaP consumer received {} : {}" + response.getResponseCode(),
response.getResponseMessage());
- if (response.getResponseCode() == null || !response.getResponseCode().equals("200")) {
+ if (response.getResponseCode() == null || !"200".equals(response.getResponseCode())) {
logger.error("DMaaP consumer received: {} : {}", response.getResponseCode(),
response.getResponseMessage());
props.setProperty("contenttype", "application/json");
if (additionalProps != null) {
- for (final String key : additionalProps.keySet())
- props.put(key, additionalProps.get(key));
+ for (Map.Entry<String, String> entry : additionalProps.entrySet())
+ props.put(entry.getKey(), entry.getValue());
}
MRClientFactory.prop = props;
/**
* MR based Publisher
*/
- protected MRSimplerBatchPublisher publisher;
-
public DmaapAafPublisherWrapper(List<String> servers, String topic,
String aafLogin,
String aafPassword, boolean useHttps) {
this.password = password;
this.selfSignedCerts = selfSignedCerts;
- StringBuffer tmpBaseUrl = new StringBuffer();
+ StringBuilder tmpBaseUrl = new StringBuilder();
if (this.https) {
tmpBaseUrl.append("https://");
ClientBuilder clientBuilder;
return hostname;
}
+ @Override
public int getPort() {
return port;
}
/**
* Container for servlets
*/
- protected HashMap<String, ServletHolder> servlets = new HashMap<String, ServletHolder>();
+ protected HashMap<String, ServletHolder> servlets = new HashMap<>();
/**
* Swagger ID
@Override
public synchronized void addServletPackage(String servletPath, String restPackage) {
-
+ String servPath = servletPath;
if (restPackage == null || restPackage.isEmpty())
throw new IllegalArgumentException("No discoverable REST package provided");
- if (servletPath == null || servletPath.isEmpty())
- servletPath = "/*";
+ if (servPath == null || servPath.isEmpty())
+ servPath = "/*";
- ServletHolder jerseyServlet = this.getServlet(servletPath);
+ ServletHolder jerseyServlet = this.getServlet(servPath);
String initClasses =
jerseyServlet.getInitParameter(JERSEY_INIT_CLASSNAMES_PARAM_NAME);
* @throws IllegalArgumentException if invalid parameters are passed in
*/
public JettyServletServer(String name, String host, int port, String contextPath) {
-
- if (name == null || name.isEmpty())
- name = "http-" + port;
+ String srvName = name;
+ String srvHost = host;
+ String ctxtPath = contextPath;
+
+ if (srvName == null || srvName.isEmpty())
+ srvName = "http-" + port;
if (port <= 0 && port >= 65535)
throw new IllegalArgumentException("Invalid Port provided: " + port);
- if (host == null || host.isEmpty())
- host = "localhost";
+ if (srvHost == null || srvHost.isEmpty())
+ srvHost = "localhost";
- if (contextPath == null || contextPath.isEmpty())
- contextPath = "/";
+ if (ctxtPath == null || ctxtPath.isEmpty())
+ ctxtPath = "/";
- this.name = name;
+ this.name = srvName;
- this.host = host;
+ this.host = srvHost;
this.port = port;
- this.contextPath = contextPath;
+ this.contextPath = ctxtPath;
this.context = new ServletContextHandler(ServletContextHandler.SESSIONS);
- this.context.setContextPath(contextPath);
+ this.context.setContextPath(ctxtPath);
this.jettyServer = new Server();
this.jettyServer.setRequestLog(new Slf4jRequestLog());
this.connector = new ServerConnector(this.jettyServer);
- this.connector.setName(name);
+ this.connector.setName(srvName);
this.connector.setReuseAddress(true);
this.connector.setPort(port);
- this.connector.setHost(host);
+ this.connector.setHost(srvHost);
this.jettyServer.addConnector(this.connector);
this.jettyServer.setHandler(context);
@Override
public void setBasicAuthentication(String user, String password, String servletPath) {
- if (user == null || user.isEmpty() || password == null || password.isEmpty())
+ String srvltPath = servletPath;
+
+ if (user == null || user.isEmpty() || password == null || password.isEmpty())
throw new IllegalArgumentException("Missing user and/or password");
- if (servletPath == null || servletPath.isEmpty())
- servletPath = "/*";
+ if (srvltPath == null || srvltPath.isEmpty())
+ srvltPath = "/*";
HashLoginService hashLoginService = new HashLoginService();
hashLoginService.putUser(user,
ConstraintMapping constraintMapping = new ConstraintMapping();
constraintMapping.setConstraint(constraint);
- constraintMapping.setPathSpec(servletPath);
+ constraintMapping.setPathSpec(srvltPath);
ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler();
securityHandler.setAuthenticator(new BasicAuthenticator());