提交 4e81b4b8 编写于 作者: W wqzwh

Squashed 'sharding-ui/' content from commit 52987a55

git-subtree-dir: sharding-ui
git-subtree-split: 52987a55
上级
# maven ignore
target/
*.jar
*.war
*.zip
*.tar
*.tar.gz
# eclipse ignore
.settings/
.project
.classpath
# idea ignore
.idea/
*.ipr
*.iml
*.iws
# temp ignore
logs/
*.doc
*.log
*.cache
*.diff
*.patch
*.tmp
# system ignore
.DS_Store
Thumbs.db
*.class
\ No newline at end of file
sudo: required
cache:
directories:
- "$HOME/.m2"
language: java
jdk:
- oraclejdk8
# - oraclejdk7
# - openjdk7
before_script:
- echo "MAVEN_OPTS='-Xmx1024m -XX:MaxPermSize=256m'" > ~/.mavenrc
script:
- mvn clean install cobertura:cobertura coveralls:report -DrepoToken="${COVERALLS_REPO_TOKEN}"
install: travis_wait 30 mvn install
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.
# Sharding UI
[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![Build Status](https://api.travis-ci.org/sharding-sphere/sharding-ui.png?branch=master)](https://travis-ci.org/sharding-sphere/sharding-ui)
## Overview
Sharding UI is a management background for [ShardingSphere](http://shardingsphere.io/), including: dynamic configuration, Data orchestration, etc.
### Sharding-ui-frontend
Sharding-ui-frontend based on [vue](https://github.com/vuejs/vue) and use the UI Toolkit [element](https://github.com/ElemeFE/element).
* [sharding-ui-frontend/README.md](sharding-ui-frontend/README.md)
### Sharding-ui-backend
Sharding-ui-backend is a standard spring boot project.
## Build
1. `git clone https://github.com/sharding-sphere/sharding-ui.git`
2. `cd shrding-ui/`
3. Run `mvn clean package`
4. Get the package in `/dist`.(sharding-ui.tar.gz)
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-ui</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<modules>
<module>sharding-ui-frontend</module>
<module>sharding-ui-backend</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.7</java.version>
<spring-boot.version>2.0.2.RELEASE</spring-boot.version>
<lombok.version>1.16.4</lombok.version>
<snakeyaml.version>1.16</snakeyaml.version>
<commons-codec.version>1.11</commons-codec.version>
<gson.version>2.7</gson.version>
<sharding-sphere.version>4.0.0-RC1</sharding-sphere.version>
<frontend-maven-plugin.version>1.6</frontend-maven-plugin.version>
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
<maven-jar-plugin.version>2.6</maven-jar-plugin.version>
<maven-source-plugin.version>2.4</maven-source-plugin.version>
<maven-assembly-plugin.version>3.1.0</maven-assembly-plugin.version>
<coveralls-maven-plugin.version>4.3.0</coveralls-maven-plugin.version>
<cobertura-maven-plugin.version>2.7</cobertura-maven-plugin.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-orchestration-core</artifactId>
<version>${sharding-sphere.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-orchestration-reg-zookeeper-curator</artifactId>
<version>${sharding-sphere.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>${snakeyaml.version}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>${commons-codec.version}</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<version>${frontend-maven-plugin.version}</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven-assembly-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<testSource>${java.version}</testSource>
<testTarget>${java.version}</testTarget>
</configuration>
<version>${maven-compiler-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven-resources-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<id>attach-sources</id>
<phase>verify</phase>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>${coveralls-maven-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>${cobertura-maven-plugin.version}</version>
<configuration>
<check>
<!--<branchRate>85</branchRate>-->
<!--<lineRate>85</lineRate>-->
<!--<haltOnFailure>true</haltOnFailure>-->
<!--<totalBranchRate>85</totalBranchRate>-->
<!--<totalLineRate>85</totalLineRate>-->
<!--<packageLineRate>85</packageLineRate>-->
<!--<packageBranchRate>85</packageBranchRate>-->
</check>
<aggregate>true</aggregate>
<encoding>${project.build.sourceEncoding}</encoding>
<quiet>true</quiet>
<format>xml</format>
<instrumentation>
<ignoreTrivial>true</ignoreTrivial>
<ignoreMethodAnnotations>
<ignoreMethodAnnotation>lombok.Generated</ignoreMethodAnnotation>
</ignoreMethodAnnotations>
<excludes>
<exclude>io/shardingsphere/**/*Test.class</exclude>
<exclude>io/shardingsphere/**/Test*.class</exclude>
</excludes>
</instrumentation>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-ui</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>sharding-ui-backend</artifactId>
<name>${project.artifactId}</name>
<properties>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-orchestration-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
<artifactId>sharding-orchestration-reg-zookeeper-curator</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
</dependencies>
<build>
<finalName>sharding-ui</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
<resources>
<resource>
<targetPath>${project.build.directory}/classes/public</targetPath>
<directory>${project.parent.basedir}/sharding-ui-frontend/dist</directory>
</resource>
<resource>
<targetPath>${project.build.directory}/classes</targetPath>
<directory>src/main/resources</directory>
<excludes>
<exclude>assembly/**</exclude>
<exclude>bin/**</exclude>
</excludes>
</resource>
</resources>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/resources/assembly/assembly.xml</descriptor>
</descriptors>
<outputDirectory>${project.parent.build.directory}</outputDirectory>
</configuration>
<executions>
<execution>
<id>assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Sharding UI Bootstrap.
*
* @author chenqingyang
*/
@SpringBootApplication
public class Bootstrap {
/**
* Sharding UI main entrance.
*
* @param args startup arguments
*/
public static void main(final String[] args) {
SpringApplication.run(Bootstrap.class, args);
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.common.constant;
import io.shardingsphere.shardingui.common.exception.ShardingUIException;
/**
* Registry center type.
*
* @author chenqingyang
*/
public enum RegistryCenterType {
ZOOKEEPER("Zookeeper"), ETCD("Etcd");
private final String name;
RegistryCenterType(final String name) {
this.name = name;
}
/**
* Get registry center type via name.
*
* @param name registry center name
* @return registry center type
*/
public static RegistryCenterType nameOf(final String name) {
for (RegistryCenterType each : RegistryCenterType.values()) {
if ((each.name).equals(name)) {
return each;
}
}
throw new ShardingUIException(ShardingUIException.SERVER_ERROR, String.format("Unsupported registry center `%s`", name));
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.common.domain;
import lombok.Getter;
import lombok.Setter;
import java.util.Properties;
/**
* Registry center config.
*
* @author chenqingyang
*/
@Getter
@Setter
public class RegistryCenterConfig {
private String name;
private String registryCenterType;
private String serverLists;
private String namespace;
private String orchestrationName;
private String digest;
private boolean activated;
private Properties props = new Properties();
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.common.domain;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
/**
* Registry center configs.
*
* @author chenqingyang
*/
@Getter
@Setter
public class RegistryCenterConfigs {
private List<RegistryCenterConfig> registryCenterConfigs = new ArrayList<>();
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.common.dto;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* Instance DTO.
*
* @author chenqingyang
*/
@Setter
@Getter
@NoArgsConstructor
public class InstanceDTO {
private static final String DELIMITER = "@";
private String serverIp;
private String instanceId;
private boolean enabled;
public InstanceDTO(final String instanceId, final boolean enabled) {
this.instanceId = instanceId;
this.enabled = enabled;
this.serverIp = instanceId.split(DELIMITER)[0];
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.common.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* Sharding schema DTO.
*
* @author chenqingyang
*/
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class ShardingSchemaDTO {
private String name;
private String ruleConfiguration;
private String dataSourceConfiguration;
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.common.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* Slave data source DTO.
*
* @author chenqingyang
*/
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class SlaveDataSourceDTO {
private String schema;
private String masterDataSourceName;
private String slaveDataSourceName;
private boolean enabled;
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.common.exception;
import lombok.Getter;
import lombok.Setter;
/**
* Sharding UI system exception.
*
* @author chenqingyang
*/
@Getter
@Setter
public final class ShardingUIException extends RuntimeException {
public static final int INVALID_PARAM = 400;
public static final int NO_RIGHT = 403;
public static final int SERVER_ERROR = 500;
private final int errCode;
private final String errMsg;
public ShardingUIException(final int errCode, final String errMsg) {
super(errMsg);
this.errCode = errCode;
this.errMsg = errMsg;
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.config;
import io.shardingsphere.shardingui.security.AuthenticationFilter;
import io.shardingsphere.shardingui.security.UserAuthenticationService;
import io.shardingsphere.shardingui.web.filter.CORSFilter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.ArrayList;
import java.util.List;
/**
* Web filter configuration.
*
* @author chenqingyang
*/
@Configuration
public class FilterConfiguration {
@Autowired
private UserAuthenticationService userAuthenticationService;
/**
* Register the CORS filter.
*
* @return filter registration bean
*/
@Bean
public FilterRegistrationBean corsFilter() {
CORSFilter corsFilter = new CORSFilter();
FilterRegistrationBean filterRegBean = new FilterRegistrationBean();
filterRegBean.setFilter(corsFilter);
List<String> urlPatterns = new ArrayList<>();
urlPatterns.add("/api/*");
filterRegBean.setUrlPatterns(urlPatterns);
return filterRegBean;
}
/**
* Register the authentication filter.
*
* @return filter registration bean
*/
@Bean
public FilterRegistrationBean authenticationFilter() {
AuthenticationFilter authenticationFilter = new AuthenticationFilter();
authenticationFilter.setUserAuthenticationService(userAuthenticationService);
FilterRegistrationBean filterRegBean = new FilterRegistrationBean();
filterRegBean.setFilter(authenticationFilter);
List<String> urlPatterns = new ArrayList<>();
urlPatterns.add("/api/*");
filterRegBean.setUrlPatterns(urlPatterns);
return filterRegBean;
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.repository;
import io.shardingsphere.shardingui.common.domain.RegistryCenterConfigs;
/**
* Registry center configs repository interface.
*
* @author chenqingyang
*/
public interface RegistryCenterConfigsRepository {
/**
* Load registry center configs.
*
* @return registry center configs
*/
RegistryCenterConfigs load();
/**
* Save registry center configs.
*
* @param registryCenterConfigs registry center configs
*/
void save(RegistryCenterConfigs registryCenterConfigs);
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.repository.impl;
import io.shardingsphere.shardingui.common.domain.RegistryCenterConfigs;
import io.shardingsphere.shardingui.common.exception.ShardingUIException;
import io.shardingsphere.shardingui.repository.RegistryCenterConfigsRepository;
import org.springframework.stereotype.Repository;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.constructor.Constructor;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Implementation of Registry center configs repository.
*
* @author chenqingyang
*/
@Repository
public final class YamlRegistryCenterConfigsRepositoryImpl implements RegistryCenterConfigsRepository {
private final File file;
public YamlRegistryCenterConfigsRepositoryImpl() {
file = new File(new File(System.getProperty("user.home")), "sharding-ui-configs.yaml");
}
@Override
public RegistryCenterConfigs load() {
if (!file.exists()) {
return new RegistryCenterConfigs();
}
try (FileInputStream fileInputStream = new FileInputStream(file);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream, "UTF-8")) {
return new Yaml(new Constructor(RegistryCenterConfigs.class)).loadAs(inputStreamReader, RegistryCenterConfigs.class);
} catch (IOException e) {
throw new ShardingUIException(ShardingUIException.SERVER_ERROR, "load config error");
}
}
@Override
public void save(final RegistryCenterConfigs registryCenterConfigs) {
Yaml yaml = new Yaml();
try (BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(file))) {
bufferedOutputStream.write(yaml.dumpAsMap(registryCenterConfigs).getBytes());
bufferedOutputStream.flush();
} catch (IOException e) {
throw new ShardingUIException(ShardingUIException.SERVER_ERROR, "save config error");
}
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.security;
import com.google.common.base.Strings;
import com.google.gson.Gson;
import io.shardingsphere.shardingui.web.response.ResponseResultUtil;
import lombok.Setter;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
/**
* Authentication filter.
*
* @author chenqingyang
*/
public final class AuthenticationFilter implements Filter {
private static final String LOGIN_URI = "/api/login";
@Setter
private UserAuthenticationService userAuthenticationService;
@Override
public void init(final FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) servletRequest;
HttpServletResponse httpResponse = (HttpServletResponse) servletResponse;
if (LOGIN_URI.equals(httpRequest.getRequestURI())) {
handleLogin(httpRequest, httpResponse);
} else {
String accessToken = httpRequest.getHeader("Access-Token");
if (!Strings.isNullOrEmpty(accessToken) && accessToken.equals(userAuthenticationService.getToken())) {
filterChain.doFilter(httpRequest, httpResponse);
} else {
respondWithUnauthorized(httpResponse);
}
}
}
@Override
public void destroy() {
}
private void handleLogin(final HttpServletRequest httpRequest, final HttpServletResponse httpResponse) {
try {
UserAccount user = new Gson().fromJson(httpRequest.getReader(), UserAccount.class);
if (userAuthenticationService.checkUser(user)) {
httpResponse.setContentType("application/json");
httpResponse.setCharacterEncoding("UTF-8");
Map<String, Object> result = new HashMap<>();
result.put("username", userAuthenticationService.getUsername());
result.put("accessToken", userAuthenticationService.getToken());
httpResponse.getWriter().write(new Gson().toJson(ResponseResultUtil.build(result)));
} else {
respondWithUnauthorized(httpResponse);
}
} catch (IOException e) {
e.printStackTrace();
}
}
private void respondWithUnauthorized(final HttpServletResponse httpResponse) throws IOException {
httpResponse.setContentType("application/json");
httpResponse.setCharacterEncoding("UTF-8");
httpResponse.getWriter().write(new Gson().toJson(ResponseResultUtil.handleUnauthorizedException("Unauthorized.")));
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.security;
import lombok.Getter;
import lombok.Setter;
/**
* User account.
*
* @author chenqingyang
*/
@Getter
@Setter
public class UserAccount {
private String username;
private String password;
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.security;
import com.google.common.base.Strings;
import com.google.gson.Gson;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.codec.binary.Base64;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* User authentication service.
*
* @author chenqingyang
*/
@Component
@ConfigurationProperties(prefix = "user.admin")
public final class UserAuthenticationService {
@Getter
@Setter
private String username;
@Getter
@Setter
private String password;
/**
* Check user.
*
* @param userAccount user account
* @return check success or failure
*/
public boolean checkUser(final UserAccount userAccount) {
if (userAccount == null || Strings.isNullOrEmpty(userAccount.getUsername()) || Strings.isNullOrEmpty(userAccount.getPassword())) {
return false;
}
if (!username.equals(userAccount.getUsername()) || !password.equals(userAccount.getPassword())) {
return false;
}
return true;
}
/**
* Get user authentication token.
*
* @return authentication token
*/
public String getToken() {
return new Base64().encodeToString(new Gson().toJson(this).getBytes());
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.servcie;
import java.util.Map;
/**
* Sharding config map service.
*
* @author chenqingyang
*/
public interface ConfigMapService {
/**
* Load config map.
*
* @return config map
*/
Map<String, Object> loadConfigMap();
/**
* Update config map.
*
* @param configMap config map
*/
void updateConfigMap(Map<String, Object> configMap);
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.servcie;
import io.shardingsphere.shardingui.common.dto.InstanceDTO;
import io.shardingsphere.shardingui.common.dto.SlaveDataSourceDTO;
import java.util.Collection;
/**
* Orchestration operation service.
*
* @author chenqingyang
*/
public interface OrchestrationService {
/**
* Get all instances.
*
* @return all instances
*/
Collection<InstanceDTO> getALLInstance();
/**
* Update instance status.
*
* @param instanceId instance id
* @param enabled enabled
*/
void updateInstanceStatus(String instanceId, boolean enabled);
/**
* Get all slave data source.
*
* @return all slaver data source dto
*/
Collection<SlaveDataSourceDTO> getAllSlaveDataSource();
/**
* update slave data source status.
*
* @param schemaNames schema name
* @param slaveDataSourceName slave data source name
* @param enabled enabled
*/
void updateSlaveDataSourceStatus(String schemaNames, String slaveDataSourceName, boolean enabled);
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.servcie;
import org.apache.shardingsphere.core.rule.Authentication;
/**
* Sharding proxy Authentication service.
*
* @author chenqingyang
*/
public interface ProxyAuthenticationService {
/**
* Get authentication.
*
* @return authentication
*/
Authentication getAuthentication();
/**
* Update authentication.
*
* @param authentication authentication
*/
void updateAuthentication(Authentication authentication);
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.servcie;
import com.google.common.base.Optional;
import io.shardingsphere.shardingui.common.domain.RegistryCenterConfig;
import io.shardingsphere.shardingui.common.domain.RegistryCenterConfigs;
/**
* Registry center config service.
*
* @author chenqingyang
*/
public interface RegistryCenterConfigService {
/**
* Load registry center config.
*
* @param name registry center config name
* @return registry center config
*/
RegistryCenterConfig load(String name);
/**
* Load the activated registry center config.
*
* @return activated registry center config
*/
Optional<RegistryCenterConfig> loadActivated();
/**
* Add registry center config.
*
* @param config registry center config
*/
void add(RegistryCenterConfig config);
/**
* Delete registry center config.
*
* @param name registry center config name
*/
void delete(String name);
/**
* Set activated registry center config.
*
* @param name registry center config name
*/
void setActivated(String name);
/**
* Load all registry center configs.
*
* @return all registry center configs.
*/
RegistryCenterConfigs loadAll();
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.servcie;
import org.apache.shardingsphere.orchestration.internal.registry.config.node.ConfigurationNode;
import org.apache.shardingsphere.orchestration.internal.registry.state.node.StateNode;
import org.apache.shardingsphere.orchestration.reg.api.RegistryCenter;
/**
* Registry center service.
*
* @author chenqingyang
*/
public interface RegistryCenterService {
/**
* Get activated registry center.
*
* @return registry center
*/
RegistryCenter getActivatedRegistryCenter();
/**
* Get activated configuration node.
*
* @return configuration node
*/
ConfigurationNode getActivateConfigurationNode();
/**
* Get activated state node.
*
* @return state node
*/
StateNode getActivatedStateNode();
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.servcie;
/**
* Sharding properties service.
*
* @author chenqingyang
*/
public interface ShardingPropertiesService {
/**
* Load sharding properties.
*
* @return sharding properties
*/
String loadShardingProperties();
/**
* Update sharding properties.
*
* @param configData config data
*/
void updateShardingProperties(String configData);
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.servcie;
import java.util.Collection;
/**
* Sharding schema service.
*
* @author chenqingyang
*/
public interface ShardingSchemaService {
/**
* Get all schema names.
*
* @return all schema names
*/
Collection<String> getAllSchemaNames();
/**
* Get rule configuration.
*
* @param schemaName schema name
* @return rule configuration
*/
String getRuleConfiguration(String schemaName);
/**
* Get data source configuration.
*
* @param schemaName schema name
* @return data source configuration
*/
String getDataSourceConfiguration(String schemaName);
/**
* Update rule configuration.
*
* @param schemaName schema name
* @param configData config data
*/
void updateRuleConfiguration(String schemaName, String configData);
/**
* Update data source configuration.
*
* @param schemaName schema name
* @param configData config data
*/
void updateDataSourceConfiguration(String schemaName, String configData);
/**
* Add schema configuration.
*
* @param schemaName schema name
* @param ruleConfiguration rule configuration
* @param dataSourceConfiguration data source configuration
*/
void addSchemaConfiguration(String schemaName, String ruleConfiguration, String dataSourceConfiguration);
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.servcie.impl;
import io.shardingsphere.shardingui.servcie.ConfigMapService;
import io.shardingsphere.shardingui.servcie.RegistryCenterService;
import io.shardingsphere.shardingui.util.ConfigurationYamlConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* Implementation of config map service.
*
* 4.0.0-RC1 has removed this directory.
*
* @author chenqingyang
*/
@Deprecated
@Service
public final class ConfigMapServiceImpl implements ConfigMapService {
@Autowired
private RegistryCenterService registryCenterService;
@Override
public Map<String, Object> loadConfigMap() {
// String configData = registryCenterService.getActivatedRegistryCenter().get(registryCenterService.getActivateConfigurationNode().getConfigMapPath());
// return ConfigurationYamlConverter.loadConfigMap(configData);
return new HashMap<>();
}
@Override
public void updateConfigMap(final Map<String, Object> configMap) {
String configData = ConfigurationYamlConverter.dumpConfigMap(configMap);
// registryCenterService.getActivatedRegistryCenter().persist(registryCenterService.getActivateConfigurationNode().getConfigMapPath(), configData);
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.servcie.impl;
import io.shardingsphere.shardingui.common.dto.InstanceDTO;
import io.shardingsphere.shardingui.common.dto.SlaveDataSourceDTO;
import io.shardingsphere.shardingui.servcie.OrchestrationService;
import io.shardingsphere.shardingui.servcie.RegistryCenterService;
import io.shardingsphere.shardingui.servcie.ShardingSchemaService;
import io.shardingsphere.shardingui.util.ConfigurationYamlConverter;
import org.apache.shardingsphere.api.config.masterslave.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.api.config.sharding.ShardingRuleConfiguration;
import org.apache.shardingsphere.orchestration.internal.registry.state.node.StateNodeStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
/**
* Implementation of orchestration operation service.
*
* @author chenqingyang
*/
@Service
public final class OrchestrationServiceImpl implements OrchestrationService {
@Autowired
private RegistryCenterService registryCenterService;
@Autowired
private ShardingSchemaService shardingSchemaService;
@Override
public Collection<InstanceDTO> getALLInstance() {
List<String> instanceIds = registryCenterService.getActivatedRegistryCenter().getChildrenKeys(getInstancesNodeFullRootPath());
Collection<InstanceDTO> result = new ArrayList<>(instanceIds.size());
for (String instanceId : instanceIds) {
String value = registryCenterService.getActivatedRegistryCenter().get(registryCenterService.getActivatedStateNode().getInstancesNodeFullPath(instanceId));
result.add(new InstanceDTO(instanceId, !StateNodeStatus.DISABLED.toString().equalsIgnoreCase(value)));
}
return result;
}
@Override
public void updateInstanceStatus(final String instanceId, final boolean enabled) {
String value = enabled ? "" : StateNodeStatus.DISABLED.toString();
registryCenterService.getActivatedRegistryCenter().persist(registryCenterService.getActivatedStateNode().getInstancesNodeFullPath(instanceId), value);
}
@Override
public Collection<SlaveDataSourceDTO> getAllSlaveDataSource() {
Collection<SlaveDataSourceDTO> result = new ArrayList<>();
for (String schemaName : shardingSchemaService.getAllSchemaNames()) {
String configData = shardingSchemaService.getRuleConfiguration(schemaName);
if (configData.contains("tables:\n")) {
handleShardingRuleConfiguration(result, configData, schemaName);
} else {
handleMasterSlaveRuleConfiguration(result, configData, schemaName);
}
}
return result;
}
@Override
public void updateSlaveDataSourceStatus(final String schemaNames, final String slaveDataSourceName, final boolean enabled) {
String value = enabled ? "" : StateNodeStatus.DISABLED.toString();
registryCenterService.getActivatedRegistryCenter().persist(registryCenterService.getActivatedStateNode().getDataSourcesNodeFullPath(schemaNames + "." + slaveDataSourceName), value);
}
private String getInstancesNodeFullRootPath() {
String result = registryCenterService.getActivatedStateNode().getInstancesNodeFullPath("");
return result.substring(0, result.length() - 1);
}
private void handleShardingRuleConfiguration(final Collection<SlaveDataSourceDTO> slaveDataSourceDTOS, final String configData, final String schemaName) {
ShardingRuleConfiguration shardingRuleConfiguration = ConfigurationYamlConverter.loadShardingRuleConfiguration(configData);
Collection<MasterSlaveRuleConfiguration> masterSlaveRuleConfigs = shardingRuleConfiguration.getMasterSlaveRuleConfigs();
for (MasterSlaveRuleConfiguration masterSlaveRuleConfiguration : masterSlaveRuleConfigs) {
addSlaveDataSource(slaveDataSourceDTOS, masterSlaveRuleConfiguration, schemaName);
}
}
private void handleMasterSlaveRuleConfiguration(final Collection<SlaveDataSourceDTO> slaveDataSourceDTOS, final String configData, final String schemaName) {
MasterSlaveRuleConfiguration masterSlaveRuleConfiguration = ConfigurationYamlConverter.loadMasterSlaveRuleConfiguration(configData);
addSlaveDataSource(slaveDataSourceDTOS, masterSlaveRuleConfiguration, schemaName);
}
private void addSlaveDataSource(final Collection<SlaveDataSourceDTO> slaveDataSourceDTOS, final MasterSlaveRuleConfiguration masterSlaveRuleConfiguration, final String schemaName) {
Collection<String> disabledSchemaDataSourceNames = getDisabledSchemaDataSourceNames();
for (String slaveDateSourceName : masterSlaveRuleConfiguration.getSlaveDataSourceNames()) {
slaveDataSourceDTOS.add(new SlaveDataSourceDTO(schemaName, masterSlaveRuleConfiguration.getMasterDataSourceName(),
slaveDateSourceName, !disabledSchemaDataSourceNames.contains(schemaName + "." + slaveDateSourceName)));
}
}
private Collection<String> getDisabledSchemaDataSourceNames() {
List<String> result = new ArrayList<>();
List<String> schemaDataSourceNames = registryCenterService.getActivatedRegistryCenter().getChildrenKeys(registryCenterService.getActivatedStateNode().getDataSourcesNodeFullRootPath());
for (String schemaDataSourceName : schemaDataSourceNames) {
String value = registryCenterService.getActivatedRegistryCenter().get(registryCenterService.getActivatedStateNode().getDataSourcesNodeFullPath(schemaDataSourceName));
if (StateNodeStatus.DISABLED.toString().equalsIgnoreCase(value)) {
result.add(schemaDataSourceName);
}
}
return result;
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.servcie.impl;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import io.shardingsphere.shardingui.servcie.ProxyAuthenticationService;
import io.shardingsphere.shardingui.servcie.RegistryCenterService;
import io.shardingsphere.shardingui.util.ConfigurationYamlConverter;
import org.apache.shardingsphere.core.rule.Authentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Implementation of sharding proxy authentication service.
*
* @author chenqingyang
*/
@Service
public final class ProxyAuthenticationServiceImpl implements ProxyAuthenticationService {
@Autowired
private RegistryCenterService registryCenterService;
@Override
public Authentication getAuthentication() {
String data = registryCenterService.getActivatedRegistryCenter().get(registryCenterService.getActivateConfigurationNode().getAuthenticationPath());
return Strings.isNullOrEmpty(data) ? null : ConfigurationYamlConverter.loadAuthentication(data);
}
@Override
public void updateAuthentication(final Authentication authentication) {
Preconditions.checkState(!Strings.isNullOrEmpty(authentication.getUsername()), "Authority configuration is invalid.");
registryCenterService.getActivatedRegistryCenter()
.persist(registryCenterService.getActivateConfigurationNode().getAuthenticationPath(), ConfigurationYamlConverter.dumpAuthentication(authentication));
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.servcie.impl;
import com.google.common.base.Optional;
import io.shardingsphere.shardingui.common.domain.RegistryCenterConfig;
import io.shardingsphere.shardingui.common.domain.RegistryCenterConfigs;
import io.shardingsphere.shardingui.common.exception.ShardingUIException;
import io.shardingsphere.shardingui.repository.RegistryCenterConfigsRepository;
import io.shardingsphere.shardingui.servcie.RegistryCenterConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Implementation of Registry center config service.
*
* @author chenqingyang
*/
@Service
public final class RegistryCenterConfigServiceImpl implements RegistryCenterConfigService {
@Autowired
private RegistryCenterConfigsRepository registryCenterConfigsRepository;
@Override
public RegistryCenterConfig load(final String name) {
return find(name, loadAll());
}
@Override
public Optional<RegistryCenterConfig> loadActivated() {
return Optional.fromNullable(findActivatedRegistryCenterConfiguration(loadAll()));
}
@Override
public void add(final RegistryCenterConfig config) {
RegistryCenterConfigs configs = loadAll();
RegistryCenterConfig existedConfig = find(config.getName(), configs);
if (null != existedConfig) {
throw new ShardingUIException(ShardingUIException.SERVER_ERROR, "Registry center already existed!");
}
configs.getRegistryCenterConfigs().add(config);
registryCenterConfigsRepository.save(configs);
}
@Override
public void delete(final String name) {
RegistryCenterConfigs configs = loadAll();
RegistryCenterConfig toBeRemovedConfig = find(name, configs);
if (null != toBeRemovedConfig) {
configs.getRegistryCenterConfigs().remove(toBeRemovedConfig);
registryCenterConfigsRepository.save(configs);
}
}
@Override
public void setActivated(final String name) {
RegistryCenterConfigs configs = loadAll();
RegistryCenterConfig config = find(name, configs);
if (null == config) {
throw new ShardingUIException(ShardingUIException.SERVER_ERROR, "Registry center not existed!");
}
RegistryCenterConfig activatedConfig = findActivatedRegistryCenterConfiguration(configs);
if (!config.equals(activatedConfig)) {
if (null != activatedConfig) {
activatedConfig.setActivated(false);
}
config.setActivated(true);
registryCenterConfigsRepository.save(configs);
}
}
@Override
public RegistryCenterConfigs loadAll() {
return registryCenterConfigsRepository.load();
}
private RegistryCenterConfig findActivatedRegistryCenterConfiguration(final RegistryCenterConfigs registryCenterConfigs) {
for (RegistryCenterConfig each : registryCenterConfigs.getRegistryCenterConfigs()) {
if (each.isActivated()) {
return each;
}
}
return null;
}
private RegistryCenterConfig find(final String name, final RegistryCenterConfigs configs) {
for (RegistryCenterConfig each : configs.getRegistryCenterConfigs()) {
if (name.equals(each.getName())) {
return each;
}
}
return null;
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.servcie.impl;
import com.google.common.base.Optional;
import io.shardingsphere.shardingui.common.domain.RegistryCenterConfig;
import io.shardingsphere.shardingui.common.exception.ShardingUIException;
import io.shardingsphere.shardingui.servcie.RegistryCenterConfigService;
import io.shardingsphere.shardingui.servcie.RegistryCenterService;
import io.shardingsphere.shardingui.util.RegistryCenterFactory;
import org.apache.shardingsphere.orchestration.internal.registry.config.node.ConfigurationNode;
import org.apache.shardingsphere.orchestration.internal.registry.state.node.StateNode;
import org.apache.shardingsphere.orchestration.reg.api.RegistryCenter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Implementation of Registry center service.
*
* @author chenqingyang
*/
@Service
public final class RegistryCenterServiceImpl implements RegistryCenterService {
@Autowired
private RegistryCenterConfigService registryCenterConfigService;
@Override
public RegistryCenter getActivatedRegistryCenter() {
Optional<RegistryCenterConfig> optional = registryCenterConfigService.loadActivated();
if (optional.isPresent()) {
return RegistryCenterFactory.createRegistryCenter(optional.get());
}
throw new ShardingUIException(ShardingUIException.SERVER_ERROR, "No activated registry center!");
}
@Override
public ConfigurationNode getActivateConfigurationNode() {
Optional<RegistryCenterConfig> optional = registryCenterConfigService.loadActivated();
if (optional.isPresent()) {
return new ConfigurationNode(optional.get().getOrchestrationName());
}
throw new ShardingUIException(ShardingUIException.SERVER_ERROR, "No activated registry center!");
}
@Override
public StateNode getActivatedStateNode() {
Optional<RegistryCenterConfig> optional = registryCenterConfigService.loadActivated();
if (optional.isPresent()) {
return new StateNode(optional.get().getOrchestrationName());
}
throw new ShardingUIException(ShardingUIException.SERVER_ERROR, "No activated registry center!");
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.servcie.impl;
import io.shardingsphere.shardingui.servcie.RegistryCenterService;
import io.shardingsphere.shardingui.servcie.ShardingPropertiesService;
import io.shardingsphere.shardingui.util.ConfigurationYamlConverter;
import org.apache.shardingsphere.core.constant.properties.ShardingProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Properties;
/**
* Implementation of sharding properties service.
*
* @author chenqingyang
*/
@Service
public final class ShardingPropertiesServiceImpl implements ShardingPropertiesService {
@Autowired
private RegistryCenterService registryCenterService;
@Override
public String loadShardingProperties() {
return registryCenterService.getActivatedRegistryCenter().get(registryCenterService.getActivateConfigurationNode().getPropsPath());
}
@Override
public void updateShardingProperties(final String configData) {
checkShardingProperties(configData);
registryCenterService.getActivatedRegistryCenter().persist(registryCenterService.getActivateConfigurationNode().getPropsPath(), configData);
}
private void checkShardingProperties(final String configData) {
try {
Properties properties = ConfigurationYamlConverter.loadProperties(configData);
new ShardingProperties(properties);
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
throw new IllegalArgumentException("Sharding properties is invalid.");
}
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.servcie.impl;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import io.shardingsphere.shardingui.servcie.RegistryCenterService;
import io.shardingsphere.shardingui.servcie.ShardingSchemaService;
import io.shardingsphere.shardingui.util.ConfigurationYamlConverter;
import org.apache.shardingsphere.api.config.RuleConfiguration;
import org.apache.shardingsphere.core.config.DataSourceConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collection;
import java.util.Map;
/**
* Implementation of sharding schema service.
*
* @author chenqingyang
*/
@Service
public final class ShardingSchemaServiceImpl implements ShardingSchemaService {
@Autowired
private RegistryCenterService registryCenterService;
@Override
public Collection<String> getAllSchemaNames() {
return registryCenterService.getActivatedRegistryCenter().getChildrenKeys(registryCenterService.getActivateConfigurationNode().getSchemaPath());
}
@Override
public String getRuleConfiguration(final String schemaName) {
return registryCenterService.getActivatedRegistryCenter().get(registryCenterService.getActivateConfigurationNode().getRulePath(schemaName));
}
@Override
public String getDataSourceConfiguration(final String schemaName) {
return registryCenterService.getActivatedRegistryCenter().get(registryCenterService.getActivateConfigurationNode().getDataSourcePath(schemaName));
}
@Override
public void updateRuleConfiguration(final String schemaName, final String configData) {
checkRuleConfiguration(configData);
persistRuleConfiguration(schemaName, configData);
}
@Override
public void updateDataSourceConfiguration(final String schemaName, final String configData) {
checkDataSourceConfiguration(configData);
persistDataSourceConfiguration(schemaName, configData);
}
@Override
public void addSchemaConfiguration(final String schemaName, final String ruleConfiguration, final String dataSourceConfiguration) {
checkSchemaName(schemaName, getAllSchemaNames());
checkRuleConfiguration(ruleConfiguration);
checkDataSourceConfiguration(dataSourceConfiguration);
persistRuleConfiguration(schemaName, ruleConfiguration);
persistDataSourceConfiguration(schemaName, dataSourceConfiguration);
}
private void checkRuleConfiguration(final String configData) {
try {
RuleConfiguration ruleConfig = configData.contains("tables:\n")
? ConfigurationYamlConverter.loadShardingRuleConfiguration(configData) : ConfigurationYamlConverter.loadMasterSlaveRuleConfiguration(configData);
Preconditions.checkState(ruleConfig != null, "rule configuration is invalid.");
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
throw new IllegalArgumentException("rule configuration is invalid.");
}
}
private void persistRuleConfiguration(final String schemaName, final String ruleConfiguration) {
registryCenterService.getActivatedRegistryCenter().persist(registryCenterService.getActivateConfigurationNode().getRulePath(schemaName), ruleConfiguration);
}
private void checkDataSourceConfiguration(final String configData) {
try {
Map<String, DataSourceConfiguration> dataSourceConfigs = ConfigurationYamlConverter.loadDataSourceConfigurations(configData);
Preconditions.checkState(!dataSourceConfigs.isEmpty(), "data source configuration is invalid.");
// CHECKSTYLE:OFF
} catch (final Exception ex) {
// CHECKSTYLE:ON
throw new IllegalArgumentException("data source configuration is invalid.");
}
}
private void persistDataSourceConfiguration(final String schemaName, final String dataSourceConfiguration) {
registryCenterService.getActivatedRegistryCenter().persist(registryCenterService.getActivateConfigurationNode().getDataSourcePath(schemaName), dataSourceConfiguration);
}
private void checkSchemaName(final String schemaName, final Collection<String> existedSchemaNames) {
Preconditions.checkArgument(!Strings.isNullOrEmpty(schemaName), "schema name is invalid.");
Preconditions.checkArgument(!existedSchemaNames.contains(schemaName), "schema name already exists.");
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.util;
import com.google.common.base.Function;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.api.config.masterslave.MasterSlaveRuleConfiguration;
import org.apache.shardingsphere.api.config.sharding.ShardingRuleConfiguration;
import org.apache.shardingsphere.core.config.DataSourceConfiguration;
import org.apache.shardingsphere.core.rule.Authentication;
import org.apache.shardingsphere.core.yaml.config.common.YamlAuthentication;
import org.apache.shardingsphere.core.yaml.config.masterslave.YamlMasterSlaveRuleConfiguration;
import org.apache.shardingsphere.core.yaml.config.sharding.YamlShardingRuleConfiguration;
import org.apache.shardingsphere.core.yaml.engine.DefaultYamlRepresenter;
import org.apache.shardingsphere.core.yaml.engine.YamlEngine;
import org.apache.shardingsphere.core.yaml.swapper.impl.AuthenticationYamlSwapper;
import org.apache.shardingsphere.core.yaml.swapper.impl.MasterSlaveRuleConfigurationYamlSwapper;
import org.apache.shardingsphere.core.yaml.swapper.impl.ShardingRuleConfigurationYamlSwapper;
import org.apache.shardingsphere.orchestration.yaml.config.YamlDataSourceConfiguration;
import org.apache.shardingsphere.orchestration.yaml.swapper.DataSourceConfigurationYamlSwapper;
import org.yaml.snakeyaml.Yaml;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Properties;
/**
* YAML converter for configuration.
*
* @author panjuan
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ConfigurationYamlConverter {
/**
* Load data source configurations.
*
* @param data data
* @return data source configurations
*/
@SuppressWarnings("unchecked")
public static Map<String, DataSourceConfiguration> loadDataSourceConfigurations(final String data) {
Map<String, YamlDataSourceConfiguration> result = (Map) YamlEngine.unmarshal(data);
Preconditions.checkState(null != result && !result.isEmpty(), "No available data sources to load for orchestration.");
return Maps.transformValues(result, new Function<YamlDataSourceConfiguration, DataSourceConfiguration>() {
@Override
public DataSourceConfiguration apply(final YamlDataSourceConfiguration input) {
return new DataSourceConfigurationYamlSwapper().swap(input);
}
});
}
/**
* Load sharding rule configuration.
*
* @param data data
* @return sharding rule configuration
*/
public static ShardingRuleConfiguration loadShardingRuleConfiguration(final String data) {
return new ShardingRuleConfigurationYamlSwapper().swap(YamlEngine.unmarshal(data, YamlShardingRuleConfiguration.class));
}
/**
* Load master-slave rule configuration.
*
* @param data data
* @return master-slave rule configuration
*/
public static MasterSlaveRuleConfiguration loadMasterSlaveRuleConfiguration(final String data) {
return new MasterSlaveRuleConfigurationYamlSwapper().swap(YamlEngine.unmarshal(data, YamlMasterSlaveRuleConfiguration.class));
}
/**
* Load authentication.
*
* @param data data
* @return authentication
*/
public static Authentication loadAuthentication(final String data) {
Authentication result = new AuthenticationYamlSwapper().swap(YamlEngine.unmarshal(data, YamlAuthentication.class));
Preconditions.checkState(!Strings.isNullOrEmpty(result.getUsername()), "Authority configuration is invalid.");
return result;
}
/**
* Load config map. 4.0.0-RC1 has removed this directory.
*
* @param data data
* @return config map
*/
@SuppressWarnings("unchecked")
@Deprecated
public static Map<String, Object> loadConfigMap(final String data) {
return Strings.isNullOrEmpty(data) ? new LinkedHashMap<String, Object>() : (Map) new Yaml().load(data);
}
/**
* Load properties configuration.
*
* @param data data
* @return properties
*/
public static Properties loadProperties(final String data) {
return YamlEngine.unmarshalProperties(data);
}
/**
* Dump data sources configuration.
*
* @param dataSourceConfigs data sources configurations
* @return YAML string
*/
@SuppressWarnings("unchecked")
public static String dumpDataSourceConfigurations(final Map<String, DataSourceConfiguration> dataSourceConfigs) {
return new Yaml(new DefaultYamlRepresenter()).dumpAsMap(
Maps.transformValues(dataSourceConfigs, new Function<DataSourceConfiguration, YamlDataSourceConfiguration>() {
@Override
public YamlDataSourceConfiguration apply(final DataSourceConfiguration input) {
YamlDataSourceConfiguration result = new YamlDataSourceConfiguration();
result.setDataSourceClassName(input.getDataSourceClassName());
result.setProperties(input.getProperties());
return result;
}
}));
}
/**
* Dump sharding rule configuration.
*
* @param shardingRuleConfig sharding rule configuration
* @return YAML string
*/
public static String dumpShardingRuleConfiguration(final ShardingRuleConfiguration shardingRuleConfig) {
return new Yaml(new DefaultYamlRepresenter()).dumpAsMap(new ShardingRuleConfigurationYamlSwapper().swap(shardingRuleConfig));
}
/**
* Dump master-slave rule configuration.
*
* @param masterSlaveRuleConfig master-slave rule configuration
* @return YAML string
*/
public static String dumpMasterSlaveRuleConfiguration(final MasterSlaveRuleConfiguration masterSlaveRuleConfig) {
return new Yaml(new DefaultYamlRepresenter()).dumpAsMap(new MasterSlaveRuleConfigurationYamlSwapper().swap(masterSlaveRuleConfig));
}
/**
* Dump authentication.
*
* @param authentication authentication
* @return YAML string
*/
public static String dumpAuthentication(final Authentication authentication) {
return new Yaml(new DefaultYamlRepresenter()).dumpAsMap(authentication);
}
/**
* Dump config map. 4.0.0-RC1 has removed it.
*
* @param configMap config map
* @return YAML string
*/
@Deprecated
public static String dumpConfigMap(final Map<String, Object> configMap) {
return new Yaml(new DefaultYamlRepresenter()).dumpAsMap(configMap);
}
/**
* Dump properties configuration.
*
* @param props props
* @return YAML string
*/
public static String dumpProperties(final Properties props) {
return new Yaml(new DefaultYamlRepresenter()).dumpAsMap(props);
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.util;
import io.shardingsphere.shardingui.common.constant.RegistryCenterType;
import io.shardingsphere.shardingui.common.domain.RegistryCenterConfig;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.orchestration.reg.api.RegistryCenter;
import org.apache.shardingsphere.orchestration.reg.api.RegistryCenterConfiguration;
import org.apache.shardingsphere.orchestration.reg.zookeeper.curator.CuratorZookeeperRegistryCenter;
import java.util.concurrent.ConcurrentHashMap;
/**
* Registry center factory.
*
* @author chenqingyang
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class RegistryCenterFactory {
private static final ConcurrentHashMap<String, RegistryCenter> REGISTRY_CENTER_MAP = new ConcurrentHashMap<>();
/**
* Create registry center instance.
*
* @param config registry center config
* @return registry center
*/
public static RegistryCenter createRegistryCenter(final RegistryCenterConfig config) {
RegistryCenter result = REGISTRY_CENTER_MAP.get(config.getName());
if (null != result) {
return result;
}
RegistryCenterType registryCenterType = RegistryCenterType.nameOf(config.getRegistryCenterType());
switch (registryCenterType) {
case ZOOKEEPER:
result = new CuratorZookeeperRegistryCenter();
break;
default:
throw new UnsupportedOperationException(config.getName());
}
result.init(convert(config));
REGISTRY_CENTER_MAP.put(config.getName(), result);
return result;
}
private static RegistryCenterConfiguration convert(final RegistryCenterConfig config) {
RegistryCenterConfiguration result = new RegistryCenterConfiguration(config.getRegistryCenterType());
result.setServerLists(config.getServerLists());
result.setNamespace(config.getNamespace());
result.setDigest(config.getDigest());
return result;
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.web.advice;
import io.shardingsphere.shardingui.common.exception.ShardingUIException;
import io.shardingsphere.shardingui.web.response.ResponseResult;
import io.shardingsphere.shardingui.web.response.ResponseResultUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* Global exception handler.
*
* @author chenqingyang
*/
@Slf4j
@ControllerAdvice
public final class GlobalExceptionHandler {
/**
* Handle exception.
*
* @param ex exception
* @return response result
*/
@ExceptionHandler(Exception.class)
@ResponseBody
public ResponseResult<?> handleException(final Exception ex) {
log.error("controller error", ex);
if (ex instanceof IllegalArgumentException) {
return ResponseResultUtil.handleIllegalArgumentException(ex.getMessage());
} else if (ex instanceof ShardingUIException) {
return ResponseResultUtil.handleShardingUIException((ShardingUIException) ex);
}
return ResponseResultUtil.handleUncaughtException(ex.getMessage());
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.web.controller;
import io.shardingsphere.shardingui.servcie.ConfigMapService;
import io.shardingsphere.shardingui.web.response.ResponseResult;
import io.shardingsphere.shardingui.web.response.ResponseResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* RESTful API of config map.
*
* @author chenqingyang
*/
@RestController
@RequestMapping("/api/config-map")
public final class ConfigMapController {
@Autowired
private ConfigMapService configMapService;
/**
* Load config map.
*
* @return response result
*/
@RequestMapping(value = "", method = RequestMethod.GET)
public ResponseResult<Map<String, Object>> loadConfigMap() {
return ResponseResultUtil.build(configMapService.loadConfigMap());
}
/**
* Update config map.
*
* @param configMap config map
* @return response result
*/
@RequestMapping(value = "", method = RequestMethod.PUT)
public ResponseResult updateConfigMap(@RequestBody final Map<String, Object> configMap) {
configMapService.updateConfigMap(configMap);
return ResponseResultUtil.success();
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.web.controller;
import io.shardingsphere.shardingui.common.dto.InstanceDTO;
import io.shardingsphere.shardingui.common.dto.SlaveDataSourceDTO;
import io.shardingsphere.shardingui.servcie.OrchestrationService;
import io.shardingsphere.shardingui.web.response.ResponseResult;
import io.shardingsphere.shardingui.web.response.ResponseResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collection;
/**
* RESTful API of orchestration operation.
*
* @author chenqingyang
*/
@RestController
@RequestMapping("/api/orchestration")
public final class OrchestrationController {
@Autowired
private OrchestrationService orchestrationService;
/**
* Load all instances.
*
* @return response result
*/
@RequestMapping(value = "/instance", method = RequestMethod.GET)
public ResponseResult<Collection<InstanceDTO>> loadAllInstances() {
return ResponseResultUtil.build(orchestrationService.getALLInstance());
}
/**
* update instance status.
*
* @param instanceDTO instance DTO
* @return response result
*/
@RequestMapping(value = "/instance", method = RequestMethod.PUT)
public ResponseResult updateInstanceStatus(@RequestBody final InstanceDTO instanceDTO) {
orchestrationService.updateInstanceStatus(instanceDTO.getInstanceId(), instanceDTO.isEnabled());
return ResponseResultUtil.success();
}
/**
* Load all slave data sources.
*
* @return response result
*/
@RequestMapping(value = "/datasource", method = RequestMethod.GET)
public ResponseResult<Collection<SlaveDataSourceDTO>> loadAllSlaveDataSources() {
return ResponseResultUtil.build(orchestrationService.getAllSlaveDataSource());
}
/**
* Update slave data source status.
*
* @param slaveDataSourceDTO slave data source DTO
* @return response result
*/
@RequestMapping(value = "/datasource", method = RequestMethod.PUT)
public ResponseResult updateSlaveDataSourceStatus(@RequestBody final SlaveDataSourceDTO slaveDataSourceDTO) {
orchestrationService.updateSlaveDataSourceStatus(slaveDataSourceDTO.getSchema(), slaveDataSourceDTO.getSlaveDataSourceName(), slaveDataSourceDTO.isEnabled());
return ResponseResultUtil.success();
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.web.controller;
import io.shardingsphere.shardingui.servcie.ProxyAuthenticationService;
import io.shardingsphere.shardingui.web.response.ResponseResult;
import io.shardingsphere.shardingui.web.response.ResponseResultUtil;
import org.apache.shardingsphere.core.rule.Authentication;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
/**
* RESTful API of sharding proxy authentication.
*
* @author chenqingyang
*/
@RestController
@RequestMapping("/api/authentication")
public final class ProxyAuthenticationController {
@Autowired
private ProxyAuthenticationService proxyAuthenticationService;
/**
* Load authentication.
*
* @return response result
*/
@RequestMapping(value = "", method = RequestMethod.GET)
public ResponseResult<Authentication> loadAuthentication() {
return ResponseResultUtil.build(proxyAuthenticationService.getAuthentication());
}
/**
* Update authentication.
*
* @param authentication authentication
* @return response result
*/
@RequestMapping(value = "", method = RequestMethod.PUT)
public ResponseResult updateAuthentication(@RequestBody final Authentication authentication) {
proxyAuthenticationService.updateAuthentication(authentication);
return ResponseResultUtil.success();
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.web.controller;
import io.shardingsphere.shardingui.common.domain.RegistryCenterConfig;
import io.shardingsphere.shardingui.servcie.RegistryCenterConfigService;
import io.shardingsphere.shardingui.util.RegistryCenterFactory;
import io.shardingsphere.shardingui.web.response.ResponseResult;
import io.shardingsphere.shardingui.web.response.ResponseResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* RESTful API of registry center configuration.
*
* @author chenqingyang
*/
@RestController
@RequestMapping("/api/reg-center")
public final class RegistryCenterController {
@Autowired
private RegistryCenterConfigService registryCenterConfigService;
/**
* Load all registry center configs.
*
* @return response result
*/
@RequestMapping(value = "", method = RequestMethod.GET)
public ResponseResult<List<RegistryCenterConfig>> loadConfigs() {
return ResponseResultUtil.build(registryCenterConfigService.loadAll().getRegistryCenterConfigs());
}
/**
* Add registry center config.
*
* @param config registry center config
* @return response result
*/
@RequestMapping(value = "", method = RequestMethod.POST)
public ResponseResult add(@RequestBody final RegistryCenterConfig config) {
registryCenterConfigService.add(config);
return ResponseResultUtil.success();
}
/**
* Delete registry center config.
*
* @param config registry center config
* @return response result
*/
@RequestMapping(value = "", method = RequestMethod.DELETE)
public ResponseResult delete(@RequestBody final RegistryCenterConfig config) {
registryCenterConfigService.delete(config.getName());
return ResponseResultUtil.success();
}
/**
* Connect registry center.
*
* @param config registry center config
* @return response result
*/
@RequestMapping(value = "/connect", method = RequestMethod.POST)
public ResponseResult<Boolean> connect(@RequestBody final RegistryCenterConfig config) {
RegistryCenterFactory.createRegistryCenter(registryCenterConfigService.load(config.getName()));
registryCenterConfigService.setActivated(config.getName());
return ResponseResultUtil.build(Boolean.TRUE);
}
/**
* Get activated registry center config.
*
* @return response result
*/
@RequestMapping(value = "/activated", method = RequestMethod.GET)
public ResponseResult<RegistryCenterConfig> activated() {
return ResponseResultUtil.build(registryCenterConfigService.loadActivated().orNull());
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.web.controller;
import io.shardingsphere.shardingui.servcie.ShardingPropertiesService;
import io.shardingsphere.shardingui.web.response.ResponseResult;
import io.shardingsphere.shardingui.web.response.ResponseResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* RESTful API of sharding properties.
*
* @author chenqingyang
*/
@RestController
@RequestMapping("/api/props")
public final class ShardingPropertiesController {
@Autowired
private ShardingPropertiesService shardingPropertiesService;
/**
* Load sharding properties.
*
* @return response result
*/
@RequestMapping(value = "", method = RequestMethod.GET)
public ResponseResult<String> loadShardingProperties() {
return ResponseResultUtil.build(shardingPropertiesService.loadShardingProperties());
}
/**
* Update sharding properties.
*
* @param configMap config map
* @return response result
*/
@RequestMapping(value = "", method = RequestMethod.PUT)
public ResponseResult updateShardingProperties(@RequestBody final Map<String, String> configMap) {
shardingPropertiesService.updateShardingProperties(configMap.get("props"));
return ResponseResultUtil.success();
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.web.controller;
import io.shardingsphere.shardingui.common.dto.ShardingSchemaDTO;
import io.shardingsphere.shardingui.servcie.ShardingSchemaService;
import io.shardingsphere.shardingui.web.response.ResponseResult;
import io.shardingsphere.shardingui.web.response.ResponseResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collection;
import java.util.Map;
/**
* RESTful API of sharding schema configuration.
*
* @author chenqingyang
*/
@RestController
@RequestMapping("/api/schema")
public final class ShardingSchemaController {
@Autowired
private ShardingSchemaService shardingSchemaService;
/**
* Load all schema names.
*
* @return response result
*/
@RequestMapping(value = "", method = RequestMethod.GET)
public ResponseResult<Collection<String>> loadAllSchemaNames() {
return ResponseResultUtil.build(shardingSchemaService.getAllSchemaNames());
}
/**
* Add schema configuration.
*
* @param shardingSchema sharding schema DTO.
* @return response result
*/
@RequestMapping(value = "", method = RequestMethod.POST)
public ResponseResult addSchema(final @RequestBody ShardingSchemaDTO shardingSchema) {
shardingSchemaService.addSchemaConfiguration(shardingSchema.getName(), shardingSchema.getRuleConfiguration(), shardingSchema.getDataSourceConfiguration());
return ResponseResultUtil.success();
}
/**
* Load rule configuration.
*
* @param schemaName schema name
* @return response result
*/
@RequestMapping(value = "/rule/{schemaName}", method = RequestMethod.GET)
public ResponseResult<String> loadRuleConfiguration(@PathVariable("schemaName") final String schemaName) {
return ResponseResultUtil.build(shardingSchemaService.getRuleConfiguration(schemaName));
}
/**
* Update rule configuration.
*
* @param schemaName schema name
* @param configMap config map
* @return response result
*/
@RequestMapping(value = "/rule/{schemaName}", method = RequestMethod.PUT)
public ResponseResult updateRuleConfiguration(@PathVariable("schemaName") final String schemaName, @RequestBody final Map<String, String> configMap) {
shardingSchemaService.updateRuleConfiguration(schemaName, configMap.get("ruleConfig"));
return ResponseResultUtil.success();
}
/**
* Load data source configuration.
*
* @param schemaName schema name
* @return response result
*/
@RequestMapping(value = "/datasource/{schemaName}", method = RequestMethod.GET)
public ResponseResult<String> loadDataSourceConfiguration(@PathVariable("schemaName") final String schemaName) {
return ResponseResultUtil.build(shardingSchemaService.getDataSourceConfiguration(schemaName));
}
/**
* Update data source configuration.
*
* @param schemaName schema name
* @param configMap config map
* @return response result
*/
@RequestMapping(value = "/datasource/{schemaName}", method = RequestMethod.PUT)
public ResponseResult updateDataSourceConfiguration(@PathVariable("schemaName") final String schemaName, @RequestBody final Map<String, String> configMap) {
shardingSchemaService.updateDataSourceConfiguration(schemaName, configMap.get("dataSourceConfig"));
return ResponseResultUtil.success();
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.web.filter;
import org.springframework.http.HttpStatus;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* CORS filter.
*
* @author chenqingyang
*/
public final class CORSFilter implements Filter {
@Override
public void init(final FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) servletResponse;
HttpServletRequest request = (HttpServletRequest) servletRequest;
response.setHeader("Access-Control-Allow-Origin", request.getHeader("Origin"));
response.setHeader("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE,OPTIONS");
response.setHeader("Access-Control-Max-Age", "3600");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Headers", "Content-Type,Access-Token");
if ("OPTIONS".equals(request.getMethod())) {
response.setStatus(HttpStatus.OK.value());
} else {
filterChain.doFilter(request, response);
}
}
@Override
public void destroy() {
}
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.web.response;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.io.Serializable;
/**
* Restful Response result.
*
* @author chenqingyang
*/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public final class ResponseResult<T> implements Serializable {
private static final long serialVersionUID = 8144393142115317354L;
private boolean success = true;
private int errorCode;
private String errorMsg;
private T model;
}
/*
* Copyright 2016-2018 shardingsphere.io.
* <p>
* 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.
* </p>
*/
package io.shardingsphere.shardingui.web.response;
import io.shardingsphere.shardingui.common.exception.ShardingUIException;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
/**
* Response result utility.
*
* @author chenqingyang
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ResponseResultUtil {
/**
* Build the successful response without data model.
*
* @return response result
*/
public static ResponseResult success() {
return build(null);
}
/**
* Build the successful response with data model.
*
* @param model data model
* @param <T> data model type
* @return response result
*/
public static <T> ResponseResult<T> build(final T model) {
ResponseResult<T> result = new ResponseResult<>();
result.setSuccess(true);
result.setModel(model);
return result;
}
/**
* Build the error response of illegal argument exception.
*
* @param errorMsg error message
* @return response result
*/
public static ResponseResult handleIllegalArgumentException(final String errorMsg) {
ResponseResult result = new ResponseResult<>();
result.setSuccess(false);
result.setErrorCode(ShardingUIException.INVALID_PARAM);
result.setErrorMsg(errorMsg);
return result;
}
/**
* Build the error response of unauthorized exception.
*
* @param errorMsg error message
* @return response result
*/
public static ResponseResult handleUnauthorizedException(final String errorMsg) {
ResponseResult result = new ResponseResult<>();
result.setSuccess(false);
result.setErrorCode(ShardingUIException.NO_RIGHT);
result.setErrorMsg(errorMsg);
return result;
}
/**
* Build the error response of sharding UI exception.
*
* @param exception sharding UI exception
* @return response result
*/
public static ResponseResult handleShardingUIException(final ShardingUIException exception) {
ResponseResult result = new ResponseResult<>();
result.setSuccess(false);
result.setErrorCode(exception.getErrCode());
result.setErrorMsg(exception.getMessage());
return result;
}
/**
* Build the error response of uncaught exception.
*
* @param errorMsg error message
* @return response result
*/
public static ResponseResult handleUncaughtException(final String errorMsg) {
ResponseResult result = new ResponseResult<>();
result.setSuccess(false);
result.setErrorCode(ShardingUIException.SERVER_ERROR);
result.setErrorMsg(errorMsg);
return result;
}
}
server.port=8088
user.admin.username=admin
user.admin.password=admin
\ No newline at end of file
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>assembly</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<includes>
<include>*.jar</include>
</includes>
<outputDirectory>lib</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/resources/bin</directory>
<outputDirectory>bin</outputDirectory>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<directory>src/main/resources</directory>
<includes>
<include>application.properties</include>
<include>logback.xml</include>
</includes>
<outputDirectory>conf</outputDirectory>
<fileMode>0644</fileMode>
</fileSet>
</fileSets>
</assembly>
#!/bin/bash
SERVER_NAME=Sharding-UI
cd `dirname $0`
cd ..
DEPLOY_DIR=`pwd`
LOGS_DIR=${DEPLOY_DIR}/logs
if [ ! -d ${LOGS_DIR} ]; then
mkdir ${LOGS_DIR}
fi
STDOUT_FILE=${LOGS_DIR}/stdout.log
PIDS=`ps -ef | grep java | grep "$DEPLOY_DIR" | grep -v grep | awk '{print $2}'`
if [ -n "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME already started!"
echo "PID: $PIDS"
exit 1
fi
CLASS_PATH=.:${DEPLOY_DIR}/conf:${DEPLOY_DIR}/lib/*
JAVA_OPTS=" -server -Xmx1g -Xms1g -Xmn512m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 "
JAVA_OPTS="${JAVA_OPTS} -jar ${DEPLOY_DIR}/lib/sharding-ui.jar"
JAVA_OPTS="${JAVA_OPTS} --spring.config.location=${DEPLOY_DIR}/conf/application.properties"
JAVA_OPTS="${JAVA_OPTS} --logging.config=${DEPLOY_DIR}/conf/logback.xml"
echo "Starting the $SERVER_NAME ..."
nohup java ${JAVA_OPTS} > ${STDOUT_FILE} 2>&1 &
sleep 1
echo "Please check the STDOUT file: $STDOUT_FILE"
#!/bin/bash
SERVER_NAME=Sharding-UI
cd `dirname $0`
cd ..
DEPLOY_DIR=`pwd`
PIDS=`ps -ef | grep java | grep "$DEPLOY_DIR" | grep -v grep |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
echo -e "Stopping the $SERVER_NAME ...\c"
for PID in ${PIDS} ; do
kill ${PID} > /dev/null 2>&1
done
COUNT=0
while [ ${COUNT} -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=1
for PID in ${PIDS} ; do
PID_EXIST=`ps -f -p ${PID} | grep java`
if [ -n "$PID_EXIST" ]; then
COUNT=0
break
fi
done
done
echo "OK!"
echo "PID: $PIDS"
<?xml version="1.0"?>
<configuration>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>[%-5level] %d{HH:mm:ss.SSS} [%thread] %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<logger name="io.shardingsphere" level="info" additivity="false">
<appender-ref ref="console"/>
</logger>
<root>
<level value="info" />
<appender-ref ref="console" />
</root>
</configuration>
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime", "dynamic-import-webpack"]
}
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
/build/
/config/
/dist/
/*.js
module.exports = {
root: true,
parserOptions: {
parser: 'babel-eslint',
sourceType: 'module'
},
env: {
browser: true,
node: true,
es6: true,
},
extends: ['plugin:vue/recommended', 'eslint:recommended'],
// add your custom rules here
//it is base on https://github.com/vuejs/eslint-config-vue
rules: {
"vue/max-attributes-per-line": [2, {
"singleline": 10,
"multiline": {
"max": 1,
"allowFirstLine": false
}
}],
"vue/name-property-casing": ["error", "PascalCase"],
'accessor-pairs': 2,
'arrow-spacing': [2, {
'before': true,
'after': true
}],
'block-spacing': [2, 'always'],
'brace-style': [2, '1tbs', {
'allowSingleLine': true
}],
'camelcase': [0, {
'properties': 'always'
}],
'comma-dangle': [2, 'never'],
'comma-spacing': [2, {
'before': false,
'after': true
}],
'comma-style': [2, 'last'],
'constructor-super': 2,
'curly': [2, 'multi-line'],
'dot-location': [2, 'property'],
'eol-last': 0,
'eqeqeq': [2, 'allow-null'],
'generator-star-spacing': [2, {
'before': true,
'after': true
}],
'handle-callback-err': [2, '^(err|error)$'],
'indent': [2, 2, {
'SwitchCase': 1
}],
'jsx-quotes': [2, 'prefer-single'],
'key-spacing': [2, {
'beforeColon': false,
'afterColon': true
}],
'keyword-spacing': [2, {
'before': true,
'after': true
}],
'new-cap': [2, {
'newIsCap': true,
'capIsNew': false
}],
'new-parens': 2,
'no-array-constructor': 2,
'no-caller': 2,
'no-console': 'off',
'no-class-assign': 2,
'no-cond-assign': 2,
'no-const-assign': 2,
'no-control-regex': 2,
'no-delete-var': 2,
'no-dupe-args': 2,
'no-dupe-class-members': 2,
'no-dupe-keys': 2,
'no-duplicate-case': 2,
'no-empty-character-class': 2,
'no-empty-pattern': 2,
'no-eval': 2,
'no-ex-assign': 2,
'no-extend-native': 2,
'no-extra-bind': 2,
'no-extra-boolean-cast': 2,
'no-extra-parens': [2, 'functions'],
'no-fallthrough': 2,
'no-floating-decimal': 2,
'no-func-assign': 2,
'no-implied-eval': 2,
'no-inner-declarations': [2, 'functions'],
'no-invalid-regexp': 2,
'no-irregular-whitespace': 2,
'no-iterator': 2,
'no-label-var': 2,
'no-labels': [2, {
'allowLoop': false,
'allowSwitch': false
}],
'no-lone-blocks': 2,
'no-mixed-spaces-and-tabs': 2,
'no-multi-spaces': 2,
'no-multi-str': 2,
'no-multiple-empty-lines': [2, {
'max': 1
}],
'no-native-reassign': 2,
'no-negated-in-lhs': 2,
'no-new-object': 2,
'no-new-require': 2,
'no-new-symbol': 2,
'no-new-wrappers': 2,
'no-obj-calls': 2,
'no-octal': 2,
'no-octal-escape': 2,
'no-path-concat': 2,
'no-proto': 2,
'no-redeclare': 2,
'no-regex-spaces': 2,
'no-return-assign': [2, 'except-parens'],
'no-self-assign': 2,
'no-self-compare': 2,
'no-sequences': 2,
'no-shadow-restricted-names': 2,
'no-spaced-func': 2,
'no-sparse-arrays': 2,
'no-this-before-super': 2,
'no-throw-literal': 2,
'no-trailing-spaces': 2,
'no-undef': 2,
'no-undef-init': 2,
'no-unexpected-multiline': 2,
'no-unmodified-loop-condition': 2,
'no-unneeded-ternary': [2, {
'defaultAssignment': false
}],
'no-unreachable': 2,
'no-unsafe-finally': 2,
'no-unused-vars': [2, {
'vars': 'all',
'args': 'none'
}],
'no-useless-call': 2,
'no-useless-computed-key': 2,
'no-useless-constructor': 2,
'no-useless-escape': 0,
'no-whitespace-before-property': 2,
'no-with': 2,
'one-var': [2, {
'initialized': 'never'
}],
'operator-linebreak': [2, 'after', {
'overrides': {
'?': 'before',
':': 'before'
}
}],
'padded-blocks': [2, 'never'],
'quotes': [2, 'single', {
'avoidEscape': true,
'allowTemplateLiterals': true
}],
'semi': [2, 'never'],
'semi-spacing': [2, {
'before': false,
'after': true
}],
'space-before-blocks': [2, 'always'],
'space-before-function-paren': [2, 'never'],
'space-in-parens': [2, 'never'],
'space-infix-ops': 2,
'space-unary-ops': [2, {
'words': true,
'nonwords': false
}],
'spaced-comment': [2, 'always', {
'markers': ['global', 'globals', 'eslint', 'eslint-disable', '*package', '!', ',']
}],
'template-curly-spacing': [2, 'never'],
'use-isnan': 2,
'valid-typeof': 2,
'wrap-iife': [2, 'any'],
'yield-star-spacing': [2, 'both'],
'yoda': [2, 'never'],
'prefer-const': 2,
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'object-curly-spacing': [2, 'always', {
objectsInObjects: false
}],
'array-bracket-spacing': [2, 'never']
}
}
.DS_Store
node_modules/
node/
/dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
package-lock.json
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
// https://github.com/michael-ciniawsky/postcss-load-config
module.exports = {
"plugins": {
"postcss-import": {},
"postcss-url": {},
// to edit target browsers: use "browserslist" field in package.json
"autoprefixer": {}
}
}
# sharding-ui-frontend
## Build Setup
``` bash
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# build for production and view the bundle analyzer report
npm run build --report
```
## Test command
```bash
npm run test
```
\ No newline at end of file
'use strict'
require('./check-versions')()
process.env.NODE_ENV = 'production'
const ora = require('ora')
const rm = require('rimraf')
const path = require('path')
const chalk = require('chalk')
const webpack = require('webpack')
const config = require('../config')
const webpackConfig = require('./webpack.prod.conf')
const spinner = ora('building for production...')
spinner.start()
rm(path.join(config.build.assetsRoot, config.build.assetsSubDirectory), err => {
if (err) throw err
webpack(webpackConfig, (err, stats) => {
spinner.stop()
if (err) throw err
process.stdout.write(stats.toString({
colors: true,
modules: false,
children: false, // If you are using ts-loader, setting this to true will make TypeScript errors show up during build.
chunks: false,
chunkModules: false
}) + '\n\n')
if (stats.hasErrors()) {
console.log(chalk.red(' Build failed with errors.\n'))
process.exit(1)
}
console.log(chalk.cyan(' Build complete.\n'))
console.log(chalk.yellow(
' Tip: built files are meant to be served over an HTTP server.\n' +
' Opening index.html over file:// won\'t work.\n'
))
})
})
'use strict'
const chalk = require('chalk')
const semver = require('semver')
const packageConfig = require('../package.json')
const shell = require('shelljs')
function exec (cmd) {
return require('child_process').execSync(cmd).toString().trim()
}
const versionRequirements = [
{
name: 'node',
currentVersion: semver.clean(process.version),
versionRequirement: packageConfig.engines.node
}
]
if (shell.which('npm')) {
versionRequirements.push({
name: 'npm',
currentVersion: exec('npm --version'),
versionRequirement: packageConfig.engines.npm
})
}
module.exports = function () {
const warnings = []
for (let i = 0; i < versionRequirements.length; i++) {
const mod = versionRequirements[i]
if (!semver.satisfies(mod.currentVersion, mod.versionRequirement)) {
warnings.push(mod.name + ': ' +
chalk.red(mod.currentVersion) + ' should be ' +
chalk.green(mod.versionRequirement)
)
}
}
if (warnings.length) {
console.log('')
console.log(chalk.yellow('To use this template, you must update following to modules:'))
console.log()
for (let i = 0; i < warnings.length; i++) {
const warning = warnings[i]
console.log(' ' + warning)
}
console.log()
process.exit(1)
}
}
'use strict'
const path = require('path')
const config = require('../config')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const packageConfig = require('../package.json')
exports.assetsPath = function(_path) {
const assetsSubDirectory =
process.env.NODE_ENV === 'production'
? config.build.assetsSubDirectory
: config.dev.assetsSubDirectory
return path.posix.join(assetsSubDirectory, _path)
}
exports.cssLoaders = function(options) {
options = options || {}
const cssLoader = {
loader: 'css-loader',
options: {
sourceMap: options.sourceMap
}
}
const postcssLoader = {
loader: 'postcss-loader',
options: {
sourceMap: options.sourceMap
}
}
// generate loader string to be used with extract text plugin
function generateLoaders(loader, loaderOptions) {
const loaders = options.usePostCSS
? [cssLoader, postcssLoader]
: [cssLoader]
if (loader) {
loaders.push({
loader: loader + '-loader',
options: Object.assign({}, loaderOptions, {
sourceMap: options.sourceMap
})
})
}
// Extract CSS when that option is specified
// (which is the case during production build)
if (options.extract) {
return [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: '../../'
}
}
].concat(loaders)
} else {
return ['vue-style-loader'].concat(loaders)
}
}
// https://vue-loader.vuejs.org/en/configurations/extract-css.html
return {
css: generateLoaders(),
postcss: generateLoaders(),
less: generateLoaders('less'),
sass: generateLoaders('sass', { indentedSyntax: true }),
scss: generateLoaders('sass'),
stylus: generateLoaders('stylus'),
styl: generateLoaders('stylus')
}
}
// Generate loaders for standalone style files (outside of .vue)
exports.styleLoaders = function(options) {
const output = []
const loaders = exports.cssLoaders(options)
for (const extension in loaders) {
const loader = loaders[extension]
output.push({
test: new RegExp('\\.' + extension + '$'),
use: loader
})
}
return output
}
exports.createNotifierCallback = () => {
const notifier = require('node-notifier')
return (severity, errors) => {
if (severity !== 'error') return
const error = errors[0]
const filename = error.file && error.file.split('!').pop()
notifier.notify({
title: packageConfig.name,
message: severity + ': ' + error.name,
subtitle: filename || '',
icon: path.join(__dirname, 'logo.png')
})
}
}
'use strict'
const path = require('path')
const utils = require('./utils')
const config = require('../config')
const vueLoaderConfig = require('./vue-loader.conf')
function resolve (dir) {
return path.join(__dirname, '..', dir)
}
const createLintingRule = () => ({
test: /\.(js|vue)$/,
loader: 'eslint-loader',
enforce: 'pre',
include: [resolve('src'), resolve('test')],
options: {
formatter: require('eslint-friendly-formatter'),
emitWarning: !config.dev.showEslintErrorsInOverlay
}
})
module.exports = {
context: path.resolve(__dirname, '../'),
entry: {
app: './src/main.js'
},
output: {
path: config.build.assetsRoot,
filename: '[name].js',
publicPath: process.env.NODE_ENV === 'production'
? config.build.assetsPublicPath
: config.dev.assetsPublicPath
},
resolve: {
extensions: ['.js', '.vue', '.json'],
alias: {
'vue$': 'vue/dist/vue.esm.js',
'@': resolve('src'),
}
},
module: {
rules: [
...(config.dev.useEslint ? [createLintingRule()] : []),
{
test: /\.vue$/,
loader: 'vue-loader',
options: vueLoaderConfig
},
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
},
{
test: /\.svg$/,
loader: 'svg-sprite-loader',
include: [resolve('src/icons')],
options: {
symbolId: 'icon-[name]'
}
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
exclude: [resolve('src/icons')],
options: {
limit: 10000,
name: utils.assetsPath('img/[name].[hash:7].[ext]')
}
},
{
test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('media/[name].[hash:7].[ext]')
}
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 10000,
name: utils.assetsPath('fonts/[name].[hash:7].[ext]')
}
}
]
},
node: {
// prevent webpack from injecting useless setImmediate polyfill because Vue
// source contains it (although only uses it if it's native).
setImmediate: false,
// prevent webpack from injecting mocks to Node native modules
// that does not make sense for the client
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
child_process: 'empty'
}
}
'use strict'
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const path = require('path')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin')
const portfinder = require('portfinder')
const { VueLoaderPlugin } = require('vue-loader')
function resolve(dir) {
return path.join(__dirname, '..', dir)
}
const HOST = process.env.HOST
const PORT = process.env.PORT && Number(process.env.PORT)
const devWebpackConfig = merge(baseWebpackConfig, {
mode: 'development',
module: {
rules: utils.styleLoaders({
sourceMap: config.dev.cssSourceMap,
usePostCSS: true
})
},
// cheap-module-eval-source-map is faster for development
devtool: config.dev.devtool,
// these devServer options should be customized in /config/index.js
devServer: {
clientLogLevel: 'warning',
historyApiFallback: {
rewrites: [
{
from: /.*/,
to: path.posix.join(config.dev.assetsPublicPath, 'index.html')
}
]
},
hot: true,
contentBase: false, // since we use CopyWebpackPlugin.
compress: true,
host: HOST || config.dev.host,
port: PORT || config.dev.port,
open: config.dev.autoOpenBrowser,
overlay: config.dev.errorOverlay
? { warnings: false, errors: true }
: false,
publicPath: config.dev.assetsPublicPath,
proxy: config.dev.proxyTable,
quiet: true, // necessary for FriendlyErrorsPlugin
watchOptions: {
poll: config.dev.poll
}
},
plugins: [
new webpack.DefinePlugin({
'process.env': require('../config/dev.env')
}),
new VueLoaderPlugin(),
new webpack.HotModuleReplacementPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'index.html',
inject: true,
favicon: resolve('favicon.png'),
title: 'sharding-ui'
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.dev.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
module.exports = new Promise((resolve, reject) => {
portfinder.basePort = process.env.PORT || config.dev.port
portfinder.getPort((err, port) => {
if (err) {
reject(err)
} else {
// publish the new Port, necessary for e2e tests
process.env.PORT = port
// add port to devServer config
devWebpackConfig.devServer.port = port
// Add FriendlyErrorsPlugin
devWebpackConfig.plugins.push(
new FriendlyErrorsPlugin({
compilationSuccessInfo: {
messages: [
`Your application is running here: http://${
devWebpackConfig.devServer.host
}:${port}`
]
},
onErrors: config.dev.notifyOnErrors
? utils.createNotifierCallback()
: undefined
})
)
resolve(devWebpackConfig)
}
})
})
'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const OptimizeCSSPlugin = require('optimize-css-assets-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader')
function resolve(dir) {
return path.join(__dirname, '..', dir)
}
const env = require('../config/prod.env')
const webpackConfig = merge(baseWebpackConfig, {
mode: 'production',
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: true,
usePostCSS: true
})
},
devtool: config.build.productionSourceMap ? config.build.devtool : false,
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash].js'),
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
},
optimization: {
providedExports: true,
usedExports: true, // tree shaking
sideEffects: true,
concatenateModules: true,
noEmitOnErrors: true,
splitChunks: {
chunks: 'all',
minSize: 30000,
maxSize: 0,
minChunks: 1,
maxAsyncRequests: 5,
maxInitialRequests: 3,
automaticNameDelimiter: '~',
name: true,
cacheGroups: {
vendors: {
test: /[\\/]node_modules[\\/]/,
priority: -10
},
default: {
priority: -20,
reuseExistingChunk: true
}
}
},
runtimeChunk: {
name: 'manifest'
}
},
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
new VueLoaderPlugin(),
new MiniCssExtractPlugin({
filename: utils.assetsPath('css/[name].[contenthash].css')
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
new OptimizeCSSPlugin({
cssProcessorOptions: config.build.productionSourceMap
? { safe: true, map: { inline: false }}
: { safe: true }
}),
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
// see https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: config.build.index,
template: 'index.html',
inject: true,
favicon: resolve('favicon.png'),
title: 'sharding-ui',
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency'
}),
// keep module.id stable when vendor modules does not change
new webpack.HashedModuleIdsPlugin(),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
if (config.build.productionGzip) {
const CompressionWebpackPlugin = require('compression-webpack-plugin')
webpackConfig.plugins.push(
new CompressionWebpackPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\\.(' + config.build.productionGzipExtensions.join('|') + ')$'
),
threshold: 10240,
minRatio: 0.8
})
)
}
if (config.build.bundleAnalyzerReport) {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer')
.BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}
module.exports = webpackConfig
'use strict'
const merge = require('webpack-merge')
const prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: process.env.NODE_ENV !== 'mock' ? '"development"' : '"mock"'
})
'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.
const path = require('path')
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {
'/api': {
target: 'http://localhost:8088',
changeOrigin: true,
pathRewrite: {
'^/api': '/api'
}
}
},
// Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false,
errorOverlay: true,
notifyOnErrors: true,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
// Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: true,
// If true, eslint errors and warnings will also be shown in the error overlay
// in the browser.
showEslintErrorsInOverlay: false,
/**
* Source Maps
*/
// https://webpack.js.org/configuration/devtool/#development
devtool: 'cheap-module-eval-source-map',
// If you have problems debugging vue-files in devtools,
// set this to false - it *may* help
// https://vue-loader.vuejs.org/en/options.html#cachebusting
cacheBusting: true,
cssSourceMap: false
},
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/',
/**
* Source Maps
*/
productionSourceMap: true,
// https://webpack.js.org/configuration/devtool/#production
devtool: '#source-map',
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
}
}
'use strict'
module.exports = {
NODE_ENV: '"production"'
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>sharding-ui</title>
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
{
"name": "sharding-ui-frontend",
"version": "1.0.0",
"description": "A Vue.js project",
"author": "ShardingSphere",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"start": "npm run dev",
"lint": "eslint --ext .js,.vue src",
"test": "cross-env NODE_ENV=mock webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
"build": "node build/build.js"
},
"dependencies": {
"axios": "^0.18.0",
"element-ui": "^2.4.9",
"js-yaml": "^3.12.0",
"jsonp": "^0.2.1",
"lodash": "^4.17.11",
"normalize.css": "^8.0.1",
"qs": "^6.6.0",
"vue": "^2.5.2",
"vue-i18n": "^8.4.0",
"vue-router": "^3.0.1",
"vuex": "^3.0.1"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-eslint": "^8.2.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.1",
"babel-plugin-dynamic-import-webpack": "^1.1.0",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.7.0",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-2": "^6.22.0",
"chalk": "^2.0.1",
"copy-webpack-plugin": "^5.0.3",
"cross-env": "^5.2.0",
"css-loader": "^2.1.1",
"eslint": "^4.15.0",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^2.1.2",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-node": "^5.2.0",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"eslint-plugin-vue": "^4.0.0",
"file-loader": "^3.0.1",
"friendly-errors-webpack-plugin": "^1.7.0",
"html-webpack-plugin": "^3.2.0",
"mini-css-extract-plugin": "^0.6.0",
"node-notifier": "^5.1.2",
"node-sass": "^4.10.0",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"postcss-import": "^11.0.0",
"postcss-loader": "^2.0.8",
"postcss-url": "^7.2.1",
"rimraf": "^2.6.0",
"sass-loader": "^7.1.0",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"svg-sprite-loader": "^4.1.3",
"url-loader": "^1.1.2",
"vue-loader": "^15.7.0",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"webpack": "^4.31.0",
"webpack-bundle-analyzer": "^2.9.0",
"webpack-cli": "^3.3.2",
"webpack-dev-server": "^3.4.1",
"webpack-merge": "^4.1.0"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-ui</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>sharding-ui-frontend</artifactId>
<name>${project.artifactId}</name>
<properties>
<node.version>v6.10.0</node.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.github.eirslett</groupId>
<artifactId>frontend-maven-plugin</artifactId>
<executions>
<execution>
<id>install node and npm</id>
<goals>
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>${node.version}</nodeVersion>
</configuration>
</execution>
<execution>
<id>npm install</id>
<goals>
<goal>npm</goal>
</goals>
<phase>generate-resources</phase>
<configuration>
<arguments>install</arguments>
</configuration>
</execution>
<execution>
<id>npm run build</id>
<goals>
<goal>npm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<template>
<div id="app">
<s-container v-if="localStorage.getItem('Access-Token')">
<el-breadcrumb separator="/" class="bread-wrap">
<el-breadcrumb-item :to="{ path: '/' }">Home</el-breadcrumb-item>
<el-breadcrumb-item>Data governance</el-breadcrumb-item>
<el-breadcrumb-item>{{ name }}</el-breadcrumb-item>
</el-breadcrumb>
<router-view/>
</s-container>
<template v-else>
<router-view/>
</template>
</div>
</template>
<script>
import SContainer from '@/components/Container/index.vue'
export default {
name: 'App',
components: {
SContainer
},
data() {
return {
name: '',
localStorage: window.localStorage
}
},
watch: {
$route(to, from) {
this.name = to.name
}
}
}
</script>
<style lang="scss" scoped>
.bread-wrap {
margin-bottom: 15px;
}
</style>
@font-face {font-family: "iconfont";
src: url('iconfont.eot?t=1546841685227'); /* IE9 */
src: url('iconfont.eot?t=1546841685227#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAb4AAsAAAAADDwAAAapAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCDSAqLMIllATYCJAMYCw4ABCAFhG0HVRuYCqOiflFOELJ/Jth08hYKo+mWRcxCM1nMh3rqW6X088bfKvXoCLdsJhtykJwYcmZW4cSQ1qmYk9ZJ38+sph55ced0mte10ESVTiodc6IJX/I7Z8dZji6XzsFwEZmAtICVNgECNAjydo/JScqSUGxCteldVwysy/pkBw/9e5E9KYF5iSEtJJARDvVXepzC3JiVfeH5AAGwgg2oaVsHx9CMZukQbYazCppzdnQLE6lNTM2+BfCAijptod4B4JXw7/HDWGoAiiqDtW1D3wxg5ZHP+8mD0w6jfAQo5vMCgHAQAAGQCIAGuGr9i9XF2sRQz9atXM8IwJUahZ6rFfrP+z9Xn/c7neTUVhi52v/yAFRoiKAAVoDelcXWFFTgc+LKNYMeVqBhiIAVEIZx0EE/Qz/6AQUAgJlxnTCAF4DaYFESbUtxQdC8bs/wYJg0p2OSV0e0qy8GahBj1GrGtWrUWJnpAkWxyrJFFE2SZPa1XF4aszhZni8t/wRZntLdp7PsdkSCqcMeh+bWUzHtuzo7fM/K8Rbd/sP8kQS99cAF4Vyc1qzdJyW27NzdpbcMb7XvdejGt/EHBC1avyOzfY8WTUFtXXqc1NGrNXO7hBi0dvPxlrbTkS27u7r1F6Q4875D9oOxpr1nHeejdZb9ckr7nl2dvmjOadmpQ2twa3qtBWC/KIqsQ0Ze4YRTt84dAnaWdSDysq8REZU4QeE7tHOc0DrCIVoEu0QQFAIvZybZRdER9OQVRZCkFa54vqy9VWjHG9Ce7HlDwO7ca6A690V57DkQQLr2D7P7urfpSLveo1Vrq463dmrBjGB7NzbForkVL65PKkYdDla04iYAabmf2tyun89J5pN3fa/LI1vvZYkmVlFmsbLlzAP9JcnEojJYsuCuZ0mdfjctIA/qDzjywgysYr1l4kCslM2w+3lyV/AdM0o2qeoxHHxqQU403bZ6LyGWtt3PVka23M2Uy29J46+aTt/XXVFGtT/Ikcpuy+NuWE/d014UhZqKqIb10EQt37FjOdFQvAQWaCpJapZ9Jfnot1RvPjn46acHGQ3hJfDkU73lSpKI49euHQ8NstNwfFoBf/7Mm94L3z8kJQSbmn5KQeD596oMOyefXrwr1MjdX7PGCwOSWMSmRjiW/Kqn5xq71wXWSI2YMmOycUK402aDl2EzOJdyO8Iz+ybbJvjbpF6qWgYz103r5dciz4Dm5lG8UMnzGJCswVqZpg0x7Qc55ZknVcOEX/hNto3wt1m9lFkK8JZfcZBQZqjkwhb19C1e2NW10PfTw1/8ebFGU+kcM9bPGBDXMHFqs3XqnMaYen9DLF1JKt1l3npi3JRvs+VvaoEkkCQjW+QOM2ctWXTv3qLvWQlr/j5eDkZ/ekeswfrp0+s9DfIS3I/7Xvs9R03auHES9aMlvLIywpJakzXX6bLOxTm3MFzB67yqobCUXkeXMivEGG0PGbfbpyezg34oO/H2Fx7MQxtClueI2pwWaILh5QOrVveVWZHS4DDsLV+5srwXrIwKrOX9q1cNlJ/cVv7/5i0f+17E8T5N7178ypa0yNT89cV3fRpw3AWqLGnhH6eDiM2n8dvq55mTuPCDst6eWhS86zqnnT2TU/vwiHHuqbODMP/Vd2pi/JWebhxBqoTa2939NR1uW98x/czemJp3Xs2bc/LMYMx79UFtToDS34ujfOqFJQMzH2+x7e8L7/o0GV97M3t60Njf60ZmT6r6PVp5es6b5pGTTT60vBk9va9SA5+kjf/Aittxc9Qk3AAAcL5BvsmskP8n2Uya+ffIGTLN/5wMq+stXiNXyDJlXA8+Onro2ViPhd+auf9z1pvDPU6YmPMNGuaR0ygD9FZQPUXPYbSusrSMMSa48l5CRgevLAWAtacBULiwt9+5jNreCrpt1KYAxUUQQKhFImlsIqDCyUww1M7ZDMBKsI2DOT5YHSwaAIj3SgDk6Q2guLsCEJ4+kDT2B1DR+QMYnhGAZYnOY3Kim9a6zqSEAqxeotM+M45LWqO2h2TLRHFWFfJOiQuXwtGhkWJpmzLiOXYozuyYiEHDPsUtcjFKEo85+4i0DIUi+dzwsKm7wZD2KbSqwIgiSABVXfrijuZlzMyitdT6Q8QqJRRuGVITP0VYwS0djRoy0gO5rc96DbmXzoUz1hhhvAa6vZmXQluMlyR23kN5/VoRookh4Yhsbs4wM5rpqx9a35h+5UUAsKzrM0EhQRpVyKALMNNnNizrE5fFLdrnl+yyu0t96lLVHJT+srxUGQAAAAA=') format('woff2'),
url('iconfont.woff?t=1546841685227') format('woff'),
url('iconfont.ttf?t=1546841685227') format('truetype'), /* chrome, firefox, opera, Safari, Android, iOS 4.2+ */
url('iconfont.svg?t=1546841685227#iconfont') format('svg'); /* iOS 4.1- */
}
.iconfont {
font-family: "iconfont" !important;
font-size: 12px;
font-style: normal;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-yonghu:before {
content: "\e623";
}
.icon-link:before {
content: "\e69f";
}
.icon-copyright:before {
content: "\e661";
}
.icon-mima:before {
content: "\e617";
}
.icon-duoyuyan:before {
content: "\e603";
}
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<!--
2013-9-30: Created.
-->
<svg>
<metadata>
Created by iconfont
</metadata>
<defs>
<font id="iconfont" horiz-adv-x="1024" >
<font-face
font-family="iconfont"
font-weight="500"
font-stretch="normal"
units-per-em="1024"
ascent="896"
descent="-128"
/>
<missing-glyph />
<glyph glyph-name="yonghu" unicode="&#58915;" d="M652.3 333.29999999999995C741.6 382.70000000000005 802 477.8 802 587c0 160.2-129.8 290-290 290-160.2 0-290-129.8-290-290 0-109.2 60.4-204.3 149.7-253.7C184 273.79999999999995 48 98.29999999999995 48-109l58 0c0 224.2 181.8 406 406 406 224.2 0 406-181.8 406-406l58 0C976 98.29999999999995 840 273.79999999999995 652.3 333.29999999999995zM280 587c0 128.1 103.9 232 232 232 128.1 0 232-103.9 232-232 0-128.1-103.9-232-232-232C383.9 355 280 458.9 280 587z" horiz-adv-x="1024" />
<glyph glyph-name="link" unicode="&#59039;" d="M504.96 499.328c5.952 11.36 7.872 23.968 5.952 36.352-2.144 11.744-7.264 23.104-16.672 32.48l-1.28 1.312-128.672 128.64-0.16 0 0 0.448-1.28 0.864c-10.912 10.656-25.856 16.032-40.832 16.032-15.2 0-30.336-5.824-41.888-16.896l0-0.448-82.112-82.496-0.416 0-0.832-1.088c-10.72-11.072-16.256-26.016-16.256-40.608 0-15.424 5.984-30.784 17.088-42.304l0 0.192 0.416-0.192 129.728-129.76c9.184-9.184 20.736-14.784 32.704-17.088 11.968-1.728 25.248 0 36.32 5.984 14.976 7.488 32.704 1.504 40.608-13.216 7.072-14.784 1.28-32.96-13.664-40.416-22.656-11.552-48.32-15.392-72.672-11.36-24.352 3.872-47.456 15.2-65.824 33.408l0 0 0 0-128.256 128.16-1.696 2.144c-23.52 23.136-35.04 53.664-35.04 84.448 0 29.728 11.104 59.648 33.344 82.688l1.696 1.76 0 0.448 82.496 82.048c23.104 23.104 53.888 35.04 84.224 35.04 29.888 0 59.84-11.52 82.912-33.504l1.696-1.536 0.448 0 128.256-128.672 1.28-1.728c18.816-18.176 29.92-41.472 33.76-65.408 3.648-24.576 0-50.176-11.52-73.056-7.232-14.528-25.664-20.928-40.192-13.056-14.976 7.264-20.96 25.408-13.664 40.384l0 0zM404.896 533.504l256.48-256.896c12-11.296 12-30.752 0-42.08-11.52-11.744-30.784-11.744-42.304 0l-256.704 256.448c-11.744 11.328-11.744 30.784 0 42.496 11.776 11.968 30.784 11.968 42.528 0l0 0 0 0zM404.896 742.368l-40.8-1.536c11.328 11.104 28.832 11.776 40.8 1.536l0 0 0 0zM153.6 656.576l1.696-40.992c-11.52 11.52-11.968 29.28-1.696 40.992l0 0 0 0zM519.04 268.928c-5.952-11.552-7.872-24.384-5.952-36.832 2.144-11.936 7.648-23.264 16.672-32.448l1.696-1.536 128.448-128.64 1.12-0.64c11.52-10.656 26.08-16.288 40.832-16.288 15.168 0 30.592 5.984 42.048 16.928l-0.16 0 0.16 0.224 82.144 82.24 0.384 0 1.312 1.312c10.688 10.88 15.808 25.856 15.808 40.832 0 15.136-5.536 30.56-17.12 41.888l0 0-0.384 0-1.312 1.76-128.48 128.608-0.192 0c-9.184 8.992-20.704 14.592-32.064 16.48-12.608 1.92-25.216 0-36.736-5.568-14.528-7.904-32.896-1.472-40.608 13.024-7.264 14.592-1.28 33.152 13.472 40.256 22.816 11.936 48.48 15.328 72.832 11.52 24.352-3.68 47.488-14.944 65.856-33.408l0-0.16 128.256-128.256 1.696-1.504c23.296-23.488 35.04-54.048 35.04-84.608 0-29.92-11.328-59.84-33.344-82.912l-1.696-1.312 0-0.416-82.08-82.048-0.416 0c-23.328-23.776-53.824-35.296-84.416-35.296-29.952 0-59.616 11.168-82.944 33.12l-1.504 2.176-128.64 128.608-1.504 1.12c-18.176 18.56-29.28 41.44-33.152 65.6-4.256 24.832-0.416 50.432 10.88 73.088 7.936 14.752 25.664 20.704 40.832 13.248 14.528-7.488 20.544-25.216 13.248-40.16l0 0 0 0zM618.88 25.248l40.992 2.176c-11.296-11.584-29.056-12.416-40.992-2.176l0 0 0 0zM870.432 111.2l-1.696 40.768c11.52-11.072 11.744-29.248 1.696-40.768l0 0 0 0z" horiz-adv-x="1024" />
<glyph glyph-name="copyright" unicode="&#58977;" d="M730.285714 282.285714v-62.285714q0-28.571429-20.857143-50.857143t-53.714285-34.571428-67.428572-18.571429-67.142857-6.285714q-117.142857 0-195.714286 79.428571T246.857143 386.857143q0 116 77.714286 193.714286t193.714285 77.714285q19.428571 0 43.142857-2.571428t53.142858-10.285715 52.857142-19.428571 39.428572-32.285714 16-46.285715v-62.285714q0-9.142857-9.142857-9.142857h-67.428572q-9.142857 0-9.142857 9.142857v40q0 24.571429-37.428571 38.571429T521.142857 577.714286q-80 0-130.571428-52.285715T340 389.714286q0-86.285714 52.285714-142.571429T525.714286 190.857143q38.857143 0 78.857143 13.714286t40 37.714285v40q0 4 2.571428 6.571429t6 2.571428h68q3.428571 0 6.285714-2.571428t2.857143-6.571429zM512 749.714286q-74.285714 0-142-29.142857t-116.571429-78-78-116.571429T146.285714 384t29.142857-142 78-116.571429 116.571429-78 142-29.142857 142 29.142857 116.571429 78 78 116.571429 29.142857 142-29.142857 142-78 116.571429-116.571429 78T512 749.714286z m438.857143-365.714286q0-119.428571-58.857143-220.285714T732.285714 4 512-54.857143t-220.285714 58.857143T132 163.714286 73.142857 384t58.857143 220.285714T291.714286 764 512 822.857143t220.285714-58.857143T892 604.285714 950.857143 384z" horiz-adv-x="1024" />
<glyph glyph-name="mima" unicode="&#58903;" d="M799 474.6H331.3v76.3c0 104 84.7 188.7 188.8 188.7s188.8-84.8 188.8-188.9c0-14.1 11.4-25.5 25.5-25.5s25.5 11.4 25.5 25.5c0 132.3-107.6 239.9-239.8 239.9-64.1 0-124.3-24.9-169.6-70.2-45.3-45.3-70.2-105.4-70.2-169.5v-76.3h-53.7c-31.3 0-56.3-25-56.3-56.2v-387c0-31.3 25.1-57.1 56.3-57.1h572.3c31.3 0 57 25.8 57 57.1v387c0.1 31.2-25.6 56.2-56.9 56.2z m6-443.8c0-3.1-2.5-5.7-5.7-5.7H226.9c-3.1 0-5.7 2.5-5.7 5.7V417.9c0 3.1 2.5 5.7 5.7 5.7h572.3c3.1 0 5.7-2.5 5.7-5.7v-387.1h0.1zM508.5 342.5c-28.8 0-52.1-23.3-52.1-52.1 0-19 10.2-35.7 25.5-44.8v-101.1c0-14 11.5-25.5 25.5-25.5s25.5 11.5 25.5 25.5v99.8c16.6 8.7 27.8 26.1 27.8 46.1-0.1 28.8-23.4 52.1-52.2 52.1z m0 0" horiz-adv-x="1024" />
<glyph glyph-name="duoyuyan" unicode="&#58883;" d="M848.806 90.428c70.998 81.26 109.78 184.217 109.78 293.144 0 119.205-46.422 231.278-130.714 315.57C744.877 782.137 634.941 828.383 517.79 829.786c-1.925 0.6-10.29 0.592-12.228-0.015-116.682-1.717-226.127-47.931-308.826-130.63C113.863 616.268 67.63 506.54 66.095 389.583c-0.428-1.65-0.437-8.602-0.021-10.227 1.083-117.628 47.365-228.058 130.66-311.354 84.292-84.292 196.364-130.713 315.57-130.713 119.205 0 231.277 46.421 315.57 130.713 6.139 6.14 12.054 12.444 17.788 18.872a20.532 20.532 0 0 1 1.472 1.44 20.566 20.566 0 0 1 1.672 2.113zM107.447 363.957H294.95c1.322-65.68 9.253-127.265 22.505-182.113-61.69-16.687-100.82-38.372-121.076-51.906-52.068 64.726-84.702 145.705-88.93 234.019z m88.434 272.635c20.09-13.557 59.243-35.462 121.34-52.26-12.997-54.128-20.826-114.778-22.243-179.433H107.526c4.55 87.37 36.912 167.489 88.355 231.693z m721.2-231.692H729.63c-1.416 64.631-9.24 125.26-22.23 179.374 61.955 16.694 101.236 38.445 121.567 52.021 51.305-64.155 83.571-144.161 88.116-231.395z m-228.403 0h-156.51V560.939c52.208 1.095 97.103 6.454 135.272 14.033C680 522.836 687.286 465.103 688.678 404.9z m-156.51 196.984V786.082c36.84-10.4 72.779-49.206 100.926-110.016 8.81-19.036 16.645-39.642 23.464-61.521-35.026-6.772-76.296-11.608-124.39-12.66z m-40.944 183.842v-183.805c-47.505 1.127-88.379 6.002-123.12 12.803 6.807 21.813 14.623 42.36 23.409 61.344 27.839 60.14 63.296 98.756 99.71 109.658z m0-224.767V404.9H335.929c1.392 60.213 8.68 117.955 21.244 170.1 37.835-7.537 82.314-12.887 134.05-14.04z m-155.33-197.002h155.33v-158.668c-51.61-1.194-96.02-6.564-133.822-14.103-12.825 52.886-20.208 111.57-21.509 172.77z m155.33-199.63v-182.909c-36.416 10.902-71.872 49.519-99.71 109.66-8.68 18.752-16.41 39.034-23.158 60.55 34.64 6.727 75.417 11.552 122.868 12.7z m40.943-183.264V164.391c47.904-1.025 89.104-5.862 124.117-12.656-6.756-21.556-14.497-41.874-23.19-60.656-28.147-60.81-64.086-99.617-100.927-110.016z m0 224.277V363.957h156.547c-1.299-61.097-8.66-119.685-21.446-172.503-38.114 7.532-82.949 12.835-135.1 13.886zM729.66 363.957h187.502c-4.221-88.139-36.733-168.974-88.62-233.636-20.47 13.669-59.636 35.3-121.304 51.869 13.2 54.76 21.102 116.225 22.422 181.767z m71.86 303.3c-18.33-11.57-52.31-29.355-104.858-43.493-19.296 63.056-46.11 115.004-78.062 150.976 70.401-19.15 133.234-56.837 182.92-107.483zM406.008 774.74c-31.906-35.92-58.69-87.769-77.979-150.702-52.404 14.241-86.37 32.099-104.582 43.588 49.63 50.46 112.33 88.01 182.561 107.114z m-182.09-675.703c18.284 11.536 52.098 29.23 104.332 43.336 19.272-62.605 45.976-114.187 77.758-149.969C336 11.45 273.472 48.818 223.918 99.037z m394.68-106.633c31.802 35.804 58.519 87.426 77.794 150.082 51.985-14.023 85.972-31.631 104.533-43.208-49.592-50.34-112.206-87.8-182.326-106.874z" horiz-adv-x="1024" />
</font>
</defs></svg>
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册