abebaba9619f5a5bac8e2116899b5e882c55516b
[dmaap/messagerouter/msgrtr.git] / src / main / java / com / att / dmf / mr / transaction / DMaaPTransactionObjDB.java
1 /*******************************************************************************
2  *  ============LICENSE_START=======================================================
3  *  org.onap.dmaap
4  *  ================================================================================
5  *  Copyright © 2017 AT&T Intellectual Property. All rights reserved.
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  *        http://www.apache.org/licenses/LICENSE-2.0
11 *  
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *  ============LICENSE_END=========================================================
18  *  
19  *  ECOMP is a trademark and service mark of AT&T Intellectual Property.
20  *  
21  *******************************************************************************/
22 package com.att.dmf.mr.transaction;
23
24 import java.util.Set;
25
26 import com.att.nsa.configs.ConfigDbException;
27 import com.att.nsa.security.NsaSecurityManagerException;
28
29
30 /**
31  * Persistent storage for Transaction Object and secrets built over an abstract config db. Instances
32  * of this DB must support concurrent access.
33  * @author nilanjana.maity
34  *
35  * @param <K> DMaaPTransactionObj
36  */
37 public interface DMaaPTransactionObjDB <K extends DMaaPTransactionObj> {
38
39
40         /**
41          * Create a new Transaction Object. If one exists, 
42          * @param id
43          * @return the new Transaction record
44          * @throws ConfigDbException 
45          */
46         K createTransactionObj (String id) throws KeyExistsException, ConfigDbException;
47
48
49         /**
50          * An exception to signal a Transaction object already exists 
51          * @author nilanjana.maity
52          *
53          */
54         public static class KeyExistsException extends NsaSecurityManagerException
55         {
56                 /**
57                  * If the key exists
58                  * @param key
59                  */
60                 public KeyExistsException ( String key ) { super ( "Transaction Object " + key + " exists" ); }
61                 private static final long serialVersionUID = 1L;
62         }
63
64         /**
65          * Save a Transaction Object record. This must be used after changing auxiliary data on the record.
66          * Note that the transaction must exist (via createTransactionObj). 
67          * @param transactionObj
68          * @throws ConfigDbException 
69          */
70         void saveTransactionObj ( K transactionObj ) throws ConfigDbException;
71         
72         /**
73          * Load an Transaction Object record based on the Transaction ID value
74          * @param transactionId
75          * @return a transaction record or null
76          * @throws ConfigDbException 
77          */
78         K loadTransactionObj ( String transactionId ) throws ConfigDbException;
79         
80         /**
81          * Load all Transaction objects.
82          * @return
83          * @throws ConfigDbException
84          */
85         Set<String> loadAllTransactionObjs () throws ConfigDbException;
86 }