aboutsummaryrefslogtreecommitdiffstats
path: root/ms/neng
diff options
context:
space:
mode:
Diffstat (limited to 'ms/neng')
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/ApplicationConfig.java11
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/NamePersister.java2
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java11
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequence.java16
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java3
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/rs/RestServiceImpl.java14
-rw-r--r--ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImpl.java4
7 files changed, 39 insertions, 22 deletions
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/ApplicationConfig.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/ApplicationConfig.java
index f68add72..0bdf40ae 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/ApplicationConfig.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/ApplicationConfig.java
@@ -4,6 +4,9 @@
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * *================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -45,6 +48,9 @@ import org.springframework.orm.jpa.JpaVendorAdapter;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.annotation.EnableTransactionManagement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
/**
* Manages the overall configuration of the application related to persistence.
@@ -57,6 +63,7 @@ public class ApplicationConfig {
@Autowired
private Environment environment;
+ private Logger logger = LoggerFactory.getLogger(ApplicationConfig.class);
@SuppressWarnings("rawtypes")
void debugProperties() {
@@ -66,8 +73,8 @@ public class ApplicationConfig {
.filter(ps -> ps instanceof EnumerablePropertySource)
.map(ps -> ((EnumerablePropertySource) ps).getPropertyNames())
.flatMap(Arrays::<String>stream)
- .forEach(propName -> props.setProperty(propName, this.environment.getProperty(propName)));
- System.out.println("Properties: " + props);
+ .forEach(propName -> props.setProperty(propName, this.environment.getProperty(propName)));
+ logger.info("Properties: " + props);
}
/**
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/NamePersister.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/NamePersister.java
index cd07a46e..1dd6cebb 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/NamePersister.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/NamePersister.java
@@ -36,7 +36,7 @@ public class NamePersister {
/**
* Persist the given name.
*/
- public void persist(GeneratedName name) throws Exception {
+ public void persist(GeneratedName name) {
repository.save(name);
}
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java
index 09a6e49b..181bb7a3 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -95,7 +97,7 @@ public abstract class PolicyReader implements PolicyFinder {
Map<String, ?> theModel = null;
if (namingModels != null) {
for (Map<String, ?> model : namingModels) {
- Object val = model.get("naming-type");
+ Object val = model.get(NAMING_TYPE);
if (val != null) {
if (namingType.equalsIgnoreCase(val.toString())) {
theModel = model;
@@ -106,7 +108,7 @@ public abstract class PolicyReader implements PolicyFinder {
if (theModel == null) {
namingType = relaxedNamingType(namingType);
for (Map<String, ?> model : namingModels) {
- Object val = model.get("naming-type");
+ Object val = model.get(NAMING_TYPE);
if (val != null) {
String relaxedVal = relaxedNamingType(val.toString());
if (namingType.equalsIgnoreCase(relaxedVal)) {
@@ -124,8 +126,6 @@ public abstract class PolicyReader implements PolicyFinder {
* Finds the naming-operation from the given naming-model.
*/
public static String namingOperation(Map<String, ?> namimgModel) {
- //String propValue = value(namimgModel, "name-operation");
- //return propValue;
return value(namimgModel, "name-operation");
}
@@ -162,7 +162,7 @@ public abstract class PolicyReader implements PolicyFinder {
* Finds the naming-type from the given naming-model.
*/
public static String namingType(Map<String, ?> namimgModelOrElement) {
- return value(namimgModelOrElement, "naming-type");
+ return value(namimgModelOrElement, NAMING_TYPE);
}
/**
@@ -299,7 +299,6 @@ public abstract class PolicyReader implements PolicyFinder {
Map<String, Object> getPolicy(String jsonString) throws Exception {
ObjectMapper mapper = new ObjectMapper();
- // Map<String, Object> jsonObject = mapper.readValue(jsonString, new TypeReference<Map<String, Object>>() {});
return mapper.readValue(jsonString, new TypeReference<Map<String, Object>>() {});
}
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequence.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequence.java
index 526f67c1..f70b0633 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequence.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequence.java
@@ -3,13 +3,14 @@
* ONAP : CCSDK.apps
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2018 IBM.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* 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.
@@ -20,15 +21,17 @@
package org.onap.ccsdk.apps.ms.neng.core.policy;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Represents a sequence object in the policy, as a POJO.
*/
public class PolicySequence {
/**
- * The type of the policy sequence.
+ * The type of the policy sequence.
*/
- public enum Type {
- ALPHA, NUMERIC
+ public enum Type {
+ ALPHA, NUMERIC
}
private long startValue;
@@ -41,6 +44,8 @@ public class PolicySequence {
private String key;
private String value;
private Long lastReleaseSeqNumTried;
+ private Logger logger = LoggerFactory.getLogger(PolicySequence.class);
+
public long getStartValue() {
return startValue;
@@ -79,6 +84,7 @@ public class PolicySequence {
try {
this.maxValue = Long.valueOf(this.maxValueString, base);
} catch (Exception e) {
+ logger.error("Exception",e);
this.maxValue = null;
}
}
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java
index 01c8324d..c5cabe51 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/SpringServiceImpl.java
@@ -115,7 +115,7 @@ public class SpringServiceImpl implements SpringService {
List<Map<String, String>> allElements = new ArrayList<>();
Map<String, Map<String, ?>> policyCache = new HashMap<>();
List<Map<String, String>> generatedNames = new ArrayList<>();
- List<String> earlierNamingTypes = new ArrayList<String>();
+ List<String> earlierNamingTypes = new ArrayList<>();
validateRequest(request);
if (request.getElements() != null && !request.getElements().isEmpty()) {
allElements.addAll(request.getElements());
@@ -226,6 +226,7 @@ public class SpringServiceImpl implements SpringService {
}
void validateRequest(NameGenRequest request) throws Exception {
+ // this method does nothing
}
private PolicyFinder findPolicyFinderImpl(NameGenRequest request) {
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/rs/RestServiceImpl.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/rs/RestServiceImpl.java
index e52e0016..3746756e 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/rs/RestServiceImpl.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/service/rs/RestServiceImpl.java
@@ -42,7 +42,9 @@ import org.springframework.web.bind.annotation.RequestBody;
public class RestServiceImpl implements RestService {
private static Logger log = Logger.getLogger(RestServiceImpl.class.getName());
private static final String INTERNAL_ERROR_MSG = "Internal error occured while processing the request.";
-
+ private static final String ERROR="error";
+
+
@Autowired SpringService service;
/**
@@ -67,11 +69,11 @@ public class RestServiceImpl implements RestService {
return buildResponse(resp);
} catch (NengException e) {
log.warning(e.getMessage());
- response.put("error", buildErrorResponse("NELGEN-0003", e.getMessage()));
+ response.put(ERROR, buildErrorResponse("NELGEN-0003", e.getMessage()));
return buildErrorResponse(response);
} catch (Exception e) {
log.warning(e.getMessage());
- response.put("error", buildErrorResponse("err-0500", INTERNAL_ERROR_MSG));
+ response.put(ERROR, buildErrorResponse("err-0500", INTERNAL_ERROR_MSG));
return buildErrorResponse(response);
}
}
@@ -88,11 +90,11 @@ public class RestServiceImpl implements RestService {
return buildResponse(resp);
} catch (NengException e) {
log.warning(e.getMessage());
- response.put("error", buildErrorResponse("NELGEN-0002", e.getMessage()));
+ response.put(ERROR, buildErrorResponse("NELGEN-0002", e.getMessage()));
return buildErrorResponse(response);
} catch (Exception e) {
log.warning(e.getMessage());
- response.put("error", buildErrorResponse("err-0500", INTERNAL_ERROR_MSG));
+ response.put(ERROR, buildErrorResponse("err-0500", INTERNAL_ERROR_MSG));
return buildErrorResponse(response);
}
}
@@ -120,7 +122,7 @@ public class RestServiceImpl implements RestService {
return buildResponse(response);
} catch (Exception e) {
log.warning(e.getMessage());
- response.put("error", buildErrorResponse("err-0500", e.getMessage()));
+ response.put(ERROR, buildErrorResponse("err-0500", e.getMessage()));
return buildErrorResponse(response);
}
}
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImpl.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImpl.java
index e93675bf..b30ac0e6 100644
--- a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImpl.java
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/service/extinf/impl/PolicyFinderServiceImpl.java
@@ -4,6 +4,8 @@
* ================================================================================
* Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -74,7 +76,7 @@ public class PolicyFinderServiceImpl implements PolicyFinder {
if (response instanceof List) {
@SuppressWarnings("unchecked")
List<Map<String, Object>> policyList = (List<Map<String, Object>>) response;
- return ((policyList != null && policyList.size() > 0) ? policyList.get(0) : null);
+ return ((!policyList.isEmpty()) ? policyList.get(0) : null);
} else {
return null;
}