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