DMAAP-MR - Merge MR repos
[dmaap/messagerouter/messageservice.git] / src / main / java / org / onap / dmaap / dmf / mr / metabroker / Topic.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 org.onap.dmaap.dmf.mr.metabroker;
23
24 import com.att.nsa.configs.ConfigDbException;
25 import com.att.nsa.security.NsaAcl;
26 import com.att.nsa.security.NsaApiKey;
27 import com.att.nsa.security.ReadWriteSecuredResource;
28
29 /**
30  * This is the interface for topic and all the topic related operations
31  * get topic name, owner, description, transactionEnabled etc.
32  * @author nilanjana.maity
33  *
34  */
35 public interface Topic extends ReadWriteSecuredResource
36 {       
37         /**
38          * User defined exception for access denied while access the topic for Publisher and consumer
39          * @author nilanjana.maity
40          *
41          *//*
42         public class AccessDeniedException extends Exception
43         
44                 *//**
45                  * AccessDenied Description
46                  *//*
47                 
48                 *//**
49                  * AccessDenied Exception for the user while authenticating the user request
50                  * @param user
51                  *//*
52                 
53                 private static final long serialVersionUID = 1L;
54         }*/
55
56         /**
57          * Get this topic's name
58          * @return
59          */
60         String getName ();
61
62         /**
63          * Get the API key of the owner of this topic.
64          * @return
65          */
66         String getOwner ();
67
68         /**
69          * Get a description of the topic, as set by the owner at creation time.
70          * @return
71          */
72         String getDescription ();
73         
74         /**
75          * If the topic is transaction enabled
76          * @return boolean true/false
77          */
78         boolean isTransactionEnabled();
79         
80         /**
81          * Get the ACL for reading on this topic. Can be null.
82          * @return
83          */
84         NsaAcl getReaderAcl ();
85
86         /**
87          * Get the ACL for writing on this topic.  Can be null.
88          * @return
89          */
90         NsaAcl getWriterAcl ();
91
92         /**
93          * Check if this user can read the topic. Throw otherwise. Note that
94          * user may be null.
95          * @param user
96          */
97         void checkUserRead ( NsaApiKey user ) throws AccessDeniedException;
98
99         /**
100          * Check if this user can write to the topic. Throw otherwise. Note
101          * that user may be null.
102          * @param user
103          */
104         void checkUserWrite ( NsaApiKey user ) throws AccessDeniedException;
105
106         /**
107          * allow the given user to publish
108          * @param publisherId
109          * @param asUser
110          */
111         void permitWritesFromUser ( String publisherId, NsaApiKey asUser ) throws AccessDeniedException, ConfigDbException;
112
113         /**
114          * deny the given user from publishing
115          * @param publisherId
116          * @param asUser
117          */
118         void denyWritesFromUser ( String publisherId, NsaApiKey asUser ) throws AccessDeniedException, ConfigDbException;
119
120         /**
121          * allow the given user to read the topic
122          * @param consumerId
123          * @param asUser
124          */
125         void permitReadsByUser ( String consumerId, NsaApiKey asUser ) throws AccessDeniedException, ConfigDbException;
126
127         /**
128          * deny the given user from reading the topic
129          * @param consumerId
130          * @param asUser
131          * @throws ConfigDbException 
132          */
133         void denyReadsByUser ( String consumerId, NsaApiKey asUser ) throws AccessDeniedException, ConfigDbException;
134 }