Skip to content

Commit

Permalink
Merge branch 'main' into feat_ldap
Browse files Browse the repository at this point in the history
  • Loading branch information
G-XD committed Aug 16, 2023
2 parents 1412f40 + 190b1ea commit 05d200a
Show file tree
Hide file tree
Showing 59 changed files with 1,400 additions and 308 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Apache Paimon (incubating) Manager
# Apache Paimon (incubating) Web UI

This repository is web ui for the [Apache Paimon](https://paimon.apache.org/) project.

Expand Down
1 change: 1 addition & 0 deletions paimon-web-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ under the License.
<artifactId>paimon-web-common</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
Expand Down
17 changes: 17 additions & 0 deletions paimon-web-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,23 @@ under the License.
Paimon Web Server is a server for the [Apache Paimon](https://paimon.apache.org/) project.
</description>

<properties>
<hadoop.version>2.8.5</hadoop.version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.paimon</groupId>
<artifactId>paimon-web-common</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.paimon</groupId>
<artifactId>paimon-web-api</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
Expand Down Expand Up @@ -146,6 +156,13 @@ under the License.
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-client</artifactId>
<version>${hadoop.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.paimon.web.server.configrue;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;

/** CorsConfig. */
@Slf4j
// @Configuration
public class CorsConfig {

@Bean
public CorsFilter corsFilter() {
CorsConfiguration corsConfiguration = new CorsConfiguration();
corsConfiguration.setAllowCredentials(true);
corsConfiguration.addAllowedHeader("*");
corsConfiguration.addAllowedMethod("*");
corsConfiguration.addExposedHeader("*");
corsConfiguration.addAllowedOrigin("http://127.0.0.1:5173");
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", corsConfiguration);
return new CorsFilter(source);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.apache.paimon.web.server.configrue;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;

import java.text.SimpleDateFormat;

/** JacksonConfig. */
@Configuration
public class JacksonConfig {
@Bean
public ObjectMapper getJacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
// When the sequence is changed to json, all longs will be changed to strings.
// Because the numeric type in js cannot contain all java long values, precision will be
// lost after more than 16 digits.
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(
Long.class, com.fasterxml.jackson.databind.ser.std.ToStringSerializer.instance);
simpleModule.addSerializer(
Long.TYPE, com.fasterxml.jackson.databind.ser.std.ToStringSerializer.instance);
objectMapper.registerModule(simpleModule);
// If there are more attributes during deserialization, no exception will be thrown.
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// Date format handling.
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
return objectMapper;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@

import cn.dev33.satoken.interceptor.SaInterceptor;
import cn.dev33.satoken.stp.StpUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/** Sa-Token path config. */
@Configuration
// @Configuration
public class SaTokenConfigure implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new SaInterceptor(handle -> StpUtil.checkLogin()))
.addPathPatterns("/**")
.excludePathPatterns("/api/login");
.excludePathPatterns("/***");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.paimon.web.server.controller;

import org.apache.paimon.web.api.catalog.CatalogCreator;
import org.apache.paimon.web.server.data.model.CatalogInfo;
import org.apache.paimon.web.server.data.result.R;
import org.apache.paimon.web.server.data.result.enums.Status;
import org.apache.paimon.web.server.service.CatalogService;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/** Catalog api controller. */
@Slf4j
@RestController
@RequestMapping("/api/catalog")
public class CatalogController {

@Autowired private CatalogService catalogService;

/**
* Create a filesystem catalog.
*
* @param catalogInfo The catalogInfo for the filesystem catalog.
* @return The created catalog.
*/
@PostMapping("/createFilesystemCatalog")
public R<Void> createFilesystemCatalog(@RequestBody CatalogInfo catalogInfo) {
if (!catalogService.checkCatalogNameUnique(catalogInfo)) {
return R.failed(Status.CATALOG_NAME_IS_EXIST, catalogInfo.getCatalogName());
}

try {
CatalogCreator.createFilesystemCatalog(catalogInfo.getWarehouse());
return catalogService.save(catalogInfo) ? R.succeed() : R.failed();
} catch (Exception e) {
e.printStackTrace();
return R.failed(Status.CATALOG_CREATE_ERROR);
}
}

/**
* Create a hive catalog.
*
* @param catalogInfo The information for the hive catalog.
* @return The created catalog.
*/
@PostMapping("/createHiveCatalog")
public R<Void> createHiveCatalog(@RequestBody CatalogInfo catalogInfo) {
if (!catalogService.checkCatalogNameUnique(catalogInfo)) {
return R.failed(Status.CATALOG_NAME_IS_EXIST, catalogInfo.getCatalogName());
}

try {
CatalogCreator.createHiveCatalog(
catalogInfo.getWarehouse(),
catalogInfo.getHiveUri(),
catalogInfo.getHiveConfDir());
return catalogService.save(catalogInfo) ? R.succeed() : R.failed();
} catch (Exception e) {
e.printStackTrace();
return R.failed(Status.CATALOG_CREATE_ERROR);
}
}

/**
* Get all catalog information.
*
* @return The list of all catalogs.
*/
@GetMapping("/getAllCatalogs")
public R<List<CatalogInfo>> getCatalog() {
List<CatalogInfo> catalogs = catalogService.list();
return R.succeed(catalogs);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.paimon.web.server.data.model;

import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/** Catalog table model. */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@TableName("catalog")
public class CatalogInfo extends BaseModel {

private String catalogType;

private String catalogName;

private String warehouse;

private String hiveUri;

private String hiveConfDir;

@TableLogic private boolean isDelete;
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public enum Status {
MENU_IN_USED(10201, "menu.in.used"),
MENU_NAME_IS_EXIST(10202, "menu.name.exist"),
MENU_PATH_INVALID(10203, "menu.path.invalid"),

/** ------------catalog-----------------. */
CATALOG_NAME_IS_EXIST(10301, "catalog.name.exist"),
CATALOG_CREATE_ERROR(10302, "catalog.create.error"),
;

private final int code;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.paimon.web.server.mapper;

import org.apache.paimon.web.server.data.model.CatalogInfo;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;

/** Catalog table mapper. */
@Mapper
public interface CatalogMapper extends BaseMapper<CatalogInfo> {}
Loading

0 comments on commit 05d200a

Please sign in to comment.