Adding part-1 of naming micro-service code.

Adding pom, main files and policy related classes.

Change-Id: I9ccbd03784cb2d85b3f1be353417f596384bd554
Issue-ID: CCSDK-342
Signed-off-by: BT2983 <BT2983@att.com>
diff --git a/ms/neng/.classpath b/ms/neng/.classpath
new file mode 100644
index 0000000..2fd27b3
--- /dev/null
+++ b/ms/neng/.classpath
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" output="target/classes" path="src/main/java">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="opt/etc/config">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="opt/etc/keystore">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="opt/etc/truststore">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java">
+		<attributes>
+			<attribute name="optional" value="true"/>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry excluding="**" kind="src" output="target/classes" path="opt/aai/keystore">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="src" path=".apt_generated">
+		<attributes>
+			<attribute name="optional" value="true"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/ms/neng/.project b/ms/neng/.project
new file mode 100644
index 0000000..e3af483
--- /dev/null
+++ b/ms/neng/.project
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>networkelementnamegen</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.wst.common.project.facet.core.builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.springframework.ide.eclipse.core.springbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.springframework.ide.eclipse.core.springnature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
+		<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
+	</natures>
+</projectDescription>
diff --git a/ms/neng/.settings/org.eclipse.core.resources.prefs b/ms/neng/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 0000000..219fb33
--- /dev/null
+++ b/ms/neng/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,10 @@
+eclipse.preferences.version=1
+encoding//opt/aai/keystore=UTF-8
+encoding//opt/etc/config=UTF-8
+encoding//opt/etc/keystore=UTF-8
+encoding//opt/etc/truststore=UTF-8
+encoding//src/main/java=UTF-8
+encoding//src/main/resources=UTF-8
+encoding//src/test/java=UTF-8
+encoding//src/test/resources=UTF-8
+encoding/<project>=UTF-8
diff --git a/ms/neng/.settings/org.eclipse.jdt.core.prefs b/ms/neng/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..78b2bfc
--- /dev/null
+++ b/ms/neng/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,6 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.processAnnotations=enabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/ms/neng/README.md b/ms/neng/README.md
new file mode 100644
index 0000000..0c82cfa
--- /dev/null
+++ b/ms/neng/README.md
@@ -0,0 +1,32 @@
+<!-- 
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+  -->
+
+## ONAP-CCSDK.apps-NetworkElementNameGen (NENG)
+
+Micro-service to generate names for network elements based on naming policies.
+
+
+
+### Build and test
+
+````bash
+$ mvn clean install
+````
+
diff --git a/ms/neng/pom.xml b/ms/neng/pom.xml
new file mode 100644
index 0000000..e96b4f6
--- /dev/null
+++ b/ms/neng/pom.xml
@@ -0,0 +1,377 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+  -->
+<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>
+
+    <groupId>org.onap.ccsdk.apps.ms</groupId>
+    <artifactId>networkelementnamegen</artifactId>
+    <version>2018.10.01</version>
+
+    <properties>
+        <swagger.directory>${basedir}/target/classes/META-INF/resources/swagger</swagger.directory>
+        <icd.file>service.json</icd.file>
+        <icd.package>org.onap.ccsdk.apps.ms.neng.service.rs</icd.package>
+        <java.version>1.8</java.version>
+        <docker.registry>TBD:5100</docker.registry>
+        <build.number>local</build.number>
+        <kube.namespace>TBD</kube.namespace>
+        <service.account>TBD</service.account>
+        <namespace>org.onap.ccsdk.apps.ms.neng</namespace>
+        <maven.compiler.source>1.8</maven.compiler.source>
+        <maven.compiler.target>1.8</maven.compiler.target>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <sdk.java.rest>6.2.0.11</sdk.java.rest>
+        <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
+        <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
+        <sonar.surefire.reportsPath>${basedir}/target/surefire-reports</sonar.surefire.reportsPath>
+        <sonar.failsafe.reportsPath>${basedir}/target/failsafe-reports</sonar.failsafe.reportsPath>
+        <jacoco.path>${basedir}/target/jacoco_report</jacoco.path>
+        <jacoco.itPath>${basedir}/target/jacoco_itReport</jacoco.itPath>
+        <sonar.jacoco.reportPath>${basedir}/target/jacoco-ut.exec</sonar.jacoco.reportPath>
+        <sonar.jacoco.itReportPath>${basedir}/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+        <sonar.language>java</sonar.language>
+        <serviceArtifactName>ms-networkelementnamegen</serviceArtifactName>
+    </properties>
+
+    <profiles>
+        <profile>
+            <id>all-tests</id>
+            <properties>
+                <build.profile.id>all-tests</build.profile.id>
+                <skip.integration.tests>false</skip.integration.tests>
+                <skip.unit.tests>false</skip.unit.tests>
+            </properties>
+        </profile>
+        <profile>
+            <id>dev</id>
+        </profile>
+        <profile>
+            <id>integration-test</id>
+            <properties>
+                <build.profile.id>integration-test</build.profile.id>
+                <skip.integration.tests>false</skip.integration.tests>
+                <skip.unit.tests>true</skip.unit.tests>
+            </properties>
+        </profile>
+    </profiles>
+
+    <developers>
+        <developer>
+            <id>${userId}</id>
+        </developer>
+    </developers>
+    
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>1.5.3.RELEASE</version>
+        <relativePath/>
+    </parent>
+
+    <dependencies>
+        <dependency>
+            <groupId>io.swagger</groupId>
+            <artifactId>swagger-core</artifactId>
+            <version>1.5.20</version>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-jersey</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-actuator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-tomcat</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-jpa</artifactId>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.ws.rs</groupId>
+            <artifactId>javax.ws.rs-api</artifactId>
+            <version>2.1</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.6</version>
+        </dependency>
+        <dependency>
+            <groupId>org.liquibase</groupId>
+            <artifactId>liquibase-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.wisdom-framework</groupId>
+            <artifactId>mysql-connector-java</artifactId>
+            <version>5.1.34_1</version>
+        </dependency>
+        <dependency>
+            <groupId>com.h2database</groupId>
+            <artifactId>h2</artifactId>
+        </dependency>
+
+        <dependency>
+        	<groupId>org.springframework.boot</groupId>
+        	<artifactId>spring-boot-configuration-processor</artifactId>
+        	<optional>true</optional>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <finalName>NetworkElementNameGen</finalName>
+        <plugins>
+            <plugin>
+                <groupId>org.jacoco</groupId>
+                <artifactId>jacoco-maven-plugin</artifactId>
+                <version>0.7.5.201505241946</version>
+                <executions>
+                    <execution>
+                        <id>pre-unit-test</id>
+                        <goals>
+                            <goal>prepare-agent</goal>
+                        </goals>
+                        <configuration>
+                            <destFile>${sonar.jacoco.reportPath}</destFile>
+                            <propertyName>surefireArgLine</propertyName>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>post-unit-test</id>
+                        <phase>test</phase>
+                        <goals>
+                            <goal>report</goal>
+                        </goals>
+                        <configuration>
+                            <dataFile>${sonar.jacoco.reportPath}</dataFile>
+                            <outputDirectory>${jacoco.path}</outputDirectory>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>pre-integration-test</id>
+                        <phase>pre-integration-test</phase>
+                        <goals>
+                            <goal>prepare-agent</goal>
+                        </goals>
+                        <configuration>
+                            <destFile>${sonar.jacoco.itReportPath}</destFile>
+                            <propertyName>failsafeArgLine</propertyName>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>post-integration-test</id>
+                        <phase>post-integration-test</phase>
+                        <goals>
+                            <goal>report</goal>
+                        </goals>
+                        <configuration>
+                            <dataFile>${sonar.jacoco.itReportPath}/</dataFile>
+                            <outputDirectory>${jacoco.itPath}</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <configuration>
+                    <argLine>${surefireArgLine}</argLine>
+                    <skipTests>${skip.unit.tests}</skipTests>
+                    <excludes>
+                        <exclude>**/IT*.java</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>integration-tests</id>
+                        <goals>
+                            <goal>integration-test</goal>
+                            <goal>verify</goal>
+                        </goals>
+                        <configuration>
+                            <argLine>${failsafeArgLine}</argLine>
+                            <skipTests>${skip.integration.tests}</skipTests>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <artifactId>maven-dependency-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>com.github.kongchen</groupId>
+                <artifactId>swagger-maven-plugin</artifactId>
+                <version>3.1.3</version>
+                <configuration>
+                    <apiSources>
+                        <apiSource>
+                            <locations>org.onap.ccsdk.apps.ms.neng.service.rs</locations>
+                            <basePath>/web</basePath>
+                            <info>
+                                <title>${project.artifactId} Service</title>
+                                <version>${project.version}</version>
+                            </info>
+                            <swaggerDirectory>${swagger.directory}</swaggerDirectory>
+                        </apiSource>
+                    </apiSources>
+                </configuration>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>generate</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+
+            <plugin>
+                <artifactId>exec-maven-plugin</artifactId>
+                <groupId>org.codehaus.mojo</groupId>
+            </plugin>
+            <plugin>
+                <groupId>com.spotify</groupId>
+                <artifactId>docker-maven-plugin</artifactId>
+                <version>0.4.11</version>
+                <configuration>
+                    <imageName>${docker.registry}/org.onap.ccsdk.apps/${serviceArtifactName}</imageName>
+                    <dockerDirectory>src/main/docker</dockerDirectory>
+                    <serverId>docker-hub</serverId>
+                    <registryUrl>https://${docker.registry}</registryUrl>
+                    <imageTags>
+                        <imageTag>${project.version}</imageTag>
+                        <imageTag>latest</imageTag>
+                    </imageTags>
+                    <forceTags>true</forceTags>
+                    <resources>
+                        <resource>
+                            <targetPath>/</targetPath>
+                            <directory>${project.build.directory}</directory>
+                            <include>${project.build.finalName}.jar</include>
+                        </resource>
+                        <resource>
+                            <targetPath>/</targetPath>
+                            <directory>${project.build.directory}</directory>
+                            <include>opt/etc/config/*</include>
+                        </resource>
+                        <resource>
+                            <targetPath>/</targetPath>
+                            <directory>${project.build.directory}</directory>
+                            <include>opt/etc/keystore/*</include>
+                        </resource>
+                        <resource>
+                            <targetPath>/</targetPath>
+                            <directory>${project.build.directory}</directory>
+                            <include>opt/etc/truststore/*</include>
+                        </resource>
+                        <resource>
+                            <targetPath>/</targetPath>
+                            <directory>${project.build.directory}</directory>
+                            <include>opt/aai/keystore/*</include>
+                        </resource>
+                        <resource>
+                            <targetPath>/</targetPath>
+                            <directory>${project.build.directory}</directory>
+                            <include>etc/*</include>
+                        </resource>
+                    </resources>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>repackage</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </resource>
+            <resource>
+                <directory>opt/aai/keystore</directory>
+                <targetPath>../opt/aai/keystore</targetPath>
+                <filtering>false</filtering>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </resource>
+
+            <resource>
+                <directory>opt/etc/config</directory>
+                <targetPath>../opt/etc/config</targetPath>
+                <filtering>true</filtering>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </resource>
+            <resource>
+                <directory>opt/etc/keystore</directory>
+                <targetPath>../opt/etc/keystore</targetPath>
+                <filtering>false</filtering>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </resource>
+            <resource>
+                <directory>opt/etc/truststore</directory>
+                <targetPath>../opt/etc/truststore</targetPath>
+                <filtering>false</filtering>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </resource>
+        </resources>
+    </build>
+</project>
+
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/Application.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/Application.java
new file mode 100644
index 0000000..e95fb7e
--- /dev/null
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/Application.java
@@ -0,0 +1,77 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.apps.ms.neng.core;
+
+import java.util.Arrays;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
+import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.web.support.SpringBootServletInitializer;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.ComponentScan;
+import org.springframework.scheduling.annotation.EnableAsync;
+
+/**
+ * Entry point for the micro-service -- it starts up the application. 
+ */
+@SpringBootApplication
+@ComponentScan(basePackages = "org.onap.ccsdk")
+@EnableAsync
+@EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
+public class Application extends SpringBootServletInitializer {
+    /**
+     * Configures the application.
+     */
+    @Override
+    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
+        return application.sources(Application.class);
+    }
+
+    /**
+     * Entry point for the application. 
+     */
+    public static void main(String[] args) throws Exception {
+        SpringApplication.run(Application.class, args);
+    }
+
+    /**
+     * Prints diagnostic information after application startup.
+     */
+    @Bean
+    public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
+        return args -> {
+            System.out.println("################################");
+            System.out.println("Inspecting the beans provided by Spring Boot:");
+            String[] beanNames = ctx.getBeanDefinitionNames();
+            Arrays.sort(beanNames);
+            for (String beanName : beanNames) {
+                System.out.println(beanName);
+            }
+            System.out.println("################################");
+        };
+    }
+
+}
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
new file mode 100644
index 0000000..d69c270
--- /dev/null
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/persistence/ApplicationConfig.java
@@ -0,0 +1,141 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.apps.ms.neng.core.persistence;
+
+import java.util.HashMap;
+import java.util.Map;
+import javax.sql.DataSource;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.orm.jpa.JpaProperties;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.env.Environment;
+import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
+import org.springframework.jdbc.datasource.DriverManagerDataSource;
+import org.springframework.orm.jpa.JpaTransactionManager;
+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;
+
+/**
+ * Manages the overall configuration of the application related to persistence.
+ */
+@Configuration
+@EnableJpaRepositories(basePackages = "org.onap.ccsdk.apps.ms.neng.persistence.repository")
+@EnableTransactionManagement
+public class ApplicationConfig {
+
+    @Autowired
+    private Environment environment;
+
+    /**
+     * Builds and returns the DataSource used for persisting the data managed by this micro-service.
+     */
+    @Bean
+    public DataSource dataSource() {
+        DriverManagerDataSource dataSource = new DriverManagerDataSource();
+        dataSource.setDriverClassName(environment.getProperty("datasource.db.driver-class-name"));
+        dataSource.setUrl(environment.getProperty("datasource.db.url"));
+        dataSource.setUsername(environment.getProperty("datasource.db.username"));
+        dataSource.setPassword(environment.getProperty("datasource.db.password"));
+        return dataSource;
+    }
+
+    /**
+     * Builds and returns the JpaProperties used for configuration.
+     */
+    @Bean
+    @ConfigurationProperties(prefix = "jpa")
+    public JpaProperties jpaProperties() {
+        return new JpaProperties();
+    }
+
+    /**
+     * Builds and returns the JpaVendorAdapter used for configuration.
+     */
+    @Bean
+    public JpaVendorAdapter jpaVendorAdapter(JpaProperties jpaProperties) {
+        HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
+        hibernateJpaVendorAdapter.setShowSql(jpaProperties.isShowSql());
+        hibernateJpaVendorAdapter.setGenerateDdl(jpaProperties.isGenerateDdl());
+        return hibernateJpaVendorAdapter;
+    }
+
+    /**
+     * Builds and returns the Properties used for Hibernate configuration.
+     */
+    @Bean
+    public Map<String, String> hibProperties() {
+        Map<String, String> hibProperties = new HashMap<>();
+        String[] propertyNames = {
+            "hibernate.dialect",
+            "hibernate.show_sql",
+            "hibernate.format_sql",
+            "hibernate.cache.provider_class",
+            "hibernate.id.new_generator_mappings",
+            "hibernate.hbm2ddl.auto",
+        };
+        for (String name : propertyNames) {
+            hibProperties.put(name,  environment.getProperty(name));
+        }
+        return hibProperties;
+    }
+
+    /**
+     * Builds and returns the JpaTransactionManager.
+     */
+    @Bean
+    public JpaTransactionManager transactionManager(LocalContainerEntityManagerFactoryBean entityManagerFactory) {
+        JpaTransactionManager transactionManager = new JpaTransactionManager();
+        transactionManager.setEntityManagerFactory(entityManagerFactory.getObject());
+        return transactionManager;
+    }
+
+    /**
+     * Builds and returns the PersistenceExceptionTranslationPostProcessor.
+     * 
+     * <p/>PersistenceExceptionTranslationPostProcessor is a bean post processor which adds an advisor to any bean 
+     * annotated with Repository so that any platform-specific exceptions are caught and then re-thrown 
+     * as one of Spring's unchecked data access exceptions (i.e. a subclass of DataAccessException).
+     */
+    @Bean
+    public PersistenceExceptionTranslationPostProcessor exceptionTranslation() {
+        return new PersistenceExceptionTranslationPostProcessor();
+    }
+
+    /**
+     * Builds and returns the Factory used for building entities.
+     */
+    @Bean
+    public LocalContainerEntityManagerFactoryBean entityManagerFactory(
+                    JpaVendorAdapter jpaVendAdapter, 
+                    Map<String, String> hibProps, 
+                    DataSource dataSource) {
+        EntityManagerFactoryBuilder factBuilder = new EntityManagerFactoryBuilder(jpaVendAdapter, hibProps, null);
+        String pkgToScan = environment.getProperty("entitymanager.packagesToScan");
+        return factBuilder.dataSource(dataSource).packages(pkgToScan).build();
+    }
+
+}
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyFinder.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyFinder.java
new file mode 100644
index 0000000..6d8a27a
--- /dev/null
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyFinder.java
@@ -0,0 +1,38 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.apps.ms.neng.core.policy;
+
+import java.util.Map;
+
+/**
+ * Finds policy data, normally by calling policy-manager.
+ */
+public interface PolicyFinder {
+    /**
+     * Finds the policy with a given name.
+     * 
+     * @param policyName   the name of the policy the caller is looking for
+     * @return             a map ( String -> Object ) representing the policy, as a general JSON structure, 
+     *     where the map entries are String-s, or arrays of similar maps, or similar nested maps. 
+     * @throws Exception   any exceptions caught are propagated
+     */
+    public Map<String, Object> findPolicy(String policyName) throws Exception;
+}
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyParameters.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyParameters.java
new file mode 100644
index 0000000..37fc38c
--- /dev/null
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyParameters.java
@@ -0,0 +1,44 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.apps.ms.neng.core.policy;
+
+/**
+ * Specifies parameters that control the nature of policy data and the behavior of this micro-service.
+ * 
+ * <p/>These parameters are typically stored in DB or read from a configuration file.
+ */
+public interface PolicyParameters {
+    /**
+     * Gives the separator between the entries within the same recipe -- such as the pipe('|') character.
+     */
+    public String getRecipeSeparator() throws Exception;
+
+    /**
+     * Maps a given function, used in the policy, to the equivalent function in this micro-service. 
+     */
+    public String mapFunction(String name) throws Exception;
+
+    /**
+     * Maximum number of times the micro-service should attempt name generation in the same transaction
+     * (if all previous attempts in the same transaction fail). 
+     */
+    public int getMaxGenAttempt() throws Exception;
+}
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyPropertyMethodUtils.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyPropertyMethodUtils.java
new file mode 100644
index 0000000..9f4725f
--- /dev/null
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyPropertyMethodUtils.java
@@ -0,0 +1,69 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.apps.ms.neng.core.policy;
+
+/**
+ * Utility methods equivalent to the JavaScript like functions used in policies by the policy-manager.
+ */
+public class PolicyPropertyMethodUtils {
+
+    /**
+     * Equivalent to the substring function used by policy-manager (which works similar to JavaScript
+     * substring function).
+     */
+    public static String substring(String sourceStr, String startIndex, String endIndex) {
+        return sourceStr.substring(Integer.parseInt(startIndex), Integer.parseInt(endIndex));
+    }
+
+    /**
+     * Equivalent to the substring function used by policy-manager (which works similar to JavaScript
+     * substring function).
+     */
+    public static String substring(String sourceStr, String length) {
+
+        int startIndexInt = 0;
+        int subStrLength = Integer.parseInt(length);
+        if (subStrLength < 0) {
+
+            startIndexInt = sourceStr.length() + subStrLength;
+            startIndexInt = (startIndexInt < 0) ? 0 : startIndexInt;
+
+            return sourceStr.substring(startIndexInt);
+        } else if (subStrLength > sourceStr.length()) {
+            subStrLength = sourceStr.length();
+        }
+        return sourceStr.substring(startIndexInt, subStrLength);
+    }
+
+    /**
+     * Equivalent to the to_upper_case function used by policy-manager.
+     */
+    public static String toUpperCase(String sourceStr) {
+        return sourceStr.toUpperCase();
+    }
+
+    /**
+     * Equivalent to the to_lower_case function used by policy-manager.
+     */
+    public static String toLowerCase(String sourceStr) {
+        return sourceStr.toLowerCase();
+    }
+}
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
new file mode 100644
index 0000000..de034f0
--- /dev/null
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicyReader.java
@@ -0,0 +1,328 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.apps.ms.neng.core.policy;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Converts policy data to the structure expected by this micro-service.
+ */
+public abstract class PolicyReader implements PolicyFinder {
+    /**
+     * Extracts the naming-models from a policy.
+     * 
+     * @param policy    the policy
+     * @return          the list of naming-models found in the policy
+     */
+    public static List<Map<String, ?>> namingModels(Map<String, ?> policy) {
+        Set<String> keys = policy.keySet();
+        // TODO : retrieve naming-models at any level
+        if (keys.contains("config")) {
+            @SuppressWarnings("unchecked")
+            Map<String, ?> config = (Map<String, ?>) policy.get("config");
+            List<Map<String, ?>> namingModels = list(map(config, "content"), "naming-models");
+            if (namingModels == null) {
+                namingModels = list(config, "naming-models");
+            }
+            return namingModels;
+        } else {
+            return list(map(map(policy, "input"), "naming-model"), "naming-models");
+        }
+
+    }
+
+    /**
+     * Extracts a naming-model from the given list of models, based on a naming-type.
+     * 
+     * @param namingModels    a list of naming-models
+     * @param namingType      the naming type
+     * @return                the naming model found, or null if none is found
+     */
+    public static Map<String, ?> namingModel(List<Map<String, ?>> namingModels, String namingType) {
+        Map<String, ?> theModel = null;
+        if (namingModels != null) {
+            for (Map<String, ?> model : namingModels) {
+                Object val = model.get("naming-type");
+                if (namingType.equals(val)) {
+                    theModel = model;
+                    break;
+                }
+            }
+        }
+        return theModel;
+    }
+    
+    /**
+     * Extracts a naming-model from the given list of models, based on a naming-type, by using a more
+     * relaxed/liberal comparison of the naming-type.
+     * 
+     * <p/>When doing the relaxed comparison, upper-case/lower-case differences are ignored, some
+     * special characters like underscore, dash etc. are ignored, and the presence of the 'NAME'
+     * at the end of the naming-type is ignored.
+     * 
+     * @param namingModels    a list of naming-models
+     * @param namingType      the naming type
+     * @return                the naming model found, or null if none is found
+     */
+    public static Map<String, ?> namingModelRelaxed(List<Map<String, ?>> namingModels, String namingType) {
+        Map<String, ?> theModel = null;
+        if (namingModels != null) {
+            for (Map<String, ?> model : namingModels) {
+                Object val = model.get("naming-type");
+                if (val != null) {
+                    if (namingType.equalsIgnoreCase(val.toString())) {
+                        theModel = model;
+                        break;
+                    }
+                }
+            }
+            if (theModel == null) {
+                namingType = relaxedNamingType(namingType);
+                for (Map<String, ?> model : namingModels) {
+                    Object val = model.get("naming-type");
+                    if (val != null) {
+                        String relaxedVal = relaxedNamingType(val.toString());
+                        if (namingType.equalsIgnoreCase(relaxedVal)) {
+                            theModel = model;
+                            break;
+                        }
+                    }
+                }
+            }
+        }
+        return theModel;
+    }
+
+    /**
+     * Finds the naming-operation from the given naming-model. 
+     */
+    public static String namingOperation(Map<String, ?> namimgModel) {
+        String propValue = value(namimgModel, "name-operation");
+        return propValue;
+    }
+
+    /**
+     * Finds the naming-property with a given name from a naming-model.
+     *  
+     * @param namingModel    a naming-model
+     * @param propertyName   the property name
+     * @return               the property found, or null if none is found
+     */
+    public static Map<String, ?> namingProperty(Map<String, ?> namingModel, String propertyName) {
+        List<Map<String, ?>> properties = namingProperties(namingModel);
+        Map<String, ?> theProp = null;
+        if (properties != null) {
+            for (Map<String, ?> prop : properties) {
+                String onePropName = propertyName(prop);
+                if (propertyName.equals(onePropName)) {
+                    theProp = prop;
+                    break;
+                }
+            }
+        }
+        return theProp;
+    }
+
+    /**
+     * Finds the naming-recipe from the given naming-model. 
+     */
+    public static String namingRecipe(Map<String, ?> namimgModel) {
+        return value(namimgModel, "naming-recipe");
+    }
+
+    /**
+     * Finds the naming-type from the given naming-model. 
+     */
+    public static String namingType(Map<String, ?> namimgModelOrElement) {
+        return value(namimgModelOrElement, "naming-type");
+    }
+
+    /**
+     * Finds the property-value from the given property map. 
+     */
+    public static String propertyValue(Map<String, ?> properties) {
+        return value(properties, "property-value");
+    }
+
+    /**
+     * Converts the a naming-type to a relaxed/liberal convention.
+     * 
+     * <p/>In the relaxed convention, all characters are upper-case, some special characters like underscore, 
+     * dash etc. are ignored, and there is no 'NAME' at the end of the naming-type.
+     * 
+     *  @param type    the naming-type
+     */
+    public static String relaxedNamingType(String type) {
+        type = type.toUpperCase();
+        if (type.endsWith("NAME")) {
+            type = type.substring(0, type.length() - 4);
+        }
+        type = type.replaceAll("-", "");
+        type = type.replaceAll("_", "");
+        return type;
+    }
+
+    /**
+     * Builds a PolicySequence based on given properties. 
+     */
+    public static PolicySequence seq(Map<String, ?> properties) {
+        properties = map(properties, "increment-sequence");
+        String scope = value(properties, "scope");
+        String startValue = value(properties, "start-value");
+        String max = value(properties, "max");
+        String increment = value(properties, "increment");
+        String type = value(properties, "sequence-type");
+        String length = value(properties, "length");
+
+        PolicySequence seq = new PolicySequence();
+        seq.setScope(scope);
+        seq.setStartValue(number(startValue, 1));
+        seq.setMaxValueString(max);
+        seq.setIncrement(number(increment, 1));
+        seq.setType(type);
+        seq.setLength(number(length, 3));
+
+        return seq;
+    }
+    
+    /**
+     * Finds the value of a given key, as a String, in a map.
+     * 
+     * @param map    a map, which can be null
+     * @param key    a key
+     * @return       the value of the key in the map, or null if there is none.
+     */
+    public static String value(Map<String, ?> map, String key) {
+        String value = null;
+        if (map != null) {
+            value = (String) map.get(key);
+            if (!(value instanceof String)) {
+                value = null;
+            }
+        }
+        return value;
+    }
+
+    /**
+     * Finds the value of a given key, as a String, in a map.
+     * 
+     * @param map      a map, which can be null
+     * @param key      a key
+     * @param relaxed  if true, relaxed/liberal comparison of the keys is done, by ignoring special
+     *     characters dash and underscore
+     * @return         the value of the key in the map, or null if there is none.
+     */
+    public static String value(Map<String, ?> map, String key, boolean relaxed) {
+        if (relaxed) {
+            String value = null;
+            if (map != null) {
+                for (final String aKey : map.keySet()) {
+                    if (aKey.equalsIgnoreCase(key)) {
+                        value = (String) map.get(aKey);
+                        break;
+                    }
+                }
+                if (value == null) {
+                    key = key.replaceAll("_", "");
+                    key = key.replaceAll("-", "");
+                    for (final String aKey : map.keySet()) {
+                        String keyDup = aKey.replaceAll("_", "");
+                        keyDup = keyDup.replaceAll("-", "");
+                        if (keyDup.equalsIgnoreCase(key)) {
+                            value = (String) map.get(aKey);
+                            break;
+                        }
+                    }
+                }
+                if (!(value instanceof String)) {
+                    value = null;
+                }
+            }
+            return value;
+        } else {
+            return value(map, key);
+        }
+    }
+
+    static Map<String, ?> dependentNamingModel(List<Map<String, ?>> namingModels, String recipeItem) {
+        Map<String, ?> theModel = namingModel(namingModels, recipeItem);
+        if (theModel == null) {
+            theModel = namingModelRelaxed(namingModels, recipeItem);
+        }
+        return theModel;
+    }
+
+    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 jsonObject;
+    }
+    
+    static List<Map<String, ?>> list(Map<String, ?> policy, String name) {
+        List<Map<String, ?>> list = null;
+        if (policy != null) {
+            @SuppressWarnings("unchecked")
+            List<Map<String, ?>> listObj = (List<Map<String, ?>>) policy.get(name);
+            if (list instanceof List<?>) {
+                list = listObj;
+            }
+        }
+        return list;
+    }
+    
+    static Map<String, ?> map(Map<String, ?> policy, String name) {
+        Map<String, ?> map = null;
+        if (policy != null) {
+            @SuppressWarnings("unchecked")
+            Map<String, ?> mapObj = (Map<String, ?>) policy.get(name);
+            if (mapObj instanceof Map<?, ?>) {
+                map = mapObj;
+            }
+        }
+        return map;
+    }
+
+    static List<Map<String, ?>> namingProperties(Map<String, ?> namimgModel) {
+        return list(namimgModel, "naming-properties");
+    }
+    
+    static long number(String str, long defaultValue) {
+        long value;
+        try {
+            value = Long.valueOf(str);
+        } catch (Exception e) {
+            value = defaultValue;
+        }
+        return value;
+    }
+
+    static String propertyName(Map<String, ?> properties) {
+        return value(properties, "property-name");
+    }
+
+    static String propertyOperation(Map<String, ?> properties) {
+        return value(properties, "property-operation");
+    }
+}
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
new file mode 100644
index 0000000..dc0b6fd
--- /dev/null
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PolicySequence.java
@@ -0,0 +1,158 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.apps.ms.neng.core.policy;
+
+/**
+ * Represents a sequence object in the policy, as a POJO.
+ */
+public class PolicySequence {
+    /**
+     * The type of the policy sequence. 
+     */
+    public enum Type { 
+        ALPHA, NUMERIC 
+    }
+
+    private long startValue;
+    private long increment;
+    private long length;
+    private Long maxValue;
+    private String maxValueString;
+    private Type type = Type.NUMERIC;
+    private String scope;
+    private String key;
+    private String value;
+    private Long lastReleaseSeqNumTried;
+
+    public long getStartValue() {
+        return startValue;
+    }
+
+    public void setStartValue(long startValue) {
+        this.startValue = startValue;
+    }
+
+    public long getIncrement() {
+        return increment;
+    }
+
+    public void setIncrement(long increment) {
+        this.increment = increment;
+    }
+
+    public long getLength() {
+        return length;
+    }
+
+    public void setLength(long length) {
+        this.length = length;
+    }
+
+    /**
+     * Generate and return the maximum value for the sequence.
+     */
+    public long getMaxValue() {
+        if (this.maxValue == null) {
+            int base = 10;
+            if (this.type == Type.ALPHA) {
+                base = 36;
+            }
+            if (this.maxValueString != null) {
+                try {
+                    this.maxValue = Long.valueOf(this.maxValueString, base);
+                } catch (Exception e) {
+                    this.maxValue = null;
+                }
+            }
+            if (this.maxValue == null) {
+                long length = this.length;
+                if (length <= 0) {
+                    length = 3;
+                }
+                this.maxValue = (long) Math.pow(base, length) - 1;
+            }
+        }
+        return maxValue;
+    }
+
+    public void setMaxValue(long maxValue) {
+        this.maxValue = maxValue;
+    }
+
+    public String getMaxValueString() {
+        return maxValueString;
+    }
+
+    public void setMaxValueString(String maxValueString) {
+        this.maxValueString = maxValueString;
+    }
+
+    public Type getType() {
+        return type;
+    }
+
+    public void setType(Type type) {
+        this.type = type;
+    }
+
+    /**
+     * Sets the type.
+     */
+    public void setType(String typeStr) {
+        if ("numeric".equalsIgnoreCase(typeStr)) {
+            setType(Type.NUMERIC);
+        } else if ("alpha-numeric".equalsIgnoreCase(typeStr)) {
+            setType(Type.ALPHA);
+        }
+    }
+
+    public String getScope() {
+        return scope;
+    }
+
+    public void setScope(String scope) {
+        this.scope = scope;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public Long getLastReleaseSeqNumTried() {
+        return lastReleaseSeqNumTried;
+    }
+
+    public void setLastReleaseSeqNumTried(Long lastReleaseSeqNumTried) {
+        this.lastReleaseSeqNumTried = lastReleaseSeqNumTried;
+    }
+}
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperator.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperator.java
new file mode 100644
index 0000000..7eb6324
--- /dev/null
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/PropertyOperator.java
@@ -0,0 +1,152 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.apps.ms.neng.core.policy;
+
+import static org.onap.ccsdk.apps.ms.neng.core.policy.PolicyReader.propertyOperation;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+/**
+ * Applies property operations while processing a policy.
+ */
+public class PropertyOperator {
+    /**
+     * Apply a property found in the policy.
+     * 
+     * <p/> If the property cannot be applied correctly for any reason, the value is returned as is.
+     * 
+     * @param value           the String to which the property has to be applied
+     * @param propertyMap     a map representing the property, the key of which is "property-operation"
+     *     and the value is the actual property
+     * @param policyParams    parameters configuring policy 
+     * @return                the result of applying the property
+     * @throws Exception      all exceptions are propagated
+     */
+    public String apply(String value, Map<String, ?> propertyMap, PolicyParameters policyParams) throws Exception {
+        String op = propertyOperation(propertyMap);
+        String mapped = null;
+        if (op != null) {
+            String fn = operationFunction(op);
+            if (fn != null) {
+                mapped = policyParams.mapFunction(fn);
+                if (mapped == null) {
+                    mapped = camelConverted(fn);
+                }
+                if (mapped != null) {
+                    op = op.replaceFirst(fn, mapped);
+                }
+            }
+            value = applyJavaOperation(value, op, mapped);
+        }
+        return value;
+    }
+
+    /**
+     * Apply a property found in the policy.
+     * 
+     * <p/> If the property cannot be applied correctly for any reason, the value is returned as is.
+     * 
+     * @param value           the String to which the property has to be applied
+     * @param operation       the operation to be applied
+     * @param policyParams    parameters configuring policy 
+     * @return                the result of applying the property
+     * @throws Exception      all exceptions are propagated
+     */
+    public String apply(String value, String operation, PolicyParameters policyParams) throws Exception {
+        String mapped = null;
+        if (operation != null) {
+            String fn = operationFunction(operation);
+            if (fn != null) {
+                mapped = policyParams.mapFunction(fn);
+                if (mapped == null) {
+                    mapped = camelConverted(fn);
+                }
+                if (mapped != null) {
+                    operation = operation.replaceFirst(fn, mapped);
+                }
+            }
+            value = applyJavaOperation(value, operation, mapped);
+        }
+        return value;
+    }
+
+    private String applyJavaOperation(String inputString, String op, String methodName) throws Exception {
+        String postOp = null;
+        try {
+            String argPart = "";
+            if (op.indexOf("(") > 0) {
+                int funcStartIndex = op.indexOf("(");
+                int funcEndIndex = op.lastIndexOf(")");
+                argPart = op.substring(funcStartIndex + 1, funcEndIndex);
+            }
+
+            argPart = inputString + "," + argPart;
+            String[] args = argPart.split(",");
+
+            PolicyPropertyMethodUtils utils = new PolicyPropertyMethodUtils();
+            for (Method m : PolicyPropertyMethodUtils.class.getDeclaredMethods()) {
+                if (m.getName().equals(methodName) && m.getParameterCount() == args.length) {
+                    postOp = (String) m.invoke(utils, (Object[])args);
+                    break;
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            throw e;
+        }
+        return postOp;
+    }
+    
+    static String operationFunction(String operation) throws Exception {
+        operation = operation.trim();
+        int i = 0;
+        for (; i < operation.length(); ++i) {
+            char ch = operation.charAt(i);
+            if (!Character.isJavaIdentifierPart(ch)) {
+                break;
+            }
+        }
+        String value = operation.substring(0, i);
+        if (value.length() == 0) {
+            value = null;
+        }
+        return value;
+    }
+
+    static String camelConverted(String fn) throws Exception {
+        boolean upperNext = false;
+        StringBuffer buf = new StringBuffer();
+        for (int i = 0; i < fn.length(); ++i) {
+            char ch = fn.charAt(i);
+            if (ch == '_') {
+                upperNext = true;
+            } else {
+                if (upperNext) {
+                    ch = Character.toUpperCase(ch);
+                }
+                buf.append(ch);
+                upperNext = false;
+            }
+        }
+        return buf.toString();
+    }
+}
diff --git a/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/RecipeParser.java b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/RecipeParser.java
new file mode 100644
index 0000000..d9eda66
--- /dev/null
+++ b/ms/neng/src/main/java/org/onap/ccsdk/apps/ms/neng/core/policy/RecipeParser.java
@@ -0,0 +1,59 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : CCSDK.apps
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.apps.ms.neng.core.policy;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Parses recipe into a list of items.
+ */
+public class RecipeParser {
+
+    /**
+     * Parses recipe into a list of items.
+     * 
+     * @param policyParams    the policy parameters
+     * @param recipe          the recipe from policy manager
+     * @return                a list containing the items in the recipe
+     * @throws Exception      all exceptions are propagated
+     */
+    public static List<String> parseRecipe(PolicyParameters policyParams, String recipe) throws Exception {
+        String separatorAll = policyParams.getRecipeSeparator();
+        if (separatorAll == null) {
+            separatorAll = "|\":\",";
+        }
+        String[] separators = separatorAll.split("\"");
+        List<String> recipeItems = new ArrayList<>();
+        for (String separator : separators) {
+            if (recipe.contains(separator)) {
+                separator = "\\" + separator;
+                recipeItems = Arrays.asList(recipe.split(separator));
+                break;
+            }
+        }
+        if (recipeItems.isEmpty() && recipe.length() > 0) {
+            recipeItems.add(recipe);
+        }
+        return recipeItems;
+    }
+}