2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 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====================================================
22 package com.att.dao.aaf.test;
24 import org.onap.aaf.auth.dao.CassAccess;
25 import org.onap.aaf.auth.env.AuthzEnv;
27 import com.datastax.driver.core.Cluster;
28 import com.datastax.driver.core.ResultSet;
29 import com.datastax.driver.core.Row;
30 import com.datastax.driver.core.Session;
32 public class NS_ChildUpdate {
34 public static void main(String[] args) {
35 if(args.length < 3 ) {
36 System.out.println("usage: NS_ChildUpdate machine mechid (encrypted)passwd");
39 AuthzEnv env = new AuthzEnv();
40 env.setLog4JNames("log.properties","authz","authz","audit","init","trace");
42 Cluster cluster = Cluster.builder()
43 .addContactPoint(args[0])
44 .withCredentials(args[1],env.decrypt(args[2], false))
47 Session session = cluster.connect(CassAccess.KEYSPACE);
49 ResultSet result = session.execute("SELECT name,parent FROM ns");
51 for(Row r : result.all()) {
53 String name = r.getString(0);
54 String parent = r.getString(1);
56 int idx = name.lastIndexOf('.');
58 parent = idx>0?name.substring(0, idx):".";
59 System.out.println("UPDATE " + name + " to " + parent);
60 session.execute("UPDATE ns SET parent='" + parent + "' WHERE name='" + name + "';");
63 System.out.println("Processed " + count + " records");
68 } catch (Exception e) {