diff options
Diffstat (limited to 'ECOMP-REST/src/main/java/org')
118 files changed, 14343 insertions, 0 deletions
diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/XACMLRest.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/XACMLRest.java new file mode 100644 index 000000000..7e535cbcf --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/XACMLRest.java @@ -0,0 +1,220 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest; + +import java.io.IOException; +import java.util.Enumeration; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import javax.servlet.ServletConfig; +import javax.servlet.http.HttpServletRequest; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + +import org.openecomp.policy.xacml.api.XACMLErrorConstants; +import com.att.research.xacml.util.XACMLProperties; + + +/** + * This static class is used by both the PDP and PAP servlet's. It contains some common + * static functions and objects used by both the servlet's. + * + * + */ +public class XACMLRest { + private static final Log logger = LogFactory.getLog(XACMLRest.class); + private static Properties restProperties = new Properties(); + + /** + * This must be called during servlet initialization. It sets up the xacml.?.properties + * file as a system property. If the System property is already set, then it does not + * do anything. This allows the developer to specify their own xacml.properties file to be + * used. They can 1) modify the default properties that comes with the project, or 2) change + * the WebInitParam annotation, or 3) specify an alternative path in the web.xml, or 4) set + * the Java System property to point to their xacml.properties file. + * + * The recommended way of overriding the default xacml.properties file is using a Java System + * property: + * + * -Dxacml.properties=/opt/app/xacml/etc/xacml.admin.properties + * + * This way one does not change any actual code or files in the project and can leave the + * defaults alone. + * + * @param config - The servlet config file passed from the javax servlet init() function + */ + public static void xacmlInit(ServletConfig config) { + // + // Get the XACML Properties File parameter first + // + String propFile = config.getInitParameter("XACML_PROPERTIES_NAME"); + if (propFile != null) { + // + // Look for system override + // + String xacmlPropertiesName = System.getProperty(XACMLProperties.XACML_PROPERTIES_NAME); + if (xacmlPropertiesName == null) { + // + // Set it to our servlet default + // + if (logger.isDebugEnabled()) { + logger.debug("Using Servlet Config Property for XACML_PROPERTIES_NAME:" + propFile); + } + System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, propFile); + } else { + if (logger.isDebugEnabled()) { + logger.debug("Using System Property for XACML_PROPERTIES_NAME:" + xacmlPropertiesName); + } + } + } + // + // Setup the remaining properties + // + Enumeration<String> params = config.getInitParameterNames(); + while (params.hasMoreElements()) { + String param = params.nextElement(); + if (! param.equals("XACML_PROPERTIES_NAME")) { + String value = config.getInitParameter(param); + //logger.info(param + "=" + config.getInitParameter(param)); + PolicyLogger.info(param + "=" + config.getInitParameter(param)); + restProperties.setProperty(param, value); + } + } + } + + /** + * Reset's the XACMLProperties internal properties object so we start + * in a fresh environment. Then adds back in our Servlet init properties that were + * passed in the javax Servlet init() call. + * + * This function is primarily used when a new configuration is passed in and the + * PDP servlet needs to load a new PDP engine instance. + * + * @param pipProperties - PIP configuration properties + * @param policyProperties - Policy configuration properties + */ + public static void loadXacmlProperties(Properties policyProperties, Properties pipProperties) { + try { + // + // Start fresh + // + XACMLProperties.reloadProperties(); + // + // Now load our init properties + // + XACMLProperties.getProperties().putAll(XACMLRest.restProperties); + // + // Load our policy properties + // + if (policyProperties != null) { + XACMLProperties.getProperties().putAll(policyProperties); + } + // + // Load our pip config properties + // + if (pipProperties != null) { + XACMLProperties.getProperties().putAll(pipProperties); + } + } catch (IOException e) { + //logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to put init properties into Xacml properties", e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Failed to put init properties into Xacml properties"); + } + // + // Dump them + // + if (logger.isDebugEnabled()) { + try { + logger.debug(XACMLProperties.getProperties().toString()); + } catch (IOException e) { + //logger.error( XACMLErrorConstants.ERROR_PROCESS_FLOW + "Cannot dump properties", e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Cannot dump properties"); + } + } + } + + /** + * Helper routine to dump the HTTP servlet request being serviced. Primarily for debugging. + * + * @param request - Servlet request (from a POST/GET/PUT/etc.) + */ + public static void dumpRequest(HttpServletRequest request) { + if (logger.isDebugEnabled()) { + // special-case for receiving heartbeat - don't need to repeatedly output all of the information in multiple lines + if (request.getMethod().equals("GET") && "hb".equals(request.getParameter("type")) ) { + //logger.debug("GET type=hb : heartbeat received"); + PolicyLogger.debug("GET type=hb : heartbeat received"); + return; + } + logger.debug(request.getMethod() + ":" + request.getRemoteAddr() + " " + request.getRemoteHost() + " " + request.getRemotePort()); + logger.debug(request.getLocalAddr() + " " + request.getLocalName() + " " + request.getLocalPort()); + Enumeration<String> en = request.getHeaderNames(); + logger.debug("Headers:"); + while (en.hasMoreElements()) { + String element = en.nextElement(); + Enumeration<String> values = request.getHeaders(element); + while (values.hasMoreElements()) { + String value = values.nextElement(); + logger.debug(element + ":" + value); + } + } + logger.debug("Attributes:"); + en = request.getAttributeNames(); + while (en.hasMoreElements()) { + String element = en.nextElement(); + logger.debug(element + ":" + request.getAttribute(element)); + } + logger.debug("ContextPath: " + request.getContextPath()); + if (request.getMethod().equals("PUT") || request.getMethod().equals("POST")) { + // POST and PUT are allowed to have parameters in the content, but in our usage the parameters are always in the Query string. + // More importantly, there are cases where the POST and PUT content is NOT parameters (e.g. it might contain a Policy file). + // Unfortunately the request.getParameterMap method reads the content to see if there are any parameters, + // and once the content is read it cannot be read again. + // Thus for PUT and POST we must avoid reading the content here so that the main code can read it. + logger.debug("Query String:" + request.getQueryString()); + try { + if (request.getInputStream() == null) { + logger.debug("Content: No content inputStream"); + } else { + logger.debug("Content available: " + request.getInputStream().available()); + } + } catch (Exception e) { + logger.debug("Content: inputStream exception: " + e.getMessage() + "; (May not be relevant)"); + } + } else { + logger.debug("Parameters:"); + Map<String, String[]> params = request.getParameterMap(); + Set<String> keys = params.keySet(); + for (String key : keys) { + String[] values = params.get(key); + logger.debug(key + "(" + values.length + "): " + (values.length > 0 ? values[0] : "")); + } + } + logger.debug("Request URL:" + request.getRequestURL()); + } + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/XACMLRestProperties.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/XACMLRestProperties.java new file mode 100644 index 000000000..bc991aafb --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/XACMLRestProperties.java @@ -0,0 +1,443 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest; + +import com.att.research.xacml.util.XACMLProperties; + +/** + * These are XACML Properties that are relevant to the RESTful API interface for + * the PDP, PAP and AC interfaces. + * + * + */ +public class XACMLRestProperties extends XACMLProperties { + /** + * A unique identifier for the PDP servlet instance. Usually set to the URL + * it is running as in the J2EE container. + * + * Eg. http://localhost:8080/pdp/ + */ + public static final String PROP_PDP_ID = "xacml.rest.pdp.id"; + /** + * A PDP servlet's configuration directory. Holds the pip and policy + * configuration data as well as the local policy cache. + * + * Eg: /opt/app/xacml/config + */ + public static final String PROP_PDP_CONFIG = "xacml.rest.pdp.config"; + // Resilience feature- + public static final String PROP_PDP_WEBAPPS = "xacml.rest.pdp.webapps"; + //Closed Loop JSON table + public static final String PROP_ADMIN_CLOSEDLOOP = "xacml.rest.admin.closedLoopJSON"; + /** + * Set this property to true or false if the PDP servlet should register + * itself upon startup with the PAP servlet. + */ + public static final String PROP_PDP_REGISTER = "xacml.rest.pdp.register"; + /** + * Number of seconds the PDP will sleep while retrying registration with the + * PAP. This value must be greater or equal to 5. + */ + public static final String PROP_PDP_REGISTER_SLEEP = "xacml.rest.pdp.register.sleep"; + /** + * Number of retry attempts at registration with the PAP. A value of -1 + * indicates infinite retries. + */ + public static final String PROP_PDP_REGISTER_RETRIES = "xacml.rest.pdp.register.retries"; + /** + * Max content length accepted for an incoming POST XML/JSON request. + * Default is 32767 bytes. + */ + public static final String PROP_PDP_MAX_CONTENT = "xacml.rest.pdp.maxcontent"; + /** + * Custom HTTP header used by PDP to send the value of the PROP_PDP_ID + */ + public static final String PROP_PDP_HTTP_HEADER_ID = "X-XACML-PDP-ID"; + /** + * Custom HHTP header used by PDP to send its heartbeat value. + */ + public static final String PROP_PDP_HTTP_HEADER_HB = "X-XACML-PDP-HB"; + /* + * Custom HTTP header used by PDP to send the value of the + * X-XACML-PDP-JMX-PORT + */ + public static final String PROP_PDP_HTTP_HEADER_JMX_PORT = "X-XACML-PDP-JMX-PORT"; + /** + * The URL of the PAP servlet. Used by PDP servlet's to communicate. Because + * administrators can set whatever context they want to run the PAP servlet, + * it isn't easy to determine a return URL for the PAP servlet. This is + * especially true upon initialization. + */ + public static final String PROP_PAP_URL = "xacml.rest.pap.url"; + /** + * A comma divided list of urls pointing to avaiable PAP urls. + * If one or more fail, the other servers in the list can + * handle the requests. + */ + public static final String PROP_PAP_URLS = "xacml.rest.pap.urls"; + public static final String PROP_PAP_FAILED_URLS = "xacml.rest.pap.failedUrls"; + public static final String PROP_PAP_SUCCEEDED_URLS = "xacml.rest.pap.succeededUrls"; + //public static final String PROP_PAP_FAILED_URL_TIME = "xacml.rest.pap.failedUrlTime"; + + /** + * Upon startup, have the PAP servlet send latest configuration information + * to all the PDP nodes it knows about. + */ + public static final String PROP_PAP_INITIATE_PDP_CONFIG = "xacml.rest.pap.initiate.pdp"; + /** + * The interval the PAP servlet uses to send heartbeat requests to the PDP + * nodes. + */ + public static final String PROP_PAP_HEARTBEAT_INTERVAL = "xacml.rest.pap.heartbeat.interval"; + /** + * Timeout value used by the PAP servlet when trying to check the heartbeat + * of a PDP node. + */ + public static final String PROP_PAP_HEARTBEAT_TIMEOUT = "xacml.rest.pap.heartbeat.timeout"; + /* + * This is the domain you can setup for your organization, it should be a URI. + * Eg. com:sample:foo + */ + public static final String PROP_PAP_DOMAIN = "xacml.rest.pap.domain"; + + /* + * Local path to where user workspaces exist. The user workspace contains temporary files, the + * user's clone of the GIT repository, anything specific to the user, etc. + */ + public static final String PROP_PAP_WORKSPACE = "xacml.rest.pap.workspace"; + + /* + * Local path to where the GIT repository exists. + * + * Eg. /opt/app/xacml/repository + */ + public static final String PROP_PAP_REPOSITORY = "xacml.rest.pap.repository"; + + /* + * Database driver property + */ + public static final String PROP_PAP_DB_DRIVER = "javax.persistence.jdbc.driver"; + + /* + * Database url + */ + public static final String PROP_PAP_DB_URL = "javax.persistence.jdbc.url"; + + /* + * Database user + */ + public static final String PROP_PAP_DB_USER = "javax.persistence.jdbc.user"; + + /* + * Database password + */ + public static final String PROP_PAP_DB_PASSWORD = "javax.persistence.jdbc.password"; + + /* + * Time in ms which a Policy DB transaction will wait to get the transaction lock object + */ + public static final String PROP_PAP_TRANS_WAIT = "xacml.rest.pap.transaction.waitms"; + + /* + * Policy DB transaction timeout in ms after it has obtained the transaction lock object + */ + public static final String PROP_PAP_TRANS_TIMEOUT = "xacml.rest.pap.transaction.timeoutms"; + + /* + * Policy Audit transaction timeout in ms after it has obtained the transaction lock object + */ + public static final String PROP_PAP_AUDIT_TIMEOUT = "xacml.rest.pap.audit.timeoutms"; + + /* + * Value determines direction of audit. Value=true will synch the file system to contents of the DB. + * Value=false will synch the DB to the contents of the file system. + */ + public static final String PROP_PAP_AUDIT_FLAG = "xacml.rest.pap.filesystem.audit"; + + /* + * Value for enable/disable of audit functionality + */ + public static final String PROP_PAP_RUN_AUDIT_FLAG = "xacml.rest.pap.run.audit.flag"; + + /* + * Controls how long the timeout will be when a pap sends a notification to another pap + */ + public static final String PROP_PAP_NOTIFY_TIMEOUT = "xacml.rest.pap.notify.timeoutms"; + /* + * Value for Enable/Disable of AutoPush Flag. + */ + public static final String PROP_PAP_PUSH_FLAG = "xacml.rest.pap.autopush.flag"; + + /* + * Properties file for the AutoPush Functionality. + */ + public static final String PROP_PAP_PUSH_FILE = "xacml.rest.pap.autopush.file"; + + /* + * Local path to where the GIT repository exists. + * + * Eg. /opt/app/xacml/repository + */ + public static final String PROP_ADMIN_REPOSITORY = "xacml.rest.admin.repository"; + /* + * Local path to where user workspaces exist. The user workspace contains + * temporary files, the user's clone of the GIT repository, anything + * specific to the user, etc. + */ + public static final String PROP_ADMIN_WORKSPACE = "xacml.rest.admin.workspace"; + /* + * This is the domain you can setup for your organization, it should be a + * URI. + * + * Eg. com:sample:foo + */ + public static final String PROP_ADMIN_DOMAIN = "xacml.rest.admin.domain"; + /** + * PROP_ADMIN_USER_NAME is simply a name for the logged in user. + * + * AC authentication is out the scope of the web application itself. It is + * up to the developer to setup authentication as they please in the J2EE + * container used to run the web application. Whatever authentication + * mechanism they use, they should then set the attribute into the + * HttpSession object. The Admin Console will be able to read that value + * (default to "guest") in. + * + * ((HttpServletRequest) + * request).getSession().setAttribute("xacml.rest.admin.user.name", + * "Homer"); + * + */ + public static final String PROP_ADMIN_USER_NAME = "xacml.rest.admin.user.name"; + /** + * + * PROP_ADMIN_USER_ID is an id for the logged in user. + * + * Eg. hs1234 + * + * @see #PROP_ADMIN_USER_NAME for more information. + */ + public static final String PROP_ADMIN_USER_ID = "xacml.rest.admin.user.id"; + /** + * + * PROP_ADMIN_USER_EMAIL is a user's email address. + * + * @see #PROP_ADMIN_USER_NAME for more information. + */ + public static final String PROP_ADMIN_USER_EMAIL = "xacml.rest.admin.user.email"; + /** + * Directory path containing sub-directories where the Subscriber servlet + * puts files sent through data feeds. + */ + public static final String PROP_SUBSCRIBER_INCOMING = "xacml.subscriber.incoming"; + /** + * The specific data feed name for the Subscriber servlet to register for. + */ + public static final String PROP_SUBSCRIBER_FEED = "xacml.subscriber.feed"; + /** + * Value for the log time frame that is to be stored in the database any + * logs after this time frame will be removed. + */ + public static final String PROP_LOG_TIMEFRAME = "xacml.log.timeframe"; + /** + * Value for the DB connections used to store the log files. + */ + public static final String PROP_LOG_DB_DRIVER = "xacml.log.db.driver"; + public static final String PROP_LOG_DB_URL = "xacml.log.db.url"; + public static final String PROP_LOG_DB_USER = "xacml.log.db.user"; + public static final String PROP_LOG_DB_PASSWORD = "xacml.log.db.password"; + /* + * Value for JMX port for the PDP + */ + public static final String PROP_PDP_JMX_PORT = "xacml.jmx.port"; + + /* + * Value for refresh rate + */ + public static final String PROP_REFRESH_RATE = "xacml.refresh.rate"; + + // added for Security between Policy Components. + // 6/26 + /* + * PROP_PAP_USERID is the PAP Unique User ID + */ + public static final String PROP_PAP_USERID = "xacml.rest.pap.userid"; + /* + * PROP_PAP_PASS is the PAP password + */ + public static final String PROP_PAP_PASS = "xacml.rest.pap.password"; + /* + * PROP_PAP_PASS is the PAP password + */ + public static final String PROP_CONFIG_URL = "xacml.rest.config.url"; + /* + * PROP_PDP_USERID is the PDP Unique User ID + */ + public static final String PROP_PDP_USERID = "xacml.rest.pdp.userid"; + /* + * PROP_PDP_PASS is the PDP password + */ + public static final String PROP_PDP_PASS = "xacml.rest.pdp.password"; + /* + * PROP_PDP_IDFILE is the PDP Authentication File + */ + public static final String PROP_PDP_IDFILE = "xacml.rest.pdp.idfile"; + /* + * PROP_PEP_IDFILE is the Client Authentication File + */ + public static final String PROP_PEP_IDFILE = "xacml.rest.pep.idfile"; + /* + * webapps Location of the PAP-REST server + */ + public static final String PROP_PAP_WEBAPPS= "xacml.rest.config.webapps"; + /* + * Value for Notification Option + */ + public static final String PROP_NOTIFICATION_TYPE = "xacml.notification.type"; + + /* + * Value for Notification Servers + */ + public static final String PROP_NOTIFICATION_UEB_CLUSTER = "xacml.ueb.cluster"; + /* + * Value for Notification Delay + */ + public static final String PROP_NOTIFICATION_DELAY= "xacml.rest.notification.delay"; + /* + * Closedloop Fault Policy Template Version + */ + public static final String TemplateVersion_Fault= "xacml.rest.closedLoopFault"; + /* + * Closedloop PM Policy Template Version + */ + public static final String TemplateVersion_PM= "xacml.rest.closedLoopPM"; + /* + * Value for model properties file + */ + public static final String PROP_ADMIN_MICROSERVICE = "xacml.rest.admin.microServiceModel"; + /* + * MicroService Policy Template Version + */ + public static final String TemplateVersion_MS= "xacml.rest.microServices"; + /* + * GOC Policy Template Version + */ + public static final String TemplateVersion_GOC= "xacml.rest.gocPolicy"; + /* + * Firewall Policy Template Version + */ + public static final String TemplateVersion_FW= "xacml.rest.firewallPolicy"; + /* + * Size of SelectList for Users in MS + * + */ + public static final String PROP_USER_SELECTLIST_WINDOW_SIZE= "xacml.user.column.count"; + /* + * Audit function in pap admin to Update userinfo table to syncronize with Roles table + */ + public static final String PROP_ROLES_USERINFO_AUDIT= "xacml.audit.userInfo"; + /* + * test Environment LoginId + */ + public static final String PROP_TEST_ENVIRONMENT_LOGINID= "xacml.testEnvironment.loginId"; + /* + * Size of of the page length for sqlcontainer + * + */ + public static final String PROP_SQLCONTAINER_PAGE_LENGTH= "xacml.sqlcontainer.page.length"; + /* + * add values used to connect to restful api + * + */ + public static final String PROP_RESTFUL_INTERFACE= "xacm.restful.interface.file"; + /* + * add pattern to identify what values are designed as required + * + */ + public static final String PROP_XCORE_REQUIRED_PATTERN= "xacm.xcor.required.pattern"; + /* + * Time before a cache value is evicted + * + */ + public static final String PROP_CACHE_LIVE_TIME= "xacm.cache.live.time"; + /* + * Highest value allowed in priority + * + */ + public static final String PROP_PRIORITY_COUNT= "xacml.max.priority.count"; + /* + * The name of the PAP. Must be unique across the system + */ + public static final String PAP_RESOURCE_NAME="xacml.rest.pap.resource.name"; + /* + * The name of the site in which the PAP resides + */ + public static final String PAP_SITE_NAME="site_name"; + /* + * The node type of the PAP - really a no-op since it's value is pap + */ + public static final String PAP_NODE_TYPE="node_type"; + /* + * A list of the groups of resources/nodes on which the PAP is dependent. The members of a + * group are comma-separated and the groups are separated with semicolons. + */ + public static final String PAP_DEPENDENCY_GROUPS="dependency_groups"; + /* + * The (optional) period of time in seconds between executions of the integrity audit. + * Value < 0 : Audit does not run (default value if property is not present = -1) + * Value = 0 : Audit runs continuously + * Value > 0 : The period of time in seconds between execution of the audit on a particular node + */ + public static final String PAP_INTEGRITY_AUDIT_PERIOD_SECONDS = "integrity_audit_period_seconds"; + /* + * The name of the Admin. Must be unique across the system + */ + public static final String ADMIN_RESOURCE_NAME="xacml.rest.admin.resource.name"; + /* + * The name of the PDP. Must be unique across the system + */ + public static final String PDP_RESOURCE_NAME="xacml.rest.pdp.resource.name"; + /* + * Audit function in pap admin to Update userinfo table to syncronize with Roles table + */ + public static final String PROP_AUTOMATIC_POLICYPUSH= "xacml.automatic.push"; + /* + * Add Limit for Ecomp Portal Dashboard tab data + */ + public static final String PROP_ECOMP_LOGLIMIT = "xacml.ecomp.dashboard.logTableLimit"; + public static final String PROP_ECOMP_SYSTEMALERTLIMIT = "xacml.ecomp.dashboard.systemAlertTableLimit"; + /* + * Diff of the policies for the Firewall Feature. + */ + public static final String PROP_FW_GETURL = "FW_GETURL"; + public static final String PROP_FW_AUTHOURL = "FW_AUTHOURL"; + public static final String PROP_FW_PROXY = "FW_PROXY"; + public static final String PROP_FW_PORT = "FW_PORT"; + + /* + * The number of Risk Levels allowed + */ + public static final String ADMIN_RISK_LEVEL_COUNT="xacml.risk.level.count"; + /* + * The maxium Level displayed on the UI for Micro Services + */ + public static final String PROP_MODEL_LEVEL = "xacml.model.level"; + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/XacmlAdminAuthorization.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/XacmlAdminAuthorization.java new file mode 100644 index 000000000..f611cf944 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/XacmlAdminAuthorization.java @@ -0,0 +1,223 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.jpa.UserInfo; + +import com.att.research.xacml.api.DataTypeException; +import com.att.research.xacml.api.Decision; +import com.att.research.xacml.api.Request; +import com.att.research.xacml.api.Response; +import com.att.research.xacml.api.Result; +import org.openecomp.policy.xacml.api.XACMLErrorConstants; +import com.att.research.xacml.api.pdp.PDPEngine; +import com.att.research.xacml.api.pdp.PDPEngineFactory; +import com.att.research.xacml.api.pdp.PDPException; +import com.att.research.xacml.std.annotations.RequestParser; +import com.att.research.xacml.std.annotations.XACMLAction; +import com.att.research.xacml.std.annotations.XACMLRequest; +import com.att.research.xacml.std.annotations.XACMLResource; +import com.att.research.xacml.std.annotations.XACMLSubject; +import com.att.research.xacml.util.FactoryException; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + +public class XacmlAdminAuthorization { + private static Log logger = LogFactory.getLog(XacmlAdminAuthorization.class); + + private static UserInfo userId; + public static UserInfo getUserId() { + return userId; + } + + public void setUserId(UserInfo userId) { + XacmlAdminAuthorization.userId = userId; + } + + public enum AdminAction { + ACTION_ACCESS("access"), + ACTION_READ("read"), + ACTION_WRITE("write"), + ACTION_ADMIN("admin"); + + String action; + AdminAction(String a) { + this.action = a; + } + public String toString() { + return this.action; + } + } + + public enum AdminResource { + RESOURCE_APPLICATION("application"), + RESOURCE_POLICY_WORKSPACE("workspace"), + RESOURCE_POLICY_EDITOR("editor"), + RESOURCE_DICTIONARIES("dictionaries"), + RESOURCE_PDP_ADMIN("pdp_admin"), + RESOURCE_PIP_ADMIN("pip_admin"), + RESOURCE_SCOPES_SUPERADMIN("manage_scopes"); + + String resource; + AdminResource(String r) { + this.resource = r; + } + public String toString() { + return this.resource; + } + } + + public enum Role { + ROLE_GUEST("guest"), + ROLE_ADMIN("admin"), + ROLE_EDITOR("editor"), + ROLE_SUPERGUEST("super-guest"), + ROLE_SUPEREDITOR("super-editor"), + ROLE_SUPERADMIN("super-admin"); + + String userRole; + + Role(String a) { + this.userRole = a; + } + public String toString() { + return this.userRole; + } + } + + @XACMLRequest(ReturnPolicyIdList=true) + public class AuthorizationRequest { + + @XACMLSubject(includeInResults=true) + String userID; + + @XACMLAction() + String action; + + @XACMLResource() + String resource; + + public AuthorizationRequest(String userId, String action, String resource) { + this.userID = userId; + this.action = action; + this.resource = resource; + } + + public String getUserID() { + return userID; + } + + public void setUserID(String userID) { + this.userID = userID; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getResource() { + return resource; + } + + public void setResource(String resource) { + this.resource = resource; + } + } + + // + // The PDP Engine + // + protected PDPEngine pdpEngine; + + public XacmlAdminAuthorization() { + PDPEngineFactory pdpEngineFactory = null; + try { + pdpEngineFactory = PDPEngineFactory.newInstance(); + if (pdpEngineFactory == null) { + logger.error("Failed to create PDP Engine Factory"); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error("Failed to create PDP Engine Factory"); + } + this.pdpEngine = pdpEngineFactory.newEngine(); + } catch (FactoryException e) { + logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Exception create PDP Engine: " + e.getLocalizedMessage()); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "XacmlAdminAuthorization", "Exception create PDP Engine"); + } + } + + public boolean isAuthorized(String userid, AdminAction action, AdminResource resource) { + logger.info("authorize: " + userid + " to " + action + " with " + resource); + if (this.pdpEngine == null) { + logger.warn("no pdp engine available to authorize"); + return false; + } + Request request; + try { + request = RequestParser.parseRequest(new AuthorizationRequest(userid, action.toString(), resource.toString())); + } catch (IllegalArgumentException | IllegalAccessException | DataTypeException e) { + logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to create request: " + e.getLocalizedMessage()); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "XacmlAdminAuthorization", "Failed to create request"); + return false; + } + if (request == null) { + logger.error("Failed to parse request."); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error("Failed to parse request"); + return false; + } + logger.info("Request: " + request); + // + // Ask the engine + // + try { + Response response = this.pdpEngine.decide(request); + if (response == null) { + logger.error("Null response from PDP decide"); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error("Null response from PDP decide"); + } + // + // Should only be one result + // + for (Result result : response.getResults()) { + Decision decision = result.getDecision(); + logger.info("Decision: " + decision); + if (decision.equals(Decision.PERMIT)) { + return true; + } + } + } catch (PDPException e) { + logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "PDP Decide failed: " + e.getLocalizedMessage()); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "XacmlAdminAuthorization", "PDP Decide failed"); + } + return false; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ActionListDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ActionListDao.java new file mode 100644 index 000000000..b8aa2948a --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ActionListDao.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.ActionList; + +public interface ActionListDao { + List<ActionList> getActionListData(); + List<String> getActionListDataByName(); + void Save(ActionList actionList); + void delete(ActionList actionList); + void update(ActionList actionList); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ActionPolicyDictDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ActionPolicyDictDao.java new file mode 100644 index 000000000..c4914eb47 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ActionPolicyDictDao.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.ActionPolicyDict; + +public interface ActionPolicyDictDao { + List<ActionPolicyDict> getActionDictData(); + List<String> getActionDictDataByName(); + ActionPolicyDict getActionEntityDatabyId(String action); + void Save(ActionPolicyDict action); + void delete(ActionPolicyDict action); + void update(ActionPolicyDict action); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/AddressGroupDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/AddressGroupDao.java new file mode 100644 index 000000000..c4c7002b3 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/AddressGroupDao.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.AddressGroup; + +public interface AddressGroupDao { + List<AddressGroup> getAddressGroupData(); + List<String> getAddressGroupDataByName(); + void Save(AddressGroup addressGroup); + void delete(AddressGroup addressGroup); + void update(AddressGroup addressGroup); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/AttributeDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/AttributeDao.java new file mode 100644 index 000000000..796157f62 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/AttributeDao.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.Attribute; + +public interface AttributeDao { + + List<Attribute> getData(); + List<String> getAttributeData(); + void Save(Attribute attribute); + void delete(Attribute attribute); + void update(Attribute attribute); + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/BRMSParamTemplateDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/BRMSParamTemplateDao.java new file mode 100644 index 000000000..2c03192c0 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/BRMSParamTemplateDao.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.BRMSParamTemplate; + +public interface BRMSParamTemplateDao { + List<BRMSParamTemplate> getBRMSParamTemplateData(); + List<String> getBRMSParamDataByName(); + void Save(BRMSParamTemplate brmsParam); + void delete(BRMSParamTemplate brmsParam); + void update(BRMSParamTemplate brmsParam); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/CategoryDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/CategoryDao.java new file mode 100644 index 000000000..e90aa1d8b --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/CategoryDao.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.Category; + +public interface CategoryDao { + List<Category> getCategoryListData(); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/DCAEUUIDDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/DCAEUUIDDao.java new file mode 100644 index 000000000..418d77629 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/DCAEUUIDDao.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.DCAEuuid; + +public interface DCAEUUIDDao { + List<DCAEuuid> getDCAEuuidData(); + List<String> getDCAEuuidDataByName(); + void Save(DCAEuuid dcaeUUID); + void delete(DCAEuuid dcaeUUID); + void update(DCAEuuid dcaeUUID); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/DecisionPolicyDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/DecisionPolicyDao.java new file mode 100644 index 000000000..372a1fb7c --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/DecisionPolicyDao.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.DecisionSettings; + +public interface DecisionPolicyDao { + List<DecisionSettings> getDecisionSettingsData(); + List<String> getDecisionDataByName(); + void Save(DecisionSettings decisionSettings); + void delete(DecisionSettings decisionSettings); + void update(DecisionSettings decisionSettings); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/DescriptiveScopeDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/DescriptiveScopeDao.java new file mode 100644 index 000000000..b0001390e --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/DescriptiveScopeDao.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.DescriptiveScope; + +public interface DescriptiveScopeDao { + + List<DescriptiveScope> getDescriptiveScope(); + List<String> getDescriptiveScopeDataByName(); + void Save(DescriptiveScope descriptiveScope); + void delete(DescriptiveScope descriptiveScope); + void update(DescriptiveScope descriptiveScope); + DescriptiveScope getDescriptiveScopeById(String name); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/EcompNameDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/EcompNameDao.java new file mode 100644 index 000000000..420121883 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/EcompNameDao.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.EcompName; + +public interface EcompNameDao { + List<EcompName> getEcompName(); + List<String> getEcompNameDataByName(); + void Save(EcompName ecompName); + void delete(EcompName ecompName); + void update(EcompName ecompName); + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/EnforcerPolicyDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/EnforcerPolicyDao.java new file mode 100644 index 000000000..55f4bf599 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/EnforcerPolicyDao.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.EnforcingType; + +public interface EnforcerPolicyDao { + List<EnforcingType> getEnforcingTypeData(); + void Save(EnforcingType enforcingType); + void delete(EnforcingType enforcingType); + void update(EnforcingType enforcingType); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/FirewallDictionaryListDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/FirewallDictionaryListDao.java new file mode 100644 index 000000000..76cb1bc1f --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/FirewallDictionaryListDao.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.FirewallDictionaryList; + + +public interface FirewallDictionaryListDao { + List<FirewallDictionaryList> getFWDictionaryListData(); + List<String> getFWDictionaryListDataByName(); + void Save(FirewallDictionaryList firewallDictionaryList); + void delete(FirewallDictionaryList firewallDictionaryList); + void update(FirewallDictionaryList firewallDictionaryList); + void updateQuery(String query); + FirewallDictionaryList getFWDictionaryDataById(String value); +} + diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/GroupPolicyScopeListDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/GroupPolicyScopeListDao.java new file mode 100644 index 000000000..fdab28a0f --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/GroupPolicyScopeListDao.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.GroupPolicyScopeList; + +public interface GroupPolicyScopeListDao{ + List<GroupPolicyScopeList> getGroupPolicyScopeListData(); + List<String> getGroupPolicyScopeListDataByName(); + void Save(GroupPolicyScopeList attribute); + void delete(GroupPolicyScopeList attribute); + void update(GroupPolicyScopeList attribute); + List<GroupPolicyScopeList> CheckDuplicateEntry(String value); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/MicroServiceConfigNameDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/MicroServiceConfigNameDao.java new file mode 100644 index 000000000..f0321031c --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/MicroServiceConfigNameDao.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.MicroServiceConfigName; + +public interface MicroServiceConfigNameDao { + List<MicroServiceConfigName> getMicroServiceConfigNameData(); + List<String> getMSConfigDataByName(); + void Save(MicroServiceConfigName microServiceConfigName); + void delete(MicroServiceConfigName microServiceConfigName); + void update(MicroServiceConfigName microServiceConfigName); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/MicroServiceLocationDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/MicroServiceLocationDao.java new file mode 100644 index 000000000..fdb9c559e --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/MicroServiceLocationDao.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.MicroServiceLocation; + +public interface MicroServiceLocationDao { + List<MicroServiceLocation> getMicroServiceLocationData(); + List<String> getMSLocationDataByName(); + void Save(MicroServiceLocation microServiceLocation); + void delete(MicroServiceLocation microServiceLocation); + void update(MicroServiceLocation microServiceLocation); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/MicroServiceModelsDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/MicroServiceModelsDao.java new file mode 100644 index 000000000..0a56edd2c --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/MicroServiceModelsDao.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.MicroServiceModels; + +public interface MicroServiceModelsDao { + List<MicroServiceModels> getMicroServiceModelsData(); + List<String> getMSModelsDataByName(); + void Save(MicroServiceModels microServiceModels); + void delete(MicroServiceModels microServiceModels); + void update(MicroServiceModels microServiceModels); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PEPOptionsDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PEPOptionsDao.java new file mode 100644 index 000000000..d1bbf2a1a --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PEPOptionsDao.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.PEPOptions; + + + +public interface PEPOptionsDao { + List<PEPOptions> getPEPOptionsData(); + List<String> getPEPOptionsDataByName(); + void Save(PEPOptions pepOptions); + void delete(PEPOptions pepOptions); + void update(PEPOptions pepOptions); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PolicyScopeClosedLoopDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PolicyScopeClosedLoopDao.java new file mode 100644 index 000000000..7730adacb --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PolicyScopeClosedLoopDao.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.PolicyScopeClosedLoop; + +public interface PolicyScopeClosedLoopDao { + List<PolicyScopeClosedLoop> getPolicyScopeClosedLoopData(); + List<String> getPolicyScopeClosedLoopDataByName(); + void Save(PolicyScopeClosedLoop attribute); + void delete(PolicyScopeClosedLoop attribute); + void update(PolicyScopeClosedLoop attribute); + List<PolicyScopeClosedLoop> CheckDuplicateEntry(String value); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PolicyScopeResourceDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PolicyScopeResourceDao.java new file mode 100644 index 000000000..4ff88fed8 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PolicyScopeResourceDao.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.PolicyScopeResource; + +public interface PolicyScopeResourceDao { + List<PolicyScopeResource> getPolicyScopeResourceData(); + List<String> getPolicyScopeResourceDataByName(); + void Save(PolicyScopeResource attribute); + void delete(PolicyScopeResource attribute); + void update(PolicyScopeResource attribute); + List<PolicyScopeResource> CheckDuplicateEntry(String value); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PolicyScopeServiceDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PolicyScopeServiceDao.java new file mode 100644 index 000000000..2a5c8c565 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PolicyScopeServiceDao.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.PolicyScopeService; + +public interface PolicyScopeServiceDao { + List<PolicyScopeService> getPolicyScopeServiceData(); + List<String> getPolicyScopeServiceDataByName(); + void Save(PolicyScopeService attribute); + void delete(PolicyScopeService attribute); + void update(PolicyScopeService attribute); + List<PolicyScopeService> CheckDuplicateEntry(String value); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PolicyScopeTypeDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PolicyScopeTypeDao.java new file mode 100644 index 000000000..e49f84cec --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PolicyScopeTypeDao.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.PolicyScopeType; + +public interface PolicyScopeTypeDao { + List<PolicyScopeType> getPolicyScopeTypeData(); + List<String> getPolicyScopeTypeDataByName(); + void Save(PolicyScopeType attribute); + void delete(PolicyScopeType attribute); + void update(PolicyScopeType attribute); + List<PolicyScopeType> CheckDuplicateEntry(String value); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PortListDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PortListDao.java new file mode 100644 index 000000000..461387f4a --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PortListDao.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.PortList; + +public interface PortListDao { + List<PortList> getPortListData(); + List<String> getPortListDataByName(); + void Save(PortList portList); + void delete(PortList portList); + void update(PortList portList); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PrefixListDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PrefixListDao.java new file mode 100644 index 000000000..29571dddb --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/PrefixListDao.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.PREFIXLIST; + +public interface PrefixListDao { + List<PREFIXLIST> getPREFIXLISTData(); + List<String> getPrefixListDataByName(); + void Save(PREFIXLIST prefixList); + void delete(PREFIXLIST prefixList); + void update(PREFIXLIST prefixList); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ProtocolListDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ProtocolListDao.java new file mode 100644 index 000000000..11956ee94 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ProtocolListDao.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.ProtocolList; + +public interface ProtocolListDao { + List<ProtocolList> getProtocolListData(); + List<String> getProtocolListDataByName(); + void Save(ProtocolList protocolList); + void delete(ProtocolList protocolList); + void update(ProtocolList protocolList); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/RiskTypeDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/RiskTypeDao.java new file mode 100644 index 000000000..6c14928d8 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/RiskTypeDao.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.RiskType; + +public interface RiskTypeDao { + List<RiskType> getRiskName(); + List<String> getRiskTypeDataByName(); + void Save(RiskType riskName); + void delete(RiskType riskName); + void update(RiskType riskName); + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/SafePolicyWarningDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/SafePolicyWarningDao.java new file mode 100644 index 000000000..3812f9470 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/SafePolicyWarningDao.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.SafePolicyWarning; + +public interface SafePolicyWarningDao{ + List<SafePolicyWarning> getSafePolicyWarningData(); + List<String> getSafePolicyWarningDataByName(); + void Save(SafePolicyWarning attribute); + void delete(SafePolicyWarning attribute); + void update(SafePolicyWarning attribute); + SafePolicyWarning getSafePolicyWarningDataById(String riskType); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/SecurityZoneDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/SecurityZoneDao.java new file mode 100644 index 000000000..4367023b5 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/SecurityZoneDao.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.SecurityZone; + +public interface SecurityZoneDao { + List<SecurityZone> getSecurityZoneData(); + List<String> getSecurityZoneDataByName(); + void Save(SecurityZone securityZone); + void delete(SecurityZone securityZone); + void update(SecurityZone securityZone); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ServiceDictionaryDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ServiceDictionaryDao.java new file mode 100644 index 000000000..a756f3234 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ServiceDictionaryDao.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.ClosedLoopD2Services; + +public interface ServiceDictionaryDao { + List<ClosedLoopD2Services> getClosedLoopD2ServicesData(); + List<String> getCLServiceDictDataByName(); + void Save(ClosedLoopD2Services closedLoopD2Services); + void delete(ClosedLoopD2Services closedLoopD2Services); + void update(ClosedLoopD2Services closedLoopD2Services); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ServiceGroupDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ServiceGroupDao.java new file mode 100644 index 000000000..678c6426a --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ServiceGroupDao.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.GroupServiceList; + +public interface ServiceGroupDao { + List<GroupServiceList> getGroupServiceListData(); + List<String> getGroupServiceDataByName(); + void Save(GroupServiceList groupServiceList); + void delete(GroupServiceList groupServiceList); + void update(GroupServiceList groupServiceList); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ServiceListDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ServiceListDao.java new file mode 100644 index 000000000..116f9cb17 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ServiceListDao.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.ServiceList; + + +public interface ServiceListDao { + List<ServiceList> getServiceListData(); + List<String> getServiceListDataByName(); + void Save(ServiceList serviceList); + void delete(ServiceList serviceList); + void update(ServiceList serviceList); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/SiteDictionaryDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/SiteDictionaryDao.java new file mode 100644 index 000000000..21cae69b9 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/SiteDictionaryDao.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.ClosedLoopSite; + +public interface SiteDictionaryDao { + List<ClosedLoopSite> getClosedLoopSiteData(); + List<String> getCLSiteDataByName(); + void Save(ClosedLoopSite closedLoopSite); + void delete(ClosedLoopSite closedLoopSite); + void update(ClosedLoopSite closedLoopSite); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/TermListDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/TermListDao.java new file mode 100644 index 000000000..c2c81cfd8 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/TermListDao.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.TermList; + +public interface TermListDao { + List<TermList> getTermListData(); + List<String> getTermListDataByName(); + void Save(TermList termList); + void delete(TermList termList); + void update(TermList termList); + TermList getTermListValueByName(String name); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/UserInfoDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/UserInfoDao.java new file mode 100644 index 000000000..a144a463f --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/UserInfoDao.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.UserInfo; + +public interface UserInfoDao { + void save(UserInfo userInfo); + List<UserInfo> getUserInfo(); + UserInfo getUserInfoByLoginId(String loginid); + String getUserName(String loginid); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/VNFTypeDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/VNFTypeDao.java new file mode 100644 index 000000000..ff68a4065 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/VNFTypeDao.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.VNFType; + +public interface VNFTypeDao { + List<VNFType> getVNFTypeData(); + List<String> getVNFTypeDataByName(); + void Save(VNFType vnfType); + void delete(VNFType vnfType); + void update(VNFType vnfType); + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/VSCLActionDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/VSCLActionDao.java new file mode 100644 index 000000000..3d0245555 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/VSCLActionDao.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.VSCLAction; + + + +public interface VSCLActionDao { + List<VSCLAction> getVSCLActionData(); + List<String> getVsclActionDataByName(); + void Save(VSCLAction vSCLAction); + void delete(VSCLAction vSCLAction); + void update(VSCLAction vSCLAction); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/VarbindDictionaryDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/VarbindDictionaryDao.java new file mode 100644 index 000000000..f3153f6df --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/VarbindDictionaryDao.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.VarbindDictionary; + +public interface VarbindDictionaryDao { + List<VarbindDictionary> getVarbindDictionaryData(); + List<VarbindDictionary> getVarbindEntityByName(String value); + List<String> getVarbindDataByName(); + void Save(VarbindDictionary varbindDictionary); + void delete(VarbindDictionary varbindDictionary); + void update(VarbindDictionary varbindDictionary); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ZoneDao.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ZoneDao.java new file mode 100644 index 000000000..df318e167 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/ZoneDao.java @@ -0,0 +1,33 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; + +import java.util.List; + +import org.openecomp.policy.rest.jpa.Zone; + +public interface ZoneDao { + List<Zone> getZoneData(); + List<String> getZoneDataByName(); + void Save(Zone zone); + void delete(Zone zone); + void update(Zone zone); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/package-info.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/package-info.java new file mode 100644 index 000000000..c9f449f4f --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/dao/package-info.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.dao; diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionBodyEntity.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionBodyEntity.java new file mode 100644 index 000000000..d12f6b3e1 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionBodyEntity.java @@ -0,0 +1,198 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Lob; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Version; +/* + * The Entity class to persist a policy object Action Body + */ + +import com.fasterxml.jackson.annotation.JsonBackReference; + +@Entity +@Table(name="ActionBodyEntity") +@NamedQueries({ + @NamedQuery(name=" ActionBodyEntity.findAll", query="SELECT e FROM ActionBodyEntity e "), + @NamedQuery(name="ActionBodyEntity.deleteAll", query="DELETE FROM ActionBodyEntity WHERE 1=1") +}) +//@SequenceGenerator(name="seqActBody", initialValue=1, allocationSize=1) + +public class ActionBodyEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqActBody") + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="actionBodyId") + @JsonBackReference + private long actionBodyId; + + @Column(name="actionBodyName", nullable=false, length=255) + private String actionBodyName = ""; + + @Version + @Column(name="version") + private int version; + + @Lob + @Column(name="actionBody", nullable=false, columnDefinition="TEXT") + private String actionBody = "NoBody"; + + @Column(name="created_by", nullable=false, length=255) + private String createdBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="modified_by", nullable=false, length=255) + private String modifiedBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @Column(name="deleted", nullable=false) + private boolean deleted = false; + + public ActionBodyEntity() { + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + /** + * @return the configurationDataId + */ + public long getActionBodyId() { + return actionBodyId; + } + /** + * @param configurationDataId the configurationDataId to set + */ + public void setActionBodyName(String name) { + this.actionBodyName = name; + } + public String getActionBodyName(){ + return this.actionBodyName; + } + + /** + * @return the actionBody + */ + public String getActionBody() { + return actionBody; + } + /** + * @param configBody the configBody to set + */ + public void setActionBody(String body) { + this.actionBody = body; + } + /** + * @return the createdBy + */ + public String getCreatedBy() { + return createdBy; + } + /** + * @param createdBy the createdBy to set + */ + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * @return the modifiedBy + */ + public String getModifiedBy() { + return modifiedBy; + } + /** + * @param modifiedBy the modifiedBy to set + */ + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + /** + * @return the modifiedDate + */ + public Date getModifiedDate() { + return modifiedDate; + } + /** + * @param modifiedDate the modifiedDate to set + */ + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + /** + * @return the version + */ + public int getVersion() { + return version; + } + /** + * @return the createdDate + */ + public Date getCreatedDate() { + return createdDate; + } + + /** + * @return the deleted + */ + public boolean isDeleted() { + return deleted; + } + + /** + * @param deleted the deleted to set + */ + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionList.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionList.java new file mode 100644 index 000000000..0176c17be --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionList.java @@ -0,0 +1,106 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name="actionlist") +@NamedQuery(name="ActionList.findAll", query="SELECT e FROM ActionList e ") +public class ActionList implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="actionname", nullable=false) + @OrderBy("asc") + private String actionName; + + @Column(name="description") + private String description; +/* + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate;*/ + + public ActionList() { + + } + public ActionList(String string, String userid) { + this(domain); + + } + public ActionList(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + public String getActionName() { + return this.actionName; + } + + public void setActionName(String actionName) { + this.actionName = actionName; + + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionPolicyDict.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionPolicyDict.java new file mode 100644 index 000000000..fa7d2af95 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ActionPolicyDict.java @@ -0,0 +1,215 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + +@Entity +@Table(name="ActionPolicyDict") +//@NamedQuery(name="ActionPolicyDict.findAll", query="SELECT e FROM ActionPolicyDict e ") +@NamedQueries({ + @NamedQuery(name="ActionPolicyDict.findAll", query="SELECT e FROM ActionPolicyDict e") +}) +public class ActionPolicyDict implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="ATTRIBUTE_NAME", nullable=false) + @OrderBy("asc") + private String attributeName; + + @Column(name="Type", nullable=false) + @OrderBy("asc") + private String type; + + @Column(name="URL", nullable=false) + @OrderBy("asc") + private String url; + + @Column(name="Method", nullable=false) + @OrderBy("asc") + private String method; + + @Column(name="Headers", nullable=true) + @OrderBy("asc") + private String header; + + @Column(name="Body", nullable=true) + @OrderBy("asc") + private String body; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(ActionPolicyDict.class); + public ActionPolicyDict() { + + } + + public ActionPolicyDict(String string, String userid) { + this(string); + } + + public ActionPolicyDict(String domain) { + this.type = domain; + } + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "ActionPolicyDict", "Exception caused While adding Modified by Role"); + } + } + public int getId() { + return this.id; + } + public void setId(int id) { + this.id = id; + } + + public Date getCreatedDate() { + return this.createdDate; + } + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + public String getDescription() { + return this.description; + } + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + public String getUrl() { + return url; + } + public void setUrl(String url) { + this.url = url; + } + public String getMethod() { + return method; + } + public void setMethod(String method) { + this.method = method; + } + public String getHeader() { + return header; + } + public void setHeader(String header) { + this.header = header; + } + + public String getBody() { + return body; + } + public void setBody(String body) { + this.body = body; + } + public String getAttributeName() { + return attributeName; + } + public void setAttributeName(String attributeName) { + this.attributeName = attributeName; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/AddressGroup.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/AddressGroup.java new file mode 100644 index 000000000..6418d6bc5 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/AddressGroup.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + +@Entity +@Table(name="AddressGroup") +@NamedQuery(name="AddressGroup.findAll", query="SELECT e FROM AddressGroup e ") +public class AddressGroup implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="prefixlist") + private String prefixList; + + + @Column(name="description") + private String description; + + public AddressGroup() { + + } + public AddressGroup(String string, String userid) { + this(domain); + + } + public AddressGroup(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getGroupName() { + return this.name; + } + + public void setGroupName(String serviceName) { + this.name = serviceName; + + } + + public String getPrefixList() { + return this.prefixList; + } + + public void setServiceList(String prefixList) { + this.prefixList = prefixList; + + } + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Attribute.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Attribute.java new file mode 100644 index 000000000..e79126ae2 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Attribute.java @@ -0,0 +1,376 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; +import org.openecomp.policy.rest.jpa.UserInfo; + +import com.att.research.xacml.api.Identifier; +import com.att.research.xacml.std.IdentifierImpl; +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonManagedReference; + +/** + * The persistent class for the Attribute database table. + * + */ +@Entity +@Table(name="Attribute") +@NamedQuery(name="Attribute.findAll", query="SELECT a FROM Attribute a order by a.priority asc, a.xacmlId asc") +public class Attribute implements Serializable { + private static final long serialVersionUID = 1L; + + public static String ATTRIBUTE_DESIGNATOR = "Attribute Designator"; + public static String ATTRIBUTE_SELECTOR = "Attribute Selector"; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + //bi-directional many-to-one association to Category + @ManyToOne + @JoinColumn(name="constraint_type", nullable=true) + @JsonIgnore + private ConstraintType constraintType; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @Column(name="PRIORITY", nullable=true) + @OrderBy("asc") + private String priority; + + @Column(name="ATTRIBUTE_VALUE", nullable=true) + @OrderBy("asc") + private String attributeValue; + + @Column(name="xacml_id", unique = true, nullable=false) + @OrderBy("asc") + private String xacmlId = "urn"; + + //bi-directional many-to-one association to ConstraintValue + @OneToMany(mappedBy="attribute", orphanRemoval=true, cascade=CascadeType.REMOVE) + @JsonIgnore + private Set<ConstraintValue> constraintValues = new HashSet<ConstraintValue>(); + + //bi-directional many-to-one association to Category + @ManyToOne + @JoinColumn(name="category") + @JsonIgnore + private Category categoryBean; + + //bi-directional many-to-one association to Datatype + @ManyToOne + @JoinColumn(name="datatype") + private Datatype datatypeBean; + + @Column(name="is_designator", nullable=false) + @JsonIgnore + private char isDesignator = '1'; + + @Column(name="selector_path", nullable=true, length=2048) + private String selectorPath; + + + + @Transient + private String issuer = null; + + @Transient + private boolean mustBePresent = false; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(Attribute.class); + public Attribute() { + } + + public Attribute(String domain) { + this.xacmlId = domain; + } + + public Attribute(String domain, String user) { + this(domain); + } + + public Attribute(Attribute copy, String user) { + this(copy.getXacmlId() + ":(0)", user); + this.constraintType = copy.getConstraintType(); + this.categoryBean = copy.getCategoryBean(); + this.datatypeBean = copy.getDatatypeBean(); + this.description = copy.getDescription(); + for (ConstraintValue value : copy.getConstraintValues()) { + ConstraintValue newValue = new ConstraintValue(value); + newValue.setAttribute(this); + this.addConstraintValue(newValue); + } + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy = XacmlAdminAuthorization.getUserId(); + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + //PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "Attribute", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public ConstraintType getConstraintType() { + return this.constraintType; + } + + public void setConstraintType(ConstraintType constraintType) { + this.constraintType = constraintType; + } + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + + public String getXacmlId() { + return this.xacmlId; + } + +/* @Transient + public Identifier getXacmlIdentifier() { + return new IdentifierImpl(this.xacmlId); + }*/ + + public void setXacmlId(String xacmlId) { + this.xacmlId = xacmlId; + } + + public Set<ConstraintValue> getConstraintValues() { + return this.constraintValues; + } + + public void setConstraintValues(Set<ConstraintValue> constraintValues) { + for (ConstraintValue value : this.constraintValues) { + value.setAttribute(this); + } + this.constraintValues = constraintValues; + } + + public ConstraintValue addConstraintValue(ConstraintValue constraintValue) { + if (this.constraintValues == null) { + this.constraintValues = new HashSet<ConstraintValue>(); + } + this.constraintValues.add(constraintValue); + constraintValue.setAttribute(this); + + return constraintValue; + } + + public ConstraintValue removeConstraintValue(ConstraintValue constraintValue) { + this.constraintValues.remove(constraintValue); + constraintValue.setAttribute(null); + + return constraintValue; + } + + public void removeAllConstraintValues() { + if (this.constraintValues == null) { + return; + } + for (ConstraintValue value : this.constraintValues) { + value.setAttribute(null); + } + this.constraintValues.clear(); + } + + public Category getCategoryBean() { + return this.categoryBean; + } + + public void setCategoryBean(Category categoryBean) { + this.categoryBean = categoryBean; + } + + public Datatype getDatatypeBean() { + return this.datatypeBean; + } + + public void setDatatypeBean(Datatype datatypeBean) { + this.datatypeBean = datatypeBean; + } + + public char getIsDesignator() { + return this.isDesignator; + } + + public void setIsDesignator(char is) { + this.isDesignator = is; + } + + public String getSelectorPath() { + return this.selectorPath; + } + + public void setSelectorPath(String path) { + this.selectorPath = path; + } + + @Transient + public String getIssuer() { + return issuer; + } + + @Transient + public void setIssuer(String issuer) { + this.issuer = issuer; + } + + @Transient + public boolean isMustBePresent() { + return mustBePresent; + } + + @Transient + public void setMustBePresent(boolean mustBePresent) { + this.mustBePresent = mustBePresent; + } + + @Transient + public boolean isDesignator() { + return (this.isDesignator == '1'); + } + + @Transient + public void setIsDesignator(boolean is) { + if (is) { + this.isDesignator = '1'; + } else { + this.isDesignator = '0'; + } + } + + public String getPriority() { + return priority; + } + + public void setPriority(String priority) { + this.priority = priority; + } + + public String getAttributeValue() { + return attributeValue; + } + + public void setAttributeValue(String attributeValue) { + this.attributeValue = attributeValue; + } +} + diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/AttributeAssignment.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/AttributeAssignment.java new file mode 100644 index 000000000..1e81213d3 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/AttributeAssignment.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.Table; + + +/** + * The persistent class for the ObadviceExpressions database table. + * + */ +@Entity +@Table(name="AttributeAssignment") +@NamedQuery(name="AttributeAssignment.findAll", query="SELECT a FROM AttributeAssignment a") +public class AttributeAssignment implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String EXPRESSION_APPLY = "Apply"; + public static final String EXPRESSION_SELECTOR = "AttributeSelector"; + public static final String EXPRESSION_VALUE = "AttributeValue"; + public static final String EXPRESSION_FUNCTION = "Function"; + public static final String EXPRESSION_REFERENCE = "VarableReference"; + public static final String EXPRESSION_DESIGNATOR = "AttributeDesignator"; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="attribute_id") + private int attributeId; + + //bi-directional many-to-one association to Obadvice + @Column(name="expression", nullable=false) + private String expression; + + //bi-directional many-to-one association to Obadvice + @ManyToOne + private Obadvice obadvice; + + public AttributeAssignment() { + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public int getAttributeId() { + return this.attributeId; + } + + public void setAttributeId(int attributeId) { + this.attributeId = attributeId; + } + + public String getExpression() { + return expression; + } + + public void setExpression(String expression) { + this.expression = expression; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/BRMSParamTemplate.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/BRMSParamTemplate.java new file mode 100644 index 000000000..54661de0c --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/BRMSParamTemplate.java @@ -0,0 +1,142 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.Lob; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.openecomp.policy.rest.jpa.UserInfo; + +/* + * JPA for the BRMS Param Template. + * + * @version: 0.1 + */ + + +@Entity +@Table(name="BRMSParamTemplate") +@NamedQuery(name="BRMSParamTemplate.findAll", query="SELECT b FROM BRMSParamTemplate b ") +public class BRMSParamTemplate implements Serializable{ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="param_template_name", nullable=false, unique=true) + @OrderBy("asc") + private String ruleName; + + @Lob + @Column(name="rule",nullable=false) + private String rule; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public BRMSParamTemplate(){ + } + + public BRMSParamTemplate(String userid){ + + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getRule(){ + return this.rule; + } + + public void setRule(String rule){ + this.rule = rule; + } + + public String getRuleName(){ + return this.ruleName; + } + + public void setRuleName(String ruleName){ + this.ruleName = ruleName; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Category.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Category.java new file mode 100644 index 000000000..abc06879d --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Category.java @@ -0,0 +1,219 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Transient; + +import com.att.research.xacml.api.Identifier; +import com.att.research.xacml.api.XACML3; +import com.att.research.xacml.std.IdentifierImpl; +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonIgnore; + + +/** + * The persistent class for the Categories database table. + * + */ +@Entity +@Table(name="Category") +@NamedQuery(name="Category.findAll", query="SELECT c FROM Category c") +public class Category implements Serializable { + private static final long serialVersionUID = 1L; + + public static final char STANDARD = 'S'; + public static final char CUSTOM = 'C'; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="grouping", nullable=false, length=64) + private String grouping; + + @Column(name="is_standard", nullable=false) + private char isStandard; + + @Column(name="xacml_id", nullable=false, unique=true, length=255) + private String xacmlId; + + @Column(name="short_name", nullable=false, length=64) + private String shortName; + + //bi-directional many-to-one association to Attribute + @OneToMany(mappedBy="categoryBean") + @JsonBackReference + private Set<Attribute> attributes = new HashSet<>(); + + public Category() { + this.xacmlId = XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT.stringValue(); + this.grouping = "subject"; + this.isStandard = Category.STANDARD; + this.shortName = "subject"; + } + + public Category(Identifier cat, String grouping, char isStandard) { + if (cat != null) { + this.xacmlId = cat.stringValue(); + } + this.isStandard = isStandard; + if (grouping != null) { + this.grouping = grouping; + } else { + this.grouping = Category.extractGrouping(this.xacmlId); + } + } + + public Category(Identifier cat, String grouping) { + this(cat, grouping, Category.STANDARD); + } + + public Category(Identifier cat, char standard) { + this(cat, null, standard); + } + + public Category(Identifier cat) { + this(cat, Category.STANDARD); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getGrouping() { + return this.grouping; + } + + public void setGrouping(String grouping) { + this.grouping = grouping; + } + + public char getIsStandard() { + return this.isStandard; + } + + public void setIsStandard(char isStandard) { + this.isStandard = isStandard; + } + + public String getXacmlId() { + return this.xacmlId; + } + + public void setXacmlId(String xacmlId) { + this.xacmlId = xacmlId; + } + + public String getShortName() { + return this.shortName; + } + + public void setShortName(String shortName) { + this.shortName = shortName; + } + + public Set<Attribute> getAttributes() { + return this.attributes; + } + + public void setAttributes(Set<Attribute> attributes) { + this.attributes = attributes; + } + + public Attribute addAttribute(Attribute attribute) { + getAttributes().add(attribute); + attribute.setCategoryBean(this); + + return attribute; + } + + public Attribute removeAttribute(Attribute attribute) { + getAttributes().remove(attribute); + attribute.setCategoryBean(null); + + return attribute; + } + + @Transient + public boolean isStandard() { + return (this.isStandard == Category.STANDARD); + } + + @Transient + public boolean isCustom() { + return (this.isStandard == Category.CUSTOM); + } + + @Transient + public static String extractGrouping(String xacmlId) { + if (xacmlId == null) { + return null; + } + if (xacmlId.matches(".*:attribute\\-category:.*")) { + String[] parts = xacmlId.split("[:]"); + if (parts != null && parts.length > 0) { + return parts[parts.length - 1]; + } + } else if (xacmlId.matches(".*:[a-zA-Z]+[\\-]category:.*")) { + String[] parts = xacmlId.split("[:]"); + if (parts != null && parts.length > 0) { + for (String part : parts) { + int index = part.indexOf("-category"); + if (index > 0) { + return part.substring(0, index); + } + } + } + } + return null; + } + + @Transient + public Identifier getIdentifer() { + return new IdentifierImpl(this.xacmlId); + } + + @Transient + @Override + public String toString() { + return "Category [id=" + id + ", grouping=" + grouping + + ", isStandard=" + isStandard + ", xacmlId=" + xacmlId + + ", attributes=" + attributes + "]"; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ClosedLoopD2Services.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ClosedLoopD2Services.java new file mode 100644 index 000000000..408190ac9 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ClosedLoopD2Services.java @@ -0,0 +1,177 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + * + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name = "ClosedLoopD2Services") +@NamedQuery(name="ClosedLoopD2Services.findAll", query="SELECT c FROM ClosedLoopD2Services c ") +public class ClosedLoopD2Services implements Serializable{ + private static final long serialVersionUID = 1L; + + private static String domain; + + + @Id + @Column(name ="id") + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + @Column(name="service_Name", nullable=false, unique=true) + @OrderBy("asc") + private String serviceName; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(ClosedLoopD2Services.class); + + public ClosedLoopD2Services(){ + + } + + public ClosedLoopD2Services(String string, String userid) { + this(domain); + } + + public ClosedLoopD2Services(String domain) { + this.serviceName = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy = XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "ClosedLoopD2Services", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public Date getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ClosedLoopSite.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ClosedLoopSite.java new file mode 100644 index 000000000..b32091307 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ClosedLoopSite.java @@ -0,0 +1,178 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +/* + * + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name = "ClosedLoopSite") +@NamedQuery(name="ClosedLoopSite.findAll", query="SELECT c FROM ClosedLoopSite c ") +public class ClosedLoopSite implements Serializable{ + private static final long serialVersionUID = 1L; + + private static String domain; + + + @Id + @Column(name ="id") + @GeneratedValue(strategy = GenerationType.AUTO) + private int id; + + @Column(name="site_Name", nullable=false, unique=true) + @OrderBy("asc") + private String siteName; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(ClosedLoopSite.class); + + public ClosedLoopSite(){ + + } + + public ClosedLoopSite(String string, String userid) { + this(domain); + } + + public ClosedLoopSite(String domain) { + this.siteName = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy = XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "ClosedLoopSite", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getSiteName() { + return siteName; + } + + public void setSiteName(String siteName) { + this.siteName = siteName; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public Date getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConfigurationDataEntity.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConfigurationDataEntity.java new file mode 100644 index 000000000..71a6d6fb7 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConfigurationDataEntity.java @@ -0,0 +1,227 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Lob; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Version; +/* + * The Entity class to persist a policy object configuration data + */ + +import com.fasterxml.jackson.annotation.JsonBackReference; + +@Entity +@Table(name="ConfigurationDataEntity") +@NamedQueries({ + @NamedQuery(name="ConfigurationDataEntity.findAll", query="SELECT e FROM ConfigurationDataEntity e "), + @NamedQuery(name="ConfigurationDataEntity.deleteAll", query="DELETE FROM ConfigurationDataEntity WHERE 1=1") +}) +//@SequenceGenerator(name="seqConfig", initialValue=1, allocationSize=1) + +public class ConfigurationDataEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqConfig") + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="configurationDataId") + @JsonBackReference + private long configurationDataId; + + @Column(name="configurationName", nullable=false, length=255) + private String configurationName = ""; + + @Version + @Column(name="version") + private int version; + + @Column(name="configType", nullable=false, length=255) + private String configType = "NoType"; + + @Lob + @Column(name="configBody", nullable=false, columnDefinition="TEXT") + private String configBody = "NoBody"; + + @Column(name="created_by", nullable=false, length=255) + private String createdBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=false, length=2048) + private String description = "NoDescription"; + + @Column(name="modified_by", nullable=false, length=255) + private String modifiedBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @Column(name="deleted", nullable=false) + private boolean deleted = false; + + public ConfigurationDataEntity() { + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + /** + * @return the configurationDataId + */ + public long getConfigurationDataId() { + return configurationDataId; + } + /** + * @param configurationDataId the configurationDataId to set + */ + public void setConfigurationName(String configurationName) { + this.configurationName = configurationName; + } + public String getConfigurationName(){ + return this.configurationName; + } + /** + * @return the configType + */ + public String getConfigType() { + return configType; + } + /** + * @param configType the configType to set + */ + public void setConfigType(String configType) { + this.configType = configType; + } + /** + * @return the configBody + */ + public String getConfigBody() { + return configBody; + } + /** + * @param configBody the configBody to set + */ + public void setConfigBody(String configBody) { + this.configBody = configBody; + } + /** + * @return the createdBy + */ + public String getCreatedBy() { + return createdBy; + } + /** + * @param createdBy the createdBy to set + */ + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + /** + * @return the description + */ + public String getDescription() { + return description; + } + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + /** + * @return the modifiedBy + */ + public String getModifiedBy() { + return modifiedBy; + } + /** + * @param modifiedBy the modifiedBy to set + */ + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + /** + * @return the modifiedDate + */ + public Date getModifiedDate() { + return modifiedDate; + } + /** + * @param modifiedDate the modifiedDate to set + */ + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + /** + * @return the version + */ + public int getVersion() { + return version; + } + /** + * @return the createdDate + */ + public Date getCreatedDate() { + return createdDate; + } + + /** + * @return the deleted + */ + public boolean isDeleted() { + return deleted; + } + + /** + * @param deleted the deleted to set + */ + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintType.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintType.java new file mode 100644 index 000000000..73e053ce7 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintType.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +@Entity +@Table(name="ConstraintType") +@NamedQuery(name="ConstraintType.findAll", query="SELECT a FROM ConstraintType a") +public class ConstraintType implements Serializable { + private static final long serialVersionUID = 1L; + + public static String ENUMERATION_TYPE = "Enumeration"; + public static String RANGE_TYPE = "Range"; + public static String REGEXP_TYPE = "Regular Expression"; + + public static Map<String, String> defaults = new HashMap<String, String>(); + static { + defaults.put(ENUMERATION_TYPE, "Enumerate a set of values that the attribute may be set to during policy creation."); + defaults.put(RANGE_TYPE, "Set a range of min and/or max integer/double values the attribute can be set to during policy creation."); + defaults.put(REGEXP_TYPE, "Define a regular expression the attribute must match against during policy creation."); + } + public static final String[] RANGE_TYPES = {"minExclusive", "minInclusive", "maxExclusive", "maxInclusive"}; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="constraint_type", nullable=false, length=64) + private String constraintType; + + @Column(name="description", nullable=false, length=255) + private String description; + + //bi-directional many-to-one association to Attribute + @OneToMany(mappedBy="constraintType") + private Set<Attribute> attributes = new HashSet<>(); + + public ConstraintType() { + + } + + public ConstraintType(String constraintType) { + this(); + this.constraintType = constraintType; + } + + public ConstraintType(String constraintType, String description) { + this(constraintType); + this.description = description; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getConstraintType() { + return constraintType; + } + + public void setConstraintType(String constraintType) { + this.constraintType = constraintType; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Set<Attribute> getAttributes() { + return attributes; + } + + public void setAttributes(Set<Attribute> attributes) { + this.attributes = attributes; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintValue.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintValue.java new file mode 100644 index 000000000..65eb6586a --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ConstraintValue.java @@ -0,0 +1,116 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.Table; + + +/** + * The persistent class for the ConstraintValues database table. + * + */ +@Entity +@Table(name="ConstraintValues") +@NamedQuery(name="ConstraintValue.findAll", query="SELECT c FROM ConstraintValue c") +public class ConstraintValue implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="property") + private String property; + + @Column(name="value") + private String value; + + //bi-directional many-to-one association to Attribute + @ManyToOne + @JoinColumn(name="attribute_id") + private Attribute attribute; + + public ConstraintValue() { + } + + public ConstraintValue(String property, String value) { + this.property = property; + this.value = value; + } + + public ConstraintValue(ConstraintValue value) { + this.property = value.getProperty(); + this.value = value.getValue(); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getProperty() { + return this.property; + } + + public void setProperty(String property) { + this.property = property; + } + + public String getValue() { + return this.value; + } + + public void setValue(String value) { + this.value = value; + } + + public Attribute getAttribute() { + return this.attribute; + } + + public void setAttribute(Attribute attribute) { + this.attribute = attribute; + } + + public ConstraintValue clone() { + ConstraintValue constraint = new ConstraintValue(); + + constraint.property = this.property; + constraint.value = this.value; + constraint.attribute = this.attribute; + + return constraint; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DCAEUsers.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DCAEUsers.java new file mode 100644 index 000000000..eb0c4cc1b --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DCAEUsers.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="DCAEUsers") +@NamedQuery(name="DCAEUsers.findAll", query="SELECT e FROM DCAEUsers e ") +public class DCAEUsers implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description ") + private String description ; + + + public DCAEUsers() { + + } + public DCAEUsers(String string, String userid) { + this(domain); + + } + public DCAEUsers(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + public String getDescriptionValue() { + return this.description ; + } + + public void setDescriptionValue(String description ) { + this.description = description ; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DCAEuuid.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DCAEuuid.java new file mode 100644 index 000000000..a71921b5e --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DCAEuuid.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="DCAEuuid") +@NamedQuery(name="DCAEuuid.findAll", query="SELECT e FROM DCAEuuid e ") +public class DCAEuuid implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description") + private String description; + + + public DCAEuuid() { + + } + public DCAEuuid(String string, String userid) { + this(domain); + + } + public DCAEuuid(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DatabaseLockEntity.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DatabaseLockEntity.java new file mode 100644 index 000000000..c24b13a0e --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DatabaseLockEntity.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; + +@Entity +@Table(name="DatabaseLockEntity") +public class DatabaseLockEntity implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @Column(name="lock_key") + private int lock_key = 1; + public DatabaseLockEntity(){ + + } + public int getKey(){ + return lock_key; + } + public void setKey(int key){ + this.lock_key = key; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Datatype.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Datatype.java new file mode 100644 index 000000000..b3922f10b --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Datatype.java @@ -0,0 +1,245 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Transient; + +import com.att.research.xacml.api.Identifier; +import com.att.research.xacml.api.XACML3; +import com.att.research.xacml.std.IdentifierImpl; +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonManagedReference; + + +/** + * The persistent class for the Datatype database table. + * + */ +@Entity +@Table(name="Datatype") +@NamedQuery(name="Datatype.findAll", query="SELECT d FROM Datatype d") +public class Datatype implements Serializable { + private static final long serialVersionUID = 1L; + + public static final char STANDARD = 'S'; + public static final char CUSTOM = 'C'; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="is_standard", nullable=false) + private char isStandard; + + @Column(name="xacml_id", nullable=false, unique=true, length=255) + private String xacmlId; + + @Column(name="short_name", nullable=false, length=64) + private String shortName; + + //bi-directional many-to-one association to Attribute + @OneToMany(mappedBy="datatypeBean") + @JsonBackReference + private Set<Attribute> attributes = new HashSet<>(); + + //bi-directional many-to-one association to Attribute + @OneToMany(mappedBy="datatypeBean") + @JsonIgnore + private Set<FunctionDefinition> functions = new HashSet<>(); + + //bi-directional many-to-one association to Attribute + @OneToMany(mappedBy="datatypeBean") + @JsonIgnore + private Set<FunctionArgument> arguments = new HashSet<>(); + + public Datatype() { + this.xacmlId = XACML3.ID_DATATYPE_STRING.stringValue(); + this.isStandard = Datatype.STANDARD; + } + + + public Datatype(int id, Datatype dt) { + this.id = id; + this.isStandard = dt.isStandard; + this.xacmlId = dt.xacmlId; + this.shortName = dt.shortName; + // + // Make a copy? + // + this.attributes = new HashSet<>(); + } + + public Datatype(Identifier identifier, char standard) { + if (identifier != null) { + this.xacmlId = identifier.stringValue(); + + } + this.isStandard = standard; + } + + public Datatype(Identifier identifier) { + this(identifier, Datatype.STANDARD); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public char getIsStandard() { + return this.isStandard; + } + + public void setIsStandard(char isStandard) { + this.isStandard = isStandard; + } + + public String getXacmlId() { + return this.xacmlId; + } + + public void setXacmlId(String xacmlId) { + this.xacmlId = xacmlId; + } + + public String getShortName() { + return shortName; + } + + public void setShortName(String shortName) { + this.shortName = shortName; + } + + public Set<Attribute> getAttributes() { + return this.attributes; + } + + public void setAttributes(Set<Attribute> attributes) { + this.attributes = attributes; + } + + public Attribute addAttribute(Attribute attribute) { + getAttributes().add(attribute); + attribute.setDatatypeBean(this); + + return attribute; + } + + public Attribute removeAttribute(Attribute attribute) { + getAttributes().remove(attribute); + attribute.setDatatypeBean(null); + + return attribute; + } + + public Set<FunctionDefinition> getFunctions() { + return this.functions; + } + + public void setFunctions(Set<FunctionDefinition> functions) { + this.functions = functions; + } + + public FunctionDefinition addFunction(FunctionDefinition function) { + getFunctions().add(function); + function.setDatatypeBean(this); + + return function; + } + + public FunctionDefinition removeAttribute(FunctionDefinition function) { + getFunctions().remove(function); + function.setDatatypeBean(null); + + return function; + } + + public Set<FunctionArgument> getArguments() { + return this.arguments; + } + + public void setArguments(Set<FunctionArgument> argument) { + this.arguments = argument; + } + + public FunctionArgument addArgument(FunctionArgument argument) { + getArguments().add(argument); + argument.setDatatypeBean(this); + + return argument; + } + + public FunctionArgument removeArgument(FunctionArgument argument) { + getArguments().remove(argument); + argument.setDatatypeBean(null); + + return argument; + } + + @Transient + public Identifier getIdentifer() { + return new IdentifierImpl(this.xacmlId); + } + + @Transient + public Identifier getIdentiferByShortName() { + return new IdentifierImpl(this.shortName); + } + + @Transient + public boolean isStandard() { + return (this.isStandard == Datatype.STANDARD); + } + + @Transient + public boolean isCustom() { + return (this.isStandard == Datatype.CUSTOM); + } + + @Transient + @Override + public String toString() { + return "Datatype [id=" + id + ", isStandard=" + isStandard + + ", xacmlId=" + xacmlId + ", shortName=" + shortName + + ", attributes=" + attributes + ", functions=" + functions + + ", arguments=" + arguments + "]"; + + //return "Datatype [shortName=" + shortName + "]"; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DecisionSettings.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DecisionSettings.java new file mode 100644 index 000000000..1d90af679 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DecisionSettings.java @@ -0,0 +1,245 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import com.att.research.xacml.api.Identifier; +import com.att.research.xacml.std.IdentifierImpl; +import com.fasterxml.jackson.annotation.JsonManagedReference; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name="DecisionSettings") +@NamedQuery(name="DecisionSettings.findAll", query="SELECT a FROM DecisionSettings a order by a.priority asc, a.xacmlId asc") +public class DecisionSettings implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @Column(name="PRIORITY", nullable=true) + @OrderBy("asc") + private String priority; + + @Column(name="xacml_id", unique = true, nullable=false) + @OrderBy("asc") + private String xacmlId = "urn"; + + //bi-directional many-to-one association to Datatype + @ManyToOne + @JoinColumn(name="datatype") + private Datatype datatypeBean; + + @Transient + private String issuer = null; + + @Transient + private boolean mustBePresent = false; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(DecisionSettings.class); + public DecisionSettings() { + } + + public DecisionSettings(String domain) { + this.xacmlId = domain; + } + + public DecisionSettings(String domain, String user) { + this(domain); + } + public DecisionSettings(DecisionSettings copy, String user) { + this(copy.getXacmlId() + ":(0)", user); + this.datatypeBean = copy.getDatatypeBean(); + this.description = copy.getDescription(); + + } + + public String getDecisionSettings(){ + return this.xacmlId; + } + + public String setDecisionSettings(){ + return this.xacmlId = xacmlId; + } + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy = XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "DecisionSettings", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + + public String getXacmlId() { + return this.xacmlId; + } + +/* @Transient + public Identifier getXacmlIdentifier() { + return new IdentifierImpl(this.xacmlId); + }*/ + + public void setXacmlId(String xacmlId) { + this.xacmlId = xacmlId; + } + + public Datatype getDatatypeBean() { + return this.datatypeBean; + } + + public void setDatatypeBean(Datatype datatypeBean) { + this.datatypeBean = datatypeBean; + } + + @Transient + public String getIssuer() { + return issuer; + } + + @Transient + public void setIssuer(String issuer) { + this.issuer = issuer; + } + + @Transient + public boolean isMustBePresent() { + return mustBePresent; + } + + @Transient + public void setMustBePresent(boolean mustBePresent) { + this.mustBePresent = mustBePresent; + } + + public String getPriority() { + return priority; + } + + public void setPriority(String priority) { + this.priority = priority; + } +} + diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DescriptiveScope.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DescriptiveScope.java new file mode 100644 index 000000000..9f751f7c0 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/DescriptiveScope.java @@ -0,0 +1,182 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name = "DescriptiveScope") +@NamedQuery(name = "DescriptiveScope.findAll", query= "Select p from DescriptiveScope p") +public class DescriptiveScope implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "Id") + private int id; + + @Column(name="scopename", nullable=false) + @OrderBy("asc") + private String descriptiveScopeName; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Column(name="search", nullable=true) + @OrderBy("asc") + private String search; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(DescriptiveScope.class); + + public DescriptiveScope(){ + + } + + public DescriptiveScope(String string, String userid) { + this(string); + } + + public DescriptiveScope(String domain) { + this.descriptiveScopeName = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "DescriptiveScope", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return this.id; + } + public void setId(int id) { + this.id = id; + } + + public String getScopeName() { + return descriptiveScopeName; + } + + public void setScopeName(String descriptiveScopeName) { + this.descriptiveScopeName = descriptiveScopeName; + } + + public String getSearch() { + return search; + } + + public void setSearch(String search) { + this.search = search; + } + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/EcompName.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/EcompName.java new file mode 100644 index 000000000..599e47818 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/EcompName.java @@ -0,0 +1,178 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; +import org.openecomp.policy.rest.jpa.UserInfo; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonManagedReference; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name="EcompName") +@NamedQuery(name="EcompName.findAll", query="SELECT e FROM EcompName e ") +public class EcompName implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="ecomp_Name", nullable=false, unique=true) + @OrderBy("asc") + private String ecompName; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(EcompName.class); + + public EcompName() { + + } + + public EcompName(String string, String userid) { + this(domain); + } + + public EcompName(String domain) { + this.ecompName = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId(); + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "EcompName", "Exception caused While adding Modified by Role"); + } + } + public String getEcompName() { + return this.ecompName; + } + + public void setEcompName(String ecompName) { + this.ecompName = ecompName; + + } + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/EnforcingType.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/EnforcingType.java new file mode 100644 index 000000000..f293bc0cb --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/EnforcingType.java @@ -0,0 +1,96 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.*; + +/** + * Entity implementation class for Entity: EnforcingType + * + */ +@Entity +@Table(name="EnforcingType") +@NamedQuery(name="EnforcingType.findAll", query="SELECT e FROM EnforcingType e ") +public class EnforcingType implements Serializable { + + + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + @Column(name="enforcingType", nullable=false, unique=true) + @OrderBy("asc") + private String enforcingType; + @Column(name="script", nullable=false, length=255) + private String script; + @Column(name="connectionQuery", nullable=false, length=255) + private String connectionQuery; + @Column(name="valueQuery", nullable=false, length=255) + private String valueQuery; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getEnforcingType() { + return enforcingType; + } + + public void setEnforcingType(String enforcingType) { + this.enforcingType = enforcingType; + } + + public String getScript() { + return script; + } + + public void setScript(String script) { + this.script = script; + } + + public String getConnectionQuery() { + return connectionQuery; + } + + public void setConnectionQuery(String connectionQuery) { + this.connectionQuery = connectionQuery; + } + + public String getValueQuery() { + return valueQuery; + } + + public void setValueQuery(String valueQuery) { + this.valueQuery = valueQuery; + } + + public EnforcingType() { + super(); + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FirewallDictionaryList.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FirewallDictionaryList.java new file mode 100644 index 000000000..3c47de817 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FirewallDictionaryList.java @@ -0,0 +1,185 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name="parentdictionaryitems") +@NamedQuery(name="FirewallDictionaryList.findAll", query="SELECT e FROM FirewallDictionaryList e") +public class FirewallDictionaryList implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="parentItemName", nullable=false) + @OrderBy("asc") + private String parentItemName; + + @Column(name="description") + private String description; + + @Column(name="addressList") + private String addressList; + + @Column(name="serviceList") + private String serviceList; + +/* @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy;*/ + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getParentItemName() { + return parentItemName; + } + + public String getDescription() { + return description; + } + + public String getAddressList() { + return addressList; + } + + public String getServiceList() { + return serviceList; + } + + public void setParentItemName(String parentItemName) { + this.parentItemName = parentItemName; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setAddressList(String addressList) { + this.addressList = addressList; + } + + public void setServiceList(String serviceList) { + this.serviceList = serviceList; + } + + + /*public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + }*/ + + private static Log logger = LogFactory.getLog(FirewallDictionaryList.class); + + public FirewallDictionaryList() { + + } + + private static final Log auditLogger = LogFactory + .getLog("auditLogger"); + + public FirewallDictionaryList(String string, String userid) { + this(domain); + } + public FirewallDictionaryList(String domain) { + this.parentItemName = domain; + } + + /*@PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + auditLogger.debug("Added New Term Name: "+this.parentItemName+" by "+this.userCreatedBy); + + } + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "TermList", "Exception caused While adding Modified by Role"); + } + auditLogger.debug("Updated Term Name: "+this.parentItemName+" by "+this.userModifiedBy); + } +*/ +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FunctionArgument.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FunctionArgument.java new file mode 100644 index 000000000..c660fde06 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FunctionArgument.java @@ -0,0 +1,122 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.*; + + +/** + * The persistent class for the FunctionArguments database table. + * + */ +@Entity +@Table(name="FunctionArguments") +@NamedQuery(name="FunctionArgument.findAll", query="SELECT f FROM FunctionArgument f") +public class FunctionArgument implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="is_bag", nullable=false) + private int isBag; + + //bi-directional many-to-one association to FunctionDefinition + @ManyToOne + @JoinColumn(name="function_id") + private FunctionDefinition functionDefinition; + + @Column(name="arg_index", nullable=false) + private int argIndex; + + //bi-directional many-to-one association to Datatype + @ManyToOne + @JoinColumn(name="datatype_id") + private Datatype datatypeBean; + + public FunctionArgument() { + } + + public FunctionArgument(final FunctionArgument argument) { + this.argIndex = argument.argIndex; + this.datatypeBean = argument.datatypeBean; + this.isBag = argument.isBag; + this.functionDefinition = argument.functionDefinition; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public int getArgIndex() { + return this.argIndex; + } + + public void setArgIndex(int argIndex) { + this.argIndex = argIndex; + } + + public Datatype getDatatypeBean() { + return this.datatypeBean; + } + + public void setDatatypeBean(Datatype datatypeBean) { + this.datatypeBean = datatypeBean; + } + + public FunctionDefinition getFunctionDefinition() { + return this.functionDefinition; + } + + public int getIsBag() { + return isBag; + } + + public void setIsBag(int isBag) { + this.isBag = isBag; + } + + public void setFunctionDefinition(FunctionDefinition functionDefinition) { + this.functionDefinition = functionDefinition; + } + + @Transient + @Override + public String toString() { + return "FunctionArgument [id=" + id + ", argIndex=" + argIndex + + ", datatypeBean=" + datatypeBean + ", isBag=" + isBag + + ", functionDefinition=" + functionDefinition + "]"; + } + + @Transient + public boolean isBag() { + return this.isBag == 1; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FunctionDefinition.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FunctionDefinition.java new file mode 100644 index 000000000..c0ccef99a --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/FunctionDefinition.java @@ -0,0 +1,219 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.*; + +import java.util.List; + + +/** + * The persistent class for the FunctionDefinition database table. + * + */ +@Entity +@Table(name="FunctionDefinition") +@NamedQueries({ + @NamedQuery(name="FunctionDefinition.findAll", query="SELECT f FROM FunctionDefinition f") +}) +public class FunctionDefinition implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="short_name", nullable=false, length=64) + private String shortname; + + @Column(name="xacml_id", nullable=false, length=255) + private String xacmlid; + + //bi-directional many-to-one association to Datatype + @ManyToOne + @JoinColumn(name="return_datatype", nullable=true) + private Datatype datatypeBean; + + @Column(name="is_bag_return", nullable=false) + private Integer isBagReturn; + + @Column(name="is_higher_order", nullable=false) + private Integer isHigherOrder; + + @Column(name="arg_lb", nullable=false) + private Integer argLb; + + @Column(name="arg_ub", nullable=false) + private Integer argUb; + + @Column(name="ho_arg_lb", nullable=true) + private Integer higherOrderArg_LB; + + @Column(name="ho_arg_ub", nullable=true) + private Integer higherOrderArg_UB; + + @Column(name="ho_primitive", nullable=true) + private Character higherOrderIsPrimitive; + + //bi-directional many-to-one association to FunctionArgument + @OneToMany(mappedBy="functionDefinition") + private List<FunctionArgument> functionArguments; + + public FunctionDefinition() { + } + + public int getId() { + return this.id; + } + + public void setId(Integer id) { + this.id = id; + } + + public int getArgLb() { + return this.argLb; + } + + public void setArgLb(Integer argLb) { + this.argLb = argLb; + } + + public int getArgUb() { + return this.argUb; + } + + public void setArgUb(Integer argUb) { + this.argUb = argUb; + } + + public int getIsBagReturn() { + return isBagReturn; + } + + public void setIsBagReturn(Integer isBagReturn) { + this.isBagReturn = isBagReturn; + } + + public int getIsHigherOrder() { + return isHigherOrder; + } + + public void setIsHigherOrder(Integer isHigherOrder) { + this.isHigherOrder = isHigherOrder; + } + + public Datatype getDatatypeBean() { + return this.datatypeBean; + } + + public void setDatatypeBean(Datatype datatypeBean) { + this.datatypeBean = datatypeBean; + } + + public String getShortname() { + return this.shortname; + } + + public void setShortname(String shortname) { + this.shortname = shortname; + } + + public String getXacmlid() { + return this.xacmlid; + } + + public void setXacmlid(String xacmlid) { + this.xacmlid = xacmlid; + } + + public int getHigherOrderArg_LB() { + return higherOrderArg_LB; + } + + public void setHigherOrderArg_LB(Integer higherOrderArg_LB) { + this.higherOrderArg_LB = higherOrderArg_LB; + } + + public int getHigherOrderArg_UB() { + return higherOrderArg_UB; + } + + public void setHigherOrderArg_UB(Integer higherOrderArg_UB) { + this.higherOrderArg_UB = higherOrderArg_UB; + } + + public Character getHigherOrderIsPrimitive() { + return higherOrderIsPrimitive; + } + + public void setHigherOrderIsPrimitive(Character higherOrderIsPrimitive) { + this.higherOrderIsPrimitive = higherOrderIsPrimitive; + } + + public List<FunctionArgument> getFunctionArguments() { + return this.functionArguments; + } + + public void setFunctionArguments(List<FunctionArgument> functionArguments) { + this.functionArguments = functionArguments; + } + + public FunctionArgument addFunctionArgument(FunctionArgument functionArgument) { + getFunctionArguments().add(functionArgument); + functionArgument.setFunctionDefinition(this); + + return functionArgument; + } + + public FunctionArgument removeFunctionArgument(FunctionArgument functionArgument) { + getFunctionArguments().remove(functionArgument); + functionArgument.setFunctionDefinition(null); + + return functionArgument; + } + + @Transient + @Override + public String toString() { + return "FunctionDefinition [id=" + id + ", argLb=" + argLb + ", argUb=" + + argUb + ", isBagReturn=" + isBagReturn + ", isHigherOrder=" + + isHigherOrder + ", datatypeBean=" + datatypeBean + + ", shortname=" + shortname + ", xacmlid=" + xacmlid + + ", higherOrderArg_LB=" + higherOrderArg_LB + + ", higherOrderArg_UB=" + higherOrderArg_UB + + ", higherOrderIsPrimitive=" + higherOrderIsPrimitive + + ", functionArguments=" + functionArguments + "]"; + } + + @Transient + public boolean isBagReturn() { + return this.isBagReturn == 1; + } + + @Transient + public boolean isHigherOrder() { + return this.isHigherOrder == 1; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GlobalRoleSettings.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GlobalRoleSettings.java new file mode 100644 index 000000000..5b69cab32 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GlobalRoleSettings.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.Table; + + +/** + * Entity implementation class for Entity: Administration + * + */ +@Entity +@Table(name="GlobalRoleSettings") +@NamedQuery(name="GlobalRoleSettings.findAll", query="SELECT g FROM GlobalRoleSettings g") +public class GlobalRoleSettings implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @Column(name="role", length=45) + private String role; + + @Column(name="lockdown") + private boolean lockdown; + + public GlobalRoleSettings() { + super(); + } + + public GlobalRoleSettings(boolean lockdown) { + this.role = org.openecomp.policy.rest.XacmlAdminAuthorization.Role.ROLE_SUPERADMIN.toString(); + this.lockdown = lockdown; + } + + /** + * return the role + * + * @return the role + */ + public String getRole() { + return role; + } + + /** + * set role + * + * @param role the role to set + */ + public void setRole(String role) { + this.role = role; + } + + /** + * is the system locked down + * + * @return + */ + public boolean isLockdown() { + return lockdown; + } + + /** + * sets lockdown configuration + * + * @param lockdown + */ + public void setLockdown(boolean lockdown) { + this.lockdown = lockdown; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupEntity.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupEntity.java new file mode 100644 index 000000000..b3897d0ee --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupEntity.java @@ -0,0 +1,276 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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========================================================= + */ + +/* + * AT&T - PROPRIETARY + * THIS FILE CONTAINS PROPRIETARY INFORMATION OF + * AT&T AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN + * ACCORDANCE WITH APPLICABLE AGREEMENTS. + * + * Copyright (c) 2013 AT&T Knowledge Ventures + * Unpublished and Not for Publication + * All Rights Reserved + */ +package org.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Index; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.Lob; +import javax.persistence.ManyToMany; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToOne; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.UniqueConstraint; +import javax.persistence.Version; + +import com.fasterxml.jackson.annotation.JsonManagedReference; + +/* + * The Entity class to persist a policy object and its configuration data + */ + +/** + * + */ +@Entity +//Add a non-unique index and a constraint that says the combo of policyName and scopeId must be unique +@Table(name="GroupEntity") + +@NamedQueries({ + @NamedQuery(name="GroupEntity.findAll", query="SELECT e FROM GroupEntity e "), + @NamedQuery(name="GroupEntity.deleteAll", query="DELETE FROM GroupEntity WHERE 1=1") +}) + +public class GroupEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @Column (name="groupKey", nullable=false) + //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqGroup") + @GeneratedValue(strategy = GenerationType.AUTO) + private long groupKey; + + @Column (name="groupId", nullable=false) + private String groupId; + + @Column(name="groupName", nullable=false, unique=false, length=255) + private String groupName; + + @Version + @Column(name="version") + private int version; + + @ManyToMany + @JoinTable(name="PolicyGroupEntity",joinColumns={@JoinColumn(name="groupKey", referencedColumnName="groupKey")}, + inverseJoinColumns={@JoinColumn(name="policyId",referencedColumnName="policyId")}) + @JsonManagedReference + private List<PolicyEntity> policies; + + @Column(name="created_by", nullable=false, length=255) + private String createdBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=false, length=2048) + private String description = "NoDescription"; + + @Column(name="modified_by", nullable=false, length=255) + private String modifiedBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @Column(name="defaultGroup", nullable=false) + private boolean defaultGroup = false; + @Column(name="deleted", nullable=false) + private boolean deleted = false; + + public GroupEntity() { + super(); + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + + /** + * @return the policyId + */ + public String getGroupId() { + return groupId; + } + public long getGroupKey(){ + return groupKey; + } + + public void setGroupId(String groupId){ + this.groupId = groupId; + } + + /** + * @param policyId cannot be set + */ + + public String getgroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public boolean isDefaultGroup(){ + return defaultGroup; + } + + public void setDefaultGroup(boolean isDefaultGroup){ + this.defaultGroup = isDefaultGroup; + } + + + + /** + * @return the configurationDataEntity + */ + public List<PolicyEntity> getPolicies() { + return policies; + } + + /** + * @param configurationDataEntity the configurationDataEntity to set + */ + public void addPolicyToGroup(PolicyEntity policy) { + if(!this.policies.contains(policy)){ + this.policies.add(policy); + } + } + public void removePolicyFromGroup(PolicyEntity policy){ + this.policies.remove(policy); + } + + + + /** + * @return the createdBy + */ + public String getCreatedBy() { + return createdBy; + } + + /** + * @param createdBy the createdBy to set + */ + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the modifiedBy + */ + public String getModifiedBy() { + return modifiedBy; + } + + /** + * @param modifiedBy the modifiedBy to set + */ + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + /** + * @return the version + */ + public int getVersion() { + return version; + } + + /** + * @return the createdDate + */ + public Date getCreatedDate() { + return createdDate; + } + + /** + * @return the modifiedDate + */ + public Date getModifiedDate() { + return modifiedDate; + } + + /** + * @return the deleted + */ + public boolean isDeleted() { + return deleted; + } + + /** + * @param deleted the deleted to set + */ + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } + + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupPolicyScopeList.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupPolicyScopeList.java new file mode 100644 index 000000000..c57d1475a --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupPolicyScopeList.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + + +@Entity +@Table(name="GroupPolicyScopeList") +@NamedQuery(name="GroupPolicyScopeList.findAll", query="SELECT e FROM GroupPolicyScopeList e ") +public class GroupPolicyScopeList implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="groupList") + private String groupList; + + @Column(name="description") + private String description; + + public GroupPolicyScopeList() { + + } + public GroupPolicyScopeList(String string, String userid) { + this(domain); + + } + public GroupPolicyScopeList(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getGroupName() { + return this.name; + } + + public void setGroupName(String serviceName) { + this.name = serviceName; + + } + + public String getGroupList() { + return this.groupList; + } + + public void setGroupList(String groupList) { + this.groupList = groupList; + + } + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupServiceList.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupServiceList.java new file mode 100644 index 000000000..b5fbd9355 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/GroupServiceList.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + + +@Entity +@Table(name="GroupServiceList") +@NamedQuery(name="GroupServiceList.findAll", query="SELECT e FROM GroupServiceList e ") +public class GroupServiceList implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="serviceList ") + private String serviceList; + + + public GroupServiceList() { + + } + public GroupServiceList(String string, String userid) { + this(domain); + + } + public GroupServiceList(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getGroupName() { + return this.name; + } + + public void setGroupName(String serviceName) { + this.name = serviceName; + + } + + public String getServiceList() { + return this.serviceList; + } + + public void setServiceList(String serviceList) { + this.serviceList = serviceList; + + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceConfigName.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceConfigName.java new file mode 100644 index 000000000..594cacf33 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceConfigName.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="MicroServiceConfigName") +@NamedQuery(name="MicroServiceConfigName.findAll", query="SELECT e FROM MicroServiceConfigName e ") +public class MicroServiceConfigName implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description ") + private String description ; + + + public MicroServiceConfigName() { + + } + public MicroServiceConfigName(String string, String userid) { + this(domain); + + } + public MicroServiceConfigName(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + public String getDescriptionValue() { + return this.description ; + } + + public void setDescriptionValue(String description ) { + this.description = description ; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceLocation.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceLocation.java new file mode 100644 index 000000000..8532f81a1 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceLocation.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="MicroServiceLocation") +@NamedQuery(name="MicroServiceLocation.findAll", query="SELECT e FROM MicroServiceLocation e ") +public class MicroServiceLocation implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description ") + private String description ; + + + public MicroServiceLocation() { + + } + public MicroServiceLocation(String string, String userid) { + this(domain); + + } + public MicroServiceLocation(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + public String getDescriptionValue() { + return this.description ; + } + + public void setDescriptionValue(String description ) { + this.description = description ; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceModels.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceModels.java new file mode 100644 index 000000000..ca7460640 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/MicroServiceModels.java @@ -0,0 +1,172 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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========================================================= + */ + +/* + * AT&T - PROPRIETARY + * THIS FILE CONTAINS PROPRIETARY INFORMATION OF + * AT&T AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN + * ACCORDANCE WITH APPLICABLE AGREEMENTS. + * + * Copyright (c) 2015 AT&T Knowledge Ventures + * Unpublished and Not for Publication + * All Rights Reserved + */ +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.Table; +/* + * JPA for the Micro Service Models. + * + * @version: 0.1 + */ +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.openecomp.policy.rest.jpa.UserInfo; + + +@Entity +@Table(name="MicroServiceModels") +@NamedQuery(name="MicroServiceModels.findAll", query="SELECT b FROM MicroServiceModels b ") +public class MicroServiceModels implements Serializable{ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="modelName", nullable=false, unique=true) + @OrderBy("asc") + private String modelName; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Column(name="dependency", nullable=true, length=2048) + private String dependency; + + @Column(name="attributes", nullable=false, length=255) + private String attributes; + + @Column(name="ref_attributes", nullable=false, length=255) + private String ref_attributes; + + @Column (name="sub_attributes", nullable=false, length=2000) + private String sub_attributes; + + @Column (name="version", nullable=false, length=2000) + private String version; + + public String getSub_attributes() { + return sub_attributes; + } + + public void setSub_attributes(String sub_attributes) { + this.sub_attributes = sub_attributes; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + @ManyToOne + @JoinColumn(name="imported_by") + private UserInfo userCreatedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public MicroServiceModels(){ + } + + public MicroServiceModels(String userid){ + + } + + public String getAttributes() { + return attributes; + } + + public void setAttributes(String attributes) { + this.attributes = attributes; + } + + public String getRef_attributes() { + return ref_attributes; + } + + public void setRef_attributes(String ref_attributes) { + this.ref_attributes = ref_attributes; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDependency() { + return dependency; + } + + public void setDependency(String dependency) { + this.dependency = dependency; + } + + public String getModelName(){ + return this.modelName; + } + + public void setModelName(String modelName){ + this.modelName = modelName; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Obadvice.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Obadvice.java new file mode 100644 index 000000000..f26fc9d95 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Obadvice.java @@ -0,0 +1,227 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +import com.att.research.xacml.api.Identifier; + +/** + * The persistent class for the Obadvice database table. + * + */ +@Entity +@Table(name="Obadvice") +@NamedQuery(name="Obadvice.findAll", query="SELECT o FROM Obadvice o") +public class Obadvice implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String OBLIGATION = "Obligation"; + public static final String ADVICE = "Advice"; + public static final String EFFECT_PERMIT = "Permit"; + public static final String EFFECT_DENY = "Deny"; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="type", nullable=false) + private String type; + + @Column(name="xacml_id", nullable=false, length=255) + private String xacmlId; + + @Column(name="fulfill_on", nullable=true, length=32) + private String fulfillOn; + + @Column(name="description", nullable=true, length=2048) + private String description; + + //bi-directional one-to-many association to Attribute Assignment + @OneToMany(mappedBy="obadvice", orphanRemoval=true, cascade=CascadeType.REMOVE) + private Set<ObadviceExpression> obadviceExpressions = new HashSet<ObadviceExpression>(2); + + @Column(name="created_by", nullable=false, length=255) + private String createdBy; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", nullable=false, updatable=false) + private Date createdDate; + + @Column(name="modified_by", nullable=false, length=255) + private String modifiedBy; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + public Obadvice() { + this.type = Obadvice.OBLIGATION; + this.fulfillOn = Obadvice.EFFECT_PERMIT; + } + + public Obadvice(String domain, String userid) { + this.xacmlId = domain; + this.type = Obadvice.OBLIGATION; + this.fulfillOn = Obadvice.EFFECT_PERMIT; + this.createdBy = userid; + this.modifiedBy = userid; + } + + public Obadvice(Identifier id, String userid) { + this(id.stringValue(), userid); + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getCreatedBy() { + return this.createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getFulfillOn() { + return this.fulfillOn; + } + + public void setFulfillOn(String fulfillOn) { + this.fulfillOn = fulfillOn; + } + + public String getModifiedBy() { + return this.modifiedBy; + } + + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + public String getXacmlId() { + return this.xacmlId; + } + + public void setXacmlId(String xacmlId) { + this.xacmlId = xacmlId; + } + + public Set<ObadviceExpression> getObadviceExpressions() { + return this.obadviceExpressions; + } + + public void setObadviceExpressions(Set<ObadviceExpression> obadviceExpressions) { + this.obadviceExpressions = obadviceExpressions; + } + + public ObadviceExpression addObadviceExpression(ObadviceExpression obadviceExpression) { + this.obadviceExpressions.add(obadviceExpression); + obadviceExpression.setObadvice(this); + + return obadviceExpression; + } + + public ObadviceExpression removeObadviceExpression(ObadviceExpression obadviceExpression) { + this.obadviceExpressions.remove(obadviceExpression); + obadviceExpression.setObadvice(null); + + return obadviceExpression; + } + + public void removeAllExpressions() { + if (this.obadviceExpressions == null) { + return; + } + for (ObadviceExpression expression : this.obadviceExpressions) { + expression.setObadvice(null); + } + this.obadviceExpressions.clear(); + } + + @Transient + public Obadvice clone() { + Obadvice obadvice = new Obadvice(); + + obadvice.type = this.type; + obadvice.xacmlId = this.xacmlId; + obadvice.fulfillOn = this.fulfillOn; + obadvice.description = this.description; + obadvice.createdBy = this.createdBy; + obadvice.modifiedBy = this.modifiedBy; + for (ObadviceExpression exp: this.obadviceExpressions) { + obadvice.addObadviceExpression(exp.clone()); + } + + return obadvice; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ObadviceExpression.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ObadviceExpression.java new file mode 100644 index 000000000..28957fa85 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ObadviceExpression.java @@ -0,0 +1,126 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.Lob; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OneToOne; +import javax.persistence.Table; + +import org.openecomp.policy.rest.jpa.Attribute; + + +/** + * The persistent class for the ObadviceExpressions database table. + * + */ +@Entity +@Table(name="ObadviceExpressions") +@NamedQuery(name="ObadviceExpression.findAll", query="SELECT o FROM ObadviceExpression o") +public class ObadviceExpression implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String EXPRESSION_APPLY = "Apply"; + public static final String EXPRESSION_SELECTOR = "Attribute Selector"; + public static final String EXPRESSION_VALUE = "Attribute Value"; + public static final String EXPRESSION_FUNCTION = "Function"; + public static final String EXPRESSION_REFERENCE = "Varable Reference"; + public static final String EXPRESSION_DESIGNATOR = "Attribute Designator"; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + //unidirectional one-to-one association to Attribute + @OneToOne + @JoinColumn(name="attribute_id") + private Attribute attribute; + + @Column(name="type", nullable=false) + private String type; + + /* + @Lob + @Column(name="expression", nullable=false) + private byte[] expression; + */ + + //bi-directional many-to-one association to Obadvice + @ManyToOne + @JoinColumn(name="obadvice_id") + private Obadvice obadvice; + + public ObadviceExpression() { + type = EXPRESSION_VALUE; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public Attribute getAttribute() { + return this.attribute; + } + + public void setAttribute(Attribute attribute) { + this.attribute = attribute; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + public Obadvice getObadvice() { + return this.obadvice; + } + + public void setObadvice(Obadvice obadvice) { + this.obadvice = obadvice; + } + + public ObadviceExpression clone() { + ObadviceExpression expression = new ObadviceExpression(); + + expression.attribute = this.attribute; + expression.type = this.type; + expression.obadvice = this.obadvice; + + return expression; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PEPOptions.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PEPOptions.java new file mode 100644 index 000000000..8b05e8ffc --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PEPOptions.java @@ -0,0 +1,184 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + * + * */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name = "PEPOptions") +@NamedQuery(name = "PEPOptions.findAll", query= "Select p from PEPOptions p") +public class PEPOptions implements Serializable { + private static final long serialVersionUID = 1L; + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "Id") + private int id; + + @Column(name="PEP_NAME", nullable=false) + @OrderBy("asc") + private String pepName; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Column(name="Actions", nullable=true) + @OrderBy("asc") + private String actions; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(PEPOptions.class); + + public PEPOptions(){ + + } + + public PEPOptions(String string, String userid) { + this(string); + } + + public PEPOptions(String domain) { + this.pepName = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PEPOptions", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return this.id; + } + public void setId(int id) { + this.id = id; + } + + public String getPepName() { + return pepName; + } + + public void setPepName(String pepName) { + this.pepName = pepName; + } + + public String getActions() { + return actions; + } + + public void setActions(String actions) { + this.actions = actions; + } + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPConfigParam.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPConfigParam.java new file mode 100644 index 000000000..d3724363f --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPConfigParam.java @@ -0,0 +1,147 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.*; + + +/** + * The persistent class for the PIPConfigParams database table. + * + */ +@Entity +@Table(name="PIPConfigParams") +@NamedQuery(name="PIPConfigParam.findAll", query="SELECT p FROM PIPConfigParam p") +public class PIPConfigParam implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="PARAM_NAME", nullable=false, length=1024) + private String paramName; + + @Column(name="PARAM_VALUE", nullable=false, length=2048) + private String paramValue; + + @Column(name="PARAM_DEFAULT", nullable=true, length=2048) + private String paramDefault = null; + + @Column(name="REQUIRED", nullable=false) + private char required = '0'; + + //bi-directional many-to-one association to PIPConfiguration + @ManyToOne + @JoinColumn(name="PIP_ID") + private PIPConfiguration pipconfiguration; + + public PIPConfigParam() { + } + + public PIPConfigParam(String param) { + this.paramName = param; + } + + public PIPConfigParam(String param, String value) { + this(param); + this.paramValue = value; + } + + public PIPConfigParam(PIPConfigParam param) { + this(param.getParamName(), param.getParamValue()); + this.paramDefault = param.getParamDefault(); + this.required = param.required; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getParamName() { + return this.paramName; + } + + public void setParamName(String paramName) { + this.paramName = paramName; + } + + public String getParamValue() { + return this.paramValue; + } + + public void setParamValue(String paramValue) { + this.paramValue = paramValue; + } + + public String getParamDefault() { + return paramDefault; + } + + public void setParamDefault(String paramDefault) { + this.paramDefault = paramDefault; + } + + public char getRequired() { + return required; + } + + public void setRequired(char required) { + this.required = required; + } + + public PIPConfiguration getPipconfiguration() { + return this.pipconfiguration; + } + + public void setPipconfiguration(PIPConfiguration pipconfiguration) { + this.pipconfiguration = pipconfiguration; + } + + @Transient + public boolean isRequired() { + return (this.required == '1'); + } + + @Transient + public void setRequired(boolean required) { + if (required) { + this.setRequired('1'); + } else { + this.setRequired('0'); + } + } + + @Transient + @Override + public String toString() { + return "PIPConfigParam [id=" + id + ", paramName=" + paramName + + ", paramValue=" + paramValue + ", required=" + required + "]"; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPConfiguration.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPConfiguration.java new file mode 100644 index 000000000..8f75bef89 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPConfiguration.java @@ -0,0 +1,572 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.openecomp.policy.xacml.api.XACMLErrorConstants; +import com.att.research.xacml.api.pip.PIPException; +import com.att.research.xacml.std.pip.engines.StdConfigurableEngine; +import com.att.research.xacml.std.pip.engines.csv.CSVEngine; +import com.att.research.xacml.std.pip.engines.csv.HyperCSVEngine; +import com.att.research.xacml.std.pip.engines.jdbc.JDBCEngine; +import com.att.research.xacml.std.pip.engines.ldap.LDAPEngine; +import com.att.research.xacml.util.XACMLProperties; +import com.google.common.base.Joiner; +import com.google.common.base.Splitter; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +/** + * The persistent class for the PIPConfiguration database table. + * + */ +@Entity +@Table(name="PIPConfiguration") +@NamedQuery(name="PIPConfiguration.findAll", query="SELECT p FROM PIPConfiguration p") +public class PIPConfiguration implements Serializable { + private static final long serialVersionUID = 1L; + private static final Log logger = LogFactory.getLog(PIPConfiguration.class); + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="DESCRIPTION", nullable=true, length=2048) + private String description; + + @Column(name="NAME", nullable=false, length=255) + private String name; + + @Column(name="CLASSNAME", nullable=false, length=2048) + private String classname; + + @Column(name="ISSUER", nullable=true, length=1024) + private String issuer; + + @Column(name="READ_ONLY", nullable=false) + private char readOnly = '0'; + + @Column(name="REQUIRES_RESOLVER", nullable=false) + private char requiresResolvers; + + @Column(name="CREATED_BY", nullable=false, length=255) + private String createdBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="CREATED_DATE", nullable=false, updatable=false) + private Date createdDate; + + @Column(name="MODIFIED_BY", nullable=false, length=255) + private String modifiedBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="MODIFIED_DATE", nullable=false) + private Date modifiedDate; + + //bi-directional many-to-one association to PIPConfigParam + @OneToMany(mappedBy="pipconfiguration", orphanRemoval=true, cascade=CascadeType.REMOVE) + private Set<PIPConfigParam> pipconfigParams = new HashSet<PIPConfigParam>(); + + //bi-directional many-to-one association to PIPType + @ManyToOne + @JoinColumn(name="TYPE") + private PIPType piptype; + + //bi-directional many-to-one association to PIPResolver + @OneToMany(mappedBy="pipconfiguration", orphanRemoval=true, cascade=CascadeType.REMOVE) + private Set<PIPResolver> pipresolvers = new HashSet<PIPResolver>(); + + public PIPConfiguration() { + } + + public PIPConfiguration(PIPConfiguration config, String user) { + this.description = config.description; + this.name = config.name; + this.classname = config.classname; + this.issuer = config.issuer; + this.requiresResolvers = config.requiresResolvers; + this.readOnly = config.readOnly; + this.piptype = config.piptype; + for (PIPConfigParam param : config.pipconfigParams) { + this.addPipconfigParam(new PIPConfigParam(param)); + } + for (PIPResolver resolver : config.pipresolvers) { + this.addPipresolver(new PIPResolver(resolver)); + } + } + + public PIPConfiguration(String id, Properties properties) throws PIPException { + this.readProperties(id, properties); + } + + public PIPConfiguration(String id, Properties properties, String user) throws PIPException { + this.createdBy = user; + this.modifiedBy = user; + this.readProperties(id, properties); + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getClassname() { + return classname; + } + + public void setClassname(String classname) { + this.classname = classname; + } + + public String getIssuer() { + return issuer; + } + + public void setIssuer(String issuer) { + this.issuer = issuer; + } + + public char getReadOnly() { + return readOnly; + } + + public void setReadOnly(char readOnly) { + this.readOnly = readOnly; + } + + public char getRequiresResolvers() { + return requiresResolvers; + } + + public void setRequiresResolvers(char requireResolvers) { + this.requiresResolvers = requireResolvers; + } + + public Set<PIPConfigParam> getPipconfigParams() { + return this.pipconfigParams; + } + + public void setPipconfigParams(Set<PIPConfigParam> pipconfigParams) { + this.pipconfigParams = pipconfigParams; + } + + public PIPConfigParam addPipconfigParam(PIPConfigParam pipconfigParam) { + getPipconfigParams().add(pipconfigParam); + pipconfigParam.setPipconfiguration(this); + + return pipconfigParam; + } + + public PIPConfigParam removePipconfigParam(PIPConfigParam pipconfigParam) { + if (pipconfigParam == null) { + return pipconfigParam; + } + getPipconfigParams().remove(pipconfigParam); + pipconfigParam.setPipconfiguration(null); + + return pipconfigParam; + } + + @Transient + public void clearConfigParams() { + while (this.pipconfigParams.isEmpty() == false) { + this.removePipconfigParam(this.pipconfigParams.iterator().next()); + } + } + + public PIPType getPiptype() { + return this.piptype; + } + + public void setPiptype(PIPType piptype) { + this.piptype = piptype; + } + + public Set<PIPResolver> getPipresolvers() { + return this.pipresolvers; + } + + public void setPipresolvers(Set<PIPResolver> pipresolvers) { + this.pipresolvers = pipresolvers; + } + + public PIPResolver addPipresolver(PIPResolver pipresolver) { + getPipresolvers().add(pipresolver); + pipresolver.setPipconfiguration(this); + + return pipresolver; + } + + public PIPResolver removePipresolver(PIPResolver pipresolver) { + getPipresolvers().remove(pipresolver); + pipresolver.setPipconfiguration(null); + + return pipresolver; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public Date getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + + @Transient + public boolean isReadOnly() { + return (this.readOnly == '1'); + } + + @Transient + public void setReadOnly(boolean readOnly) { + if (readOnly) { + this.readOnly = '1'; + } else { + this.readOnly = '0'; + } + } + + @Transient + public boolean requiresResolvers() { + return (this.requiresResolvers == '1'); + } + + @Transient + public void setRequiresResolvers(boolean requires) { + if (requires) { + this.requiresResolvers = '1'; + } else { + this.requiresResolvers = '0'; + } + } + + @Transient + public static Collection<PIPConfiguration> importPIPConfigurations(Properties properties) { + Collection<PIPConfiguration> configurations = new ArrayList<PIPConfiguration>(); + String engines = properties.getProperty(XACMLProperties.PROP_PIP_ENGINES); + if (engines == null || engines.isEmpty()) { + return configurations; + } + for (String id : Splitter.on(',').trimResults().omitEmptyStrings().split(engines)) { + PIPConfiguration configuration; + try { + String user = "super-admin"; + //TODO + //String user = ((XacmlAdminUI)UI.getCurrent()).getUserid(); + configuration = new PIPConfiguration(id, properties, user); + configuration.setCreatedBy(user); + configuration.setModifiedBy(user); + configurations.add(configuration); + } catch (PIPException e) { + logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Import failed: " + e.getLocalizedMessage()); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PIPConfiguration", "Import failed"); + } + } + + return configurations; + } + + @Transient + protected void readProperties(String id, Properties properties) throws PIPException { + // + // Save the id if we don't have one already + // + + if (this.id == 0) { + try { + this.id = Integer.parseInt(id); + } catch (NumberFormatException e) { + logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Convert id to integer failed: " + id); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PIPConfiguration", "Convert id to integer failed"); + } + } + // + // Get its classname, this MUST exist. + // + this.classname = properties.getProperty(id + ".classname"); + if (this.classname == null) { + throw new PIPException("PIP Engine defined without a classname"); + } + // + // These classes we know for sure require resolvers. + // + //TODO: Commented out due to JPAUtils class & As of now we are not using PIP. So, it will not impact any Errors + /*if (this.classname.equals(JDBCEngine.class.getCanonicalName())) { + this.setRequiresResolvers(true); + this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_SQL)); + } else if (this.classname.equals(LDAPEngine.class.getCanonicalName())) { + this.setRequiresResolvers(true); + this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_LDAP)); + } else if (this.classname.equals(HyperCSVEngine.class.getCanonicalName())) { + this.setRequiresResolvers(true); + this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_HYPERCSV)); + } else if (this.classname.equals(CSVEngine.class.getCanonicalName())) { + this.setRequiresResolvers(true); + this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_CSV)); + } else { + // + // Assume it does not require resolvers for now, if we encounter + // one then we will change it. The user can always change it via the gui. + // + this.setRequiresResolvers(false); + this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_CUSTOM)); + }*/ + // + // Go through each property + // + for (Object name : properties.keySet()) { + if (name.toString().startsWith(id) == false) { + continue; + } + if (name.equals(id + ".classname")) { + // + // We already saved this + // + } else if (name.equals(id + "." + StdConfigurableEngine.PROP_NAME)) { + this.name = properties.getProperty(name.toString()); + } else if (name.equals(id + "." + StdConfigurableEngine.PROP_DESCRIPTION)) { + this.description = properties.getProperty(name.toString()); + } else if (name.equals(id + "." + StdConfigurableEngine.PROP_ISSUER)) { + this.issuer = properties.getProperty(name.toString()); + } else if (name.equals(id + ".resolvers")) { + // + // It has resolvers, make sure this is set to true if + // it has been already. + // + this.setRequiresResolvers(true); + // + // Parse the resolvers + // + Collection<PIPResolver> resolvers = PIPResolver.importResolvers(id + ".resolver", + properties.getProperty(name.toString()), + properties,"super-admin" + ); + //TODO: replace with UserId + //((XacmlAdminUI)UI.getCurrent()).getUserid() + for (PIPResolver resolver : resolvers) { + this.addPipresolver(resolver); + } + } else if (name.toString().startsWith(id + ".resolver")) { + // + // Ignore, the PIPResolver will parse these values + // + } else { + // + // Config Parameter + // + this.addPipconfigParam(new PIPConfigParam(name.toString().substring(id.length() + 1), + properties.getProperty(name.toString()))); + } + } + // + // Make sure we have a name at least + // + if (this.name == null) { + this.name = id; + } + } + + + @Transient + public Map<String, String> getConfiguration(String name) { + String prefix; + if (name == null) { + prefix = Integer.toString(this.id); + } else { + prefix = name; + } + if (prefix.endsWith(".") == false) { + prefix = prefix + "."; + } + Map<String, String> map = new HashMap<String, String>(); + map.put(prefix + "classname", this.classname); + map.put(prefix + "name", this.name); + if (this.description != null) { + map.put(prefix + "description", this.description); + } + if (this.issuer != null) { + map.put(prefix + "issuer", this.issuer); + } + + for (PIPConfigParam param : this.pipconfigParams) { + map.put(prefix + param.getParamName(), param.getParamValue()); + } + + List<String> ids = new ArrayList<String>(); + Iterator<PIPResolver> iter = this.pipresolvers.iterator(); + while (iter.hasNext()) { + PIPResolver resolver = iter.next(); + String id = Integer.toString(resolver.getId()); + Map<String, String> resolverMap = resolver.getConfiguration(prefix + "resolver." + id); + map.putAll(resolverMap); + ids.add(id); + } + if (ids.size() > 0) { + map.put(prefix + "resolvers", Joiner.on(',').join(ids)); + } + return map; + } + + @Transient + public Properties generateProperties(String name) { + String prefix; + if (name == null) { + prefix = Integer.toString(this.id); + } else { + if (name.endsWith(".")) { + prefix = name; + } else { + prefix = name + "."; + } + } + Properties props = new Properties(); + props.setProperty("xacml.pip.engines", name); + props.setProperty(prefix + "classname", this.classname); + props.setProperty(prefix + "name", this.name); + if (this.description != null) { + props.setProperty(prefix + "description", this.description); + } + if (this.issuer != null && this.issuer.isEmpty() == false) { + props.setProperty(prefix + "issuer", this.issuer); + } + + for (PIPConfigParam param : this.pipconfigParams) { + props.setProperty(prefix + param.getParamName(), param.getParamValue()); + } + + List<String> ids = new ArrayList<String>(); + Iterator<PIPResolver> iter = this.pipresolvers.iterator(); + while (iter.hasNext()) { + PIPResolver resolver = iter.next(); + String id = Integer.toString(resolver.getId()); + resolver.generateProperties(props, prefix + "resolver." + id); + ids.add(id); + } + if (ids.size() > 0) { + props.setProperty(prefix + "resolvers", Joiner.on(',').join(ids)); + } + return props; + } + + @Transient + @Override + public String toString() { + return "PIPConfiguration [id=" + id + ", piptype=" + piptype + + ", classname=" + classname + ", name=" + name + + ", description=" + description + ", issuer=" + issuer + + ", readOnly=" + readOnly + ", requiresResolvers=" + + requiresResolvers + ", createdBy=" + createdBy + + ", createdDate=" + createdDate + ", modifiedBy=" + modifiedBy + + ", modifiedDate=" + modifiedDate + ", pipconfigParams=" + + pipconfigParams + ", pipresolvers=" + pipresolvers + "]"; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPResolver.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPResolver.java new file mode 100644 index 000000000..634ff3e63 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPResolver.java @@ -0,0 +1,365 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Properties; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +import com.att.research.xacml.api.pip.PIPException; +import com.att.research.xacml.std.pip.engines.StdConfigurableEngine; +import com.google.common.base.Splitter; + + +/** + * The persistent class for the PIPResolver database table. + * + */ +@Entity +@Table(name="PIPResolver") +@NamedQuery(name="PIPResolver.findAll", query="SELECT p FROM PIPResolver p") +public class PIPResolver implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="DESCRIPTION", nullable=true, length=2048) + private String description; + + @Column(name="NAME", nullable=false, length=255) + private String name; + + @Column(name="ISSUER", nullable=true, length=1024) + private String issuer; + + @Column(name="CLASSNAME", nullable=false, length=2048) + private String classname; + + @Column(name="READ_ONLY", nullable=false) + private char readOnly = '0'; + + @Column(name="CREATED_BY", nullable=false, length=255) + private String createdBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="CREATED_DATE", nullable=false, updatable=false) + private Date createdDate; + + @Column(name="MODIFIED_BY", nullable=false, length=255) + private String modifiedBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="MODIFIED_DATE", nullable=false) + private Date modifiedDate; + + //bi-directional many-to-one association to PIPConfiguration + @ManyToOne + @JoinColumn(name="PIP_ID") + private PIPConfiguration pipconfiguration; + + //bi-directional many-to-one association to PIPResolverParam + @OneToMany(mappedBy="pipresolver", orphanRemoval=true, cascade=CascadeType.REMOVE) + private Set<PIPResolverParam> pipresolverParams = new HashSet<PIPResolverParam>(); + + public PIPResolver() { + } + + public PIPResolver(String prefix, Properties properties, String user) throws PIPException { + this.createdBy = user; + this.modifiedBy = user; + this.readOnly = '0'; + this.readProperties(prefix, properties); + } + + public PIPResolver(PIPResolver resolver) { + this.name = resolver.name; + this.description = resolver.description; + this.issuer = resolver.issuer; + this.classname = resolver.classname; + this.readOnly = resolver.readOnly; + for (PIPResolverParam param : this.pipresolverParams) { + this.addPipresolverParam(new PIPResolverParam(param)); + } + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + } + + public String getIssuer() { + return issuer; + } + + public void setIssuer(String issuer) { + this.issuer = issuer; + } + + public String getClassname() { + return classname; + } + + public void setClassname(String classname) { + this.classname = classname; + } + + public char getReadOnly() { + return readOnly; + } + + public void setReadOnly(char readOnly) { + this.readOnly = readOnly; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + public Date getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + + public PIPConfiguration getPipconfiguration() { + return this.pipconfiguration; + } + + public void setPipconfiguration(PIPConfiguration pipconfiguration) { + this.pipconfiguration = pipconfiguration; + } + + public Set<PIPResolverParam> getPipresolverParams() { + return this.pipresolverParams; + } + + public void setPipresolverParams(Set<PIPResolverParam> pipresolverParams) { + this.pipresolverParams = pipresolverParams; + } + + public PIPResolverParam addPipresolverParam(PIPResolverParam pipresolverParam) { + getPipresolverParams().add(pipresolverParam); + pipresolverParam.setPipresolver(this); + + return pipresolverParam; + } + + public PIPResolverParam removePipresolverParam(PIPResolverParam pipresolverParam) { + if (pipresolverParam == null) { + return pipresolverParam; + } + getPipresolverParams().remove(pipresolverParam); + pipresolverParam.setPipresolver(null); + + return pipresolverParam; + } + + @Transient + public void clearParams() { + while (this.pipresolverParams.isEmpty() == false) { + this.removePipresolverParam(this.pipresolverParams.iterator().next()); + } + } + + @Transient + public boolean isReadOnly() { + return (this.readOnly == '1'); + } + + @Transient + public void setReadOnly(boolean readOnly) { + if (readOnly) { + this.readOnly = '1'; + } else { + this.readOnly = '0'; + } + } + + @Transient + public static Collection<PIPResolver> importResolvers(String prefix, String list, Properties properties, String user) throws PIPException { + Collection<PIPResolver> resolvers = new ArrayList<PIPResolver>(); + for (String id : Splitter.on(',').trimResults().omitEmptyStrings().split(list)) { + resolvers.add(new PIPResolver(prefix + "." + id, properties, user)); + } + return resolvers; + } + + @Transient + protected void readProperties(String prefix, Properties properties) throws PIPException { + // + // Get its classname, this MUST exist. + // + this.classname = properties.getProperty(prefix + ".classname"); + if (this.classname == null) { + throw new PIPException("PIP Engine defined without a classname"); + } + // + // Go through each property + // + for (Object name : properties.keySet()) { + if (name.toString().startsWith(prefix) == false) { + continue; + } + if (name.equals(prefix + ".classname")) { + // + // We already saved this + // + } else if (name.equals(prefix + "." + StdConfigurableEngine.PROP_NAME)) { + this.name = properties.getProperty(name.toString()); + } else if (name.equals(prefix + "." + StdConfigurableEngine.PROP_DESCRIPTION)) { + this.description = properties.getProperty(name.toString()); + } else if (name.equals(prefix + "." + StdConfigurableEngine.PROP_ISSUER)) { + this.issuer = properties.getProperty(name.toString()); + } else { + this.addPipresolverParam(new PIPResolverParam(name.toString().substring(prefix.length() + 1), + properties.getProperty(name.toString()))); + } + } + } + + @Transient + public Map<String, String> getConfiguration(String prefix) { + Map<String, String> map = new HashMap<String, String>(); + if (prefix.endsWith(".") == false) { + prefix = prefix + "."; + } + map.put(prefix + "classname", this.classname); + map.put(prefix + "name", this.name); + if (this.description != null) { + map.put(prefix + "description", this.description); + } + if (this.issuer != null && this.issuer.isEmpty() != false) { + map.put(prefix + "issuer", this.issuer); + } + for (PIPResolverParam param : this.pipresolverParams) { + map.put(prefix + param.getParamName(), param.getParamValue()); + } + return map; + } + + @Transient + public void generateProperties(Properties props, String prefix) { + if (prefix.endsWith(".") == false) { + prefix = prefix + "."; + } + props.setProperty(prefix + "classname", this.classname); + props.setProperty(prefix + "name", this.name); + if (this.description != null) { + props.setProperty(prefix + "description", this.description); + } + if (this.issuer != null && this.issuer.isEmpty() != false) { + props.setProperty(prefix + "issuer", this.issuer); + } + for (PIPResolverParam param : this.pipresolverParams) { + props.setProperty(prefix + param.getParamName(), param.getParamValue()); + } + } + + @Transient + @Override + public String toString() { + return "PIPResolver [id=" + id + ", classname=" + classname + ", name=" + + name + ", description=" + description + ", issuer=" + issuer + + ", readOnly=" + readOnly + ", createdBy=" + createdBy + + ", createdDate=" + createdDate + ", modifiedBy=" + modifiedBy + + ", modifiedDate=" + modifiedDate + ", pipresolverParams=" + + pipresolverParams + "]"; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPResolverParam.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPResolverParam.java new file mode 100644 index 000000000..957b105d1 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPResolverParam.java @@ -0,0 +1,147 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.*; + + +/** + * The persistent class for the PIPResolverParams database table. + * + */ +@Entity +@Table(name="PIPResolverParams") +@NamedQuery(name="PIPResolverParam.findAll", query="SELECT p FROM PIPResolverParam p") +public class PIPResolverParam implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="PARAM_NAME", nullable=false, length=1024) + private String paramName; + + @Column(name="PARAM_VALUE", nullable=false, length=2048) + private String paramValue; + + @Column(name="PARAM_DEFAULT", nullable=true, length=2048) + private String paramDefault; + + @Column(name="REQUIRED", nullable=false) + private char required = '0'; + + //bi-directional many-to-one association to PIPResolver + @ManyToOne + @JoinColumn(name="ID_RESOLVER") + private PIPResolver pipresolver; + + public PIPResolverParam() { + } + + public PIPResolverParam(String name) { + this.paramName = name; + } + + public PIPResolverParam(String name, String value) { + this(name); + this.paramValue = value; + } + + public PIPResolverParam(PIPResolverParam param) { + this(param.getParamName(), param.getParamValue()); + this.paramDefault = param.getParamDefault(); + this.required = param.required; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getParamName() { + return this.paramName; + } + + public void setParamName(String paramName) { + this.paramName = paramName; + } + + public String getParamValue() { + return this.paramValue; + } + + public void setParamValue(String paramValue) { + this.paramValue = paramValue; + } + + public String getParamDefault() { + return paramDefault; + } + + public void setParamDefault(String paramDefault) { + this.paramDefault = paramDefault; + } + + public char getRequired() { + return required; + } + + public void setRequired(char required) { + this.required = required; + } + + public PIPResolver getPipresolver() { + return this.pipresolver; + } + + public void setPipresolver(PIPResolver pipresolver) { + this.pipresolver = pipresolver; + } + + @Transient + public boolean isRequired() { + return this.required == '1'; + } + + @Transient + public void setRequired(boolean required) { + if (required) { + this.required = '1'; + } else { + this.required = '0'; + } + } + + @Transient + @Override + public String toString() { + return "PIPResolverParam [id=" + id + ", paramName=" + paramName + + ", paramValue=" + paramValue + ", required=" + required + "]"; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPType.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPType.java new file mode 100644 index 000000000..964a15412 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PIPType.java @@ -0,0 +1,131 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Set; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.Table; +import javax.persistence.Transient; + + +/** + * The persistent class for the PIPType database table. + * + */ +@Entity +@Table(name="PIPType") +@NamedQuery(name="PIPType.findAll", query="SELECT p FROM PIPType p") +public class PIPType implements Serializable { + private static final long serialVersionUID = 1L; + + public static final String TYPE_SQL = "SQL"; + public static final String TYPE_LDAP = "LDAP"; + public static final String TYPE_CSV = "CSV"; + public static final String TYPE_HYPERCSV = "Hyper-CSV"; + public static final String TYPE_CUSTOM = "Custom"; + + @Id + @GeneratedValue(strategy=GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="type", nullable=false, length=45) + private String type; + + //bi-directional many-to-one association to PIPConfiguration + @OneToMany(mappedBy="piptype") + private Set<PIPConfiguration> pipconfigurations; + + public PIPType() { + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + } + + public Set<PIPConfiguration> getPipconfigurations() { + return this.pipconfigurations; + } + + public void setPipconfigurations(Set<PIPConfiguration> pipconfigurations) { + this.pipconfigurations = pipconfigurations; + } + + public PIPConfiguration addPipconfiguration(PIPConfiguration pipconfiguration) { + getPipconfigurations().add(pipconfiguration); + pipconfiguration.setPiptype(this); + + return pipconfiguration; + } + + public PIPConfiguration removePipconfiguration(PIPConfiguration pipconfiguration) { + getPipconfigurations().remove(pipconfiguration); + pipconfiguration.setPiptype(null); + + return pipconfiguration; + } + + @Transient + public boolean isSQL() { + return this.type.equals(TYPE_SQL); + } + + @Transient + public boolean isLDAP() { + return this.type.equals(TYPE_LDAP); + } + + @Transient + public boolean isCSV() { + return this.type.equals(TYPE_CSV); + } + + @Transient + public boolean isHyperCSV() { + return this.type.equals(TYPE_HYPERCSV); + } + + @Transient + public boolean isCustom() { + return this.type.equals(TYPE_CUSTOM); + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PREFIXLIST.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PREFIXLIST.java new file mode 100644 index 000000000..aac04795c --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PREFIXLIST.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name="PREFIXLIST") +@NamedQuery(name="PREFIXLIST.findAll", query="SELECT e FROM PREFIXLIST e ") +public class PREFIXLIST implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="pl_name", nullable=false) + @OrderBy("asc") + private String prefixListName; + + @Column(name="description", nullable=false) + private String description; + + @Column(name="pl_value", nullable=false) + private String prefixListValue; +/* + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate;*/ + + public PREFIXLIST() { + + } + public PREFIXLIST(String string, String userid) { + this(domain); + + } + public PREFIXLIST(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + public String getPrefixListName() { + return this.prefixListName; + } + + public void setPrefixListName(String prefixListName) { + this.prefixListName = prefixListName; + + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + + } + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getPrefixListValue() { + return this.prefixListValue; + } + + public void setPrefixListValue(String prefixListValue) { + this.prefixListValue = prefixListValue; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PdpEntity.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PdpEntity.java new file mode 100644 index 000000000..191dfde60 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PdpEntity.java @@ -0,0 +1,247 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Index; +import javax.persistence.JoinColumn; +import javax.persistence.Lob; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToOne; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.UniqueConstraint; +import javax.persistence.Version; + +/* + * The Entity class to persist a policy object and its configuration data + */ + +/** + * + */ +@Entity +//Add a non-unique index and a constraint that says the combo of policyName and scopeId must be unique +@Table(name="PdpEntity") +@NamedQueries({ + @NamedQuery(name="PdpEntity.findAll", query="SELECT e FROM PdpEntity e "), + @NamedQuery(name="PdpEntity.deleteAll", query="DELETE FROM PdpEntity WHERE 1=1") +}) + +public class PdpEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqPdp") + @GeneratedValue(strategy = GenerationType.AUTO) + @Column (name="pdpKey") + private long pdpKey; + + @Column (name="pdpId", nullable=false, unique=false, length=255) + private String pdpId; + + @Column(name="pdpName", nullable=false, unique=false, length=255) + private String pdpName; + + @Column(name="jmxPort", nullable=false, unique=false) + private int jmxPort; + + + @ManyToOne(optional=false) + @JoinColumn(name="groupKey", referencedColumnName="groupKey") + private GroupEntity groupEntity; + + @Column(name="created_by", nullable=false, length=255) + private String createdBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=false, length=2048) + private String description = "NoDescription"; + + @Column(name="modified_by", nullable=false, length=255) + private String modifiedBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @Column(name="deleted", nullable=false) + private boolean deleted = false; + + public PdpEntity() { + super(); + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + + public long getPdpKey(){ + return pdpKey; + } + /** + * @return the policyId + */ + public String getPdpId() { + return pdpId; + } + + public void setPdpId(String id){ + pdpId = id; + } + /** + * @param policyId cannot be set + */ + + public String getPdpName() { + return pdpName; + } + + public void setPdpName(String groupName) { + this.pdpName = groupName; + } + + + + /** + * @return the configurationDataEntity + */ + public GroupEntity getGroup() { + return groupEntity; + } + + /** + * @param configurationDataEntity the configurationDataEntity to set + */ + public void setGroup(GroupEntity group) { + this.groupEntity = group; + } + + + + /** + * @return the createdBy + */ + public String getCreatedBy() { + return createdBy; + } + + /** + * @param createdBy the createdBy to set + */ + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the modifiedBy + */ + public String getModifiedBy() { + return modifiedBy; + } + + /** + * @param modifiedBy the modifiedBy to set + */ + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + /** + * @return the version + */ + public int getJmxPort() { + return jmxPort; + } + + public void setJmxPort(int jmxPort){ + this.jmxPort = jmxPort; + } + + /** + * @return the createdDate + */ + public Date getCreatedDate() { + return createdDate; + } + + /** + * @return the modifiedDate + */ + public Date getModifiedDate() { + return modifiedDate; + } + + /** + * @return the deleted + */ + public boolean isDeleted() { + return deleted; + } + + /** + * @param deleted the deleted to set + */ + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } + + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyAlgorithms.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyAlgorithms.java new file mode 100644 index 000000000..eb46ae0dc --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyAlgorithms.java @@ -0,0 +1,116 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Transient; + +import com.att.research.xacml.api.Identifier; + +@Entity +@Table(name="PolicyAlgorithms") +@NamedQuery(name="PolicyAlgorithms.findAll", query="SELECT d FROM PolicyAlgorithms d") +public class PolicyAlgorithms implements Serializable { + private static final long serialVersionUID = 1L; + + public static final char STANDARD = 'S'; + public static final char CUSTOM = 'C'; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="is_standard", nullable=false) + private char isStandard; + + @Column(name="xacml_id", nullable=false, unique=true, length=255) + private String xacmlId; + + @Column(name="short_name", nullable=false, length=64) + private String shortName; + + public PolicyAlgorithms(Identifier identifier, char standard) { + this.isStandard = standard; + if (identifier != null) { + this.xacmlId = identifier.stringValue(); + } + } + + public PolicyAlgorithms(Identifier identifier) { + this(identifier, PolicyAlgorithms.STANDARD); + } + + public PolicyAlgorithms() { + this(null, PolicyAlgorithms.STANDARD); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public char getIsStandard() { + return this.isStandard; + } + + public void setIsStandard(char isStandard) { + this.isStandard = isStandard; + } + + @Transient + public boolean isStandard() { + return (this.isStandard == PolicyAlgorithms.STANDARD); + } + + @Transient + public boolean isCustom() { + return (this.isStandard == PolicyAlgorithms.CUSTOM); + } + + public String getXacmlId() { + return this.xacmlId; + } + + public void setXacmlId(String xacmlId) { + this.xacmlId = xacmlId; + } + + public String getShortName() { + return shortName; + } + + public void setShortName(String shortName) { + this.shortName = shortName; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyDBDaoEntity.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyDBDaoEntity.java new file mode 100644 index 000000000..c395ab49a --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyDBDaoEntity.java @@ -0,0 +1,150 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +/* + * The Entity class to persist a PolicyDBDaoEntity object for registration of PolicyDBDao + */ + +/** + * + */ +@Entity +@Table(name="PolicyDBDaoEntity") + +@NamedQueries({ + @NamedQuery(name="PolicyDBDaoEntity.findAll", query="SELECT e FROM PolicyDBDaoEntity e "), + @NamedQuery(name="PolicyDBDaoEntity.deleteAll", query="DELETE FROM PolicyDBDaoEntity WHERE 1=1") +}) + +public class PolicyDBDaoEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @Column(name="policyDBDaoUrl", nullable=false, unique=true) + private String policyDBDaoUrl; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + //username for the pap server that registered this PolicyDBDaoEntity + @Column(name="username") + private String username; + + //AES encrypted password for the pap server that registered this PolicyDBDaoEntity + @Column(name="password") + private String password; + + //A column to allow some descriptive text. For example: Atlanta data center + @Column(name="description", nullable=false, length=2048) + private String description = "NoDescription"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + public PolicyDBDaoEntity() { + super(); + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + + /** + * @return the policyDBDaoUrl + */ + public String getPolicyDBDaoUrl() { + return policyDBDaoUrl; + } + + /** + * @param url the policyDBDaoUrl to set + */ + public void setPolicyDBDaoUrl(String url) { + this.policyDBDaoUrl = url; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the createdDate + */ + public Date getCreatedDate() { + return createdDate; + } + + /** + * @return the modifiedDate + */ + public Date getModifiedDate() { + return modifiedDate; + } + + public String getUsername(){ + return this.username; + } + public void setUsername(String username){ + this.username = username; + } + public String getPassword(){ + return this.password; + } + public void setPassword(String password){ + this.password = password; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyEditorScopes.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyEditorScopes.java new file mode 100644 index 000000000..daf97b3ed --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyEditorScopes.java @@ -0,0 +1,159 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + +@Entity +@Table(name="PolicyEditorScopes") +@NamedQuery(name="PolicyEditorScopes.findAll", query="SELECT p FROM PolicyEditorScopes p ") +public class PolicyEditorScopes implements Serializable{ + private static final long serialVersionUID = 1L; + private static Log logger = LogFactory.getLog(PolicyEditorScopes.class); + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="scopeName", nullable=false, unique=true) + @OrderBy("asc") + private String scopeName; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public PolicyEditorScopes() { + } + + public PolicyEditorScopes(String string, String userid) { + this(domain); + } + + public PolicyEditorScopes(String domain) { + this.scopeName = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId(); + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyEditorScopes", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getScopeName() { + return scopeName; + } + + public void setScopeName(String scopeName) { + this.scopeName = scopeName; + } + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyEntity.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyEntity.java new file mode 100644 index 000000000..80869c225 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyEntity.java @@ -0,0 +1,318 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.Index; +import javax.persistence.JoinColumn; +import javax.persistence.Lob; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OneToOne; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.SequenceGenerator; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.UniqueConstraint; +import javax.persistence.Version; + +import com.fasterxml.jackson.annotation.JsonBackReference; +import com.fasterxml.jackson.annotation.JsonManagedReference; + +/* + * The Entity class to persist a policy object and its configuration data + */ + +/** + * + */ +@Entity +//Add a non-unique index and a constraint that says the combo of policyName and scopeId must be unique +@Table(name="PolicyEntity", indexes = {@Index(name="scope", columnList="scope", unique=false), + @Index(name="policyName", columnList="policyName", unique=false)}, + uniqueConstraints=@UniqueConstraint(columnNames={"policyName", "scope"})) + +//Using a sequence generator because the value is available as soon as the +//the object is persisted. That is, you don't have to flush/commit to the DB. +//@SequenceGenerator(name="seqPolicy", initialValue=1, allocationSize=1) + +@NamedQueries({ + @NamedQuery(name="PolicyEntity.findAll", query="SELECT e FROM PolicyEntity e "), + @NamedQuery(name="PolicyEntity.findAllByDeletedFlag", query="SELECT e FROM PolicyEntity e WHERE e.deleted = :deleted"), + @NamedQuery(name="PolicyEntity.FindById", query="SELECT e FROM PolicyEntity e WHERE e.policyId = :id"), + @NamedQuery(name="PolicyEntity.deleteAll", query="DELETE FROM PolicyEntity WHERE 1=1"), + @NamedQuery(name="PolicyEntity.findByNameAndScope", query="SELECT e FROM PolicyEntity e WHERE e.policyName = :name AND e.scope = :scope") +}) + +public class PolicyEntity implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + //@GeneratedValue(strategy = GenerationType.SEQUENCE, generator="seqPolicy") + @GeneratedValue(strategy = GenerationType.AUTO) + @Column (name="policyId") + @JsonBackReference + private long policyId; + + @Column(name="policyName", nullable=false, unique=false, length=255) + private String policyName; + + //The scope is the directory structure in dot notation. For example: org.openecomp.myproject + @Column(name="scope", nullable=false, unique=false, length=255) + private String scope; + + @Version + @Column(name="version") + private int version; + + //not going to be used + @Column(name="policyVersion") + private int policyVersion = 0; + + @Lob + @Column(name="policyData", nullable=false, columnDefinition="TEXT") + private String policyData = "NoData"; + + @OneToOne(optional=true, orphanRemoval=true) + @JoinColumn(name="configurationDataId", referencedColumnName="configurationDataId") + @JsonManagedReference + private ConfigurationDataEntity configurationDataEntity; + + @OneToOne(optional=true, orphanRemoval=true) + @JoinColumn(name="actionBodyId", referencedColumnName="actionBodyId") + @JsonManagedReference + private ActionBodyEntity actionBodyEntity; + + @Column(name="created_by", nullable=false, length=255) + private String createdBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=false, length=2048) + private String description = "NoDescription"; + + @Column(name="modified_by", nullable=false, length=255) + private String modifiedBy = "guest"; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @Column(name="deleted", nullable=false) + private boolean deleted = false; + + public PolicyEntity() { + super(); + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + } + + /* + public void resetPolicyVersion(){ + this.policyVersion = 1; + } + public void advancePolicyVersion(){ + this.policyVersion++; + } + public int getPolicyVersion(){ + return this.policyVersion; + } + public void setPolicyVersion(int polVer){ + this.policyVersion = polVer; + } + */ + + /** + * @return the policyId + */ + public long getPolicyId() { + return policyId; + } + + /** + * @param policyId cannot be set + */ + + public String getPolicyName() { + return policyName; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + /** + * @return the policyData + */ + public String getPolicyData() { + return policyData; + } + + /** + * @param policyData the policyData to set + */ + public void setPolicyData(String policyData) { + this.policyData = policyData; + } + + /** + * @return the configurationDataEntity + */ + public ConfigurationDataEntity getConfigurationData() { + return configurationDataEntity; + } + + /** + * @param configurationDataEntity the configurationDataEntity to set + */ + public void setConfigurationData(ConfigurationDataEntity configurationDataEntity) { + this.configurationDataEntity = configurationDataEntity; + } + + /** + * @return the actionBodyEntity + */ + public ActionBodyEntity getActionBodyEntity() { + return actionBodyEntity; + } + + /** + * @param actionBodyEntity the actionBodyEntity to set + */ + public void setActionBodyEntity(ActionBodyEntity actionBodyEntity) { + this.actionBodyEntity = actionBodyEntity; + } + + /** + * @return the scope + */ + public String getScope() { + return scope; + } + + /** + * @param scope the scope to set + */ + public void setScope(String scope) { + this.scope = scope; + } + + /** + * @return the createdBy + */ + public String getCreatedBy() { + return createdBy; + } + + /** + * @param createdBy the createdBy to set + */ + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + /** + * @return the description + */ + public String getDescription() { + return description; + } + + /** + * @param description the description to set + */ + public void setDescription(String description) { + this.description = description; + } + + /** + * @return the modifiedBy + */ + public String getModifiedBy() { + return modifiedBy; + } + + /** + * @param modifiedBy the modifiedBy to set + */ + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + + /** + * @return the version + */ + public int getVersion() { + return version; + } + + /** + * @return the createdDate + */ + public Date getCreatedDate() { + return createdDate; + } + + /** + * @return the modifiedDate + */ + public Date getModifiedDate() { + return modifiedDate; + } + + /** + * @return the deleted + */ + public boolean isDeleted() { + return deleted; + } + + /** + * @param deleted the deleted to set + */ + public void setDeleted(boolean deleted) { + this.deleted = deleted; + } + + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyManagement.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyManagement.java new file mode 100644 index 000000000..3f036d555 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyManagement.java @@ -0,0 +1,162 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.sql.Clob; +import java.sql.Timestamp; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.Table; + + +/** + * The persistent class for the roles database table. + * + */ +@Entity +@Table(name="policy_manangement") +@NamedQuery(name="PolicyManagement.findAll", query="SELECT r FROM PolicyManagement r") +public class PolicyManagement implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + + @Column(name="id") + private int id; + + @Column(name="POLICY_NAME", nullable=false, length=45) + private String policyName; + + @Column(name="scope", nullable=false, length=45) + private String scope; + + @Column(name="ECOMP_NAME", nullable=false, length=45) + private String ecompName; + + @Column(name="CONFIG_NAME", nullable=false, length=45) + private String configName; + + @Column(name="XML", nullable=false) + private Clob xml; + + @Column(name="CREATE_DATE_TIME", nullable=false) + private Timestamp createDateTime; + + + @Column(name="CREATED_BY", nullable=false, length=45) + private String createdBy; + + @Column(name="UPDATE_DATE_TIME", nullable=false) + private Timestamp updateDateTime; + + @Column(name="UPDATED_BY", nullable=false, length=45) + private String updatedBy; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getPolicyName() { + return policyName; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + public String getScope() { + return scope; + } + + public void setScope(String scope) { + this.scope = scope; + } + + public String getEcompName() { + return ecompName; + } + + public void setEcompName(String ecompName) { + this.ecompName = ecompName; + } + + public String getConfigName() { + return configName; + } + + public void setConfigName(String configName) { + this.configName = configName; + } + + public Clob getXml() { + return xml; + } + + public void setXml(Clob xml) { + this.xml = xml; + } + + public Timestamp getCreateDateTime() { + return createDateTime; + } + + public void setCreateDateTime(Timestamp createDateTime) { + this.createDateTime = createDateTime; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public Timestamp getUpdateDateTime() { + return updateDateTime; + } + + public void setUpdateDateTime(Timestamp updateDateTime) { + this.updateDateTime = updateDateTime; + } + + public String getUpdatedBy() { + return updatedBy; + } + + public void setUpdatedBy(String updatedBy) { + this.updatedBy = updatedBy; + } + + + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyRoles.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyRoles.java new file mode 100644 index 000000000..71df02b99 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyRoles.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.Table; + +import org.openecomp.policy.rest.jpa.UserInfo; + + +/** + * The persistent class for the roles database table. + * + */ +@Entity +@Table(name="roles") +@NamedQuery(name="PolicyRoles.findAll", query="SELECT r FROM PolicyRoles r ") +public class PolicyRoles implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + + @Column(name="id") + private int id; + + @ManyToOne + @JoinColumn(name="loginid") + @OrderBy("asc") + private UserInfo loginid; + + public UserInfo getLoginId() { + return loginid; + } + + public void setLoginId(UserInfo loginid) { + this.loginid = loginid; + } + + @Column(name="scope", nullable=true, length=45) + private String scope; + + @Column(name="role", nullable=false, length=45) + private String role; + + public PolicyRoles() { + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getScope() { + return this.scope; + } + + public void setScope(String scope) { + this.scope = scope; + + } + public String getRole() { + return this.role; + } + + public void setRole(String role) { + this.role = role; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeClosedLoop.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeClosedLoop.java new file mode 100644 index 000000000..484851d7b --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeClosedLoop.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="PolicyScopeClosedLoop") +@NamedQuery(name="PolicyScopeClosedLoop.findAll", query="SELECT e FROM PolicyScopeClosedLoop e ") +public class PolicyScopeClosedLoop implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description ") + private String description ; + + public PolicyScopeClosedLoop() { + + } + public PolicyScopeClosedLoop(String string, String userid) { + this(domain); + + } + public PolicyScopeClosedLoop(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + public String getDescriptionValue() { + return this.description ; + } + + public void setDescriptionValue(String description ) { + this.description = description ; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeResource.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeResource.java new file mode 100644 index 000000000..e126c4118 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeResource.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="PolicyScopeResource") +@NamedQuery(name="PolicyScopeResource.findAll", query="SELECT e FROM PolicyScopeResource e ") +public class PolicyScopeResource implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description ") + private String description ; + + public PolicyScopeResource() { + + } + public PolicyScopeResource(String string, String userid) { + this(domain); + + } + public PolicyScopeResource(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + public String getDescriptionValue() { + return this.description ; + } + + public void setDescriptionValue(String description ) { + this.description = description ; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeService.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeService.java new file mode 100644 index 000000000..cc8c11383 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeService.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="PolicyScopeService") +@NamedQuery(name="PolicyScopeService.findAll", query="SELECT e FROM PolicyScopeService e ") +public class PolicyScopeService implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description ") + private String description ; + + public PolicyScopeService() { + + } + public PolicyScopeService(String string, String userid) { + this(domain); + + } + public PolicyScopeService(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + public String getDescriptionValue() { + return this.description ; + } + + public void setDescriptionValue(String description ) { + this.description = description ; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeType.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeType.java new file mode 100644 index 000000000..d4ade7fe9 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScopeType.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="PolicyScopeType") +@NamedQuery(name="PolicyScopeType.findAll", query="SELECT e FROM PolicyScopeType e ") +public class PolicyScopeType implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description ") + private String description ; + + public PolicyScopeType() { + + } + public PolicyScopeType(String string, String userid) { + this(domain); + + } + public PolicyScopeType(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + public String getDescriptionValue() { + return this.description ; + } + + public void setDescriptionValue(String description ) { + this.description = description ; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScore.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScore.java new file mode 100644 index 000000000..cae9cfc6a --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyScore.java @@ -0,0 +1,109 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + + +@Entity +@Table(name="POLICYSCORE") +@NamedQueries({ + @NamedQuery(name="POLICYSCORE.findAll", query="SELECT p FROM PolicyScore p"), + @NamedQuery(name="POLICYSCORE.deleteAll", query="DELETE FROM PolicyScore WHERE 1=1"), + @NamedQuery(name="POLICYSCORE.findByPolicyName", query="Select p from PolicyScore p where p.PolicyName=:pname") +}) +public class PolicyScore implements Serializable { + + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="POLICY_NAME", nullable=false) + @OrderBy("asc") + private String PolicyName; + + @Column(name="VERSIONEXTENSION", nullable=false) + @OrderBy("asc") + private String VersionExtension; + + @Column(name="POLICY_SCORE", nullable=true) + private String PolicyScore; + + public PolicyScore() { + + } + + public PolicyScore(String pName, String pScore) { + this(domain); + + } + public PolicyScore(String domain) { + + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + public String getPolicyName() { + return PolicyName; + } + public void setPolicyName(String policyName) { + PolicyName = policyName; + } + public String getVersionExtension() { + return VersionExtension; + } + + public void setVersionExtension(String versionExtension) { + VersionExtension = versionExtension; + } + public String getPolicyScore() { + return PolicyScore; + } + public void setPolicyScore(String policyScore) { + PolicyScore = policyScore; + } + + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyVersion.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyVersion.java new file mode 100644 index 000000000..73d39ad8e --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PolicyVersion.java @@ -0,0 +1,182 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +//import java.sql.Clob; +import java.sql.Timestamp; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQueries; +import javax.persistence.NamedQuery; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + + +@Entity +@Table(name="PolicyVersion") +@NamedQueries({ + @NamedQuery(name="PolicyVersion.findAll", query="SELECT p FROM PolicyVersion p"), + @NamedQuery(name="PolicyVersion.deleteAll", query="DELETE FROM PolicyVersion WHERE 1=1"), + @NamedQuery(name="PolicyVersion.findByPolicyName", query="Select p from PolicyVersion p where p.policyName=:pname") +}) +public class PolicyVersion implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + + @Column(name="id") + private int id; + + @Column(name="POLICY_NAME", nullable=false, length=255) + private String policyName; + + @Column(name="ACTIVE_VERSION") + private int activeVersion; + + @Column(name="HIGHEST_VERSION") + private int higherVersion; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", nullable=false) + private Date createdDate; + + + public int getActiveVersion() { + return activeVersion; + } + + public void setActiveVersion(int activeVersion) { + this.activeVersion = activeVersion; + } + + public int getHigherVersion() { + return higherVersion; + } + + public void setHigherVersion(int higherVersion) { + this.higherVersion = higherVersion; + } + + @Column(name="CREATED_BY", nullable=false, length=45) + private String createdBy; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + + @Column(name="modified_by", nullable=false, length=45) + private String modifiedBy; + + public PolicyVersion(String domain, String loginUserId) { + this(domain); + this.createdBy = loginUserId; + this.modifiedBy = loginUserId; + } + + public PolicyVersion(String domain) { + this.policyName = domain; + } + + public PolicyVersion(){ + + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + /* + * The modifiedBy must be set via the setModifiedBy() method since PolicyVersion + * has been moved to XACML-REST module for access from the XACML-PAP-REST module + + String userid = ((XacmlAdminUI) UI.getCurrent()).getLoginUserId(); + this.modifiedBy =userid; + * + */ + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getPolicyName() { + return policyName; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Timestamp createdDate) { + this.createdDate = createdDate; + } + + public String getCreatedBy() { + return createdBy; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public Date getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(Timestamp modifiedDate) { + this.modifiedDate = modifiedDate; + } + + public String getModifiedBy() { + return modifiedBy; + } + + public void setModifiedBy(String modifiedBy) { + this.modifiedBy = modifiedBy; + } + +} + diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PortList.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PortList.java new file mode 100644 index 000000000..88ce58afc --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/PortList.java @@ -0,0 +1,107 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name="portlist") +@NamedQuery(name="PortList.findAll", query="SELECT e FROM PortList e ") +public class PortList implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="portname", nullable=false) + @OrderBy("asc") + private String portName; + + @Column(name="description") + private String description; +/* + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate;*/ + + public PortList() { + + } + public PortList(String string, String userid) { + this(domain); + + } + public PortList(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getPortName() { + return this.portName; + } + + public void setPortName(String portName) { + this.portName = portName; + + } + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ProtocolList.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ProtocolList.java new file mode 100644 index 000000000..a450c2551 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ProtocolList.java @@ -0,0 +1,108 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name="protocollist") +@NamedQuery(name="ProtocolList.findAll", query="SELECT e FROM ProtocolList e ") +public class ProtocolList implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="protocolname", nullable=false) + @OrderBy("asc") + private String protocolName; + + @Column(name="description") + private String description; +/* + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate;*/ + + public ProtocolList() { + + } + public ProtocolList(String string, String userid) { + this(domain); + + } + public ProtocolList(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + public String getProtocolName() { + return this.protocolName; + } + + public void setProtocolName(String protocolName) { + this.protocolName = protocolName; + + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RemoteCatalogValues.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RemoteCatalogValues.java new file mode 100644 index 000000000..c906c79cb --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RemoteCatalogValues.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="RemoteCatalogValues") +@NamedQuery(name="RemoteCatalogValues.findAll", query="SELECT e FROM RemoteCatalogValues e ") +public class RemoteCatalogValues implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="value") + private String value; + + + public RemoteCatalogValues() { + + } + public RemoteCatalogValues(String string, String userid) { + this(domain); + + } + public RemoteCatalogValues(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RiskType.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RiskType.java new file mode 100644 index 000000000..da18c744e --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RiskType.java @@ -0,0 +1,178 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; +import org.openecomp.policy.rest.jpa.UserInfo; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonManagedReference; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name="RiskType") +@NamedQuery(name="RiskType.findAll", query="SELECT e FROM RiskType e ") +public class RiskType implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false, unique=true) + @OrderBy("asc") + private String name; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(RiskType.class); + + public RiskType() { + + } + + public RiskType(String string, String userid) { + this(domain); + } + + public RiskType(String domain) { + this.name = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId(); + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "RiskType", "Exception caused While adding Modified by Role"); + } + } + public String getRiskName() { + return this.name; + } + + public void setRiskName(String riskName) { + this.name = riskName; + + } + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RuleAlgorithms.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RuleAlgorithms.java new file mode 100644 index 000000000..4ec0dff67 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/RuleAlgorithms.java @@ -0,0 +1,125 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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========================================================= + */ + +/* + * AT&T - PROPRIETARY + * THIS FILE CONTAINS PROPRIETARY INFORMATION OF + * AT&T AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN + * ACCORDANCE WITH APPLICABLE AGREEMENTS. + * + * Copyright (c) 2014 AT&T Knowledge Ventures + * Unpublished and Not for Publication + * All Rights Reserved + */ +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Transient; + +import com.att.research.xacml.api.Identifier; + +@Entity +@Table(name="RuleAlgorithms") +@NamedQuery(name="RuleAlgorithms.findAll", query="SELECT d FROM RuleAlgorithms d") +public class RuleAlgorithms implements Serializable { + private static final long serialVersionUID = 1L; + + public static final char STANDARD = 'S'; + public static final char CUSTOM = 'C'; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="is_standard", nullable=false) + private char isStandard; + + @Column(name="xacml_id", nullable=false, unique=true, length=255) + private String xacmlId; + + @Column(name="short_name", nullable=false, length=64) + private String shortName; + + public RuleAlgorithms(Identifier id, char standard) { + if (id != null) { + this.xacmlId = id.stringValue(); + } + this.isStandard = standard; + } + public RuleAlgorithms(Identifier id) { + this(id, RuleAlgorithms.STANDARD); + } + + public RuleAlgorithms() { + this(null, RuleAlgorithms.STANDARD); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public char getIsStandard() { + return this.isStandard; + } + + public void setIsStandard(char isStandard) { + this.isStandard = isStandard; + } + + @Transient + public boolean isStandard() { + return (this.isStandard == RuleAlgorithms.STANDARD); + } + + @Transient + public boolean isCustom() { + return (this.isStandard == RuleAlgorithms.CUSTOM); + } + + public String getXacmlId() { + return this.xacmlId; + } + + public void setXacmlId(String xacmlId) { + this.xacmlId = xacmlId; + } + + public String getShortName() { + return shortName; + } + + public void setShortName(String shortName) { + this.shortName = shortName; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SafePolicyWarning.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SafePolicyWarning.java new file mode 100644 index 000000000..8d3a0f277 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SafePolicyWarning.java @@ -0,0 +1,109 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="SafePolicyWarning") +@NamedQuery(name="SafePolicyWarning.findAll", query="SELECT e FROM SafePolicyWarning e ") +public class SafePolicyWarning implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="message") + private String message ; + + @Column(name="riskType") + private String riskType ; + + public String getRiskType() { + return riskType; + } + public void setRiskType(String riskType) { + this.riskType = riskType; + } + public SafePolicyWarning() { + + } + public SafePolicyWarning(String string, String userid) { + this(domain); + + } + public SafePolicyWarning(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + public void setName(String name) { + this.name = name; + + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SecurityZone.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SecurityZone.java new file mode 100644 index 000000000..2fbd4486d --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SecurityZone.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name="securityzone") +@NamedQuery(name="SecurityZone.findAll", query="SELECT e FROM SecurityZone e ") +public class SecurityZone implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String zoneName; + + @Column(name="value") + private String zoneValue; + + + public SecurityZone() { + + } + public SecurityZone(String string, String userid) { + this(domain); + + } + public SecurityZone(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getZoneName() { + return this.zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + + } + public String getZoneValue() { + return this.zoneValue; + } + + public void setZoneValue(String zoneValue) { + this.zoneValue = zoneValue; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ServiceList.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ServiceList.java new file mode 100644 index 000000000..9a72916b1 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/ServiceList.java @@ -0,0 +1,157 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name="servicegroup") +@NamedQuery(name="ServiceList.findAll", query="SELECT e FROM ServiceList e ") +public class ServiceList implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String serviceName; + + @Column(name="description") + private String serviceDesc; + + @Column(name="type") + private String serviceType; + + @Column(name="transportprotocol") + private String serviceTrasProtocol; + + @Column(name="appprotocol ") + private String serviceAppProtocol; + + @Column(name="ports") + private String servicePorts; + + + +/* + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate;*/ + + public ServiceList() { + + } + public ServiceList(String string, String userid) { + this(domain); + + } + public ServiceList(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getServiceName() { + return this.serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + + } + + public String getServiceDescription() { + return this.serviceDesc; + } + + public void setServiceDescription(String serviceDesc) { + this.serviceDesc = serviceDesc; + + } + + public String getServiceType() { + return this.serviceType; + } + + public void setServiceType(String serviceType) { + this.serviceType = serviceType; + } + + public String getServiceTransProtocol() { + return this.serviceTrasProtocol; + } + + public void setServiceTransProtocol(String serviceTrasProtocol) { + this.serviceTrasProtocol = serviceTrasProtocol; + + } + + public String getServiceAppProtocol() { + return this.serviceAppProtocol; + } + + public void setServiceAppProtocol(String serviceAppProtocol) { + this.serviceAppProtocol = serviceAppProtocol; + + } + public String getServicePorts() { + return this.servicePorts; + } + + public void setServicePorts(String servicePorts) { + this.servicePorts = servicePorts; + + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SystemLogDB.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SystemLogDB.java new file mode 100644 index 000000000..a86857aee --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/SystemLogDB.java @@ -0,0 +1,173 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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========================================================= + */ + +/* + * AT&T - PROPRIETARY + * THIS FILE CONTAINS PROPRIETARY INFORMATION OF + * AT&T AND IS NOT TO BE DISCLOSED OR USED EXCEPT IN + * ACCORDANCE WITH APPLICABLE AGREEMENTS. + * + * Copyright (c) 2013 AT&T Knowledge Ventures + * Unpublished and Not for Publication + * All Rights Reserved + */ +package org.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OneToMany; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; +import javax.persistence.Transient; + +import com.att.research.xacml.api.Identifier; + +/** + * The persistent class for the system log database table. + * +*/ +@Entity +@Table(name="SystemLogDB") +@NamedQuery(name="SystemLogDB.findAll", query="SELECT o FROM SystemLogDB o") +public class SystemLogDB implements Serializable { + private static final long serialVersionUID = 1L; + + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="type", nullable=false) + private String type; + + @Column(name="system", nullable=false, length=255) + private String system; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Column(name="remote", nullable=false, length=255) + private String remote; + + @Column(name="logtype", nullable=false, length=255) + private String logtype; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="date", nullable=false, updatable=false) + private Date date; + + public SystemLogDB() { + super(); + } + + public SystemLogDB(int id, String system, String description, String remote, + String type, String logtype) { + // TODO Auto-generated constructor stub + this.id = id; + this.system = system; + this.description = description; + this.remote = remote; + this.type = type; + this.logtype = logtype; + } + + public void SystemLogB (int id, String system, String description, String remote, String type, Date date, String logtype){ + this.id = id; + this.system = system; + this.description = description; + this.remote = remote; + this.type = type; + this.date = date; + this.logtype = logtype; + + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getDate(){ + return this.date; + } + + public void setDate(Date date){ + this.date = date; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getType() { + return this.type; + } + + public void setType(String type) { + this.type = type; + + } + + public String getSystem() { + return this.system; + } + + public void setSystem(String system) { + this.system = system; + } + + public String getRemote() { + return this.remote; + } + + public void setRemote(String remote) { + this.remote = remote; + + } + public String getLogtype() { + return this.logtype; + } + + public void setLogtype(String logtype) { + this.logtype = logtype; + + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/TermList.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/TermList.java new file mode 100644 index 000000000..ce94fb8d8 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/TermList.java @@ -0,0 +1,262 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name="TERM") +@NamedQuery(name="TermList.findAll", query="SELECT e FROM TermList e") +public class TermList implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="termName", nullable=false) + @OrderBy("asc") + private String termName; + + @Column(name="description") + private String termDescription; + + @Column(name="fromzone") + private String fromZone; + + @Column(name="tozone") + private String toZone; + + @Column(name="srcIPList") + private String srcIPList; + + @Column(name="destIPList") + private String destIPList; + + @Column(name="protocolList") + private String protocolList; + + @Column(name="portList") + private String portList; + + @Column(name="srcPortList") + private String srcPortList; + + @Column(name="destPortList") + private String destPortList; + + @Column(name="action") + private String action; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(TermList.class); + + public TermList() { + + } + + private static final Log auditLogger = LogFactory + .getLog("auditLogger"); + + public TermList(String string, String userid) { + this(domain); + } + public TermList(String domain) { + this.termName = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + auditLogger.debug("Added New Term Name: "+this.termName+" by "+this.userCreatedBy); + + } + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "TermList", "Exception caused While adding Modified by Role"); + } + auditLogger.debug("Updated Term Name: "+this.termName+" by "+this.userModifiedBy); + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getTermName() { + return this.termName; + } + + public void setTermName(String termName) { + this.termName = termName; + } + + public String getTermDescription() { + return this.termDescription; + } + + public void setDescription(String termDescription) { + this.termDescription = termDescription; + } + + public String getFromZone() { + return this.fromZone; + } + + public void setFromZones(String fromZone) { + this.fromZone = fromZone; + } + + public String getToZone() { + return this.toZone; + } + + public void setToZones(String toZone) { + this.toZone = toZone; + } + + public String getSrcIPList() { + return this.srcIPList; + } + + public void setSrcIPList(String srcIPList) { + this.srcIPList = srcIPList; + } + + public String getDestIPList() { + return this.destIPList; + } + + public void setDestIPList(String destIPList) { + this.destIPList = destIPList; + } + + public String getProtocolList() { + return this.protocolList; + } + + public void setProtocolList(String protocolList) { + this.protocolList = protocolList; + } + + public String getPortList() { + return this.portList; + } + + public void setPortList(String portList) { + this.portList = portList; + } + + public String getSrcPortList() { + return this.srcPortList; + } + + public void setSrcPortList(String srcPortList) { + this.srcPortList = srcPortList; + } + + public String getDestPortList() { + return this.destPortList; + } + + public void setDestPortList(String destPortList) { + this.destPortList = destPortList; + } + + + public String getAction() { + return this.action; + } + + public void setAction(String action) { + this.action = action; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/UserInfo.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/UserInfo.java new file mode 100644 index 000000000..6f5982aa8 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/UserInfo.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.Table; +import javax.persistence.Transient; + +import com.att.research.xacml.api.Identifier; +import com.att.research.xacml.std.IdentifierImpl; +import com.fasterxml.jackson.annotation.JsonBackReference; + +@Entity +@Table(name = "UserInfo") +@NamedQuery(name="UserInfo.findAll", query="SELECT u FROM UserInfo u ") +public class UserInfo implements Serializable { + private static final long serialVersionUID = 1L; + + @Id + @Column(name="loginId", nullable=false, length=45) + private String userLoginId; + + @Column(name = "name", nullable = false, unique = true) + private String userName; + + public UserInfo(){ + this.userLoginId = userName; + + } + + public String getUserLoginId() { + return userLoginId; + } + + public void setUserLoginId(String loginid) { + this.userLoginId = loginid; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + @Transient + @JsonBackReference + public Identifier getIdentiferByUserId() { + return new IdentifierImpl(this.userName); + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VMType.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VMType.java new file mode 100644 index 000000000..a1adcd447 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VMType.java @@ -0,0 +1,103 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; + + +@Entity +@Table(name="VMType") +@NamedQuery(name="VMType.findAll", query="SELECT e FROM VMType e ") +public class VMType implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="name", nullable=false) + @OrderBy("asc") + private String name; + + @Column(name="description") + private String description; + + + public VMType() { + + } + public VMType(String string, String userid) { + this(domain); + + } + public VMType(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getName() { + return this.name; + } + + public void setName(String name) { + this.name = name; + + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VNFType.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VNFType.java new file mode 100644 index 000000000..a2c19da31 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VNFType.java @@ -0,0 +1,174 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + + +@Entity +@Table(name="VNFType") +@NamedQuery(name="VNFType.findAll", query="SELECT v FROM VNFType v ") +public class VNFType implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="vnf_type", nullable=false, unique=true) + @OrderBy("asc") + private String vnftype; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(VNFType.class); + + public VNFType() { + + } + + public String getVnftype() { + return vnftype; + } + + public void setVnftype(String vnftype) { + this.vnftype = vnftype; + } + + public VNFType(String string, String userid) { + this(domain); + } + + public VNFType(String domain) { + this.vnftype = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "VNFType", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VSCLAction.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VSCLAction.java new file mode 100644 index 000000000..39d671f1d --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VSCLAction.java @@ -0,0 +1,174 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + + +@Entity +@Table(name="VSCLAction") +@NamedQuery(name="VSCLAction.findAll", query="SELECT v FROM VSCLAction v ") +public class VSCLAction implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="vscl_action", nullable=false, unique=true) + @OrderBy("asc") + private String vsclaction; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Column(name="description", nullable=true, length=2048) + private String description; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(VSCLAction.class); + + public VSCLAction() { + + } + + public VSCLAction(String string, String userid) { + this(domain); + } + + public VSCLAction(String domain) { + this.vsclaction = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "VSCLAction", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getVsclaction() { + return vsclaction; + } + + public void setVsclaction(String vsclaction) { + this.vsclaction = vsclaction; + } + + + public Date getCreatedDate() { + return this.createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getModifiedDate() { + return this.modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VarbindDictionary.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VarbindDictionary.java new file mode 100644 index 000000000..05e5710d7 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/VarbindDictionary.java @@ -0,0 +1,185 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; + +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XacmlAdminAuthorization; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + +@Entity +@Table(name="VarbindDictionary") +@NamedQuery(name = "VarbindDictionary.findAll", query = "Select v FROM VarbindDictionary v") +public class VarbindDictionary implements Serializable{ + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "Id") + private int id; + + @Column(name ="varbind_Name", nullable = false, unique = true) + @OrderBy("asc") + private String varbindName; + + @Column(name = "varbind_Description", nullable = true, length = 2048) + private String varbindDescription; + + @Column(name = "varbind_oid", nullable = false) + private String varbindOID; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="created_date", updatable=false) + private Date createdDate; + + @Temporal(TemporalType.TIMESTAMP) + @Column(name="modified_date", nullable=false) + private Date modifiedDate; + + @ManyToOne(optional = false) + @JoinColumn(name="created_by") + private UserInfo userCreatedBy; + + @ManyToOne(optional = false) + @JoinColumn(name="modified_by") + private UserInfo userModifiedBy; + + public UserInfo getUserCreatedBy() { + return userCreatedBy; + } + + public void setUserCreatedBy(UserInfo userCreatedBy) { + this.userCreatedBy = userCreatedBy; + } + + public UserInfo getUserModifiedBy() { + return userModifiedBy; + } + + public void setUserModifiedBy(UserInfo userModifiedBy) { + this.userModifiedBy = userModifiedBy; + } + + private static Log logger = LogFactory.getLog(VarbindDictionary.class); + + public VarbindDictionary() { + + } + + public VarbindDictionary(String string, String userid) { + this(domain); + } + + public VarbindDictionary(String domain) { + this.varbindName = domain; + } + + @PrePersist + public void prePersist() { + Date date = new Date(); + this.createdDate = date; + this.modifiedDate = date; + } + + @PreUpdate + public void preUpdate() { + this.modifiedDate = new Date(); + try { + this.userModifiedBy =XacmlAdminAuthorization.getUserId();; + } catch (Exception e) { + logger.error("Exception caused While adding Modified by Role"+e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "VarbindDictionary", "Exception caused While adding Modified by Role"); + } + } + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + + public String getVarbindName() { + return varbindName; + } + + public void setVarbindName(String varbindName) { + this.varbindName = varbindName; + } + + public String getVarbindDescription() { + return varbindDescription; + } + + public void setVarbindDescription(String varbindDescription) { + this.varbindDescription = varbindDescription; + } + + public String getVarbindOID() { + return varbindOID; + } + + public void setVarbindOID(String varbindOID) { + this.varbindOID = varbindOID; + } + + public Date getCreatedDate() { + return createdDate; + } + + public void setCreatedDate(Date createdDate) { + this.createdDate = createdDate; + } + + public Date getModifiedDate() { + return modifiedDate; + } + + public void setModifiedDate(Date modifiedDate) { + this.modifiedDate = modifiedDate; + } + + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/WatchPolicyNotificationTable.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/WatchPolicyNotificationTable.java new file mode 100644 index 000000000..2acc82cce --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/WatchPolicyNotificationTable.java @@ -0,0 +1,80 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + * + * + * */ + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.Table; + +@Entity +@Table(name = "WatchPolicyNotificationTable") +@NamedQuery(name="WatchPolicyNotificationTable.findAll", query="SELECT e FROM WatchPolicyNotificationTable e ") +public class WatchPolicyNotificationTable implements Serializable{ + private static final long serialVersionUID = 1L; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="policyName", nullable=false, unique=true) + @OrderBy("asc") + private String policyName; + + @Column(name="loginIds", nullable=false, unique=true) + @OrderBy("asc") + private String loginIds; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getPolicyName() { + return policyName; + } + + public void setPolicyName(String policyName) { + this.policyName = policyName; + } + + public String getLoginIds() { + return loginIds; + } + + public void setLoginIds(String loginIds) { + this.loginIds = loginIds; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Zone.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Zone.java new file mode 100644 index 000000000..e1db124c3 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/Zone.java @@ -0,0 +1,104 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; +/* + */ +import java.io.Serializable; +import java.util.Date; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.NamedQuery; +import javax.persistence.OrderBy; +import javax.persistence.PrePersist; +import javax.persistence.PreUpdate; +import javax.persistence.Table; +import javax.persistence.Temporal; +import javax.persistence.TemporalType; + +@Entity +@Table(name="zone") +@NamedQuery(name="Zone.findAll", query="SELECT e FROM Zone e ") +public class Zone implements Serializable { + private static final long serialVersionUID = 1L; + + private static String domain; + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name="id") + private int id; + + @Column(name="zonename", nullable=false) + @OrderBy("asc") + private String zoneName; + + @Column(name="zonevalue") + private String zoneValue; + + + public Zone() { + + } + public Zone(String string, String userid) { + this(domain); + + } + public Zone(String domain) { + + } + + @PrePersist + public void prePersist() { + + } + @PreUpdate + public void preUpdate() { + } + + + public int getId() { + return this.id; + } + + public void setId(int id) { + this.id = id; + } + public String getZoneName() { + return this.zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + + } + public String getZoneValue() { + return this.zoneValue; + } + + public void setZoneValue(String zoneValue) { + this.zoneValue = zoneValue; + } + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/package-info.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/package-info.java new file mode 100644 index 000000000..d5b935077 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/jpa/package-info.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.jpa; diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/LockdownListener.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/LockdownListener.java new file mode 100644 index 000000000..a44ef63d8 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/LockdownListener.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.util; + +public interface LockdownListener { + /** + * lockdown has been set in database + */ + public void lockdownSet(); + + /** + * lockdown has been unset in the database + */ + public void lockdownUnset(); +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/MSAttributeObject.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/MSAttributeObject.java new file mode 100644 index 000000000..45b5aefb8 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/MSAttributeObject.java @@ -0,0 +1,88 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.util; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class MSAttributeObject { + + private String className; + private HashMap<String, String> attribute = new HashMap<String, String>(); + private HashMap<String, String> refAttribute = new HashMap<String, String>(); + private HashMap<String, String> subClass = new HashMap<String, String>(); + private String dependency; + private List<String> enumType; + + + public Map<String, String> getRefAttribute() { + return refAttribute; + } + public void setRefAttribute(HashMap<String, String> refAttribute) { + this.refAttribute = refAttribute; + } + public String getClassName() { + return className; + } + public void setClassName(String className) { + this.className = className; + } + public Map<String, String> getAttribute() { + return attribute; + } + public void setAttribute(HashMap<String, String> attribute) { + this.attribute = attribute; + } + public List<String> getEnumType() { + return enumType; + } + public void setEnumType(List<String> enumType) { + this.enumType = enumType; + } + public void addAttribute(String key, String value){ + this.attribute.put(key, value); + } + public void addRefAttribute(String key, String value){ + this.refAttribute.put(key, value); + } + public void addAllAttribute(Map<String, String> map){ + this.attribute.putAll(map); + } + public void addAllRefAttribute(Map<String, String> map){ + this.refAttribute.putAll(map); + } + public HashMap<String, String> getSubClass() { + return subClass; + } + public void setSubClass(HashMap<String, String> subClass) { + this.subClass = subClass; + } + public void addAllSubClass(HashMap<String, String> subClass){ + this.subClass.putAll(subClass); + } + public String getDependency() { + return dependency; + } + public void setDependency(String dependency) { + this.dependency = dependency; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/MSAttributeValue.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/MSAttributeValue.java new file mode 100644 index 000000000..cce8f7619 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/MSAttributeValue.java @@ -0,0 +1,60 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.util; + +public class MSAttributeValue{ + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + public Boolean getRequired() { + return required; + } + public void setRequired(Boolean required) { + this.required = required; + } + public Boolean getArrayValue() { + return arrayValue; + } + public void setArrayValue(Boolean arrayValue) { + this.arrayValue = arrayValue; + } + public String getDefaultValue() { + return defaultValue; + } + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + private String name; + private String type; + private Boolean required; + private Boolean arrayValue; + private String defaultValue; + +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/MSModelUtitils.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/MSModelUtitils.java new file mode 100644 index 000000000..dd015be68 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/MSModelUtitils.java @@ -0,0 +1,450 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.util; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.TreeIterator; +import org.eclipse.emf.ecore.EAnnotation; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; +import org.eclipse.emf.ecore.EEnum; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; +import org.eclipse.emf.ecore.EStructuralFeature; + +import org.json.JSONObject; +import org.openecomp.policy.rest.XACMLRestProperties; + +import com.att.research.xacml.util.XACMLProperties; + +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; +import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl; + + +public class MSModelUtitils { + + private static final Log logger = LogFactory.getLog(MSModelUtitils.class); + + private HashMap<String,MSAttributeObject > classMap = new HashMap<String,MSAttributeObject>(); + + public HashMap<String, MSAttributeObject> processEpackage(String xmiFile){ + EPackage root = getEpackage(xmiFile); + TreeIterator<EObject> treeItr = root.eAllContents(); + String className = null; + String returnValue = null; + + // Pulling out dependency from file + while (treeItr.hasNext()) { + EObject obj = (EObject) treeItr.next(); + if (obj instanceof EClassifier) { + EClassifier eClassifier = (EClassifier) obj; + className = eClassifier.getName(); + + if (obj instanceof EEnum) { + // getEEnum(); + returnValue = null; + }else if (obj instanceof EClass) { + String temp = getDependencyList(eClassifier, className).toString(); + returnValue = StringUtils.replaceEach(temp, new String[]{"[", "]"}, new String[]{"", ""}); + getAttributes(className, returnValue, root); + } + } + } + return classMap; + } + + private EPackage getEpackage(String xmiFile) { + ResourceSet resSet = new ResourceSetImpl(); + Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE; + Map<String, Object> m = reg.getExtensionToFactoryMap(); + m.put("xmi", new XMIResourceFactoryImpl()); + Resource resource = resSet.getResource(URI.createFileURI(xmiFile), true); + try { + resource.load(Collections.EMPTY_MAP); + } catch (IOException e) { + logger.error("Error loading Encore Resource for new Model"); + } + + EPackage root = (EPackage) resource.getContents().get(0); + + return root; + } + + private void getEEnum() { + + } + + public void getAttributes(String className, String dependency, EPackage root) { + List<String> dpendList = null; + if (dependency!=null){ + dpendList = new ArrayList<String>(Arrays.asList(dependency.split(","))); + } + MSAttributeObject msAttributeObject = new MSAttributeObject(); + msAttributeObject.setClassName(className); + HashMap<String, String> returnRefList = getRefAttributeList(root, className); + HashMap<String, String> returnAttributeList = getAttributeList(root, className); + HashMap<String, String> returnSubList = getSubAttributeList(root, className); + msAttributeObject.setAttribute(returnAttributeList); + msAttributeObject.setRefAttribute(returnRefList); + msAttributeObject.setSubClass(returnSubList); + msAttributeObject.setDependency(dpendList.toString()); + this.classMap.put(className, msAttributeObject); + } + + private HashMap<String, String> getSubAttributeList(EPackage root, String className) { + //EPackage root = (EPackage) resource.getContents().get(0); + TreeIterator<EObject> treeItr = root.eAllContents(); + boolean requiredAttribute = false; + HashMap<String, String> subAttribute = new HashMap<String, String>(); + int rollingCount = 0; + int processClass = 0; + boolean annotation = false; + + // Pulling out dependency from file + while (treeItr.hasNext() && rollingCount < 2) { + + EObject obj = treeItr.next(); + if (obj instanceof EClassifier) { + requiredAttribute = isRequiredAttribute(obj, className); + if (requiredAttribute){ + processClass++; + } + rollingCount = rollingCount+processClass; + } + + if (requiredAttribute) { + if (obj instanceof EStructuralFeature) { + EStructuralFeature eStrucClassifier = (EStructuralFeature) obj; + if (eStrucClassifier.getEAnnotations().size() != 0) { + annotation = testAnnotation(eStrucClassifier); + if (annotation && obj instanceof EReference) { + EClass refType = ((EReference) obj).getEReferenceType(); + // String array = arrayCheck(((EStructuralFeature) obj).getUpperBound()); + if(!refType.toString().contains("eProxyURI:")){ + subAttribute.put(eStrucClassifier.getName(), refType.getName()); + } + } + } + } + } + } + return subAttribute; + } + + public String checkDefultValue(String defultValue) { + if (defultValue!=null){ + return ":defaultValue-"+ defultValue; + } + return ":defaultValue-NA"; + + } + + public String checkRequiredPattern(int upper, int lower) { + String pattern = XACMLProperties.getProperty(XACMLRestProperties.PROP_XCORE_REQUIRED_PATTERN); + + if (pattern!=null){ + if (upper == Integer.parseInt(pattern.split(",")[1]) && lower==Integer.parseInt(pattern.split(",")[0])){ + return ":required-true"; + } + } + + return ":required-false"; + } + + public JSONObject buildJavaObject(HashMap<String, String> map, String attributeType){ + + JSONObject returnValue = new JSONObject(map); + + return returnValue; + + } + + public HashMap<String, String> getRefAttributeList(EPackage root, String className){ + + TreeIterator<EObject> treeItr = root.eAllContents(); + boolean requiredAttribute = false; + HashMap<String, String> refAttribute = new HashMap<String, String>(); + int rollingCount = 0; + int processClass = 0; + boolean annotation = false; + + // Pulling out dependency from file + while (treeItr.hasNext()) { + EObject obj = treeItr.next(); + if (obj instanceof EClassifier) { + requiredAttribute = isRequiredAttribute(obj, className); + if (requiredAttribute){ + processClass++; + } + rollingCount = rollingCount+processClass; + } + + if (requiredAttribute) { + if (obj instanceof EStructuralFeature) { + EStructuralFeature eStrucClassifier = (EStructuralFeature) obj; + if (eStrucClassifier.getEAnnotations().size() != 0) { + annotation = testAnnotation(eStrucClassifier); + if ( annotation && obj instanceof EReference) { + EClass refType = ((EReference) obj).getEReferenceType(); + if(refType.toString().contains("eProxyURI:")){ + String one = refType.toString().split("eProxyURI:")[1]; + String refValue = StringUtils.replaceEach(one.split("#")[1], new String[]{"//", ")"}, new String[]{"", ""}); + refAttribute.put(eStrucClassifier.getName(), refValue); + } else { + String array = arrayCheck(((EStructuralFeature) obj).getUpperBound()); + if (array.contains("false")){ + array = ""; + } + refAttribute.put(eStrucClassifier.getName(), refType.getName() + array); + } + } + } + } + } + } + return refAttribute; + } + + private boolean testAnnotation(EStructuralFeature eStrucClassifier) { + String annotationType = null; + EAnnotation eAnnotation = null; + String ecompType = null; + + EList<EAnnotation> value = eStrucClassifier.getEAnnotations(); + + for (int i = 0; i < value.size(); i++){ + annotationType = value.get(i).getSource(); + eAnnotation = eStrucClassifier.getEAnnotations().get(i); + ecompType = eAnnotation.getDetails().get(0).getValue(); + if (annotationType.contains("http://localhost.com") && ecompType.contains("configuration")){ + return true; + } + } + + return false; + } + + public boolean isRequiredAttribute(EObject obj, String className){ + EClassifier eClassifier = (EClassifier) obj; + String workingClass = eClassifier.getName(); + workingClass.trim(); + if (workingClass.equalsIgnoreCase(className)){ + return true; + } + + return false; + } + + public HashMap<String, String> getAttributeList(EPackage root, String className){ + + TreeIterator<EObject> treeItr = root.eAllContents(); + boolean reference = false; + boolean requiredAttribute = false; + HashMap<String, String> refAttribute = new HashMap<String, String>(); + String workingClass = null; + boolean annotation = false; + + // Pulling out dependency from file + while (treeItr.hasNext()) { + reference = false; + EObject obj = treeItr.next(); + if (obj instanceof EClassifier) { + requiredAttribute = isRequiredAttribute(obj, className ); + } + + if (requiredAttribute){ + if (obj instanceof EStructuralFeature) { + EStructuralFeature eStrucClassifier = (EStructuralFeature) obj; + if (eStrucClassifier.getEAnnotations().size() != 0) { + annotation = testAnnotation(eStrucClassifier); + if (annotation && !(obj instanceof EReference)) { + String name = eStrucClassifier.getName(); + String defaultValue = checkDefultValue(((EStructuralFeature) obj).getDefaultValueLiteral()); + String eType = eStrucClassifier.getEType().getInstanceClassName(); + String array = arrayCheck(((EStructuralFeature) obj).getUpperBound()); + String required = checkRequiredPattern(((EStructuralFeature) obj).getUpperBound(), ((EStructuralFeature) obj).getLowerBound()); + String attributeValue = eType + defaultValue + required + array; + refAttribute.put(name, attributeValue); + } + } + } + } + } + return refAttribute; + + } + + public String arrayCheck(int upperBound) { + + if (upperBound == -1){ + return ":MANY-true"; + } + + return ":MANY-false"; + } + + public List<String> getDependencyList(EClassifier eClassifier, String className){ + List<String> returnValue = new ArrayList<>();; + EList<EClass> somelist = ((EClass) eClassifier).getEAllSuperTypes(); + if (somelist.isEmpty()){ + return returnValue; + } + for(EClass depend: somelist){ + if (depend.toString().contains("eProxyURI:")){ + String one = depend.toString().split("eProxyURI:")[1]; + String value = StringUtils.replaceEach(one.split("#")[1], new String[]{"//", ")"}, new String[]{"", ""}); + returnValue.add(value); + } + } + + return returnValue; + } + + public String createJson(HashMap<String, String> subClassAttributes, HashMap<String, MSAttributeObject> classMap, String className) { + String json = ""; + JSONObject jsonObj; + + jsonObj = new JSONObject(); + + Map<String, String> missingValues = new HashMap<String, String>(); + Map<String, String> workingMap = new HashMap<String, String>(); + + for ( Entry<String, String> map : classMap.get(className).getRefAttribute().entrySet()){ + String value = map.getValue().split(":")[0]; + if (value!=null){ + workingMap = classMap.get(value).getRefAttribute(); + for ( Entry<String, String> subMab : workingMap.entrySet()){ + String value2 = subMab.getValue().split(":")[0]; + if (!subClassAttributes.containsValue(value2)){ + missingValues.put(subMab.getKey(), subMab.getValue()); + classMap.get(value).addAttribute(subMab.getKey(), subMab.getValue()); + } + } + + } + } + + if (!missingValues.isEmpty()){ + for (Entry<String, String> addValue : missingValues.entrySet()){ + subClassAttributes.put(addValue.getKey(), addValue.getValue().split(":")[0]); + } + } + + for ( Map.Entry<String, String> map : subClassAttributes.entrySet()){ + jsonObj.put(map.getValue().split(":")[0], classMap.get(map.getValue().split(":")[0]).getAttribute()); + } + + if (logger.isDebugEnabled()) { + logger.debug("Json value: " + jsonObj); + } + + return jsonObj.toString(); + } + + public String createSubAttributes(ArrayList<String> dependency, HashMap<String, MSAttributeObject> classMap, String modelName) { + + HashMap <String, String> workingMap = new HashMap<String,String>(); + MSAttributeObject tempObject = new MSAttributeObject(); + HashMap <String, String> refAttribute = new HashMap<String,String>(); + HashMap <String, String> workingSubMap = new HashMap<String,String>(); + Map<String, String> tempPefAttribute = null; + LinkedList linkedList = new LinkedList(); + String addedValue = null; + + boolean addingValues = false; + + if (dependency!=null){ + if (dependency.size()==0){ + return "{}"; + } + dependency.add(modelName); + for (String element: dependency){ + tempObject = classMap.get(element); + if (tempObject!=null){ + workingMap.putAll(classMap.get(element).getSubClass()); + // workingSubMap = CheckForSecondSubClass(classMap.get(element).getSubClass(), classMap); + // if (workingSubMap!=null){ + // workingMap.putAll(workingSubMap); + // } + } + } + } + + String returnValue = createJson(workingMap, classMap, modelName); + return returnValue; + } + + private HashMap<String, String> CheckForSecondSubClass(HashMap<String, String> subClass, HashMap<String, MSAttributeObject> mainMap) { + MSAttributeObject tempObject = new MSAttributeObject(); + HashMap<String, String> subClassValue = new HashMap<String,String>(); + + for (Entry<String, String> classSet : subClass.entrySet()){ + String key = classSet.getKey(); + String value = classSet.getValue(); + tempObject = mainMap.get(value); + subClassValue = tempObject.getSubClass(); + if (subClassValue!=null){ + return subClassValue; + } + } + return null; + + } + + public ArrayList<String> getFullDependencyList(ArrayList<String> dependency, HashMap<String,MSAttributeObject > classMap) { + ArrayList<String> returnList = new ArrayList<String>(); + ArrayList<String> workingList = new ArrayList<String>(); + int i = 0; + MSAttributeObject newDepend = null; + returnList.addAll(dependency); + for (String element : dependency ){ + if (classMap.containsKey(element)){ + MSAttributeObject value = classMap.get(element); + String rawValue = StringUtils.replaceEach(value.getDependency(), new String[]{"[", "]"}, new String[]{"", ""}); + workingList = new ArrayList<String>(Arrays.asList(rawValue.split(","))); + for(String depend : workingList){ + if (!returnList.contains(depend) && !depend.isEmpty()){ + returnList.add(depend.trim()); + } + } + } + } + + return returnList; + } +} diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/ModelObject.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/ModelObject.java new file mode 100644 index 000000000..bc7fa9f2d --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/ModelObject.java @@ -0,0 +1,157 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import com.vaadin.ui.TextField; +import com.vaadin.ui.VerticalLayout; + +public class ModelObject { + private String name; + private String parent; + private List<String> attibutes = new ArrayList<String>(); + private List<String> arrays = new ArrayList<String>(); + private List<Integer> integers = new ArrayList<Integer>(); + private List<ModelObject> subObjects = new ArrayList<ModelObject>(); + private HashMap<String, LinkedList<ModelObject>> subObjectList = new HashMap<String, LinkedList<ModelObject>>(); + private HashMap<String, TextField> attribute = new HashMap<String, TextField>(); + private Map<String, LinkedList<TextField>> arrayTextList = new HashMap<String, LinkedList<TextField>>(); + private Map<String, VerticalLayout> textFieldLayout = new HashMap<String, VerticalLayout>(); + + private boolean many = false; + + public Map<String, LinkedList<TextField>> getArrayTextList() { + return arrayTextList; + } + public void setArrayTextList(Map<String, LinkedList<TextField>> arrayTextList) { + this.arrayTextList = arrayTextList; + } + public void addArrayTextList(String name, TextField textField ){ + LinkedList<TextField> list = new LinkedList<TextField>(); + if (getArrayTextList().get(name) != null){ + list = getArrayTextList().get(name); + } + + list.push(textField); + this.arrayTextList.put(name, list); + } + public void removeLastTextList(String name){ + LinkedList<TextField> list = getArrayTextList().get(name); + + list.pop(); + this.arrayTextList.put(name, list); + } + public HashMap<String, TextField> getAttribute() { + return attribute; + } + public void setAttribute(HashMap<String, TextField> attribute) { + this.attribute = attribute; + } + public void addAttribute(String name, TextField textField){ + this.attribute.put(name, textField); + } + public List<String> getAttibutes() { + return attibutes; + } + public void setAttibutes(List<String> attibutes) { + this.attibutes = attibutes; + } + public List<String> getArrays() { + return arrays; + } + public void setArrays(List<String> arrays) { + this.arrays = arrays; + } + public List<Integer> getIntegers() { + return integers; + } + public void setIntegers(List<Integer> integers) { + this.integers = integers; + } + public List<ModelObject> getSubObjects() { + return subObjects; + } + public void setSubObjects(List<ModelObject> subObjects) { + this.subObjects = subObjects; + } + public void addSubObject(ModelObject subObjects ){ + this.subObjects.add(subObjects); + } + public void addAttributes(String attibutes){ + this.attibutes.add(attibutes); + } + public void addArrays(String arrays){ + this.arrays.add(arrays); + } + public void addIntegers(Integer integers){ + this.integers.add(integers); + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public boolean isMany() { + return many; + } + public void setMany(boolean many) { + this.many = many; + } + public String getParent() { + return parent; + } + public void setParent(String parent) { + this.parent = parent; + } + public HashMap<String, LinkedList<ModelObject>> getSubObjectList() { + return subObjectList; + } + public void setSubObjectList(HashMap<String, LinkedList<ModelObject>> subObjectList) { + this.subObjectList = subObjectList; + } + public void addSubObjectList(String name, ModelObject object) { + LinkedList<ModelObject> list = new LinkedList<ModelObject>(); + if (subObjectList.get(name) != null){ + list = subObjectList.get(name); + } + + list.push(object); + + this.subObjectList.put(name, list); + } + public Map<String, VerticalLayout> getTextFieldLayout() { + return textFieldLayout; + } + public void setTextFieldLayout(Map<String, VerticalLayout> textFieldLayout) { + this.textFieldLayout = textFieldLayout; + } + public void addTextFieldLayout(String name, VerticalLayout vLayout){ + this.textFieldLayout.put(name, vLayout); + } + +} +*/ diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/Webapps.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/Webapps.java new file mode 100644 index 000000000..c2f4ff2c6 --- /dev/null +++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/Webapps.java @@ -0,0 +1,113 @@ +/*- + * ============LICENSE_START======================================================= + * ECOMP-REST + * ================================================================================ + * 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.openecomp.policy.rest.util; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.openecomp.policy.rest.XACMLRestProperties; + +import org.openecomp.policy.xacml.api.XACMLErrorConstants; +import com.att.research.xacml.util.XACMLProperties; + +import org.openecomp.policy.common.logging.eelf.MessageCodes; +import org.openecomp.policy.common.logging.eelf.PolicyLogger; + +public class Webapps { + private static String actionHome = null; + private static String configHome = null; + private static Log logger = LogFactory.getLog(Webapps.class); + + private Webapps() { + } + + public static String getConfigHome(){ + try { + loadWebapps(); + } catch (Exception e) { + return null; + } + return configHome; + } + + public static String getActionHome(){ + try { + loadWebapps(); + } catch (Exception e) { + return null; + } + return actionHome; + } + + private static void loadWebapps() throws Exception{ + if(actionHome == null || configHome == null){ + Path webappsPath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS)); + //Sanity Check + if (webappsPath == null) { + logger.error("Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error("Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS); + throw new Exception("Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS); + } + Path webappsPathConfig; + Path webappsPathAction; + if(webappsPath.toString().contains("\\")) + { + webappsPathConfig = Paths.get(webappsPath.toString()+"\\Config"); + webappsPathAction = Paths.get(webappsPath.toString()+"\\Action"); + } + else + { + webappsPathConfig = Paths.get(webappsPath.toString()+"/Config"); + webappsPathAction = Paths.get(webappsPath.toString()+"/Action"); + } + if (Files.notExists(webappsPathConfig)) + { + try { + Files.createDirectories(webappsPathConfig); + } catch (IOException e) { + logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to create config directory: " + + webappsPathConfig.toAbsolutePath().toString(), e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Webapps", "Failed to create config directory"); + } + } + if (Files.notExists(webappsPathAction)) + { + try { + Files.createDirectories(webappsPathAction); + } catch (IOException e) { + logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to create config directory: " + + webappsPathAction.toAbsolutePath().toString(), e); + // TODO:EELF Cleanup - Remove logger + PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Webapps", "Failed to create config directory"); + } + } + actionHome = webappsPathAction.toString(); + configHome = webappsPathConfig.toString(); + } + } + +} |