Merge "AAF integration in Policy SDK"
[policy/engine.git] / POLICY-SDK-APP / src / main / java / org / onap / policy / controller / PolicyController.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.controller;
23
24 import com.att.research.xacml.util.XACMLProperties;
25 import com.fasterxml.jackson.databind.ObjectMapper;
26 import java.io.File;
27 import java.io.FileInputStream;
28 import java.io.IOException;
29 import java.io.InputStream;
30 import java.util.ArrayList;
31 import java.util.HashMap;
32 import java.util.List;
33 import java.util.Map;
34 import java.util.Map.Entry;
35 import java.util.Properties;
36 import java.util.Set;
37 import java.util.TreeMap;
38 import javax.annotation.PostConstruct;
39 import javax.mail.MessagingException;
40 import javax.script.SimpleBindings;
41 import javax.servlet.http.HttpServletRequest;
42 import javax.servlet.http.HttpServletResponse;
43 import org.json.JSONObject;
44 import org.onap.policy.admin.PolicyNotificationMail;
45 import org.onap.policy.admin.RESTfulPAPEngine;
46 import org.onap.policy.common.logging.flexlogger.FlexLogger;
47 import org.onap.policy.common.logging.flexlogger.Logger;
48 import org.onap.policy.model.PDPGroupContainer;
49 import org.onap.policy.model.Roles;
50 import org.onap.policy.rest.XACMLRestProperties;
51 import org.onap.policy.rest.dao.CommonClassDao;
52 import org.onap.policy.rest.jpa.Datatype;
53 import org.onap.policy.rest.jpa.FunctionDefinition;
54 import org.onap.policy.rest.jpa.PolicyEntity;
55 import org.onap.policy.rest.jpa.PolicyVersion;
56 import org.onap.policy.rest.jpa.UserInfo;
57 import org.onap.policy.utils.UserUtils.Pair;
58 import org.onap.policy.xacml.api.XACMLErrorConstants;
59 import org.onap.policy.xacml.api.pap.PAPPolicyEngine;
60 import org.onap.portalsdk.core.controller.RestrictedBaseController;
61 import org.onap.portalsdk.core.domain.UserApp;
62 import org.onap.portalsdk.core.web.support.JsonMessage;
63 import org.onap.portalsdk.core.web.support.UserUtils;
64 import org.springframework.beans.factory.annotation.Autowired;
65 import org.springframework.http.MediaType;
66 import org.springframework.stereotype.Controller;
67 import org.springframework.web.bind.annotation.RequestMapping;
68 import org.springframework.web.bind.annotation.RequestMethod;
69 import org.springframework.web.servlet.ModelAndView;
70
71
72 @Controller
73 @RequestMapping("/")
74 public class PolicyController extends RestrictedBaseController {
75     private static final Logger policyLogger = FlexLogger.getLogger(PolicyController.class);
76
77     private static CommonClassDao commonClassDao;
78     //
79     // The PAP Engine
80     //
81     private static PAPPolicyEngine papEngine;
82
83     private static String logTableLimit;
84     private static String systemAlertTableLimit;
85     protected static Map<String, String> dropDownMap = new HashMap<>();
86
87     public static Map<String, String> getDropDownMap() {
88         return dropDownMap;
89     }
90
91     public static void setDropDownMap(Map<String, String> dropDownMap) {
92         PolicyController.dropDownMap = dropDownMap;
93     }
94
95     public static String getDomain() {
96         return XACMLProperties.getProperty(XACMLRestProperties.PROP_ADMIN_DOMAIN, "urn");
97     }
98
99     private static final Object mapAccess = new Object();
100     private static Map<Datatype, List<FunctionDefinition>> mapDatatype2Function = null;
101     private static Map<String, FunctionDefinition> mapID2Function = null;
102
103     // Constant variables used across Policy-sdk
104     private static final String policyData = "policyData";
105     private static final String characterEncoding = "UTF-8";
106     private static final String contentType = "application/json";
107     private static final String file = "file";
108
109     // Smtp Java Mail Properties
110     private static String smtpHost = null;
111     private static String smtpPort = null;
112     private static String smtpUsername = null;
113     private static String smtpPassword = null;
114     private static String smtpApplicationName = null;
115     private static String smtpEmailExtension = null;
116     // log db Properties
117     private static String logdbDriver = null;
118     private static String logdbUrl = null;
119     private static String logdbUserName = null;
120     private static String logdbPassword = null;
121     private static String logdbDialect = null;
122     // Xacml db properties
123     private static String xacmldbUrl = null;
124     private static String xacmldbUserName = null;
125     private static String xacmldbPassword = null;
126
127     // AutoPush feature.
128     private static String autoPushAvailable;
129     private static String autoPushDSClosedLoop;
130     private static String autoPushDSFirewall;
131     private static String autoPushDSMicroservice;
132     private static String autoPushPDPGroup;
133
134     // papURL
135     private static String papUrl;
136
137     // MicroService Model Properties
138     private static String msOnapName;
139     private static String msPolicyName;
140
141     // WebApp directories
142     private static String configHome;
143     private static String actionHome;
144
145     // File upload size
146     private static long fileSizeLimit;
147
148     private static boolean jUnit = false;
149
150
151     public static boolean isjUnit() {
152         return jUnit;
153     }
154
155     public static void setjUnit(boolean jUnit) {
156         PolicyController.jUnit = jUnit;
157     }
158
159     @Autowired
160     private PolicyController(CommonClassDao commonClassDao) {
161         PolicyController.commonClassDao = commonClassDao;
162     }
163
164     public PolicyController() {
165         // Empty constructor
166     }
167
168     /**
169      * init method to load the properties.
170      */
171     @PostConstruct
172     public void init() {
173         Properties prop = new Properties();
174
175         try {
176             String fileName;
177             if (jUnit) {
178                 fileName = new File(".").getCanonicalPath() + File.separator + "src" + File.separator + "test"
179                         + File.separator + "resources" + File.separator + "JSONConfig.json";
180             } else {
181                 fileName = "xacml.admin.properties";
182             }
183
184             try (InputStream input = new FileInputStream(fileName)) {
185                 // load a properties file
186                 prop.load(input);
187             }
188
189             // file upload size limit property
190             setFileSizeLimit(prop.getProperty("file.size.limit"));
191             // pap url
192             setPapUrl(prop.getProperty("xacml.rest.pap.url"));
193             // get the property values
194             setSmtpHost(prop.getProperty("onap.smtp.host"));
195             setSmtpPort(prop.getProperty("onap.smtp.port"));
196             setSmtpUsername(prop.getProperty("onap.smtp.userName"));
197             setSmtpPassword(prop.getProperty("onap.smtp.password"));
198             setSmtpApplicationName(prop.getProperty("onap.application.name"));
199             setSmtpEmailExtension(prop.getProperty("onap.smtp.emailExtension"));
200             // Log Database Properties
201             setLogdbDriver(prop.getProperty("xacml.log.db.driver"));
202             setLogdbUrl(prop.getProperty("xacml.log.db.url"));
203             setLogdbUserName(prop.getProperty("xacml.log.db.user"));
204             setLogdbPassword(prop.getProperty("xacml.log.db.password"));
205             setLogdbDialect(prop.getProperty("onap.dialect"));
206             // Xacml Database Properties
207             setXacmldbUrl(prop.getProperty("javax.persistence.jdbc.url"));
208             setXacmldbUserName(prop.getProperty("javax.persistence.jdbc.user"));
209             setXacmldbPassword(prop.getProperty("javax.persistence.jdbc.password"));
210             // AutoPuh
211             setAutoPushAvailable(prop.getProperty("xacml.automatic.push"));
212             setAutoPushDSClosedLoop(prop.getProperty("xacml.autopush.closedloop"));
213             setAutoPushDSFirewall(prop.getProperty("xacml.autopush.firewall"));
214             setAutoPushDSMicroservice(prop.getProperty("xacml.autopush.microservice"));
215             setAutoPushPDPGroup(prop.getProperty("xacml.autopush.pdpGroup"));
216             // Micro Service Properties
217             setMsOnapName(prop.getProperty("xacml.policy.msOnapName"));
218             if (getMsOnapName() == null) {
219                 setMsOnapName(prop.getProperty("xacml.policy.msEcompName"));
220             }
221             policyLogger.info("getMsOnapName => " + getMsOnapName());
222             setMsPolicyName(prop.getProperty("xacml.policy.msPolicyName"));
223             policyLogger.info("setMsPolicyName => " + getMsPolicyName());
224             // WebApp directories
225             setConfigHome(prop.getProperty("xacml.rest.config.webapps") + "Config");
226             setActionHome(prop.getProperty("xacml.rest.config.webapps") + "Action");
227             // Get the Property Values for Dashboard tab Limit
228             try {
229                 setLogTableLimit(prop.getProperty("xacml.onap.dashboard.logTableLimit"));
230                 setSystemAlertTableLimit(prop.getProperty("xacml.onap.dashboard.systemAlertTableLimit"));
231             } catch (Exception e) {
232                 policyLogger
233                         .error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Dashboard tab Property fields are missing" + e);
234                 setLogTableLimit("5000");
235                 setSystemAlertTableLimit("2000");
236             }
237             System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "xacml.admin.properties");
238         } catch (IOException ex) {
239             policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE
240                     + "Exception Occured while reading the Smtp properties from xacml.admin.properties file" + ex);
241         }
242
243         // Initialize the FunctionDefinition table at Server Start up
244         Map<Datatype, List<FunctionDefinition>> functionMap = getFunctionDatatypeMap();
245         for (Entry<Datatype, List<FunctionDefinition>> entry : functionMap.entrySet()) {
246             List<FunctionDefinition> functionDefinations = entry.getValue();
247             for (FunctionDefinition functionDef : functionDefinations) {
248                 dropDownMap.put(functionDef.getShortname(), functionDef.getXacmlid());
249             }
250         }
251
252     }
253
254     /**
255      * Get FunctionData Type from DB.
256      * 
257      * @return list of FunctionData.
258      */
259     public static Map<Datatype, List<FunctionDefinition>> getFunctionDatatypeMap() {
260         synchronized (mapAccess) {
261             if (mapDatatype2Function == null) {
262                 buildFunctionMaps();
263             }
264         }
265         return mapDatatype2Function;
266     }
267
268     /**
269      * Get Function ID.
270      * 
271      * @return Function ID.
272      */
273     public static Map<String, FunctionDefinition> getFunctionIdMap() {
274         synchronized (mapAccess) {
275             if (mapID2Function == null) {
276                 buildFunctionMaps();
277             }
278         }
279         return mapID2Function;
280     }
281
282     private static void buildFunctionMaps() {
283         mapDatatype2Function = new HashMap<>();
284         mapID2Function = new HashMap<>();
285         List<Object> functiondefinitions = commonClassDao.getData(FunctionDefinition.class);
286         for (int i = 0; i < functiondefinitions.size(); i++) {
287             FunctionDefinition value = (FunctionDefinition) functiondefinitions.get(i);
288             mapID2Function.put(value.getXacmlid(), value);
289             if (!mapDatatype2Function.containsKey(value.getDatatypeBean())) {
290                 mapDatatype2Function.put(value.getDatatypeBean(), new ArrayList<FunctionDefinition>());
291             }
292             mapDatatype2Function.get(value.getDatatypeBean()).add(value);
293         }
294     }
295
296     /**
297      * Get Functional Definition data.
298      * 
299      * @param request HttpServletRequest.
300      * @param response HttpServletResponse.
301      */
302     @RequestMapping(value = {"/get_FunctionDefinitionDataByName"},
303             method = {org.springframework.web.bind.annotation.RequestMethod.GET},
304             produces = MediaType.APPLICATION_JSON_VALUE)
305     public void getFunctionDefinitionData(HttpServletRequest request, HttpServletResponse response) {
306         try {
307             Map<String, Object> model = new HashMap<>();
308             ObjectMapper mapper = new ObjectMapper();
309             model.put("functionDefinitionDatas",
310                     mapper.writeValueAsString(commonClassDao.getDataByColumn(FunctionDefinition.class, "shortname")));
311             JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
312             JSONObject j = new JSONObject(msg);
313             response.getWriter().write(j.toString());
314         } catch (Exception e) {
315             policyLogger.error(
316                     XACMLErrorConstants.ERROR_DATA_ISSUE + "Error while retriving the Function Definition data" + e);
317         }
318     }
319
320     /**
321      * Get PolicyEntity Data from db.
322      * 
323      * @param scope scopeName.
324      * @param policyName policyName.
325      * @return policyEntity data.
326      */
327     public PolicyEntity getPolicyEntityData(String scope, String policyName) {
328         String key = scope + ":" + policyName;
329         List<Object> data = commonClassDao.getDataById(PolicyEntity.class, "scope:policyName", key);
330         return (PolicyEntity) data.get(0);
331     }
332
333     /**
334      * Get Policy User Roles from db.
335      * 
336      * @param userId LoginID.
337      * @return list of Roles.
338      */
339     public List<String> getRolesOfUser(String userId) {
340         List<String> rolesList = new ArrayList<>();
341         List<Object> roles = commonClassDao.getDataById(Roles.class, "loginId", userId);
342         for (Object role : roles) {
343             rolesList.add(((Roles) role).getRole());
344         }
345         return rolesList;
346     }
347
348     public List<Object> getRoles(String userId) {
349         return commonClassDao.getDataById(Roles.class, "loginId", userId);
350     }
351
352     /**
353      * Get List of User Roles.
354      * 
355      * @param request HttpServletRequest.
356      * @param response HttpServletResponse.
357      */
358     @RequestMapping(value = {"/get_UserRolesData"},
359             method = {org.springframework.web.bind.annotation.RequestMethod.GET},
360             produces = MediaType.APPLICATION_JSON_VALUE)
361     public void getUserRolesEntityData(HttpServletRequest request, HttpServletResponse response) {
362         try {
363             String userId = UserUtils.getUserSession(request).getOrgUserId();
364             Map<String, Object> model = new HashMap<>();
365             ObjectMapper mapper = new ObjectMapper();
366             model.put("userRolesDatas", mapper.writeValueAsString(getRolesOfUser(userId)));
367             JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
368             JSONObject j = new JSONObject(msg);
369             response.getWriter().write(j.toString());
370         } catch (Exception e) {
371             policyLogger.error("Exception Occured" + e);
372         }
373     }
374
375     /**
376      * Policy tabs Model and View.
377      * 
378      * @param request Request input.
379      * @return view model.
380      */
381     @RequestMapping(value = {"/policy", "/policy/Editor"}, method = RequestMethod.GET)
382     public ModelAndView view(HttpServletRequest request) {
383         getUserRoleFromSession(request);
384         String myRequestUrl = request.getRequestURL().toString();
385         try {
386             //
387             // Set the URL for the RESTful PAP Engine
388             //
389             setPapEngine((PAPPolicyEngine) new RESTfulPAPEngine(myRequestUrl));
390             new PDPGroupContainer((PAPPolicyEngine) new RESTfulPAPEngine(myRequestUrl));
391         } catch (Exception e) {
392             policyLogger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Exception Occured while loading PAP" + e);
393         }
394         Map<String, Object> model = new HashMap<>();
395         return new ModelAndView("policy_Editor", "model", model);
396     }
397
398     /**
399      * Read the role from session.
400      * 
401      * @param request Request input.
402      */
403     public void getUserRoleFromSession(HttpServletRequest request) {
404         // While user landing on Policy page, fetch the userId and Role from
405         // session.
406         // And, Query the Roles table and if user not exists or else modified
407         // update the Roles table.
408         List<String> roles;
409         List<String> newRoles = new ArrayList<>();
410         String userId = UserUtils.getUserSession(request).getOrgUserId();
411         String name = UserUtils.getUserSession(request).getFullName();
412         @SuppressWarnings("unchecked")
413         Set<UserApp> userApps = UserUtils.getUserSession(request).getUserApps();
414         for (UserApp userApp : userApps) {
415             newRoles.add(userApp.getRole().getName());
416         }
417         List<Object> userRoles = getRoles(userId);
418         String filteredRole = filterRole(newRoles);
419         if (userRoles == null || userRoles.isEmpty()) {
420             savePolicyRoles(name, filteredRole, userId);
421         } else {
422             Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
423             roles = pair.u;
424             if (!roles.contains(filteredRole)) {
425                 String query = "delete from Roles where loginid='" + userId + "'";
426                 commonClassDao.updateQuery(query);
427                 savePolicyRoles(name, filteredRole, userId);
428             }
429         }
430     }
431
432     /**
433      * Save the Role to DB.
434      * 
435      * @param name User Name.
436      * @param filteredRole Role Name.
437      * @param userId User LoginID.
438      */
439     private void savePolicyRoles(String name, String filteredRole, String userId) {
440         UserInfo userInfo = new UserInfo();
441         userInfo.setUserLoginId(userId);
442         userInfo.setUserName(name);
443         commonClassDao.save(userInfo);
444         Roles role = new Roles();
445         role.setName(name);
446         role.setRole(filteredRole);
447         role.setLoginId(userId);
448         commonClassDao.save(role);
449     }
450
451     /**
452      * Filter the list of roles hierarchy wise.
453      * 
454      * @param newRoles list of roles from request.
455      * @return
456      */
457     private String filterRole(List<String> newRoles) {
458         Map<Integer, String> roleMap = new TreeMap<>();
459         roleMap.put(6, "guest");
460         for (String role : newRoles) {
461             if ("Policy Super Admin".equalsIgnoreCase(role.trim())
462                     || "System Administrator".equalsIgnoreCase(role.trim())
463                     || "Standard User".equalsIgnoreCase(role.trim())) {
464                 roleMap.put(1, "super-admin");
465             } else if ("Policy Super Editor".equalsIgnoreCase(role.trim())) {
466                 roleMap.put(2, "super-editor");
467             } else if ("Policy Super Guest".equalsIgnoreCase(role.trim())) {
468                 roleMap.put(3, "super-guest");
469             } else if ("Policy Admin".equalsIgnoreCase(role.trim())) {
470                 roleMap.put(4, "admin");
471             } else if ("Policy Editor".equalsIgnoreCase(role.trim())) {
472                 roleMap.put(5, "editor");
473             }
474         }
475         return roleMap.entrySet().iterator().next().getValue();
476     }
477
478     public PAPPolicyEngine getPapEngine() {
479         return papEngine;
480     }
481
482     public static void setPapEngine(PAPPolicyEngine papEngine) {
483         PolicyController.papEngine = papEngine;
484     }
485
486     /**
487      * Get UserName based on LoginID.
488      * 
489      * @param createdBy loginID.
490      * @return name.
491      */
492     public String getUserName(String createdBy) {
493         String loginId = createdBy;
494         List<Object> data = commonClassDao.getDataById(UserInfo.class, "loginId", loginId);
495         return data.get(0).toString();
496     }
497
498     /**
499      * Check if the Policy is Active or not.
500      * @param query sql query.
501      * @return boolean.
502      */
503     public static boolean getActivePolicy(String query) {
504         return !commonClassDao.getDataByQuery(query, new SimpleBindings()).isEmpty();
505     }
506
507     public void executeQuery(String query) {
508         commonClassDao.updateQuery(query);
509     }
510
511     public void saveData(Object cloneEntity) {
512         commonClassDao.save(cloneEntity);
513     }
514
515     public void updateData(Object entity) {
516         commonClassDao.update(entity);
517     }
518
519     public void deleteData(Object entity) {
520         commonClassDao.delete(entity);
521     }
522
523     public List<Object> getData(@SuppressWarnings("rawtypes") Class className) {
524         return commonClassDao.getData(className);
525     }
526
527     public PolicyVersion getPolicyEntityFromPolicyVersion(String query) {
528         return (PolicyVersion) commonClassDao.getEntityItem(PolicyVersion.class, "policyName", query);
529     }
530
531     public List<Object> getDataByQuery(String query, SimpleBindings params) {
532         return commonClassDao.getDataByQuery(query, params);
533     }
534
535
536     @SuppressWarnings("rawtypes")
537     public Object getEntityItem(Class className, String columname, String key) {
538         return commonClassDao.getEntityItem(className, columname, key);
539     }
540
541
542     /**
543      * Watch Policy Function.
544      * 
545      * @param entity PolicyVersion entity.
546      * @param policyName updated policy name.
547      * @param mode type of action rename/delete/import.
548      */
549     public void watchPolicyFunction(PolicyVersion entity, String policyName, String mode) {
550         PolicyNotificationMail email = new PolicyNotificationMail();
551         try {
552             email.sendMail(entity, policyName, mode, commonClassDao);
553         } catch (MessagingException e) {
554             policyLogger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR
555                     + "Excepton Occured while Renaming/Deleting a Policy or Scope" + e);
556         }
557     }
558
559     /**
560      * Switch Version Policy Content.
561      * 
562      * @param pName which is used to find associated versions.
563      * @return list of available versions based on policy name.
564      */
565     public JSONObject switchVersionPolicyContent(String pName) {
566         String policyName = pName;
567         String dbCheckName = policyName.replace("/", ".");
568         if (dbCheckName.contains("Config_")) {
569             dbCheckName = dbCheckName.replace(".Config_", ":Config_");
570         } else if (dbCheckName.contains("Action_")) {
571             dbCheckName = dbCheckName.replace(".Action_", ":Action_");
572         } else if (dbCheckName.contains("Decision_")) {
573             dbCheckName = dbCheckName.replace(".Decision_", ":Decision_");
574         }
575         String[] splitDbCheckName = dbCheckName.split(":");
576         String query = "FROM PolicyEntity where policyName like :splitDBCheckName1 and scope = :splitDBCheckName0";
577         SimpleBindings params = new SimpleBindings();
578         params.put("splitDBCheckName1", splitDbCheckName[1] + "%");
579         params.put("splitDBCheckName0", splitDbCheckName[0]);
580         List<Object> policyEntity = commonClassDao.getDataByQuery(query, params);
581         List<String> av = new ArrayList<>();
582         for (Object entity : policyEntity) {
583             PolicyEntity pEntity = (PolicyEntity) entity;
584             String removeExtension = pEntity.getPolicyName().replace(".xml", "");
585             String version = removeExtension.substring(removeExtension.lastIndexOf('.') + 1);
586             av.add(version);
587         }
588         if (policyName.contains("/")) {
589             policyName = policyName.replace("/", File.separator);
590         }
591         PolicyVersion entity =
592                 (PolicyVersion) commonClassDao.getEntityItem(PolicyVersion.class, "policyName", policyName);
593         JSONObject el = new JSONObject();
594         el.put("activeVersion", entity.getActiveVersion());
595         el.put("availableVersions", av);
596         el.put("highestVersion", entity.getHigherVersion());
597         return el;
598     }
599
600     public static String getLogTableLimit() {
601         return logTableLimit;
602     }
603
604     public static void setLogTableLimit(String logTableLimit) {
605         PolicyController.logTableLimit = logTableLimit;
606     }
607
608     public static String getSystemAlertTableLimit() {
609         return systemAlertTableLimit;
610     }
611
612     public static void setSystemAlertTableLimit(String systemAlertTableLimit) {
613         PolicyController.systemAlertTableLimit = systemAlertTableLimit;
614     }
615
616     public static CommonClassDao getCommonClassDao() {
617         return commonClassDao;
618     }
619
620     public static void setCommonClassDao(CommonClassDao commonClassDao) {
621         PolicyController.commonClassDao = commonClassDao;
622     }
623
624     public static Map<Datatype, List<FunctionDefinition>> getMapDatatype2Function() {
625         return mapDatatype2Function;
626     }
627
628     public static void setMapDatatype2Function(Map<Datatype, List<FunctionDefinition>> mapDatatype2Function) {
629         PolicyController.mapDatatype2Function = mapDatatype2Function;
630     }
631
632     public static Map<String, FunctionDefinition> getMapID2Function() {
633         return mapID2Function;
634     }
635
636     public static void setMapID2Function(Map<String, FunctionDefinition> mapID2Function) {
637         PolicyController.mapID2Function = mapID2Function;
638     }
639
640     public static String getSmtpHost() {
641         return smtpHost;
642     }
643
644     public static void setSmtpHost(String smtpHost) {
645         PolicyController.smtpHost = smtpHost;
646     }
647
648     public static String getSmtpPort() {
649         return smtpPort;
650     }
651
652     public static void setSmtpPort(String smtpPort) {
653         PolicyController.smtpPort = smtpPort;
654     }
655
656     public static String getSmtpUsername() {
657         return smtpUsername;
658     }
659
660     public static void setSmtpUsername(String smtpUsername) {
661         PolicyController.smtpUsername = smtpUsername;
662     }
663
664     public static String getSmtpPassword() {
665         return smtpPassword;
666     }
667
668     public static void setSmtpPassword(String smtpPassword) {
669         PolicyController.smtpPassword = smtpPassword;
670     }
671
672     public static String getSmtpApplicationName() {
673         return smtpApplicationName;
674     }
675
676     public static void setSmtpApplicationName(String smtpApplicationName) {
677         PolicyController.smtpApplicationName = smtpApplicationName;
678     }
679
680     public static String getSmtpEmailExtension() {
681         return smtpEmailExtension;
682     }
683
684     public static void setSmtpEmailExtension(String smtpEmailExtension) {
685         PolicyController.smtpEmailExtension = smtpEmailExtension;
686     }
687
688     public static String getLogdbDriver() {
689         return logdbDriver;
690     }
691
692     public static void setLogdbDriver(String logdbDriver) {
693         PolicyController.logdbDriver = logdbDriver;
694     }
695
696     public static String getLogdbUrl() {
697         return logdbUrl;
698     }
699
700     public static void setLogdbUrl(String logdbUrl) {
701         PolicyController.logdbUrl = logdbUrl;
702     }
703
704     public static String getLogdbUserName() {
705         return logdbUserName;
706     }
707
708     public static void setLogdbUserName(String logdbUserName) {
709         PolicyController.logdbUserName = logdbUserName;
710     }
711
712     public static String getLogdbPassword() {
713         return logdbPassword;
714     }
715
716     public static void setLogdbPassword(String logdbPassword) {
717         PolicyController.logdbPassword = logdbPassword;
718     }
719
720     public static String getLogdbDialect() {
721         return logdbDialect;
722     }
723
724     public static void setLogdbDialect(String logdbDialect) {
725         PolicyController.logdbDialect = logdbDialect;
726     }
727
728     public static String getXacmldbUrl() {
729         return xacmldbUrl;
730     }
731
732     public static void setXacmldbUrl(String xacmldbUrl) {
733         PolicyController.xacmldbUrl = xacmldbUrl;
734     }
735
736     public static String getXacmldbUserName() {
737         return xacmldbUserName;
738     }
739
740     public static void setXacmldbUserName(String xacmldbUserName) {
741         PolicyController.xacmldbUserName = xacmldbUserName;
742     }
743
744     public static String getXacmldbPassword() {
745         return xacmldbPassword;
746     }
747
748     public static void setXacmldbPassword(String xacmldbPassword) {
749         PolicyController.xacmldbPassword = xacmldbPassword;
750     }
751
752     public static String getAutoPushAvailable() {
753         return autoPushAvailable;
754     }
755
756     public static void setAutoPushAvailable(String autoPushAvailable) {
757         PolicyController.autoPushAvailable = autoPushAvailable;
758     }
759
760     public static String getAutoPushDSClosedLoop() {
761         return autoPushDSClosedLoop;
762     }
763
764     public static void setAutoPushDSClosedLoop(String autoPushDSClosedLoop) {
765         PolicyController.autoPushDSClosedLoop = autoPushDSClosedLoop;
766     }
767
768     public static String getAutoPushDSFirewall() {
769         return autoPushDSFirewall;
770     }
771
772     public static void setAutoPushDSFirewall(String autoPushDSFirewall) {
773         PolicyController.autoPushDSFirewall = autoPushDSFirewall;
774     }
775
776     public static String getAutoPushDSMicroservice() {
777         return autoPushDSMicroservice;
778     }
779
780     public static void setAutoPushDSMicroservice(String autoPushDSMicroservice) {
781         PolicyController.autoPushDSMicroservice = autoPushDSMicroservice;
782     }
783
784     public static String getAutoPushPDPGroup() {
785         return autoPushPDPGroup;
786     }
787
788     public static void setAutoPushPDPGroup(String autoPushPDPGroup) {
789         PolicyController.autoPushPDPGroup = autoPushPDPGroup;
790     }
791
792     public static String getPapUrl() {
793         return papUrl;
794     }
795
796     public static void setPapUrl(String papUrl) {
797         PolicyController.papUrl = papUrl;
798     }
799
800     public static String getMsOnapName() {
801         return msOnapName;
802     }
803
804     public static void setMsOnapName(String msOnapName) {
805         PolicyController.msOnapName = msOnapName;
806     }
807
808     public static String getMsPolicyName() {
809         return msPolicyName;
810     }
811
812     public static void setMsPolicyName(String msPolicyName) {
813         PolicyController.msPolicyName = msPolicyName;
814     }
815
816     public static String getConfigHome() {
817         return configHome;
818     }
819
820     public static void setConfigHome(String configHome) {
821         PolicyController.configHome = configHome;
822     }
823
824     public static String getActionHome() {
825         return actionHome;
826     }
827
828     public static void setActionHome(String actionHome) {
829         PolicyController.actionHome = actionHome;
830     }
831
832     public static Object getMapaccess() {
833         return mapAccess;
834     }
835
836     public static String getPolicydata() {
837         return policyData;
838     }
839
840     public static String getCharacterencoding() {
841         return characterEncoding;
842     }
843
844     public static String getContenttype() {
845         return contentType;
846     }
847
848     public static String getFile() {
849         return file;
850     }
851
852     /**
853      * Set File Size limit.
854      * 
855      * @param uploadSize value.
856      */
857     public static void setFileSizeLimit(String uploadSize) {
858         // Default size limit is 30MB
859         if (uploadSize == null || uploadSize.isEmpty()) {
860             fileSizeLimit = 30000000;
861         } else {
862             fileSizeLimit = Long.parseLong(uploadSize);
863         }
864     }
865
866     public static long getFileSizeLimit() {
867         return fileSizeLimit;
868     }
869
870     /**
871      * Function to convert date.
872      * 
873      * @param dateTTL input date value.
874      * @return
875      */
876     public String convertDate(String dateTTL) {
877         String formateDate = null;
878         if (dateTTL.contains("-")) {
879             formateDate = dateTTL.replace("-", "/");
880         }
881         return formateDate;
882     }
883 }