diff options
Diffstat (limited to 'mdsal-resource/provider/src')
16 files changed, 0 insertions, 1119 deletions
diff --git a/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResource.java b/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResource.java deleted file mode 100644 index e2e9bc230..000000000 --- a/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResource.java +++ /dev/null @@ -1,153 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.sli.adaptors.resource.mdsal; - -import java.util.Map; -import java.util.Properties; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; - -public class ConfigResource implements SvcLogicResource { - - private static final Logger LOG = LoggerFactory.getLogger(ConfigResource.class); - - private RestService restService; - - public ConfigResource(MdsalResourcePropertiesProvider propProvider) { - LOG.info("Loading ConfigResource using property provider"); - Properties props = propProvider.getProperties(); - - String sdncUser = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-user", "admin"); - String sdncPasswd = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-passwd", "admin"); - String sdncHost = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-host", "localhost"); - String sdncProtocol = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-protocol", "https"); - String sdncPort = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-port", "8443"); - - restService = new RestService(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd, "XML", "XML"); - } - - public ConfigResource(String sdncProtocol, String sdncHost, String sdncPort, String sdncUser, String sdncPasswd) - { - restService = new RestService(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd, "XML", "XML"); - } - - public ConfigResource(RestService restService) { - this.restService = restService; - } - - @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 - { - 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 { - String module = resource; - StringBuffer restQuery = new StringBuffer(); - - String[] keyParts = key.split("/"); - for (String keyPart : keyParts) { - if (restQuery.length() > 0) { - restQuery.append("/"); - } - if (keyPart.startsWith("$")) { - 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 urlString = "restconf/config/" + module + ":" + restQueryStr; - LOG.info("Querying resource: " + resource + ". At URL: " + urlString); - - Document results = restService.get(urlString); - if (results == null) { - return(QueryStatus.NOT_FOUND); - } else { - 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 { - return(QueryStatus.SUCCESS); - - } - - @Override - public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException { - 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<String, String> 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); - } - - - public QueryStatus update(String resource, String key, - Map<String, String> parms, String prefix, SvcLogicContext ctx) - throws SvcLogicException { - return(QueryStatus.SUCCESS); - } - -} diff --git a/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProvider.java b/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProvider.java deleted file mode 100755 index e433a4c13..000000000 --- a/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProvider.java +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.sli.adaptors.resource.mdsal; - -import java.util.Properties; - -public interface MdsalResourcePropertiesProvider { - - public Properties getProperties(); -} diff --git a/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProviderImpl.java b/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProviderImpl.java deleted file mode 100755 index e9e006f17..000000000 --- a/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/MdsalResourcePropertiesProviderImpl.java +++ /dev/null @@ -1,186 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * onap - * ================================================================================ - * Copyright (C) 2016 - 2017 ONAP - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.sli.adaptors.resource.mdsal; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Optional; -import java.util.Properties; -import java.util.Vector; - -import org.onap.ccsdk.sli.core.sli.ConfigurationException; -import org.onap.ccsdk.sli.core.utils.JREFileResolver; -import org.onap.ccsdk.sli.core.utils.KarafRootFileResolver; -import org.onap.ccsdk.sli.core.utils.PropertiesFileResolver; -import org.onap.ccsdk.sli.core.utils.common.CoreDefaultFileResolver; -import org.onap.ccsdk.sli.core.utils.common.SdncConfigEnvVarFileResolver; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Responsible for determining the properties file to use and instantiating the - * <code>SqlResource</code> Service. The priority for properties file - * resolution is as follows: - * - * <ol> - * <li>A directory identified by the system environment variable - * <code>SDNC_CONFIG_DIR</code></li> - * <li>The default directory <code>DEFAULT_DBLIB_PROP_DIR</code></li> - * <li>A directory identified by the JRE argument - * <code>sql-resource.properties</code></li> - * <li>A <code>sql-resource.properties</code> file located in the karaf root - * directory</li> - * </ol> - */ -public class MdsalResourcePropertiesProviderImpl implements MdsalResourcePropertiesProvider { - - private static final Logger LOG = LoggerFactory.getLogger(MdsalResourcePropertiesProviderImpl.class); - - /** - * The name of the properties file for database configuration - */ - private static final String MDSALRESOURCE_PROP_FILE_NAME = "mdsal-resource.properties"; - - /** - * A prioritized list of strategies for resolving sql-resource properties files. - */ - private Vector<PropertiesFileResolver> mdsalResourcePropertiesFileResolvers = new Vector<>(); - - /** - * The configuration properties for the db connection. - */ - private Properties properties; - - /** - * Set up the prioritized list of strategies for resolving dblib properties - * files. - */ - public MdsalResourcePropertiesProviderImpl() { - mdsalResourcePropertiesFileResolvers - .add(new SdncConfigEnvVarFileResolver("Using property file (1) from environment variable")); - mdsalResourcePropertiesFileResolvers.add(new CoreDefaultFileResolver("Using property file (2) from default directory")); - - mdsalResourcePropertiesFileResolvers.add( - new JREFileResolver("Using property file (3) from JRE argument", MdsalResourcePropertiesProviderImpl.class)); - mdsalResourcePropertiesFileResolvers.add(new KarafRootFileResolver("Using property file (4) from karaf root", this)); - - // determines properties file as according to the priority described in the - // class header comment - final File propertiesFile = determinePropertiesFile(this); - if (propertiesFile != null) { - try (FileInputStream fileInputStream = new FileInputStream(propertiesFile)) { - properties = new Properties(); - properties.load(fileInputStream); - } catch (final IOException e) { - LOG.error("Failed to load properties for file: {}", propertiesFile.toString(), - new ConfigurationException("Failed to load properties for file: " + propertiesFile.toString(), - e)); - } - } else { - // Try to read properties as resource - - InputStream propStr = getClass().getResourceAsStream("/" + MDSALRESOURCE_PROP_FILE_NAME); - if (propStr != null) { - properties = new Properties(); - try { - properties.load(propStr); - propStr.close(); - } catch (IOException e) { - properties = null; - } - } - - } - - if (properties == null) { - reportFailure("Missing configuration properties resource(3)", new ConfigurationException( - "Missing configuration properties resource(3): " + MDSALRESOURCE_PROP_FILE_NAME)); - } - } - - /** - * Extract svclogic config properties. - * - * @return the svclogic config properties - */ - public Properties getProperties() { - return properties; - } - - /** - * Reports the method chosen for properties resolution to the - * <code>Logger</code>. - * - * @param message - * Some user friendly message - * @param fileOptional - * The file location of the chosen properties file - * @return the file location of the chosen properties file - */ - private static File reportSuccess(final String message, final Optional<File> fileOptional) { - if (fileOptional.isPresent()) { - final File file = fileOptional.get(); - LOG.info("{} {}", message, file.getPath()); - return file; - } - return null; - } - - /** - * Reports fatal errors. This is the case in which no properties file could be - * found. - * - * @param message - * An appropriate fatal error message - * @param configurationException - * An exception describing what went wrong during resolution - */ - private static void reportFailure(final String message, final ConfigurationException configurationException) { - - LOG.error("{}", message, configurationException); - } - - /** - * Determines the sql-resource properties file to use based on the following priority: - * <ol> - * <li>A directory identified by the system environment variable - * <code>SDNC_CONFIG_DIR</code></li> - * <li>The default directory <code>DEFAULT_DBLIB_PROP_DIR</code></li> - * <li>A directory identified by the JRE argument - * <code>mdsal-resource.properties</code></li> - * <li>A <code>sql-resource.properties</code> file located in the karaf root - * directory</li> - * </ol> - */ - File determinePropertiesFile(final MdsalResourcePropertiesProviderImpl resourceProvider) { - - for (final PropertiesFileResolver sliPropertiesFileResolver : mdsalResourcePropertiesFileResolvers) { - final Optional<File> fileOptional = sliPropertiesFileResolver.resolveFile(MDSALRESOURCE_PROP_FILE_NAME); - if (fileOptional.isPresent()) { - return reportSuccess(sliPropertiesFileResolver.getSuccessfulResolutionMessage(), fileOptional); - } - } - - return null; - } -} diff --git a/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/OperationalResource.java b/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/OperationalResource.java deleted file mode 100644 index 320878126..000000000 --- a/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/OperationalResource.java +++ /dev/null @@ -1,147 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.sli.adaptors.resource.mdsal; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; - -import java.util.Map; -import java.util.Properties; - -public class OperationalResource implements SvcLogicResource { - - private static final Logger LOG = LoggerFactory.getLogger(OperationalResource.class); - - private RestService restService; - - public OperationalResource(MdsalResourcePropertiesProvider propProvider) { - Properties props = propProvider.getProperties(); - - String sdncUser = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-user", "admin"); - String sdncPasswd = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-passwd", "admin"); - String sdncHost = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-host", "localhost"); - String sdncProtocol = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-protocol", "https"); - String sdncPort = props.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-port", "8443"); - - restService = new RestService(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd, "XML", "XML"); - } - - public OperationalResource(String sdncProtocol, String sdncHost, String sdncPort, String sdncUser, String sdncPasswd) { - restService = new RestService(sdncProtocol, sdncHost, sdncPort, sdncUser, sdncPasswd, "XML", "XML"); - } - - public OperationalResource(RestService restService) { - this.restService = restService; - } - - @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 { - 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 { - String module = resource; - StringBuffer restQuery = new StringBuffer(); - - String[] keyParts = key.split("/"); - for (String keyPart : keyParts) { - if (restQuery.length() > 0) { - restQuery.append("/"); - } - if (keyPart.startsWith("$")) { - 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 urlString = "restconf/operational/" + module + ":" + restQueryStr; - LOG.info("Querying resource: " + resource + ". At URL: " + urlString); - - Document results = restService.get(urlString); - - if (results == null) { - return (QueryStatus.NOT_FOUND); - } else { - 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 { - return (QueryStatus.SUCCESS); - } - - @Override - public QueryStatus release(String resource, String key, SvcLogicContext ctx) throws SvcLogicException { - 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<String, String> 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); - } - - public QueryStatus update(String resource, String key, - Map<String, String> parms, String prefix, SvcLogicContext ctx) - throws SvcLogicException { - return (QueryStatus.SUCCESS); - } - -} diff --git a/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/RestService.java b/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/RestService.java deleted file mode 100644 index ebddc24ae..000000000 --- a/mdsal-resource/provider/src/main/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/RestService.java +++ /dev/null @@ -1,184 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.sli.adaptors.resource.mdsal; - -import org.apache.commons.codec.binary.Base64; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.xml.XMLConstants; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import java.io.*; -import java.net.Authenticator; -import java.net.HttpURLConnection; -import java.net.PasswordAuthentication; -import java.net.URL; - -public class RestService { - - private static final Logger LOG = LoggerFactory.getLogger(ConfigResource.class); - private String user; - private String passwd; - private String contentType; - private String accept; - private String protocol; - private String host; - private String port; - - public RestService(String protocol, String host, String port, String user, String passwd, String accept, String contentType) { - this.protocol = protocol; - this.host = host; - this.port = port; - this.user = user; - this.passwd = passwd; - this.accept = accept; - this.contentType = contentType; - } - - private HttpURLConnection getRestConnection(String urlString, String method) throws IOException { - URL sdncUrl = new URL(urlString); - Authenticator.setDefault(new SdncAuthenticator(user, passwd)); - - String authStr = user + ":" + passwd; - String encodedAuthStr = new String(Base64.encodeBase64(authStr.getBytes())); - - HttpURLConnection conn = (HttpURLConnection) sdncUrl.openConnection(); - conn.addRequestProperty("Authentication", "Basic " + encodedAuthStr); - conn.setRequestMethod(method); - conn.setDoInput(true); - conn.setDoOutput(true); - conn.setUseCaches(false); - - //Setting Accept header (doesn't dependent on Msg Body if present or not) - if ("XML".equalsIgnoreCase(accept)) { - conn.setRequestProperty("Accept", "application/xml"); - } else { - conn.setRequestProperty("Accept", "application/json"); - } - - return (conn); - } - - private Document send(String urlString, byte[] msgBytes, String method) { - Document response = null; - String fullUrl = protocol + "://" + host + ":" + port + "/" + urlString; - LOG.info("Sending REST {} to {}", method, fullUrl); - - try { - HttpURLConnection conn = getRestConnection(fullUrl, method); - if (conn instanceof HttpsURLConnection) { - HostnameVerifier hostnameVerifier = (hostname, session) -> true; - ((HttpsURLConnection) conn).setHostnameVerifier(hostnameVerifier); - } - - // Write message - if (msgBytes != null) { - LOG.info("Message body:\n{}", msgBytes); - conn.setRequestProperty("Content-Length", "" + msgBytes.length); - - // Setting Content-Type header only if Msg Body is present - if ("XML".equalsIgnoreCase(contentType)) { - conn.setRequestProperty("Content-Type", "application/xml"); - } else { - conn.setRequestProperty("Content-Type", "application/json"); - } - - DataOutputStream outStr = new DataOutputStream(conn.getOutputStream()); - outStr.write(msgBytes); - outStr.close(); - } else { - conn.setRequestProperty("Content-Length", "0"); - } - - // Read response - LOG.info("Response: {} {}", conn.getResponseCode(), conn.getResponseMessage()); - - BufferedReader respRdr; - 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(); - dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true); - dbf.setFeature("http://xml.org/sax/features/external-general-entities", false); - dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false); - 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 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()); - } - - } - -} diff --git a/mdsal-resource/provider/src/main/resources/IPV4_ADDRESS_POOL.csv b/mdsal-resource/provider/src/main/resources/IPV4_ADDRESS_POOL.csv deleted file mode 100755 index 30ce117bc..000000000 --- a/mdsal-resource/provider/src/main/resources/IPV4_ADDRESS_POOL.csv +++ /dev/null @@ -1,9 +0,0 @@ -"192.168.1.2","OAM","AVAILABLE" -"192.168.1.3","OAM","AVAILABLE" -"192.168.1.4","OAM","AVAILABLE" -"192.168.1.5","OAM","AVAILABLE" -"192.168.1.6","OAM","AVAILABLE" -"192.168.1.7","OAM","AVAILABLE" -"192.168.1.8","OAM","AVAILABLE" -"192.168.1.9","OAM","AVAILABLE" -"192.168.1.10","OAM","AVAILABLE" diff --git a/mdsal-resource/provider/src/main/resources/OSGI-INF/blueprint/mdsal-resource-blueprint.xml b/mdsal-resource/provider/src/main/resources/OSGI-INF/blueprint/mdsal-resource-blueprint.xml deleted file mode 100755 index 9c691263c..000000000 --- a/mdsal-resource/provider/src/main/resources/OSGI-INF/blueprint/mdsal-resource-blueprint.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - openECOMP : SDN-C - ================================================================================ - Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights - reserved. - ================================================================================ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ============LICENSE_END========================================================= - --> - -<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" - xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" - odl:use-default-for-reference-types="true"> - - <bean id="propProvider" class="org.onap.ccsdk.sli.adaptors.resource.mdsal.MdsalResourcePropertiesProviderImpl" /> - - - <bean id="configResourceInstance" class="org.onap.ccsdk.sli.adaptors.resource.mdsal.ConfigResource"> - <argument ref="propProvider"/> - </bean> - - <bean id="operResourceInstance" class="org.onap.ccsdk.sli.adaptors.resource.mdsal.OperationalResource"> - <argument ref="propProvider"/> - </bean> - - <service ref="configResourceInstance"> - <interfaces> - <value>org.onap.ccsdk.sli.adaptors.resource.mdsal.ConfigResource</value> - </interfaces> - </service> - - <service ref="operResourceInstance"> - <interfaces> - <value>org.onap.ccsdk.sli.adaptors.resource.mdsal.OperationalResource</value> - </interfaces> - </service> -</blueprint> diff --git a/mdsal-resource/provider/src/main/resources/VLAN_ID_POOL.csv b/mdsal-resource/provider/src/main/resources/VLAN_ID_POOL.csv deleted file mode 100755 index 6c4b0f775..000000000 --- a/mdsal-resource/provider/src/main/resources/VLAN_ID_POOL.csv +++ /dev/null @@ -1,22 +0,0 @@ -"1100","IPAG","AVAILABLE",NULL -"1101","IPAG","AVAILABLE",NULL -"1102","IPAG","AVAILABLE",NULL -"1103","IPAG","AVAILABLE",NULL -"1104","IPAG","AVAILABLE",NULL -"1105","IPAG","AVAILABLE",NULL -"1106","IPAG","AVAILABLE",NULL -"1107","IPAG","AVAILABLE",NULL -"1108","IPAG","AVAILABLE",NULL -"1109","IPAG","AVAILABLE",NULL -"1110","IPAG","AVAILABLE",NULL -"1200","VPE","AVAILABLE",NULL -"1201","VPE","AVAILABLE",NULL -"1202","VPE","AVAILABLE",NULL -"1203","VPE","AVAILABLE",NULL -"1204","VPE","AVAILABLE",NULL -"1205","VPE","AVAILABLE",NULL -"1206","VPE","AVAILABLE",NULL -"1207","VPE","AVAILABLE",NULL -"1208","VPE","AVAILABLE",NULL -"1209","VPE","AVAILABLE",NULL -"1210","VPE","AVAILABLE",NULL diff --git a/mdsal-resource/provider/src/main/resources/crtables.sql b/mdsal-resource/provider/src/main/resources/crtables.sql deleted file mode 100644 index 5ee75f4e4..000000000 --- a/mdsal-resource/provider/src/main/resources/crtables.sql +++ /dev/null @@ -1,70 +0,0 @@ ---- --- ============LICENSE_START======================================================= --- openECOMP : SDN-C --- ================================================================================ --- Copyright (C) 2017 AT&T Intellectual Property. All rights --- reserved. --- ================================================================================ --- Licensed under the Apache License, Version 2.0 (the "License"); --- you may not use this file except in compliance with the License. --- You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, software --- distributed under the License is distributed on an "AS IS" BASIS, --- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --- See the License for the specific language governing permissions and --- limitations under the License. --- ============LICENSE_END========================================================= ---- - -CREATE TABLE sdnctl.VNF ( -vnf_id varchar(80) NOT NULL, -vnf_name varchar(80) NOT NULL, -vnf_type varchar(10) NOT NULL, -orchestration_status varchar(20), -heat_stack_id varchar(80), -mso_catalog_key varchar(80), -availability_zone varchar(80), -aic_site_id varchar(80), -oam_ipv4_address varchar(20), -CONSTRAINT P_VNF PRIMARY KEY(vnf_id)); - -CREATE TABLE sdnctl.VNF_NETWORK_CONNECTION ( -connection_uuid varchar(80) NOT NULL, -vnf_id varchar(80) NOT NULL, -connection_id varchar(80), -connection_type varchar(20), -neutron_network_id varchar(80), -neutron_network_name varchar(80), -orchestration_status varchar(20), -switch_id varchar(40), -heat_stack_id varchar(80), -mso_catalog_key varchar(80), -provider_network varchar(80), -port_group_id varchar(80), -port_group_name varchar(80), -CONSTRAINT P_NETWORK_CONNECTION PRIMARY KEY(connection_uuid)); - -CREATE TABLE sdnctl.VNF_NETWORK_CONNECTION_VLAN ( -vlan_uuid varchar(80) NOT NULL, -vlan_id numeric(4) NOT NULL, -vlan_type varchar(5) NOT NULL, -connection_uuid varchar(80), -CONSTRAINT P_VNF_NETWORK_CONNECTION_VLAN PRIMARY KEY(vlan_uuid)); - -CREATE TABLE sdnctl.VLAN_ID_POOL ( -vlan_id numeric(4) NOT NULL, -universe varchar(40) NOT NULL, -status varchar(40) NOT NULL, -vlan_uuid varchar(80), -CONSTRAINT P_VLAN_ID_POOL PRIMARY KEY(vlan_id,universe)); - -CREATE TABLE sdnctl.IPV4_ADDRESS_POOL ( -ipv4_addr varchar(20) NOT NULL, -universe varchar(40) NOT NULL, -status varchar(40) NOT NULL, -CONSTRAINT P_IPV4_ADDRESS_POOL PRIMARY KEY(ipv4_addr, universe)); - - diff --git a/mdsal-resource/provider/src/main/resources/mdsal-resource.properties b/mdsal-resource/provider/src/main/resources/mdsal-resource.properties deleted file mode 100644 index 47c8ebf77..000000000 --- a/mdsal-resource/provider/src/main/resources/mdsal-resource.properties +++ /dev/null @@ -1,27 +0,0 @@ -### -# ============LICENSE_START======================================================= -# openECOMP : SDN-C -# ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights -# reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### - -org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-user=admin -org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-passwd=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U -org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-host=localhost -org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-protocol=http -org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-port=8181 - diff --git a/mdsal-resource/provider/src/main/resources/org/opendaylight/blueprint/mdsal-resource-blueprint.xml b/mdsal-resource/provider/src/main/resources/org/opendaylight/blueprint/mdsal-resource-blueprint.xml deleted file mode 100755 index 9c691263c..000000000 --- a/mdsal-resource/provider/src/main/resources/org/opendaylight/blueprint/mdsal-resource-blueprint.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ============LICENSE_START======================================================= - openECOMP : SDN-C - ================================================================================ - Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights - reserved. - ================================================================================ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ============LICENSE_END========================================================= - --> - -<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" - xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" - odl:use-default-for-reference-types="true"> - - <bean id="propProvider" class="org.onap.ccsdk.sli.adaptors.resource.mdsal.MdsalResourcePropertiesProviderImpl" /> - - - <bean id="configResourceInstance" class="org.onap.ccsdk.sli.adaptors.resource.mdsal.ConfigResource"> - <argument ref="propProvider"/> - </bean> - - <bean id="operResourceInstance" class="org.onap.ccsdk.sli.adaptors.resource.mdsal.OperationalResource"> - <argument ref="propProvider"/> - </bean> - - <service ref="configResourceInstance"> - <interfaces> - <value>org.onap.ccsdk.sli.adaptors.resource.mdsal.ConfigResource</value> - </interfaces> - </service> - - <service ref="operResourceInstance"> - <interfaces> - <value>org.onap.ccsdk.sli.adaptors.resource.mdsal.OperationalResource</value> - </interfaces> - </service> -</blueprint> diff --git a/mdsal-resource/provider/src/main/resources/svclogic.properties b/mdsal-resource/provider/src/main/resources/svclogic.properties deleted file mode 100644 index 0abadc5c8..000000000 --- a/mdsal-resource/provider/src/main/resources/svclogic.properties +++ /dev/null @@ -1,26 +0,0 @@ -### -# ============LICENSE_START======================================================= -# openECOMP : SDN-C -# ================================================================================ -# Copyright (C) 2017 AT&T Intellectual Property. All rights -# reserved. -# ================================================================================ -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============LICENSE_END========================================================= -### - -org.onap.ccsdk.sli.adaptors.dbtype = jdbc -org.onap.ccsdk.sli.adaptors.jdbc.url = jdbc:mysql://dbhost:3306/sdnctl -org.onap.ccsdk.sli.adaptors.jdbc.database = sdnctl -org.onap.ccsdk.sli.adaptors.jdbc.user = sdnctl -org.onap.ccsdk.sli.adaptors.jdbc.password = gamma diff --git a/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResourceTest.java b/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResourceTest.java deleted file mode 100644 index f5b0bcf0c..000000000 --- a/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/ConfigResourceTest.java +++ /dev/null @@ -1,43 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.sli.adaptors.resource.mdsal; - -import org.junit.Test; -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicResource.QueryStatus; - -import static org.junit.Assert.assertEquals; - -public class ConfigResourceTest { - ConfigResource configResource = new ConfigResource("http", "local", - "10001", "admin", - "password"); - - @Test - public void isAvailableNegativeTest() throws SvcLogicException { - SvcLogicContext ctx = new SvcLogicContext(); - assertEquals(QueryStatus.NOT_FOUND, configResource.isAvailable - ("xyz", "key", "prefix", ctx)); - } -} - diff --git a/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestConfigResource.java b/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestConfigResource.java deleted file mode 100644 index 80563b96b..000000000 --- a/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestConfigResource.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.onap.ccsdk.sli.adaptors.resource.mdsal; - -import junit.framework.TestCase; - -import static org.mockito.Mockito.mock; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; -import static org.junit.Assert.assertNotNull; - -public class TestConfigResource extends TestCase { - - public void test() throws Exception { - - RestService restService = mock(RestService.class); - SvcLogicContext ctx = new SvcLogicContext(); - - ConfigResource res = new ConfigResource(restService); - - res.delete("my-resource", null, ctx); - res.notify("my-resource", "action", "key", ctx); - res.query("my-resource", false, "my-select", "mykey", "pfx", null, ctx); - res.release("my-resource", "mykey", ctx); - res.reserve("my-resource", "my-select", "mykey", "pfx", ctx); - res.exists("my-resource", "mykey", "pfx", ctx); - res.isAvailable("my-resource", "mykey", "pfx", ctx); - res.save("resource", false, false, null, null, null, ctx); - res.update("my-resource", "mykey", null, "pfx", ctx); - assertNotNull(res); - } - -} diff --git a/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestMdsalResourcePropertiesProviderImpl.java b/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestMdsalResourcePropertiesProviderImpl.java deleted file mode 100644 index 7f05d1e5f..000000000 --- a/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestMdsalResourcePropertiesProviderImpl.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * openECOMP : SDN-C - * ================================================================================ - * Copyright (C) 2018 Samsung. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.ccsdk.sli.adaptors.resource.mdsal; - -import org.junit.Before; -import org.junit.Test; - -import java.util.Properties; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -public class TestMdsalResourcePropertiesProviderImpl { - - MdsalResourcePropertiesProviderImpl mdsal; - - @Before - public void setup() { - mdsal = new MdsalResourcePropertiesProviderImpl(); - } - - - @Test - public void testGetProperties() { - Properties prop = mdsal.getProperties(); - - System.out.println("All Default Properties : " + prop); - - assertEquals("localhost",prop.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-host")); - assertEquals("Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U",prop.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-passwd")); - assertEquals("http",prop.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-protocol")); - assertEquals("8181",prop.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-port")); - assertEquals("admin",prop.getProperty("org.onap.ccsdk.sli.adaptors.resource.mdsal.sdnc-user")); - } - - - @Test - public void testGetPropertie() throws IllegalStateException, IllegalArgumentException { - MdsalResourcePropertiesProviderImpl test = new MdsalResourcePropertiesProviderImpl(); - - mdsal.determinePropertiesFile(test); - assertNotNull(test); - - } -} diff --git a/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestOperationalResource.java b/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestOperationalResource.java deleted file mode 100644 index 2e9798df1..000000000 --- a/mdsal-resource/provider/src/test/java/org/onap/ccsdk/sli/adaptors/resource/mdsal/TestOperationalResource.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.onap.ccsdk.sli.adaptors.resource.mdsal; - -import static org.mockito.Mockito.mock; - -import org.onap.ccsdk.sli.core.sli.SvcLogicContext; - -import junit.framework.TestCase; -import static org.junit.Assert.assertNotNull; - -public class TestOperationalResource extends TestCase { - - - public void test() throws Exception { - - RestService restService = mock(RestService.class); - SvcLogicContext ctx = new SvcLogicContext(); - - OperationalResource res = new OperationalResource(restService); - - res.delete("my-resource", null, ctx); - res.notify("my-resource", "action", "key", ctx); - res.query("my-resource", false, "my-select", "mykey", "pfx", null, ctx); - res.release("my-resource", "mykey", ctx); - res.reserve("my-resource", "my-select", "mykey", "pfx", ctx); - res.exists("my-resource", "mykey", "pfx", ctx); - res.isAvailable("my-resource", "mykey", "pfx", ctx); - res.save("resource", false, false, null, null, null, ctx); - res.update("my-resource", "mykey", null, "pfx", ctx); - assertNotNull(restService); - } -} |