From 806052bf4df8bd023cfb391794bc5937f2624716 Mon Sep 17 00:00:00 2001 From: Marcus G K Williams Date: Wed, 2 Aug 2017 15:09:24 -0700 Subject: Convert tabs to spaces Per Java Code Style Guide: https://wiki.onap.org/display/DW/Java+code+style Converting tabs to 4 spaces. Issue-Id: SDNC-25 Change-Id: I99ce6c244df72f805b52d0d66403d8b76d9929ae Signed-off-by: Marcus G K Williams --- mdsal-resource/features/pom.xml | 234 +++++++-------- .../features/src/main/resources/features.xml | 2 +- mdsal-resource/installer/pom.xml | 252 ++++++++-------- .../src/assembly/assemble_installer_zip.xml | 60 ++-- .../src/assembly/assemble_mvnrepo_zip.xml | 40 +-- .../src/main/resources/scripts/install-feature.sh | 6 +- mdsal-resource/pom.xml | 24 +- mdsal-resource/provider/pom.xml | 220 +++++++------- .../sdnc/sli/resource/mdsal/ConfigResource.java | 160 +++++----- .../sli/resource/mdsal/MdsalResourceActivator.java | 90 +++--- .../sli/resource/mdsal/OperationalResource.java | 150 +++++----- .../sdnc/sli/resource/mdsal/RestService.java | 326 ++++++++++----------- .../provider/src/main/resources/crtables.sql | 2 +- .../src/main/resources/svclogic.properties | 2 +- 14 files changed, 784 insertions(+), 784 deletions(-) (limited to 'mdsal-resource') diff --git a/mdsal-resource/features/pom.xml b/mdsal-resource/features/pom.xml index fbad6e21..140810ff 100755 --- a/mdsal-resource/features/pom.xml +++ b/mdsal-resource/features/pom.xml @@ -1,134 +1,134 @@ - 4.0.0 - - mdsal-resource - org.onap.ccsdk.sli.adaptors - 0.0.1-SNAPSHOT - - mdsal-resource-features - MD-SAL Resource Adaptor - Features + 4.0.0 + + mdsal-resource + org.onap.ccsdk.sli.adaptors + 0.0.1-SNAPSHOT + + mdsal-resource-features + MD-SAL Resource Adaptor - Features - jar + jar - + - - org.onap.ccsdk.sli.adaptors - mdsal-resource-provider - ${project.version} - + + org.onap.ccsdk.sli.adaptors + mdsal-resource-provider + ${project.version} + - - commons-lang - commons-lang - 2.6 - compile - + + commons-lang + commons-lang + 2.6 + compile + - - org.opendaylight.mdsal - features-mdsal - ${odl.mdsal.features.version} - features - xml + + org.opendaylight.mdsal + features-mdsal + ${odl.mdsal.features.version} + features + xml - runtime - + runtime + - - - org.opendaylight.odlparent - opendaylight-karaf-empty - ${odl.karaf.empty.distro.version} - zip - + + + org.opendaylight.odlparent + opendaylight-karaf-empty + ${odl.karaf.empty.distro.version} + zip + - - - org.opendaylight.odlparent - features-test - ${odl.commons.opendaylight.version} - test - + + + org.opendaylight.odlparent + features-test + ${odl.commons.opendaylight.version} + test + - - org.opendaylight.yangtools - features-yangtools - ${odl.yangtools.version} - features - xml - runtime - - + + org.opendaylight.yangtools + features-yangtools + ${odl.yangtools.version} + features + xml + runtime + + - - - - true - src/main/resources - - - - - org.apache.maven.plugins - maven-resources-plugin - - - filter - - resources - - generate-resources - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - attach-artifacts - - attach-artifact - - package - - - - ${project.build.directory}/classes/${features.file} - xml - features - - - - - - - - + org.apache.maven.plugins + maven-surefire-plugin + 2.16 + + + org.opendaylight.controller + opendaylight-karaf-empty + ${odl.karaf.empty.distro.version} + + + org.opendaylight.yangtools:features-test + + + + --> + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + diff --git a/mdsal-resource/features/src/main/resources/features.xml b/mdsal-resource/features/src/main/resources/features.xml index 5f4a954b..6ed0b1eb 100644 --- a/mdsal-resource/features/src/main/resources/features.xml +++ b/mdsal-resource/features/src/main/resources/features.xml @@ -4,7 +4,7 @@ openECOMP : SDN-C ================================================================================ Copyright (C) 2017 ONAP Intellectual Property. All rights - reserved. + reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/mdsal-resource/installer/pom.xml b/mdsal-resource/installer/pom.xml index 0e52c130..d636f8d9 100755 --- a/mdsal-resource/installer/pom.xml +++ b/mdsal-resource/installer/pom.xml @@ -1,138 +1,138 @@ - 4.0.0 - - mdsal-resource - org.onap.ccsdk.sli.adaptors - 0.0.1-SNAPSHOT - - mdsal-resource-installer - MDSAL Resource - Karaf Installer - pom + 4.0.0 + + mdsal-resource + org.onap.ccsdk.sli.adaptors + 0.0.1-SNAPSHOT + + mdsal-resource-installer + MDSAL Resource - Karaf Installer + pom - - sdnc-mdsal-resource - sdnc-mdsal-resource - mvn:org.onap.ccsdk.sli.adaptors/mdsal-resource-features/${project.version}/xml/features - false - + + sdnc-mdsal-resource + sdnc-mdsal-resource + mvn:org.onap.ccsdk.sli.adaptors/mdsal-resource-features/${project.version}/xml/features + false + - + - - org.onap.ccsdk.sli.adaptors - mdsal-resource-features - ${project.version} - features - xml - - - * - * - - - + + org.onap.ccsdk.sli.adaptors + mdsal-resource-features + ${project.version} + features + xml + + + * + * + + + - - org.onap.ccsdk.sli.adaptors - mdsal-resource-provider - ${project.version} - + + org.onap.ccsdk.sli.adaptors + mdsal-resource-provider + ${project.version} + - + - - - - maven-assembly-plugin - 2.6 - - - maven-repo-zip - - single - - package - - false - stage/${application.name}-${project.version} - - src/assembly/assemble_mvnrepo_zip.xml - - false - - - - installer-zip - - single - - package - - true - ${application.name}-${project.version}-installer - - src/assembly/assemble_installer_zip.xml - - false - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy-dependencies - - copy-dependencies - - prepare-package - - false - ${project.build.directory}/assembly/system - false - true - true - true - false - false - org.onap.ccsdk - sli-common,sli-provider,dblib-provider - provided - - - - - - maven-resources-plugin - 2.6 - - - copy-version - - copy-resources - - validate - - ${basedir}/target/stage - - - src/main/resources/scripts - - install-feature.sh - - true - - - - + + + + maven-assembly-plugin + 2.6 + + + maven-repo-zip + + single + + package + + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + false + + + + installer-zip + + single + + package + + true + ${application.name}-${project.version}-installer + + src/assembly/assemble_installer_zip.xml + + false + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.onap.ccsdk + sli-common,sli-provider,dblib-provider + provided + + + + + + maven-resources-plugin + 2.6 + + + copy-version + + copy-resources + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + - - + + - - + + diff --git a/mdsal-resource/installer/src/assembly/assemble_installer_zip.xml b/mdsal-resource/installer/src/assembly/assemble_installer_zip.xml index e278872a..5f32ff4c 100644 --- a/mdsal-resource/installer/src/assembly/assemble_installer_zip.xml +++ b/mdsal-resource/installer/src/assembly/assemble_installer_zip.xml @@ -3,7 +3,7 @@ openECOMP : SDN-C ================================================================================ Copyright (C) 2017 ONAP Intellectual Property. All rights - reserved. + reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -22,37 +22,37 @@ - installer_zip - - zip - + xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> + installer_zip + + zip + - - false + + false - - - target/stage/ - ${application.name} - 755 - - *.sh - - - - target/stage/ - ${application.name} - 644 - - *.sh - - - + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + diff --git a/mdsal-resource/installer/src/assembly/assemble_mvnrepo_zip.xml b/mdsal-resource/installer/src/assembly/assemble_mvnrepo_zip.xml index 1edacdb6..6b7d23f8 100644 --- a/mdsal-resource/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/mdsal-resource/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -3,7 +3,7 @@ openECOMP : SDN-C ================================================================================ Copyright (C) 2017 ONAP Intellectual Property. All rights - reserved. + reserved. ================================================================================ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -22,27 +22,27 @@ - mvnrepo_zip - - zip - + xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> + mvnrepo_zip + + zip + - - false + + false - - - target/assembly/ - . - - - - + + + target/assembly/ + . + + + + diff --git a/mdsal-resource/installer/src/main/resources/scripts/install-feature.sh b/mdsal-resource/installer/src/main/resources/scripts/install-feature.sh index 9a47d222..214dbbe7 100644 --- a/mdsal-resource/installer/src/main/resources/scripts/install-feature.sh +++ b/mdsal-resource/installer/src/main/resources/scripts/install-feature.sh @@ -30,10 +30,10 @@ REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip if [ -f ${REPOZIP} ] then - unzip -d ${ODL_HOME} ${REPOZIP} + unzip -d ${ODL_HOME} ${REPOZIP} else - echo "ERROR : repo zip ($REPOZIP) not found" - exit 1 + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 fi ${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} diff --git a/mdsal-resource/pom.xml b/mdsal-resource/pom.xml index 4501edd1..a6f68b43 100755 --- a/mdsal-resource/pom.xml +++ b/mdsal-resource/pom.xml @@ -1,21 +1,21 @@ - - org.onap.ccsdk.sli.adaptors - sdnc-adaptors - 0.0.1-SNAPSHOT - + + org.onap.ccsdk.sli.adaptors + sdnc-adaptors + 0.0.1-SNAPSHOT + - 4.0.0 - pom - org.onap.ccsdk.sli.adaptors - mdsal-resource + 4.0.0 + pom + org.onap.ccsdk.sli.adaptors + mdsal-resource - MD-SAL Resource Adaptor - The MD-SAL resource adaptor allows service logic to access persistent data from MD-SAL config and operational trees + MD-SAL Resource Adaptor + The MD-SAL resource adaptor allows service logic to access persistent data from MD-SAL config and operational trees - 0.0.1-SNAPSHOT + 0.0.1-SNAPSHOT diff --git a/mdsal-resource/provider/pom.xml b/mdsal-resource/provider/pom.xml index 0092f699..92dada64 100755 --- a/mdsal-resource/provider/pom.xml +++ b/mdsal-resource/provider/pom.xml @@ -1,122 +1,122 @@ - 4.0.0 - - org.onap.ccsdk.sli.adaptors - mdsal-resource - 0.0.1-SNAPSHOT - - mdsal-resource-provider - bundle - MD-SAL Resource Adaptor - Provider - http://maven.apache.org - - UTF-8 - - + 4.0.0 + + org.onap.ccsdk.sli.adaptors + mdsal-resource + 0.0.1-SNAPSHOT + + mdsal-resource-provider + bundle + MD-SAL Resource Adaptor - Provider + http://maven.apache.org + + UTF-8 + + - - junit - junit - 3.8.1 - test - - - org.onap.ccsdk.sli.core - sli-common - ${sdnctl.sli.version} - compile - - - org.onap.ccsdk.sli.core - sli-provider - ${sdnctl.sli.version} - compile - - - equinoxSDK381 - org.eclipse.osgi - ${equinox.osgi.version} - - - org.slf4j - slf4j-api - ${slf4j.version} - - - org.slf4j - jcl-over-slf4j - ${slf4j.version} - - - commons-codec - commons-codec - ${commons.codec.version} - + + junit + junit + 3.8.1 + test + + + org.onap.ccsdk.sli.core + sli-common + ${sdnctl.sli.version} + compile + + + org.onap.ccsdk.sli.core + sli-provider + ${sdnctl.sli.version} + compile + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + + + org.slf4j + slf4j-api + ${slf4j.version} + + + org.slf4j + jcl-over-slf4j + ${slf4j.version} + + + commons-codec + commons-codec + ${commons.codec.version} + - + - - + + - - org.apache.felix - maven-bundle-plugin - ${bundle.plugin.version} - true - - - org.openecomp.sdnc.sli.resource.mdsal - org.openecomp.sdnc.sli.resource.mdsal.MdsalResourceActivator - org.openecomp.sdnc.sli.resource.mdsal - org.openecomp.sdnc.sli.*,org.osgi.framework.*,org.slf4j.*,com.mysql.jdbc.* - - * - true - + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + true + + + org.openecomp.sdnc.sli.resource.mdsal + org.openecomp.sdnc.sli.resource.mdsal.MdsalResourceActivator + org.openecomp.sdnc.sli.resource.mdsal + org.openecomp.sdnc.sli.*,org.osgi.framework.*,org.slf4j.*,com.mysql.jdbc.* + + * + true + - + - + - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - - com.brocade.developer - - - providermodule-plugin - - - [1.2.0.100-SNAPSHOT,) - - - process - - - - - - - - - - - - - + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + com.brocade.developer + + + providermodule-plugin + + + [1.2.0.100-SNAPSHOT,) + + + process + + + + + + + + + + + + + diff --git a/mdsal-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/mdsal/ConfigResource.java b/mdsal-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/mdsal/ConfigResource.java index ed0ed063..4a89ad8f 100644 --- a/mdsal-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/mdsal/ConfigResource.java +++ b/mdsal-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/mdsal/ConfigResource.java @@ -33,118 +33,118 @@ import org.w3c.dom.Document; public class ConfigResource implements SvcLogicResource { - private static final Logger LOG = LoggerFactory.getLogger(ConfigResource.class); + private static final Logger LOG = LoggerFactory.getLogger(ConfigResource.class); - private RestService restService; + private RestService restService; - public ConfigResource(String sdncProtocol, String sdncHost, String sdncPort, String sdncUser, String sdncPasswd) - { - restService = new RestService(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd, RestService.PayloadType.XML); - } + public ConfigResource(String sdncProtocol, String sdncHost, String sdncPort, String sdncUser, String sdncPasswd) + { + restService = new RestService(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd, RestService.PayloadType.XML); + } - @Override - public QueryStatus isAvailable(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException - { - return(query(resource, false, null, key, prefix, null, null)); - } + @Override + public QueryStatus isAvailable(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException + { + return(query(resource, false, null, key, prefix, null, null)); + } - @Override - public QueryStatus exists(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException - { + @Override + public QueryStatus exists(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException + { - return(query(resource, false, null, key, prefix, null, null)); + return(query(resource, false, null, key, prefix, null, null)); - } + } - @Override - public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix, - String orderBy, SvcLogicContext ctx) throws SvcLogicException { + @Override + public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix, + String orderBy, SvcLogicContext ctx) throws SvcLogicException { - String module = resource; - StringBuffer restQuery = new StringBuffer(); + String module = resource; + StringBuffer restQuery = new StringBuffer(); - String[] keyParts = key.split("/"); + String[] keyParts = key.split("/"); - for (String keyPart : keyParts) { - if (restQuery.length() > 0) { - restQuery.append("/"); - } - if (keyPart.startsWith("$")) { + for (String keyPart : keyParts) { + if (restQuery.length() > 0) { + restQuery.append("/"); + } + if (keyPart.startsWith("$")) { - restQuery.append(ctx.resolve(keyPart.substring(1))); - } else { - restQuery.append(keyPart); - } - } + restQuery.append(ctx.resolve(keyPart.substring(1))); + } else { + restQuery.append(keyPart); + } + } - String restQueryStr = restQuery.toString(); - if ((restQueryStr.startsWith("'") && restQueryStr.endsWith("'")) || - (restQueryStr.startsWith("\"") && restQueryStr.endsWith("\""))) { - restQueryStr = restQueryStr.substring(1, restQueryStr.length()-1); - } + String restQueryStr = restQuery.toString(); + if ((restQueryStr.startsWith("'") && restQueryStr.endsWith("'")) || + (restQueryStr.startsWith("\"") && restQueryStr.endsWith("\""))) { + restQueryStr = restQueryStr.substring(1, restQueryStr.length()-1); + } - String urlString = "restconf/config/" + module + ":" + restQueryStr; + String urlString = "restconf/config/" + module + ":" + restQueryStr; LOG.info("Querying resource: " + resource + ". At URL: " + urlString); - Document results = restService.get(urlString); + Document results = restService.get(urlString); - if (results == null) { - return(QueryStatus.NOT_FOUND); - } else { + if (results == null) { + return(QueryStatus.NOT_FOUND); + } else { - if (ctx != null) { - ctx.mergeDocument(prefix, results); - } - return(QueryStatus.SUCCESS); - } + if (ctx != null) { + ctx.mergeDocument(prefix, results); + } + return(QueryStatus.SUCCESS); + } - } + } - @Override - public QueryStatus reserve(String resource, String select, String key, String prefix, - SvcLogicContext ctx) throws SvcLogicException { + @Override + public QueryStatus reserve(String resource, String select, String key, String prefix, + SvcLogicContext ctx) throws SvcLogicException { - return(QueryStatus.SUCCESS); + return(QueryStatus.SUCCESS); - } + } - @Override - public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException { + @Override + public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException { - return(QueryStatus.SUCCESS); - } + return(QueryStatus.SUCCESS); + } - @Override - public QueryStatus delete(String arg0, String arg1, SvcLogicContext arg2) - throws SvcLogicException { - // TODO Auto-generated method stub - return(QueryStatus.SUCCESS); - } + @Override + public QueryStatus delete(String arg0, String arg1, SvcLogicContext arg2) + throws SvcLogicException { + // TODO Auto-generated method stub + return(QueryStatus.SUCCESS); + } - @Override - public QueryStatus save(String arg0, boolean arg1, boolean localOnly, String arg2, - Map arg3, String arg4, SvcLogicContext arg5) - throws SvcLogicException { - // TODO Auto-generated method stub - return(QueryStatus.SUCCESS); - } + @Override + public QueryStatus save(String arg0, boolean arg1, boolean localOnly, String arg2, + Map arg3, String arg4, SvcLogicContext arg5) + throws SvcLogicException { + // TODO Auto-generated method stub + return(QueryStatus.SUCCESS); + } - @Override - public QueryStatus notify(String resource, String action, String key, - SvcLogicContext ctx) throws SvcLogicException { - return(QueryStatus.SUCCESS); - } + @Override + public QueryStatus notify(String resource, String action, String key, + SvcLogicContext ctx) throws SvcLogicException { + return(QueryStatus.SUCCESS); + } - public QueryStatus update(String resource, String key, - Map parms, String prefix, SvcLogicContext ctx) - throws SvcLogicException { - return(QueryStatus.SUCCESS); - } + public QueryStatus update(String resource, String key, + Map parms, String prefix, SvcLogicContext ctx) + throws SvcLogicException { + return(QueryStatus.SUCCESS); + } diff --git a/mdsal-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/mdsal/MdsalResourceActivator.java b/mdsal-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/mdsal/MdsalResourceActivator.java index ea0bab26..9be03e9d 100644 --- a/mdsal-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/mdsal/MdsalResourceActivator.java +++ b/mdsal-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/mdsal/MdsalResourceActivator.java @@ -38,69 +38,69 @@ public class MdsalResourceActivator implements BundleActivator { - private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; + private static final String SDNC_CONFIG_DIR = "SDNC_CONFIG_DIR"; - public LinkedList registrations = new LinkedList(); + public LinkedList registrations = new LinkedList(); - private static final Logger LOG = LoggerFactory - .getLogger(MdsalResourceActivator.class); + private static final Logger LOG = LoggerFactory + .getLogger(MdsalResourceActivator.class); - @Override - public void start(BundleContext ctx) throws Exception { + @Override + public void start(BundleContext ctx) throws Exception { - // Read properties - Properties props = new Properties(); + // Read properties + Properties props = new Properties(); - String propDir = System.getenv(SDNC_CONFIG_DIR); - if (propDir == null) { + String propDir = System.getenv(SDNC_CONFIG_DIR); + if (propDir == null) { - propDir = "/opt/sdnc/data/properties"; - } - String propPath = propDir + "/mdsal-resource.properties"; + propDir = "/opt/sdnc/data/properties"; + } + String propPath = propDir + "/mdsal-resource.properties"; - File propFile = new File(propPath); + File propFile = new File(propPath); - if (!propFile.exists()) { + if (!propFile.exists()) { - throw new ConfigurationException( - "Missing configuration properties file : " - + propFile); - } - try { + throw new ConfigurationException( + "Missing configuration properties file : " + + propFile); + } + try { - props.load(new FileInputStream(propFile)); - } catch (Exception e) { - throw new ConfigurationException( - "Could not load properties file " + propPath, e); + props.load(new FileInputStream(propFile)); + } catch (Exception e) { + throw new ConfigurationException( + "Could not load properties file " + propPath, e); - } + } - String sdncUser = props.getProperty("org.openecomp.sdnc.sli.resource.mdsal.sdnc-user", "admin"); - String sdncPasswd = props.getProperty("org.openecomp.sdnc.sli.resource.mdsal.sdnc-passwd", "admin"); - String sdncHost = props.getProperty("org.openecomp.sdnc.sli.resource.mdsal.sdnc-host", "localhost"); - String sdncProtocol = props.getProperty("org.openecomp.sdnc.sli.resource.mdsal.sdnc-protocol", "https"); - String sdncPort = props.getProperty("org.openecomp.sdnc.sli.resource.mdsal.sdnc-port", "8443"); + String sdncUser = props.getProperty("org.openecomp.sdnc.sli.resource.mdsal.sdnc-user", "admin"); + String sdncPasswd = props.getProperty("org.openecomp.sdnc.sli.resource.mdsal.sdnc-passwd", "admin"); + String sdncHost = props.getProperty("org.openecomp.sdnc.sli.resource.mdsal.sdnc-host", "localhost"); + String sdncProtocol = props.getProperty("org.openecomp.sdnc.sli.resource.mdsal.sdnc-protocol", "https"); + String sdncPort = props.getProperty("org.openecomp.sdnc.sli.resource.mdsal.sdnc-port", "8443"); - // Advertise MD-SAL resource adaptors - SvcLogicResource impl = new ConfigResource(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd); + // Advertise MD-SAL resource adaptors + SvcLogicResource impl = new ConfigResource(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd); - LOG.debug("Registering MdsalResource service "+impl.getClass().getName()); - registrations.add(ctx.registerService(impl.getClass().getName(), impl, null)); + LOG.debug("Registering MdsalResource service "+impl.getClass().getName()); + registrations.add(ctx.registerService(impl.getClass().getName(), impl, null)); - impl = new OperationalResource(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd); + impl = new OperationalResource(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd); - LOG.debug("Registering MdsalResource service "+impl.getClass().getName()); - registrations.add(ctx.registerService(impl.getClass().getName(), impl, null)); - } + LOG.debug("Registering MdsalResource service "+impl.getClass().getName()); + registrations.add(ctx.registerService(impl.getClass().getName(), impl, null)); + } - @Override - public void stop(BundleContext ctx) throws Exception { + @Override + public void stop(BundleContext ctx) throws Exception { - for (ServiceRegistration registration : registrations) - { - registration.unregister(); - } - } + for (ServiceRegistration registration : registrations) + { + registration.unregister(); + } + } } diff --git a/mdsal-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/mdsal/OperationalResource.java b/mdsal-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/mdsal/OperationalResource.java index 32323e3b..9374d2ab 100644 --- a/mdsal-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/mdsal/OperationalResource.java +++ b/mdsal-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/mdsal/OperationalResource.java @@ -33,52 +33,52 @@ import org.w3c.dom.Document; public class OperationalResource implements SvcLogicResource { - private static final Logger LOG = LoggerFactory.getLogger(OperationalResource.class); + private static final Logger LOG = LoggerFactory.getLogger(OperationalResource.class); - private RestService restService; + private RestService restService; - public OperationalResource(String sdncProtocol, String sdncHost, String sdncPort, String sdncUser, String sdncPasswd) - { - restService = new RestService(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd, RestService.PayloadType.XML); + public OperationalResource(String sdncProtocol, String sdncHost, String sdncPort, String sdncUser, String sdncPasswd) + { + restService = new RestService(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd, RestService.PayloadType.XML); - } + } - @Override - public QueryStatus isAvailable(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException - { - return(query(resource, false, null, key, prefix, null, null)); - } + @Override + public QueryStatus isAvailable(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException + { + return(query(resource, false, null, key, prefix, null, null)); + } - @Override - public QueryStatus exists(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException - { + @Override + public QueryStatus exists(String resource, String key, String prefix, SvcLogicContext ctx) throws SvcLogicException + { - return(query(resource, false, null, key, prefix, null, null)); + return(query(resource, false, null, key, prefix, null, null)); - } + } - @Override - public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix, - String orderBy, SvcLogicContext ctx) throws SvcLogicException { + @Override + public QueryStatus query(String resource, boolean localOnly, String select, String key, String prefix, + String orderBy, SvcLogicContext ctx) throws SvcLogicException { - String module = resource; - StringBuffer restQuery = new StringBuffer(); + String module = resource; + StringBuffer restQuery = new StringBuffer(); - String[] keyParts = key.split("/"); + String[] keyParts = key.split("/"); - for (String keyPart : keyParts) { - if (restQuery.length() > 0) { - restQuery.append("/"); - } - if (keyPart.startsWith("$")) { + for (String keyPart : keyParts) { + if (restQuery.length() > 0) { + restQuery.append("/"); + } + if (keyPart.startsWith("$")) { - restQuery.append(ctx.resolve(keyPart.substring(1))); - } else { - restQuery.append(keyPart); - } - } + restQuery.append(ctx.resolve(keyPart.substring(1))); + } else { + restQuery.append(keyPart); + } + } String restQueryStr = restQuery.toString(); if ((restQueryStr.startsWith("'") && restQueryStr.endsWith("'")) || @@ -86,66 +86,66 @@ public class OperationalResource implements SvcLogicResource { restQueryStr = restQueryStr.substring(1, restQueryStr.length()-1); } - String urlString = "restconf/operational/" + module + ":" + restQueryStr; + String urlString = "restconf/operational/" + module + ":" + restQueryStr; LOG.info("Querying resource: " + resource + ". At URL: " + urlString); - Document results = restService.get(urlString); + Document results = restService.get(urlString); - if (results == null) { - return(QueryStatus.NOT_FOUND); - } else { + if (results == null) { + return(QueryStatus.NOT_FOUND); + } else { - if (ctx != null) { - ctx.mergeDocument(prefix, results); - } - return(QueryStatus.SUCCESS); - } + if (ctx != null) { + ctx.mergeDocument(prefix, results); + } + return(QueryStatus.SUCCESS); + } - } + } - @Override - public QueryStatus reserve(String resource, String select, String key, String prefix, - SvcLogicContext ctx) throws SvcLogicException { + @Override + public QueryStatus reserve(String resource, String select, String key, String prefix, + SvcLogicContext ctx) throws SvcLogicException { - return(QueryStatus.SUCCESS); + return(QueryStatus.SUCCESS); - } + } - @Override - public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException { + @Override + public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException { - return(QueryStatus.SUCCESS); - } + return(QueryStatus.SUCCESS); + } - @Override - public QueryStatus delete(String arg0, String arg1, SvcLogicContext arg2) - throws SvcLogicException { - // TODO Auto-generated method stub - return(QueryStatus.SUCCESS); - } + @Override + public QueryStatus delete(String arg0, String arg1, SvcLogicContext arg2) + throws SvcLogicException { + // TODO Auto-generated method stub + return(QueryStatus.SUCCESS); + } - @Override - public QueryStatus save(String arg0, boolean arg1, boolean localOnly, String arg2, - Map arg3, String arg4, SvcLogicContext arg5) - throws SvcLogicException { - // TODO Auto-generated method stub - return(QueryStatus.SUCCESS); - } + @Override + public QueryStatus save(String arg0, boolean arg1, boolean localOnly, String arg2, + Map arg3, String arg4, SvcLogicContext arg5) + throws SvcLogicException { + // TODO Auto-generated method stub + return(QueryStatus.SUCCESS); + } - @Override - public QueryStatus notify(String resource, String action, String key, - SvcLogicContext ctx) throws SvcLogicException { - return(QueryStatus.SUCCESS); - } + @Override + public QueryStatus notify(String resource, String action, String key, + SvcLogicContext ctx) throws SvcLogicException { + return(QueryStatus.SUCCESS); + } - public QueryStatus update(String resource, String key, - Map parms, String prefix, SvcLogicContext ctx) - throws SvcLogicException { - return(QueryStatus.SUCCESS); - } + public QueryStatus update(String resource, String key, + Map parms, String prefix, SvcLogicContext ctx) + throws SvcLogicException { + return(QueryStatus.SUCCESS); + } } diff --git a/mdsal-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/mdsal/RestService.java b/mdsal-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/mdsal/RestService.java index 21d3439d..a7b77e5b 100644 --- a/mdsal-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/mdsal/RestService.java +++ b/mdsal-resource/provider/src/main/java/org/openecomp/sdnc/sli/resource/mdsal/RestService.java @@ -46,167 +46,167 @@ import org.w3c.dom.Document; public class RestService { - - private static final Logger LOG = LoggerFactory.getLogger(ConfigResource.class); - - public enum PayloadType { - XML, - JSON - } - - private class SdncAuthenticator extends Authenticator { - - private String user; - private String passwd; - - SdncAuthenticator(String user, String passwd) { - this.user = user; - this.passwd = passwd; - } - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(user, passwd.toCharArray()); - } - - } - - private String user; - private String passwd; - private PayloadType payloadType; - - private String protocol; - private String host; - private String port; - - public RestService(String protocol, String host, String port, String user, String passwd, PayloadType payloadType) { - this.protocol = protocol; - this.host = host; - this.port = port; - this.user = user; - this.passwd = passwd; - this.payloadType = payloadType; - } - - private HttpURLConnection getRestConnection(String urlString, String method) throws IOException - { - - URL sdncUrl = new URL(urlString); - Authenticator.setDefault(new SdncAuthenticator(user, passwd)); - - HttpURLConnection conn = (HttpURLConnection) sdncUrl.openConnection(); - - String authStr = user+":"+passwd; - String encodedAuthStr = new String(Base64.encodeBase64(authStr.getBytes())); - - conn.addRequestProperty("Authentication", "Basic "+encodedAuthStr); - - conn.setRequestMethod(method); - - if (payloadType == PayloadType.XML) { - conn.setRequestProperty("Content-Type", "application/xml"); - conn.setRequestProperty("Accept", "application/xml"); - } else { - - conn.setRequestProperty("Content-Type", "application/json"); - conn.setRequestProperty("Accept", "application/json"); - } - - conn.setDoInput(true); - conn.setDoOutput(true); - conn.setUseCaches(false); - - return(conn); - - } - - - private Document send(String urlString, byte[] msgBytes, String method) { - Document response = null; - String fullUrl = protocol + "://" + host + ":" + port + "/" + urlString; - LOG.info("Sending REST "+method +" to "+fullUrl); - - if (msgBytes != null) { - LOG.info("Message body:\n"+msgBytes); - } - - try { - HttpURLConnection conn = getRestConnection(fullUrl, method); - - if (conn instanceof HttpsURLConnection) { - HostnameVerifier hostnameVerifier = new HostnameVerifier() { - @Override - public boolean verify(String hostname, SSLSession session) { - return true; - } - }; - ((HttpsURLConnection)conn).setHostnameVerifier(hostnameVerifier); - } - - // Write message - if (msgBytes != null) { - conn.setRequestProperty("Content-Length", ""+msgBytes.length); - DataOutputStream outStr = new DataOutputStream(conn.getOutputStream()); - outStr.write(msgBytes); - outStr.close(); - } else { - conn.setRequestProperty("Content-Length", "0"); - } - - - // Read response - BufferedReader respRdr; - - LOG.info("Response: "+conn.getResponseCode()+" "+conn.getResponseMessage()); - - - if (conn.getResponseCode() < 300) { - - respRdr = new BufferedReader(new InputStreamReader(conn.getInputStream())); - } else { - respRdr = new BufferedReader(new InputStreamReader(conn.getErrorStream())); - } - - StringBuffer respBuff = new StringBuffer(); - - String respLn; - - while ((respLn = respRdr.readLine()) != null) { - respBuff.append(respLn+"\n"); - } - respRdr.close(); - - String respString = respBuff.toString(); - - LOG.info("Response body :\n"+respString); - - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - - - response = db.parse(new ByteArrayInputStream(respString.getBytes())); - - } catch (Exception e) { - - LOG.error("Caught exception executing REST command", e); - } - - return (response); - } - - - public Document get(String urlString) { - return(send(urlString, null, "GET")); - } - - public Document delete(String urlString) { - return(send(urlString, null, "DELETE")); - } - - public Document post(String urlString, byte[] msgBytes) { - return(send(urlString, msgBytes, "POST")); - } - - public Document put(String urlString, byte[] msgBytes) { - return(send(urlString, msgBytes, "PUT")); - } + + private static final Logger LOG = LoggerFactory.getLogger(ConfigResource.class); + + public enum PayloadType { + XML, + JSON + } + + private class SdncAuthenticator extends Authenticator { + + private String user; + private String passwd; + + SdncAuthenticator(String user, String passwd) { + this.user = user; + this.passwd = passwd; + } + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(user, passwd.toCharArray()); + } + + } + + private String user; + private String passwd; + private PayloadType payloadType; + + private String protocol; + private String host; + private String port; + + public RestService(String protocol, String host, String port, String user, String passwd, PayloadType payloadType) { + this.protocol = protocol; + this.host = host; + this.port = port; + this.user = user; + this.passwd = passwd; + this.payloadType = payloadType; + } + + private HttpURLConnection getRestConnection(String urlString, String method) throws IOException + { + + URL sdncUrl = new URL(urlString); + Authenticator.setDefault(new SdncAuthenticator(user, passwd)); + + HttpURLConnection conn = (HttpURLConnection) sdncUrl.openConnection(); + + String authStr = user+":"+passwd; + String encodedAuthStr = new String(Base64.encodeBase64(authStr.getBytes())); + + conn.addRequestProperty("Authentication", "Basic "+encodedAuthStr); + + conn.setRequestMethod(method); + + if (payloadType == PayloadType.XML) { + conn.setRequestProperty("Content-Type", "application/xml"); + conn.setRequestProperty("Accept", "application/xml"); + } else { + + conn.setRequestProperty("Content-Type", "application/json"); + conn.setRequestProperty("Accept", "application/json"); + } + + conn.setDoInput(true); + conn.setDoOutput(true); + conn.setUseCaches(false); + + return(conn); + + } + + + private Document send(String urlString, byte[] msgBytes, String method) { + Document response = null; + String fullUrl = protocol + "://" + host + ":" + port + "/" + urlString; + LOG.info("Sending REST "+method +" to "+fullUrl); + + if (msgBytes != null) { + LOG.info("Message body:\n"+msgBytes); + } + + try { + HttpURLConnection conn = getRestConnection(fullUrl, method); + + if (conn instanceof HttpsURLConnection) { + HostnameVerifier hostnameVerifier = new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + ((HttpsURLConnection)conn).setHostnameVerifier(hostnameVerifier); + } + + // Write message + if (msgBytes != null) { + conn.setRequestProperty("Content-Length", ""+msgBytes.length); + DataOutputStream outStr = new DataOutputStream(conn.getOutputStream()); + outStr.write(msgBytes); + outStr.close(); + } else { + conn.setRequestProperty("Content-Length", "0"); + } + + + // Read response + BufferedReader respRdr; + + LOG.info("Response: "+conn.getResponseCode()+" "+conn.getResponseMessage()); + + + if (conn.getResponseCode() < 300) { + + respRdr = new BufferedReader(new InputStreamReader(conn.getInputStream())); + } else { + respRdr = new BufferedReader(new InputStreamReader(conn.getErrorStream())); + } + + StringBuffer respBuff = new StringBuffer(); + + String respLn; + + while ((respLn = respRdr.readLine()) != null) { + respBuff.append(respLn+"\n"); + } + respRdr.close(); + + String respString = respBuff.toString(); + + LOG.info("Response body :\n"+respString); + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + + + response = db.parse(new ByteArrayInputStream(respString.getBytes())); + + } catch (Exception e) { + + LOG.error("Caught exception executing REST command", e); + } + + return (response); + } + + + public Document get(String urlString) { + return(send(urlString, null, "GET")); + } + + public Document delete(String urlString) { + return(send(urlString, null, "DELETE")); + } + + public Document post(String urlString, byte[] msgBytes) { + return(send(urlString, msgBytes, "POST")); + } + + public Document put(String urlString, byte[] msgBytes) { + return(send(urlString, msgBytes, "PUT")); + } } diff --git a/mdsal-resource/provider/src/main/resources/crtables.sql b/mdsal-resource/provider/src/main/resources/crtables.sql index a5dea5bf..f8f57166 100644 --- a/mdsal-resource/provider/src/main/resources/crtables.sql +++ b/mdsal-resource/provider/src/main/resources/crtables.sql @@ -3,7 +3,7 @@ -- openECOMP : SDN-C -- ================================================================================ -- Copyright (C) 2017 ONAP Intellectual Property. All rights --- reserved. +-- reserved. -- ================================================================================ -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. diff --git a/mdsal-resource/provider/src/main/resources/svclogic.properties b/mdsal-resource/provider/src/main/resources/svclogic.properties index 1a2cf0c7..e113161e 100644 --- a/mdsal-resource/provider/src/main/resources/svclogic.properties +++ b/mdsal-resource/provider/src/main/resources/svclogic.properties @@ -3,7 +3,7 @@ # openECOMP : SDN-C # ================================================================================ # Copyright (C) 2017 ONAP Intellectual Property. All rights -# reserved. +# reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. -- cgit 1.2.3-korg