aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--INFO.yaml42
-rw-r--r--pom.xml2
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/authentication/ApiPerms.java6
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/database/DatabaseClass.java16
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/model/Feed.java5
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/resources/BridgeResource.java4
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/resources/DR_SubResource.java4
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/server/JettyServer.java28
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java27
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/service/MR_ClusterService.java4
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/util/Graph.java13
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/resources/DR_SubResourceTest.java34
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/util/FqdnTest.java33
13 files changed, 151 insertions, 67 deletions
diff --git a/INFO.yaml b/INFO.yaml
new file mode 100644
index 0000000..172026d
--- /dev/null
+++ b/INFO.yaml
@@ -0,0 +1,42 @@
+---
+project: 'dmaap-dbcapi'
+project_creation_date: '2017-08-29'
+lifecycle_state: 'Incubation'
+project_lead: &onap_releng_ptl
+ name: 'Ram Koya'
+ email: 'rk541m@att.com'
+ id: 'rampi_k'
+ company: 'ATT'
+ timezone: 'America/Dallas'
+primary_contact: *onap_releng_ptl
+issue_tracking:
+ type: 'jira'
+ url: 'https://jira.onap.org/projects/DMAAP'
+ key: 'DMAAP'
+meetings:
+ - type: 'zoom'
+ agenda: ''
+ url: 'https://wiki.onap.org/pages/viewpage.action?pageId=13599275'
+ server: 'n/a'
+ channel: 'n/a'
+ repeats: 'weekly'
+ time: '13:00 UTC'
+committers:
+ - <<: *onap_releng_ptl
+ - name: 'Ramdas Sawant'
+ email: 'rs873m@att.com'
+ company: 'ATT'
+ id: 'rs873m'
+ timezone: 'America/Dallas'
+ - name: 'Varun Gudisena'
+ email: 'vg411h@att.com'
+ company: 'ATT'
+ id: 'vg411h'
+ timezone: 'America/Dallas'
+tsc:
+ approval: 'https://lists.onap.org/pipermail/onap-tsc'
+ changes:
+ - type: 'Removal'
+ name: 'Habib Madani'
+ name: 'Xinhui Li'
+ name: 'Jing Wang'
diff --git a/pom.xml b/pom.xml
index 8db05b1..975866c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -379,7 +379,7 @@
<jackson.version>2.9.5</jackson.version>
<jersey.version>2.26</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <jettyVersion>9.3.8.RC0</jettyVersion>
+ <jettyVersion>9.4.12.RC2</jettyVersion>
<eelf.version>1.0.0</eelf.version>
<artifact.version>1.0.20-SNAPSHOT</artifact.version>
<!-- SONAR -->
diff --git a/src/main/java/org/onap/dmaap/dbcapi/authentication/ApiPerms.java b/src/main/java/org/onap/dmaap/dbcapi/authentication/ApiPerms.java
index f3b9ebc..bcadf40 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/authentication/ApiPerms.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/authentication/ApiPerms.java
@@ -3,6 +3,8 @@
* org.onap.dmaap
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Modifications Copyright (C) 2018 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -172,8 +174,8 @@ public class ApiPerms extends BaseLoggingClass {
}
public void setEnvMap() {
- Dmaap dmaap = new DmaapService().getDmaap();
- String dmaapName = dmaap.getDmaapName();
+ Dmaap dmaapVar = new DmaapService().getDmaap();
+ String dmaapName = dmaapVar.getDmaapName();
PermissionMap.initMap( envMap, dmaapName );
}
diff --git a/src/main/java/org/onap/dmaap/dbcapi/database/DatabaseClass.java b/src/main/java/org/onap/dmaap/dbcapi/database/DatabaseClass.java
index 11b0d15..934b7bb 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/database/DatabaseClass.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/database/DatabaseClass.java
@@ -200,22 +200,18 @@ public class DatabaseClass extends BaseLoggingClass {
mirrors = new HashMap<>();
}
dmaap.init(new Dmaap("0", "", "", "", "", "", "", ""));
- // check for, and set up initial data, if it isn't already there
+ // force initial read from DB, if it exists
+ @SuppressWarnings("unused")
Dmaap dmx = dmaap.get();
- if ("0".equals(dmx.getVersion())) {
-
- dmx = new Dmaap("0", "", "", "", "", "", "", "");
- dmx.setDmaapName(p.getProperty("DmaapName"));
- dmx.setDrProvUrl("https://" + p.getProperty("DR.provhost", "notSet"));
- dmx.setTopicNsRoot(p.getProperty("topicNsRoot"));
- dmx.setBridgeAdminTopic("DCAE_MM_AGENT");
+
+ // old code in this spot would read from properties file as part of init.
+ // but all those properties are now set via /dmaap API
- dmaap.update(dmx);
- }
} catch (Exception e) {
errorLogger.error("Error", e);
errorLogger.error(DmaapbcLogMessageEnum.DB_UPDATE_ERROR, e.getMessage());
}
+
}
public static synchronized String getNextClientId() {
diff --git a/src/main/java/org/onap/dmaap/dbcapi/model/Feed.java b/src/main/java/org/onap/dmaap/dbcapi/model/Feed.java
index 648812f..b78377b 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/model/Feed.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/model/Feed.java
@@ -3,6 +3,8 @@
* org.onap.dmaap
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Modifications Copyright (C) 2019 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -262,8 +264,7 @@ public class Feed extends DmaapObject {
}
public static String getSubProvURL( String feedId ) {
- String ret = new String();
- ret = new DmaapService().getDmaap().getDrProvUrl() + "/subscribe/" + feedId ;
+ String ret = new DmaapService().getDmaap().getDrProvUrl() + "/subscribe/" + feedId ;
return ret;
}
diff --git a/src/main/java/org/onap/dmaap/dbcapi/resources/BridgeResource.java b/src/main/java/org/onap/dmaap/dbcapi/resources/BridgeResource.java
index e6fede7..192b63d 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/resources/BridgeResource.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/resources/BridgeResource.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -121,7 +123,7 @@ public class BridgeResource extends BaseLoggingClass {
}
logger.info( "Count for "+ key + ": " + mCnt);
totCnt += mCnt;
- if (showDetail) {
+ if (showDetail && mm!=null) {
brTopic[s] = new BrTopic();
brTopic[s].setBrSource( mm.getSourceCluster());
brTopic[s].setBrTarget(mm.getTargetCluster());
diff --git a/src/main/java/org/onap/dmaap/dbcapi/resources/DR_SubResource.java b/src/main/java/org/onap/dmaap/dbcapi/resources/DR_SubResource.java
index 58a39df..28bfdc5 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/resources/DR_SubResource.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/resources/DR_SubResource.java
@@ -3,6 +3,8 @@
* org.onap.dmaap
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Modifications Copyright (C) 2019 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -120,8 +122,6 @@ public class DR_SubResource extends BaseLoggingClass {
fnew.setSubs(subs);
logger.info( "update feed");
- //feeds.updateFeed( fnew, err );
-
return resp.success(Status.CREATED.getStatusCode(), snew);
}
diff --git a/src/main/java/org/onap/dmaap/dbcapi/server/JettyServer.java b/src/main/java/org/onap/dmaap/dbcapi/server/JettyServer.java
index 748eedc..81c08b2 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/server/JettyServer.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/server/JettyServer.java
@@ -2,7 +2,9 @@
* ============LICENSE_START=======================================================
* org.onap.dmaap
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017 AT&T Intellectual Property.
+ *
+ * Modifications Copyright (C) 2019 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,32 +23,14 @@
package org.onap.dmaap.dbcapi.server;
-import java.util.Properties;
-
-import javax.net.ssl.SSLContext;
-
-import org.apache.log4j.Logger;
-import org.eclipse.jetty.security.SecurityHandler;
-import org.eclipse.jetty.server.Connector;
-import org.eclipse.jetty.server.HttpConfiguration;
-import org.eclipse.jetty.server.HttpConnectionFactory;
-import org.eclipse.jetty.server.SecureRequestCustomizer;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.ServerConnector;
-import org.eclipse.jetty.server.SslConnectionFactory;
+import org.eclipse.jetty.server.*;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.util.ssl.SslContextFactory;
-
-
-
-
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-
-import org.onap.dmaap.dbcapi.database.LoadSchema;
import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
+
+import java.util.Properties;
/**
* A Jetty server which supports:
* - http and https (simultaneously for dev env)
diff --git a/src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java b/src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java
index 9d9b922..408d000 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java
@@ -3,6 +3,8 @@
* org.onap.dmaap
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Modifications Copyright (C) 2019 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,16 +23,6 @@
package org.onap.dmaap.dbcapi.service;
import java.util.ArrayList;
-
-
-
-
-
-
-
-
-
-
import org.onap.dmaap.dbcapi.aaf.AafService;
import org.onap.dmaap.dbcapi.aaf.DmaapGrant;
import org.onap.dmaap.dbcapi.aaf.DmaapPerm;
@@ -43,7 +35,6 @@ import org.onap.dmaap.dbcapi.logging.DmaapbcLogMessageEnum;
import org.onap.dmaap.dbcapi.model.ApiError;
import org.onap.dmaap.dbcapi.model.Dmaap;
import org.onap.dmaap.dbcapi.model.MR_Client;
-import org.onap.dmaap.dbcapi.model.ReplicationType;
import org.onap.dmaap.dbcapi.model.Topic;
import org.onap.dmaap.dbcapi.model.DmaapObject.DmaapObject_Status;
import org.onap.dmaap.dbcapi.util.DmaapConfig;
@@ -58,7 +49,7 @@ public class DmaapService extends BaseLoggingClass {
String topicFactory; // = "org.openecomp.dcae.dmaap.topicFactory";
String topicMgrRole; // = "org.openecomp.dmaapBC.TopicMgr";
- String dcaeTopicNs; // = "org.openecomp.dcae.dmaap";
+
private boolean multiSite;
@@ -66,14 +57,14 @@ public class DmaapService extends BaseLoggingClass {
DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
topicFactory = p.getProperty("MR.TopicFactoryNS", "MR.topicFactoryNS.not.set");
topicMgrRole = p.getProperty("MR.TopicMgrRole", "MR.TopicMgrRole.not.set" );
- dcaeTopicNs = dmaapholder.get().getTopicNsRoot();
+
multiSite = "true".equalsIgnoreCase(p.getProperty("MR.multisite", "true"));
noEnvironmentPrefix = p.getProperty( "AAF.NoEnvironmentPrefix", "org.onap");
logger.info( "DmaapService settings: " +
" topicFactory=" + topicFactory +
" topicMgrRole=" + topicMgrRole +
- " dcaeTopicNs=" + dcaeTopicNs +
+
" multisite=" + multiSite +
" noEnvironmentPrefix=" + noEnvironmentPrefix
);
@@ -93,7 +84,7 @@ public class DmaapService extends BaseLoggingClass {
nd.setLastMod();
dmaapholder.update(nd);
-
+
AafService aaf = new AafService( ServiceType.AAF_Admin);
ApiPolicy apiPolicy = new ApiPolicy();
if ( apiPolicy.getUseAuthClass() ) {
@@ -137,7 +128,7 @@ public class DmaapService extends BaseLoggingClass {
if ( ! dmaap.isStatusValid() || ! nd.getDmaapName().equals(dmaap.getDmaapName()) || dmaap.getVersion().equals( "0") ) {
nd.setLastMod();
dmaapholder.update(nd); //need to set this so the following perms will pick up any new vals.
- dcaeTopicNs = dmaapholder.get().getTopicNsRoot();
+ //dcaeTopicNs = dmaapholder.get().getTopicNsRoot();
ApiPolicy apiPolicy = new ApiPolicy();
if ( apiPolicy.getUseAuthClass()) {
ApiPerms p = new ApiPerms();
@@ -194,7 +185,7 @@ public class DmaapService extends BaseLoggingClass {
private boolean setTopicMgtPerms( Dmaap nd, AafService aaf ){
String[] actions = { "create", "destroy" };
- String instance = ":" + dcaeTopicNs + "." + nd.getDmaapName() + ".mr.topic:" + dcaeTopicNs + "." + nd.getDmaapName();
+ String instance = ":" + nd.getTopicNsRoot() + "." + nd.getDmaapName() + ".mr.topic:" + nd.getTopicNsRoot() + "." + nd.getDmaapName();
for( String action : actions ) {
@@ -214,7 +205,7 @@ public class DmaapService extends BaseLoggingClass {
}
}
- String t = dcaeTopicNs +"." + nd.getDmaapName() + ".mr.topic";
+ String t = nd.getTopicNsRoot() +"." + nd.getDmaapName() + ".mr.topic";
String[] s = { "view", "pub", "sub" };
actions = s;
instance = "*";
diff --git a/src/main/java/org/onap/dmaap/dbcapi/service/MR_ClusterService.java b/src/main/java/org/onap/dmaap/dbcapi/service/MR_ClusterService.java
index dea5d83..db6389e 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/service/MR_ClusterService.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/service/MR_ClusterService.java
@@ -3,6 +3,8 @@
* org.onap.dmaap
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Modifications Copyright (C) 2019 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -156,7 +158,7 @@ public class MR_ClusterService extends BaseLoggingClass {
cluster.setLastMod();
cluster.setStatus(DmaapObject_Status.INVALID);
mr_clusters.put( cluster.getDcaeLocationName(), cluster );
- } else if ( loc.isCentral() & multiSite ) {
+ } else if ( loc.isCentral() && multiSite ) {
ApiError resp = TopicService.setBridgeClientPerms( cluster );
if ( ! resp.is2xx() ) {
logger.error( "Unable to provision Bridge to " + cluster.getDcaeLocationName() );
diff --git a/src/main/java/org/onap/dmaap/dbcapi/util/Graph.java b/src/main/java/org/onap/dmaap/dbcapi/util/Graph.java
index a7700a1..700c77f 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/util/Graph.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/util/Graph.java
@@ -3,6 +3,8 @@
* org.onap.dmaap
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Modifications Copyright (C) 2019 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,18 +22,17 @@
package org.onap.dmaap.dbcapi.util;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.onap.dmaap.dbcapi.database.DatabaseClass;
import org.onap.dmaap.dbcapi.model.DcaeLocation;
import org.onap.dmaap.dbcapi.model.MR_Client;
import org.onap.dmaap.dbcapi.model.MR_Cluster;
import org.onap.dmaap.dbcapi.service.MR_ClusterService;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
public class Graph {
private HashMap<String, String> graph;
diff --git a/src/test/java/org/onap/dmaap/dbcapi/resources/DR_SubResourceTest.java b/src/test/java/org/onap/dmaap/dbcapi/resources/DR_SubResourceTest.java
index 48d1016..917507f 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/resources/DR_SubResourceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/resources/DR_SubResourceTest.java
@@ -21,6 +21,8 @@
package org.onap.dmaap.dbcapi.resources;
import org.onap.dmaap.dbcapi.model.*;
import org.onap.dmaap.dbcapi.service.*;
+import org.onap.dmaap.dbcapi.testframework.DmaapObjectFactory;
+
import static org.junit.Assert.*;
import org.junit.After;
@@ -39,16 +41,44 @@ import javax.ws.rs.Path;
import javax.ws.rs.GET;
public class DR_SubResourceTest extends JerseyTest{
+
+ static DmaapObjectFactory factory = new DmaapObjectFactory();
@Override
protected Application configure() {
return new ResourceConfig()
.register( DR_SubResource.class )
- .register( FeedResource.class );
+ .register( FeedResource.class )
+ .register( DcaeLocationResource.class )
+ .register( DmaapResource.class );
}
- private static final String fmt = "%24s: %s%n";
String d, un, up, f, p;
+
+ @Before
+ public void preTest() throws Exception {
+ try {
+
+ Dmaap dmaap = factory.genDmaap();
+ Entity<Dmaap> reqEntity = Entity.entity( dmaap, MediaType.APPLICATION_JSON );
+ Response resp = target( "dmaap").request().post( reqEntity, Response.class );
+ System.out.println( resp.getStatus() );
+ assertTrue( resp.getStatus() == 200 );
+ }catch (Exception e ) {
+ }
+ try {
+ DcaeLocation loc = factory.genDcaeLocation( "central" );
+ Entity<DcaeLocation> reqEntity = Entity.entity( loc, MediaType.APPLICATION_JSON );
+ Response resp = target( "dcaeLocations").request().post( reqEntity, Response.class );
+ System.out.println( "POST dcaeLocation resp=" + resp.getStatus() + " " + resp.readEntity( String.class ));
+ if ( resp.getStatus() != 409 ) {
+ assertTrue( resp.getStatus() == 201 );
+ }
+ } catch (Exception e ) {
+ }
+
+
+ }
/*
@Before
public void setUp() throws Exception {
diff --git a/src/test/java/org/onap/dmaap/dbcapi/util/FqdnTest.java b/src/test/java/org/onap/dmaap/dbcapi/util/FqdnTest.java
new file mode 100644
index 0000000..7c7815f
--- /dev/null
+++ b/src/test/java/org/onap/dmaap/dbcapi/util/FqdnTest.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * org.onap.dmaap
+ * ================================================================================
+ * Copyright (C) 2019 IBM Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.dmaap.dbcapi.util;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+public class FqdnTest {
+
+ @Test
+ public void testIsValid() {
+ assertTrue(Fqdn.isValid("www.ibm.com"));
+ assertFalse(Fqdn.isValid("testuser@ibm.com"));
+ }
+} \ No newline at end of file