diff options
author | Michael DÜrre <michael.duerre@highstreet-technologies.com> | 2022-01-31 05:11:03 +0100 |
---|---|---|
committer | KAPIL SINGAL <ks220y@att.com> | 2022-02-01 03:42:42 +0000 |
commit | f01064b548d479d2f98abb7d30429b4a410a209e (patch) | |
tree | 08bede472e8833eeb431836a4bb33ae544f5430d /sdnr/wt/data-provider | |
parent | 9912e1626d93afeb4f7148dd5d826ae1caa1ef8a (diff) |
add nodb support
add option to work without db
Issue-ID: CCSDK-3573
Signed-off-by: Michael DÜrre <michael.duerre@highstreet-technologies.com>
Change-Id: I1a1dc785dceb1789fe12bf6b3009e35d56578816
Signed-off-by: Michael DÜrre <michael.duerre@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/data-provider')
9 files changed, 583 insertions, 31 deletions
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbDataProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbDataProvider.java new file mode 100644 index 000000000..2179097cf --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbDataProvider.java @@ -0,0 +1,137 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH 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.ccsdk.features.sdnr.wt.dataprovider.database.nodb; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; +import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultcurrentEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Guicutthrough; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.PmdataEntity; + +public class NoDbDataProvider implements DataProvider { + + @Override + public int doIndexClean(Date olderAreOutdated) { + return 0; + } + + @Override + public long getNumberOfOldObjects(Date olderAreOutdated) { + return 0; + } + + @Override + public void writeConnectionLog(ConnectionlogEntity event) { + + } + + @Override + public void writeEventLog(EventlogEntity event) { + + } + + @Override + public void writeFaultLog(FaultlogEntity fault) { + + } + + @Override + public void writeCMLog(CmlogEntity cm) { + + } + + @Override + public void updateFaultCurrent(FaultcurrentEntity fault) { + + } + + @Override + public int clearFaultsCurrentOfNode(String nodeName) { + return 0; + } + + @Override + public int clearFaultsCurrentOfNodeWithObjectId(String nodeName, String objectId) { + return 0; + } + + @Override + public List<String> getAllNodesWithCurrentAlarms() { + return Arrays.asList(); + } + + @Override + public void writeInventory(String nodeId, List<Inventory> list) { + + } + + @Override + public void writeGuiCutThroughData(Guicutthrough gcData, String nodeId) { + + } + + @Override + public int clearGuiCutThroughEntriesOfNode(String nodeName) { + return 0; + } + + @Override + public boolean updateNetworkConnectionDeviceType(NetworkElementConnectionEntity networkElementConnectionEntitiy, + String nodeId) { + return true; + } + + @Override + public boolean updateNetworkConnection22(NetworkElementConnectionEntity networkElementConnectionEntitiy, + String nodeId) { + return true; + } + + @Override + public void removeNetworkConnection(String nodeId) { + + } + + @Override + public List<NetworkElementConnectionEntity> getNetworkElementConnections() { + return Arrays.asList(); + } + + @Override + public void doWritePerformanceData(List<PmdataEntity> list) { + + } + + @Override + public HtDatabaseClient getRawClient() { + return null; + } +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbDatabaseDataProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbDatabaseDataProvider.java new file mode 100644 index 000000000..e2ba9567e --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbDatabaseDataProvider.java @@ -0,0 +1,244 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH 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.ccsdk.features.sdnr.wt.dataprovider.database.nodb; + +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.DatabaseDataProvider; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMediatorserver; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtUserdataManager; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMediatorServerInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMediatorServerOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateNetworkElementConnectionOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteMaintenanceInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteMaintenanceOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteMediatorServerInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteMediatorServerOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteNetworkElementConnectionInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteNetworkElementConnectionOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EntityInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionEntity; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadEventlogListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultcurrentListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultlogListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadGuiCutThroughEntryOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadInventoryListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadMaintenanceListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadMediatorServerListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadNetworkElementConnectionListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata15mDeviceListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata15mListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata15mLtpListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata24hDeviceListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata24hListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadPmdata24hLtpListOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadStatusOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMaintenanceInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMaintenanceOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMediatorServerInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateMediatorServerOutputBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateNetworkElementConnectionInput; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.UpdateNetworkElementConnectionOutputBuilder; + +public class NoDbDatabaseDataProvider implements DatabaseDataProvider { + + private final HtUserdataManager usermanger; + private final HtDatabaseMediatorserver mediatorserver; + private final HtDatabaseMaintenance maintenance; + private final DataProvider dataprovider; + + public NoDbDatabaseDataProvider() { + this.usermanger = new NoDbHtUserdataManager(); + this.mediatorserver = new NoDbHtDatabaseMediatorserver(); + this.maintenance = new NoDbHtDatabaseMaintenance(); + this.dataprovider = new NoDbDataProvider(); + } + @Override + public HtDatabaseClient getRawClient() { + return null; + } + + @Override + public ReadFaultcurrentListOutputBuilder readFaultCurrentList(EntityInput input) { + return new ReadFaultcurrentListOutputBuilder(); + } + + @Override + public ReadFaultlogListOutputBuilder readFaultLogList(EntityInput input) { + return new ReadFaultlogListOutputBuilder(); + } + + @Override + public ReadCmlogListOutputBuilder readCMLogList(EntityInput input) { + return new ReadCmlogListOutputBuilder(); + } + + @Override + public ReadMaintenanceListOutputBuilder readMaintenanceList(EntityInput input) { + return new ReadMaintenanceListOutputBuilder(); + } + + @Override + public ReadMediatorServerListOutputBuilder readMediatorServerList(EntityInput input) { + return new ReadMediatorServerListOutputBuilder(); + } + + @Override + public ReadNetworkElementConnectionListOutputBuilder readNetworkElementConnectionList(EntityInput input) { + return new ReadNetworkElementConnectionListOutputBuilder(); + } + + @Override + public ReadInventoryListOutputBuilder readInventoryList(EntityInput input) { + return new ReadInventoryListOutputBuilder(); + } + + @Override + public ReadConnectionlogListOutputBuilder readConnectionlogList(EntityInput input) { + return new ReadConnectionlogListOutputBuilder(); + } + + @Override + public ReadEventlogListOutputBuilder readEventlogList(EntityInput input) throws IOException { + return new ReadEventlogListOutputBuilder(); + } + + @Override + public ReadPmdata15mListOutputBuilder readPmdata15mList(EntityInput input) { + return new ReadPmdata15mListOutputBuilder(); + } + + @Override + public ReadPmdata24hListOutputBuilder readPmdata24hList(EntityInput input) { + return new ReadPmdata24hListOutputBuilder(); + } + + @Override + public ReadPmdata15mLtpListOutputBuilder readPmdata15mLtpList(EntityInput input) throws IOException { + return new ReadPmdata15mLtpListOutputBuilder(); + } + + @Override + public ReadPmdata15mDeviceListOutputBuilder readPmdata15mDeviceList(EntityInput input) throws IOException { + return new ReadPmdata15mDeviceListOutputBuilder(); + } + + @Override + public ReadPmdata24hLtpListOutputBuilder readPmdata24hLtpList(EntityInput input) throws IOException { + return new ReadPmdata24hLtpListOutputBuilder(); + } + + @Override + public ReadPmdata24hDeviceListOutputBuilder readPmdata24hDeviceList(EntityInput input) throws IOException { + return new ReadPmdata24hDeviceListOutputBuilder(); + } + + @Override + public ReadStatusOutputBuilder readStatus() throws IOException { + return new ReadStatusOutputBuilder(); + } + + @Override + public boolean waitForYellowDatabaseStatus(long timeout, TimeUnit unit) { + return true; + } + + @Override + public CreateNetworkElementConnectionOutputBuilder createNetworkElementConnection( + NetworkElementConnectionEntity input) throws IOException { + return new CreateNetworkElementConnectionOutputBuilder(); + } + + @Override + public UpdateNetworkElementConnectionOutputBuilder updateNetworkElementConnection( + UpdateNetworkElementConnectionInput input) throws IOException { + return new UpdateNetworkElementConnectionOutputBuilder(); + } + + @Override + public DeleteNetworkElementConnectionOutputBuilder deleteNetworkElementConnection( + DeleteNetworkElementConnectionInput input) throws IOException { + return new DeleteNetworkElementConnectionOutputBuilder(); + } + + @Override + public DeleteMediatorServerOutputBuilder deleteMediatorServer(DeleteMediatorServerInput input) throws IOException { + return new DeleteMediatorServerOutputBuilder(); + } + + @Override + public DeleteMaintenanceOutputBuilder deleteMaintenance(DeleteMaintenanceInput input) throws IOException { + return new DeleteMaintenanceOutputBuilder(); + } + + @Override + public UpdateMaintenanceOutputBuilder updateMaintenance(UpdateMaintenanceInput input) throws IOException { + return new UpdateMaintenanceOutputBuilder(); + } + + @Override + public UpdateMediatorServerOutputBuilder updateMediatorServer(UpdateMediatorServerInput input) throws IOException { + return new UpdateMediatorServerOutputBuilder(); + } + + @Override + public CreateMaintenanceOutputBuilder createMaintenance(CreateMaintenanceInput input) throws IOException { + return new CreateMaintenanceOutputBuilder(); + } + + @Override + public CreateMediatorServerOutputBuilder createMediatorServer(CreateMediatorServerInput input) throws IOException { + return new CreateMediatorServerOutputBuilder(); + } + + @Override + public ReadGuiCutThroughEntryOutputBuilder readGuiCutThroughEntry(EntityInput input) { + return new ReadGuiCutThroughEntryOutputBuilder(); + } + + @Override + public DataProvider getDataProvider() { + return dataprovider; + } + + @Override + public HtDatabaseMaintenance getHtDatabaseMaintenance() { + return this.maintenance; + } + + @Override + public HtDatabaseMediatorserver getHtDatabaseMediatorServer() { + return this.mediatorserver; + } + + @Override + public HtUserdataManager getUserManager() { + return this.usermanger; + } +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbHtDatabaseMaintenance.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbHtDatabaseMaintenance.java new file mode 100644 index 000000000..7fbb2e3dc --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbHtDatabaseMaintenance.java @@ -0,0 +1,57 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH 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.ccsdk.features.sdnr.wt.dataprovider.database.nodb; + +import java.util.Arrays; +import java.util.List; +import org.eclipse.jdt.annotation.Nullable; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MaintenanceBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MaintenanceEntity; + +public class NoDbHtDatabaseMaintenance implements HtDatabaseMaintenance { + + @Override + public MaintenanceEntity createIfNotExists(String mountPointNodeName) { + return new MaintenanceBuilder().build(); + } + + @Override + public void deleteIfNotRequired(String mountPointNodeName) { + + } + + @Override + public List<MaintenanceEntity> getAll() { + return Arrays.asList(); + } + + @Override + public MaintenanceEntity getMaintenance(@Nullable String mountpointName) { + return new MaintenanceBuilder().build(); + } + + @Override + public MaintenanceEntity setMaintenance(MaintenanceEntity m) { + return m; + } +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbHtDatabaseMediatorserver.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbHtDatabaseMediatorserver.java new file mode 100644 index 000000000..9f25608a3 --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbHtDatabaseMediatorserver.java @@ -0,0 +1,36 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH 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.ccsdk.features.sdnr.wt.dataprovider.database.nodb; + +import java.util.Arrays; +import java.util.List; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMediatorserver; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MediatorServerEntity; + +public class NoDbHtDatabaseMediatorserver implements HtDatabaseMediatorserver { + + @Override + public List<MediatorServerEntity> getAll() { + return Arrays.asList(); + } + +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbHtUserdataManager.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbHtUserdataManager.java new file mode 100644 index 000000000..0f50dda0a --- /dev/null +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/nodb/NoDbHtUserdataManager.java @@ -0,0 +1,58 @@ +/* + * ============LICENSE_START======================================================= + * ONAP : ccsdk features + * ================================================================================ + * Copyright (C) 2020 highstreet technologies GmbH 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.ccsdk.features.sdnr.wt.dataprovider.database.nodb; + +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtUserdataManager; + +public class NoDbHtUserdataManager implements HtUserdataManager { + + @Override + public String getUserdata(String username) { + return "{}"; + } + + @Override + public String getUserdata(String username, String key) { + return "{}"; + } + + @Override + public boolean setUserdata(String username, String data) { + return true; + } + + @Override + public boolean setUserdata(String username, String key, String data) { + return true; + } + + @Override + public boolean removeUserdata(String username) { + return true; + } + + @Override + public boolean removeUserdata(String username, String key) { + return true; + } + +} diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java index 6eae55f04..40a46e6fb 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java @@ -23,6 +23,7 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.http.about; import java.io.IOException; import java.net.URL; +import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -36,7 +37,7 @@ import javax.servlet.http.HttpServletResponse; import org.apache.http.HttpHeaders; import org.onap.ccsdk.features.sdnr.wt.common.Resources; import org.onap.ccsdk.features.sdnr.wt.common.file.PomFile; -import org.onap.ccsdk.features.sdnr.wt.common.file.PomPropertiesFile; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.FrameworkUtil; @@ -115,12 +116,11 @@ public class AboutHttpServlet extends HttpServlet { * collect static versioning data */ private void collectStaticData() { - PomPropertiesFile props = this.getPomProperties(); final String ccsdkVersion = this.getPomParentVersion(); final String mdsalVersion = SystemInfo.getMdSalVersion(UNKNOWN); this.data.put(PLACEHOLDER_ONAP_RELEASENAME, ODLVersionLUT.getONAPReleaseName(ccsdkVersion, UNKNOWN)); this.data.put(PLACEHOLDER_ODL_RELEASENAME, ODLVersionLUT.getOdlVersion(mdsalVersion, UNKNOWN)); - this.data.put(PLACEHOLDER_BUILD_TIMESTAMP, props != null ? String.valueOf(props.getBuildDate()) : ""); + this.data.put(PLACEHOLDER_BUILD_TIMESTAMP, getDate(this.getManifestValue("Bnd-LastModified"), UNKNOWN)); this.data.put(PLACEHOLDER_PACAKGE_VERSION, this.getManifestValue("Bundle-Version")); this.data.put(PLACEHOLDER_CCSDK_VERSION, ccsdkVersion); this.data.put(PLACEHOLDER_ONAP_RELEASEVERSION, SystemInfo.getOnapVersion(UNKNOWN)); @@ -129,6 +129,20 @@ public class AboutHttpServlet extends HttpServlet { this.data.put(PLACEHOLDER_PACKAGE_GITHASH, this.getGitHash(UNKNOWN)); } + private String getDate(String value, String defaultValue) { + if(value==null) { + return defaultValue; + } + try { + long x = Long.parseLong(value); + return NetconfTimeStampImpl.getConverter().getTimeStampAsNetconfString(new Date(x)); + } + catch(NumberFormatException e) { + LOG.debug("date value is not a numeric one"); + } + return defaultValue; + } + @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { @@ -217,27 +231,6 @@ public class AboutHttpServlet extends HttpServlet { } /** - * get object representation of /META-INF/maven/groupId/artifactId/pom.properties - * - * @return - */ - private PomPropertiesFile getPomProperties() { - URL url = Resources.getUrlForRessource(AboutHttpServlet.class, - METAINF_MAVEN + groupId + "/" + artifactId + "/pom.properties"); - PomPropertiesFile propfile; - if (url == null) { - return null; - } - try { - propfile = new PomPropertiesFile(url.openStream()); - return propfile; - } catch (Exception e) { - LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e); - } - return null; - } - - /** * get parent pom version out of /META-INF/maven/groupId/artifactId/pom.xml * * @return diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderConfig.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderConfig.java index 5e8dc92fc..950c8e919 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderConfig.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderConfig.java @@ -32,6 +32,9 @@ public class DataProviderConfig implements Configuration { private static final String PROPERTY_KEY_DBTYPE = "dbType"; private static final Object DEFAULT_DBTYPE = "${SDNRDBTYPE}"; private static final SdnrDbType DEFAULT_DBTYPE_VALUE = SdnrDbType.ELASTICSEARCH; + private static final String PROPERTY_KEY_DBENABLED = "enabled"; + private static final String DEFAULT_ISENABLED = "${SDNRDBENABLED}"; + private static final boolean DEFAULT_ISENABLED_IFNOTSET = true; private final EsConfig esConfig; private final SqlDBConfig maridadbConfig; private ConfigurationFileRepresentation configuration; @@ -51,10 +54,18 @@ public class DataProviderConfig implements Configuration { return this.maridadbConfig; } + public boolean isEnabled() { + final String s = this.configuration.getProperty(ConfigurationFileRepresentation.SECTIONNAME_ROOT, PROPERTY_KEY_DBENABLED); + if(s!= null && !s.isBlank()) { + return Boolean.getBoolean(s); + } + return DEFAULT_ISENABLED_IFNOTSET; + } @Override public void defaults() { configuration.setPropertyIfNotAvailable(this.getSectionName(), PROPERTY_KEY_DBTYPE, DEFAULT_DBTYPE); + configuration.setPropertyIfNotAvailable(this.getSectionName(), PROPERTY_KEY_DBENABLED, DEFAULT_ISENABLED); } @Override diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java index 251ba90f2..41fee76ad 100644 --- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java +++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java @@ -39,6 +39,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.DatabaseDataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.impl.ElasticSearchDataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.impl.HtUserdataManagerImpl; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.nodb.NoDbDatabaseDataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.SqlDBDataProvider; import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.MsServlet; import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; @@ -148,10 +149,15 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab this.dbConfig = new DataProviderConfig(configuration); this.dataBroker = dataBroker; this.mediatorServerServlet = mediatorServerServlet; - if (this.dbConfig.getDbType() == SdnrDbType.ELASTICSEARCH) { - this.dataProvider = new ElasticSearchDataProvider(this.dbConfig.getEsConfig()); - } else { - this.dataProvider = new SqlDBDataProvider(this.dbConfig.getMariadbConfig()); + if(this.dbConfig.isEnabled()) { + if (this.dbConfig.getDbType() == SdnrDbType.ELASTICSEARCH) { + this.dataProvider = new ElasticSearchDataProvider(this.dbConfig.getEsConfig()); + } else { + this.dataProvider = new SqlDBDataProvider(this.dbConfig.getMariadbConfig()); + } + } + else { + this.dataProvider = new NoDbDatabaseDataProvider(); } this.dbUserManager = this.dataProvider.getUserManager(); this.dataProvider.waitForYellowDatabaseStatus(DATABASE_TIMEOUT_MS, TimeUnit.MILLISECONDS); @@ -159,6 +165,7 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab // Register ourselves as the REST API RPC implementation LOG.info("Register RPC Service {}", DataProviderServiceImpl.class.getSimpleName()); this.rpcReg = rpcProviderService.registerRpcImplementation(DataProviderService.class, this); + } private void sendResyncCallbackToApiGateway() { diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java index 8c62ec9d5..c12128337 100644 --- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java +++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java @@ -22,7 +22,8 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.test; import static org.junit.Assert.assertEquals; - +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import java.io.File; import org.junit.After; @@ -32,6 +33,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRep import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section; import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section.EnvGetter; import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.EsConfig; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.impl.DataProviderConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,6 +43,7 @@ public class TestConfig { private static final String TESTFILENAME = "testconfig.properties"; private static String ENVSDNRDBURL = "SDNRDBURL"; + private static String ENVSDNRDBENABLED = "SDNRDBENABLED"; private static String SDNRDBURL = "http://sdnrdb:9200"; @After @@ -60,11 +63,17 @@ public class TestConfig { return envname.equals(ENVSDNRDBURL) ? SDNRDBURL : env.getenv(envname); }); ConfigurationFileRepresentation configuration = new ConfigurationFileRepresentation(TESTFILENAME); - EsConfig esConfig = new EsConfig(configuration); + DataProviderConfig dbConfig = new DataProviderConfig(configuration); + EsConfig esConfig = dbConfig.getEsConfig(); LOG.info("Defaultconfiguration: {}", esConfig.toString()); assertEquals("http", esConfig.getHosts()[0].protocol.getValue()); assertEquals(9200, esConfig.getHosts()[0].port); assertEquals("sdnrdb", esConfig.getHosts()[0].hostname); - + assertTrue(dbConfig.isEnabled()); + Section.setEnvGetter((envname) -> { + return envname.equals(ENVSDNRDBENABLED) ? "false" : env.getenv(envname); + }); + assertFalse(dbConfig.isEnabled()); + } } |