Bump to odlparent 3.1.6
[alto.git] / utils / migrate_namespace.sh
1 ##############################################################################
2 # Copyright (c) 2016 SNLab. All rights reserved.
3 #
4 # This program and the accompanying materials are made available under the
5 # terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 # and is available at http://www.eclipse.org/legal/epl-v10.html
7 ##############################################################################
8 #!/bin/bash
9
10 fix_namespace() {
11         FILE=$1
12         CATEGORY=$2
13
14         sed -i "s/urn:opendaylight:alto:$CATEGORY/urn:alto/g" $FILE
15 }
16
17 fix_package() {
18         FILE=$1
19         CATEGORY=$2
20
21         sed -i "s/urn.opendaylight.alto.$CATEGORY/urn.alto/g" $FILE
22 }
23
24 fix_folder() {
25         CATEGORY=$1
26
27         for d in $(find . -wholename "*/urn/opendaylight/alto/$CATEGORY"); do
28                 target=$(echo $d | sed "s/opendaylight\/alto\/$CATEGORY/alto/g")
29                 mkdir -p $target
30                 mv $d/* $target
31                 rm -rf $d
32         done
33 }
34
35
36 for suffix in core basic ext; do
37         for f in $(find . -name '*.xml'); do
38                 fix_namespace $f $suffix
39         done
40
41         for f in $(find . -name '*.yang'); do
42                 fix_namespace $f $suffix
43         done
44
45         for f in $(find . -name '*.java'); do
46                 fix_package $f $suffix
47         done
48
49         fix_folder $suffix
50 done