- public void doDictionaryAPIPut(HttpServletRequest request, HttpServletResponse response) {
- String result = null;
- String dictionaryType = request.getParameter("dictionaryType");
- String operation = request.getParameter("operation");
- try {
- DictionaryService dictionary = new DictionaryService();
- switch (dictionaryType) {
- case "OnapName":
- result = dictionary.saveOnapDictionary(request, response);
- break;
- case "Attribute":
- result = dictionary.saveAttributeDictionary(request, response);
- break;
- case "Action":
- result = dictionary.saveActionPolicyDictionary(request, response);
- break;
- case "BRMSParamTemplate":
- result = dictionary.saveBRMSParamDictionary(request, response);
- break;
- case "VSCLAction":
- result = dictionary.saveVSCLAction(request, response);
- break;
- case "VNFType":
- result = dictionary.saveVnfType(request, response);
- break;
- case "PEPOptions":
- result = dictionary.savePEPOptions(request, response);
- break;
- case "Varbind":
- result = dictionary.saveVarbind(request, response);
- break;
- case "Service":
- result = dictionary.saveServiceType(request, response);
- break;
- case "Site":
- result = dictionary.saveSiteType(request, response);
- break;
- case "Settings":
- result = dictionary.saveSettingsDictionary(request, response);
- break;
- case "RainyDayTreatments":
- result = dictionary.saveRainyDayDictionary(request, response);
- break;
- case "DescriptiveScope":
- result = dictionary.saveDescriptiveDictionary(request, response);
- break;
- case "ActionList":
- result = dictionary.saveActionListDictionary(request, response);
- break;
- case "ProtocolList":
- result = dictionary.saveProtocolListDictionary(request, response);
- break;
- case "Zone":
- result = dictionary.saveZoneDictionary(request, response);
- break;
- case "SecurityZone":
- result = dictionary.saveSecurityZoneDictionary(request, response);
- break;
- case "PrefixList":
- result = dictionary.savePrefixListDictionary(request, response);
- break;
- case "AddressGroup":
- result = dictionary.saveAddressGroupDictionary(request, response);
- break;
- case "ServiceGroup":
- result = dictionary.saveServiceGroupDictionary(request, response);
- break;
- case "ServiceList":
- result = dictionary.saveServiceListDictionary(request, response);
- break;
- case "TermList":
- case "RuleList":
- case "FirewallRuleList":
- case "Term":
- result = dictionary.saveTermListDictionary(request, response);
- break;
- case "MicroServiceLocation":
- result = dictionary.saveMicroServiceLocationDictionary(request, response);
- break;
- case "MicroServiceConfigName":
- result = dictionary.saveMicroServiceConfigNameDictionary(request, response);
- break;
- case "DCAEUUID":
- result = dictionary.saveDCAEUUIDDictionary(request, response);
- break;
- case "MicroServiceModels":
- result = dictionary.saveMicroServiceModelsDictionary(request, response);
- break;
- case "PolicyScopeService":
- result = dictionary.savePSServiceDictionary(request, response);
- break;
- case "PolicyScopeResource":
- result = dictionary.savePSResourceDictionary(request, response);
- break;
- case "PolicyScopeType":
- result = dictionary.savePSTypeDictionary(request, response);
- break;
- case "PolicyScopeClosedLoop":
- result = dictionary.savePSClosedLoopDictionary(request, response);
- break;
- case "GroupPolicyScopeList":
- result = dictionary.savePSGroupScopeDictionary(request, response);
- break;
- case "RiskType":
- result = dictionary.saveRiskTypeDictionary(request, response);
- break;
- case "SafePolicyWarning":
- result = dictionary.saveSafePolicyWarningDictionary(request, response);
- break;
- case "MicroServiceDictionary":
- result = dictionary.saveMicroServiceDictionary(request, response);
- break;
- default:
- result = extendedOptions(dictionaryType, request, response, false);
- if(result==null){
- return;
- }else{
- break;
- }
- }
- } catch (Exception e) {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + " Error Updating the Database: " + e.getMessage();
- PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPapServlet", " Error Updating the Database.");
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- response.addHeader("error", message);
- return;
- }
- if (result.equalsIgnoreCase("Success")) {
- response.setStatus(HttpServletResponse.SC_OK);
- response.addHeader("successMapKey", "success");
- if (operation.equalsIgnoreCase("update")) {
- response.addHeader("operation", "updateDictionary");
- } else {
- response.addHeader("operation", "createDictionary");
- }
- } else if (result.equalsIgnoreCase("Duplicate")) {
- response.setStatus(HttpServletResponse.SC_CONFLICT);
- response.addHeader("error", "dictionaryItemExists");
- } else if (result.equalsIgnoreCase("DuplicateGroup")) {
- response.setStatus(HttpServletResponse.SC_CONFLICT);
- response.addHeader("error", "duplicateGroup");
- } else {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + " Error Updating the Database.";
- PolicyLogger.error(message);
- response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
- response.addHeader("error", message);
- }
- }
+ /**
+ * Can be used to extend the services.
+ * <p>
+ * getflag=true indicates Get Request.
+ * getflag=false indicates Put Request.
+ *
+ * @return
+ */
+ public String extendedOptions(String dictionaryType, HttpServletRequest request, HttpServletResponse response,
+ boolean getflag) {
+ // Default code
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE + " Invalid Dictionary in Request.";
+ PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, "DictionaryHandler", " Invalid Dictionary in Request.");
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ response.setHeader("error", "dictionary");
+ response.addHeader("error", message);
+ return null;
+ }
+
+ public void doDictionaryAPIPut(HttpServletRequest request, HttpServletResponse response) {
+ String result = null;
+ String dictionaryType = request.getParameter("dictionaryType");
+ String operation = request.getParameter("operation");
+ try {
+ DictionaryService dictionary = new DictionaryService();
+ switch (dictionaryType) {
+ case "OnapName":
+ result = dictionary.saveOnapDictionary(request, response);
+ break;
+ case "Attribute":
+ result = dictionary.saveAttributeDictionary(request, response);
+ break;
+ case "Action":
+ result = dictionary.saveActionPolicyDictionary(request, response);
+ break;
+ case "BRMSParamTemplate":
+ result = dictionary.saveBRMSParamDictionary(request, response);
+ break;
+ case "VSCLAction":
+ result = dictionary.saveVSCLAction(request, response);
+ break;
+ case "VNFType":
+ result = dictionary.saveVnfType(request, response);
+ break;
+ case "PEPOptions":
+ result = dictionary.savePEPOptions(request, response);
+ break;
+ case "Varbind":
+ result = dictionary.saveVarbind(request, response);
+ break;
+ case "Service":
+ result = dictionary.saveServiceType(request, response);
+ break;
+ case "Site":
+ result = dictionary.saveSiteType(request, response);
+ break;
+ case "Settings":
+ result = dictionary.saveSettingsDictionary(request, response);
+ break;
+ case "RainyDayTreatments":
+ result = dictionary.saveRainyDayDictionary(request, response);
+ break;
+ case "DescriptiveScope":
+ result = dictionary.saveDescriptiveDictionary(request, response);
+ break;
+ case "ActionList":
+ result = dictionary.saveActionListDictionary(request, response);
+ break;
+ case "ProtocolList":
+ result = dictionary.saveProtocolListDictionary(request, response);
+ break;
+ case "Zone":
+ result = dictionary.saveZoneDictionary(request, response);
+ break;
+ case "SecurityZone":
+ result = dictionary.saveSecurityZoneDictionary(request, response);
+ break;
+ case "PrefixList":
+ result = dictionary.savePrefixListDictionary(request, response);
+ break;
+ case "AddressGroup":
+ result = dictionary.saveAddressGroupDictionary(request, response);
+ break;
+ case "ServiceGroup":
+ result = dictionary.saveServiceGroupDictionary(request, response);
+ break;
+ case "ServiceList":
+ result = dictionary.saveServiceListDictionary(request, response);
+ break;
+ case "TermList":
+ case "RuleList":
+ case "FirewallRuleList":
+ case "Term":
+ result = dictionary.saveTermListDictionary(request, response);
+ break;
+ case "MicroServiceLocation":
+ result = dictionary.saveMicroServiceLocationDictionary(request, response);
+ break;
+ case "MicroServiceConfigName":
+ result = dictionary.saveMicroServiceConfigNameDictionary(request, response);
+ break;
+ case "DCAEUUID":
+ result = dictionary.saveDCAEUUIDDictionary(request, response);
+ break;
+ case "MicroServiceModels":
+ result = dictionary.saveMicroServiceModelsDictionary(request, response);
+ break;
+ case "MicroServiceDictionary":
+ result = dictionary.saveMicroServiceDictionary(request, response);
+ break;
+ case "OptimizationModels":
+ result = dictionary.saveOptimizationModelsDictionary(request, response);
+ break;
+ case "PolicyScopeService":
+ result = dictionary.savePSServiceDictionary(request, response);
+ break;
+ case "PolicyScopeResource":
+ result = dictionary.savePSResourceDictionary(request, response);
+ break;
+ case "PolicyScopeType":
+ result = dictionary.savePSTypeDictionary(request, response);
+ break;
+ case "PolicyScopeClosedLoop":
+ result = dictionary.savePSClosedLoopDictionary(request, response);
+ break;
+ case "GroupPolicyScopeList":
+ result = dictionary.savePSGroupScopeDictionary(request, response);
+ break;
+ case "RiskType":
+ result = dictionary.saveRiskTypeDictionary(request, response);
+ break;
+ case "SafePolicyWarning":
+ result = dictionary.saveSafePolicyWarningDictionary(request, response);
+ break;
+ default:
+ result = extendedOptions(dictionaryType, request, response, false);
+ if (result == null) {
+ return;
+ } else {
+ break;
+ }
+ }
+ } catch (Exception e) {
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE + " Error Updating the Database: " + e.getMessage();
+ PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPapServlet", " Error Updating the Database.");
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ response.addHeader("error", message);
+ return;
+ }
+ if (result.equalsIgnoreCase("Success")) {
+ response.setStatus(HttpServletResponse.SC_OK);
+ response.addHeader("successMapKey", "success");
+ if (operation.equalsIgnoreCase("update")) {
+ response.addHeader("operation", "updateDictionary");
+ } else {
+ response.addHeader("operation", "createDictionary");
+ }
+ } else if (result.equalsIgnoreCase("Duplicate")) {
+ response.setStatus(HttpServletResponse.SC_CONFLICT);
+ response.addHeader("error", "dictionaryItemExists");
+ } else if (result.equalsIgnoreCase("DuplicateGroup")) {
+ response.setStatus(HttpServletResponse.SC_CONFLICT);
+ response.addHeader("error", "duplicateGroup");
+ } else {
+ String message = XACMLErrorConstants.ERROR_DATA_ISSUE + " Error Updating the Database.";
+ PolicyLogger.error(message);
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
+ response.addHeader("error", message);
+ }
+ }