+++ /dev/null
-/*******************************************************************************\r
- * ============LICENSE_START====================================================\r
- * * org.onap.aaf\r
- * * ===========================================================================\r
- * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
- * * ===========================================================================\r
- * * Licensed under the Apache License, Version 2.0 (the "License");\r
- * * you may not use this file except in compliance with the License.\r
- * * You may obtain a copy of the License at\r
- * * \r
- * * http://www.apache.org/licenses/LICENSE-2.0\r
- * * \r
- * * Unless required by applicable law or agreed to in writing, software\r
- * * distributed under the License is distributed on an "AS IS" BASIS,\r
- * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * * See the License for the specific language governing permissions and\r
- * * limitations under the License.\r
- * * ============LICENSE_END====================================================\r
- * *\r
- * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
- * *\r
- ******************************************************************************/\r
-package com.att.dao.aaf.test;\r
-\r
-import com.att.authz.env.AuthzEnv;\r
-import com.datastax.driver.core.Cluster;\r
-import com.datastax.driver.core.ResultSet;\r
-import com.datastax.driver.core.Row;\r
-import com.datastax.driver.core.Session;\r
-\r
-public class NS_ChildUpdate {\r
-\r
- public static void main(String[] args) {\r
- if(args.length < 3 ) {\r
- System.out.println("usage: NS_ChildUpdate machine mechid (encrypted)passwd");\r
- } else {\r
- try {\r
- AuthzEnv env = new AuthzEnv();\r
- env.setLog4JNames("log.properties","authz","authz","audit","init","trace");\r
- \r
- Cluster cluster = Cluster.builder()\r
- .addContactPoint(args[0])\r
- .withCredentials(args[1],env.decrypt(args[2], false))\r
- .build();\r
- \r
- Session session = cluster.connect("authz");\r
- try {\r
- ResultSet result = session.execute("SELECT name,parent FROM ns");\r
- int count = 0;\r
- for(Row r : result.all()) {\r
- ++count;\r
- String name = r.getString(0);\r
- String parent = r.getString(1);\r
- if(parent==null) {\r
- int idx = name.lastIndexOf('.');\r
- \r
- parent = idx>0?name.substring(0, idx):".";\r
- System.out.println("UPDATE " + name + " to " + parent);\r
- session.execute("UPDATE ns SET parent='" + parent + "' WHERE name='" + name + "';");\r
- }\r
- }\r
- System.out.println("Processed " + count + " records");\r
- } finally {\r
- session.close();\r
- cluster.close();\r
- }\r
- } catch (Exception e) {\r
- e.printStackTrace();\r
- }\r
- }\r
- }\r
-\r
-}\r