X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ONAP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fservice%2FImportService.java;fp=ONAP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fpap%2Fxacml%2Frest%2Fservice%2FImportService.java;h=c804f2b2074810736cf5ed8a78b5ca054b94c271;hb=5ba143338d6fbc2b4d1e36c0efcbbabe15c65301;hp=e942e6b3b301d235f09aa59aa829098c56cfc594;hpb=e5c628fee6a6e6bb57a34d5b73e092d89ee26a5c;p=policy%2Fengine.git diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/ImportService.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/ImportService.java index e942e6b3b..c804f2b20 100644 --- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/ImportService.java +++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/service/ImportService.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP-PAP-REST * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,11 +48,23 @@ public class ImportService { private static String service = "service"; private static String extractDir = "ExtractDir"; private static String successMessage = "success"; + private static String invalidServiceName = "Invalid ServiceName"; + private static final String REGEX = "[0-9a-zA-Z._ ]*"; + public void doImportMicroServicePut(HttpServletRequest request, HttpServletResponse response) { - String importServiceCreation = request.getParameter("importService");; + String importServiceCreation = request.getParameter("importService"); String fileName = request.getParameter("fileName"); String version = request.getParameter("version"); String serviceName = request.getParameter("serviceName"); + + if(serviceName == null || serviceName.isEmpty() || !serviceName.matches(REGEX)){ + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + response.addHeader(errorMsg, "missing"); + response.addHeader(operation, importHeader); + response.addHeader(service, invalidServiceName); + return; + } + String description = request.getParameter("description"); Map successMap = new HashMap<>(); if(("BRMSPARAM").equals(importServiceCreation)){ @@ -165,4 +177,4 @@ public class ImportService { } } -} +} \ No newline at end of file