summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-sdk')
-rw-r--r--ecomp-sdk/README.md1
-rw-r--r--ecomp-sdk/epsdk-analytics/pom.xml6
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportDefinition.java2
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java10
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java2
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/VisualManager.java8
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/controller/FileServletController.java2
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/ColumnHeader.java9
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/ColumnVisual.java9
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/DataRow.java7
-rw-r--r--ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/DataValue.java9
-rw-r--r--ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportLoaderTest.java1165
-rw-r--r--ecomp-sdk/epsdk-app-common/db-scripts/portalsdk.cql54
-rw-r--r--ecomp-sdk/epsdk-app-common/pom.xml26
-rw-r--r--ecomp-sdk/epsdk-app-os/pom.xml13
-rw-r--r--ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java2
-rw-r--r--ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/filter/SecurityXssFilter.java20
-rw-r--r--ecomp-sdk/epsdk-app-os/src/main/resources/music.properties24
-rw-r--r--ecomp-sdk/epsdk-app-os/src/main/webapp/WEB-INF/web.xml10
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/resources/cache.ccf16
-rw-r--r--ecomp-sdk/epsdk-core/pom.xml30
-rw-r--r--ecomp-sdk/epsdk-fw/pom.xml4
-rw-r--r--ecomp-sdk/epsdk-music/README.md14
-rw-r--r--ecomp-sdk/epsdk-music/pom.xml190
-rw-r--r--ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/EnableMuscicHttpSession.java56
-rw-r--r--ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicHttpSessionConfiguration.java54
-rw-r--r--ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSession.java382
-rw-r--r--ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionConfig.java55
-rw-r--r--ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepository.java135
-rw-r--r--ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandler.java56
-rw-r--r--ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/model/RestResponse.java119
-rw-r--r--ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/model/RestStatusEnum.java54
-rw-r--r--ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/service/MusicService.java543
-rw-r--r--ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicProperties.java217
-rw-r--r--ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java125
-rw-r--r--ecomp-sdk/epsdk-music/src/main/resources/org/onap/music/core/2.4.4/core-2.4.4.jarbin0 -> 132593 bytes
-rw-r--r--ecomp-sdk/epsdk-music/src/main/resources/org/onap/music/core/maven-metadata-local.xml12
-rw-r--r--ecomp-sdk/epsdk-music/src/main/resources/org/onap/music/dependency/2.4.4/dependency-2.4.4.jarbin0 -> 113653669 bytes
-rw-r--r--ecomp-sdk/epsdk-music/src/main/resources/org/onap/music/dependency/maven-metadata-local.xml12
-rw-r--r--ecomp-sdk/epsdk-workflow/pom.xml6
-rw-r--r--ecomp-sdk/pom.xml1
41 files changed, 3425 insertions, 35 deletions
diff --git a/ecomp-sdk/README.md b/ecomp-sdk/README.md
index e1d18139..f721e611 100644
--- a/ecomp-sdk/README.md
+++ b/ecomp-sdk/README.md
@@ -8,6 +8,7 @@ This is the parent Maven project for the following child Maven modules:
* Portal SDK Workflow library
* Portal SDK Common Application library
* Portal SDK Common Overlay Web Application
+* Portal SDK Music library
This area also includes ECOMP Portal SDK web application projects.
diff --git a/ecomp-sdk/epsdk-analytics/pom.xml b/ecomp-sdk/epsdk-analytics/pom.xml
index 5f10690d..09ebf15f 100644
--- a/ecomp-sdk/epsdk-analytics/pom.xml
+++ b/ecomp-sdk/epsdk-analytics/pom.xml
@@ -31,17 +31,17 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<!-- Raptor required Libraries -->
<!-- for static charts -->
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportDefinition.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportDefinition.java
index 0f7ffac9..0b8f1121 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportDefinition.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportDefinition.java
@@ -113,7 +113,7 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
public class ReportDefinition extends ReportWrapper implements Serializable {
- private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportDefinition.class);
+ private static transient final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportDefinition.class);
private ReportSchedule reportSchedule = null;
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java
index f4b54a18..5ffb1326 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/definition/ReportSchedule.java
@@ -40,6 +40,7 @@ package org.onap.portalsdk.analytics.model.definition;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
+import java.io.Serializable;
import java.io.Writer;
import java.sql.Connection;
import java.sql.PreparedStatement;
@@ -77,9 +78,14 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
import org.onap.portalsdk.core.util.SecurityCodecUtil;
import org.owasp.esapi.ESAPI;
-public class ReportSchedule extends RaptorObject {
+public class ReportSchedule extends RaptorObject implements Serializable{
- private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportSchedule.class);
+ /**
+ *
+ */
+ private static final long serialVersionUID = 6936844475227328201L;
+
+ private static transient final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(ReportSchedule.class);
private String reportID = null;
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java
index 7da22187..de8df881 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/FormField.java
@@ -89,7 +89,7 @@ import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate;
public class FormField extends org.onap.portalsdk.analytics.RaptorObject implements Serializable {
- private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FormField.class);
+ private static transient final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FormField.class);
private static final String HTML_FORM = "formd";
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/VisualManager.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/VisualManager.java
index 7036b254..ee0b2b4e 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/VisualManager.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/model/runtime/VisualManager.java
@@ -37,12 +37,18 @@
*/
package org.onap.portalsdk.analytics.model.runtime;
+import java.io.Serializable;
import java.util.HashMap;
import org.onap.portalsdk.analytics.RaptorObject;
import org.onap.portalsdk.analytics.util.AppConstants;
-public class VisualManager extends RaptorObject {
+public class VisualManager extends RaptorObject implements Serializable{
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5503994112113552952L;
+
private HashMap hiddenCols = new HashMap();
private String sortByColId = "";
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/controller/FileServletController.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/controller/FileServletController.java
index b6c985a5..94ee29fd 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/controller/FileServletController.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/system/fusion/controller/FileServletController.java
@@ -64,7 +64,7 @@ import org.springframework.web.servlet.ModelAndView;;
public class FileServletController {
- private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FileServletController.class);
+ private static transient final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(FileServletController.class);
private DataAccessService dataAccessService;
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/ColumnHeader.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/ColumnHeader.java
index 0abd35ca..4a140d15 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/ColumnHeader.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/ColumnHeader.java
@@ -37,7 +37,14 @@
*/
package org.onap.portalsdk.analytics.view;
-public class ColumnHeader extends org.onap.portalsdk.analytics.RaptorObject {
+import java.io.Serializable;
+
+public class ColumnHeader extends org.onap.portalsdk.analytics.RaptorObject implements Serializable{
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5667833660934169723L;
+
private String columnTitle = "";
private String columnWidth = "";
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/ColumnVisual.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/ColumnVisual.java
index 9ce62ef4..f6623bb1 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/ColumnVisual.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/ColumnVisual.java
@@ -37,9 +37,16 @@
*/
package org.onap.portalsdk.analytics.view;
+import java.io.Serializable;
+
import org.onap.portalsdk.analytics.RaptorObject;
-public class ColumnVisual extends RaptorObject {
+public class ColumnVisual extends RaptorObject implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -6102940391623735541L;
+
private String colId = null;
private String colDisplay = null;
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/DataRow.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/DataRow.java
index cd4a0a76..619df67e 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/DataRow.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/DataRow.java
@@ -37,11 +37,16 @@
*/
package org.onap.portalsdk.analytics.view;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Vector;
-public class DataRow/* extends Vector*/ {
+public class DataRow implements Serializable{
+ /**
+ *
+ */
+ private static final long serialVersionUID = 701793162902559746L;
private ArrayList dataValueList = new ArrayList();
private HtmlFormatter rowFormatter = null;
diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/DataValue.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/DataValue.java
index e95e2de0..c4627ca4 100644
--- a/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/DataValue.java
+++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/onap/portalsdk/analytics/view/DataValue.java
@@ -37,7 +37,14 @@
*/
package org.onap.portalsdk.analytics.view;
-public class DataValue extends org.onap.portalsdk.analytics.RaptorObject {
+import java.io.Serializable;
+
+public class DataValue extends org.onap.portalsdk.analytics.RaptorObject implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1264128118175701859L;
+
private String displayValue = "";
private String displayCalculatedValue = "";
diff --git a/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportLoaderTest.java b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportLoaderTest.java
new file mode 100644
index 00000000..6c1698dd
--- /dev/null
+++ b/ecomp-sdk/epsdk-analytics/src/test/java/org/onap/portalsdk/analytics/model/ReportLoaderTest.java
@@ -0,0 +1,1165 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalsdk.analytics.model;
+
+import static org.junit.Assert.*;
+
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.Vector;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.portalsdk.analytics.error.RaptorException;
+import org.onap.portalsdk.analytics.error.ReportSQLException;
+import org.onap.portalsdk.analytics.model.base.ReportWrapper;
+import org.onap.portalsdk.analytics.model.runtime.ReportRuntime;
+import org.onap.portalsdk.analytics.system.AppUtils;
+import org.onap.portalsdk.analytics.system.DbUtils;
+import org.onap.portalsdk.analytics.system.Globals;
+import org.onap.portalsdk.analytics.util.AppConstants;
+import org.onap.portalsdk.analytics.util.DataSet;
+import org.onap.portalsdk.analytics.util.Utils;
+import org.onap.portalsdk.analytics.xmlobj.MockitoTestSuite;
+import org.onap.portalsdk.core.util.SecurityCodecUtil;
+import org.owasp.esapi.ESAPI;
+import org.owasp.esapi.Encoder;
+import org.owasp.esapi.codecs.Codec;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest({ Globals.class, DbUtils.class, Utils.class, AppUtils.class, ESAPI.class, Encoder.class,
+ SecurityCodecUtil.class, Codec.class })
+public class ReportLoaderTest {
+
+ @Mock
+ Connection connection;
+ @Mock
+ PreparedStatement stmt;
+ @Mock
+ ResultSet rs;
+
+ @Mock
+ InputStream inputStream;
+
+ @Mock
+ InputStreamReader in;
+
+ MockitoTestSuite mockitoTestSuite = new MockitoTestSuite();
+ HttpServletRequest mockedRequest = mockitoTestSuite.getMockedRequest();
+ HttpServletResponse mockedResponse = mockitoTestSuite.getMockedResponse();
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class)
+ public void loadCustomReportXMLTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(DbUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(Globals.getLoadCustomReportXml()).thenReturn("testSql");
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isWeblogicServer()).thenReturn(true);
+ reportLoader.loadCustomReportXML("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class)
+ public void loadCustomReportXML1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(DbUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(Globals.getLoadCustomReportXml()).thenReturn("testSql");
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isWeblogicServer()).thenReturn(true);
+ Mockito.when(rs.next()).thenReturn(true);
+ java.sql.Clob clob = PowerMockito.mock(java.sql.Clob.class);
+ Mockito.when(rs.getClob(1)).thenReturn(clob);
+ Mockito.when(clob.getAsciiStream()).thenReturn(inputStream);
+ PowerMockito.whenNew(InputStreamReader.class).withArguments(Matchers.any(InputStream.class)).thenReturn(in);
+ reportLoader.loadCustomReportXML("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class)
+ public void loadCustomReportXML2Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(DbUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(Globals.getLoadCustomReportXml()).thenReturn("testSql");
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isWeblogicServer()).thenReturn(false);
+ Mockito.when(rs.next()).thenReturn(true);
+ java.sql.Clob clob = PowerMockito.mock(java.sql.Clob.class);
+ Mockito.when(rs.getClob(1)).thenReturn(clob);
+ Mockito.when(clob.getAsciiStream()).thenReturn(inputStream);
+ PowerMockito.whenNew(InputStreamReader.class).withArguments(Matchers.any(InputStream.class)).thenReturn(in);
+ Mockito.when(in.read(Matchers.any(char[].class))).thenReturn(1);
+ reportLoader.loadCustomReportXML("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadCustomReportXML3Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(DbUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(Globals.getLoadCustomReportXml()).thenReturn("testSql");
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isWeblogicServer()).thenReturn(false);
+ Mockito.when(rs.next()).thenReturn(true);
+ java.sql.Clob clob = PowerMockito.mock(java.sql.Clob.class);
+ Mockito.when(rs.getClob(1)).thenReturn(clob);
+ Mockito.when(clob.getAsciiStream()).thenReturn(inputStream);
+ PowerMockito.whenNew(InputStreamReader.class).withArguments(Matchers.any(InputStream.class)).thenReturn(in);
+ Mockito.when(in.read(Matchers.any(char[].class))).thenReturn(1);
+ Mockito.when(Globals.isPostgreSQL()).thenReturn(true);
+ reportLoader.loadCustomReportXML("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadCustomReportXML4Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(DbUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(Globals.getLoadCustomReportXml()).thenReturn("testSql");
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isWeblogicServer()).thenReturn(false);
+ Mockito.when(rs.next()).thenReturn(true);
+ java.sql.Clob clob = PowerMockito.mock(java.sql.Clob.class);
+ Mockito.when(rs.getClob(1)).thenReturn(clob);
+ Mockito.when(clob.getAsciiStream()).thenReturn(inputStream);
+ PowerMockito.whenNew(InputStreamReader.class).withArguments(Matchers.any(InputStream.class)).thenReturn(in);
+ Mockito.when(in.read(Matchers.any(char[].class))).thenReturn(1);
+ Mockito.when(Globals.isMySQL()).thenReturn(true);
+ reportLoader.loadCustomReportXML("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class)
+ public void updateCustomReportRecTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ ReportWrapper rw = PowerMockito.mock(ReportWrapper.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+
+ Mockito.when(Globals.getUpdateCustomReportRec()).thenReturn("testSql");
+ Mockito.when(rw.getReportName()).thenReturn("name");
+ Mockito.when(rw.getReportDescr()).thenReturn("desr");
+ Mockito.when(rw.isPublic()).thenReturn(true);
+ Mockito.when(rw.isMenuApproved()).thenReturn(true);
+ Mockito.when(rw.getMenuID()).thenReturn("id");
+ Mockito.when(rw.getOwnerID()).thenReturn("test");
+ Mockito.when(rw.getUpdateID()).thenReturn("test");
+ Mockito.when(rw.getUpdateDate()).thenReturn("test");
+ Mockito.when(rw.isDashboardType()).thenReturn(true);
+ Mockito.when(rw.getReportType()).thenReturn("test");
+ Mockito.when(rw.getReportID()).thenReturn("1");
+ Mockito.when(Globals.getDBUpdateReportXml()).thenReturn("test");
+ Mockito.when(Globals.getTimeFormat()).thenReturn("testformat");
+ PowerMockito.mockStatic(Utils.class);
+ Mockito.when(Utils.oracleSafe(Matchers.anyString())).thenReturn("test");
+ Mockito.when(Globals.isMySQL()).thenReturn(false);
+ Mockito.when(connection.prepareStatement(Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt()))
+ .thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ reportLoader.updateCustomReportRec(connection, rw, "test");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void updateCustomReportRec1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ ReportWrapper rw = PowerMockito.mock(ReportWrapper.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+
+ Mockito.when(Globals.getUpdateCustomReportRec()).thenReturn("testSql");
+ Mockito.when(rw.getReportName()).thenReturn("name");
+ Mockito.when(rw.getReportDescr()).thenReturn("desr");
+ Mockito.when(rw.isPublic()).thenReturn(true);
+ Mockito.when(rw.isMenuApproved()).thenReturn(true);
+ Mockito.when(rw.getMenuID()).thenReturn("id");
+ Mockito.when(rw.getOwnerID()).thenReturn("test");
+ Mockito.when(rw.getUpdateID()).thenReturn("test");
+ Mockito.when(rw.getUpdateDate()).thenReturn("test");
+ Mockito.when(rw.isDashboardType()).thenReturn(true);
+ Mockito.when(rw.getReportType()).thenReturn("test");
+ Mockito.when(rw.getReportID()).thenReturn("1");
+ Mockito.when(Globals.getDBUpdateReportXml()).thenReturn("test");
+ Mockito.when(Globals.getTimeFormat()).thenReturn("testformat");
+ PowerMockito.mockStatic(Utils.class);
+ Mockito.when(Utils.oracleSafe(Matchers.anyString())).thenReturn("test");
+ Mockito.when(Globals.isMySQL()).thenReturn(false);
+ Mockito.when(connection.prepareStatement(Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt()))
+ .thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isPostgreSQL()).thenReturn(true);
+ Mockito.when(rs.next()).thenReturn(true);
+ reportLoader.updateCustomReportRec(connection, rw, "test");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class)
+ public void updateCustomReportRec2Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ ReportWrapper rw = PowerMockito.mock(ReportWrapper.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+
+ Mockito.when(Globals.getUpdateCustomReportRec()).thenReturn("testSql");
+ Mockito.when(rw.getReportName()).thenReturn("name");
+ Mockito.when(rw.getReportDescr()).thenReturn("desr");
+ Mockito.when(rw.isPublic()).thenReturn(true);
+ Mockito.when(rw.isMenuApproved()).thenReturn(true);
+ Mockito.when(rw.getMenuID()).thenReturn("id");
+ Mockito.when(rw.getOwnerID()).thenReturn("test");
+ Mockito.when(rw.getUpdateID()).thenReturn("test");
+ Mockito.when(rw.getUpdateDate()).thenReturn("test");
+ Mockito.when(rw.isDashboardType()).thenReturn(true);
+ Mockito.when(rw.getReportType()).thenReturn("test");
+ Mockito.when(rw.getReportID()).thenReturn("1");
+ Mockito.when(Globals.getDBUpdateReportXml()).thenReturn("test");
+ Mockito.when(Globals.getTimeFormat()).thenReturn("testformat");
+ PowerMockito.mockStatic(Utils.class);
+ Mockito.when(Utils.oracleSafe(Matchers.anyString())).thenReturn("test");
+ Mockito.when(Globals.isMySQL()).thenReturn(false);
+ Mockito.when(connection.prepareStatement(Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt()))
+ .thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isPostgreSQL()).thenReturn(true);
+ Mockito.when(rs.next()).thenReturn(false);
+ reportLoader.updateCustomReportRec(connection, rw, "test");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.RaptorException.class)
+ public void updateCustomReportRec3Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ ReportWrapper rw = PowerMockito.mock(ReportWrapper.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+
+ Mockito.when(Globals.getUpdateCustomReportRec()).thenReturn("testSql");
+ Mockito.when(rw.getReportName()).thenReturn("name");
+ Mockito.when(rw.getReportDescr()).thenReturn("desr");
+ Mockito.when(rw.isPublic()).thenReturn(true);
+ Mockito.when(rw.isMenuApproved()).thenReturn(true);
+ Mockito.when(rw.getMenuID()).thenReturn("id");
+ Mockito.when(rw.getOwnerID()).thenReturn("test");
+ Mockito.when(rw.getUpdateID()).thenReturn("test");
+ Mockito.when(rw.getUpdateDate()).thenReturn("test");
+ Mockito.when(rw.isDashboardType()).thenReturn(true);
+ Mockito.when(rw.getReportType()).thenReturn("test");
+ Mockito.when(rw.getReportID()).thenReturn("1");
+ Mockito.when(Globals.getDBUpdateReportXml()).thenReturn("test");
+ Mockito.when(Globals.getTimeFormat()).thenReturn("testformat");
+ PowerMockito.mockStatic(Utils.class);
+ Mockito.when(Utils.oracleSafe(Matchers.anyString())).thenReturn("test");
+ Mockito.when(Globals.isMySQL()).thenReturn(true);
+ Mockito.when(connection.prepareStatement(Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt()))
+ .thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isPostgreSQL()).thenReturn(false);
+ Mockito.when(rs.next()).thenReturn(false);
+ reportLoader.updateCustomReportRec(connection, rw, "test");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void updateCustomReportRec4Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ ReportWrapper rw = PowerMockito.mock(ReportWrapper.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+
+ Mockito.when(Globals.getUpdateCustomReportRec()).thenReturn("testSql");
+ Mockito.when(rw.getReportName()).thenReturn("name");
+ Mockito.when(rw.getReportDescr()).thenReturn("desr");
+ Mockito.when(rw.isPublic()).thenReturn(true);
+ Mockito.when(rw.isMenuApproved()).thenReturn(true);
+ Mockito.when(rw.getMenuID()).thenReturn("id");
+ Mockito.when(rw.getOwnerID()).thenReturn("test");
+ Mockito.when(rw.getUpdateID()).thenReturn("test");
+ Mockito.when(rw.getUpdateDate()).thenReturn("test");
+ Mockito.when(rw.isDashboardType()).thenReturn(true);
+ Mockito.when(rw.getReportType()).thenReturn("test");
+ Mockito.when(rw.getReportID()).thenReturn("1");
+ Mockito.when(Globals.getDBUpdateReportXml()).thenReturn("test");
+ Mockito.when(Globals.getTimeFormat()).thenReturn("testformat");
+ PowerMockito.mockStatic(Utils.class);
+ Mockito.when(Utils.oracleSafe(Matchers.anyString())).thenReturn("test");
+ Mockito.when(Globals.isMySQL()).thenReturn(true);
+ Mockito.when(connection.prepareStatement(Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt()))
+ .thenReturn(stmt);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isPostgreSQL()).thenReturn(false);
+ Mockito.when(rs.next()).thenReturn(true);
+ Mockito.when(rs.getBinaryStream("report_xml")).thenReturn(inputStream);
+ Mockito.when(Globals.getDBUpdateReportXmlMySql()).thenReturn("test");
+ reportLoader.updateCustomReportRec(connection, rw, "test");
+ }
+
+ // @SuppressWarnings("static-access")
+ // @Test
+ // public void isDashboardTypeTest() throws Exception
+ // {
+ // ReportLoader reportLoader = new ReportLoader();
+ // reportLoader.isDashboardType("test");
+ // }
+ @SuppressWarnings("static-access")
+ @Test
+ public void isReportsAlreadyScheduledTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getIsReportAlreadyScheduled()).thenReturn("testSql");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ reportLoader.isReportsAlreadyScheduled("1");
+
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void isReportsAlreadyScheduled1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getIsReportAlreadyScheduled()).thenReturn("testSql");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(rs.next()).thenReturn(true);
+ reportLoader.isReportsAlreadyScheduled("1");
+
+ }
+
+ @SuppressWarnings({ "static-access", "unchecked" })
+ @Test(expected = org.onap.portalsdk.analytics.error.ReportSQLException.class)
+ public void isReportsAlreadyScheduled2Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getIsReportAlreadyScheduled()).thenReturn("testSql");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenThrow(SQLException.class);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(rs.next()).thenReturn(true);
+ reportLoader.isReportsAlreadyScheduled("1");
+
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.ReportSQLException.class)
+ public void isReportsAlreadyScheduled3Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getIsReportAlreadyScheduled()).thenReturn("testSql");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(rs.next()).thenReturn(true);
+ Mockito.doThrow(SQLException.class).when(rs).close();
+ reportLoader.isReportsAlreadyScheduled("1");
+
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void createCustomReportRecTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ ReportWrapper rw = PowerMockito.mock(ReportWrapper.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+
+ Mockito.when(Globals.getCreateCustomReportRec()).thenReturn("testSql");
+ Mockito.when(rw.getReportName()).thenReturn("name");
+ Mockito.when(rw.getReportDescr()).thenReturn("desr");
+ Mockito.when(rw.isPublic()).thenReturn(true);
+ Mockito.when(rw.isMenuApproved()).thenReturn(true);
+ Mockito.when(rw.getMenuID()).thenReturn("id");
+ Mockito.when(rw.getOwnerID()).thenReturn("test");
+ Mockito.when(rw.getUpdateID()).thenReturn("test");
+ Mockito.when(rw.getUpdateDate()).thenReturn("test");
+ Mockito.when(rw.isDashboardType()).thenReturn(true);
+ Mockito.when(rw.getReportType()).thenReturn("test");
+ Mockito.when(rw.getReportID()).thenReturn("1");
+ PowerMockito.mockStatic(Utils.class);
+ Mockito.when(rw.getCreateID()).thenReturn("test");
+ Mockito.when(rw.getFolderId()).thenReturn("1");
+ Mockito.when(rw.getCreateDate()).thenReturn("11/11/2010");
+ Mockito.when(Utils.oracleSafe(Matchers.anyString())).thenReturn("test");
+ Mockito.when(Globals.getTimeFormat()).thenReturn("test");
+ Mockito.when(Globals.getDBUpdateReportXml()).thenReturn("test");
+ Mockito.when(Globals.getTimeFormat()).thenReturn("testformat");
+ PowerMockito.mockStatic(Utils.class);
+ Mockito.when(Utils.oracleSafe(Matchers.anyString())).thenReturn("test");
+ Mockito.when(Globals.isMySQL()).thenReturn(false);
+ Mockito.when(connection.prepareStatement(Matchers.anyString(), Matchers.anyInt(), Matchers.anyInt()))
+ .thenReturn(stmt);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(Globals.isPostgreSQL()).thenReturn(true);
+ Mockito.when(rs.next()).thenReturn(true);
+ reportLoader.createCustomReportRec(connection, rw, "test");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getUserReportNamesTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Mockito.when(Globals.getTheUserReportNames()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getUserReportNames(mockedRequest);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getReportOwnerIDTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheReportOwnerId()).thenReturn("test");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(rs.next()).thenReturn(true);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(rs.getString(1)).thenReturn("test");
+ reportLoader.getReportOwnerID("1");
+
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.ReportSQLException.class)
+ public void getReportOwnerID1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheReportOwnerId()).thenReturn("test");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenThrow(SQLException.class);
+ Mockito.when(rs.next()).thenReturn(true);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(rs.getString(1)).thenReturn("test");
+ reportLoader.getReportOwnerID("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.ReportSQLException.class)
+ public void getReportOwnerID2Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheReportOwnerId()).thenReturn("test");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.when(rs.next()).thenReturn(true);
+ Mockito.when(stmt.executeQuery()).thenReturn(rs);
+ Mockito.when(rs.getString(1)).thenReturn("test");
+ Mockito.doThrow(SQLException.class).when(rs).close();
+ reportLoader.getReportOwnerID("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void deleteReportRecordTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(DbUtils.startTransaction()).thenReturn(connection);
+ Mockito.when(Globals.getDeleteReportRecordLog()).thenReturn("test");
+ PowerMockito.mockStatic(ESAPI.class);
+ PowerMockito.mockStatic(SecurityCodecUtil.class);
+ Mockito.when(mockedRequest.getParameter("action")).thenReturn("test");
+ ReportRuntime rr = PowerMockito.mock(ReportRuntime.class);
+ Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr);
+ Encoder encoder = PowerMockito.mock(Encoder.class);
+ Mockito.when(ESAPI.encoder()).thenReturn(encoder);
+ Codec codec = PowerMockito.mock(Codec.class);
+ Mockito.when(SecurityCodecUtil.getCodec()).thenReturn(codec);
+ Mockito.when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *");
+ reportLoader.deleteReportRecord("test");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void deleteReportRecord1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(DbUtils.startTransaction()).thenReturn(connection);
+ Mockito.when(Globals.getDeleteReportRecordLog()).thenReturn("test");
+ Mockito.when(Globals.getDeleteReportRecordUsers()).thenReturn("test");
+ Mockito.when(Globals.getDeleteReportRecordSchedule()).thenReturn("test");
+ Mockito.when(Globals.getDeleteReportRecordAccess()).thenReturn("test");
+ Mockito.when(Globals.getDeleteReportRecordEmail()).thenReturn("test");
+ Mockito.when(Globals.getDeleteReportRecordFavorite()).thenReturn("test");
+ Mockito.when(Globals.getDeleteReportRecordReport()).thenReturn("test");
+ PowerMockito.mockStatic(ESAPI.class);
+ PowerMockito.mockStatic(SecurityCodecUtil.class);
+ Mockito.when(mockedRequest.getParameter("action")).thenReturn("test");
+ ReportRuntime rr = PowerMockito.mock(ReportRuntime.class);
+ Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr);
+ Encoder encoder = PowerMockito.mock(Encoder.class);
+ Mockito.when(ESAPI.encoder()).thenReturn(encoder);
+ Codec codec = PowerMockito.mock(Codec.class);
+ Mockito.when(SecurityCodecUtil.getCodec()).thenReturn(codec);
+ Mockito.when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *");
+ reportLoader.deleteReportRecord("test");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadQuickLinksTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadQuickLinks()).thenReturn("testsql");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ reportLoader.loadQuickLinks(mockedRequest, "1", true);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getQuickLinksJSONTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadQuickLinks()).thenReturn("test");
+ PowerMockito.mockStatic(ESAPI.class);
+ PowerMockito.mockStatic(SecurityCodecUtil.class);
+ Mockito.when(mockedRequest.getParameter("action")).thenReturn("test");
+ ReportRuntime rr = PowerMockito.mock(ReportRuntime.class);
+ Mockito.when(mockedRequest.getSession().getAttribute(AppConstants.SI_REPORT_RUNTIME)).thenReturn(rr);
+ Encoder encoder = PowerMockito.mock(Encoder.class);
+ Mockito.when(ESAPI.encoder()).thenReturn(encoder);
+ Codec codec = PowerMockito.mock(Codec.class);
+ Mockito.when(SecurityCodecUtil.getCodec()).thenReturn(codec);
+ Mockito.when(encoder.encodeForSQL(Matchers.any(Codec.class), Matchers.anyString())).thenReturn("select *");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ reportLoader.getQuickLinksJSON(mockedRequest, "1", true);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadFolderReportsTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadFolderReports()).thenReturn("test");
+ Mockito.when(Globals.getLoadFolderReportsUser()).thenReturn("test");
+ Mockito.when(Globals.getLoadFolderReportsPublicSql()).thenReturn("test");
+
+ Mockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(true);
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when( ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadFolderReports(mockedRequest, "1", true, "folderId", true, true);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadFolderReports1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadFolderReports()).thenReturn("test");
+ Mockito.when(Globals.getLoadFolderReportsUser()).thenReturn("test");
+ Mockito.when(Globals.getLoadFolderReportsPublicSql()).thenReturn("test");
+
+ Mockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(false);
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when( ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadFolderReports(mockedRequest, "1", true, "folderId", false, true);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadFolderReports2Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadFolderReports()).thenReturn("test");
+ Mockito.when(Globals.getLoadFolderReportsUser()).thenReturn("test");
+ Mockito.when(Globals.getLoadFolderReportsPublicSql()).thenReturn("test");
+
+ Mockito.when(AppUtils.isSuperUser(mockedRequest)).thenReturn(false);
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when( ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadFolderReports(mockedRequest, "1", true, "folderId", false, false);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadQuickDownloadLinksTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getLoadQuickDownloadLinks()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadQuickDownloadLinks("test", mockedRequest);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadQuickDownloadLinks1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getLoadQuickDownloadLinks()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadQuickDownloadLinks("test", mockedRequest);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadReportsToScheduleTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadReportsToSchedule()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getItem(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadReportsToSchedule(mockedRequest);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadReportsToSchedule1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadReportsToSchedule()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getItem(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadReportsToSchedule(mockedRequest);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadReportsToAddInDashboardTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadReportsToAddInDashboard()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getItem(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadReportsToAddInDashboard(mockedRequest);
+ }
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadReportsToAddInDashboard1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadReportsToAddInDashboard()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getItem(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadReportsToAddInDashboard(mockedRequest);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadReportsToAddInDashboard2Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadReportsToAddInDashboard()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getItem(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadReportsToAddInDashboard(mockedRequest);
+ }
+
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadMyRecentLinksTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ vc.add("test");
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadMyRecentLinks()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getItem(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadMyRecentLinks("test",mockedRequest);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadMyRecentLinks1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Vector vc = new Vector();
+ Mockito.when(AppUtils.getUserRoles(mockedRequest)).thenReturn(vc);
+ Mockito.when(Globals.getLoadMyRecentLinks()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getItem(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadMyRecentLinks("test",mockedRequest);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void createReportLogEntryTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getCreateReportLogEntry()).thenReturn("test");
+ Mockito.when(Globals.getEnableReportLog()).thenReturn(true);
+ reportLoader.createReportLogEntry(connection, "test", "test", "test", "executionTime", "form_fields");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void createReportLogEntry1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getCreateReportLogEntry()).thenReturn("test");
+ Mockito.when(Globals.getEnableReportLog()).thenReturn(true);
+ reportLoader.createReportLogEntry(null, "test", "test", "test", "executionTime", "form_fields");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void createReportLogEntryForExecutionTimeTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getCreateReportLogEntryExecTime()).thenReturn("test");
+ Mockito.when(Globals.getEnableReportLog()).thenReturn(true);
+ reportLoader.createReportLogEntryForExecutionTime(connection, "test", "test", "test", "executionTime", "form_fields");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void createReportLogEntryForExecutionTime1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getCreateReportLogEntryExecTime()).thenReturn("test");
+ Mockito.when(Globals.getEnableReportLog()).thenReturn(true);
+ reportLoader.createReportLogEntryForExecutionTime(null, "test", "test", "test", "executionTime", "form_fields");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void clearReportLogEntriesTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getClearReportLogEntries()).thenReturn("test");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ reportLoader.clearReportLogEntries("1","2");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.ReportSQLException.class)
+ public void clearReportLogEntries1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getClearReportLogEntries()).thenReturn("test");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenReturn(stmt);
+ Mockito.doThrow(SQLException.class).when(stmt).close();
+ reportLoader.clearReportLogEntries("1","2");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test(expected = org.onap.portalsdk.analytics.error.ReportSQLException.class)
+ public void clearReportLogEntries2Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getClearReportLogEntries()).thenReturn("test");
+ Mockito.when(DbUtils.getConnection()).thenReturn(connection);
+ Mockito.when(connection.prepareStatement(Matchers.anyString())).thenThrow(SQLException.class);
+ reportLoader.clearReportLogEntries("1","2");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadReportLogEntriesTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getLoadReportLogEntries()).thenReturn("test");
+ Mockito.when(AppUtils.getRaptorActionURL()).thenReturn("test");
+ Mockito.when(AppUtils.getImgFolderURL()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadReportLogEntries("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void loadReportLogEntries1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getLoadReportLogEntries()).thenReturn("test");
+ Mockito.when(AppUtils.getRaptorActionURL()).thenReturn("test");
+ Mockito.when(AppUtils.getImgFolderURL()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.loadReportLogEntries("1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void doesUserCanScheduleReportTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(true);
+ reportLoader.doesUserCanScheduleReport(mockedRequest, "1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void doesUserCanScheduleReport1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false);
+ Mockito.when(Globals.getDoesUserCanScheduleReport()).thenReturn("test");
+ Mockito.when(Globals.getScheduleLimit()).thenReturn(1);
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(Globals.getDoesUserCanSchedule()).thenReturn("1");
+
+ reportLoader.doesUserCanScheduleReport(mockedRequest, "1");
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void doesUserCanScheduleReport2Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false);
+ Mockito.when(Globals.getDoesUserCanScheduleReport()).thenReturn("test");
+ Mockito.when(Globals.getScheduleLimit()).thenReturn(1);
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(Globals.getDoesUserCanSchedule()).thenReturn("1");
+
+ reportLoader.doesUserCanScheduleReport(mockedRequest, "1");
+ }
+ @SuppressWarnings("static-access")
+ @Test
+ public void doesUserCanScheduleReport3Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(AppUtils.getUserID(mockedRequest)).thenReturn("test");
+ Mockito.when(AppUtils.isAdminUser(mockedRequest)).thenReturn(false);
+ Mockito.when(Globals.getDoesUserCanScheduleReport()).thenReturn("test");
+ Mockito.when(Globals.getScheduleLimit()).thenReturn(1);
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(Globals.getDoesUserCanSchedule()).thenReturn("1");
+ reportLoader.doesUserCanScheduleReport(mockedRequest, null);
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getSystemDateTimeTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheSystemDateTime()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getSystemDateTime();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getSystemDateTime1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheSystemDateTime()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getSystemDateTime();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getNextDaySystemDateTimeTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheNextDayDateTime()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getNextDaySystemDateTime();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getNextDaySystemDateTime1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheNextDayDateTime()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getNextDaySystemDateTime();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getNext15MinutesOfSystemDateTimeTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheNextFifteenMinDateTime()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getNext15MinutesOfSystemDateTime();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getNext15MinutesOfSystemDateTime1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheNextFifteenMinDateTime()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getNext15MinutesOfSystemDateTime();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getNext30MinutesOfSystemDateTimeTest() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheNextThirtyMinDateTime()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(1);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getNext15MinutesOfSystemDateTime();
+ }
+
+ @SuppressWarnings("static-access")
+ @Test
+ public void getNext30MinutesOfSystemDateTime1Test() throws Exception {
+ ReportLoader reportLoader = new ReportLoader();
+ PowerMockito.mockStatic(AppUtils.class);
+ PowerMockito.mockStatic(Globals.class);
+ PowerMockito.mockStatic(DbUtils.class);
+ Mockito.when(Globals.getTheNextThirtyMinDateTime()).thenReturn("test");
+ DataSet ds = PowerMockito.mock(DataSet.class);
+ Mockito.when(DbUtils.executeQuery(Matchers.anyString())).thenReturn(ds);
+ Mockito.when(ds.getRowCount()).thenReturn(0);
+ Mockito.when(ds.getString(Matchers.anyInt(), Matchers.anyInt())).thenReturn("test");
+ reportLoader.getNext30MinutesOfSystemDateTime();
+ }
+}
diff --git a/ecomp-sdk/epsdk-app-common/db-scripts/portalsdk.cql b/ecomp-sdk/epsdk-app-common/db-scripts/portalsdk.cql
new file mode 100644
index 00000000..62da5dd7
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-common/db-scripts/portalsdk.cql
@@ -0,0 +1,54 @@
+CREATE KEYSPACE IF NOT EXISTS portalsdk
+ WITH REPLICATION = {
+ 'class' : 'SimpleStrategy',
+ 'replication_factor': 1
+ }
+ AND DURABLE_WRITES = true;
+
+
+CREATE TABLE portalsdk.spring_session (
+ primary_id text PRIMARY KEY,
+ creation_time text,
+ expiry_time text,
+ last_access_time text,
+ max_inactive_interval text,
+ principal_name text,
+ session_id text,
+ vector_ts text
+) WITH bloom_filter_fp_chance = 0.01
+ AND caching = {'keys': 'ALL', 'rows_per_partition': '10'}
+ AND comment = ''
+ AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
+ AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
+ AND crc_check_chance = 1.0
+ AND dclocal_read_repair_chance = 0.1
+ AND default_time_to_live = 0
+ AND gc_grace_seconds = 864000
+ AND max_index_interval = 2048
+ AND memtable_flush_period_in_ms = 0
+ AND min_index_interval = 128
+ AND read_repair_chance = 0.0
+ AND speculative_retry = '99PERCENTILE';
+
+
+CREATE TABLE portalsdk.spring_session_attributes (
+ primary_id text,
+ attribute_name text,
+ attribute_bytes blob,
+ vector_ts text,
+ PRIMARY KEY (primary_id, attribute_name)
+) WITH CLUSTERING ORDER BY (attribute_name ASC)
+ AND bloom_filter_fp_chance = 0.01
+ AND caching = {'keys': 'ALL', 'rows_per_partition': '1'}
+ AND comment = ''
+ AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
+ AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
+ AND crc_check_chance = 1.0
+ AND dclocal_read_repair_chance = 0.1
+ AND default_time_to_live = 0
+ AND gc_grace_seconds = 864000
+ AND max_index_interval = 2048
+ AND memtable_flush_period_in_ms = 0
+ AND min_index_interval = 128
+ AND read_repair_chance = 0.0
+ AND speculative_retry = '99PERCENTILE';
diff --git a/ecomp-sdk/epsdk-app-common/pom.xml b/ecomp-sdk/epsdk-app-common/pom.xml
index 74621092..e9eec2ac 100644
--- a/ecomp-sdk/epsdk-app-common/pom.xml
+++ b/ecomp-sdk/epsdk-app-common/pom.xml
@@ -129,17 +129,17 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
@@ -236,6 +236,16 @@
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.1.0</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- Jacoco for offline instrumentation -->
<dependency>
@@ -339,5 +349,15 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.3</version>
+ </dependency>
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.2</version>
+ </dependency>
</dependencies>
</project>
diff --git a/ecomp-sdk/epsdk-app-os/pom.xml b/ecomp-sdk/epsdk-app-os/pom.xml
index 49298d6a..496f3e3e 100644
--- a/ecomp-sdk/epsdk-app-os/pom.xml
+++ b/ecomp-sdk/epsdk-app-os/pom.xml
@@ -243,6 +243,12 @@
<artifactId>epsdk-workflow</artifactId>
<version>${epsdk.version}</version>
</dependency>
+ <!-- Music -->
+ <dependency>
+ <groupId>org.onap.portal.sdk</groupId>
+ <artifactId>epsdk-music</artifactId>
+ <version>${epsdk.version}</version>
+ </dependency>
<dependency>
<groupId>com.att.eelf</groupId>
<artifactId>eelf-core</artifactId>
@@ -252,17 +258,17 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
@@ -362,5 +368,6 @@
<version>${jacoco.version}</version>
<classifier>runtime</classifier>
</dependency>
+
</dependencies>
</project>
diff --git a/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java b/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java
index 6f3e8f28..9c777b9e 100644
--- a/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java
+++ b/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/conf/ExternalAppConfig.java
@@ -41,6 +41,7 @@ import java.util.ArrayList;
import java.util.List;
import org.onap.portalapp.login.LoginStrategyImpl;
+import org.onap.portalapp.music.conf.MusicSessionConfig;
import org.onap.portalapp.scheduler.RegistryAdapter;
import org.onap.portalsdk.core.auth.LoginStrategy;
import org.onap.portalsdk.core.conf.AppConfig;
@@ -75,6 +76,7 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
@Profile("src")
@EnableAsync
@EnableScheduling
+@Import({ MusicSessionConfig.class })
public class ExternalAppConfig extends AppConfig implements Configurable {
private RegistryAdapter schedulerRegistryAdapter;
diff --git a/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/filter/SecurityXssFilter.java b/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/filter/SecurityXssFilter.java
index aad01286..0a1f340d 100644
--- a/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/filter/SecurityXssFilter.java
+++ b/ecomp-sdk/epsdk-app-os/src/main/java/org/onap/portalapp/filter/SecurityXssFilter.java
@@ -44,6 +44,9 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
import javax.servlet.FilterChain;
import javax.servlet.ReadListener;
@@ -74,8 +77,25 @@ public class SecurityXssFilter extends OncePerRequestFilter {
private ByteArrayOutputStream cachedBytes;
+ private Map parameter = new HashMap();
+
+ @SuppressWarnings("unchecked")
public RequestWrapper(HttpServletRequest request) {
super(request);
+ Enumeration<String> parameterNames = request.getParameterNames();
+ while (parameterNames.hasMoreElements()) {
+ String paramName = parameterNames.nextElement();
+ String paramValue = request.getParameter(paramName);
+ parameter.put(paramName,paramValue);
+ }
+ }
+
+ @Override
+ public String getParameter(String name) {
+ if (parameter != null) {
+ return (String) parameter.get(name);
+ }
+ return null;
}
@Override
diff --git a/ecomp-sdk/epsdk-app-os/src/main/resources/music.properties b/ecomp-sdk/epsdk-app-os/src/main/resources/music.properties
new file mode 100644
index 00000000..635ccb50
--- /dev/null
+++ b/ecomp-sdk/epsdk-app-os/src/main/resources/music.properties
@@ -0,0 +1,24 @@
+music.endpoint = http://vm-ep-dev4.research.att.com/MUSIC/rest/
+music.version = v2
+music.keyspace = keyspaces
+music.session.keyspace = test_session
+music.session.attr.tables = spring_session_attributes
+music.session.meta.tables = spring_session
+music.x.minor.version = 3
+music.x.patch.version = 0
+music.ns = com.att.ecomp.portal.demeter
+music.user.id = m00468@portal.ecomp.att.com
+music.password = friedG33nS-
+music.consistency.info = type
+music.consistency.info.value = eventual
+music.cache = false
+music.serialize.compress = true
+music.session.max.inactive.interval.seconds = 1800
+#By default it's eventual
+music.atomic.get = false
+music.atomic.put = false
+
+cassandra.host=135.197.226.103
+zookeeper.host=135.197.226.103, 135.197.226.108, 135.197.226.119
+cassandra.user=cassandra
+cassandra.password=cassandra \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-app-os/src/main/webapp/WEB-INF/web.xml b/ecomp-sdk/epsdk-app-os/src/main/webapp/WEB-INF/web.xml
index 76a372be..f621d5c2 100644
--- a/ecomp-sdk/epsdk-app-os/src/main/webapp/WEB-INF/web.xml
+++ b/ecomp-sdk/epsdk-app-os/src/main/webapp/WEB-INF/web.xml
@@ -21,6 +21,16 @@
<filter-name>SecurityXssFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
+ <!-- <filter>
+ <filter-name>springSessionRepositoryFilter</filter-name>
+ <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>springSessionRepositoryFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>ERROR</dispatcher>
+ </filter-mapping> -->
<error-page>
<location>/WEB-INF/jsp/error.jsp</location>
</error-page>
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/resources/cache.ccf b/ecomp-sdk/epsdk-app-overlay/src/main/resources/cache.ccf
index d21404b0..c2653c88 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/resources/cache.ccf
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/resources/cache.ccf
@@ -1,9 +1,9 @@
# DEFAULT CACHE REGION
jcs.default=DC
-jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
+jcs.default.cacheattributes=org.apache.commons.commons.jcs.engine.CompositeCacheAttributes
jcs.default.cacheattributes.MaxObjects=1000
-jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
-jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
+jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.commons.jcs.engine.memory.lru.LRUMemoryCache
+jcs.default.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
jcs.default.elementattributes.IsEternal=true
jcs.default.elementattributes.IsSpool=true
@@ -13,18 +13,18 @@ jcs.default.elementattributes.IsSpool=true
#jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=3600
#jcs.default.cacheattributes.ShrinkerIntervalSeconds=60
#jcs.default.cacheattributes.MaxSpoolPerRun=500
-#jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
+#jcs.default.elementattributes=org.apache.commons.commons.jcs.engine.ElementAttributes
#jcs.default.elementattributes.IsEternal=false
# AUXILLARY CACHE CONFIGURATION
-jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
-jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
+jcs.auxiliary.DC=org.apache.commons.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
+jcs.auxiliary.DC.attributes=org.apache.commons.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
jcs.auxiliary.DC.attributes.DiskPath=/tmp
# PRE-DEFINED REGION FOR LOOKUP DATA
jcs.region.lookUpObjectCache=DC
-jcs.region.lookUpObjectCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
+jcs.region.lookUpObjectCache.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
jcs.region.lookUpObjectCache.cacheattributes.MaxObjects=4000
-jcs.region.lookUpObjectCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
+jcs.region.lookUpObjectCache.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
diff --git a/ecomp-sdk/epsdk-core/pom.xml b/ecomp-sdk/epsdk-core/pom.xml
index 61f6fb1c..abaad567 100644
--- a/ecomp-sdk/epsdk-core/pom.xml
+++ b/ecomp-sdk/epsdk-core/pom.xml
@@ -225,17 +225,17 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<!-- Use Mariadb connector -->
<dependency>
@@ -342,6 +342,16 @@
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.1.0.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils-core</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<!-- UEB was originally named Cambria -->
@@ -362,6 +372,10 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
+ <exclusion>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ </exclusion>
</exclusions>
</dependency>
<!-- Jacoco for offline instrumentation -->
@@ -466,6 +480,16 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.3</version>
+ </dependency>
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.2</version>
+ </dependency>
</dependencies>
</project>
diff --git a/ecomp-sdk/epsdk-fw/pom.xml b/ecomp-sdk/epsdk-fw/pom.xml
index 5529a082..0cecde97 100644
--- a/ecomp-sdk/epsdk-fw/pom.xml
+++ b/ecomp-sdk/epsdk-fw/pom.xml
@@ -75,12 +75,12 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<dependency>
<groupId>org.owasp.esapi</groupId>
diff --git a/ecomp-sdk/epsdk-music/README.md b/ecomp-sdk/epsdk-music/README.md
new file mode 100644
index 00000000..8be313f2
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/README.md
@@ -0,0 +1,14 @@
+# ONAP Portal SDK Core
+
+## Overview
+
+This is the Maven project for the ONAP Portal SDK Music library,
+which is distributed as epsdk-music-N.N.N.jar. This library
+requires Spring, and provides session management feature, including session replication across cassandra nodes and portal resilience.
+
+## Release Notes
+
+### ONAP Distributions
+
+Version 2.2.0
+- PORTAL-210 Effort to make portal resilient \ No newline at end of file
diff --git a/ecomp-sdk/epsdk-music/pom.xml b/ecomp-sdk/epsdk-music/pom.xml
new file mode 100644
index 00000000..de623670
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/pom.xml
@@ -0,0 +1,190 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+<!-- <parent>
+ <groupId>org.onap.portal.sdk</groupId>
+ <artifactId>epsdk-project</artifactId>
+ <version>2.2.0-SNAPSHOT</version>
+ </parent>
+ -->
+ <groupId>org.onap.portal.sdk</groupId>
+ <artifactId>epsdk-music</artifactId>
+ <version>2.2.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>ONAP Portal SDK Music</name>
+ <url>http://maven.apache.org</url>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <springframework.version>4.2.0.RELEASE</springframework.version>
+ <jersey1.version>1.19.4</jersey1.version>
+ <jaxrs.version>2.0.1</jaxrs.version>
+ <cassandra.version>3.0.0</cassandra.version>
+ <zookeeper.version>3.4.6</zookeeper.version>
+ </properties>
+ <repositories>
+ <repository>
+ <id>resources</id>
+ <url>file:${project.basedir}/src/main/resources</url>
+ </repository>
+ </repositories>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.att.eelf</groupId>
+ <artifactId>eelf-core</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <!-- Spring -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>${springframework.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>${springframework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-webmvc</artifactId>
+ <version>${springframework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-tx</artifactId>
+ <version>${springframework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context-support</artifactId>
+ <version>${springframework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-orm</artifactId>
+ <version>${springframework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${springframework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ <version>${springframework.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ <version>1.3.0.RELEASE</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.slf4j</groupId>
+ <artifactId>log4j-over-slf4j</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>ch.qos.logback</groupId>
+ <artifactId>logback-classic</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>com.att.eelf</groupId>
+ <artifactId>eelf-core</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+
+ <!-- Music -->
+ <dependency>
+ <groupId>org.onap.music</groupId>
+ <artifactId>core</artifactId>
+ <version>2.4.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onap.music</groupId>
+ <artifactId>dependency</artifactId>
+ <version>2.4.4</version>
+ </dependency>
+
+ <!-- Mapper -->
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ <version>2.6.3</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <version>2.6.3</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.6.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.session</groupId>
+ <artifactId>spring-session-jdbc</artifactId>
+ <version>2.0.1.RELEASE</version>
+ </dependency>
+ <dependency>
+ <groupId>org.json</groupId>
+ <artifactId>json</artifactId>
+ <version>20160212</version>
+ </dependency>
+ </dependencies>
+ <profiles>
+ <!-- disable doclint, a new feature in Java 8, when generating javadoc -->
+ <profile>
+ <id>doclint-java8-disable</id>
+ <activation>
+ <jdk>[1.8,)</jdk>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.10.4</version>
+ <configuration>
+ <additionalparam>-Xdoclint:none</additionalparam>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+ <build>
+ <!-- The war file name carries no version number -->
+ <finalName>epsdk-music</finalName>
+
+ <plugins>
+ <!-- Compile to Java 1.8 class output format -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/EnableMuscicHttpSession.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/EnableMuscicHttpSession.java
new file mode 100644
index 00000000..fcdb15fe
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/EnableMuscicHttpSession.java
@@ -0,0 +1,56 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalapp.music.conf;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Documented
+@Configuration
+@Import(MusicHttpSessionConfiguration.class)
+public @interface EnableMuscicHttpSession {
+
+}
diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicHttpSessionConfiguration.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicHttpSessionConfiguration.java
new file mode 100644
index 00000000..bdf952bb
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicHttpSessionConfiguration.java
@@ -0,0 +1,54 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalapp.music.conf;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.session.config.annotation.web.http.EnableSpringHttpSession;
+
+@EnableSpringHttpSession
+@Configuration
+public class MusicHttpSessionConfiguration {
+
+
+ @Bean
+ public MusicSessionRepository sessionRepository() {
+ return new MusicSessionRepository(new MusicSessionRepositoryHandler());
+ }
+}
+
diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSession.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSession.java
new file mode 100644
index 00000000..dfaf5dc7
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSession.java
@@ -0,0 +1,382 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+/*
+ * Copyright 2014-2017 the original author or authors.
+ *
+ * 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.
+ */
+
+package org.onap.portalapp.music.conf;
+
+import java.io.Serializable;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.UUID;
+
+import org.onap.music.eelf.logging.EELFLoggerDelegate;
+import org.onap.music.exceptions.MusicLockingException;
+import org.onap.music.exceptions.MusicServiceException;
+import org.onap.portalapp.music.service.MusicService;
+import org.onap.portalapp.music.util.MusicProperties;
+import org.onap.portalapp.music.util.MusicUtil;
+import org.springframework.session.MapSession;
+import org.springframework.session.Session;
+
+/**
+ * <p>
+ * A {@link Session} implementation that is backed by a {@link java.util.Map}. The
+ * defaults for the properties are:
+ * </p>
+ * <ul>
+ * <li>id - a secure random generated id</li>
+ * <li>creationTime - the moment the {@link MapSession} was instantiated</li>
+ * <li>lastAccessedTime - the moment the {@link MapSession} was instantiated</li>
+ * <li>maxInactiveInterval - 30 minutes</li>
+ * </ul>
+ *
+ * <p>
+ * This implementation has no synchronization, so it is best to use the copy constructor
+ * when working on multiple threads.
+ * </p>
+ *
+ * @author SRIDHAR REDDY M
+ * @since 1.0
+ */
+public final class MusicSession implements Session, Serializable {
+ /**
+ * Default {@link #setMaxInactiveInterval(Duration)} (30 minutes).
+ */
+ public static final int DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS = MusicProperties.getProperty(MusicProperties.SESSION_MAX_INACTIVE_INTERVAL_SECONDS)==null ? 1800 :Integer.valueOf(MusicProperties.getProperty(MusicProperties.SESSION_MAX_INACTIVE_INTERVAL_SECONDS)) ;
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicSession.class);
+
+ private String id;
+ private String originalId;
+ private Map<String, Object> sessionAttrs = new HashMap<>();
+ private Instant creationTime = Instant.now();
+ private Instant lastAccessedTime = this.creationTime;
+ private Map<String,Integer> cachingMap = new HashMap<>();
+ private boolean musicCache = MusicUtil.isCached();
+ /**
+ * Defaults to 30 minutes.
+ */
+ private Duration maxInactiveInterval = Duration.ofSeconds(DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS);
+
+ /**
+ * Creates a new instance with a secure randomly generated identifier.
+ */
+ public MusicSession() {
+ this(generateId());
+ }
+
+
+ /**
+ * Creates a new instance with the specified id. This is preferred to the default
+ * constructor when the id is known to prevent unnecessary consumption on entropy
+ * which can be slow.
+ *
+ * @param id the identifier to use
+ */
+ public MusicSession(String id) {
+ this.id = id;
+ this.originalId = id;
+ }
+
+ /**
+ * Creates a new instance from the provided {@link Session}.
+ *
+ * @param session the {@link Session} to initialize this {@link Session} with. Cannot
+ * be null.
+ */
+ public MusicSession(Session session) {
+ if (session == null) {
+ throw new IllegalArgumentException("session cannot be null");
+ }
+ this.id = session.getId();
+ this.originalId = this.id;
+ this.sessionAttrs = new HashMap<>(
+ session.getAttributeNames().size());
+ for (String attrName : session.getAttributeNames()) {
+ Object attrValue = session.getAttribute(attrName);
+ if (attrValue != null) {
+ this.sessionAttrs.put(attrName, attrValue);
+ }
+ }
+ this.creationTime = session.getCreationTime();
+ this.lastAccessedTime = session.getLastAccessedTime();
+ this.maxInactiveInterval = session.getMaxInactiveInterval();
+ }
+
+ @Override
+ public void setLastAccessedTime(Instant lastAccessedTime) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "setLastAccessedTime: start");
+ try{
+ MusicService.setAttribute(MusicProperties.LAST_ACCESS_TIME, this.lastAccessedTime, this.id);
+ }catch(Exception e){
+ logger.error(EELFLoggerDelegate.errorLogger, "setLastAccessedTime failed with id " + this.id, e);
+ }
+ this.lastAccessedTime = lastAccessedTime;
+ }
+
+ @Override
+ public Instant getCreationTime() {
+ Instant creationTime = null;
+ logger.debug(EELFLoggerDelegate.debugLogger, "getCreationTime: start");
+ if(musicCache)
+ creationTime = this.creationTime;
+ else{
+ try {
+ String creationTimeStr = MusicService.getAttribute( MusicProperties.CREATION_TIME, this.id);
+ if(creationTimeStr!=null)
+ creationTime = Instant.parse(creationTimeStr);
+ else
+ creationTime = Instant.now();
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "getCreationTime failed with id " + this.id, e);
+ }
+ }
+ return creationTime;
+ }
+
+ @Override
+ public String getId() {
+ return this.id;
+ }
+
+ String getOriginalId() {
+ return this.originalId;
+ }
+
+ void setOriginalId(String originalId) {
+ this.originalId = originalId;
+ }
+
+ @Override
+ public String changeSessionId() {
+ String changedId = generateId();
+ setId(changedId);
+ return changedId;
+ }
+
+ @Override
+ public Instant getLastAccessedTime() {
+ Instant lastAccessedTime = null;
+ logger.debug(EELFLoggerDelegate.debugLogger, "getLastAccessedTime: start");
+ if(musicCache)
+ lastAccessedTime = this.lastAccessedTime;
+ else{
+ try {
+ String lastAccessedTimeStr = MusicService.getAttribute( MusicProperties.LAST_ACCESS_TIME, this.id);
+ if(lastAccessedTimeStr!=null)
+ lastAccessedTime = Instant.parse(lastAccessedTimeStr);
+ else
+ lastAccessedTime = this.creationTime;
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "getLastAccessedTime failed with id "+this.id, e);
+ }
+ }
+ return lastAccessedTime;
+ }
+
+ @Override
+ public void setMaxInactiveInterval(Duration interval) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "setMaxInactiveInterval: start");
+ this.maxInactiveInterval = interval;
+ try{
+ MusicService.setAttribute(MusicProperties.MAX_INACTIVE_INTERVAL, this.maxInactiveInterval, this.id);
+ }catch(Exception e){
+ logger.error(EELFLoggerDelegate.errorLogger, "setMaxInactiveInterval failed with id " + this.id, e);
+ }
+ }
+
+ @Override
+ public Duration getMaxInactiveInterval() {
+ logger.debug(EELFLoggerDelegate.debugLogger, "getMaxInactiveInterval: start");
+ Duration maxInactiveInterval = null;
+ if(musicCache)
+ maxInactiveInterval = this.maxInactiveInterval;
+ else{
+ try {
+ String maxInactiveIntervalStr = MusicService.getAttribute( MusicProperties.MAX_INACTIVE_INTERVAL, this.id);
+ if(maxInactiveIntervalStr!=null)
+ maxInactiveInterval = Duration.parse(maxInactiveIntervalStr);
+ else
+ maxInactiveInterval = Duration.ofSeconds(DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS);
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "getMaxInactiveInterval failed with id " + this.id, e);
+ }
+ }
+ return maxInactiveInterval==null? Duration.ofSeconds(DEFAULT_MAX_INACTIVE_INTERVAL_SECONDS):maxInactiveInterval;
+ }
+
+ @Override
+ public boolean isExpired() {
+ return isExpired(Instant.now());
+ }
+
+ boolean isExpired(Instant now) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "isExpired: start");
+ boolean isExpired = false;
+ Duration maxInactiveInterval = null;
+ Instant lastAccessedTime = null;
+ try {
+ if(musicCache){
+ maxInactiveInterval = this.maxInactiveInterval;
+ lastAccessedTime = this.lastAccessedTime;
+ }else{
+ maxInactiveInterval = getMaxInactiveInterval();
+ lastAccessedTime = getLastAccessedTime();
+ }
+ if (maxInactiveInterval.isNegative()) {
+ return false;
+ }
+ isExpired = now.minus(maxInactiveInterval).compareTo(lastAccessedTime) >= 0;
+ if(isExpired){
+ MusicService.removeSession(this.id);
+ }
+ } catch (MusicLockingException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "isExpired locking failed with id:" + id, e);
+ } catch (MusicServiceException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "isExpired failed with id:" + id, e);
+ }
+ return isExpired;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public <T> T getAttribute(String attributeName) {
+ if(musicCache){
+ return (T) this.sessionAttrs.get(attributeName);
+ }else{
+ try {
+ return MusicService.getAttribute( attributeName, this.id);
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, " getAttribute failed with id:" + this.id + " attribute name "+ attributeName , e);
+ return null;
+ }
+ }
+
+ }
+
+ @Override
+ public Set<String> getAttributeNames() {
+ return this.sessionAttrs.keySet();
+ }
+
+ @Override
+ public void setAttribute(String attributeName, Object attributeValue) {
+ if (attributeValue == null) {
+ removeAttribute(attributeName);
+ }else {
+ this.sessionAttrs.put(attributeName, attributeValue);
+ try{
+ MusicService.setAttribute(attributeName , attributeValue, this.id);
+ }catch(Exception e){
+ logger.error(EELFLoggerDelegate.errorLogger, " setAttribute failed id:" + this.id + " attribute name "+ attributeName , e);
+ }
+ }
+ }
+
+ @Override
+ public void removeAttribute(String attributeName) {
+ this.sessionAttrs.remove(attributeName);
+ try{
+ MusicService.removeAttribute(attributeName, this.id);
+ }catch(MusicLockingException e){
+ logger.error(EELFLoggerDelegate.errorLogger, " removeAttribute locking failed id:" + this.id + " attribute name "+ attributeName , e);
+ }catch(MusicServiceException e){
+ logger.error(EELFLoggerDelegate.errorLogger, " removeAttribute failed id:" + this.id + " attribute name "+ attributeName , e);
+ }
+
+ }
+
+ /**
+ * Sets the time that this {@link Session} was created. The default is when the
+ * {@link Session} was instantiated.
+ * @param creationTime the time that this {@link Session} was created.
+ */
+ public void setCreationTime(Instant creationTime) {
+ //MusicService musicService = new MusicService();
+ this.creationTime = creationTime;
+ try{
+ MusicService.setAttribute(MusicProperties.CREATION_TIME, creationTime, this.id);
+ }catch(Exception e){
+ logger.error(EELFLoggerDelegate.errorLogger, " setCreationTime failed id:" + this.id + " creationTime "+ creationTime , e);
+ }
+
+ }
+
+ /**
+ * Sets the identifier for this {@link Session}. The id should be a secure random
+ * generated value to prevent malicious users from guessing this value. The default is
+ * a secure random generated identifier.
+ *
+ * @param id the identifier for this session.
+ */
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj instanceof Session && this.id.equals(((Session) obj).getId());
+ }
+
+ @Override
+ public int hashCode() {
+ return this.id.hashCode();
+ }
+
+ private static String generateId() {
+ return UUID.randomUUID().toString();
+ }
+
+ private static final long serialVersionUID = 7160779239673823561L;
+}
diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionConfig.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionConfig.java
new file mode 100644
index 00000000..617ac75b
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionConfig.java
@@ -0,0 +1,55 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalapp.music.conf;
+
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * Configures Spring features in the ONAP Portal SDK including request
+ * interceptors and view resolvers. Application should subclass and override
+ * methods as needed.
+ */
+
+
+
+@Configuration
+@EnableMuscicHttpSession
+public class MusicSessionConfig {
+
+}
+
diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepository.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepository.java
new file mode 100644
index 00000000..37a7ae7e
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepository.java
@@ -0,0 +1,135 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalapp.music.conf;
+
+import java.time.Duration;
+import java.util.Map;
+
+import org.springframework.session.Session;
+import org.springframework.session.SessionRepository;
+import org.springframework.session.events.SessionDeletedEvent;
+import org.springframework.session.events.SessionExpiredEvent;
+
+
+/**
+ * A {@link SessionRepository} backed by a {@link java.util.Map} and that uses a
+ * {@link MapSession}. The injected {@link java.util.Map} can be backed by a
+ * distributed NoSQL store like Hazelcast, for instance. Note that the supplied
+ * map itself is responsible for purging the expired sessions.
+ *
+ * <p>
+ * The implementation does NOT support firing {@link SessionDeletedEvent} or
+ * {@link SessionExpiredEvent}.
+ * </p>
+ *
+ * @author SRIDHAR REDDY M
+ * @since 1.0
+ */
+public class MusicSessionRepository implements SessionRepository<MusicSession> {
+
+ /**
+ * If non-null, this value is used to override
+ * {@link Session#setMaxInactiveInterval(Duration)}.
+ */
+ private Integer defaultMaxInactiveInterval;
+
+
+ private final MusicSessionRepositoryHandler sessionHandler;
+
+ /**
+ * Creates a new instance backed by the provided {@link java.util.Map}. This
+ * allows injecting a distributed {@link java.util.Map}.
+ *
+ * @param sessions
+ * the {@link java.util.Map} to use. Cannot be null.
+ */
+ public MusicSessionRepository(MusicSessionRepositoryHandler handler) {
+ this.sessionHandler = handler;
+ }
+
+ /**
+ * If non-null, this value is used to override
+ * {@link Session#setMaxInactiveInterval(Duration)}.
+ *
+ * @param defaultMaxInactiveInterval
+ * the number of seconds that the {@link Session} should be kept
+ * alive between client requests.
+ */
+ public void setDefaultMaxInactiveInterval(int defaultMaxInactiveInterval) {
+ this.defaultMaxInactiveInterval = defaultMaxInactiveInterval;
+ }
+
+ @Override
+ public void save(MusicSession session) {
+ if (!session.getId().equals(session.getOriginalId())) {
+ this.sessionHandler.remove(session.getOriginalId());
+ session.setOriginalId(session.getId());
+ }
+ // this.sessionHandler.put(session.getId(), new MusicSession(session));
+ this.sessionHandler.put(session.getId(), new MusicSession(session));
+ }
+
+ @Override
+ public MusicSession findById(String id) {
+ Session saved = this.sessionHandler.get(id);
+ if (saved == null) {
+ return null;
+ }
+ if (saved.isExpired()) {
+ deleteById(saved.getId());
+ return null;
+ }
+ //return sessionHandler.session(saved);
+ return new MusicSession(saved);
+ }
+
+ @Override
+ public void deleteById(String id) {
+ this.sessionHandler.remove(id);
+ }
+
+ @Override
+ public MusicSession createSession() {
+ MusicSession result = new MusicSession();
+ if (this.defaultMaxInactiveInterval != null) {
+ result.setMaxInactiveInterval(Duration.ofSeconds(this.defaultMaxInactiveInterval));
+ }
+ return result;
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandler.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandler.java
new file mode 100644
index 00000000..1b0dff94
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/conf/MusicSessionRepositoryHandler.java
@@ -0,0 +1,56 @@
+package org.onap.portalapp.music.conf;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.onap.music.eelf.logging.EELFLoggerDelegate;
+import org.onap.music.exceptions.MusicLockingException;
+import org.onap.music.exceptions.MusicServiceException;
+import org.onap.portalapp.music.service.MusicService;
+import org.onap.portalapp.music.util.MusicUtil;
+import org.springframework.session.Session;
+
+public class MusicSessionRepositoryHandler {
+
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicSessionRepositoryHandler.class);
+ private final Map<String, Session> sessions = new ConcurrentHashMap<>();
+ private boolean musicCache = MusicUtil.isCached();
+
+
+ public Session get(String id) {
+ if(!musicCache){
+ try {
+ Session session = MusicService.getMetaAttribute(id);
+ return session;
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "get failed with id " + id, e);
+ }
+ }
+ return this.sessions.get(id);
+ }
+
+
+
+ public void remove(String id) {
+ sessions.remove(id);
+ try {
+ MusicService.removeSession(id);
+ } catch (MusicLockingException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "removeSession locking failed with id " + id, e);
+ } catch (MusicServiceException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "removeSession failed with id " + id, e);
+ }
+ }
+
+
+
+ public void put(String id, MusicSession musicSession) {
+ sessions.put(id, musicSession);
+ try {
+ MusicService.setMetaAttribute(musicSession);
+ } catch (Exception e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "setMetaAttribute failed with id " + id, e);
+ }
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/model/RestResponse.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/model/RestResponse.java
new file mode 100644
index 00000000..d01b0105
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/model/RestResponse.java
@@ -0,0 +1,119 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP
+ * ===================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalapp.music.model;
+
+public class RestResponse<T> {
+
+ private RestStatusEnum status;
+ private String message;
+
+ private T response;
+
+ public RestResponse(){};
+
+ public RestResponse(RestStatusEnum status, String message, T response){
+ this.status = status;
+ this.message = message;
+ this.response = response;
+ }
+
+ public RestStatusEnum getStatus() {
+ return status;
+ }
+
+ public void setStatus(RestStatusEnum status) {
+ this.status = status;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+
+ public T getResponse() {
+ return response;
+ }
+
+ public void setResponse(T response) {
+ this.response = response;
+ }
+
+ @Override
+ public String toString() {
+ return "RestResponse [status=" + status + ", message=" + message + ", response=" + response + "]";
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((message == null) ? 0 : message.hashCode());
+ result = prime * result + ((response == null) ? 0 : response.hashCode());
+ result = prime * result + ((status == null) ? 0 : status.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ RestResponse other = (RestResponse) obj;
+ if (message == null) {
+ if (other.message != null)
+ return false;
+ } else if (!message.equals(other.message))
+ return false;
+ if (response == null) {
+ if (other.response != null)
+ return false;
+ } else if (!response.equals(other.response))
+ return false;
+ if (status != other.status)
+ return false;
+ return true;
+ };
+
+
+}
diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/model/RestStatusEnum.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/model/RestStatusEnum.java
new file mode 100644
index 00000000..61e477c3
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/model/RestStatusEnum.java
@@ -0,0 +1,54 @@
+/*-
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+package org.onap.portalapp.music.model;
+
+public enum RestStatusEnum{
+ OK("ok"),
+ WARN("WARNING"),
+ ERROR("error");
+
+ private String value;
+ private RestStatusEnum(String value){
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return value;
+ }
+}
diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/service/MusicService.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/service/MusicService.java
new file mode 100644
index 00000000..0ff3cd2a
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/service/MusicService.java
@@ -0,0 +1,543 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.portalapp.music.service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.onap.music.datastore.PreparedQueryObject;
+import org.onap.music.eelf.logging.EELFLoggerDelegate;
+import org.onap.music.exceptions.MusicLockingException;
+import org.onap.music.exceptions.MusicServiceException;
+import org.onap.music.main.MusicCore;
+import org.onap.music.main.ReturnType;
+import org.onap.portalapp.music.conf.MusicSession;
+import org.onap.portalapp.music.model.RestResponse;
+import org.onap.portalapp.music.model.RestStatusEnum;
+import org.onap.portalapp.music.util.MusicProperties;
+import org.onap.portalapp.music.util.MusicUtil;
+import org.springframework.http.HttpEntity;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
+import org.springframework.session.Session;
+import org.springframework.web.client.RestTemplate;
+
+import com.datastax.driver.core.ResultSet;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class MusicService {
+ static RestTemplate template = new RestTemplate();
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicService.class);
+
+ private static boolean isAtomicPut = MusicUtil.isAtomicPut();
+ private static boolean isAtomicGet = MusicUtil.isAtomicGet();
+ private static String musicKeySpace = MusicProperties.getProperty(MusicProperties.MUSIC_SESSION_KEYSPACE);
+ private static String musicMetaTable = MusicProperties.getProperty(MusicProperties.MUSIC_SESSION_META_TABLES);
+ private static String musicAttrTable = MusicProperties.getProperty(MusicProperties.MUSIC_SESSION_ATTR_TABLES);
+
+ /**
+ * Store session attribute name and values into Cassandra via Music
+ *
+ * @param attributeName
+ * @param value
+ * @param sessionId
+ * @return ReturnType that includes required body information for Music api
+ * @throws Exception
+ */
+ public static ReturnType setAttribute(String attributeName, Object value, String sessionId) throws Exception {
+ logger.debug(EELFLoggerDelegate.debugLogger, "setAttribute: start with id " + sessionId);
+ String tableName = null;
+ ReturnType result = null;
+ boolean isMeta = MusicUtil.isSessionMetaAttr(attributeName);
+ PreparedQueryObject queryObject = new PreparedQueryObject();
+ StringBuilder querySB = new StringBuilder();
+ querySB.append("INSERT INTO ").append(musicKeySpace).append(".").append(getTableName(isMeta))
+ .append(getInsertQuery(isMeta, attributeName));
+
+ queryObject.appendQueryString(querySB.toString());
+ if (isMeta) {
+ queryObject.addValue(sessionId);
+ queryObject.addValue(String.valueOf(value));
+ tableName = musicMetaTable;
+ } else {
+ queryObject.addValue(sessionId);
+ queryObject.addValue(attributeName);
+ queryObject.addValue(MusicUtil.musicSerialize(value));
+ tableName = musicAttrTable;
+
+ }
+ if (isAtomicPut)
+ result = MusicCore.atomicPut(musicKeySpace, tableName, sessionId, queryObject, null);
+ else
+ result = MusicCore.eventualPut(queryObject);
+ logger.debug(EELFLoggerDelegate.debugLogger, "setAttribute: attributeName: " + attributeName
+ + " with session id: " + sessionId + "result:" + result.getMessage());
+ return result;
+ }
+
+ /**
+ * Store session meta data values into Cassandra via Music
+ *
+ * @param session
+ * @return ReturnType that includes required body information for Music api
+ * @throws Exception
+ */
+ public static ReturnType setMetaAttribute(Session session) throws Exception {
+ logger.debug(EELFLoggerDelegate.debugLogger, "setMetaAttribute: start with session id: " + session.getId());
+ ReturnType result = null;
+ PreparedQueryObject queryObject = new PreparedQueryObject();
+ StringBuilder querySB = new StringBuilder();
+ querySB.append("INSERT INTO ").append(musicKeySpace).append(".").append(musicMetaTable).append("(")
+ .append(MusicProperties.PRIMARY_ID).append(",").append(MusicProperties.CREATION_TIME).append(",")
+ .append(MusicProperties.LAST_ACCESS_TIME).append(",").append(MusicProperties.MAX_INACTIVE_INTERVAL)
+ .append(",").append(MusicProperties.SESSION_ID).append(") VALUES (?,?,?,?,?);");
+
+ queryObject.appendQueryString(querySB.toString());
+ queryObject.addValue(session.getId());
+ queryObject.addValue(String.valueOf(session.getCreationTime()));
+ queryObject.addValue(String.valueOf(session.getLastAccessedTime()));
+ queryObject.addValue(String.valueOf(session.getMaxInactiveInterval()));
+ queryObject.addValue(session.getId());
+ if (isAtomicPut)
+ result = MusicCore.atomicPut(musicKeySpace, musicMetaTable, session.getId(), queryObject, null);
+ else
+ result = MusicCore.eventualPut(queryObject);
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ "setMetaAttribute: with session id: " + session + "result:" + result.getMessage());
+
+ return result;
+ }
+
+ /**
+ * Retrieve session meta data from Cassandra via Music
+ *
+ * @param sessionId
+ * @return MusicSession
+ * @throws Exception
+ */
+ public static MusicSession getMetaAttribute(String sessionId) throws Exception {
+ logger.debug(EELFLoggerDelegate.debugLogger, "getMetaAttribute: start with session Id: "+ sessionId);
+ ResultSet result = null;
+ PreparedQueryObject queryObject = new PreparedQueryObject();
+ StringBuilder querySB = new StringBuilder();
+ querySB.append("SELECT * FROM ").append(musicKeySpace).append(".").append(musicMetaTable).append(" WHERE ")
+ .append(MusicProperties.PRIMARY_ID).append("=?;");
+ queryObject.appendQueryString(querySB.toString());
+ queryObject.addValue(sessionId);
+ if (isAtomicGet)
+ result = MusicCore.atomicGet(musicKeySpace, musicMetaTable, sessionId, queryObject);
+ else
+ result = MusicCore.get(queryObject);
+ logger.debug(EELFLoggerDelegate.debugLogger, "getMetaAttribute: with session id: " + sessionId);
+ return MusicUtil.parseMetaData(result.one());
+ }
+
+ /**
+ * Get proper column names (from meta or attribute table) base on isMeta
+ *
+ * @param isMeta
+ * @param attributeName
+ * @return String
+ */
+ private static String getInsertQuery(boolean isMeta, String attributeName) {
+ logger.debug(EELFLoggerDelegate.debugLogger, "getInsertQuery: start inserting : " + attributeName);
+ StringBuilder querySB = new StringBuilder();
+ if (isMeta) {
+ querySB.append(" (").append(MusicProperties.PRIMARY_ID).append(",").append(attributeName)
+ .append(") VALUES (?,?);");
+ } else {
+ querySB.append(" (").append(MusicProperties.PRIMARY_ID).append(",").append(MusicProperties.ATTRIBUTE_NAME)
+ .append(",").append(MusicProperties.ATTRIBUTE_BYTES).append(") VALUES (?,?,?);");
+ }
+ return querySB.toString();
+ }
+
+ /**
+ * Retrieve session attribute data from Cassandra via Music
+ *
+ * @param attributeName
+ * @param sessionId
+ * @return attribute value with T type
+ * @throws Exception
+ */
+ public static <T> T getAttribute(String attributeName, String sessionId) throws Exception {
+ logger.debug(EELFLoggerDelegate.debugLogger, "getAttribute: start with session id: " + sessionId);
+ ResultSet result = null;
+ String tableName = null;
+ boolean isMeta = MusicUtil.isSessionMetaAttr(attributeName);
+ PreparedQueryObject queryObject = new PreparedQueryObject();
+ StringBuilder querySB = new StringBuilder();
+ querySB.append("SELECT ").append(getColumn(attributeName, isMeta)).append(" FROM ").append(musicKeySpace)
+ .append(".").append(getTableName(isMeta)).append(" WHERE ").append(MusicProperties.PRIMARY_ID)
+ .append("= ?");
+
+ queryObject.addValue(sessionId);
+ if (!isMeta) {
+ querySB.append(" and ").append(MusicProperties.ATTRIBUTE_NAME).append("= ?");
+ queryObject.addValue(attributeName);
+ tableName = musicAttrTable;
+ } else
+ tableName = musicMetaTable;
+
+ queryObject.appendQueryString(querySB.toString());
+ if (isAtomicGet)
+ result = MusicCore.atomicGet(musicKeySpace, tableName, sessionId, queryObject);
+ else
+ result = MusicCore.get(queryObject);
+ return MusicUtil.musicRestResponseDataParsing(result, attributeName);
+
+ }
+
+ /**
+ * Remove session attribute data from Cassandra via Music
+ *
+ * @param attributeName
+ * @param sessionId
+ * @return ReturnType
+ * @throws MusicServiceException
+ * @throws MusicLockingException
+ */
+ public static ReturnType removeAttribute(String attributeName, String sessionId) throws MusicServiceException, MusicLockingException {
+ logger.debug(EELFLoggerDelegate.debugLogger, "removeAttribute: start with session id: " + sessionId);
+ boolean isMeta = MusicUtil.isSessionMetaAttr(attributeName);
+ ReturnType result = null;
+ String tableName = null;
+ PreparedQueryObject queryObject = new PreparedQueryObject();
+ StringBuilder querySB = new StringBuilder();
+ querySB.append("DELETE ").append(getDelColumn(isMeta, attributeName)).append(" FROM ").append(musicKeySpace)
+ .append(".").append(getTableName(isMeta)).append(" WHERE ").append(MusicProperties.PRIMARY_ID)
+ .append("= ? ");
+ queryObject.addValue(sessionId);
+
+ if (!isMeta) {
+ querySB.append(" and ").append(MusicProperties.ATTRIBUTE_NAME).append("= ?");
+ queryObject.addValue(attributeName);
+ tableName = musicAttrTable;
+ } else
+ tableName = musicMetaTable;
+ queryObject.appendQueryString(querySB.toString());
+ if (isAtomicPut)
+ result = MusicCore.atomicPut(musicKeySpace, tableName, sessionId, queryObject, null);
+ else
+ result = MusicCore.eventualPut(queryObject);
+ logger.debug(EELFLoggerDelegate.debugLogger,
+ "removeSession: " + attributeName + " with session id: " + sessionId + "result:" + result.getMessage());
+
+ return result;
+ }
+
+ /**
+ * Remove entire session from Cassandra via Music
+ *
+ * @param sessionId
+ * @return ReturnType
+ * @throws MusicServiceException
+ * @throws MusicLockingException
+ */
+ public static ReturnType removeSession(String sessionId) throws MusicServiceException, MusicLockingException {
+ ReturnType result = null;
+ boolean isAtomic = isAtomicPut;
+ logger.debug(EELFLoggerDelegate.debugLogger, "removeSession: start with session id: " + sessionId);
+ PreparedQueryObject queryObject = new PreparedQueryObject();
+ StringBuilder querySB = new StringBuilder();
+ querySB.append("DELETE ").append(" FROM ").append(musicKeySpace).append(".").append(musicMetaTable)
+ .append(" WHERE ").append(MusicProperties.PRIMARY_ID).append("= ? ");
+ queryObject.appendQueryString(querySB.toString());
+ queryObject.addValue(sessionId);
+ if (isAtomic)
+ result = MusicCore.atomicPut(musicKeySpace, musicMetaTable, sessionId, queryObject, null);
+ else
+ result = MusicCore.eventualPut(queryObject);
+ logger.debug(EELFLoggerDelegate.debugLogger, "removeSession: " + musicMetaTable + " with session id: "
+ + sessionId + "result:" + result.getMessage());
+
+ queryObject = new PreparedQueryObject();
+ querySB = new StringBuilder();
+ querySB.append("DELETE ").append(" FROM ").append(musicKeySpace).append(".").append(musicAttrTable)
+ .append(" WHERE ").append(MusicProperties.PRIMARY_ID).append("= ? ");
+ queryObject.appendQueryString(querySB.toString());
+ queryObject.addValue(sessionId);
+ if (isAtomic)
+ result = MusicCore.atomicPut(musicKeySpace, musicAttrTable, sessionId, queryObject, null);
+ else
+ result = MusicCore.eventualPut(queryObject);
+
+ logger.debug(EELFLoggerDelegate.debugLogger, "removeSession: " + musicAttrTable + " with session id: "
+ + sessionId + "result:" + result.getMessage());
+
+ return result;
+ }
+
+ /**
+ * Get proper table name (Meta or Attribute) base on isMeta.
+ *
+ * @param isMeta
+ * @return String
+ */
+ private static String getTableName(boolean isMeta) {
+ StringBuilder querySB = new StringBuilder();
+ if (isMeta)
+ querySB.append(musicMetaTable);
+ else
+ querySB.append(musicAttrTable);
+ return querySB.toString();
+ }
+
+ /**
+ * Get proper column name (Meta or Attribute) base on isMeta.
+ *
+ * @param attributeName
+ * @param isMeta
+ * @return String
+ */
+ private static String getColumn(String attributeName, boolean isMeta) {
+ StringBuilder querySB = new StringBuilder();
+ if (isMeta)
+ querySB.append(attributeName);
+ else
+ querySB.append("attribute_bytes");
+ return querySB.toString();
+ }
+
+ /**
+ * Get proper column name (Meta or Attribute) base on isMeta for removing.
+ *
+ * @param attributeName
+ * @param isMeta
+ * @return String
+ */
+ private static String getDelColumn(boolean isMeta, String attributeName) {
+ StringBuilder querySB = new StringBuilder();
+ if (isMeta)
+ querySB.append(attributeName);
+ return querySB.toString();
+ }
+
+ /**
+ * To set session attributes in Music
+ *
+ * @param attributeName
+ * @param value
+ * @param session
+ * @param sessionId
+ * @param isMeta
+ * @return RestResponse<String>
+ * @throws JsonProcessingException
+ */
+
+ public static RestResponse<String> setAttributeAPI(String attributeName, Object value, Session session,
+ String sessionId, String className, boolean isMeta) throws JsonProcessingException {
+ System.out.println("setAttribute: " + attributeName);
+ RestResponse<String> portalRestResponse = null;
+ HttpEntity<Map<String, Object>> entity = new HttpEntity<Map<String, Object>>(
+ getMusicRestBody(attributeName, value, sessionId, session, className, isMeta), getMusicHeader());
+ String url = getInsertUrl(isMeta);
+ ResponseEntity<String> response = null;
+ try {
+ response = template.exchange(url, HttpMethod.POST, entity, String.class);
+ portalRestResponse = new RestResponse<String>(RestStatusEnum.OK, "success", response.getBody());
+ } catch (Exception e) {
+ portalRestResponse = new RestResponse<String>(RestStatusEnum.ERROR, e.getMessage(), null);
+ }
+ return portalRestResponse;
+ }
+
+ /**
+ * To get session attribute in Music
+ *
+ * @param attributeName
+ * @param value
+ * @param sessionId
+ * @param isMeta
+ * @return RestResponse<String>
+ */
+
+ public static RestResponse<String> getAttributeAPI(String attributeName, Object value, String sessionId,
+ boolean isMeta) {
+ System.out.println("getAttribute: " + attributeName);
+ RestResponse<String> portalRestResponse = null;
+ HttpEntity<String> entity = new HttpEntity<String>(null, getMusicHeader());
+ ResponseEntity<String> response = null;
+ String url = getSelectSessionIdUrl(attributeName, sessionId, isMeta);
+ try {
+ response = template.exchange(url, HttpMethod.GET, entity, String.class);
+ portalRestResponse = new RestResponse<String>(RestStatusEnum.OK, "success", response.getBody());
+ } catch (Exception e) {
+ portalRestResponse = new RestResponse<String>(RestStatusEnum.ERROR, e.getMessage(), null);
+ }
+ return portalRestResponse;
+ }
+
+ /**
+ * To remove session attribute or session meta in Music
+ *
+ * @param attributeName
+ * @param value
+ * @param sessionId
+ * @param isMeta
+ * @return RestResponse<String>
+ */
+ public static RestResponse<String> removeAttributeAPI(String attributeName, String sessionId, boolean isMeta) {
+ RestResponse<String> portalRestResponse = null;
+ HttpEntity<Map<String, Object>> entity = new HttpEntity<>(getMusicDelRestBody(null), getMusicHeader());
+ ResponseEntity<String> response = null;
+ String url = getSelectSessionIdUrl(attributeName, sessionId, true);
+ try {
+ response = template.exchange(url, HttpMethod.DELETE, entity, String.class);
+ portalRestResponse = new RestResponse<String>(RestStatusEnum.OK, "success", response.getBody());
+ url = getSelectSessionIdUrl(attributeName, sessionId, false);
+ response = template.exchange(url, HttpMethod.DELETE, entity, String.class);
+ portalRestResponse = new RestResponse<String>(RestStatusEnum.OK, "success", response.getBody());
+ } catch (Exception e) {
+ portalRestResponse = new RestResponse<String>(RestStatusEnum.ERROR, e.getMessage(), null);
+ }
+ return portalRestResponse;
+ }
+
+ /**
+ * Generate body for Music api calls
+ *
+ * @return String that includes required body information for Music api
+ * calls
+ * @throws JsonProcessingException
+ */
+ public static Map<String, Object> getMusicRestBody(String attributeName, Object value, String sessionId,
+ Session session, String className, boolean isMeta) throws JsonProcessingException {
+ Map<String, Object> map = new HashMap<>();
+ /* Set up column values */
+ Map<String, Object> valueMap = new HashMap<>();
+ if (isMeta) {
+ valueMap.put(MusicProperties.PRIMARY_ID, session.getId());
+ valueMap.put(MusicProperties.SESSION_ID, session.getId());
+ valueMap.put(MusicProperties.CREATION_TIME, session.getCreationTime().toString());
+ valueMap.put(MusicProperties.LAST_ACCESS_TIME, session.getLastAccessedTime().toString());
+ valueMap.put(MusicProperties.MAX_INACTIVE_INTERVAL, session.getMaxInactiveInterval().toString());
+ } else {
+ ObjectMapper mapper = new ObjectMapper();
+ valueMap.put(MusicProperties.PRIMARY_ID, sessionId);
+ valueMap.put(MusicProperties.ATTRIBUTE_NAME, attributeName);
+ valueMap.put(MusicProperties.ATTRIBUTE_BYTES, mapper.writeValueAsString(value));
+ valueMap.put(MusicProperties.ATTRIBUTE_CLASS, className);
+ }
+ map.put("values", valueMap);
+ /* Set up consistency setting */
+ Map<String, String> consistencyInfoMap = new HashMap<>();
+ consistencyInfoMap.put(MusicProperties.getProperty(MusicProperties.MUSIC_CONSISTENCYINFO),
+ MusicProperties.getProperty(MusicProperties.MUSIC_CONSISTENCYINFO_VALUE));
+ map.put("consistencyInfo", consistencyInfoMap);
+ return map;
+ }
+
+ /**
+ * Generate body for Music delete api calls
+ *
+ * @return String that includes required body information for Music api
+ * calls
+ * @throws JsonProcessingException
+ */
+ public static Map<String, Object> getMusicDelRestBody(String attribute_name) {
+ Map<String, Object> map = new HashMap<>();
+ Map<String, String> consistencyInfoMap = new HashMap<>();
+ consistencyInfoMap.put(MusicProperties.getProperty(MusicProperties.MUSIC_CONSISTENCYINFO),
+ MusicProperties.getProperty(MusicProperties.MUSIC_CONSISTENCYINFO_VALUE));
+ if (attribute_name != null && !attribute_name.equals("")) {
+ Map<String, String> conditionsMap = new HashMap<>();
+ conditionsMap.put("attribute_name", attribute_name);
+ map.put("conditions", conditionsMap);
+ }
+ map.put("consistencyInfo", consistencyInfoMap);
+ return map;
+ }
+
+ private static String getSelectSessionIdUrl(String attributeName, String sessionId, boolean isMeta) {
+ String path = constructPath(isMeta);
+ StringBuilder attriPath = new StringBuilder();
+ attriPath.append(path).append(MusicProperties.getProperty(MusicProperties.MUSIC_ROWS)).append("?")
+ .append(MusicProperties.PRIMARY_ID).append("=").append(sessionId);
+ return attriPath.toString();
+ }
+
+ private static String getInsertUrl(boolean isMeta) {
+ String path = constructPath(isMeta);
+ StringBuilder attriPath = new StringBuilder();
+ attriPath.append(path);
+ attriPath.append(MusicProperties.getProperty(MusicProperties.MUSIC_ROWS));
+ return attriPath.toString();
+ }
+
+ /**
+ * Generate header for Music api calls
+ *
+ * @return header that contains required header information for Music api
+ * calls
+ */
+ private static HttpHeaders getMusicHeader() {
+ HttpHeaders headers = new HttpHeaders();
+ headers.setContentType(MediaType.APPLICATION_JSON);
+ headers.add("X-minorVersion", MusicProperties.getProperty(MusicProperties.MUSIC_X_MINOR_VERSION));
+ headers.add("X-patchVersion", MusicProperties.getProperty(MusicProperties.MUSIC_X_PATCH_VERSION));
+ headers.add("ns", MusicProperties.getProperty(MusicProperties.MUSIC_NS));
+ headers.add("userId", MusicProperties.getProperty(MusicProperties.MUSIC_USER_ID));
+ headers.add("password", MusicProperties.getProperty(MusicProperties.MUSIC_PASSWORD));
+ return headers;
+ }
+
+ /**
+ * Construct URL for Music api calls
+ *
+ * @return path
+ */
+ private static String constructPath(boolean isMeta) {
+ StringBuilder path = new StringBuilder();
+ path.append(MusicProperties.getProperty(MusicProperties.MUSIC_ENDPOINT))
+ .append(MusicProperties.getProperty(MusicProperties.MUSIC_VERSION)).append("/")
+ .append(MusicProperties.getProperty(MusicProperties.MUSIC_KEYSPACE)).append("/").append(musicKeySpace)
+ .append("/").append(MusicProperties.getProperty(MusicProperties.MUSIC_TABLES)).append("/");
+ if (isMeta)
+ path.append(musicMetaTable);
+ else
+ path.append(musicAttrTable);
+ path.append("/");
+ return path.toString();
+ }
+
+}
diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicProperties.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicProperties.java
new file mode 100644
index 00000000..2787b0a0
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicProperties.java
@@ -0,0 +1,217 @@
+/*
+ * ============LICENSE_START==========================================
+ * ONAP Portal SDK
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the "License");
+ * you may not use this software 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.
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * 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============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ */
+
+package org.onap.portalapp.music.util;
+
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.onap.music.eelf.logging.EELFLoggerDelegate;
+import org.onap.portalapp.music.service.MusicService;
+
+
+public class MusicProperties {
+
+ public static final String MUSIC_ENDPOINT = "music.endpoint";
+
+ public static final String MUSIC_VERSION = "music.version";
+
+ public static final String MUSIC_KEYSPACE = "music.keyspace";
+
+ public static final String MUSIC_SESSION_KEYSPACE = "music.session.keyspace";
+
+ public static final String MUSIC_TABLES = "TABLES";
+
+ public static final String MUSIC_SESSION_ATTR_TABLES = "music.session.attr.tables";
+
+ public static final String MUSIC_SESSION_META_TABLES = "music.session.meta.tables";
+
+ public static final String MUSIC_ROWS = "ROW";
+
+ public static final String MUSIC_SESSION_ROW = "music.sesion.rows";
+
+ public static final String MUSIC_X_MINOR_VERSION = "music.x.minor.version";
+
+ public static final String MUSIC_X_PATCH_VERSION = "music.x.patch.version";
+
+ public static final String MUSIC_AID = "AID";
+
+ public static final String MUSIC_NS = "music.ns";
+
+ public static final String MUSIC_USER_ID = "music.user.id";
+
+ public static final String MUSIC_PASSWORD = "music.password";
+
+ public static final String MUSIC_CONSISTENCYINFO = "music.consistency.info";
+
+ public static final String MUSIC_CONSISTENCYINFO_VALUE = "music.consistency.info.value";
+
+ public static final String MUSIC_CACHE = "music.cache";
+
+ public static final String MUSIC_SERIALIZE_COMPRESS = "music.serialize.compress";
+
+ public static final String MUSIC_ATOMIC_GET = "music.atomic.get";
+
+ public static final String MUSIC_ATOMIC_PUT = "music.atomic.put";
+
+ public static final String MUSIC_ATOMIC_POST = "music.atomic.post";
+
+ public static final String SESSION_MAX_INACTIVE_INTERVAL_SECONDS = "music.session.max.inactive.interval.seconds";
+
+ public static final String ATTRIBUTE_NAME = "ATTRIBUTE_NAME";
+
+ public static final String ATTRIBUTE_BYTES = "ATTRIBUTE_BYTES";
+
+ public static final String ATTRIBUTE_CLASS = "ATTRIBUTE_CLASS";
+
+ public static final String PRIMARY_ID = "PRIMARY_ID";
+
+ public static final String SESSION_ID = "SESSION_ID";
+
+ public static final String CREATION_TIME = "CREATION_TIME";
+
+ public static final String LAST_ACCESS_TIME = "LAST_ACCESS_TIME";
+
+ public static final String MAX_INACTIVE_INTERVAL = "MAX_INACTIVE_INTERVAL";
+
+ public static final String EXPIRY_TIME = "EXPIRY_TIME";
+
+ public static final String PRINCIPAL_NAME = "PRINCIPAL_NAME";
+
+ private MusicProperties(){}
+
+ private static Properties properties;
+
+ private static String propertyFileName = "music.properties";
+
+ private static final Object lockObject = new Object();
+
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicProperties.class);
+
+ /**
+ * Gets the property value for the specified key. If a value is found, leading
+ * and trailing space is trimmed.
+ *
+ * @param property
+ * Property key
+ * @return Value for the named property; null if the property file was not
+ * loaded or the key was not found.
+ */
+ public static String getProperty(String property) {
+ if (properties == null) {
+ synchronized (lockObject) {
+ try {
+ if (!initialize()) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Failed to read property file " + propertyFileName);
+ return null;
+ }
+ } catch (IOException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Failed to read property file " + propertyFileName ,e);
+ return null;
+ }
+ }
+ }
+ String value = properties.getProperty(property);
+ if (value != null)
+ value = value.trim();
+ return value;
+ }
+
+ /**
+ * Reads properties from a portal.properties file on the classpath.
+ *
+ * Clients do NOT need to call this method. Clients MAY call this method to test
+ * whether the properties file can be loaded successfully.
+ *
+ * @return True if properties were successfully loaded, else false.
+ * @throws IOException
+ * On failure
+ */
+ private static boolean initialize() throws IOException {
+ if (properties != null)
+ return true;
+ InputStream in = MusicProperties.class.getClassLoader().getResourceAsStream(propertyFileName);
+ if (in == null)
+ return false;
+ properties = new Properties();
+ try {
+ properties.load(in);
+ } finally {
+ in.close();
+ }
+ return true;
+ }
+
+ /**
+ * Tests whether a property value is available for the specified key.
+ *
+ * @param key
+ * Property key
+ * @return True if the key is known, otherwise false.
+ */
+/* public static boolean containsProperty(String key) {
+ return environment.containsProperty(key);
+ }*/
+
+ /**
+ * Returns the property value associated with the given key (never
+ * {@code null}), after trimming any trailing space.
+ *
+ * @param key
+ * Property key
+ * @return Property value; the empty string if the environment was not
+ * autowired, which should never happen.
+ * @throws IllegalStateException
+ * if the key is not found
+ */
+/* public static String getProperty(String key) {
+ String value = "";
+ if (environment == null) {
+ // logger.error(EELFLoggerDelegate.errorLogger, "getProperty: environment is null, should never happen!");
+ } else {
+ value = environment.getRequiredProperty(key);
+ // java.util.Properties preserves trailing space
+ if (value != null)
+ value = value.trim();
+ }
+ return value;
+ }*/
+
+}
diff --git a/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java
new file mode 100644
index 00000000..f582a9db
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/src/main/java/org/onap/portalapp/music/util/MusicUtil.java
@@ -0,0 +1,125 @@
+package org.onap.portalapp.music.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.nio.ByteBuffer;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+import org.onap.music.eelf.logging.EELFLoggerDelegate;
+import org.onap.portalapp.music.conf.MusicSession;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+
+public class MusicUtil {
+ private static final Set<String> sessionAttrNameSet = new HashSet<>(Arrays.asList("CREATION_TIME", "LAST_ACCESS_TIME","MAX_INACTIVE_INTERVAL","EXPIRY_TIME","PRINCIPAL_NAME"));
+
+ private static final EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(MusicUtil.class);
+ private static String atomicPut = MusicProperties.getProperty(MusicProperties.MUSIC_ATOMIC_PUT);
+ private static String atomicGet = MusicProperties.getProperty(MusicProperties.MUSIC_ATOMIC_GET);
+ private static String cached = MusicProperties.getProperty(MusicProperties.MUSIC_CACHE);
+ private static String musicSerializeCompress = MusicProperties.getProperty(MusicProperties.MUSIC_SERIALIZE_COMPRESS);
+ public static boolean isSessionMetaAttr(String key){
+ return sessionAttrNameSet.contains(key);
+ }
+
+ public static <T> T musicRestResponseDataParsing(ResultSet rs, String attributeName) throws Exception{
+ logger.debug(EELFLoggerDelegate.debugLogger, "musicRestResponseDataParsing: start");
+ Row row = rs.one();
+ if(!sessionAttrNameSet.contains(attributeName)){
+ if(row!=null)
+ return MusicUtil.musicDeserialize(row.getBytes("attribute_bytes"));
+ }else{
+ return (T) row.getString(attributeName);
+ }
+ return null;
+ }
+
+ public static <T> T musicDeserialize (ByteBuffer byteBuf) throws Exception{
+ logger.debug(EELFLoggerDelegate.debugLogger, "musicDeserialize: start");
+ ByteArrayInputStream byteArr = new ByteArrayInputStream(byteBuf.array());
+ ObjectInputStream ois = null;
+ if(isMusicSerializeCompress()){
+ GZIPInputStream zos = new GZIPInputStream(byteArr);
+ ois = new ObjectInputStream(zos);
+ }else{
+ ois = new ObjectInputStream(byteArr);
+ }
+ return (T) ois.readObject();
+ }
+
+ public static ByteBuffer musicSerialize (Object value) throws Exception{
+ logger.debug(EELFLoggerDelegate.debugLogger, "musicSerialize: start");
+ ByteArrayOutputStream bo = new ByteArrayOutputStream();
+ try {
+ if(isMusicSerializeCompress()){
+ GZIPOutputStream zos = new GZIPOutputStream(bo);
+ ObjectOutputStream oos = new ObjectOutputStream(zos);
+ oos.writeObject(value);
+ oos.flush();
+ zos.finish();
+ }else{
+ ObjectOutputStream oos = new ObjectOutputStream(bo);
+ oos.writeObject(value);
+ oos.flush();
+ }
+ } catch (IOException e) {
+ logger.error(EELFLoggerDelegate.errorLogger, "Failed to serialize ");
+ }
+ return ByteBuffer.wrap(bo.toByteArray());
+ }
+
+ public static MusicSession parseMetaData (Row row) throws Exception{
+ logger.debug(EELFLoggerDelegate.debugLogger, "parseMetaData: start");
+
+ if(row==null)
+ return null;
+ String sessionId = row.getString("primary_id");
+ MusicSession musicSession = new MusicSession(sessionId);
+ musicSession.setCreationTime(Instant.parse(row.getString("creation_time")));
+ musicSession.setLastAccessedTime(Instant.parse(row.getString("last_access_time")));
+ musicSession.setMaxInactiveInterval(Duration.parse(row.getString("max_inactive_interval")));
+ return musicSession;
+ }
+
+ public static boolean isMusicSerializeCompress(){
+ if(musicSerializeCompress==null){
+ logger.error(EELFLoggerDelegate.errorLogger, "Failed to read property file " + MusicProperties.MUSIC_SERIALIZE_COMPRESS +" fall back to eventual put");
+ return false;
+ }
+ return musicSerializeCompress.trim().equalsIgnoreCase("true");
+ }
+
+ public static boolean isAtomicPut(){
+ if(atomicPut==null){
+ logger.error(EELFLoggerDelegate.errorLogger, "Failed to read property file " + MusicProperties.MUSIC_ATOMIC_PUT +" fall back to eventual put");
+ return false;
+ }
+ return atomicPut.trim().equalsIgnoreCase("true");
+ }
+
+ public static boolean isAtomicGet(){
+ if(atomicGet==null){
+ logger.error(EELFLoggerDelegate.errorLogger, "Failed to read property file " + MusicProperties.MUSIC_ATOMIC_GET +" fall back to eventual get");
+ return false;
+ }
+ return atomicGet.trim().equalsIgnoreCase("true");
+ }
+
+ public static boolean isCached(){
+ if(cached==null){
+ logger.error(EELFLoggerDelegate.errorLogger, "Failed to read property file " + MusicProperties.MUSIC_CACHE +" fall back to non cache");
+ return false;
+ }
+ return cached.trim().equalsIgnoreCase("true");
+ }
+}
diff --git a/ecomp-sdk/epsdk-music/src/main/resources/org/onap/music/core/2.4.4/core-2.4.4.jar b/ecomp-sdk/epsdk-music/src/main/resources/org/onap/music/core/2.4.4/core-2.4.4.jar
new file mode 100644
index 00000000..c2dd2dba
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/src/main/resources/org/onap/music/core/2.4.4/core-2.4.4.jar
Binary files differ
diff --git a/ecomp-sdk/epsdk-music/src/main/resources/org/onap/music/core/maven-metadata-local.xml b/ecomp-sdk/epsdk-music/src/main/resources/org/onap/music/core/maven-metadata-local.xml
new file mode 100644
index 00000000..01c2b2bf
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/src/main/resources/org/onap/music/core/maven-metadata-local.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+ <groupId>org.onap.music</groupId>
+ <artifactId>core</artifactId>
+ <versioning>
+ <release>2.4.4</release>
+ <versions>
+ <version>2.4.4</version>
+ </versions>
+ <lastUpdated>20180302203455</lastUpdated>
+ </versioning>
+</metadata>
diff --git a/ecomp-sdk/epsdk-music/src/main/resources/org/onap/music/dependency/2.4.4/dependency-2.4.4.jar b/ecomp-sdk/epsdk-music/src/main/resources/org/onap/music/dependency/2.4.4/dependency-2.4.4.jar
new file mode 100644
index 00000000..8c5a5e04
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/src/main/resources/org/onap/music/dependency/2.4.4/dependency-2.4.4.jar
Binary files differ
diff --git a/ecomp-sdk/epsdk-music/src/main/resources/org/onap/music/dependency/maven-metadata-local.xml b/ecomp-sdk/epsdk-music/src/main/resources/org/onap/music/dependency/maven-metadata-local.xml
new file mode 100644
index 00000000..695d90ac
--- /dev/null
+++ b/ecomp-sdk/epsdk-music/src/main/resources/org/onap/music/dependency/maven-metadata-local.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<metadata>
+ <groupId>org.onap.music</groupId>
+ <artifactId>dependency</artifactId>
+ <versioning>
+ <release>2.4.4</release>
+ <versions>
+ <version>2.4.4</version>
+ </versions>
+ <lastUpdated>20180302203455</lastUpdated>
+ </versioning>
+</metadata>
diff --git a/ecomp-sdk/epsdk-workflow/pom.xml b/ecomp-sdk/epsdk-workflow/pom.xml
index 4c95a66a..0a817850 100644
--- a/ecomp-sdk/epsdk-workflow/pom.xml
+++ b/ecomp-sdk/epsdk-workflow/pom.xml
@@ -30,17 +30,17 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
- <version>2.9.2</version>
+ <version>2.8.10</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
diff --git a/ecomp-sdk/pom.xml b/ecomp-sdk/pom.xml
index 6fa922c9..8ae56339 100644
--- a/ecomp-sdk/pom.xml
+++ b/ecomp-sdk/pom.xml
@@ -23,6 +23,7 @@
<module>epsdk-fw</module>
<module>epsdk-core</module>
<module>epsdk-analytics</module>
+ <module>epsdk-music</module>
<module>epsdk-workflow</module>
<module>epsdk-app-common</module>
<module>epsdk-app-overlay</module>