release version 1.10.0
This commit is contained in:
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>ru.entaxy.esb.platform.runtime.base</groupId>
|
||||
<artifactId>resources</artifactId>
|
||||
<version>1.9.0</version>
|
||||
<version>1.10.0</version>
|
||||
</parent>
|
||||
<groupId>ru.entaxy.esb.platform.runtime.base.resources</groupId>
|
||||
<artifactId>resources-management</artifactId>
|
||||
@ -28,6 +28,11 @@
|
||||
<artifactId>resources-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resources-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* 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
|
||||
@ -40,4 +40,15 @@ public interface EntaxyResourceProviderMBean {
|
||||
List<Map<String, Object>> getResourcesInfo(
|
||||
@Parameter(name = "path", desc = "Path to resources") String path) throws Exception;
|
||||
|
||||
@Operation(desc = "Download resource")
|
||||
String downloadResource(@Parameter(name = "path", desc = "Path to the resource") String path) throws Exception;
|
||||
|
||||
@Operation(desc = "Paste resource")
|
||||
void pasteResource(@Parameter(name = "from", desc = "Location of the source resource") String from,
|
||||
@Parameter(name = "to", desc = "Path to the target resource") String to) throws Exception;
|
||||
|
||||
@Operation(desc = "Remove resource")
|
||||
void removeResource(
|
||||
@Parameter(name = "path", desc = "Path or location of the resource") String path) throws Exception;
|
||||
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resources-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resources-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* 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
|
||||
@ -27,16 +27,21 @@ package ru.entaxy.esb.resources.management.impl;
|
||||
|
||||
import javax.management.NotCompliantMBeanException;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import ru.entaxy.esb.platform.base.management.core.api.AnnotatedMBean;
|
||||
import ru.entaxy.esb.resources.EntaxyResource;
|
||||
import ru.entaxy.esb.resources.EntaxyResourceMetadata.MetadataSection;
|
||||
import ru.entaxy.esb.resources.EntaxyResourceProvider;
|
||||
import ru.entaxy.esb.resources.management.EntaxyResourceProviderMBean;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Base64;
|
||||
|
||||
public class EntaxyResourceProviderMBeanImpl extends AnnotatedMBean<EntaxyResourceProviderMBean>
|
||||
implements EntaxyResourceProviderMBean{
|
||||
@ -78,4 +83,48 @@ public class EntaxyResourceProviderMBeanImpl extends AnnotatedMBean<EntaxyResour
|
||||
|
||||
return resourcesInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String downloadResource(String path) throws Exception {
|
||||
try (InputStream is = resourceProvider.getResource(path).getInputStream()) {
|
||||
return Base64.getEncoder().encodeToString(readFromStream(is));
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] readFromStream(InputStream is) throws IOException {
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||
IOUtils.copy(is, baos);
|
||||
return baos.toByteArray();
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pasteResource(String from, String to) throws Exception {
|
||||
if (ServiceHelper.INSTANCE == null) {
|
||||
throw new IllegalStateException("Service helper is not initialized");
|
||||
}
|
||||
|
||||
EntaxyResource sourceResource = ServiceHelper.INSTANCE.entaxyResourceService.getResource(from);
|
||||
if (sourceResource.exists()) {
|
||||
try (InputStream is = sourceResource.getInputStream()) {
|
||||
EntaxyResource targetResource = resourceProvider.getResource(to);
|
||||
targetResource.save(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeResource(String path) throws Exception {
|
||||
if (path.contains(":")) {
|
||||
if (ServiceHelper.INSTANCE == null) {
|
||||
throw new IllegalStateException("Service helper is not initialized");
|
||||
}
|
||||
|
||||
ServiceHelper.INSTANCE.entaxyResourceService.getResource(path).delete();
|
||||
} else {
|
||||
resourceProvider.getResource(path).delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resources-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* 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
|
||||
|
@ -2,7 +2,7 @@
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resources-management
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2023 EmDev LLC
|
||||
* 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
|
||||
|
Reference in New Issue
Block a user