1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * ===========================================================================
\r
7 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * * you may not use this file except in compliance with the License.
\r
9 * * You may obtain a copy of the License at
\r
11 * * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * * Unless required by applicable law or agreed to in writing, software
\r
14 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * * See the License for the specific language governing permissions and
\r
17 * * limitations under the License.
\r
18 * * ============LICENSE_END====================================================
\r
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package com.att.dao.aaf.test;
\r
25 import com.att.authz.env.AuthzEnv;
\r
26 import com.datastax.driver.core.Cluster;
\r
27 import com.datastax.driver.core.ResultSet;
\r
28 import com.datastax.driver.core.Row;
\r
29 import com.datastax.driver.core.Session;
\r
31 public class NS_ChildUpdate {
\r
33 public static void main(String[] args) {
\r
34 if(args.length < 3 ) {
\r
35 System.out.println("usage: NS_ChildUpdate machine mechid (encrypted)passwd");
\r
38 AuthzEnv env = new AuthzEnv();
\r
39 env.setLog4JNames("log.properties","authz","authz","audit","init","trace");
\r
41 Cluster cluster = Cluster.builder()
\r
42 .addContactPoint(args[0])
\r
43 .withCredentials(args[1],env.decrypt(args[2], false))
\r
46 Session session = cluster.connect("authz");
\r
48 ResultSet result = session.execute("SELECT name,parent FROM ns");
\r
50 for(Row r : result.all()) {
\r
52 String name = r.getString(0);
\r
53 String parent = r.getString(1);
\r
55 int idx = name.lastIndexOf('.');
\r
57 parent = idx>0?name.substring(0, idx):".";
\r
58 System.out.println("UPDATE " + name + " to " + parent);
\r
59 session.execute("UPDATE ns SET parent='" + parent + "' WHERE name='" + name + "';");
\r
62 System.out.println("Processed " + count + " records");
\r
67 } catch (Exception e) {
\r
68 e.printStackTrace();
\r