Null check for ClientResponse in PolicyUril.java
[portal.git] / ecomp-portal-BE-common / src / main / java / org / openecomp / portalapp / portal / controller / AppsController.java
index 7a05d67..e9a1a95 100644 (file)
@@ -1,21 +1,39 @@
 /*-
- * ================================================================================
- * ECOMP Portal
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
+ * ============LICENSE_START==========================================
+ * ONAP Portal
+ * ===================================================================
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
+ * ===================================================================
+ *
+ * Unless otherwise specified, all software contained herein is licensed
+ * under the Apache License, Version 2.0 (the “License”);
+ * you may not use this software except in compliance with the License.
  * You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
+ *             http://www.apache.org/licenses/LICENSE-2.0
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- * ================================================================================
+ *
+ * Unless otherwise specified, all documentation contained herein is licensed
+ * under the Creative Commons License, Attribution 4.0 Intl. (the “License”);
+ * you may not use this documentation except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *             https://creativecommons.org/licenses/by/4.0/
+ *
+ * Unless required by applicable law or agreed to in writing, documentation
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ============LICENSE_END============================================
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
  */
 package org.openecomp.portalapp.portal.controller;
 
@@ -65,7 +83,7 @@ import org.springframework.web.bind.annotation.RestController;
 @EnableAspectJAutoProxy
 @EPAuditLog
 public class AppsController extends EPRestrictedBaseController {
-       EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppsController.class);
+       private EELFLoggerDelegate logger = EELFLoggerDelegate.getLogger(AppsController.class);
 
        @Autowired
        private AdminRolesService adminRolesService;
@@ -80,7 +98,11 @@ public class AppsController extends EPRestrictedBaseController {
         * RESTful service method to fetch all Applications available to current
         * user
         * 
-        * @return
+        * @param request
+        *            HttpServletRequest
+        * @param response
+        *            HttpServletResponse
+        * @return List<EcompApp>
         */
        @RequestMapping(value = { "/portalApi/userApps" }, method = RequestMethod.GET, produces = "application/json")
        public List<EcompApp> getUserApps(HttpServletRequest request, HttpServletResponse response) {
@@ -105,7 +127,13 @@ public class AppsController extends EPRestrictedBaseController {
         * RESTful service method to fetch all applications accessible to the
         * current user, with personalizations.
         * 
-        * @return
+        * @param request
+        *            HttpServletRequest
+        * @param response
+        *            HttpServletResponse
+        * @return List<EcompApp>
+        * @throws IOException
+        *             if sendError fails
         */
        @RequestMapping(value = { "/portalApi/persUserApps" }, method = RequestMethod.GET, produces = "application/json")
        public List<EcompApp> getPersUserApps(HttpServletRequest request, HttpServletResponse response) throws IOException {
@@ -134,7 +162,11 @@ public class AppsController extends EPRestrictedBaseController {
         * RESTful service method to fetch applications for which the current user
         * is an Administrator
         * 
-        * @return
+        * @param request
+        *            HttpServletRequest
+        * @param response
+        *            HttpServletResponse
+        * @return List<AppIdAndNameTransportModel>
         */
        @RequestMapping(value = { "/portalApi/adminApps" }, method = RequestMethod.GET, produces = "application/json")
        public List<AppIdAndNameTransportModel> getAdminApps(HttpServletRequest request, HttpServletResponse response) {
@@ -159,7 +191,11 @@ public class AppsController extends EPRestrictedBaseController {
         * RESTful service method to fetch Applications for user who is super admin
         * and/or app admin.
         * 
-        * @return
+        * @param request
+        *            HttpServletRequest
+        * @param response
+        *            HttpServletResponse
+        * @return List<AppIdAndNameTransportModel>
         */
        @RequestMapping(value = {
                        "/portalApi/appsForSuperAdminAndAccountAdmin" }, method = RequestMethod.GET, produces = "application/json")
@@ -186,6 +222,10 @@ public class AppsController extends EPRestrictedBaseController {
        /**
         * RESTful service method to fetch left menu items from the user's session.
         * 
+        * @param request
+        *            HttpServletRequest
+        * @param response
+        *            HttpServletResponse
         * @return JSON with left menu
         */
        @SuppressWarnings({ "rawtypes", "unchecked" })
@@ -254,18 +294,21 @@ public class AppsController extends EPRestrictedBaseController {
                return ecompApps;
        }
 
-       /*
-        * This method sends the user apps manual sort preference Data to service
-        * 
-        * @request: HTTP servlet request
+       /**
+        * Sets the user apps manual sort preference
         * 
-        * @response: HTTP servlet response
+        * @param request
+        *            HTTP servlet request
+        * @param response
+        *            HTTP servlet response
+        * @param epAppsManualPref
+        *            sort pref
+        * @return FieldsValidator
         */
        @RequestMapping(value = {
                        "/portalApi/saveUserAppsSortingManual" }, method = RequestMethod.PUT, produces = "application/json")
        public FieldsValidator putUserAppsSortingManual(HttpServletRequest request,
-                       @RequestBody List<EPAppsManualPreference> epAppsManualPref, HttpServletResponse response)
-                       throws IOException {
+                       @RequestBody List<EPAppsManualPreference> epAppsManualPref, HttpServletResponse response) {
                FieldsValidator fieldsValidator = null;
                try {
                        EPUser user = EPUserUtils.getUserSession(request);
@@ -316,13 +359,16 @@ public class AppsController extends EPRestrictedBaseController {
                return fieldsValidator;
        }
 
-       /*
-        * This method is being called to delete the user app manual sort preference
-        * record
-        * 
-        * @request: HTTP servlet request
+       /**
+        * Deletes the user app manual sort preference record
         * 
-        * @response: HTTP servlet response
+        * @param request
+        *            HTTP servlet request
+        * @param response
+        *            HTTP servlet response
+        * @param delManualAppData
+        *            data to delete
+        * @return FieldsValidator
         */
        @RequestMapping(value = {
                        "/portalApi/UpdateUserAppsSortManual" }, method = RequestMethod.PUT, produces = "application/json")
@@ -389,7 +435,11 @@ public class AppsController extends EPRestrictedBaseController {
         * Administrator user. Attention: Users which have Super Administrator roles
         * only are not included!
         * 
-        * @return
+        * @param request
+        *            HTTP servlet request
+        * @param response
+        *            HTTP servlet response
+        * @return List<AdminUserApplications>
         */
        @RequestMapping(value = { "/portalApi/accountAdmins" }, method = RequestMethod.GET, produces = "application/json")
        public List<AdminUserApplications> getAppsAdministrators(HttpServletRequest request, HttpServletResponse response) {
@@ -432,10 +482,11 @@ public class AppsController extends EPRestrictedBaseController {
         * regardless of enabled status.
         * 
         * @param request
+        *            HTTP servlet request
         * @param response
+        *            HTTP servlet response
         * @return List of applications
         */
-       // This API returns
        @RequestMapping(value = {
                        "/portalApi/allAvailableApps" }, method = RequestMethod.GET, produces = "application/json")
        public List<AppsResponse> getAllApps(HttpServletRequest request, HttpServletResponse response) {
@@ -458,8 +509,10 @@ public class AppsController extends EPRestrictedBaseController {
        /**
         * 
         * @param request
+        *            HTTP servlet request
         * @param response
-        * @return
+        *            HTTP servlet response
+        * @return List of applications
         */
        @RequestMapping(value = { "/portalApi/appsFullList" }, method = RequestMethod.GET, produces = "application/json")
        public List<EcompApp> getAppsFullList(HttpServletRequest request, HttpServletResponse response) {
@@ -477,8 +530,10 @@ public class AppsController extends EPRestrictedBaseController {
        /**
         * 
         * @param request
+        *            HTTP servlet request
         * @param response
-        * @return
+        *            HTTP servlet response
+        * @return UserRoles
         */
        @RequestMapping(value = { "/portalApi/userProfile" }, method = RequestMethod.GET, produces = "application/json")
        public UserRoles getUserProfile(HttpServletRequest request, HttpServletResponse response) {
@@ -502,8 +557,10 @@ public class AppsController extends EPRestrictedBaseController {
        /**
         * 
         * @param request
+        *            HTTP servlet request
         * @param appId
-        * @return
+        *            application ID
+        * @return List<LocalRole>
         */
        @RequestMapping(value = { "/portalApi/appRoles/{appId}" }, method = {
                        RequestMethod.GET }, produces = "application/json")
@@ -522,8 +579,10 @@ public class AppsController extends EPRestrictedBaseController {
        /**
         * 
         * @param request
+        *            HTTP servlet request
         * @param response
-        * @return
+        *            HTTP servlet response
+        * @return List<OnboardingApp>
         */
        @RequestMapping(value = { "/portalApi/onboardingApps" }, method = RequestMethod.GET, produces = "application/json")
        public List<OnboardingApp> getOnboardingApps(HttpServletRequest request, HttpServletResponse response) {
@@ -547,9 +606,12 @@ public class AppsController extends EPRestrictedBaseController {
        /**
         * 
         * @param request
-        * @param modifiedOnboardingApp
+        *            HTTP servlet request
         * @param response
-        * @return
+        *            HTTP servlet response
+        * @param modifiedOnboardingApp
+        *            app to update
+        * @return FieldsValidator
         */
        @RequestMapping(value = { "/portalApi/onboardingApps" }, method = RequestMethod.PUT, produces = "application/json")
        public FieldsValidator putOnboardingApp(HttpServletRequest request,
@@ -576,9 +638,12 @@ public class AppsController extends EPRestrictedBaseController {
        /**
         * 
         * @param request
-        * @param newOnboardingApp
+        *            HTTP servlet request
         * @param response
-        * @return
+        *            HTTP servlet response
+        * @param newOnboardingApp
+        *            app to add
+        * @return FieldsValidator
         */
        @RequestMapping(value = { "/portalApi/onboardingApps" }, method = RequestMethod.POST, produces = "application/json")
        public FieldsValidator postOnboardingApp(HttpServletRequest request, @RequestBody OnboardingApp newOnboardingApp,
@@ -606,9 +671,12 @@ public class AppsController extends EPRestrictedBaseController {
         * REST endpoint to process a request to delete an on-boarded application.
         * 
         * @param request
-        * @param appId
+        *            HTTP servlet request
         * @param response
-        * @return
+        *            HTTP servlet response
+        * @param appId
+        *            ID of app to delete
+        * @return FieldsValidator
         */
        @RequestMapping(value = { "/portalApi/onboardingApps/{appId}" }, method = {
                        RequestMethod.DELETE }, produces = "application/json")
@@ -637,7 +705,9 @@ public class AppsController extends EPRestrictedBaseController {
         * Gets the application thumbnail image; sets status 404 if none exists.
         * 
         * @param request
-        *            HttpServletRequest
+        *            HTTP servlet request
+        * @param response
+        *            HTTP servlet response
         * @param appId
         *            Application ID
         * @return Bytes with the app thumbnail image; null if not available.