</dependencies>
</plugin>
+ <!-- prevent SNAPSHOT dependencies -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>enforce-no-snapshots</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireReleaseDeps>
+ <message>No Snapshots Allowed!</message>
+ <excludes>
+ <exclude>org.onap.aaf.authz:aaf-cadi-client</exclude>
+ <exclude>org.onap.aaf.authz:aaf-misc-env</exclude>
+ <exclude>org.onap.aaf.authz:aaf-cadi-aaf</exclude>
+ <exclude>org.onap.aaf.authz:aaf-auth-client</exclude>
+ <exclude>org.onap.aaf.authz:aaf-cadi-core</exclude>
+ <exclude>org.onap.aaf.authz:aaf-misc-rosetta</exclude>
+ </excludes>
+ </requireReleaseDeps>
+ </rules>
+ <fail>true</fail>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
<pluginManagement>
<plugins>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
-<!-- for DMAAP-205, a point release on the common version
- addresses a security issue. Note the add notation here
- -->
- <version>${jackson.version}.1</version>
- </dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<artifactId>logback-classic</artifactId>
<version>1.2.0</version>
</dependency>
+<!-- DMAAP-656:
+ - override this dependency because it utilized a third party
+ - lib called com.google.guava:20.0 which had severe security threat identified.
+ -->
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>24.1.1-jre</version>
+ </dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
- <version>1.5.13</version>
+ <version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-jersey2-jaxrs</artifactId>
- <version>1.5.13</version>
+ <version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
- <version>1.5.13</version>
+ <version>${swagger.version}</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
- <version>1.6</version>
+ <version>1.11</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
<dependency>
</site>
</distributionManagement>
<properties>
- <jackson.version>2.8.11</jackson.version>
+ <swagger.version>1.5.19</swagger.version>
+ <jackson.version>2.9.5</jackson.version>
<jersey.version>2.26</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <jettyVersion>9.3.9.v20160517</jettyVersion>
+ <jettyVersion>9.3.8.RC0</jettyVersion>
<eelf.version>0.0.1</eelf.version>
- <artifact.version>1.0.14-SNAPSHOT</artifact.version>
+ <artifact.version>1.0.15-SNAPSHOT</artifact.version>
<!-- SONAR -->
<jacoco.version>0.7.7.201606060606</jacoco.version>
<sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>
import org.apache.commons.codec.binary.Base64;
import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
import org.onap.dmaap.dbcapi.logging.DmaapbcLogMessageEnum;
-import org.onap.dmaap.dbcapi.service.DmaapService;
import org.onap.dmaap.dbcapi.util.DmaapConfig;
public class AafConnection extends BaseLoggingClass {
-
-
+
+
private String aafCred;
private String unit_test;
-
+
private HttpsURLConnection uc;
unit_test = p.getProperty( "UnitTest", "No" );
}
-
+
private boolean makeConnection( String pURL ) {
-
+
try {
URL u = new URL( pURL );
uc = (HttpsURLConnection) u.openConnection();
uc.setInstanceFollowRedirects(false);
logger.info( "successful connect to " + pURL );
return(true);
- } catch ( UnknownHostException uhe ) {
+ } catch ( UnknownHostException uhe ) {
errorLogger.error(DmaapbcLogMessageEnum.UNKNOWN_HOST_EXCEPTION, pURL, uhe.getMessage() );
- uhe.printStackTrace();
+ logger.error("Error", uhe);
return(false);
} catch (Exception e) {
- errorLogger.error(DmaapbcLogMessageEnum.HTTP_CONNECTION_ERROR, pURL, e.getMessage() );
+ logger.error("Error", e);
+ errorLogger.error(DmaapbcLogMessageEnum.HTTP_CONNECTION_ERROR, pURL, e.getMessage());
e.printStackTrace();
return(false);
}
sb.append( line );
}
} catch (IOException ex ) {
- errorLogger.error( DmaapbcLogMessageEnum.IO_EXCEPTION, ex.getMessage());
+ errorLogger.error( DmaapbcLogMessageEnum.IO_EXCEPTION + ex.getMessage(),ex);
}
-
+
return sb.toString();
}
String auth = "Basic " + Base64.encodeBase64String(aafCred.getBytes());
int rc = -1;
-
+
if ( ! makeConnection( pURL ) ) {
return rc;
};
-
+
byte[] postData = obj.getBytes();
//logger.info( "post fields=" + postData ); //byte isn't very readable
os.write( postData );
} catch (ProtocolException pe) {
+ logger.error("Error", pe);
// Rcvd error instead of 100-Continue
try {
// work around glitch in Java 1.7.0.21 and likely others
// without this, Java will connect multiple times to the server to run the same request
uc.setDoOutput(false);
} catch (Exception e) {
+ logger.error("Error", e);
}
} catch ( SSLHandshakeException she ) {
+ logger.error("Error", she);
errorLogger.error( DmaapbcLogMessageEnum.SSL_HANDSHAKE_ERROR, pURL);
} catch ( UnknownHostException uhe ) {
+ logger.error("Error", uhe);
errorLogger.error(DmaapbcLogMessageEnum.UNKNOWN_HOST_EXCEPTION, pURL, uhe.getMessage() );
rc = 500;
return rc;
} catch ( ConnectException ce ) {
- if ( unit_test.equals( "Yes" ) ) {
+ logger.error("Error", ce);
+ if ( "Yes".equals(unit_test) ) {
rc = 201;
return rc;
}
try {
rc = uc.getResponseCode();
} catch ( SSLHandshakeException she ) {
+ logger.error("Error", she);
errorLogger.error( DmaapbcLogMessageEnum.SSL_HANDSHAKE_ERROR, pURL);
rc = 500;
return rc;
}
} catch (Exception e) {
- System.err.println("Unable to read response " );
- e.printStackTrace();
+ logger.error("Unable to read response ");
+ logger.error("Error", e);
}
finally {
try {
uc.disconnect();
- } catch ( Exception e ) {}
- }
- //return responseBody;
-
+ } catch ( Exception e ) {
+ logger.error("Error", e);
+ }
+ }
return rc;
}
os.write( postData );
} catch (ProtocolException pe) {
+ logger.error("Error", pe);
// Rcvd error instead of 100-Continue
try {
// work around glitch in Java 1.7.0.21 and likely others
// without this, Java will connect multiple times to the server to run the same request
uc.setDoOutput(false);
} catch (Exception e) {
+ logger.error("Error", e);
}
} catch ( SSLHandshakeException she ) {
- errorLogger.error( DmaapbcLogMessageEnum.SSL_HANDSHAKE_ERROR, pURL);
+ errorLogger.error( DmaapbcLogMessageEnum.SSL_HANDSHAKE_ERROR +"For:- "+pURL,she);
}
try {
rc = uc.getResponseCode();
} catch ( SSLHandshakeException she ) {
+ logger.error("Error", she);
errorLogger.error( DmaapbcLogMessageEnum.SSL_HANDSHAKE_ERROR, pURL);
rc = 500;
return rc;
}
} catch (Exception e) {
- System.err.println("Unable to read response " );
- e.printStackTrace();
- }
- //return responseBody;
-
+ logger.error("Unable to read response ");
+ logger.error("Error", e);
+ }
return rc;
}
dec = (DecryptionInterface) (Class.forName(dClass).newInstance());
dec.init( p.getProperty("CredentialCodecKeyfile", "LocalKey"));
} catch (Exception ee ) {
+ logger.error("Error", ee);
errorLogger.error(DmaapbcLogMessageEnum.UNEXPECTED_CONDITION, "attempting to instantiate " + dClass );
}
}
try {
pwd = dec.decrypt( encPwd );
} catch( IOException io ) {
+ logger.error("Error", io);
errorLogger.error(DmaapbcLogMessageEnum.DECRYPT_IO_ERROR, dClass, encPwd );
}
import org.onap.aaf.cadi.principal.UnAuthPrincipal;
import org.onap.aaf.misc.env.APIException;
import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
-import org.onap.dmaap.dbcapi.logging.DmaapbcLogMessageEnum;
-import org.onap.dmaap.dbcapi.util.DmaapConfig;
/*
* this service uses the AAF Lur object to lookup identities and perms
*/
public class AafLurService extends BaseLoggingClass {
+
+ static Logger logger = Logger.getLogger(AafLurService.class.getName());
private static AAFConHttp aafcon;
} catch ( CadiException | LocatorException e) {
appLogger.error( "Failure of AAFConHttp: " + e.getMessage() );
errorLogger.error( "Failure of AAFConHttp: " + e.getMessage() );
+ logger.error(e);
e.printStackTrace();
throw e;
}
} catch ( CadiException e) {
appLogger.error( "Failure of newLur(): " + e.getMessage() );
errorLogger.error( "Failure of newLur(): " + e.getMessage() );
+ logger.error(e);
e.printStackTrace();
throw e;
}
init( myAccess );
} catch (APIException | CadiException | LocatorException e) {
// TODO Auto-generated catch block
+ logger.error(e);
e.printStackTrace();
throw e;
}
return rc;
}
rc = aafLur.fish( principal, aafPerm );
- if (rc == true ) return rc;
+ boolean flag = true;
+ if (rc == flag ) {
+ return rc;
+ }
List<Permission> perms = new ArrayList<Permission>();
aafLur.fishAll( principal, perms);
import org.onap.aaf.misc.env.APIException;
import org.onap.dmaap.dbcapi.aaf.AafLurService;
import org.onap.dmaap.dbcapi.aaf.DmaapPerm;
-import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
-import org.onap.dmaap.dbcapi.server.Main;
import org.onap.dmaap.dbcapi.util.DmaapConfig;
AafLurAndFish() throws AuthenticationErrorException {
- String[] args = new String[1];
DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
api_namespace = p.getProperty( "ApiNamespace", "org.onap.dmaap-bc.api");
}
} catch ( IOException e ) {
logger.error( "Unable to load " + cadiprop );
+ logger.error("Error", e);
throw new AuthenticationErrorException( );
}
try {
PropAccess myAccess = new PropAccess( props );
svc = AafLurService.getInstance(myAccess);
- } catch (APIException | CadiException | LocatorException e ) {
+ } catch (APIException | CadiException | LocatorException e ) {
+ logger.error("Error", e);
logger.error( e.toString() );
throw new AuthenticationErrorException();
}
try {
boolean resp = svc.checkPerm( api_namespace, mechid, pwd, p );
- if ( resp == false ) {
+ boolean flag = false;
+ if ( resp == flag ) {
throw new AuthenticationErrorException();
}
} catch ( IOException | CadiException e ) {
+ logger.error("Error", e);
logger.error( e.toString() );
throw new AuthenticationErrorException();
}
import org.onap.dmaap.dbcapi.aaf.DmaapPerm;
+@FunctionalInterface
public interface ApiAuthorizationCheckInterface {
public void check( String mechid, String pwd, DmaapPerm p ) throws AuthenticationErrorException;
import org.onap.dmaap.dbcapi.util.DmaapConfig;
public class ApiPerms extends BaseLoggingClass {
+ static String topic = "topics";
+ static String mrClusters = "mr_clusters";
+ static String mrClients = "mr_clients";
+ static String feed = "feeds";
+ static String drSubs = "dr_subs";
+ static String drPubs = "dr_pubs";
+ static String drNodes = "dr_nodes";
+ static String dcaeLocations = "dcaeLocations";
+ static String inventory = "Inventory";
+ static String portalUser = "PortalUser";
+ static String orchestrator = "Orchestrator";
+ static String delete = "DELETE";
+ static String dmaap = "dmaap";
+ static String controller = "Controller";
private static class PermissionMap {
static final EELFLogger logger = EELFManager.getInstance().getLogger( PermissionMap.class );
String action;
String[] roles;
+ private PermissionMap( String u, String a, String[] r ) {
+ this.setUri(u);
+ this.setAction(a);
+ this.setRoles(r);
+ }
+
public String getUri() {
return uri;
}
this.roles = roles;
}
- private PermissionMap( String u, String a, String[] r ) {
- this.setUri(u);
- this.setAction(a);
- this.setRoles(r);
- }
-
- static public void initMap( PermissionMap[] pmap, String instance ) {
+ public static void initMap( PermissionMap[] pmap, String instance ) {
DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
String api = p.getProperty("ApiNamespace", "apiNamespace.not.set");
}
static PermissionMap[] bootMap = {
- new PermissionMap( "dmaap", "GET", new String[] { "Controller" }),
- new PermissionMap( "dmaap", "POST", new String[] { "Controller" }),
- new PermissionMap( "dmaap", "PUT", new String[] { "Controller" }),
- new PermissionMap( "dmaap", "DELETE", new String[] { "Controller" })
+ new PermissionMap( dmaap, "GET", new String[] { controller }),
+ new PermissionMap( dmaap, "POST", new String[] { controller }),
+ new PermissionMap( dmaap, "PUT", new String[] { controller }),
+ new PermissionMap( dmaap, delete, new String[] { controller })
};
static PermissionMap[] envMap = {
- new PermissionMap( "dmaap", "GET", new String[] { "Controller", "Orchestrator", "Inventory", "Metrics", "PortalUser" }),
- new PermissionMap( "dmaap", "POST", new String[] { "Controller" } ),
- new PermissionMap( "dmaap", "PUT", new String[] { "Controller" }),
- new PermissionMap( "dmaap", "DELETE", new String[] { "Controller" }),
+ new PermissionMap( dmaap, "GET", new String[] { controller, orchestrator, inventory, "Metrics", portalUser }),
+ new PermissionMap( dmaap, "POST", new String[] { controller } ),
+ new PermissionMap( dmaap, "PUT", new String[] { controller }),
+ new PermissionMap( dmaap, delete, new String[] { controller }),
new PermissionMap( "bridge", "GET", new String[] { "Metrics" }),
//new PermissionMap( "bridge", "POST", new String[] { "Metrics" } ),
//new PermissionMap( "bridge", "PUT", new String[] { "Metrics" }),
- //new PermissionMap( "bridge", "DELETE", new String[] { "Metrics" }),
- new PermissionMap( "dcaeLocations", "GET", new String[] { "Controller", "Orchestrator", "Inventory", "Metrics", "PortalUser" }),
- new PermissionMap( "dcaeLocations", "POST", new String[] { "Controller" } ),
- new PermissionMap( "dcaeLocations", "PUT", new String[] { "Controller" }),
- new PermissionMap( "dcaeLocations", "DELETE", new String[] { "Controller" }),
- new PermissionMap( "dr_nodes", "GET", new String[] { "Controller", "Orchestrator", "Inventory", "PortalUser" }),
- new PermissionMap( "dr_nodes", "POST", new String[] { "Controller" } ),
- new PermissionMap( "dr_nodes", "PUT", new String[] { "Controller" }),
- new PermissionMap( "dr_nodes", "DELETE", new String[] { "Controller" }),
- new PermissionMap( "dr_pubs", "GET", new String[] { "Controller", "Orchestrator", "Inventory", "Metrics", "PortalUser" }),
- new PermissionMap( "dr_pubs", "POST", new String[] { "Controller", "Orchestrator","PortalUser" } ),
- new PermissionMap( "dr_pubs", "PUT", new String[] { "Controller", "Orchestrator","PortalUser" }),
- new PermissionMap( "dr_pubs", "DELETE", new String[] { "Controller", "Orchestrator","PortalUser" }),
- new PermissionMap( "dr_subs", "GET", new String[] { "Controller", "Orchestrator", "Inventory", "Metrics", "PortalUser" }),
- new PermissionMap( "dr_subs", "POST", new String[] { "Controller", "Orchestrator","PortalUser" } ),
- new PermissionMap( "dr_subs", "PUT", new String[] { "Controller", "Orchestrator","PortalUser" }),
- new PermissionMap( "dr_subs", "DELETE", new String[] { "Controller", "Orchestrator","PortalUser" }),
- new PermissionMap( "feeds", "GET", new String[] { "Controller", "Orchestrator", "Inventory", "Metrics", "PortalUser" }),
- new PermissionMap( "feeds", "POST", new String[] { "Controller", "Orchestrator","PortalUser" } ),
- new PermissionMap( "feeds", "PUT", new String[] { "Controller", "Orchestrator", "PortalUser" }),
- new PermissionMap( "feeds", "DELETE", new String[] { "Controller", "PortalUser" }),
- new PermissionMap( "mr_clients", "GET", new String[] { "Controller", "Orchestrator", "Inventory", "Metrics", "PortalUser" }),
- new PermissionMap( "mr_clients", "POST", new String[] { "Controller","Orchestrator", "PortalUser" } ),
- new PermissionMap( "mr_clients", "PUT", new String[] { "Controller", "Orchestrator","PortalUser" }),
- new PermissionMap( "mr_clients", "DELETE", new String[] { "Controller","Orchestrator", "PortalUser" }),
- new PermissionMap( "mr_clusters", "GET", new String[] { "Controller", "Orchestrator", "Inventory", "Metrics", "PortalUser" }),
- new PermissionMap( "mr_clusters", "POST", new String[] { "Controller" } ),
- new PermissionMap( "mr_clusters", "PUT", new String[] { "Controller" }),
- new PermissionMap( "mr_clusters", "DELETE", new String[] { "Controller" }),
- new PermissionMap( "topics", "GET", new String[] { "Controller", "Orchestrator", "Inventory", "Metrics", "PortalUser" }),
- new PermissionMap( "topics", "POST", new String[] { "Controller", "Orchestrator" } ),
- new PermissionMap( "topics", "PUT", new String[] { "Controller", "Orchestrator" }),
- new PermissionMap( "topics", "DELETE", new String[] { "Controller", "Orchestrator" })
+ //new PermissionMap( "bridge", delete, new String[] { "Metrics" }),
+ new PermissionMap( dcaeLocations, "GET", new String[] { controller, orchestrator, inventory, "Metrics", portalUser }),
+ new PermissionMap( dcaeLocations, "POST", new String[] { controller } ),
+ new PermissionMap( dcaeLocations, "PUT", new String[] { controller }),
+ new PermissionMap( dcaeLocations, delete, new String[] { controller }),
+ new PermissionMap( drNodes, "GET", new String[] { controller, orchestrator, inventory, portalUser }),
+ new PermissionMap( drNodes, "POST", new String[] { controller } ),
+ new PermissionMap( drNodes, "PUT", new String[] { controller }),
+ new PermissionMap( drNodes, delete, new String[] { controller }),
+ new PermissionMap( drPubs, "GET", new String[] { controller, orchestrator, inventory, "Metrics", portalUser }),
+ new PermissionMap( drPubs, "POST", new String[] { controller, orchestrator,portalUser } ),
+ new PermissionMap( drPubs, "PUT", new String[] { controller, orchestrator,portalUser }),
+ new PermissionMap( drPubs, delete, new String[] { controller, orchestrator,portalUser }),
+ new PermissionMap( drSubs, "GET", new String[] { controller, orchestrator, inventory, "Metrics", portalUser }),
+ new PermissionMap( drSubs, "POST", new String[] { controller, orchestrator,portalUser } ),
+ new PermissionMap( drSubs, "PUT", new String[] { controller, orchestrator,portalUser }),
+ new PermissionMap( drSubs, delete, new String[] { controller, orchestrator,portalUser }),
+ new PermissionMap( feed, "GET", new String[] { controller, orchestrator, inventory, "Metrics", portalUser }),
+ new PermissionMap( feed, "POST", new String[] { controller, orchestrator,portalUser } ),
+ new PermissionMap( feed, "PUT", new String[] { controller, orchestrator, portalUser }),
+ new PermissionMap( feed, delete, new String[] { controller, portalUser }),
+ new PermissionMap( mrClients, "GET", new String[] { controller, orchestrator, inventory, "Metrics", portalUser }),
+ new PermissionMap( mrClients, "POST", new String[] { controller,orchestrator, portalUser } ),
+ new PermissionMap( mrClients, "PUT", new String[] { controller, orchestrator,portalUser }),
+ new PermissionMap( mrClients, delete, new String[] { controller,orchestrator, portalUser }),
+ new PermissionMap( mrClusters, "GET", new String[] { controller, orchestrator, inventory, "Metrics", portalUser }),
+ new PermissionMap( mrClusters, "POST", new String[] { controller } ),
+ new PermissionMap( mrClusters, "PUT", new String[] { controller }),
+ new PermissionMap( mrClusters, delete, new String[] { controller }),
+ new PermissionMap( topic, "GET", new String[] { controller, orchestrator, inventory, "Metrics", portalUser }),
+ new PermissionMap( topic, "POST", new String[] { controller, orchestrator } ),
+ new PermissionMap( topic, "PUT", new String[] { controller, orchestrator }),
+ new PermissionMap( topic, delete, new String[] { controller, orchestrator })
};
public void setBootMap() {
public void setEnvMap() {
Dmaap dmaap = new DmaapService().getDmaap();
- String dmaap_name = dmaap.getDmaapName();
- PermissionMap.initMap( envMap, dmaap_name );
+ String dmaapName = dmaap.getDmaapName();
+ PermissionMap.initMap( envMap, dmaapName );
}
import java.net.SocketException;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Arrays;
import javax.net.ssl.HttpsURLConnection;
public String doPostFeed( Feed postFeed, ApiError err ) {
byte[] postData = postFeed.getBytes();
- logger.info( "post fields=" + postData.toString() );
+ logger.info( "post fields=" + Arrays.toString(postData) );
String responsemessage = null;
String responseBody = null;
public String doPutFeed(Feed putFeed, ApiError err) {
byte[] postData = putFeed.getBytes();
- logger.info( "post fields=" + postData.toString() );
+ logger.info( "post fields=" + Arrays.toString(postData) );
String responsemessage = null;
String responseBody = null;
}
}
}
+ err.setCode(rc);
if (rc == 204 ) {
responseBody = bodyToString( uc.getInputStream() );
logger.info( "responseBody=" + responseBody );
-
} else {
- err.setCode(rc);
err.setMessage(responsemessage);
}
import java.net.ProtocolException;
import java.net.URL;
import java.net.UnknownHostException;
+import java.util.Arrays;
import javax.net.ssl.HttpsURLConnection;
try {
byte[] postData = postTopic.getBytes();
- logger.info( "post fields=" + postData.toString() );
+ logger.info( "post fields=" + Arrays.toString(postData));
// when not using AAF, do not attempt Basic Authentication
if ( useAAF ) {
import javax.net.ssl.SSLException;
import org.apache.commons.codec.binary.Base64;
-import org.apache.log4j.Logger;
import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
import org.onap.dmaap.dbcapi.model.ApiError;
import org.onap.dmaap.dbcapi.model.MR_Cluster;
return(true);
} catch (Exception e) {
logger.error("Unexpected error during openConnection of " + pURL );
- e.printStackTrace();
+ logger.error("Error", e);;
return(false);
}
return(true);
} catch (Exception e) {
logger.error("Unexpected error during openConnection of " + pURL );
- e.printStackTrace();
+ logger.error("error", e);
return(false);
}
} catch (ProtocolException pe) {
// Rcvd error instead of 100-Continue
- try {
- // work around glitch in Java 1.7.0.21 and likely others
- // without this, Java will connect multiple times to the server to run the same request
- uc.setDoOutput(false);
- } catch (Exception e) {
- }
+ callSetDoOutputOnError();
+
} catch ( SSLException se ) {
+ logger.error("Error", se);
response.setCode(500);
response.setMessage( se.getMessage());
return response;
response.setCode(500);
response.setMessage( "Unable to read response");
logger.warn( response.getMessage() );
- e.printStackTrace();
+ logger.error("Error", e);
}
}
finally {
try {
uc.disconnect();
- } catch ( Exception e ) {}
+ } catch ( Exception e ) {
+ logger.error("Error", e);
+ }
}
return response;
}
+
+ public void callSetDoOutputOnError() {
+ try {
+ // work around glitch in Java 1.7.0.21 and likely others
+ // without this, Java will connect multiple times to the server to run the same request
+ uc.setDoOutput(false);
+ } catch (Exception e) {
+ logger.error("Error", e);
+ }
+ }
}
import java.sql.*;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
public abstract class ConnWrapper<T, U> {
+ EELFLogger logger = EELFManager.getInstance().getLogger( ConnWrapper.class );
protected Connection c;
protected PreparedStatement ps;
protected ResultSet rs;
protected abstract T run(U u) throws Exception;
- public T protect(ConnectionFactory cf, U u) throws DBException {
+ public T protect(ConnectionFactory cf, U u) {
try {
try {
return(attempt(cf, u, false));
} catch (SQLException sqle) {
+ logger.error("Error", sqle);
return(attempt(cf, u, true));
}
} catch (RuntimeException rte) {
c = null;
return(ret);
} finally {
- if (rs != null) { try { rs.close(); } catch (Exception e) {}}
+ if (rs != null) {
+ try {
+ rs.close();
+ } catch (Exception e) {
+ logger.error("Error", e);
+ }}
rs = null;
- if (ps != null) { try { ps.close(); } catch (Exception e) {}}
+ if (ps != null) {
+ try {
+ ps.close();
+ } catch (Exception e) {
+ logger.error("Error", e);
+ }}
ps = null;
- if (c != null) { try { c.close(); } catch (Exception e) {}}
+ if (c != null) {
+ try {
+ c.close();
+ } catch (Exception e) {
+ logger.error("Error", e);
+ }}
c = null;
}
}
import java.sql.*;
import java.util.*;
-import org.apache.log4j.Logger;
-
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import org.onap.dmaap.dbcapi.logging.DmaapbcLogMessageEnum;
import org.onap.dmaap.dbcapi.util.DmaapConfig;
public class ConnectionFactory {
return;
}
}
- try { c.close(); } catch (Exception e) {}
+ try {
+ c.close();
+ } catch (Exception e) {
+ logger.error("Error", e);
+ }
}
}
import java.sql.*;
import java.util.*;
-import org.apache.log4j.Logger;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class DBFieldHandler {
- static final EELFLogger errorLogger = EELFManager.getInstance().getErrorLogger();
+ static final EELFLogger errorLogger = EELFManager.getInstance().getErrorLogger();
+
+ public DBFieldHandler(Class<?> c, String fieldname, int fieldnum) throws Exception {
+ this(c, fieldname, fieldnum, null);
+ }
+ public DBFieldHandler(Class<?> c, String fieldname, int fieldnum, SqlOp op) throws Exception {
+ this.fieldnum = fieldnum;
+ StringBuilder sb = new StringBuilder();
+ for (String s: fieldname.split("_")) {
+ sb.append(s.substring(0, 1).toUpperCase()).append(s.substring(1));
+ }
+ String camelcase = sb.toString();
+ try {
+ objget = c.getMethod("is" + camelcase);
+ } catch (Exception e) {
+ errorLogger.error("Error", e);
+ objget = c.getMethod("get" + camelcase);
+ }
+ objset = c.getMethod("set" + camelcase, objget.getReturnType());
+ sqlop = op;
+ if (sqlop != null) {
+ return;
+ }
+ Class<?> x = objget.getReturnType();
+ if (x.isEnum()) {
+ sqlop = new EnumSql(x);
+ return;
+ }
+ sqlop = sqltypes.get(x.getName());
+ if (sqlop != null) {
+ return;
+ }
+ errorLogger.error(DmaapbcLogMessageEnum.DB_NO_FIELD_HANDLER, c.getName(), fieldname, Integer.toString(fieldnum), x.getName());
+ }
public static interface SqlOp {
public Object get(ResultSet rs, int index) throws Exception;
}
private static Map<String, SqlOp> sqltypes;
static {
- sqltypes = new HashMap<String, SqlOp>();
+ sqltypes = new HashMap<>();
sqltypes.put("[Ljava.lang.String;", new AofString());
sqltypes.put("java.util.Date", new SqlDate());
try {
new SqlType("Short");
new SqlType("String");
} catch (Exception e) {
+ errorLogger.error("Error", e);
errorLogger.error(DmaapbcLogMessageEnum.DB_ACCESS_INIT_ERROR, e.getMessage() );
}
}
public void fromSQL(ResultSet r, Object o) throws Exception {
objset.invoke(o, sqlop.get(r, fieldnum));
}
- public DBFieldHandler(Class<?> c, String fieldname, int fieldnum) throws Exception {
- this(c, fieldname, fieldnum, null);
- }
- public DBFieldHandler(Class<?> c, String fieldname, int fieldnum, SqlOp op) throws Exception {
- this.fieldnum = fieldnum;
- StringBuffer sb = new StringBuffer();
- for (String s: fieldname.split("_")) {
- sb.append(s.substring(0, 1).toUpperCase()).append(s.substring(1));
- }
- String camelcase = sb.toString();
- try {
- objget = c.getMethod("is" + camelcase);
- } catch (Exception e) {
- objget = c.getMethod("get" + camelcase);
- }
- objset = c.getMethod("set" + camelcase, objget.getReturnType());
- sqlop = op;
- if (sqlop != null) {
- return;
- }
- Class<?> x = objget.getReturnType();
- if (x.isEnum()) {
- sqlop = new EnumSql(x);
- return;
- }
- sqlop = sqltypes.get(x.getName());
- if (sqlop != null) {
- return;
- }
- errorLogger.error(DmaapbcLogMessageEnum.DB_NO_FIELD_HANDLER, c.getName(), fieldname, Integer.toString(fieldnum), x.getName());
- }
public static String fesc(String s) {
if (s == null) {
return(s);
public DBMap(ConnectionFactory cf, Class<C> cls, String tabname, String keyfield) throws Exception {
super(cf, cls, tabname, keyfield);
}
- public void clear() throws UnsupportedOperationException {
+ public void clear() {
throw new UnsupportedOperationException();
}
- public boolean containsKey(Object key) throws DBException {
+ public boolean containsKey(Object key) {
return(get(key) != null);
}
- public boolean containsValue(Object value) throws UnsupportedOperationException {
+ public boolean containsValue(Object value) {
throw new UnsupportedOperationException();
}
public boolean isEmpty() {
return(false);
}
- public Set<Map.Entry<String, C>> entrySet() throws DBException {
+ public Set<Map.Entry<String, C>> entrySet() {
return(list());
}
- public Set<String> keySet() throws DBException {
- Set<String> ret = new HashSet<String>();
+ public Set<String> keySet() {
+ Set<String> ret = new HashSet<>();
for (Map.Entry<String, C> x: list()) {
ret.add(x.getKey());
}
return(ret);
}
- public void putAll(Map<? extends String, ? extends C> m) throws UnsupportedOperationException {
+ public void putAll(Map<? extends String, ? extends C> m) {
throw new UnsupportedOperationException();
}
public int size() {
return(2);
}
- public Collection<C> values() throws DBException {
- Collection<C> ret = new Vector<C>();
+ public Collection<C> values() {
+ Collection<C> ret = new Vector<>();
for (Map.Entry<String, C> x: list()) {
ret.add(x.getValue());
}
return(ret);
}
- public C get(Object key) throws DBException {
+ public C get(Object key) {
if (!(key instanceof String)) {
return(null);
}
}
}).protect(cf, (String)key));
}
- public Set<Map.Entry<String, C>> list() throws DBException {
+ public Set<Map.Entry<String, C>> list() {
return((new ConnWrapper<Set<Map.Entry<String, C>>, Object>() {
protected Set<Map.Entry<String, C>> run(Object junk) throws Exception {
DBFieldHandler keyfield = fields[fields.length - 1];
ps = c.prepareStatement(liststmt);
rs = ps.executeQuery();
- Set<Map.Entry<String, C>> ret = new HashSet<Map.Entry<String, C>>();
+ Set<Map.Entry<String, C>> ret = new HashSet<>();
while (rs.next()) {
C val = cls.newInstance();
for (DBFieldHandler f: fields) {
}
}).protect(cf, null));
}
- public C put(String key, C val) throws DBException {
+ public C put(String key, C val) {
try {
fields[fields.length - 1].setKey(val, key);
} catch (Exception e) {
}
}).protect(cf, val));
}
- public C remove(Object key) throws DBException {
+ public C remove(Object key) {
if (!(key instanceof String)) {
return(null);
}
super(cf, cls, tabname, null);
singleton = cls.newInstance();
}
- public C get() throws DBException {
+ public C get() {
return((new ConnWrapper<C, Object>() {
protected C run(Object junk) throws Exception {
ps = c.prepareStatement(getstmt);
}
}).protect(cf, null));
}
- public void init(C val) throws DBException {
+ public void init(C val) {
if (get() != null) {
return;
}
}
}).protect(cf, val);
}
- public void update(C val) throws DBException {
+ public void update(C val) {
(new ConnWrapper<Void, C>() {
protected Void run(C val) throws Exception {
ps = c.prepareStatement(insorreplstmt);
}
List<String> rv = new ArrayList<String>();
for (String s: val.split(",")) {
- //String[] f = s.split(";");
- //if (f.length < 3) {
- // continue;
- //}
rv.add(new String(s));
}
return(rv);
}
@SuppressWarnings("unchecked")
List<String> xv = (List<String>)val;
- StringBuffer sb = new StringBuffer();
+ StringBuilder sb = new StringBuilder();
String sep = "";
for (Object o: xv) {
String rv = (String)o;
}
try {
dmaap = new DBSingleton<Dmaap>(Dmaap.class, "dmaap");
- dcaeLocations = new DBMap<DcaeLocation>(DcaeLocation.class, "dcae_location", "dcae_location_name");
- dr_nodes = new DBMap<DR_Node>(DR_Node.class, "dr_node", "fqdn");
- dr_pubs = new DBMap<DR_Pub>(DR_Pub.class, "dr_pub", "pub_id");
- dr_subs = new DBMap<DR_Sub>(DR_Sub.class, "dr_sub", "sub_id");
- mr_clients = new DBMap<MR_Client>(MR_Client.class, "mr_client", "mr_client_id");
- mr_clusters = new DBMap<MR_Cluster>(MR_Cluster.class, "mr_cluster", "dcae_location_name");
- feeds = new DBMap<Feed>(Feed.class, "feed", "feed_id");
+ dcaeLocations = new DBMap<>(DcaeLocation.class, "dcae_location", "dcae_location_name");
+ dr_nodes = new DBMap<>(DR_Node.class, "dr_node", "fqdn");
+ dr_pubs = new DBMap<>(DR_Pub.class, "dr_pub", "pub_id");
+ dr_subs = new DBMap<>(DR_Sub.class, "dr_sub", "sub_id");
+ mr_clients = new DBMap<>(MR_Client.class, "mr_client", "mr_client_id");
+ mr_clusters = new DBMap<>(MR_Cluster.class, "mr_cluster", "dcae_location_name");
+ feeds = new DBMap<>(Feed.class, "feed", "feed_id");
TableHandler.setSpecialCase("topic", "replication_case", new TopicReplicationTypeHandler());
- topics = new DBMap<Topic>(Topic.class, "topic", "fqtn");
+ topics = new DBMap<>(Topic.class, "topic", "fqtn");
TableHandler.setSpecialCase("mirror_maker", "topics", new MirrorTopicsHandler());
- mirrors = new DBMap<MirrorMaker>(MirrorMaker.class, "mirror_maker", "mm_name");
+ mirrors = new DBMap<>(MirrorMaker.class, "mirror_maker", "mm_name");
} catch (Exception e) {
errorLogger.error("Error initializing database access " + e, e);
System.exit(1);
dmaap.setAccessKeyOwner(nd.getAccessKeyOwner());
}
};
- dcaeLocations = new HashMap<String, DcaeLocation>();
- dr_nodes = new HashMap<String, DR_Node>();
- dr_pubs = new HashMap<String, DR_Pub>();
- dr_subs = new HashMap<String, DR_Sub>();
- mr_clients = new HashMap<String, MR_Client>();
- mr_clusters = new HashMap<String, MR_Cluster>();
- feeds = new HashMap<String, Feed>();
- topics = new HashMap<String, Topic>();
- mirrors = new HashMap<String, MirrorMaker>();
+ dcaeLocations = new HashMap<>();
+ dr_nodes = new HashMap<>();
+ dr_pubs = new HashMap<>();
+ dr_subs = new HashMap<>();
+ mr_clients = new HashMap<>();
+ mr_clusters = new HashMap<>();
+ feeds = new HashMap<>();
+ topics = new HashMap<>();
+ mirrors = new HashMap<>();
}
dmaap.init(new Dmaap("0", "", "", "", "", "", "", ""));
// check for, and set up initial data, if it isn't already there
dmaap.update(dmx);
}
} catch (Exception e) {
+ errorLogger.error("Error", e);
errorLogger.error(DmaapbcLogMessageEnum.DB_UPDATE_ERROR, e.getMessage());
}
}
- public synchronized static String getNextClientId() {
+ public static synchronized String getNextClientId() {
long id = System.currentTimeMillis();
if ( id <= lastTime ) {
import java.io.*;
import java.sql.*;
-import org.apache.log4j.Logger;
-
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-
-import org.onap.dmaap.dbcapi.logging.DmaapbcLogMessageEnum;
+;
public class LoadSchema {
private static final EELFLogger logger = EELFManager.getInstance().getLogger(LoadSchema.class);
- private static final EELFLogger appLogger = EELFManager.getInstance().getApplicationLogger();
- private static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
- private static final EELFLogger debugLogger = EELFManager.getInstance().getDebugLogger();
- private static final EELFLogger errorLogger = EELFManager.getInstance().getErrorLogger();
- private static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
static int getVer(Statement s) throws SQLException {
ResultSet rs = null;
stmt.execute(cmd);
logger.info("SCHEMA: " + cmd);
} catch (SQLException sqle) {
+ logger.error("Error", sqle);
throw sqle;
}
int newver = -1;
try {
newver = getVer(stmt);
- } catch (Exception e) {}
+ } catch (Exception e) {
+ logger.error("Error", e);
+ }
logger.info("Database schema currently at version " + newver++);
} catch (IOException ioe) {
throw new SQLException(ioe);
} finally {
- if (stmt != null) { try { stmt.close(); } catch (Exception e) {}}
- if (c != null) { try { c.close(); } catch (Exception e) {}}
+ if (stmt != null) {
+ try {
+ stmt.close();
+ } catch (Exception e) {
+ logger.error("Error", e);
+ }
+ }
+ if (c != null) {
+ try {
+ c.close();
+ } catch (Exception e) {
+ logger.error("Error", e);
+ }
+ }
}
}
public static void main(String[] args) throws Exception {
protected String initstmt;
protected Class<C> cls;
protected DBFieldHandler[] fields;
- private static Map<String, Map<String, DBFieldHandler.SqlOp>> exceptions = new HashMap<String, Map<String, DBFieldHandler.SqlOp>>();
- public static void setSpecialCase(String dbtabname, String dbfldname, DBFieldHandler.SqlOp handler) {
- Map<String, DBFieldHandler.SqlOp> m = exceptions.get(dbtabname);
- if (m == null) {
- m = new HashMap<String, DBFieldHandler.SqlOp>();
- exceptions.put(dbtabname, m);
- }
- m.put(dbfldname, handler);
- }
- public static DBFieldHandler.SqlOp getSpecialCase(String dbtabname, String dbfldname) {
- Map<String, DBFieldHandler.SqlOp> m = exceptions.get(dbtabname);
- if (m != null) {
- return(m.get(dbfldname));
- }
- return(null);
- }
+ private static Map<String, Map<String, DBFieldHandler.SqlOp>> exceptions = new HashMap<>();
+ private String select = "SELECT ";
+ private String from = " FROM ";
+
protected TableHandler(Class<C> cls, String tabname, String keyname) throws Exception {
this(ConnectionFactory.getDefaultInstance(), cls, tabname, keyname);
}
}
}
}
+
+ public static void setSpecialCase(String dbtabname, String dbfldname, DBFieldHandler.SqlOp handler) {
+ Map<String, DBFieldHandler.SqlOp> m = exceptions.get(dbtabname);
+ if (m == null) {
+ m = new HashMap<>();
+ exceptions.put(dbtabname, m);
+ }
+ m.put(dbfldname, handler);
+ }
+ public static DBFieldHandler.SqlOp getSpecialCase(String dbtabname, String dbfldname) {
+ Map<String, DBFieldHandler.SqlOp> m = exceptions.get(dbtabname);
+ if (m != null) {
+ return(m.get(dbfldname));
+ }
+ return(null);
+ }
+
private void setup(DatabaseMetaData dmd, Class<C> cls, String tabname, String keyname) throws Exception {
this.cls = cls;
- Vector<DBFieldHandler> h = new Vector<DBFieldHandler>();
+ Vector<DBFieldHandler> h = new Vector<>();
String qualifiedTableName = String.format( "%s.%s", cf.getSchema(), tabname );
ResultSet rs = dmd.getColumns("", cf.getSchema(), tabname, null);
- StringBuffer sb1 = new StringBuffer();
- StringBuffer sb2 = new StringBuffer();
- StringBuffer sb3 = new StringBuffer();
+ StringBuilder sb1 = new StringBuilder();
+ StringBuilder sb2 = new StringBuilder();
+ StringBuilder sb3 = new StringBuilder();
int count = 0;
while (rs.next()) {
if (!rs.getString(3).equals(tabname)) {
h.add(new DBFieldHandler(cls, keyname, count, getSpecialCase(tabname, keyname)));
delstmt = "DELETE FROM " + qualifiedTableName + " WHERE " + keyname + " = ?";
insorreplstmt = "INSERT INTO " + qualifiedTableName + " (" + clist + ", " + keyname + ") VALUES (" + qlist + ", ?) ON CONFLICT(" + keyname + ") DO UPDATE SET (" + clist + ") = (" + elist + ")";
- getstmt = "SELECT " + clist + ", " + keyname + " FROM " + qualifiedTableName + " WHERE " + keyname + " = ?";
- liststmt = "SELECT " + clist + ", " + keyname + " FROM " + qualifiedTableName;
+ getstmt = select + clist + ", " + keyname + from + qualifiedTableName + " WHERE " + keyname + " = ?";
+ liststmt = select + clist + ", " + keyname + from + qualifiedTableName;
} else {
delstmt = "DELETE FROM " + qualifiedTableName;
initstmt = "INSERT INTO " + qualifiedTableName + " (" + clist + ") VALUES (" + qlist + ")";
insorreplstmt = "UPDATE " + qualifiedTableName + " SET (" + clist + ") = (" + qlist + ")";
- getstmt = "SELECT " + clist + ", " + keyname + " FROM " + qualifiedTableName;
+ getstmt = select + clist + ", " + keyname + from + qualifiedTableName;
}
fields = h.toArray(new DBFieldHandler[h.size()]);
}
private boolean use100;
private boolean suspended;
private String owner;
-
- public String getOwner() {
- return owner;
- }
-
- public void setOwner(String owner) {
- this.owner = owner;
- }
-
- public boolean isSuspended() {
- return suspended;
- }
-
- public void setSuspended(boolean suspended) {
- this.suspended = suspended;
- }
-
-
-
- public boolean isUse100() {
- return use100;
- }
-
- public void setUse100(boolean use100) {
- this.use100 = use100;
- }
public DR_Sub() {
logger.info( "new DR_Sub returning");
}
+
+ public String getOwner() {
+ return owner;
+ }
+
+ public void setOwner(String owner) {
+ this.owner = owner;
+ }
+
+ public boolean isSuspended() {
+ return suspended;
+ }
+
+ public void setSuspended(boolean suspended) {
+ this.suspended = suspended;
+ }
+
+
+
+ public boolean isUse100() {
+ return use100;
+ }
+
+ public void setUse100(boolean use100) {
+ this.use100 = use100;
+ }
public String getDcaeLocationName() {
return dcaeLocationName;
@XmlRootElement
public class DcaeLocation extends DmaapObject {
- static final Logger logger = Logger.getLogger(MR_Cluster.class);
+ static final Logger errorLogger = Logger.getLogger(MR_Cluster.class);
private String clli;
private String dcaeLayer;
private String dcaeLocationName;
private static String defaultTargetReplicationPort;
private static void setDefaults() {
- boolean been_here = false;
+ /* boolean been_here = false;
if ( been_here ) {
return;
- }
+ } */
DmaapConfig dc = (DmaapConfig)DmaapConfig.getConfig();
defaultTopicProtocol = dc.getProperty("MR.TopicProtocol", "https");
defaultTopicPort = dc.getProperty( "MR.TopicPort", "3905");
defaultReplicationGroup = dc.getProperty( "MR.ReplicationGroup", "" );
defaultSourceReplicationPort = dc.getProperty( "MR.SourceReplicationPort", "2181");
defaultTargetReplicationPort = dc.getProperty( "MR.TargetReplicationPort", "9092");
- been_here = true;
+ // been_here = true;
}
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
+import org.apache.log4j.Logger;
import org.onap.dmaap.dbcapi.authentication.AuthenticationErrorException;
import org.onap.dmaap.dbcapi.service.ApiService;
-import org.onap.dmaap.dbcapi.util.DmaapConfig;
@Authorization
public class AuthorizationFilter implements ContainerRequestFilter {
-
+ private Logger logger = Logger.getLogger(AuthorizationFilter.class.getName());
@Override
public void filter(ContainerRequestContext requestContext)
try {
apiResp.checkAuthorization();
} catch ( AuthenticationErrorException ae ) {
+ logger.error("Error", ae);
requestContext.abortWith( apiResp.unauthorized( apiResp.getErr().getMessage() ) );
return ;
} catch ( Exception e ) {
+ logger.error("Error", e);
requestContext.abortWith( apiResp.unavailable() );
return;
}
for( Iterator<DR_Pub> i = pubs.iterator(); i.hasNext(); ) {
DR_Pub listItem = i.next();
if ( listItem.getPubId().equals(id)) {
- pubs.remove( listItem );
+ i.remove();
}
}
fnew.setPubs(pubs);
public Response addTopic(
Topic topic
) {
- logger.info( "addTopic request: " + String.valueOf(topic) );
+ logger.info( "addTopic request: " + topic );
ApiService check = new ApiService();
try {
check.required( "topicDescription", topic.getTopicDescription(), "" );
check.required( "owner", topic.getOwner(), "" );
} catch( RequiredFieldException rfe ) {
+ logger.error("Error", rfe);
return check.error();
}
- //String repReq = topic.getReplicationRequest();
ReplicationType t = topic.getReplicationCase();
if ( t == null || t == ReplicationType.REPLICATION_NOT_SPECIFIED ) {
topic.setReplicationCase( mr_topicService.reviewTopic(topic));
try {
check.required( "fqtn", id, "" );
} catch( RequiredFieldException rfe ) {
+ logger.error("Error", rfe);
return check.error();
}
try {
check.required( "topicName", id, "^\\S+$" ); //no white space allowed in topicName
} catch( RequiredFieldException rfe ) {
+ logger.error("Error", rfe);
return check.error();
}
Topic mrc = mr_topicService.getTopic( id, check.getErr() );
boolean allowHttp = Boolean.valueOf(params.getProperty("HttpAllowed", "false"));
serverLogger.info( "port params: http=" + httpPort + " https=" + sslPort );
serverLogger.info( "allowHttp=" + allowHttp );
+ String keystore=null;
+ String keystorePwd = null;
+ String keyPwd = null;
// HTTP Server
- ServerConnector httpConnector = new ServerConnector(server, new HttpConnectionFactory(http_config));
- httpConnector.setPort(httpPort);
- httpConnector.setIdleTimeout(30000);
-
-
- // HTTPS Server
-
- HttpConfiguration https_config = new HttpConfiguration(http_config);
- https_config.addCustomizer(new SecureRequestCustomizer());
- SslContextFactory sslContextFactory = new SslContextFactory();
- String keystore = params.getProperty("KeyStoreFile", "etc/keystore");
- logger.info( "https Server using keystore at " + keystore );
- String keystorePwd = params.getProperty( "KeyStorePassword", "changeit");
- String keyPwd = params.getProperty("KeyPassword", "changeit");
-
-
- sslContextFactory.setKeyStorePath(keystore);
- sslContextFactory.setKeyStorePassword(keystorePwd);
- sslContextFactory.setKeyManagerPassword(keyPwd);
-
-
- ServerConnector sslConnector = null;
- if ( sslPort != 0 ) {
- sslConnector = new ServerConnector(server,
- new SslConnectionFactory(sslContextFactory, "http/1.1"),
- new HttpConnectionFactory(https_config));
- sslConnector.setPort(sslPort);
- if ( allowHttp ) {
- logger.info("Starting httpConnector on port " + httpPort );
- logger.info("Starting sslConnector on port " + sslPort + " for https");
- server.setConnectors( new Connector[] { httpConnector, sslConnector });
- } else {
- logger.info("NOT starting httpConnector because HttpAllowed param is " + allowHttp );
- logger.info("Starting sslConnector on port " + sslPort + " for https");
- server.setConnectors( new Connector[] { sslConnector });
- }
+ try(ServerConnector httpConnector = new ServerConnector(server, new HttpConnectionFactory(http_config))) {
+ httpConnector.setPort(httpPort);
+ httpConnector.setIdleTimeout(30000);
+
+
+ // HTTPS Server
+
+ HttpConfiguration https_config = new HttpConfiguration(http_config);
+ https_config.addCustomizer(new SecureRequestCustomizer());
+ SslContextFactory sslContextFactory = new SslContextFactory();
+ keystore = params.getProperty("KeyStoreFile", "etc/keystore");
+ logger.info("https Server using keystore at " + keystore);
+ keystorePwd = params.getProperty("KeyStorePassword", "changeit");
+ keyPwd = params.getProperty("KeyPassword", "changeit");
+
+
+ sslContextFactory.setKeyStorePath(keystore);
+ sslContextFactory.setKeyStorePassword(keystorePwd);
+ sslContextFactory.setKeyManagerPassword(keyPwd);
+
+
+ if (sslPort != 0) {
+ try(ServerConnector sslConnector = new ServerConnector(server,
+ new SslConnectionFactory(sslContextFactory, "http/1.1"),
+ new HttpConnectionFactory(https_config))) {
+ sslConnector.setPort(sslPort);
+ if (allowHttp) {
+ logger.info("Starting httpConnector on port " + httpPort);
+ logger.info("Starting sslConnector on port " + sslPort + " for https");
+ server.setConnectors(new Connector[]{httpConnector, sslConnector});
+ } else {
+ logger.info("NOT starting httpConnector because HttpAllowed param is " + allowHttp);
+ logger.info("Starting sslConnector on port " + sslPort + " for https");
+ server.setConnectors(new Connector[]{sslConnector});
+ }
+ }
+ } else {
+ serverLogger.info("NOT starting sslConnector on port " + sslPort + " for https");
+ if (allowHttp) {
+ serverLogger.info("Starting httpConnector on port " + httpPort);
+ server.setConnectors(new Connector[]{httpConnector});
+ }
+ }
}
- else {
- serverLogger.info("NOT starting sslConnector on port " + sslPort + " for https");
- if ( allowHttp ) {
- serverLogger.info("Starting httpConnector on port " + httpPort );
- server.setConnectors( new Connector[] { httpConnector });
- }
- }
// Set context for servlet. This is shared for http and https
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
return null;
}
}
- mr_topics.put( ntopic.getFqtn(), ntopic );
+ if(ntopic != null) {
+ mr_topics.put( ntopic.getFqtn(), ntopic );
+ }
err.setCode(Status.OK.getStatusCode());
return ntopic;
}
@XmlRootElement
public class DmaapTimestamp {
static final Logger logger = Logger.getLogger(DmaapTimestamp.class);
- private static Calendar cal = Calendar.getInstance();
+ private Calendar cal = Calendar.getInstance();
private Date stamp;
public DmaapTimestamp() {
major=1
minor=0
-patch=14
+patch=15
base_version=${major}.${minor}.${patch}
# Release must be completed with git revision # in Jenkins