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.aaf;
23 import java.util.ArrayList;
25 import org.apache.log4j.Logger;
26 import org.onap.dmaap.dbcapi.util.DmaapConfig;
29 public class AafNamespace extends AafObject {
30 static final Logger logger = Logger.getLogger(AafNamespace.class);
33 private ArrayList<String> admin;
34 private ArrayList<String> responsible;
36 // in some environments, an AAF Namespace must be owned by a human.
37 // So, when needed, this var can be set via a property
38 static private String NsOwnerIdentity;
40 public AafNamespace(String ns, String identity ) {
42 DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
43 NsOwnerIdentity = p.getProperty( "aaf.NsOwnerIdentity", "");
44 this.admin = new ArrayList<String>();
45 this.responsible = new ArrayList<String>();
48 this.admin.add( identity );
49 this.responsible.add( NsOwnerIdentity );
51 public void setName( String ns ) {
54 public String getName() {
57 public ArrayList<String> getAdmin() {
60 public void setAdmin(ArrayList<String> admin) {
63 public ArrayList<String> getResponsible() {
66 public void setResponsible(ArrayList<String> responsible) {
67 this.responsible = responsible;
71 // given an Array of Strings, return a String that is a separated list of quoted strings.
72 // e.g. input [ a, b, c ]
73 // output "a", "b", "c"
74 private String separatedList( ArrayList<String> list, String sep ) {
75 if (list.isEmpty()) return null;
76 String aList = new String();
78 for( String item: list) {
79 if( ! item.isEmpty()) {
80 aList += String.format( "%s\"%s\"", delim, item );
87 public String toJSON() {
89 String postJSON = String.format(" { \"name\": \"%s\", \"admin\": [",
92 postJSON += separatedList( this.getAdmin(), "," );
93 postJSON += "], \"responsible\":[";
94 postJSON += separatedList( this.getResponsible(), ",");
96 logger.info( "returning JSON: " + postJSON);