release version 1.10.0

This commit is contained in:
2024-12-14 04:07:49 +03:00
parent a5088587f7
commit c6b3d793c4
1916 changed files with 254306 additions and 0 deletions

View File

@ -0,0 +1,38 @@
/*-
* ~~~~~~licensing~~~~~~
* object-runtime-core
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.objects.runtime;
import ru.entaxy.platform.base.objects.EntaxyObject;
public interface EntaxyObjectCustomizer {
boolean isAccepted(EntaxyObject entaxyObject);
EntaxyObject applyCustomization(EntaxyObject entaxyObject);
EntaxyObject unapplyCustomization(EntaxyObject entaxyObject);
}

View File

@ -0,0 +1,36 @@
/*-
* ~~~~~~licensing~~~~~~
* object-runtime-core
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.objects.runtime;
import java.util.Map;
public interface EntaxyRuntimeObjectExtendedDataProvider {
String getProviderId();
Map<String, Object> getExtendedData(EntaxyRuntimeObject runtimeObject);
}

View File

@ -0,0 +1,99 @@
/*-
* ~~~~~~licensing~~~~~~
* object-runtime-core
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.objects.runtime.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
import org.osgi.service.component.annotations.ReferencePolicyOption;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ru.entaxy.platform.base.objects.EntaxyObject.BundleInfo;
import ru.entaxy.platform.core.support.runtime.cluster.ClusterBundleDataProvider;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObject;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObjectExtendedDataProvider;
@Component(service = EntaxyRuntimeObjectExtendedDataProvider.class, immediate = true)
public class ClusterExtendedDataProvider implements EntaxyRuntimeObjectExtendedDataProvider {
private static final Logger LOG = LoggerFactory.getLogger(ClusterExtendedDataProvider.class);
private static final String CLUSTER_PROVIDER_ID = "cluster";
@Reference(cardinality = ReferenceCardinality.OPTIONAL, policy = ReferencePolicy.DYNAMIC,
policyOption = ReferencePolicyOption.GREEDY)
volatile protected ClusterBundleDataProvider clusterBundleDataProvider = null;
protected BundleContext bundleContext;
@Activate
public void activate(ComponentContext componentContext) {
this.bundleContext = componentContext.getBundleContext();
}
@Override
public String getProviderId() {
return CLUSTER_PROVIDER_ID;
}
@Override
public Map<String, Object> getExtendedData(EntaxyRuntimeObject runtimeObject) {
if (clusterBundleDataProvider == null)
return null;
Map<String, Object> result = new HashMap<>();
List<String> groups = getClusterGroups(runtimeObject);
if (groups != null) {
result.put("groups", groups);
result.put("objectClusterState", !groups.isEmpty() ?
groups.stream().allMatch(group -> group.startsWith("?")) ? "non-clustered" : "clustered" : "local");
}
return result;
}
protected List<String> getClusterGroups(EntaxyRuntimeObject runtimeObject) {
try {
BundleInfo bi = runtimeObject.getBundleInfo();
Bundle bundle = bundleContext.getBundle(bi.getBundleId());
return clusterBundleDataProvider.getGroups(bundle);
} catch (Exception e) {
LOG.error(String.format("Error getting cluster groups for [%s]", runtimeObject.getObjectFullId()), e);
return null;
}
}
}

View File

@ -0,0 +1,171 @@
/*-
* ~~~~~~licensing~~~~~~
* object-runtime-core
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.objects.runtime.impl;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.osgi.framework.Filter;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.component.annotations.ReferenceCardinality;
import org.osgi.service.component.annotations.ReferencePolicy;
import org.osgi.service.component.annotations.ReferencePolicyOption;
import ru.entaxy.platform.base.support.CommonUtils;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObject;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObjectContainer;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObjectService;
import ru.entaxy.platform.search.AbstractSearchProvider;
import ru.entaxy.platform.search.SearchProvider;
import ru.entaxy.platform.search.SearchProviderInfo;
import ru.entaxy.platform.search.SearchService;
@Component(service = SearchProvider.class, immediate = true)
@SearchProviderInfo(id = "runtime",
targetTypes = {RuntimeObjectSearchProvider.TYPE_OBJECT, RuntimeObjectSearchProvider.TYPE_CONTAINER})
public class RuntimeObjectSearchProvider extends AbstractSearchProvider {
public static final String TYPE_OBJECT = "object";
public static final String TYPE_CONTAINER = "container";
@Reference(cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC,
policyOption = ReferencePolicyOption.GREEDY)
volatile SearchService searchService;
@Reference(cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC,
policyOption = ReferencePolicyOption.GREEDY)
volatile EntaxyRuntimeObjectService objectService;
@Override
public Map<String, String> getStandardAttributes(String targetType) throws IllegalArgumentException {
if (TYPE_CONTAINER.equalsIgnoreCase(targetType))
return EntaxyRuntimeObjectContainer.SEARCH.STANDARD_ATTRIBUTES;
if (TYPE_OBJECT.equalsIgnoreCase(targetType)) {
Map<String, String> result = new LinkedHashMap<>();
result.putAll(EntaxyRuntimeObject.SEARCH.STANDARD_ATTRIBUTES);
result.putAll(CommonUtils.prefixMap(EntaxyRuntimeObjectContainer.SEARCH.STANDARD_ATTRIBUTES, "container."));
// factory fields we'll get via search service
// for 'runtime-only' nodes the information can be unavailable
try {
result.putAll(CommonUtils.prefixMap(searchService.getStandardAttributes("factory"), "factory."));
} catch (Exception ignore) {
// NOOP
}
return result;
}
throw new IllegalArgumentException(
String.format("Provider [%s]: type [%s] nor supported", getProviderId(), targetType));
}
@Override
public List<Map<String, Object>> search(String targetType, Filter filter) throws IllegalArgumentException {
if (TYPE_CONTAINER.equalsIgnoreCase(targetType))
return searchContainers(filter);
if (TYPE_OBJECT.equalsIgnoreCase(targetType))
return searchObjects(filter);
throw new IllegalArgumentException(
String.format("Provider [%s]: type [%s] nor supported", getProviderId(), targetType));
}
protected List<Map<String, Object>> searchObjects(Filter filter) {
return objectService.getObjects().stream()
.map(obj -> getObjectEssence(obj))
.filter(ess -> filter.matches(ess))
.collect(Collectors.toList());
}
protected Map<String, Object> getObjectEssence(EntaxyRuntimeObject object) {
Map<String, Object> result = new LinkedHashMap<>();
// object attributes
result.put(EntaxyRuntimeObject.SEARCH.ATTR_ID, object.getId());
result.put(EntaxyRuntimeObject.SEARCH.ATTR_TYPE, object.getType());
result.put(EntaxyRuntimeObject.SEARCH.ATTR_LABEL, object.getAllAttributes().getOrDefault("label", ""));
result.put(EntaxyRuntimeObject.SEARCH.ATTR_DISPLAY_NAME, object.getDisplayName());
result.put(EntaxyRuntimeObject.SEARCH.ATTR_FACTORY, object.getFactoryId());
result.put(EntaxyRuntimeObject.SEARCH.ATTR_SCOPE, object.getScope());
result.put(EntaxyRuntimeObject.SEARCH.ATTR_RESOURCES, object.getResources().stream()
.map(res -> String.format("%s;%s", res.getResourceUrl(), res.getScope().name()))
.collect(Collectors.toList()));
result.put(EntaxyRuntimeObject.SEARCH.ATTR_RELATIONS_IN,
object.getIncomingRelations().stream().map(rel -> String.format("%s;%S;%s:%s",
rel.getSource().getObjectFullId(), rel.getType().name(), rel.getName(), rel.getGroup()))
.collect(Collectors.toList()));
result.put(EntaxyRuntimeObject.SEARCH.ATTR_RELATIONS_OUT,
object.getRelations().stream().map(rel -> String.format("%s;%S;%s:%s",
rel.getTarget().getObjectFullId(), rel.getType().name(), rel.getName(), rel.getGroup()))
.collect(Collectors.toList()));
// container attributes
result.putAll(CommonUtils.prefixMap(getContainerEssence(object.getContainer()), "container."));
// factory attributes we'll get via search service
// for 'runtime-only' nodes the information can be unavailable
try {
List<Map<String, Object>> factories = searchService.search("factory",
String.format("(&(id=%s)(type=%s))", object.getFactoryId(), object.getType()));
if (factories != null && !factories.isEmpty())
result.putAll(CommonUtils.prefixMap(factories.get(0), "factory."));
} catch (Exception ignore) {
// NOOP
}
return result;
}
protected List<Map<String, Object>> searchContainers(Filter filter) {
return objectService.getContainers().stream()
.map(obj -> getContainerEssence(obj))
.filter(ess -> filter.matches(ess))
.collect(Collectors.toList());
}
protected Map<String, Object> getContainerEssence(EntaxyRuntimeObjectContainer container) {
Map<String, Object> result = new LinkedHashMap<>();
result.put(EntaxyRuntimeObjectContainer.SEARCH.ATTR_ID, container.getId());
result.put(EntaxyRuntimeObjectContainer.SEARCH.ATTR_TYPE, container.getType());
result.put(EntaxyRuntimeObjectContainer.SEARCH.ATTR_NAME, container.getName());
result.put(EntaxyRuntimeObjectContainer.SEARCH.ATTR_STATE, container.getState());
return result;
}
}

View File

@ -0,0 +1,48 @@
/*-
* ~~~~~~licensing~~~~~~
* object-runtime-core
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.objects.runtime.internal;
import org.osgi.service.component.annotations.Activate;
import ru.entaxy.esb.resources.impl.AbstractResourceProviderProxy;
// @Component(service = EntaxyResourceProviderProxy.class, immediate = true)
/**
* @Deprecated already defined in core-support-runtime
*/
@Deprecated(forRemoval = true)
public class ObjectResourcesProvider extends AbstractResourceProviderProxy {
@Activate
public void activate() {
setProtocol("object-resources");
setTargetProtocol("entaxy-file-internal");
setTargetPath(".object-resources");
}
}

View File

@ -0,0 +1,63 @@
/*-
* ~~~~~~licensing~~~~~~
* object-runtime-shell
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.objects.runtime.shell;
import org.apache.karaf.shell.api.action.Action;
import org.apache.karaf.shell.api.action.Argument;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
import ru.entaxy.platform.base.support.karaf.shell.ShellTableExt;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObject;
@Service
@Command(name = "find-objects", scope = EntaxyRuntimeObjectServiceSupport.OBJECTS_SCOPE)
public class ObjectFind extends EntaxyRuntimeObjectServiceSupport implements Action {
@Argument(index = 0)
String filter;
@Override
public Object execute() throws Exception {
Filter odgiFilter = FrameworkUtil.createFilter(filter);
ShellTableExt shellTable = new ShellTableExt();
shellTable.column("Id");
shellTable.column("Type");
for (EntaxyRuntimeObject obj : objectService.findObjects(odgiFilter))
shellTable.addRow().addContent(
obj.getId(), obj.getType());
shellTable.print(System.out);
return null;
}
}

View File

@ -0,0 +1,76 @@
/*-
* ~~~~~~licensing~~~~~~
* object-runtime-shell
* ==========
* Copyright (C) 2020 - 2024 EmDev LLC
* ==========
* You may not use this file except in accordance with the License Terms of the Copyright
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
* rights to the Software and any copies are the property of the Copyright Holder. Unless
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
* Software for commercial purposes to provide services to third parties.
*
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
* Under no circumstances does the Copyright Holder guarantee or promise that the
* Software provided by him will be suitable or not suitable for the specific purposes
* of the User, that the Software will meet all commercial and personal subjective
* expectations of the User, that the Software will work properly, without technical
* errors, quickly and uninterruptedly.
*
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
* to the User for any direct or indirect losses of the User, his expenses or actual
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
* or damage to data, property, etc.
* ~~~~~~/licensing~~~~~~
*/
package ru.entaxy.platform.objects.runtime.shell;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.karaf.shell.api.action.Command;
import org.apache.karaf.shell.api.action.lifecycle.Reference;
import org.apache.karaf.shell.api.action.lifecycle.Service;
import ru.entaxy.platform.core.artifact.Artifact;
import ru.entaxy.platform.core.artifact.Artifacts;
import ru.entaxy.platform.core.artifact.repository.ArtifactRepository;
import ru.entaxy.platform.core.artifact.service.ArtifactService;
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObject;
@Service
@Command(name = "object-versions", scope = EntaxyRuntimeObjectServiceSupport.OBJECTS_SCOPE,
description = "List available object versions")
public class ObjectVersions extends RuntimeObjectAwareCommand {
@Reference
ArtifactService artifactService;
@Override
public Object doExecute(EntaxyRuntimeObject entaxyObject) throws Exception {
Set<String> availaleVersions = new HashSet<>();
Artifact artifact = Artifacts.create(Artifact.ARTIFACT_CATEGORY_BUNDLE);
artifact.getCoordinates().groupId(entaxyObject.getType()).artifactId(entaxyObject.getId());
String[] repos = new String[] {ArtifactRepository.REPO_NAME_LOCAL, ArtifactRepository.REPO_NAME_SHARED};
for (String repoName : repos) {
List<String> versions = artifactService.getRepository(repoName).getAvailableVersions(artifact);
if (versions != null)
availaleVersions.addAll(versions);
}
List<String> list = new ArrayList<>(availaleVersions);
Collections.sort(list);
System.out.println("Available versions:\n");
System.out.println(list.stream().collect(Collectors.joining("\n")));
return null;
}
}