This is an automated email from the ASF dual-hosted git repository.

aiceflower pushed a commit to branch release-0.9.4
in repository https://gitbox.apache.org/repos/asf/linkis.git

commit 0310060a584246c6f699a5400c0ae3b6b7b95014
Author: bleachzk <[email protected]>
AuthorDate: Mon Feb 24 20:41:41 2020 +0800

    fixed #297
---
 datasource/datasourcemanager/common/pom.xml        |  70 ++++++
 .../datasourcemanager/common/DsmConfiguration.java |  29 +++
 .../datasourcemanager/common/ServiceErrorCode.java |  36 +++
 .../common/domain/DataSource.java                  | 243 +++++++++++++++++++++
 .../common/domain/DataSourceEnv.java               | 187 ++++++++++++++++
 .../domain/DataSourceParamKeyDefinition.java       | 231 ++++++++++++++++++++
 .../common/domain/DataSourceType.java              |  76 +++++++
 .../datasourcemanager/common/util/CryptoUtils.java | 105 +++++++++
 .../common/util/PatternInjectUtils.java            | 177 +++++++++++++++
 .../datasourcemanager/common/util/json/Json.java   | 112 ++++++++++
 .../common/protocol/DsmQueryProtocol.scala         |  38 ++++
 11 files changed, 1304 insertions(+)

diff --git a/datasource/datasourcemanager/common/pom.xml 
b/datasource/datasourcemanager/common/pom.xml
new file mode 100644
index 0000000000..cf21b26366
--- /dev/null
+++ b/datasource/datasourcemanager/common/pom.xml
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+  ~ Copyright 2019 WeBank
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";>
+  <parent>
+    <artifactId>linkis</artifactId>
+    <groupId>com.webank.wedatasphere.linkis</groupId>
+    <version>0.9.3</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>linkis-datasourcemanager-common</artifactId>
+
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <um.version>1.0.12</um.version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>com.webank.wedatasphere.linkis</groupId>
+      <artifactId>linkis-module</artifactId>
+      <version>${linkis.version}</version>
+      <exclusions>
+        <exclusion>
+          <artifactId>asm</artifactId>
+          <groupId>org.ow2.asm</groupId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+      </plugin>
+
+      <plugin>
+        <groupId>net.alchim31.maven</groupId>
+        <artifactId>scala-maven-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+      </plugin>
+    </plugins>
+    <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+      </resource>
+    </resources>
+    <finalName>${project.artifactId}-${project.version}</finalName>
+  </build>
+</project>
diff --git 
a/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/DsmConfiguration.java
 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/DsmConfiguration.java
new file mode 100644
index 0000000000..92c22ef6c9
--- /dev/null
+++ 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/DsmConfiguration.java
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2019 WeBank
+ * 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.
+ */
+
+package com.webank.wedatasphere.linkis.datasourcemanager.common;
+
+import com.webank.wedatasphere.linkis.common.conf.CommonVars;
+
+/**
+ * Configuration
+ * @author kirkzhou
+ * 2020/02/14
+ */
+public class DsmConfiguration {
+
+    public static CommonVars<String> DSM_ADMIN_USER_LIST =
+            CommonVars.apply("wds.linkis.server.dsm.admin.users", "");
+
+
+}
diff --git 
a/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/ServiceErrorCode.java
 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/ServiceErrorCode.java
new file mode 100644
index 0000000000..7647f18b9e
--- /dev/null
+++ 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/ServiceErrorCode.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2019 WeBank
+ * 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.
+ */
+
+package com.webank.wedatasphere.linkis.datasourcemanager.common;
+
+import com.webank.wedatasphere.linkis.common.conf.CommonVars;
+
+/**
+ * Store error code map
+ * @author kirkzhou
+ * 2020/02/11
+ */
+public class ServiceErrorCode {
+
+    public static CommonVars<Integer> TRANSFORM_FORM_ERROR =
+            CommonVars.apply("wds.linkis.server.dsm.error-code.transform", 
99987);
+
+    public static CommonVars<Integer> BML_SERVICE_ERROR =
+            CommonVars.apply("wds.linkis.server.dsm.error-code.bml", 99982);
+
+    public static CommonVars<Integer> REMOTE_METADATA_SERVICE_ERROR =
+            CommonVars.apply("wds.linkis.server.dsm.error-code.metadata", 
99983);
+
+    public static CommonVars<Integer> PARAM_VALIDATE_ERROR =
+            
CommonVars.apply("wds.linkis.server.dsm.error-code.param-validate", 99986);
+}
diff --git 
a/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/domain/DataSource.java
 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/domain/DataSource.java
new file mode 100644
index 0000000000..e35d73a354
--- /dev/null
+++ 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/domain/DataSource.java
@@ -0,0 +1,243 @@
+/*
+ * Copyright 2019 WeBank
+ * 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.
+ */
+
+package com.webank.wedatasphere.linkis.datasourcemanager.common.domain;
+
+import com.webank.wedatasphere.linkis.datasourcemanager.common.util.json.Json;
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.util.*;
+
+/**
+ * Store the data source information
+ * @author kirkzhou
+ * 2020/02/11
+ */
+@JsonSerialize(include= JsonSerialize.Inclusion.NON_EMPTY)
+@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"}, 
ignoreUnknown = true)
+public class DataSource {
+
+    private Long id;
+
+    /**
+     * Data source name
+     */
+    @NotNull
+    private String dataSourceName;
+
+    /**
+     * Data source description
+     */
+    @Size(min = 0, max = 200)
+    private String dataSourceDesc;
+
+    /**
+     * ID of data source type
+     */
+    @NotNull
+    private Long dataSourceTypeId;
+
+    /**
+     * Identify from creator
+     */
+    private String createIdentify;
+
+    /**
+     * System name from creator
+     */
+    @NotNull
+    private String createSystem;
+    /**
+     * Connection parameters
+     */
+    private Map<String, Object> connectParams = new HashMap<>();
+    /**
+     * Parameter JSON string
+     */
+    @JsonIgnore
+    private String parameter;
+
+    /**
+     * ID of data source environment
+     */
+    private Long dataSourceEnvId;
+
+    /**
+     * Create time
+     */
+    private Date createTime;
+
+    /**
+     * Modify time
+     */
+    private Date modifyTime;
+
+    /**
+     * Modify user
+     */
+    private String modifyUser;
+
+    private String createUser;
+
+    /**
+     * Data source type entity
+     */
+    private DataSourceType dataSourceType;
+
+    /**
+     * Data source env
+     */
+    private DataSourceEnv dataSourceEnv;
+
+    @JsonIgnore
+    private List<DataSourceParamKeyDefinition> keyDefinitions = new 
ArrayList<>();
+
+    public DataSource(){
+        this.createTime = Calendar.getInstance().getTime();
+    }
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getDataSourceName() {
+        return dataSourceName;
+    }
+
+    public void setDataSourceName(String dataSourceName) {
+        this.dataSourceName = dataSourceName;
+    }
+
+    public String getDataSourceDesc() {
+        return dataSourceDesc;
+    }
+
+    public void setDataSourceDesc(String dataSourceDesc) {
+        this.dataSourceDesc = dataSourceDesc;
+    }
+
+    public Long getDataSourceTypeId() {
+        return dataSourceTypeId;
+    }
+
+    public void setDataSourceTypeId(Long dataSourceTypeId) {
+        this.dataSourceTypeId = dataSourceTypeId;
+    }
+
+    public String getCreateIdentify() {
+        return createIdentify;
+    }
+
+    public void setCreateIdentify(String createIdentify) {
+        this.createIdentify = createIdentify;
+    }
+
+    public String getCreateSystem() {
+        return createSystem;
+    }
+
+    public void setCreateSystem(String createSystem) {
+        this.createSystem = createSystem;
+    }
+
+    public String getParameter() {
+        return parameter;
+    }
+
+    public void setParameter(String parameter) {
+        this.parameter = parameter;
+    }
+
+    public Long getDataSourceEnvId() {
+        return dataSourceEnvId;
+    }
+
+    public void setDataSourceEnvId(Long dataSourceEnvId) {
+        this.dataSourceEnvId = dataSourceEnvId;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getModifyTime() {
+        return modifyTime;
+    }
+
+    public void setModifyTime(Date modifyTime) {
+        this.modifyTime = modifyTime;
+    }
+
+    public Map<String, Object> getConnectParams() {
+        if(connectParams.isEmpty() && StringUtils.isNotBlank(parameter)){
+            
connectParams.putAll(Objects.requireNonNull(Json.fromJson(parameter, 
Map.class)));
+        }
+        return connectParams;
+    }
+
+    public void setConnectParams(Map<String, Object> connectParams) {
+        this.connectParams = connectParams;
+    }
+
+    public String getCreateUser() {
+        return createUser;
+    }
+
+    public void setCreateUser(String createUser) {
+        this.createUser = createUser;
+    }
+
+    public String getModifyUser() {
+        return modifyUser;
+    }
+
+    public void setModifyUser(String modifyUser) {
+        this.modifyUser = modifyUser;
+    }
+
+    public DataSourceType getDataSourceType() {
+        return dataSourceType;
+    }
+
+    public void setDataSourceType(DataSourceType dataSourceType) {
+        this.dataSourceType = dataSourceType;
+    }
+
+    public DataSourceEnv getDataSourceEnv() {
+        return dataSourceEnv;
+    }
+
+    public void setDataSourceEnv(DataSourceEnv dataSourceEnv) {
+        this.dataSourceEnv = dataSourceEnv;
+    }
+
+    public List<DataSourceParamKeyDefinition> getKeyDefinitions() {
+        return keyDefinitions;
+    }
+
+    public void setKeyDefinitions(List<DataSourceParamKeyDefinition> 
keyDefinitions) {
+        this.keyDefinitions = keyDefinitions;
+    }
+}
diff --git 
a/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/domain/DataSourceEnv.java
 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/domain/DataSourceEnv.java
new file mode 100644
index 0000000000..575d2464f6
--- /dev/null
+++ 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/domain/DataSourceEnv.java
@@ -0,0 +1,187 @@
+/*
+ * Copyright 2019 WeBank
+ * 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.
+ */
+
+package com.webank.wedatasphere.linkis.datasourcemanager.common.domain;
+
+import com.webank.wedatasphere.linkis.datasourcemanager.common.util.json.Json;
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.util.*;
+
+/**
+ * Store the data source environment information
+ * @author kirkzhou
+ * 2020/02/11
+ */
+@JsonSerialize(include= JsonSerialize.Inclusion.NON_EMPTY)
+@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"}, 
ignoreUnknown = true)
+public class DataSourceEnv {
+
+    private Long id;
+    /**
+     * Environment name
+     */
+    @NotNull
+    private String envName;
+
+    /**
+     * Environment description
+     */
+    @Size(min = 0, max = 200)
+    private String envDesc;
+
+    /**
+     * ID of data source type
+     */
+    @NotNull
+    private Long dataSourceTypeId;
+
+    private DataSourceType dataSourceType;
+    /**
+     * Connection parameters for environment
+     */
+    private Map<String, Object> connectParams = new HashMap<>();
+
+    /**
+     * Parameter JSON string
+     */
+    @JsonIgnore
+    private String parameter;
+
+    /**
+     * Create time
+     */
+    private Date createTime;
+
+    /**
+     * Creator
+     */
+    private String createUser;
+
+    /**
+     * Modify time
+     */
+    private Date modifyTime;
+
+    /**
+     * Modify user
+     */
+    private String modifyUser;
+
+    @JsonIgnore
+    private List<DataSourceParamKeyDefinition> keyDefinitions = new 
ArrayList<>();
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getEnvName() {
+        return envName;
+    }
+
+    public void setEnvName(String envName) {
+        this.envName = envName;
+    }
+
+    public String getEnvDesc() {
+        return envDesc;
+    }
+
+    public void setEnvDesc(String envDesc) {
+        this.envDesc = envDesc;
+    }
+
+    public Map<String, Object> getConnectParams() {
+        if(connectParams.isEmpty() && StringUtils.isNotBlank(parameter)){
+            
connectParams.putAll(Objects.requireNonNull(Json.fromJson(parameter, 
Map.class)));
+        }
+        return connectParams;
+    }
+
+    public void setConnectParams(Map<String, Object> connectParams) {
+        this.connectParams = connectParams;
+    }
+
+    public String getParameter() {
+        return parameter;
+    }
+
+    public void setParameter(String parameter) {
+        this.parameter = parameter;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public String getCreateUser() {
+        return createUser;
+    }
+
+    public void setCreateUser(String createUser) {
+        this.createUser = createUser;
+    }
+
+    public Date getModifyTime() {
+        return modifyTime;
+    }
+
+    public void setModifyTime(Date modifyTime) {
+        this.modifyTime = modifyTime;
+    }
+
+    public String getModifyUser() {
+        return modifyUser;
+    }
+
+    public void setModifyUser(String modifyUser) {
+        this.modifyUser = modifyUser;
+    }
+
+    public Long getDataSourceTypeId() {
+        return dataSourceTypeId;
+    }
+
+    public void setDataSourceTypeId(Long dataSourceTypeId) {
+        this.dataSourceTypeId = dataSourceTypeId;
+    }
+
+    public List<DataSourceParamKeyDefinition> getKeyDefinitions() {
+        return keyDefinitions;
+    }
+
+    public void setKeyDefinitions(List<DataSourceParamKeyDefinition> 
keyDefinitions) {
+        this.keyDefinitions = keyDefinitions;
+    }
+
+    public DataSourceType getDataSourceType() {
+        return dataSourceType;
+    }
+
+    public void setDataSourceType(DataSourceType dataSourceType) {
+        this.dataSourceType = dataSourceType;
+    }
+}
diff --git 
a/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/domain/DataSourceParamKeyDefinition.java
 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/domain/DataSourceParamKeyDefinition.java
new file mode 100644
index 0000000000..6b8360ce82
--- /dev/null
+++ 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/domain/DataSourceParamKeyDefinition.java
@@ -0,0 +1,231 @@
+/*
+ * Copyright 2019 WeBank
+ * 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.
+ */
+
+package com.webank.wedatasphere.linkis.datasourcemanager.common.domain;
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+import java.io.InputStream;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Parameter key definition for data source type
+ * @author kirkzhou
+ * 2020/02/11
+ */
+@JsonSerialize(include= JsonSerialize.Inclusion.NON_EMPTY)
+@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"}, 
ignoreUnknown = true)
+public class DataSourceParamKeyDefinition {
+    /**
+     * Key-value type
+     */
+    public enum ValueType{
+        /**
+         * Email format
+         */
+        EMAIL(String.class),
+        /**
+         * String
+         */
+        TEXT(String.class),
+        /**
+         * Long
+         */
+        NUMBER(Long.class),
+        /**
+         * SELECT
+         */
+        SELECT(String.class),
+        /**
+         * List
+         */
+        LIST(List.class),
+        /**
+         * Map
+         */
+        MAP(Map.class),
+        /**
+         * RADIO
+         */
+        RADIO(String.class),
+        /**
+         * Password
+         */
+        PASSWORD(String.class),
+        /**
+         * DateTime
+         */
+        DATE(Date.class),
+        /**
+         * File
+         */
+        FILE(InputStream .class);
+        Class<?> type;
+        ValueType(Class<?> type){
+            this.type = type;
+        }
+        public Class<?> getJavaType(){
+            return this.type;
+        }
+    }
+
+    public enum Scope{
+        /**
+         * Env SCOPE
+         */
+        ENV,
+    }
+    /**
+     * Definition id
+     */
+    private Long id;
+
+    /**
+     * Key name
+     */
+    private String key;
+
+    /**
+     * Definition description
+     */
+    private String description;
+
+    /**
+     * Option name
+     */
+    private String name;
+
+    /**
+     * Default value
+     */
+    private String defaultValue;
+
+    /**
+     * Value type
+     */
+    private ValueType valueType;
+    /**
+     * Scope
+     */
+    private Scope scope;
+    /**
+     * If the definition is required
+     */
+    private boolean require;
+    /**
+     * Value regex
+     */
+    private String valueRegex;
+
+    /**
+     * Reference id
+     */
+    private Long refId;
+
+    /**
+     * Reference value
+     */
+    private String refValue;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getDefaultValue() {
+        return defaultValue;
+    }
+
+    public void setDefaultValue(String defaultValue) {
+        this.defaultValue = defaultValue;
+    }
+
+    public ValueType getValueType() {
+        return valueType;
+    }
+
+    public void setValueType(ValueType valueType) {
+        this.valueType = valueType;
+    }
+
+    public String getValueRegex() {
+        return valueRegex;
+    }
+
+    public void setValueRegex(String valueRegex) {
+        this.valueRegex = valueRegex;
+    }
+
+    public boolean isRequire() {
+        return require;
+    }
+
+    public void setRequire(boolean require) {
+        this.require = require;
+    }
+
+    public Scope getScope() {
+        return scope;
+    }
+
+    public void setScope(Scope scope) {
+        this.scope = scope;
+    }
+
+    public Long getRefId() {
+        return refId;
+    }
+
+    public void setRefId(Long refId) {
+        this.refId = refId;
+    }
+
+    public String getRefValue() {
+        return refValue;
+    }
+
+    public void setRefValue(String refValue) {
+        this.refValue = refValue;
+    }
+
+}
diff --git 
a/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/domain/DataSourceType.java
 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/domain/DataSourceType.java
new file mode 100644
index 0000000000..c273eac8eb
--- /dev/null
+++ 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/domain/DataSourceType.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2019 WeBank
+ * 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.
+ */
+
+package com.webank.wedatasphere.linkis.datasourcemanager.common.domain;
+
+
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+
+/**
+ * Data source type entity
+ * @author kirkzhou
+ * 2020/02/11
+ */
+@JsonSerialize(include= JsonSerialize.Inclusion.NON_EMPTY)
+@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"}, 
ignoreUnknown = true)
+public class DataSourceType {
+
+    private String id;
+    /**
+     * Icon class
+     */
+    private String icon;
+
+    /**
+     * Description
+     */
+    private String description;
+
+    /**
+     * Name
+     */
+    private String name;
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getIcon() {
+        return icon;
+    }
+
+    public void setIcon(String icon) {
+        this.icon = icon;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}
diff --git 
a/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/util/CryptoUtils.java
 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/util/CryptoUtils.java
new file mode 100644
index 0000000000..7b2ae4aab8
--- /dev/null
+++ 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/util/CryptoUtils.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright 2019 WeBank
+ * 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.
+ */
+
+package com.webank.wedatasphere.linkis.datasourcemanager.common.util;
+
+import org.apache.commons.codec.binary.Base64;
+import org.apache.commons.lang.StringUtils;
+
+import java.io.*;
+import java.security.MessageDigest;
+
+/**
+ * @author kirkzhou
+ * 用于密码的加密解密
+ *
+ */
+public class CryptoUtils {
+    private CryptoUtils(){
+    }
+    /**
+     * 序列化对象为String字符
+     *
+     * @param o Object
+     * @return String
+     * @throws Exception
+     */
+    public static String object2String(Serializable o) {
+        try {
+            ByteArrayOutputStream bos = new ByteArrayOutputStream();
+            ObjectOutputStream oos = new ObjectOutputStream(bos);
+            oos.writeObject(o);
+            oos.flush();
+            oos.close();
+            bos.close();
+            return new String(new Base64().encode(bos.toByteArray()));
+        }catch(Exception e){
+            throw new RuntimeException(e);
+        }
+    }
+
+    /**
+     * 反序列化字符串为对象
+     *
+     * @param str String
+     * @return Object
+     * @throws IOException
+     * @throws ClassNotFoundException
+     */
+    public static Object string2Object(String str) {
+        try {
+            ByteArrayInputStream bis = new ByteArrayInputStream(new 
Base64().decode(str.getBytes()));
+            ObjectInputStream ois = new ObjectInputStream(bis);
+            Object o = ois.readObject();
+            bis.close();
+            ois.close();
+            return o;
+        }catch(Exception e){
+            throw new RuntimeException(e);
+        }
+
+    }
+
+    /**
+     * MD5 encrypt
+     * @param source
+     * @param salt
+     * @param iterator
+     * @return
+     */
+    public static String md5(String source, String salt, int iterator){
+        StringBuilder token = new StringBuilder();
+        try{
+            MessageDigest digest = MessageDigest.getInstance("md5");
+            if(StringUtils.isNotEmpty(salt)){
+                digest.update(salt.getBytes("UTF-8"));
+            }
+            byte[] result = digest.digest(source.getBytes());
+            for(int i = 0; i < iterator - 1; i++){
+                digest.reset();
+                result = digest.digest(result);
+            }
+            for (byte aResult : result) {
+                int temp = aResult & 0xFF;
+                if (temp <= 0xF) {
+                    token.append("0");
+                }
+                token.append(Integer.toHexString(temp));
+            }
+        }catch(Exception e){
+            throw new RuntimeException(e.getMessage());
+        }
+        return token.toString();
+    }
+
+}
diff --git 
a/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/util/PatternInjectUtils.java
 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/util/PatternInjectUtils.java
new file mode 100644
index 0000000000..30d6dbcfc6
--- /dev/null
+++ 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/util/PatternInjectUtils.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2019 WeBank
+ * 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.
+ */
+
+package com.webank.wedatasphere.linkis.datasourcemanager.common.util;
+
+import com.webank.wedatasphere.linkis.datasourcemanager.common.util.json.Json;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.StringUtils;
+
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author kirkzhou
+ * 2018/10/26
+ */
+public class PatternInjectUtils {
+
+    private PatternInjectUtils(){
+
+    }
+
+    private static final String PARAMETER_PREFIX = "[#|$]";
+
+    private static final String ASSIGN_SYMBOL = "=";
+
+    private static final Pattern REGEX = Pattern.compile(
+            "(" + ASSIGN_SYMBOL + "?)" +
+                   "("+ PARAMETER_PREFIX + ")" +
+                    "\\{([\\w-]+)[|]?([^}]*)}?"
+    );
+
+    /**
+     * inject pattern
+     * @param template
+     * @param params
+     * @param useDefault use default Value
+     * @return
+     */
+    public static String inject(String template, Object[] params, boolean 
useDefault, boolean escape, boolean placeholder){
+        Matcher matcher = REGEX.matcher(template);
+        StringBuffer sb = new StringBuffer();
+        int offset = 0;
+        while(matcher.find()){
+            String value = "";
+            String extra = "";
+            if( offset < params.length && null != params[offset] ){
+                Object paramsV = params[offset];
+                if( paramsV instanceof  String || paramsV instanceof Enum ||
+                        paramsV.getClass().isPrimitive() ||
+                        isWrapClass(paramsV.getClass())){
+                    value = escape? 
StringEscapeUtils.escapeJava(String.valueOf(paramsV))
+                        : String.valueOf(paramsV);
+                }else{
+                    value = Json.toJson(paramsV, null);
+                    value = escape? StringEscapeUtils.escapeJava(value) : 
value;
+                }
+                if( null != matcher.group(1)
+                        && !"".equals(matcher.group(1))){
+                    extra = matcher.group(1);
+                }
+                offset ++;
+            }else if(null != matcher.group(4) && useDefault){
+                value = escape? 
StringEscapeUtils.escapeJava(String.valueOf(matcher.group(4)))
+                        : matcher.group(4);
+            }
+            if(StringUtils.isBlank(value) && !useDefault){
+                value = "\"" + 
(escape?StringEscapeUtils.escapeJava(matcher.group(3))
+                        : matcher.group(3));
+            }else if(!"$".equals(matcher.group(2)) && placeholder){
+                value = "\"" + StringEscapeUtils.escapeJava(value) + "\"";
+            }
+            String result = (extra + value).replace("$", "\\$");
+            matcher.appendReplacement(sb, result);
+        }
+        matcher.appendTail(sb);
+        return sb.toString().replace("\\$","$");
+    }
+    public static String inject(String pattern, Object[] params){
+        return inject(pattern, params, true, true, true);
+    }
+
+    /**
+     * inject pattern
+     * @param template
+     * @param params
+     * @param useDefault
+     * @return
+     */
+    public static String inject(String template, Map<String, Object> params, 
boolean useDefault, boolean escape, boolean placeholder){
+        Matcher matcher = REGEX.matcher(template);
+        StringBuffer sb = new StringBuffer();
+        //will be more faster?
+        while(matcher.find()){
+            String injected = matcher.group(3);
+            if(null !=  injected  && !"".equals(injected)){
+                int flag = 0;
+                String value = "";
+                String extra = "";
+                for(Map.Entry<String, Object> entry : params.entrySet()){
+                    if(injected.equals(entry.getKey()) && null != 
entry.getValue()){
+                        Object entryV = entry.getValue();
+                        if(entryV instanceof  String || entryV instanceof Enum 
||
+                                entryV.getClass().isPrimitive() ||
+                                isWrapClass(entryV.getClass())){
+                            value = escape? 
StringEscapeUtils.escapeJava(String.valueOf(entryV))
+                            : String.valueOf(entryV);
+                        }else{
+                            value = Json.toJson(entryV, null);
+                            value = escape? 
StringEscapeUtils.escapeJava(value) : value;
+                        }
+                        if(null != matcher.group(1)
+                                || !"".equals(matcher.group(1))){
+                            extra = matcher.group(1);
+                        }
+                        flag = 1;
+                        break;
+                    }
+                }
+                if(flag == 0 && null != matcher.group(4) && useDefault){
+                    value = escape? 
StringEscapeUtils.escapeJava(String.valueOf(matcher.group(4)))
+                    : matcher.group(4);
+                }
+                if(StringUtils.isBlank(value) && !useDefault){
+                    value = "\"*#{" + 
(escape?StringEscapeUtils.escapeJava(matcher.group(3))
+                            : matcher.group(3)) + "}*\"";
+                } else if(!"$".equals(matcher.group(2)) && placeholder){
+                    value = "\"" + StringEscapeUtils.escapeJava(value) + "\"";
+                }
+                String result = (extra + value).replace("$", "\\$");
+                matcher.appendReplacement(sb, result);
+            }
+        }
+        matcher.appendTail(sb);
+        String print = sb.toString();
+        return print.replace("\\$","$").replace("","");
+    }
+
+    public static String injectPattern(String template, String valuePattern){
+        Matcher matcher = REGEX.matcher(template);
+        StringBuffer sb  = new StringBuffer();
+        while(matcher.find()){
+            String extra = matcher.group(1);
+            String value = StringEscapeUtils.escapeJava(matcher.group(3));
+            value = (extra + value.replaceAll("[\\s\\S]+", valuePattern))
+                    .replace("$", "\\$");
+            matcher.appendReplacement(sb, value);
+        }
+        matcher.appendTail(sb);
+        return sb.toString().replace("\\$", "$");
+    }
+
+    public static String inject(String template, Map<String, Object> params){
+        return inject(template, params, true, true, true);
+    }
+
+
+    private static boolean isWrapClass(Class clz){
+        try{
+            return ((Class)clz.getField("TYPE").get(null)).isPrimitive();
+        }catch(Exception e){
+            return false;
+        }
+    }
+
+}
diff --git 
a/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/util/json/Json.java
 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/util/json/Json.java
new file mode 100644
index 0000000000..9becb83223
--- /dev/null
+++ 
b/datasource/datasourcemanager/common/src/main/java/com/webank/wedatasphere/linkis/datasourcemanager/common/util/json/Json.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2019 WeBank
+ * 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.
+ */
+
+package com.webank.wedatasphere.linkis.datasourcemanager.common.util.json;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.*;
+import org.apache.commons.lang.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+
+/**
+ * @author kirkzhou
+ * Json utils
+ * 2018/9/3
+ */
+public class Json {
+    private static final String PREFIX = "[";
+    private static final String SUFFIX = "]";
+    private static final Logger logger = LoggerFactory.getLogger(Json.class);
+
+    private static ObjectMapper mapper;
+
+    static{
+        mapper = new ObjectMapper();
+        mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
+        mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
+        mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
+        mapper.configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, 
true);
+        mapper.configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING, 
true);
+        mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_CONTROL_CHARS, 
true);
+        //empty beans allowed
+        mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
+        //ignore unknown properties
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, 
false);
+        //cancel to scape non ascii
+        mapper.configure(JsonGenerator.Feature.ESCAPE_NON_ASCII, false);
+    }
+    private Json(){}
+
+    @SuppressWarnings("unchecked")
+    public static <T> T fromJson(String json, Class<?> clazz, Class<?>... 
parameters){
+        if(StringUtils.isNotBlank(json)){
+            try{
+                if(parameters.length > 0){
+                    return (T)mapper.readValue(json, 
mapper.getTypeFactory().constructParametricType(clazz, parameters));
+                }
+                if(json.startsWith(PREFIX)
+                    && json.endsWith(SUFFIX)){
+                    JavaType javaType = mapper.getTypeFactory()
+                            .constructParametricType(ArrayList.class, clazz);
+                    return mapper.readValue(json, javaType);
+                }
+                return (T)mapper.readValue(json, clazz);
+            } catch (Exception e) {
+                logger.info(e.getLocalizedMessage());
+                throw new RuntimeException(e);
+            }
+        }
+        return null;
+    }
+
+    public static <T> T fromJson(InputStream stream, Class<?> clazz, 
Class<?>... parameters){
+        StringBuilder builder = new StringBuilder();
+        String jsonStr = null;
+        try{
+            BufferedReader reader = new BufferedReader(new 
InputStreamReader(stream, "UTF-8"));
+            while((jsonStr = reader.readLine()) != null){
+                builder.append(jsonStr);
+            }
+            reader.close();
+        }catch(Exception e){
+            logger.info(e.getLocalizedMessage());
+            throw new RuntimeException(e);
+        }
+        return fromJson(builder.toString(), clazz, parameters);
+    }
+
+    public static String toJson(Object obj, Class<?> model){
+        ObjectWriter writer = mapper.writer();
+        if(null != obj){
+            try{
+                if(null != model){
+                    writer = writer.withView(model);
+                }
+                return writer.writeValueAsString(obj);
+            } catch (JsonProcessingException e) {
+                logger.info(e.getLocalizedMessage());
+                throw new RuntimeException(e);
+            }
+        }
+        return null;
+    }
+
+}
diff --git 
a/datasource/datasourcemanager/common/src/main/scala/com/webank/wedatasphere/linkis/datasourcemanager/common/protocol/DsmQueryProtocol.scala
 
b/datasource/datasourcemanager/common/src/main/scala/com/webank/wedatasphere/linkis/datasourcemanager/common/protocol/DsmQueryProtocol.scala
new file mode 100644
index 0000000000..455e7dddc6
--- /dev/null
+++ 
b/datasource/datasourcemanager/common/src/main/scala/com/webank/wedatasphere/linkis/datasourcemanager/common/protocol/DsmQueryProtocol.scala
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2019 WeBank
+ * 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.
+ */
+
+package com.webank.wedatasphere.linkis.datasourcemanager.common.protocol
+
+import java.util
+
+/**
+ * Store error code map
+ * @author kirkzhou
+ * 2020/02/11
+ */
+trait DsmQueryProtocol {
+
+}
+
+/**
+ * Query request of Data Source Information
+ * @param id
+ */
+case class DsInfoQueryRequest(id: String, system: String) extends 
DsmQueryProtocol
+
+/**
+ * Response of parameter map
+ * @param params
+ */
+case class DsInfoResponse(status: Boolean, dsType: String, params : 
util.Map[String, Object], creator: String) extends DsmQueryProtocol
+


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to