2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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 * ============LICENSE_END=========================================================
21 package org.onap.dmaap.dbcapi.model;
23 import java.util.Date;
25 import javax.xml.bind.annotation.XmlRootElement;
27 import org.onap.dmaap.dbcapi.database.DatabaseClass;
29 import io.swagger.annotations.ApiModelProperty;
32 public class MR_Client extends DmaapObject {
34 @ApiModelProperty( value="a tag indicating a logical deployment site")
35 private String dcaeLocationName;
36 @ApiModelProperty( value="the URL for a MR instance - typically in the same dcaeLocation - that this client should use to access the topic")
37 private String topicURL;
38 @ApiModelProperty( value="Fully Qualified Topic Name constructed by dbcapi")
40 @ApiModelProperty( value="an AAF Role to be granted an appropriate Permission. If specified, takes precedence over clientIdentity, for backwards compatibility.")
41 private String clientRole;
42 @ApiModelProperty( value="one or more actions from the set (\"pub\", \"sub\", \"view\") for which this client needs Permission")
43 private String[] action;
44 @ApiModelProperty( value="a unique identifier generated by dbcapi for this client")
45 private String mrClientId;
46 @ApiModelProperty( value="an AAF identity to be associated to an appropriate topic Role")
47 private String clientIdentity;
51 this.mrClientId = DatabaseClass.getNextClientId();
52 this.lastMod = new Date();
54 debugLogger.debug( "MR_Client constructor " + this.lastMod );
58 public MR_Client( String dLN,
62 this.dcaeLocationName = dLN;
67 if ( this.action == null ) {
68 this.action = new String[a.length];
70 for( String aa : a ) {
71 this.action[i++] = new String( aa );
73 this.setStatus( DmaapObject_Status.NEW );
74 this.mrClientId = DatabaseClass.getNextClientId();
76 debugLogger.debug( "MR_Client constructor w initialization " + this.lastMod );
79 public String getDcaeLocationName() {
80 return dcaeLocationName;
83 public void setDcaeLocationName(String dcaeLocationName) {
84 this.dcaeLocationName = dcaeLocationName;
87 public String getFqtn() {
91 public void setFqtn(String fqtn) {
95 public String getClientRole() {
99 public void setClientRole(String clientRole) {
100 this.clientRole = clientRole;
103 public String[] getAction() {
107 public void setAction(String[] action) {
108 this.action = action;
111 @ApiModelProperty( hidden=true )
112 public boolean isPublisher() {
113 return hasAction( "pub");
115 @ApiModelProperty( hidden=true )
116 public boolean isSubscriber() {
117 return hasAction( "sub");
120 public boolean hasAction( String val ) {
121 for (String s: this.action) {
122 if ( s!= null && s.equals(val)) {
128 public String getMrClientId() {
132 public void setMrClientId(String mrClientId) {
133 this.mrClientId = mrClientId;
138 public String getTopicURL() {
142 public void setTopicURL(String topicURL) {
143 this.topicURL = topicURL;
146 public String getClientIdentity() {
147 return clientIdentity;
150 public void setClientIdentity(String clientIdentity) {
151 this.clientIdentity = clientIdentity;
153 public boolean hasClientIdentity() {
154 if ( this.clientIdentity == null || this.clientIdentity.isEmpty() ) {