72f3bcb5519ecdf1201b5981c9f355a97a3287cf
[portal.git] / ecomp-portal-BE-common / src / main / java / org / openecomp / portalapp / portal / service / SharedContextService.java
1 /*-
2  * ================================================================================
3  * ECOMP Portal
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ================================================================================
19  */
20 package org.openecomp.portalapp.portal.service;
21
22 import java.util.List;
23
24 import org.openecomp.portalapp.portal.domain.SharedContext;
25
26 /**
27  * Defines the methods exposed by the service that manages shared context
28  * objects in the database.
29  */
30 public interface SharedContextService {
31
32         /**
33          * Gets all shared context objects for the specified context ID.
34          * 
35          * @param contextId
36          *            SharedContext ID
37          * @return List of SharedContext objects
38          */
39         List<SharedContext> getSharedContexts(String contextId);
40
41         /**
42          * Gets the shared context with the specified context ID and key.
43          * 
44          * @param contextId
45          *            Context ID; usually a session ID
46          * @param key
47          *            Key for the key-value pair
48          * @return Value found in the database, null if any parameter is null or no
49          *         shared context exists with that context ID - key pair.
50          */
51         SharedContext getSharedContext(String contextId, String key);
52
53         /**
54          * Creates a new shared context entry with the specified context ID, key and
55          * value.
56          * 
57          * @param contextId
58          *            SharedContext ID
59          * @param key
60          *            Key for the key-value pair.
61          * @param value
62          *            Value for the key-value pair.
63          */
64         void addSharedContext(String contextId, String key, String value);
65
66         /**
67          * Saves the specified shared context.
68          * 
69          * @param context
70          *            SharedContext object to save.
71          */
72         void saveSharedContext(SharedContext context);
73
74         /**
75          * Deletes the specified shared context.
76          * 
77          * @param context
78          *            SharedContext object to delete.
79          */
80         void deleteSharedContext(SharedContext context);
81
82         /**
83          * Deletes all shared contexts with the specified context ID.
84          * 
85          * @param contextId
86          *            Context ID; usually a session ID
87          * @return number of shared-context objects deleted
88          */
89         int deleteSharedContexts(String contextId);
90
91         /**
92          * Deletes all shared contexts with a creation time that is older than the
93          * specified value.
94          * 
95          * @param ageInSeconds
96          *            Expiration threshold in seconds
97          */
98         void expireSharedContexts(int ageInSeconds);
99
100 }