From 073cc188efe9abb4c010cf674e34e2cf46ef1c52 Mon Sep 17 00:00:00 2001 From: Guo Ruijing Date: Mon, 31 Jul 2017 08:47:35 +0000 Subject: [POLICY-73] replace openecomp for policy-engine Change-Id: I54072f6bcd388c0e05562614ee89b4ae7ad67004 Signed-off-by: Guo Ruijing Signed-off-by: Pamela Dragosh --- .../controller/DictionaryImportController.java | 539 --------------------- 1 file changed, 539 deletions(-) delete mode 100644 ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/DictionaryImportController.java (limited to 'ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/DictionaryImportController.java') diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/DictionaryImportController.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/DictionaryImportController.java deleted file mode 100644 index 94f83674b..000000000 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/controller/DictionaryImportController.java +++ /dev/null @@ -1,539 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ECOMP-PAP-REST - * ================================================================================ - * Copyright (C) 2017 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.openecomp.policy.pap.xacml.rest.controller; - /* - * - * - * */ -import java.io.File; -import java.io.FileOutputStream; -import java.io.FileReader; -import java.io.OutputStream; -import java.util.List; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.apache.commons.compress.utils.IOUtils; -import org.openecomp.policy.rest.dao.CommonClassDao; -import org.openecomp.policy.rest.jpa.ActionList; -import org.openecomp.policy.rest.jpa.ActionPolicyDict; -import org.openecomp.policy.rest.jpa.AddressGroup; -import org.openecomp.policy.rest.jpa.Attribute; -import org.openecomp.policy.rest.jpa.BRMSParamTemplate; -import org.openecomp.policy.rest.jpa.Category; -import org.openecomp.policy.rest.jpa.Datatype; -import org.openecomp.policy.rest.jpa.DecisionSettings; -import org.openecomp.policy.rest.jpa.DescriptiveScope; -import org.openecomp.policy.rest.jpa.EcompName; -import org.openecomp.policy.rest.jpa.GroupServiceList; -import org.openecomp.policy.rest.jpa.PEPOptions; -import org.openecomp.policy.rest.jpa.PrefixList; -import org.openecomp.policy.rest.jpa.ProtocolList; -import org.openecomp.policy.rest.jpa.SecurityZone; -import org.openecomp.policy.rest.jpa.ServiceList; -import org.openecomp.policy.rest.jpa.TermList; -import org.openecomp.policy.rest.jpa.UserInfo; -import org.openecomp.policy.rest.jpa.VNFType; -import org.openecomp.policy.rest.jpa.VSCLAction; -import org.openecomp.policy.rest.jpa.VarbindDictionary; -import org.openecomp.policy.rest.jpa.Zone; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.ObjectMapper; - -import au.com.bytecode.opencsv.CSVReader; - - -@Controller -public class DictionaryImportController { - private String newFile; - - private static CommonClassDao commonClassDao; - - @Autowired - public DictionaryImportController(CommonClassDao commonClassDao){ - DictionaryImportController.commonClassDao = commonClassDao; - } - - public DictionaryImportController(){} - - - @RequestMapping(value={"/dictionary/import_dictionary"}, method={org.springframework.web.bind.annotation.RequestMethod.POST}) - public void ImportDictionaryData(HttpServletRequest request, HttpServletResponse response) throws Exception{ - ObjectMapper mapper = new ObjectMapper(); - mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - //JsonNode root = mapper.readTree(request.getReader()); - String userId = request.getParameter("userId"); - String dictionaryName = request.getParameter("dictionaryName"); - - File file = new File(dictionaryName); - OutputStream outputStream = new FileOutputStream(file); - IOUtils.copy(request.getInputStream(), outputStream); - outputStream.close(); - this.newFile = file.toString(); - CSVReader csvReader = new CSVReader(new FileReader(this.newFile)); - List dictSheet = csvReader.readAll(); - if(dictionaryName.startsWith("Attribute")){ - for(int i = 1; i< dictSheet.size(); i++){ - Attribute attribute = new Attribute(""); - UserInfo userinfo = new UserInfo(); - userinfo.setUserLoginId(userId); - attribute.setUserCreatedBy(userinfo); - attribute.setUserModifiedBy(userinfo); - String[] rows = dictSheet.get(i); - for (int j=0 ; j