}
private GroupPolicyScopeList getPolicyObject(String policyScope) {
- GroupPolicyScopeList groupList= (GroupPolicyScopeList) commonClassDao.getEntityItem(GroupPolicyScopeList.class, "name", policyScope);
- return groupList;
+ return (GroupPolicyScopeList) commonClassDao.getEntityItem(GroupPolicyScopeList.class, "name", policyScope);
}
private PolicyRestAdapter constructJson(PolicyRestAdapter policyAdapter, String jsonContent, String dummyValue) {
}
}
- if(constraints!=null &&constraints.isEmpty()==false){
+ if(constraints!=null && ! constraints.isEmpty()){
//List handling.
listBuffer.append(keySetString.toUpperCase()+"=[");
for(String str:constraints){
String presKey = null;
for(String key: element.keySet()){
if(key.contains(".")){
- presKey = key.substring(0,key.indexOf("."));
+ presKey = key.substring(0,key.indexOf('.'));
}else if(key.contains("@")){
- presKey = key.substring(0,key.indexOf("@"));
+ presKey = key.substring(0,key.indexOf('@'));
}else{
presKey = key;
}
// first check if we are different from old.
LOGGER.info(key+"\n");
if(jsonArray!=null && jsonArray.length()>0 && key.contains("@") && !key.contains(".") && oldValue!=null){
- if(!oldValue.equals(key.substring(0,key.indexOf("@")))){
+ if(!oldValue.equals(key.substring(0,key.indexOf('@')))){
jsonResult.put(oldValue, jsonArray);
jsonArray = new JSONArray();
}
//
if(key.contains(".")){
if(nodeKey==null){
- nodeKey = key.substring(0,key.indexOf("."));
+ nodeKey = key.substring(0,key.indexOf('.'));
}
- if(nodeKey.equals(key.substring(0,key.indexOf(".")))){
- node.put(key.substring(key.indexOf(".")+1), element.get(key));
+ if(nodeKey.equals(key.substring(0,key.indexOf('.')))){
+ node.put(key.substring(key.indexOf('.')+1), element.get(key));
}else{
if(node.size()!=0){
if(nodeKey.contains("@")){
if(arryKey==null){
- arryKey = nodeKey.substring(0,nodeKey.indexOf("@"));
+ arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
}
if(nodeKey.endsWith("@0")){
isArray = true;
jsonArray = new JSONArray();
}
- if(jsonArray != null && arryKey.equals(nodeKey.substring(0,nodeKey.indexOf("@")))){
+ if(jsonArray != null && arryKey.equals(nodeKey.substring(0,nodeKey.indexOf('@')))){
jsonArray.put(decodeContent(node));
}
- if((key.contains("@") && !arryKey.equals(key.substring(0,nodeKey.indexOf("@")))) || !key.contains("@")){
+ if((key.contains("@") && !arryKey.equals(key.substring(0,nodeKey.indexOf('@')))) || !key.contains("@")){
jsonResult.put(arryKey, jsonArray);
jsonArray = new JSONArray();
}
- arryKey = nodeKey.substring(0,nodeKey.indexOf("@"));
+ arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
}else{
isArray = false;
jsonResult.put(nodeKey, decodeContent(node));
}
node = nodeFactory.objectNode();
}
- nodeKey = key.substring(0,key.indexOf("."));
+ nodeKey = key.substring(0,key.indexOf('.'));
if(nodeKey.contains("@")){
- arryKey = nodeKey.substring(0,nodeKey.indexOf("@"));
+ arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
}
- node.put(key.substring(key.indexOf(".")+1), element.get(key));
+ node.put(key.substring(key.indexOf('.')+1), element.get(key));
}
}else if(node.size()!=0){
if(nodeKey.contains("@")){
if(arryKey==null){
- arryKey = nodeKey.substring(0,nodeKey.indexOf("@"));
+ arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
}
if(nodeKey.endsWith("@0")){
isArray = true;
jsonArray = new JSONArray();
}
- if(jsonArray != null && arryKey.equals(nodeKey.substring(0,nodeKey.indexOf("@")))){
+ if(jsonArray != null && arryKey.equals(nodeKey.substring(0,nodeKey.indexOf('@')))){
jsonArray.put(decodeContent(node));
}
jsonResult.put(arryKey, jsonArray);
jsonArray = new JSONArray();
- arryKey = nodeKey.substring(0,nodeKey.indexOf("@"));
+ arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
}else{
isArray = false;
jsonResult.put(nodeKey, decodeContent(node));
}
if(isArray){
if(oldValue==null){
- oldValue = key.substring(0,key.indexOf("@"));
+ oldValue = key.substring(0,key.indexOf('@'));
}
if(oldValue!=prevKey){
- oldValue = key.substring(0,key.indexOf("@"));
+ oldValue = key.substring(0,key.indexOf('@'));
}
- if(oldValue.equals(key.substring(0,key.indexOf("@")))){
+ if(oldValue.equals(key.substring(0,key.indexOf('@')))){
jsonArray.put(element.get(key));
}else{
jsonResult.put(oldValue, jsonArray);
jsonArray = new JSONArray();
}
- oldValue = key.substring(0,key.indexOf("@"));
+ oldValue = key.substring(0,key.indexOf('@'));
}else{
jsonResult.put(key, element.get(key));
}
}
if(isArray){
if(oldValue==null){
- oldValue = key.substring(0,key.indexOf("@"));
+ oldValue = key.substring(0,key.indexOf('@'));
}
if(oldValue!=prevKey){
- oldValue = key.substring(0,key.indexOf("@"));
+ oldValue = key.substring(0,key.indexOf('@'));
}
- if(oldValue.equals(key.substring(0,key.indexOf("@")))){
+ if(oldValue.equals(key.substring(0,key.indexOf('@')))){
jsonArray.put(element.get(key));
}else{
jsonResult.put(oldValue, jsonArray);
jsonArray = new JSONArray();
}
- oldValue = key.substring(0,key.indexOf("@"));
+ oldValue = key.substring(0,key.indexOf('@'));
}else{
jsonResult.put(key, element.get(key));
}
jsonArray = new JSONArray();
}
if(arryKey==null){
- arryKey = nodeKey.substring(0,nodeKey.indexOf("@"));
+ arryKey = nodeKey.substring(0,nodeKey.indexOf('@'));
}
jsonArray.put(decodeContent(node));
jsonResult.put(arryKey, jsonArray);
JsonNode root = mapper.readTree(request.getReader());
String value = root.get("policyData").toString().replaceAll("^\"|\"$", "");
- String servicename = value.toString().split("-v")[0];
+ String servicename = value.split("-v")[0];
String version = null;
- if (value.toString().contains("-v")){
- version = value.toString().split("-v")[1];
+ if (value.contains("-v")){
+ version = value.split("-v")[1];
}
MicroServiceModels returnModel = getAttributeObject(servicename, version);
Map gsonObject = (Map) gson.fromJson(subAttributes, Object.class);
JSONObject object = new JSONObject();
- JSONArray array = new JSONArray();
+ JSONArray array;
for (Entry<String, String> keySet : attributeMap.entrySet()){
array = new JSONArray();
@SuppressWarnings("unchecked")
private JSONObject recursiveReference(String name, Map<String,String> subAttributeMap, String enumAttribute) {
JSONObject object = new JSONObject();
- Map<String, String> map = new HashMap<>();
+ Map<String, String> map;
Object returnClass = subAttributeMap.get(name);
map = (Map<String, String>) returnClass;
- JSONArray array = new JSONArray();
+ JSONArray array;
for( Entry<String, String> m:map.entrySet()){
String[] splitValue = m.getValue().split(":");
JsonNode root = mapper.readTree(request.getReader());
String value = root.get("policyData").toString().replaceAll("^\"|\"$", "");
- String servicename = value.toString().split("-v")[0];
+ String servicename = value.split("-v")[0];
Set<String> returnList = getVersionList(servicename);
response.setCharacterEncoding("UTF-8");
}
private Set<String> getVersionList(String name) {
- MicroServiceModels workingModel = new MicroServiceModels();
+ MicroServiceModels workingModel;
Set<String> list = new HashSet<>();
List<Object> microServiceModelsData = commonClassDao.getDataById(MicroServiceModels.class, "modelName", name);
for (int i = 0; i < microServiceModelsData.size(); i++) {
String policyScopeName = null;
ObjectMapper mapper = new ObjectMapper();
try {
- DCAEMicroServiceObject msBody = (DCAEMicroServiceObject) mapper.readValue(entity.getConfigurationData().getConfigBody(), DCAEMicroServiceObject.class);
+ DCAEMicroServiceObject msBody = mapper.readValue(entity.getConfigurationData().getConfigBody(), DCAEMicroServiceObject.class);
policyScopeName = getPolicyScope(msBody.getPolicyScope());
policyAdapter.setPolicyScope(policyScopeName);
//Convert the map values and set into JSON body
public Map<String, String> convertMap(Map<String, String> attributesMap, Map<String, String> attributesRefMap) {
Map<String, String> attribute = new HashMap<>();
- String temp = null;
+ StringBuilder temp = null;
String key;
String value;
for (Entry<String, String> entry : attributesMap.entrySet()) {
}
for (Entry<String, String> entryRef : attributesRefMap.entrySet()) {
key = entryRef.getKey();
- value = entryRef.getValue().toString();
+ value = entryRef.getValue();
attribute.put(key, value);
}
for (Entry<String, String> entryList : attributesListRefMap.entrySet()) {
key = entryList.getKey();
- value = entryList.getValue().toString();
+ value = entryList.getValue();
attribute.put(key, value);
}
for (Entry<String, LinkedList<String>> arrayList : arrayTextList.entrySet()){
temp = null;
for (Object textList : arrayList.getValue()){
if (temp == null){
- temp = "[" + textList;
+ temp = new StringBuilder();
+ temp.append("[" + textList);
}else{
- temp = temp + "," + textList;
+ temp.append("," + textList);
}
}
attribute.put(key, temp+ "]");
IOUtils.copy(item.getInputStream(), outputStream);
outputStream.close();
this.newFile = file.toString();
- this.newModel.setModelName(this.newFile.toString().split("-v")[0]);
+ this.newModel.setModelName(this.newFile.split("-v")[0]);
- if (this.newFile.toString().contains("-v")){
+ if (this.newFile.contains("-v")){
if (item.getName().endsWith(".zip")){
- this.newModel.setVersion(this.newFile.toString().split("-v")[1].replace(".zip", ""));
+ this.newModel.setVersion(this.newFile.split("-v")[1].replace(".zip", ""));
zip = true;
}else if(item.getName().endsWith(".yml")){
- this.newModel.setVersion(this.newFile.toString().split("-v")[1].replace(".yml", ""));
+ this.newModel.setVersion(this.newFile.split("-v")[1].replace(".yml", ""));
yml = true;
}
else {
- this.newModel.setVersion(this.newFile.toString().split("-v")[1].replace(".xmi", ""));
+ this.newModel.setVersion(this.newFile.split("-v")[1].replace(".xmi", ""));
}
}
}catch(Exception e){
if (zip){
extractFolder(this.newFile);
fileList = listModelFiles(this.directory);
- }else if (yml==true){
+ }else if (yml){
parseTosca(this.newFile);
}else {
File file = new File(this.newFile);
fileList.add(file);
}
String modelType= "";
- if(yml==false){
+ if(! yml){
modelType="xmi";
//Process Main Model file first
classMap = new HashMap<>();
msAttributes.setSubClass(this.retmap);
HashMap<String, String> returnReferenceList =new HashMap<>();
- //String[] referenceArray=this.referenceAttributes.split("=");
returnReferenceList.put(className, this.referenceAttributes);
msAttributes.setRefAttribute(returnReferenceList);
private void retreiveDependency(String workingFile, Boolean modelClass) {
MSModelUtils utils = new MSModelUtils(PolicyController.getMsOnapName(), PolicyController.getMsPolicyName());
- HashMap<String, MSAttributeObject> tempMap = new HashMap<>();
+ HashMap<String, MSAttributeObject> tempMap;
tempMap = utils.processEpackage(workingFile, MODEL_TYPE.XMI);