diff --git a/pom.xml b/pom.xml index 7356667da72b6ea7a4943a935ebb38724f049531..3d90dc0963ae087b532ae07620ca4f1830775613 100644 --- a/pom.xml +++ b/pom.xml @@ -5,6 +5,7 @@ 4.0.0 rest-api-metadata + rest-api-service diff --git a/rest-api-metadata/pom.xml b/rest-api-metadata/pom.xml index c7f82d5980f71d604425f45eeee965b0b750edf4..7e5c232c16772fb5e3acbe26868464ee090c1d6c 100644 --- a/rest-api-metadata/pom.xml +++ b/rest-api-metadata/pom.xml @@ -3,7 +3,7 @@ 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"> - cdp-sg + rest-api-model com.inspur.edp 0.2.0 diff --git a/rest-api-service/pom.xml b/rest-api-service/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..ed3317acb0a8947950aa8aa0eec2a3a9bcb113bf --- /dev/null +++ b/rest-api-service/pom.xml @@ -0,0 +1,103 @@ + + + + rest-api-model + com.inspur.edp + 0.2.0 + + 4.0.0 + + rest-api-service + + + + com.inspur.edp + rest-api-metadata + ${project.version} + + + com.inspur.edp + rest-api-spi + ${project.version} + + + com.inspur.edp + rest-api-utils + ${project.version} + compile + + + org.apache.commons + commons-lang3 + + + io.iec.edp + caf-boot-starter-context + + + + io.iec.edp + caf-runtime-framework-permission-api + 0.1.8 + + + + io.iec.edp + caf-boot-starter-caching + 1.0.0-rc.1 + + + + com.inspur.edp + cdp-common-utils + 0.2.0 + + + + io.iec.edp + caf-boot-starter-rpc + 1.0.0-rc.1 + + + + com.inspur.edp + lcm-metadata-spi + 0.1.27 + + + + com.inspur.edp + metadata-rtcustomization-spi + 0.1.19 + compile + + + + io.iec.edp + caf-boot-starter-rest + 1.0.0-rc.1 + + + + + + + + maven-jar-plugin + + + maven-source-plugin + + + attach-sources + + jar + + + + + + + \ No newline at end of file diff --git a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/cache/ConfigCacheResult.java b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/cache/ConfigCacheResult.java new file mode 100644 index 0000000000000000000000000000000000000000..c82f2d05f8d53bc45ca274fb6378a2bff399a10a --- /dev/null +++ b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/cache/ConfigCacheResult.java @@ -0,0 +1,57 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.core.cache; + + +import com.inspur.edp.sgf.core.common.EapiOpConfig; + +import java.util.UUID; + +/** + * 功能描述: + * + * @ClassName: ConfigCacheResult + * @Author: Fynn Qi + * @Date: 2020/12/18 17:49 + * @Version: V1.0 + */ +public class ConfigCacheResult { + + public ConfigCacheResult(){ + this.version= UUID.randomUUID().toString(); + } + + /** + * 缓存结果的版本 + */ + private String version; + + /** + * 配置信息 + */ + private EapiOpConfig config; + + public String getVersion() { + return version; + } + + public EapiOpConfig getConfig() { + return config; + } + + public void setConfig(EapiOpConfig config) { + this.config = config; + } +} diff --git a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/cache/EapiConfigCacheManager.java b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/cache/EapiConfigCacheManager.java new file mode 100644 index 0000000000000000000000000000000000000000..2419d280983c3658a1a4c47f000d396936eee737 --- /dev/null +++ b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/cache/EapiConfigCacheManager.java @@ -0,0 +1,151 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.core.cache; + +import io.iec.edp.caf.boot.context.CAFContext; +import io.iec.edp.caf.commons.layeringcache.cache.Cache; +import io.iec.edp.caf.commons.layeringcache.manager.CacheManager; +import io.iec.edp.caf.commons.layeringcache.serializer.DefaultJsonSerializer; +import io.iec.edp.caf.commons.layeringcache.setting.LayeringCacheSetting; +import io.iec.edp.caf.commons.layeringcache.support.ExpireMode; +import io.iec.edp.caf.commons.utils.SpringBeanUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.PostConstruct; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; + +/** + * 功能描述: + * + * @ClassName: EapiConfigCacheManager + * @Author: Fynn Qi + * @Date: 2020/12/18 17:44 + * @Version: V1.0 + */ +public class EapiConfigCacheManager { + + private final static String EAPI_CONFIG_CACHE_NAME = "EAPI_CONFIG_CACHE_"; + + private final String EAPI_GLOBAL_CONFIG_CACHE_NAME = "EAPI_GLOBAL_CONFIG_CACHE"; + + private final Logger log = LoggerFactory.getLogger(EapiConfigCacheManager.class); + + private final CacheManager cacheManager; + + //todo 假单例模式,后续更改此处 + public EapiConfigCacheManager(CacheManager cacheManager) { + this.cacheManager = cacheManager; + } + + private final Map eapiConfigCacheMap = new ConcurrentHashMap<>(); + + private final Object LOCK_OBJECT = new Object(); + + private static final class InstanceHolder { + static final EapiConfigCacheManager instance = SpringBeanUtils.getBean(EapiConfigCacheManager.class); + } + + public static EapiConfigCacheManager getInstance() { + return InstanceHolder.instance; + } + + @PostConstruct + private void initCacheManager() { +// eapiConfigCache = createEapiConfigCache(); + log.info("created external api config cache"); + } + + private Cache createEapiConfigCache(Integer tenantId) { + LayeringCacheSetting layeringCacheSetting = new LayeringCacheSetting.Builder() + //开启一级缓存 + .enableFirstCache() + //一级缓存过期策略 + .firstCacheExpireMode(ExpireMode.ACCESS) + //一级缓存过期时间 + .firstCacheExpireTime(10) + //一级缓存过期时间单位 + .firstCacheTimeUnit(TimeUnit.MINUTES) + .firstCacheInitialCapacity(50) + .firstCacheMaximumSize(1000) + //开启二级缓存 + .enableSecondCache() + //二级缓存过期时间 + .secondCacheExpireTime(1L) + //二级缓存过期时间单位 + .secondCacheTimeUnit(TimeUnit.HOURS) + .dataSerializer(new DefaultJsonSerializer()) + .depict("外部服务库配置缓存租户" + tenantId) + .build(); + log.info("create external api config cache,tenantId:" + tenantId); + Cache cache = cacheManager.getCache(EAPI_CONFIG_CACHE_NAME + tenantId, layeringCacheSetting); + //创建缓存时,将旧缓存清空,防止用户重启后数据库做了更改,但缓存是旧的,导致运行错误 + cache.clear(); + return cache; + } + + public void updateCache(String key, ConfigCacheResult configResult) { + getEapiConfigCache().put(key, configResult); + } + + public void removeCache(String key) { + getEapiConfigCache().evict(key); + } + + public void clear() { + getEapiConfigCache().clear(); + } + + public Cache getEapiConfigCache() { + Integer tenantId = CAFContext.current.getTenantId(); + if (eapiConfigCacheMap.get(tenantId) == null) { + synchronized (LOCK_OBJECT) { + if (eapiConfigCacheMap.get(tenantId) == null) { + Cache cache = this.createEapiConfigCache(tenantId); + eapiConfigCacheMap.put(tenantId, cache); + } + } + } + return eapiConfigCacheMap.get(tenantId); + } + + public void updateGlobalCache(GlobalConfigCacheResult configResult) { + getEapiConfigCache().put(EAPI_GLOBAL_CONFIG_CACHE_NAME, configResult); + } + + public void removeGlobalCache() { + getEapiConfigCache().evict(EAPI_GLOBAL_CONFIG_CACHE_NAME); + } + + public GlobalConfigCacheResult getGlobalCacheResult() { + if (getEapiConfigCache() == null) { + return null; + } + return getEapiConfigCache().get(EAPI_GLOBAL_CONFIG_CACHE_NAME, GlobalConfigCacheResult.class); + } + + public void removeCache(List keys) { + if (keys == null || keys.size() <= 0) { + return; + } + for (String key : keys) { + log.info("清理API权限缓存:{}", key); + removeCache(key); + } + } +} diff --git a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/cache/GlobalConfigCacheResult.java b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/cache/GlobalConfigCacheResult.java new file mode 100644 index 0000000000000000000000000000000000000000..70a3d0e308b45277d756e1892521813161246c15 --- /dev/null +++ b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/cache/GlobalConfigCacheResult.java @@ -0,0 +1,43 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.core.cache; + +/** + * 功能描述: + * + * @ClassName: GlobalConfigCacheResult + * @Author: Fynn Qi + * @Date: 2021/1/13 14:20 + * @Version: V1.0 + */ +public class GlobalConfigCacheResult { + + public GlobalConfigCacheResult(){ + this.enable=false; + } + + /** + * 是否启用配全局置信息 + */ + private Boolean enable; + + public Boolean getEnable() { + return enable; + } + + public void setEnable(Boolean enable) { + this.enable = enable; + } +} diff --git a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/cache/ResourceInvokerCache.java b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/cache/ResourceInvokerCache.java new file mode 100644 index 0000000000000000000000000000000000000000..a010df9a205e473d6a410121ed91cc0a70d9df74 --- /dev/null +++ b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/cache/ResourceInvokerCache.java @@ -0,0 +1,63 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.core.cache; + +import com.inspur.edp.sgf.spi.EapiResource; +import com.inspur.edp.sgf.spi.ResourceInvoker; +import io.iec.edp.caf.commons.utils.SpringBeanUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashMap; +import java.util.Map; +import java.util.Optional; + +/** + * 功能描述: @ClassName: ResourceInvokerCache @Author: Fynn Qi @Date: 2020/9/1 16:28 @Version: V1.0 + */ +public class ResourceInvokerCache { + + private static Map resourceMap = new HashMap<>(); + + public static ResourceInvokerCache getInstance() { + return Singleton.INSTANCE; + } + + public static class Singleton { + static ResourceInvokerCache INSTANCE = new ResourceInvokerCache(); + } + + private ResourceInvokerCache() { + initResourceMap(); + } + + private void initResourceMap() { + Map resMap = + SpringBeanUtils.getApplicationContext().getBeansOfType(ResourceInvoker.class); + resMap.values() + .forEach( + o -> { + EapiResource annotation = o.getClass().getDeclaredAnnotation(EapiResource.class); + Optional.ofNullable(annotation) + .map(EapiResource::resourceType) + .filter(StringUtils::isNotBlank) + .ifPresent( + resourceType -> resourceMap.put(resourceType, o)); + }); + } + + public ResourceInvoker getResourceInvoker(String resType) { + return resourceMap.get(resType); + } +} diff --git a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/common/EapiOpConfig.java b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/common/EapiOpConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..15031313df6a73f707cf2ef9d0538b570b82ecf9 --- /dev/null +++ b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/common/EapiOpConfig.java @@ -0,0 +1,134 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.core.common; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * 功能描述:Eapi操作配置 + * + * @ClassName: EapiOpConfig + * @Author: Fynn Qi + * @Date: 2020/12/11 17:13 + * @Version: V1.0 + */ +public class EapiOpConfig { + + public EapiOpConfig(){ + this.bizOpIdList=new ArrayList<>(); + this.bizOpIdMap=new HashMap<>(); + } + + private String serviceId; + + /** + * 统一资源定位符 + */ + private String uri; + + /** + * Http方法 + */ + private String httpMethod; + + /** + * 基路径 + */ + private String basePath; + + /** + * 子路径 + */ + private String template; + + /** + * 是否启用 + */ + private Boolean enable; + + /** + * 业务操作ID集合 + */ + private List bizOpIdList; + + private HashMap> bizOpIdMap; + + public String getServiceId() { + return serviceId; + } + + public void setServiceId(String serviceId) { + this.serviceId = serviceId; + } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + + public String getHttpMethod() { + return httpMethod; + } + + public void setHttpMethod(String httpMethod) { + this.httpMethod = httpMethod; + } + + public List getBizOpIdList() { + return bizOpIdList; + } + + public void setBizOpIdList(List bizOpIdList) { + this.bizOpIdList = bizOpIdList; + } + + public String getBasePath() { + return basePath; + } + + public void setBasePath(String basePath) { + this.basePath = basePath; + } + + public String getTemplate() { + return template; + } + + public void setTemplate(String template) { + this.template = template; + } + + public HashMap> getBizOpIdMap() { + return bizOpIdMap; + } + + public void setBizOpIdMap(HashMap> bizOpIdMap) { + this.bizOpIdMap = bizOpIdMap; + } + + public Boolean getEnable() { + return enable; + } + + public void setEnable(Boolean enable) { + this.enable = enable; + } + +} diff --git a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/config/EApiBeanConfig.java b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/config/EApiBeanConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..38925f8e8360da77a5ffc1a925cbf888aa1bea3b --- /dev/null +++ b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/config/EApiBeanConfig.java @@ -0,0 +1,71 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.core.config; + +import com.inspur.edp.sgf.api.service.EapiConfigService; +import com.inspur.edp.sgf.api.service.InvokeService; +import com.inspur.edp.sgf.core.cache.EapiConfigCacheManager; +import com.inspur.edp.sgf.core.interceptor.EapiConfigCxfInterceptor; +import com.inspur.edp.sgf.core.manager.EapiConfigManager; +import com.inspur.edp.sgf.core.service.EapiConfigServiceImpl; +import com.inspur.edp.sgf.core.service.InvokeServiceImpl; +import io.iec.edp.caf.commons.layeringcache.manager.CacheManager; +import io.iec.edp.caf.permission.api.manager.runtime.PermissionManager; +import io.iec.edp.caf.rpc.api.service.RpcClient; +import org.apache.cxf.Bus; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; + +/** + * 功能描述: @ClassName: BeanConfig @Author: Fynn Qi @Date: 2019/7/22 19:00 @Version: V1.0 + */ +@Configuration(value = "com.inspur.edp.sgf.core.config.EApiBeanConfig", proxyBeanMethods = false) +public class EApiBeanConfig { + + @Order() + @Bean("com.inspur.edp.sgf.core.config.EApiBeanConfig.EapiConfigCxfInterceptor") + public EapiConfigCxfInterceptor eapiAuthInterceptor(EapiConfigManager configManager, PermissionManager permissionManager) { + return new EapiConfigCxfInterceptor(configManager, permissionManager); + } + + @Order() + @Bean("com.inspur.edp.sgf.core.config.EApiBeanConfig.initEapiConfigBus") + public Boolean initEapiConfigBus(Bus bus, EapiConfigCxfInterceptor cxfInInterceptor) { + bus.getInInterceptors().add(cxfInInterceptor); + return true; + } + + @Bean("com.inspur.edp.sgf.core.manager.EapiConfigManager") + public EapiConfigManager eapiConfigManager(RpcClient rpcClient, EapiConfigCacheManager eapiConfigCacheManager) { + return new EapiConfigManager(rpcClient, eapiConfigCacheManager); + } + + @Bean("com.inspur.edp.sgf.core.service.EapiConfigServiceImpl") + public EapiConfigService configService(EapiConfigManager eapiConfigManager) { + return new EapiConfigServiceImpl(eapiConfigManager); + } + + @Bean("com.inspur.edp.sgf.core.config.EApiBeanConfig.EapiConfigCacheManager") + public EapiConfigCacheManager eapiConfigCacheManager(CacheManager cacheManager) { + return new EapiConfigCacheManager(cacheManager); + } + + @Bean("com.inspur.edp.sgf.core.config.EApiBeanConfig.InvokeService") + public InvokeService invokeService() { + return new InvokeServiceImpl(); + } + +} diff --git a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/constraint/MetadataRtRefConstraint.java b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/constraint/MetadataRtRefConstraint.java new file mode 100644 index 0000000000000000000000000000000000000000..f976fcde37f783b3b72800e6d775fcf58ababa19 --- /dev/null +++ b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/constraint/MetadataRtRefConstraint.java @@ -0,0 +1,67 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.core.constraint; + +import com.inspur.edp.lcm.metadata.api.entity.GspMetadata; +import com.inspur.edp.lcm.metadata.api.entity.MetadataReference; +import com.inspur.edp.metadata.rtcustomization.api.CustomizationService; +import com.inspur.edp.metadata.rtcustomization.spi.IMetadataRtReferenceManager; +import com.inspur.edp.sgf.api.entity.SgMetadata; +import io.iec.edp.caf.commons.utils.SpringBeanUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * 功能描述: @ClassName: MetadataRtRefConstraint @Author: Fynn Qi @Date: 2020/9/21 16:49 @Version: V1.0 + */ +public class MetadataRtRefConstraint implements IMetadataRtReferenceManager { + + private static final String EAPI_RESOURCE_TYPE_VO = "VO"; + + private static final String EAPI_RESOURCE_TYPE_VO_SIMPLE = "VO-Simple"; + + @Override + public List getConstraint(GspMetadata gspMetadata) { + if (gspMetadata == null) { + return new ArrayList<>(); + } + if (gspMetadata.getContent() == null + || ((SgMetadata) gspMetadata.getContent()).getService() == null + || StringUtils.isBlank( + ((SgMetadata) gspMetadata.getContent()).getService().getResourceId())) { + return gspMetadata.getRefs(); + } + SgMetadata eapi = (SgMetadata) gspMetadata.getContent(); + if (EAPI_RESOURCE_TYPE_VO.equals(eapi.getService().getResourceType()) + || EAPI_RESOURCE_TYPE_VO_SIMPLE.equals(eapi.getService().getResourceType())) { + MetadataReference reference = new MetadataReference(); + reference.setMetadata(gspMetadata.getHeader()); + GspMetadata voMetadata = + SpringBeanUtils.getBean(CustomizationService.class) + .getMetadata(eapi.getService().getResourceId()); + //todo 此处可能会引发空指针异常 + reference.setDependentMetadata(voMetadata.getHeader()); + if (gspMetadata.getRefs() == null) { + gspMetadata.setRefs(new ArrayList<>()); + } + gspMetadata.getRefs().add(reference); + return gspMetadata.getRefs(); + } else { + return gspMetadata.getRefs(); + } + } +} diff --git a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/exception/EapiAuthorizationException.java b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/exception/EapiAuthorizationException.java new file mode 100644 index 0000000000000000000000000000000000000000..36f3ebf5706859dba12005aad894d7c68554a6be --- /dev/null +++ b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/exception/EapiAuthorizationException.java @@ -0,0 +1,38 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.core.exception; + +import io.iec.edp.caf.rest.api.exception.ExceptionResponseStatus; + +import javax.ws.rs.core.Response; + +/** + * 功能描述: + * + * @ClassName: EapiAuthorizationException + * @Author: Fynn Qi + * @Date: 2020/12/19 15:48 + * @Version: V1.0 + */ +@ExceptionResponseStatus(Response.Status.FORBIDDEN) +public class EapiAuthorizationException extends RuntimeException { + + private static final long serialVersionUID = -2973906481071284994L; + + public EapiAuthorizationException(String message) { + super(message); + } + +} diff --git a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/exception/ShouldNotHappenedException.java b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/exception/ShouldNotHappenedException.java new file mode 100644 index 0000000000000000000000000000000000000000..f350e01ef085a432e6cb0c1ebc719b945eee3719 --- /dev/null +++ b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/exception/ShouldNotHappenedException.java @@ -0,0 +1,32 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.core.exception; + +/** + * 功能描述: + * + * @ClassName: ShouldNotHappenedException + * @Author: Fynn Qi + * @Date: 2020/12/21 14:33 + * @Version: V1.0 + */ +public class ShouldNotHappenedException extends RuntimeException{ + + private static final long serialVersionUID = -3116865067947337111L; + + public ShouldNotHappenedException(String message) { + super(message); + } +} diff --git a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/interceptor/EapiConfigCxfInterceptor.java b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/interceptor/EapiConfigCxfInterceptor.java new file mode 100644 index 0000000000000000000000000000000000000000..6b935a35432983456887629d8972717c46ea3921 --- /dev/null +++ b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/interceptor/EapiConfigCxfInterceptor.java @@ -0,0 +1,202 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.core.interceptor; + +import com.inspur.edp.sgf.api.utils.ObjectMapperUtil; +import com.inspur.edp.sgf.core.cache.ConfigCacheResult; +import com.inspur.edp.sgf.core.cache.GlobalConfigCacheResult; +import com.inspur.edp.sgf.core.common.EapiOpConfig; +import com.inspur.edp.sgf.core.exception.EapiAuthorizationException; +import com.inspur.edp.sgf.core.manager.EapiConfigManager; +import io.iec.edp.caf.boot.context.CAFContext; +import io.iec.edp.caf.permission.api.manager.runtime.PermissionManager; +import org.apache.commons.lang3.StringUtils; +import org.apache.cxf.interceptor.Fault; +import org.apache.cxf.jaxrs.model.OperationResourceInfo; +import org.apache.cxf.message.Exchange; +import org.apache.cxf.message.Message; +import org.apache.cxf.phase.AbstractPhaseInterceptor; +import org.apache.cxf.phase.Phase; +import org.apache.cxf.transport.http.AbstractHTTPDestination; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.Path; +import java.util.Map; + +/** + * 功能描述: + * + * @ClassName: EapiConfigCxfInterceptor + * @Author: Fynn Qi + * @Date: 2020/12/17 18:16 + * @Version: V1.0 + */ +public class EapiConfigCxfInterceptor extends AbstractPhaseInterceptor { + + private final Logger logger = LoggerFactory.getLogger(EapiConfigCxfInterceptor.class); + + private final String GSP_RPC = "gsp-rpc"; + + private final String GSP_CONTEXT = "gsp-context"; + + private final String STRING_TRUE = "true"; + + private EapiConfigManager configManager; + + private PermissionManager permissionManager; + + public EapiConfigCxfInterceptor(EapiConfigManager configManager, PermissionManager permissionManager) { + super(Phase.PRE_INVOKE); + this.configManager = configManager; + this.permissionManager = permissionManager; + } + + @Override + public void handleMessage(Message message) throws Fault { + + if (isRequestor(message)) { + return; + } + + //获取HttpServletRequest + HttpServletRequest request = (HttpServletRequest) message.get(AbstractHTTPDestination.HTTP_REQUEST); + + if (request == null) { + throw new RuntimeException("未获取到HttpServletRequest"); + } + + if (StringUtils.isNotBlank(request.getHeader(GSP_CONTEXT))) { + Map map = ObjectMapperUtil.deserialize(request.getHeader(GSP_CONTEXT), Map.class); + if (map != null && map.containsKey(GSP_RPC) && STRING_TRUE.equals(map.get(GSP_RPC))) { + return; + } + } + + if (CAFContext.current == null || CAFContext.current.getCurrentSession() == null || StringUtils.isBlank(CAFContext.current.getCurrentSession().getUserId())) { + return; + } + + //获取EApi配置 + GlobalConfigCacheResult globalConfigCacheResult = configManager.getEapiGlobalConfig(); + + //不启用则直接放行 + if (globalConfigCacheResult == null || globalConfigCacheResult.getEnable() == null || !globalConfigCacheResult.getEnable()) { + return; + } + + String requestUri = request.getRequestURI(); + + if (StringUtils.isBlank(requestUri) || !requestUri.startsWith("/api")) { + return; + } + + Exchange exchange = message.getExchange(); + + OperationResourceInfo operationResourceInfo = exchange.get(OperationResourceInfo.class); + if (operationResourceInfo == null) { + return; + } + + String uri = getUri(exchange, operationResourceInfo); + + //获取HTTP方法 + String httpMethod = request.getMethod(); + + //获取EApi配置 + ConfigCacheResult cacheResult = configManager.getEapiConfigs(uri, httpMethod); + + //如果不存在API配置信息 + if (cacheResult == null || cacheResult.getConfig() == null) { + return; + } + + EapiOpConfig config = cacheResult.getConfig(); + + //1. API操作不启用权限控制,直接放行 + //2. 不存在功能操作配置,直接放行,我们认为该API不受操作权限控制 + if (config.getEnable() == null || !config.getEnable() || config.getBizOpIdList() == null || config.getBizOpIdList().size() <= 0) { + return; + } + + //权限验证 + Map result = permissionManager.isPrincipalHasOps(config.getBizOpIdList()); + + //采用逻辑运算符 |(或)的验证关系 + if (result != null && result.values().size() > 0 && !result.values().contains(true)) { + throw new EapiAuthorizationException(String.format("API操作[%s]%s未授权", httpMethod.toUpperCase(), uri)); + } + } + + private String getUri(Exchange exchange, OperationResourceInfo operationResourceInfo) { + + //获取Endpoint的path + String baseRequestUri = exchange.getEndpoint().getEndpointInfo().getAddress(); + + //获取类上的URITemplate + String classUriTemplate = ""; + + if (operationResourceInfo.getClassResourceInfo() != null && operationResourceInfo.getClassResourceInfo().getURITemplate() != null) { + classUriTemplate = operationResourceInfo.getClassResourceInfo().getURITemplate().getValue(); + } + + //获取方法上的URITemplate + String methodUriTemplate = ""; + + if (operationResourceInfo.getAnnotatedMethod() != null) { + Path pathAnnotation = operationResourceInfo.getAnnotatedMethod().getAnnotation(Path.class); + if (pathAnnotation != null) { + methodUriTemplate = pathAnnotation.value(); + } + } + + //build完整的uri + return buildUri(baseRequestUri, classUriTemplate, methodUriTemplate); + } + + private String buildUri(String baseRequestUri, String classUriTemplate, String methodUriTemplate) { + + String uri = "/api"; + + //拼接baseURI + uri = appendUri(baseRequestUri, uri); + + //拼接类上的URITemplate + uri = appendUri(classUriTemplate, uri); + + //拼接方法上的URITemplate + uri = appendUri(methodUriTemplate, uri); + + return uri; + } + + private String appendUri(String subUriTemplate, String uri) { + if (StringUtils.isBlank(subUriTemplate)) { + return uri; + } + String[] segmentArray = subUriTemplate.split("/"); + if (segmentArray.length <= 0) { + return uri; + } + for (String segment : segmentArray) { + if (StringUtils.isNotBlank(segment)) { + uri = String.format("%s/%s", uri, segment); + } + } + return uri; + } + +} diff --git a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/manager/EapiConfigManager.java b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/manager/EapiConfigManager.java new file mode 100644 index 0000000000000000000000000000000000000000..2d005df792c99b480468743e0e212b8143d9a584 --- /dev/null +++ b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/manager/EapiConfigManager.java @@ -0,0 +1,110 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.core.manager; + +import com.inspur.edp.sgf.core.cache.ConfigCacheResult; +import com.inspur.edp.sgf.core.cache.EapiConfigCacheManager; +import com.inspur.edp.sgf.core.cache.GlobalConfigCacheResult; +import com.inspur.edp.sgf.utils.bsession.BackendSessionUtils; +import com.inspur.edp.sgf.utils.cache.ConfigCacheUtil; +import io.iec.edp.caf.boot.event.startup.StartupCompletedEvent; +import io.iec.edp.caf.commons.layeringcache.cache.Cache; +import io.iec.edp.caf.rpc.api.service.RpcClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.ApplicationListener; + +import java.util.HashMap; +import java.util.LinkedHashMap; + +/** + * 功能描述: + * + * @ClassName: EapiConfigManager + * @Author: Fynn Qi + * @Date: 2021/4/26 10:56 + * @Version: V1.0 + */ +public class EapiConfigManager implements ApplicationListener { + + private final Logger logger = LoggerFactory.getLogger(EapiConfigManager.class); + + private final RpcClient rpcClient; + + private final EapiConfigCacheManager eapiConfigCacheManager; + + public EapiConfigManager(RpcClient rpcClient, EapiConfigCacheManager eapiConfigCacheManager) { + this.rpcClient = rpcClient; + this.eapiConfigCacheManager = eapiConfigCacheManager; + } + + public GlobalConfigCacheResult getEapiGlobalConfig() { + //缓存不为空,从缓存中区 + if (eapiConfigCacheManager.getEapiConfigCache() != null) { + GlobalConfigCacheResult cacheResult = eapiConfigCacheManager.getGlobalCacheResult(); + if (cacheResult != null) { + return cacheResult; + } else { + return invokeGlobalConfigRpcService(); + } + } else { + return invokeGlobalConfigRpcService(); + } + } + + private GlobalConfigCacheResult invokeGlobalConfigRpcService() { + LinkedHashMap map = new LinkedHashMap<>(); + return rpcClient.invoke(GlobalConfigCacheResult.class, "com.inspur.edp.sgf.config.service.EapiConfigRpcService.getGlobalConfigs", "sg", map, new HashMap<>()); + } + + public ConfigCacheResult getEapiConfigs(String uri, String httpMethod) { + Cache cache = eapiConfigCacheManager.getEapiConfigCache(); + //缓存不为空,从缓存中区 + if (cache != null) { + String key = ConfigCacheUtil.getCacheKey(httpMethod, uri); + ConfigCacheResult cacheResult = cache.get(key, ConfigCacheResult.class); + //ConfigCacheResult不为空,则从缓存中取,为空则重新调用RPC获取 + if (cacheResult != null) { + return cacheResult; + } else { + //todo 当前su未更新缓存 + return invokeEapiConfigsRpcService(uri, httpMethod); + } + } else { + return invokeEapiConfigsRpcService(uri, httpMethod); + } + } + + private ConfigCacheResult invokeEapiConfigsRpcService(String uri, String httpMethod) { + LinkedHashMap map = new LinkedHashMap<>(); + map.put("uri", uri); + map.put("httpMethod", httpMethod); + return rpcClient.invoke(ConfigCacheResult.class, "com.inspur.edp.sgf.config.service.EapiConfigRpcService.getConfigs", "sg", map, new HashMap<>()); + } + + @Override + public void onApplicationEvent(StartupCompletedEvent event) { + try { + BackendSessionUtils.wrapFirstTenantBackendSession(tenant -> { + //todo 仅对第一个租户的缓存做了处理,后续改进 + eapiConfigCacheManager.clear(); + getEapiGlobalConfig(); + }); + } catch (Exception e) { + logger.warn("初始化API权限配置全局缓存出错:" + e.getMessage(), e); + eapiConfigCacheManager.removeGlobalCache(); + } + } +} diff --git a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/manager/EapiInovkerMananger.java b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/manager/EapiInovkerMananger.java new file mode 100644 index 0000000000000000000000000000000000000000..e17bf6b9d59dba16d1ca999eaabdba378218cce3 --- /dev/null +++ b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/manager/EapiInovkerMananger.java @@ -0,0 +1,88 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.core.manager; + +import com.fasterxml.jackson.databind.JsonNode; +import com.inspur.edp.sgf.core.cache.ResourceInvokerCache; +import com.inspur.edp.sgf.spi.ResourceInvoker; +import com.inspur.edp.sgf.spi.ResourceInvokerParam; +import org.apache.commons.lang3.StringUtils; + +import java.text.MessageFormat; +import java.util.List; +import java.util.Objects; + +/** + * 功能描述: + * + * @ClassName: EapiInovkerMananger + * @Author: Fynn Qi + * @Date: 2020/9/2 9:53 + * @Version: V1.0 + */ +public class EapiInovkerMananger { + + /** + * 服务调用 + * + * @param resourceType 资源类型 + * @param resourceId 资源ID + * @param resourceOpId 资源操作ID + * @param paramList 参数列表,JsonNode类型 + * @return 服务调用返回值 + */ + public static Object invokeByJsonNode( + String resourceType, String resourceId, String resourceOpId, List paramList) { + ResourceInvoker invoker = getResourceInvoker(resourceType); + ResourceInvokerParam param = new ResourceInvokerParam(); + param.setResourceType(resourceType); + param.setResourceId(resourceId); + param.setResourceOpId(resourceOpId); + param.setNodeParams(paramList); + return invoker.invoke(param); + } + + /** + * 服务调用 + * + * @param param + * @return + */ + public static Object invoke(ResourceInvokerParam param) { + if (param == null) { + throw new RuntimeException("参数校验:服务调用的参数不能为空,请检查。"); + } + if (StringUtils.isBlank(param.getResourceType())) { + throw new RuntimeException("参数校验:服务调用的资源类型参数(resourceType)不能为空,请检查。"); + } + ResourceInvoker invoker = getResourceInvoker(param.getResourceType()); + return invoker.invoke(param); + } + + /** + * 获取资源调用适配器 + * + * @param resourceType 资源类型 + * @return 资源适配器 + */ + private static ResourceInvoker getResourceInvoker(String resourceType) { + ResourceInvoker invoker = ResourceInvokerCache.getInstance().getResourceInvoker(resourceType); + if (Objects.isNull(invoker)) { + throw new RuntimeException(MessageFormat.format("获取{0}外部服务资源调用适配器失败。", resourceType)); + } + return invoker; + } + +} diff --git a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/serializer/JsonSerializer.java b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/serializer/JsonSerializer.java new file mode 100644 index 0000000000000000000000000000000000000000..90a7e6deb9fee79ba061e4104644945865841ebf --- /dev/null +++ b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/serializer/JsonSerializer.java @@ -0,0 +1,59 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.core.serializer; + +import com.fasterxml.jackson.databind.JsonNode; +import com.inspur.edp.cdp.common.utils.json.JsonUtil; +import com.inspur.edp.lcm.metadata.api.IMetadataContent; +import com.inspur.edp.lcm.metadata.spi.MetadataContentSerializer; +import com.inspur.edp.sgf.api.entity.SgMetadata; + +import java.util.Objects; + +/** + * 功能描述: @ClassName: JsonSerializer @Author: Fynn Qi @Date: 2019/7/26 11:32 @Version: V1.0 + */ +public class JsonSerializer implements MetadataContentSerializer { + + /** + * 序列化 + * + * @param iMetadataContent + * @return + */ + @Override + public JsonNode Serialize(IMetadataContent iMetadataContent) { + if (Objects.isNull(iMetadataContent)) { + return null; + } + SgMetadata metadata = (SgMetadata) iMetadataContent; + JsonNode node = JsonUtil.getMapper().convertValue(metadata, JsonNode.class); + return node; + } + + /** + * 反序列化 + * + * @param jsonNode + * @return + */ + @Override + public IMetadataContent DeSerialize(JsonNode jsonNode) { + if (Objects.isNull(jsonNode)) { + return null; + } + return JsonUtil.toObject(jsonNode, SgMetadata.class); + } +} diff --git a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/service/EapiConfigServiceImpl.java b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/service/EapiConfigServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..ace851127a3502e44efaea6325d28522408fd3c8 --- /dev/null +++ b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/service/EapiConfigServiceImpl.java @@ -0,0 +1,54 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.core.service; + +import com.inspur.edp.sgf.api.common.EapiGlobalConfig; +import com.inspur.edp.sgf.api.service.EapiConfigService; +import com.inspur.edp.sgf.core.cache.GlobalConfigCacheResult; +import com.inspur.edp.sgf.core.manager.EapiConfigManager; + +/** + * 功能描述: + * + * @ClassName: EapiConfigServiceImpl + * @Author: Fynn Qi + * @Date: 2020/12/19 11:19 + * @Version: V1.0 + */ +public class EapiConfigServiceImpl implements EapiConfigService { + + private EapiConfigManager manager; + + public EapiConfigServiceImpl(EapiConfigManager eapiConfigManager) { + this.manager = eapiConfigManager; + } + + @Override + public EapiGlobalConfig getEapiGlobalConfig() { + + EapiGlobalConfig globalConfig = new EapiGlobalConfig(); + + GlobalConfigCacheResult result = manager.getEapiGlobalConfig(); + + globalConfig.setEnable(getEnableStatus(result.getEnable())); + + return globalConfig; + } + + private boolean getEnableStatus(Boolean enable) { + return enable != null && enable; + } + +} diff --git a/rest-api-service/src/main/java/com/inspur/edp/sgf/core/service/InvokeServiceImpl.java b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/service/InvokeServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..ddba847b2c263070876ddd1892b89c732118707c --- /dev/null +++ b/rest-api-service/src/main/java/com/inspur/edp/sgf/core/service/InvokeServiceImpl.java @@ -0,0 +1,65 @@ +/* + * Copyright © OpenAtom Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package com.inspur.edp.sgf.core.service; + +import com.fasterxml.jackson.databind.JsonNode; +import com.inspur.edp.sgf.api.service.InvokeService; +import com.inspur.edp.sgf.core.manager.EapiInovkerMananger; +import com.inspur.edp.sgf.spi.ResourceInvokerParam; + +import java.util.List; +import java.util.Map; + +/** + * 功能描述: @ClassName: InvokeServiceImpl @Author: Fynn Qi @Date: 2019/7/22 14:03 @Version: V1.0 + */ +public class InvokeServiceImpl implements InvokeService { + + /** + * 服务调用 + * + * @param resourceType 资源类型 + * @param resourceId 资源ID + * @param resourceOpId 资源操作ID + * @param paramList 参数列表,JsonNode类型 + * @return 服务调用返回值 + */ + @Override + public Object invokeByJsonNode(String resourceType, String resourceId, String resourceOpId, List paramList) { + return EapiInovkerMananger.invokeByJsonNode(resourceType, resourceId, resourceOpId, paramList); + } + + /** + * 服务调用 + * + * @param resourceType + * @param resourceId + * @param resourceOpId + * @param paramList + * @param context + * @return + */ + @Override + public Object invokeByJsonNode(String resourceType, String resourceId, String resourceOpId, List paramList, Map context) { + ResourceInvokerParam param = new ResourceInvokerParam(); + param.setResourceType(resourceType); + param.setResourceId(resourceId); + param.setResourceOpId(resourceOpId); + param.setNodeParams(paramList); + param.setContextMap(context); + return EapiInovkerMananger.invoke(param); + } + +} diff --git a/rest-api-service/src/main/resources/META-INF/spring.factories b/rest-api-service/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000000000000000000000000000000000000..3682990d71f45de825a8538f1d46ee2cc2cbe932 --- /dev/null +++ b/rest-api-service/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.inspur.edp.sgf.core.config.EApiBeanConfig \ No newline at end of file