2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
6 * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
7 * Modifications Copyright (C) 2019 Bell Canada
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
23 package org.onap.policy.controller;
25 import com.att.research.xacml.util.XACMLProperties;
26 import com.fasterxml.jackson.databind.ObjectMapper;
28 import java.io.ByteArrayInputStream;
30 import java.io.FileInputStream;
31 import java.io.IOException;
32 import java.io.InputStream;
33 import java.nio.charset.StandardCharsets;
34 import java.util.ArrayList;
35 import java.util.HashMap;
36 import java.util.List;
38 import java.util.Map.Entry;
39 import java.util.Properties;
42 import javax.annotation.PostConstruct;
43 import javax.script.SimpleBindings;
44 import javax.servlet.http.HttpServletRequest;
45 import javax.servlet.http.HttpServletResponse;
47 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicySetType;
48 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
50 import org.json.JSONObject;
51 import org.onap.policy.admin.PolicyNotificationMail;
52 import org.onap.policy.admin.RESTfulPAPEngine;
53 import org.onap.policy.common.logging.eelf.MessageCodes;
54 import org.onap.policy.common.logging.eelf.PolicyLogger;
55 import org.onap.policy.common.logging.flexlogger.FlexLogger;
56 import org.onap.policy.common.logging.flexlogger.Logger;
57 import org.onap.policy.model.PDPGroupContainer;
58 import org.onap.policy.model.Roles;
59 import org.onap.policy.rest.XACMLRestProperties;
60 import org.onap.policy.rest.dao.CommonClassDao;
61 import org.onap.policy.rest.jpa.Datatype;
62 import org.onap.policy.rest.jpa.FunctionDefinition;
63 import org.onap.policy.rest.jpa.PolicyEntity;
64 import org.onap.policy.rest.jpa.PolicyVersion;
65 import org.onap.policy.rest.jpa.UserInfo;
66 import org.onap.policy.utils.PeCryptoUtils;
67 import org.onap.policy.utils.UserUtils.Pair;
68 import org.onap.policy.xacml.api.XACMLErrorConstants;
69 import org.onap.policy.xacml.api.pap.PAPPolicyEngine;
70 import org.onap.policy.xacml.util.XACMLPolicyScanner;
71 import org.onap.portalsdk.core.controller.RestrictedBaseController;
72 import org.onap.portalsdk.core.domain.UserApp;
73 import org.onap.portalsdk.core.web.support.JsonMessage;
74 import org.onap.portalsdk.core.web.support.UserUtils;
75 import org.springframework.beans.factory.annotation.Autowired;
76 import org.springframework.http.MediaType;
77 import org.springframework.stereotype.Controller;
78 import org.springframework.web.bind.annotation.RequestMapping;
79 import org.springframework.web.bind.annotation.RequestMethod;
80 import org.springframework.web.servlet.ModelAndView;
84 public class PolicyController extends RestrictedBaseController {
85 private static final Logger policyLogger = FlexLogger.getLogger(PolicyController.class);
87 private static CommonClassDao commonClassDao;
91 private static PAPPolicyEngine papEngine;
93 private static String logTableLimit;
94 private static String systemAlertTableLimit;
95 protected static Map<String, String> dropDownMap = new HashMap<>();
97 public static Map<String, String> getDropDownMap() {
101 public static void setDropDownMap(Map<String, String> dropDownMap) {
102 PolicyController.dropDownMap = dropDownMap;
105 public static String getDomain() {
106 return XACMLProperties.getProperty(XACMLRestProperties.PROP_ADMIN_DOMAIN, "urn");
109 private static final Object mapAccess = new Object();
110 private static Map<Datatype, List<FunctionDefinition>> mapDatatype2Function = null;
111 private static Map<String, FunctionDefinition> mapID2Function = null;
113 // Constant variables used across Policy-sdk
114 private static final String policyData = "policyData";
115 private static final String characterEncoding = "UTF-8";
116 private static final String contentType = "application/json";
117 private static final String file = "file";
118 private static final String SUPERADMIN = "super-admin";
119 private static final String POLICYGUEST = "Policy Guest";
120 private static final String LOGINID = "loginId";
122 // Smtp Java Mail Properties
123 private static String smtpHost = null;
124 private static String smtpPort = null;
125 private static String smtpUsername = null;
126 private static String smtpPassword = null;
127 private static String smtpApplicationName = null;
128 private static String smtpEmailExtension = null;
130 private static String logdbDriver = null;
131 private static String logdbUrl = null;
132 private static String logdbUserName = null;
133 private static String logdbPassword = null;
134 private static String logdbDialect = null;
135 // Xacml db properties
136 private static String xacmldbUrl = null;
137 private static String xacmldbUserName = null;
138 private static String xacmldbPassword = null;
141 private static String autoPushAvailable;
142 private static String autoPushDSClosedLoop;
143 private static String autoPushDSFirewall;
144 private static String autoPushDSMicroservice;
145 private static String autoPushPDPGroup;
148 private static String papUrl;
150 // MicroService Model Properties
151 private static String msOnapName;
152 private static String msPolicyName;
154 // WebApp directories
155 private static String configHome;
156 private static String actionHome;
159 private static long fileSizeLimit;
161 private static boolean jUnit = false;
163 public static boolean isjUnit() {
167 public static void setjUnit(boolean jUnit) {
168 PolicyController.jUnit = jUnit;
172 private PolicyController(CommonClassDao commonClassDao) {
173 PolicyController.commonClassDao = commonClassDao;
176 public PolicyController() {
181 * init method to load the properties.
185 Properties prop = new Properties();
190 fileName = new File(".").getCanonicalPath() + File.separator + "src" + File.separator + "test"
191 + File.separator + "resources" + File.separator + "JSONConfig.json";
193 fileName = "xacml.admin.properties";
196 try (InputStream input = new FileInputStream(fileName)) {
197 // load a properties file
201 // file upload size limit property
202 setFileSizeLimit(prop.getProperty("file.size.limit"));
204 setPapUrl(prop.getProperty("xacml.rest.pap.url"));
205 // get the property values
206 setSmtpHost(prop.getProperty("onap.smtp.host"));
207 setSmtpPort(prop.getProperty("onap.smtp.port"));
208 setSmtpUsername(prop.getProperty("onap.smtp.userName"));
209 setSmtpPassword(prop.getProperty("onap.smtp.password"));
210 setSmtpApplicationName(prop.getProperty("onap.application.name"));
211 setSmtpEmailExtension(prop.getProperty("onap.smtp.emailExtension"));
212 // Log Database Properties
213 setLogdbDriver(prop.getProperty("xacml.log.db.driver"));
214 setLogdbUrl(prop.getProperty("xacml.log.db.url"));
215 setLogdbUserName(prop.getProperty("xacml.log.db.user"));
216 setLogdbPassword(PeCryptoUtils.decrypt(prop.getProperty("xacml.log.db.password")));
217 setLogdbDialect(prop.getProperty("onap.dialect"));
218 // Xacml Database Properties
219 setXacmldbUrl(prop.getProperty("javax.persistence.jdbc.url"));
220 setXacmldbUserName(prop.getProperty("javax.persistence.jdbc.user"));
221 setXacmldbPassword(PeCryptoUtils.decrypt(prop.getProperty("javax.persistence.jdbc.password")));
223 setAutoPushAvailable(prop.getProperty("xacml.automatic.push"));
224 setAutoPushDSClosedLoop(prop.getProperty("xacml.autopush.closedloop"));
225 setAutoPushDSFirewall(prop.getProperty("xacml.autopush.firewall"));
226 setAutoPushDSMicroservice(prop.getProperty("xacml.autopush.microservice"));
227 setAutoPushPDPGroup(prop.getProperty("xacml.autopush.pdpGroup"));
228 // Micro Service Properties
229 setMsOnapName(prop.getProperty("xacml.policy.msOnapName"));
230 if (getMsOnapName() == null) {
231 setMsOnapName(prop.getProperty("xacml.policy.msEcompName"));
233 policyLogger.info("getMsOnapName => " + getMsOnapName());
234 setMsPolicyName(prop.getProperty("xacml.policy.msPolicyName"));
235 policyLogger.info("setMsPolicyName => " + getMsPolicyName());
236 // WebApp directories
237 setConfigHome(prop.getProperty("xacml.rest.config.webapps") + "Config");
238 setActionHome(prop.getProperty("xacml.rest.config.webapps") + "Action");
239 // Get the Property Values for Dashboard tab Limit
241 setLogTableLimit(prop.getProperty("xacml.onap.dashboard.logTableLimit"));
242 setSystemAlertTableLimit(prop.getProperty("xacml.onap.dashboard.systemAlertTableLimit"));
243 } catch (Exception e) {
245 .error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Dashboard tab Property fields are missing" + e);
246 setLogTableLimit("5000");
247 setSystemAlertTableLimit("2000");
249 System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "xacml.admin.properties");
250 } catch (IOException ex) {
251 policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE
252 + "Exception Occured while reading the Smtp properties from xacml.admin.properties file" + ex);
255 // Initialize the FunctionDefinition table at Server Start up
256 Map<Datatype, List<FunctionDefinition>> functionMap = getFunctionDatatypeMap();
257 for (Entry<Datatype, List<FunctionDefinition>> entry : functionMap.entrySet()) {
258 List<FunctionDefinition> functionDefinations = entry.getValue();
259 for (FunctionDefinition functionDef : functionDefinations) {
260 dropDownMap.put(functionDef.getShortname(), functionDef.getXacmlid());
267 * Get FunctionData Type from DB.
269 * @return list of FunctionData.
271 public static Map<Datatype, List<FunctionDefinition>> getFunctionDatatypeMap() {
272 synchronized (mapAccess) {
273 if (mapDatatype2Function == null) {
277 return mapDatatype2Function;
283 * @return Function ID.
285 public static Map<String, FunctionDefinition> getFunctionIdMap() {
286 synchronized (mapAccess) {
287 if (mapID2Function == null) {
291 return mapID2Function;
294 private static void buildFunctionMaps() {
295 mapDatatype2Function = new HashMap<>();
296 mapID2Function = new HashMap<>();
297 List<Object> functiondefinitions = commonClassDao.getData(FunctionDefinition.class);
298 for (int i = 0; i < functiondefinitions.size(); i++) {
299 FunctionDefinition value = (FunctionDefinition) functiondefinitions.get(i);
300 mapID2Function.put(value.getXacmlid(), value);
301 if (!mapDatatype2Function.containsKey(value.getDatatypeBean())) {
302 mapDatatype2Function.put(value.getDatatypeBean(), new ArrayList<FunctionDefinition>());
304 mapDatatype2Function.get(value.getDatatypeBean()).add(value);
309 * Get Functional Definition data.
311 * @param request HttpServletRequest.
312 * @param response HttpServletResponse.
315 value = {"/get_FunctionDefinitionDataByName"},
316 method = {org.springframework.web.bind.annotation.RequestMethod.GET},
317 produces = MediaType.APPLICATION_JSON_VALUE)
318 public void getFunctionDefinitionData(HttpServletRequest request, HttpServletResponse response) {
320 Map<String, Object> model = new HashMap<>();
321 ObjectMapper mapper = new ObjectMapper();
322 model.put("functionDefinitionDatas",
323 mapper.writeValueAsString(commonClassDao.getDataByColumn(FunctionDefinition.class, "shortname")));
324 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
325 JSONObject j = new JSONObject(msg);
326 response.getWriter().write(j.toString());
327 } catch (Exception e) {
329 XACMLErrorConstants.ERROR_DATA_ISSUE + "Error while retriving the Function Definition data" + e);
334 * Get PolicyEntity Data from db.
336 * @param scope scopeName.
337 * @param policyName policyName.
338 * @return policyEntity data.
340 public PolicyEntity getPolicyEntityData(String scope, String policyName) {
341 String key = scope + ":" + policyName;
342 List<Object> data = commonClassDao.getDataById(PolicyEntity.class, "scope:policyName", key);
343 return (PolicyEntity) data.get(0);
347 * Get Policy User Roles from db.
349 * @param userId LoginID.
350 * @return list of Roles.
352 public List<String> getRolesOfUser(String userId) {
353 List<String> rolesList = new ArrayList<>();
354 List<Object> roles = commonClassDao.getDataById(Roles.class, LOGINID, userId);
355 for (Object role : roles) {
356 rolesList.add(((Roles) role).getRole());
361 public List<Object> getRoles(String userId) {
362 return commonClassDao.getDataById(Roles.class, LOGINID, userId);
366 * Get List of User Roles.
368 * @param request HttpServletRequest.
369 * @param response HttpServletResponse.
372 value = {"/get_UserRolesData"},
373 method = {org.springframework.web.bind.annotation.RequestMethod.GET},
374 produces = MediaType.APPLICATION_JSON_VALUE)
375 public void getUserRolesEntityData(HttpServletRequest request, HttpServletResponse response) {
377 String userId = UserUtils.getUserSession(request).getOrgUserId();
378 Map<String, Object> model = new HashMap<>();
379 ObjectMapper mapper = new ObjectMapper();
380 model.put("userRolesDatas", mapper.writeValueAsString(getRolesOfUser(userId)));
381 JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
382 JSONObject j = new JSONObject(msg);
383 response.getWriter().write(j.toString());
384 } catch (Exception e) {
385 policyLogger.error("Exception Occured" + e);
390 * Policy tabs Model and View.
392 * @param request Request input.
393 * @return view model.
395 @RequestMapping(value = {"/policy", "/policy/Editor"}, method = RequestMethod.GET)
396 public ModelAndView view(HttpServletRequest request) {
397 getUserRoleFromSession(request);
398 String myRequestUrl = request.getRequestURL().toString();
401 // Set the URL for the RESTful PAP Engine
403 setPapEngine(new RESTfulPAPEngine(myRequestUrl));
404 new PDPGroupContainer(new RESTfulPAPEngine(myRequestUrl));
405 } catch (Exception e) {
406 policyLogger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Exception Occured while loading PAP" + e);
408 Map<String, Object> model = new HashMap<>();
409 return new ModelAndView("policy_Editor", "model", model);
413 * Read the role from session for inserting into the database.
415 * @param request Request input for Role.
417 public void getUserRoleFromSession(HttpServletRequest request) {
418 // While user landing on Policy page, fetch the userId and Role from
420 // And, Query the Roles table and if user not exists or else modified
421 // update the Roles table.
423 List<String> newRoles = new ArrayList<>();
424 String userId = UserUtils.getUserSession(request).getOrgUserId();
425 String name = UserUtils.getUserSession(request).getFullName();
426 @SuppressWarnings("unchecked")
427 Set<UserApp> userApps = UserUtils.getUserSession(request).getUserApps();
428 for (UserApp userApp : userApps) {
429 newRoles.add(userApp.getRole().getName());
431 List<Object> userRoles = getRoles(userId);
432 List<String> filteredRoles = filterRole(newRoles);
433 if (!filteredRoles.isEmpty()) {
434 cleanUpRoles(filteredRoles, userId);
436 for (String filteredRole : filteredRoles) {
437 if (userRoles == null || userRoles.isEmpty()) {
438 savePolicyRoles(name, filteredRole, userId);
440 userRoles = getRoles(userId);
441 Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
443 if (!roles.contains(filteredRole)) {
444 savePolicyRoles(name, filteredRole, userId);
451 * Build a delete query for cleaning up roles and execute it.
453 * @param filteredRoles Filtered roles list.
454 * @param userId UserID.
456 private void cleanUpRoles(List<String> filteredRoles, String userId) {
457 StringBuilder query = new StringBuilder();
458 query.append("delete from Roles where loginid = '" + userId + "'");
459 if (filteredRoles.contains(SUPERADMIN)) {
460 query.append("and not role = '" + SUPERADMIN + "'");
462 for (String filteredRole : filteredRoles) {
463 query.append("and not role = '" + filteredRole + "'");
466 query.append("and id > 0");
467 commonClassDao.updateQuery(query.toString());
471 * Save the Role to DB.
473 * @param name User Name.
474 * @param filteredRole Role Name.
475 * @param userId User LoginID.
477 private void savePolicyRoles(String name, String filteredRole, String userId) {
478 UserInfo userInfo = new UserInfo();
479 userInfo.setUserLoginId(userId);
480 userInfo.setUserName(name);
481 commonClassDao.save(userInfo);
482 Roles role = new Roles();
484 role.setRole(filteredRole);
485 role.setLoginId(userId);
486 commonClassDao.save(role);
490 * Filter the list of roles hierarchy wise.
492 * @param newRoles list of roles from request.
495 private List<String> filterRole(List<String> newRoles) {
496 List<String> roles = new ArrayList<>();
497 boolean superCheck = false;
498 for (String role : newRoles) {
499 if ("Policy Super Guest".equalsIgnoreCase(role.trim())) {
501 roles.add("super-guest");
502 } else if ("Policy Super Editor".equalsIgnoreCase(role.trim())) {
505 roles.add("super-editor");
506 } else if ("Policy Super Admin".equalsIgnoreCase(role.trim())
507 || "System Administrator".equalsIgnoreCase(role.trim())
508 || "Standard User".equalsIgnoreCase(role.trim())) {
511 roles.add(SUPERADMIN);
513 if (!roles.contains(SUPERADMIN) || (POLICYGUEST.equalsIgnoreCase(role) && !superCheck)) {
514 if ("Policy Admin".equalsIgnoreCase(role.trim())) {
516 } else if ("Policy Editor".equalsIgnoreCase(role.trim())) {
518 } else if (POLICYGUEST.equalsIgnoreCase(role.trim())) {
526 public PAPPolicyEngine getPapEngine() {
530 public static void setPapEngine(PAPPolicyEngine papEngine) {
531 PolicyController.papEngine = papEngine;
535 * Get UserName based on LoginID.
537 * @param createdBy loginID.
540 public String getUserName(String createdBy) {
541 String loginId = createdBy;
542 List<Object> data = commonClassDao.getDataById(UserInfo.class, LOGINID, loginId);
543 return data.get(0).toString();
547 * Check if the Policy is Active or not.
549 * @param query sql query.
552 public static boolean getActivePolicy(String query) {
553 return !commonClassDao.getDataByQuery(query, new SimpleBindings()).isEmpty();
556 public void executeQuery(String query) {
557 commonClassDao.updateQuery(query);
560 public void saveData(Object cloneEntity) {
561 commonClassDao.save(cloneEntity);
564 public void updateData(Object entity) {
565 commonClassDao.update(entity);
568 public void deleteData(Object entity) {
569 commonClassDao.delete(entity);
572 public List<Object> getData(@SuppressWarnings("rawtypes") Class className) {
573 return commonClassDao.getData(className);
576 public PolicyVersion getPolicyEntityFromPolicyVersion(String query) {
577 return (PolicyVersion) commonClassDao.getEntityItem(PolicyVersion.class, "policyName", query);
580 public List<Object> getDataByQuery(String query, SimpleBindings params) {
581 return commonClassDao.getDataByQuery(query, params);
584 @SuppressWarnings("rawtypes")
585 public Object getEntityItem(Class className, String columname, String key) {
586 return commonClassDao.getEntityItem(className, columname, key);
590 * Watch Policy Function.
592 * @param entity PolicyVersion entity.
593 * @param policyName updated policy name.
594 * @param mode type of action rename/delete/import.
596 public void watchPolicyFunction(PolicyVersion entity, String policyName, String mode) {
597 PolicyNotificationMail email = new PolicyNotificationMail();
598 email.sendMail(entity, policyName, mode, commonClassDao);
602 * Switch Version Policy Content.
604 * @param pName which is used to find associated versions.
605 * @return list of available versions based on policy name.
607 public JSONObject switchVersionPolicyContent(String pName) {
608 String policyName = pName;
609 String dbCheckName = policyName.replace("/", ".");
610 if (dbCheckName.contains("Config_")) {
611 dbCheckName = dbCheckName.replace(".Config_", ":Config_");
612 } else if (dbCheckName.contains("Action_")) {
613 dbCheckName = dbCheckName.replace(".Action_", ":Action_");
614 } else if (dbCheckName.contains("Decision_MS_")) {
615 dbCheckName = dbCheckName.replace(".Decision_MS_", ":Decision_MS_");
616 } else if (dbCheckName.contains("Decision_")) {
617 dbCheckName = dbCheckName.replace(".Decision_", ":Decision_");
619 String[] splitDbCheckName = dbCheckName.split(":");
620 String query = "FROM PolicyEntity where policyName like :splitDBCheckName1 and scope = :splitDBCheckName0";
621 SimpleBindings params = new SimpleBindings();
622 params.put("splitDBCheckName1", splitDbCheckName[1] + "%");
623 params.put("splitDBCheckName0", splitDbCheckName[0]);
624 List<Object> policyEntity = commonClassDao.getDataByQuery(query, params);
625 List<String> av = new ArrayList<>();
626 for (Object entity : policyEntity) {
627 PolicyEntity pEntity = (PolicyEntity) entity;
628 String removeExtension = pEntity.getPolicyName().replace(".xml", "");
629 String version = removeExtension.substring(removeExtension.lastIndexOf('.') + 1);
630 String userName = getUserId(pEntity, "@ModifiedBy:");
631 av.add(version + " | " + pEntity.getModifiedDate() + " | " + userName);
633 if (policyName.contains("/")) {
634 policyName = policyName.replace("/", File.separator);
636 PolicyVersion entity =
637 (PolicyVersion) commonClassDao.getEntityItem(PolicyVersion.class, "policyName", policyName);
638 JSONObject el = new JSONObject();
639 el.put("activeVersion", entity.getActiveVersion());
640 el.put("availableVersions", av);
641 el.put("highestVersion", entity.getHigherVersion());
645 public String getUserId(PolicyEntity data, String value) {
647 String uValue = value;
648 String description = getDescription(data);
649 if (description.contains(uValue)) {
650 userId = description.substring(description.indexOf(uValue) + uValue.length(),
651 description.lastIndexOf(uValue));
653 UserInfo userInfo = (UserInfo) getEntityItem(UserInfo.class, "userLoginId", userId);
654 if (userInfo == null) {
657 return userInfo.getUserName();
660 public String getDescription(PolicyEntity data) {
661 InputStream stream = new ByteArrayInputStream(data.getPolicyData().getBytes(StandardCharsets.UTF_8));
662 Object policy = XACMLPolicyScanner.readPolicy(stream);
663 if (policy instanceof PolicySetType) {
664 return ((PolicySetType) policy).getDescription();
665 } else if (policy instanceof PolicyType) {
666 return ((PolicyType) policy).getDescription();
668 PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + "Expecting a PolicySet/Policy/Rule object. Got: "
669 + policy.getClass().getCanonicalName());
674 public String[] getUserInfo(PolicyEntity data, List<PolicyVersion> activePolicies) {
675 String policyName = data.getScope().replace(".", File.separator) + File.separator
676 + data.getPolicyName().substring(0, data.getPolicyName().indexOf('.'));
677 PolicyVersion polVersion =
678 activePolicies.stream().filter(a -> policyName.equals(a.getPolicyName())).findAny().orElse(null);
679 String[] result = new String[2];
680 UserInfo userCreate = null;
681 UserInfo userModify = null;
682 if (polVersion != null) {
683 userCreate = (UserInfo) getEntityItem(UserInfo.class, "userLoginId", polVersion.getCreatedBy());
684 userModify = (UserInfo) getEntityItem(UserInfo.class, "userLoginId", polVersion.getModifiedBy());
687 result[0] = userCreate != null ? userCreate.getUserName() : SUPERADMIN;
688 result[1] = userModify != null ? userModify.getUserName() : SUPERADMIN;
693 public static String getLogTableLimit() {
694 return logTableLimit;
697 public static void setLogTableLimit(String logTableLimit) {
698 PolicyController.logTableLimit = logTableLimit;
701 public static String getSystemAlertTableLimit() {
702 return systemAlertTableLimit;
705 public static void setSystemAlertTableLimit(String systemAlertTableLimit) {
706 PolicyController.systemAlertTableLimit = systemAlertTableLimit;
709 public static CommonClassDao getCommonClassDao() {
710 return commonClassDao;
713 public static void setCommonClassDao(CommonClassDao commonClassDao) {
714 PolicyController.commonClassDao = commonClassDao;
717 public static Map<Datatype, List<FunctionDefinition>> getMapDatatype2Function() {
718 return mapDatatype2Function;
721 public static void setMapDatatype2Function(Map<Datatype, List<FunctionDefinition>> mapDatatype2Function) {
722 PolicyController.mapDatatype2Function = mapDatatype2Function;
725 public static Map<String, FunctionDefinition> getMapID2Function() {
726 return mapID2Function;
729 public static void setMapID2Function(Map<String, FunctionDefinition> mapID2Function) {
730 PolicyController.mapID2Function = mapID2Function;
733 public static String getSmtpHost() {
737 public static void setSmtpHost(String smtpHost) {
738 PolicyController.smtpHost = smtpHost;
741 public static String getSmtpPort() {
745 public static void setSmtpPort(String smtpPort) {
746 PolicyController.smtpPort = smtpPort;
749 public static String getSmtpUsername() {
753 public static void setSmtpUsername(String smtpUsername) {
754 PolicyController.smtpUsername = smtpUsername;
757 public static String getSmtpPassword() {
761 public static void setSmtpPassword(String smtpPassword) {
762 PolicyController.smtpPassword = smtpPassword;
765 public static String getSmtpApplicationName() {
766 return smtpApplicationName;
769 public static void setSmtpApplicationName(String smtpApplicationName) {
770 PolicyController.smtpApplicationName = smtpApplicationName;
773 public static String getSmtpEmailExtension() {
774 return smtpEmailExtension;
777 public static void setSmtpEmailExtension(String smtpEmailExtension) {
778 PolicyController.smtpEmailExtension = smtpEmailExtension;
781 public static String getLogdbDriver() {
785 public static void setLogdbDriver(String logdbDriver) {
786 PolicyController.logdbDriver = logdbDriver;
789 public static String getLogdbUrl() {
793 public static void setLogdbUrl(String logdbUrl) {
794 PolicyController.logdbUrl = logdbUrl;
797 public static String getLogdbUserName() {
798 return logdbUserName;
801 public static void setLogdbUserName(String logdbUserName) {
802 PolicyController.logdbUserName = logdbUserName;
805 public static String getLogdbPassword() {
806 return logdbPassword;
809 public static void setLogdbPassword(String logdbPassword) {
810 PolicyController.logdbPassword = logdbPassword;
813 public static String getLogdbDialect() {
817 public static void setLogdbDialect(String logdbDialect) {
818 PolicyController.logdbDialect = logdbDialect;
821 public static String getXacmldbUrl() {
825 public static void setXacmldbUrl(String xacmldbUrl) {
826 PolicyController.xacmldbUrl = xacmldbUrl;
829 public static String getXacmldbUserName() {
830 return xacmldbUserName;
833 public static void setXacmldbUserName(String xacmldbUserName) {
834 PolicyController.xacmldbUserName = xacmldbUserName;
837 public static String getXacmldbPassword() {
838 return xacmldbPassword;
841 public static void setXacmldbPassword(String xacmldbPassword) {
842 PolicyController.xacmldbPassword = xacmldbPassword;
845 public static String getAutoPushAvailable() {
846 return autoPushAvailable;
849 public static void setAutoPushAvailable(String autoPushAvailable) {
850 PolicyController.autoPushAvailable = autoPushAvailable;
853 public static String getAutoPushDSClosedLoop() {
854 return autoPushDSClosedLoop;
857 public static void setAutoPushDSClosedLoop(String autoPushDSClosedLoop) {
858 PolicyController.autoPushDSClosedLoop = autoPushDSClosedLoop;
861 public static String getAutoPushDSFirewall() {
862 return autoPushDSFirewall;
865 public static void setAutoPushDSFirewall(String autoPushDSFirewall) {
866 PolicyController.autoPushDSFirewall = autoPushDSFirewall;
869 public static String getAutoPushDSMicroservice() {
870 return autoPushDSMicroservice;
873 public static void setAutoPushDSMicroservice(String autoPushDSMicroservice) {
874 PolicyController.autoPushDSMicroservice = autoPushDSMicroservice;
877 public static String getAutoPushPDPGroup() {
878 return autoPushPDPGroup;
881 public static void setAutoPushPDPGroup(String autoPushPDPGroup) {
882 PolicyController.autoPushPDPGroup = autoPushPDPGroup;
885 public static String getPapUrl() {
889 public static void setPapUrl(String papUrl) {
890 PolicyController.papUrl = papUrl;
893 public static String getMsOnapName() {
897 public static void setMsOnapName(String msOnapName) {
898 PolicyController.msOnapName = msOnapName;
901 public static String getMsPolicyName() {
905 public static void setMsPolicyName(String msPolicyName) {
906 PolicyController.msPolicyName = msPolicyName;
909 public static String getConfigHome() {
913 public static void setConfigHome(String configHome) {
914 PolicyController.configHome = configHome;
917 public static String getActionHome() {
921 public static void setActionHome(String actionHome) {
922 PolicyController.actionHome = actionHome;
925 public static Object getMapaccess() {
929 public static String getPolicydata() {
933 public static String getCharacterencoding() {
934 return characterEncoding;
937 public static String getContenttype() {
941 public static String getFile() {
946 * Set File Size limit.
948 * @param uploadSize value.
950 public static void setFileSizeLimit(String uploadSize) {
951 // Default size limit is 30MB
952 if (uploadSize == null || uploadSize.isEmpty()) {
953 fileSizeLimit = 30000000;
955 fileSizeLimit = Long.parseLong(uploadSize);
959 public static long getFileSizeLimit() {
960 return fileSizeLimit;
964 * Function to convert date.
966 * @param dateTTL input date value.
969 public String convertDate(String dateTTL) {
970 String formateDate = null;
971 if (dateTTL.contains("-")) {
972 formateDate = dateTTL.replace("-", "/");