release version 1.11.0
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ru.entaxy.esb.platform.runtime.base</groupId>
|
||||
<artifactId>resources</artifactId>
|
||||
<version>1.10.0</version>
|
||||
<version>1.11.0</version>
|
||||
</parent>
|
||||
<groupId>ru.entaxy.esb.platform.runtime.base.resources</groupId>
|
||||
<artifactId>resources-management</artifactId>
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resources-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* Copyright (C) 2020 - 2025 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
|
||||
@ -51,4 +51,8 @@ public interface EntaxyResourceProviderMBean {
|
||||
void removeResource(
|
||||
@Parameter(name = "path", desc = "Path or location of the resource") String path) throws Exception;
|
||||
|
||||
@Operation(desc = "Save resource")
|
||||
void saveResource(@Parameter(name = "path", desc = "Path to the resource") String path,
|
||||
@Parameter(name = "content", desc = "The resource content") String content) throws Exception;
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resources-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* Copyright (C) 2020 - 2025 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
|
||||
@ -30,6 +30,7 @@ import ru.entaxy.esb.platform.base.management.core.api.MBeanExportPolicy;
|
||||
import ru.entaxy.esb.platform.base.management.core.api.Operation;
|
||||
import ru.entaxy.esb.platform.base.management.core.api.Parameter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@MBeanAnnotated(policy = MBeanExportPolicy.ANNOTATED_ONLY)
|
||||
@ -47,4 +48,7 @@ public interface EntaxyResourceServiceMBean {
|
||||
Map<String, String> getResourceMetadata(
|
||||
@Parameter(name = "location", desc = "Location of the resource") String location) throws Exception;
|
||||
|
||||
@Operation(desc = "Get a list of providers")
|
||||
List<String> listProviders() throws Exception;
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resources-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* Copyright (C) 2020 - 2025 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
|
||||
@ -107,11 +107,25 @@ public class EntaxyResourceProviderMBeanImpl extends AnnotatedMBean<EntaxyResour
|
||||
}
|
||||
|
||||
EntaxyResource sourceResource = ServiceHelper.INSTANCE.entaxyResourceService.getResource(from);
|
||||
pasteResource(sourceResource, to);
|
||||
}
|
||||
|
||||
private void pasteResource(EntaxyResource sourceResource, String to) throws Exception {
|
||||
if (sourceResource.exists()) {
|
||||
try (InputStream is = sourceResource.getInputStream()) {
|
||||
EntaxyResource targetResource = resourceProvider.getResource(to);
|
||||
targetResource.save(is);
|
||||
if (sourceResource.isFolder()) {
|
||||
List<EntaxyResource> resources = ServiceHelper.INSTANCE.entaxyResourceService
|
||||
.getResources(sourceResource.getURL());
|
||||
for(EntaxyResource resource : resources) {
|
||||
pasteResource(resource, to + '/' + resource.getName());
|
||||
}
|
||||
} else {
|
||||
try (InputStream is = sourceResource.getInputStream()) {
|
||||
EntaxyResource targetResource = resourceProvider.getResource(to);
|
||||
targetResource.save(is);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Resource located at [" + sourceResource.getURL() + "] is not found");
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,4 +141,11 @@ public class EntaxyResourceProviderMBeanImpl extends AnnotatedMBean<EntaxyResour
|
||||
resourceProvider.getResource(path).delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveResource(String path, String content) throws Exception {
|
||||
try (InputStream is = IOUtils.toInputStream(content)) {
|
||||
resourceProvider.getResource(path).save(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resources-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* Copyright (C) 2020 - 2025 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resources-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* Copyright (C) 2020 - 2025 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
|
||||
@ -41,6 +41,8 @@ import javax.management.MBeanRegistration;
|
||||
import javax.management.NotCompliantMBeanException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Component(service = { EntaxyResourceServiceMBean.class, DynamicMBean.class, MBeanRegistration.class }, property = {
|
||||
ManagementCore.JMX_OBJECTNAME + "=" + ManagementCore.Q_RUNTIME_S + "," + EntaxyResourceServiceMBean.RESOURCE_SERVICE_KEY + "="
|
||||
@ -80,4 +82,9 @@ public class EntaxyResourceServiceMBeanImpl extends AnnotatedMBean<EntaxyResourc
|
||||
throw new Exception("Metadata is not present");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listProviders() {
|
||||
return new ArrayList<>(entaxyResourceService.getProviders().keySet());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,50 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resources-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2025 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.esb.resources.management.impl;
|
||||
|
||||
import org.osgi.service.component.annotations.*;
|
||||
import ru.entaxy.esb.resources.EntaxyResourceService;
|
||||
|
||||
@Component(service = ServiceHelper.class, immediate = true)
|
||||
public class ServiceHelper {
|
||||
|
||||
public static ServiceHelper INSTANCE;
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY, policy = ReferencePolicy.DYNAMIC,
|
||||
policyOption = ReferencePolicyOption.GREEDY)
|
||||
volatile public EntaxyResourceService entaxyResourceService;
|
||||
|
||||
@Activate
|
||||
public void activate() {
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
@Deactivate
|
||||
public void deactivate() {
|
||||
INSTANCE = null;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user