Update license; improve coverage; add docs dir
[portal.git] / ecomp-portal-BE-common / src / main / java / org / openecomp / portalapp / portal / controller / SharedContextRestController.java
index a59a457..352912a 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;
 
@@ -69,12 +87,12 @@ import io.swagger.annotations.ApiOperation;
 public class SharedContextRestController extends EPRestrictedRESTfulBaseController {
 
        /**
-        * Model for a one-element JSON object returned by many methods. 
+        * Model for a one-element JSON object returned by many methods.
         */
        class SharedContextJsonResponse {
                String response;
        }
-       
+
        /**
         * Access to the database
         */
@@ -94,12 +112,16 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll
        /**
         * Gets a value for the specified context and key (RESTful service method).
         * 
-        * @param ctxtId
+        * @param request
+        *            HTTP servlet request
+        * @param context_id
         *            ID that identifies the context, usually the ECOMP Portal
         *            session key.
         * @param ckey
         *            Key for the key-value pair to fetch
         * @return JSON with shared context object; response=null if not found.
+        * @throws Exception
+        *             on bad arguments
         */
        @ApiOperation(value = "Gets a value for the specified context and key.", response = SharedContext.class)
        @RequestMapping(value = { "/get" }, method = RequestMethod.GET, produces = "application/json")
@@ -123,12 +145,15 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll
        /**
         * Gets user information for the specified context (RESTful service method).
         * 
-        * @param ctxtId
+        * @param request
+        *            HTTP servlet request
+        * @param context_id
         *            ID that identifies the context, usually the ECOMP Portal
         *            session key.
-        * 
         * @return List of shared-context objects as JSON; should have user's first
         *         name, last name and email address; null if none found
+        * @throws Exception
+        *             on bad arguments
         */
        @ApiOperation(value = "Gets user information for the specified context.", response = SharedContext.class, responseContainer = "List")
        @RequestMapping(value = { "/get_user" }, method = RequestMethod.GET, produces = "application/json")
@@ -144,7 +169,7 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll
                SharedContext lastNameContext = contextService.getSharedContext(context_id,
                                EPCommonSystemProperties.USER_LAST_NAME);
                SharedContext emailContext = contextService.getSharedContext(context_id, EPCommonSystemProperties.USER_EMAIL);
-               SharedContext attuidContext = contextService.getSharedContext(context_id,
+               SharedContext orgUserIdContext = contextService.getSharedContext(context_id,
                                EPCommonSystemProperties.USER_ORG_USERID);
                if (firstNameContext != null)
                        listSharedContext.add(firstNameContext);
@@ -152,8 +177,8 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll
                        listSharedContext.add(lastNameContext);
                if (emailContext != null)
                        listSharedContext.add(emailContext);
-               if (attuidContext != null)
-                       listSharedContext.add(attuidContext);
+               if (orgUserIdContext != null)
+                       listSharedContext.add(orgUserIdContext);
                String jsonResponse = convertResponseToJSON(listSharedContext);
                return jsonResponse;
        }
@@ -162,6 +187,8 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll
         * Tests for presence of the specified key in the specified context (RESTful
         * service method).
         * 
+        * @param request
+        *            HTTP servlet request
         * @param context_id
         *            ID that identifies the context, usually the ECOMP Portal
         *            session key.
@@ -169,6 +196,8 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll
         *            Key for the key-value pair to test
         * @return JSON with result indicating whether the context and key were
         *         found.
+        * @throws Exception
+        *             on bad arguments
         */
        @ApiOperation(value = "Tests for presence of the specified key in the specified context.", response = SharedContextJsonResponse.class)
        @RequestMapping(value = { "/check" }, method = RequestMethod.GET, produces = "application/json")
@@ -192,6 +221,8 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll
         * Removes the specified key in the specified context (RESTful service
         * method).
         * 
+        * @param request
+        *            HTTP servlet request
         * @param context_id
         *            ID that identifies the context, usually the ECOMP Portal
         *            session key.
@@ -199,6 +230,8 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll
         *            Key for the key-value pair to remove
         * @return JSON with result indicating whether the context and key were
         *         found.
+        * @throws Exception
+        *             on bad arguments
         */
        @ApiOperation(value = "Removes the specified key in the specified context.", response = SharedContextJsonResponse.class)
        @RequestMapping(value = { "/remove" }, method = RequestMethod.GET, produces = "application/json")
@@ -224,11 +257,15 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll
         * Clears all key-value pairs in the specified context (RESTful service
         * method).
         * 
+        * @param request
+        *            HTTP servlet request
         * @param context_id
         *            ID that identifies the context, usually the ECOMP Portal
         *            session key.
         * @return JSON with result indicating the number of key-value pairs
         *         removed.
+        * @throws Exception
+        *             on bad arguments
         */
        @ApiOperation(value = "Clears all key-value pairs in the specified context.", response = SharedContextJsonResponse.class)
        @RequestMapping(value = { "/clear" }, method = RequestMethod.GET, produces = "application/json")
@@ -248,6 +285,8 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll
         * method). Creates the context if no context with the specified ID-key pair
         * exists, overwrites the value if it exists already.
         * 
+        * @param request
+        *            HTTP servlet request
         * @param userJson
         *            JSON block with these tag-value pairs:
         *            <UL>
@@ -257,6 +296,8 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll
         *            </UL>
         * @return JSON with result indicating whether the value was added (key not
         *         previously known) or replaced (key previously known).
+        * @throws Exception
+        *             on bad arguments
         */
        @ApiOperation(value = "Sets a context value for the specified context and key. Creates the context if no context with the specified ID-key pair exists, overwrites the value if it exists already.", response = SharedContextJsonResponse.class)
        @RequestMapping(value = { "/set" }, method = RequestMethod.POST, produces = "application/json")
@@ -314,7 +355,7 @@ public class SharedContextRestController extends EPRestrictedRESTfulBaseControll
        /**
         * Creates a JSON object with the content of the shared context; null is ok.
         * 
-        * @param responseBody
+        * @param context
         * @return tag "response" with collection of context object's fields
         * @throws JsonProcessingException
         */