release version 1.10.0
This commit is contained in:
@ -0,0 +1,175 @@
|
||||
ЛИЦЕНЗИЯ ОГРАНИЧЕННОГО ПРИМЕНЕНИЯ
|
||||
|
||||
Настоящий документ устанавливает для Пользователя условия применения Базовой (некоммерческой)
|
||||
версии лицензии для пробного использования программного обеспечения ENTAXY, принадлежащего
|
||||
Правообладателю – Обществу с ограниченной ответственностью "ЕМДЕВ" (ОГРН 1057810026658, ИНН
|
||||
7813313860, юридический адрес: 197022, Россия, г. Санкт-Петербург, ул. Профессора Попова,
|
||||
д. 23, литера В, помещение 3Н), расположенной в сети Интернет по адресу
|
||||
https://www.emdev.ru/about (далее - Компания).
|
||||
|
||||
Используя или получая доступ к Программному обеспечению, или нажав «Я согласен с Условиями»
|
||||
(или аналогичную кнопку или флажок) после загрузки или установки Программного обеспечения,
|
||||
Пользователь выражает свое согласие на обязательность условий и ограничений, изложенных в
|
||||
настоящем документе, в противном случае, он должен не использовать или не получать доступ
|
||||
к Программному обеспечению.
|
||||
|
||||
1. ТЕРМИНЫ И ОПРЕДЕЛЕНИЯ
|
||||
|
||||
a) ПО – Программное обеспечение, интеграционная шина «ЭНТАКСИ» (ENTAXY) в любой ее версии
|
||||
или редакции, исключительные права на которую принадлежат Правообладателю.
|
||||
b) Правообладатель (Компания) – ООО «ЕМДЕВ», ОГРН 1057810026658, ИНН 7813313860, исключительные
|
||||
права которого подтверждаются Свидетельством о государственной регистрации в Реестре программ
|
||||
для ЭВМ № 2021610848 от 19.01.2021 года.
|
||||
c) Пользователь – юридическое или физическое лицо, получившее через скачивание с сайта
|
||||
https://entaxy.ru или иным образом, дистрибутив ПО, пользующееся ПО.
|
||||
d) ИС – интеллектуальная собственность – закреплённое законом исключительное право, а также
|
||||
личные неимущественные права авторов произведений на результат интеллектуальной деятельности.
|
||||
e) Подписка – это коммерческое предложение Правообладателя, состоящее из Лицензии на использование
|
||||
ПО и доступа к технической поддержке программного обеспечения на срок Подписки. Подписка
|
||||
включает предоставление Пользователю неисключительного права использования ПО, в том числе
|
||||
получение обновлений функционала ПО и безопасности ПО, исправление ошибок ПО и получение
|
||||
патчей с обновлениями и исправлениями программного обеспечения. Подписка приобретается
|
||||
Пользователем на период времени, указанный в Сертификате. Количество подписок устанавливается
|
||||
для каждого Пользователя индивидуально в Сертификате.
|
||||
f) Сертификат – документ, выдаваемый Дистрибъютором или Авторизованным партнёром (Партнёром),
|
||||
подтверждающий факт приобретения физическим или юридическим лицом Подписки на программное
|
||||
обеспечение в ограниченном объёме и на определённый период времени.
|
||||
g) Лицензия (простая (неисключительная) – совокупность ограниченных прав использования ПО,
|
||||
предоставленных Пользователю согласно условиям Подписки.
|
||||
h) Библиотека – совокупность подпрограмм и объектов, используемых для разработки программного
|
||||
обеспечения.
|
||||
i) Исходный код – текст компьютерной программы на каком-либо языке программирования, состоящий
|
||||
из одного или нескольких файлов, который может быть прочтён человеком.
|
||||
j) Объектный код – файл (часть машинного кода) с промежуточным представлением отдельного модуля
|
||||
программы, полученный в результате обработки исходного кода, еще не связанный в полную программу.
|
||||
Это машинный код для одной конкретной библиотеки или модуля, который будет составлять готовый
|
||||
продукт.
|
||||
k) Некоммерческое использование – индивидуальное личное использование Пользователем программного
|
||||
обеспечения с целью обучения работе с Программным обеспечением, для оценки или демонстрации
|
||||
возможностей Программного обеспечения, при котором, Пользователем не извлекается коммерческая
|
||||
выгода и/или не идёт в доход денежное вознаграждение при использовании Программного обеспечения.
|
||||
|
||||
2. ДОПУСТИМЫЕ СПОСОБЫ ИСПОЛЬЗОВАНИЯ ПРОГРАММНОГО ОБЕСПЕЧЕНИЯ
|
||||
|
||||
2.1. Правообладатель предоставляет Пользователю ограниченное право использования Программного
|
||||
обеспечения на условиях простой (неисключительной) лицензии в объёме, ограниченном правом
|
||||
воспроизведения полной рабочей версии программного обеспечения, новых версий программного обеспечения
|
||||
в памяти оборудования и его запуска на оборудовании в соответствии со ст. 1280 ГК РФ.
|
||||
2.2. Право на использование Программного обеспечения, предоставляемое Пользователю, носит
|
||||
неисключительный характер.
|
||||
2.3. Пользователю предоставляется всемирная, неисключительная, не подлежащая сублицензированию,
|
||||
лицензия на ограниченное использование Программного обеспечения.
|
||||
2.4. Пользователь, имеющий Базовую (некоммерческую) версию лицензии для пробного использования
|
||||
имеет право приобрести Подписку на программное обеспечение. В этом случае Пользователь обязан
|
||||
обратиться в службу поддержки Правообладателя по адресу: https://entaxy.ru/ для изменения
|
||||
вида лицензии с Базовой бесплатной версии на Подписки.
|
||||
2.5. Срок использования скачанной Пользователем базовой (некоммерческой) версии лицензии для
|
||||
пробного использования программного обеспечения – не ограничен.
|
||||
2.6. Использование Пользователем настоящего программного обеспечения в целях разработки,
|
||||
модификации, обновления другого ПО, принадлежащего третьим лицам, а не Правообладателю,
|
||||
без разрешения Правообладателя не допускается.
|
||||
|
||||
3. АВТОРСКОЕ ПРАВО.
|
||||
|
||||
3.1. Все авторские права, все права интеллектуальной собственности на Программное обеспечение
|
||||
и любые его копии принадлежат Правообладателю.
|
||||
3.2. Все авторские права, все права интеллектуальной собственности в отношении любого контента,
|
||||
к которому можно получить доступ с помощью Программного обеспечения, является собственностью
|
||||
соответствующего владельца контента и защищается применимым законодательством об авторском
|
||||
праве или другими законами и договорами об интеллектуальной собственности.
|
||||
3.3. Условия использования Программного обеспечения.
|
||||
Лицензия, предоставленная Пользователю, действительна только в том случае, если Пользователь
|
||||
придерживается следующих условий:
|
||||
3.3.1. Принятие уведомлений об авторских правах. Пользователю запрещается удалять или изменять
|
||||
какие-либо уведомления об авторских правах или лицензиях, которые появляются при использовании
|
||||
Программного обеспечения или на нем.
|
||||
3.3.2. Модификация. Пользователю запрещается модифицировать, изменять, декомпилировать,
|
||||
расшифровывать, дизассемблировать, переводить или реверсировать, перепроектировать
|
||||
Программное обеспечение.
|
||||
3.3.3. Распространение. Пользователю запрещается сублицензировать, передавать право использования
|
||||
ПО или иным образом распространять или предоставлять Программное обеспечение любой третьей стороне.
|
||||
3.3.4. SaaS. За исключением случаев, когда это разрешено Правообладателем, Пользователю запрещено
|
||||
использовать Программное обеспечение в коммерческих целях для оказания услуг третьим лицам.
|
||||
|
||||
4. ОТВЕТСТВЕННОСТЬ ПРАВООБЛАДАТЕЛЯ ПРИ НАРУШЕНИИ ПОЛЬЗОВАТЕЛЕМ ПРАВ «ИС»
|
||||
|
||||
4.1. Правообладатель не несет никаких обязательств в отношении каких-либо претензий к Пользователю
|
||||
на предмет нарушения последним прав Интеллектуальной собственности, возникших в связи с
|
||||
использованием Пользователем:
|
||||
4.1.1. Любых компонентов программного обеспечения с открытым исходным кодом, включенных в
|
||||
Программное обеспечение;
|
||||
4.1.2. Любого нарушения правил использования Программного обеспечения, установленного условиями
|
||||
настоящего соглашения;
|
||||
4.1.3. Любого использования Программного обеспечения в сочетании с другими ПО, оборудованием,
|
||||
или данными, не предоставленными Пользователю Правообладателем;
|
||||
4.1.4. Любого изменения Программного обеспечения любым третьим лицом, а не Правообладателем.
|
||||
|
||||
|
||||
5. НАСТОЯЩИМ ПРАВООБЛАДАТЕЛЬ ЗАЯВЛЯЕТ, ЧТО ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ ПРЕДОСТАВЛЯЕТСЯ ПОЛЬЗОВАТЕЛЮ
|
||||
ПО ПРИНЦИПУ «AS IS» - «КАК ЕСТЬ». НИ ПРИ КАКИХ ОБСТОЯТЕЛЬСТВАХ ПРАВООБЛАДАТЕЛЬ НЕ ГАРАНТИРУЕТ
|
||||
И НЕ ОБЕЩАЕТ, ЧТО ПРЕДОСТАВЛЕННОЕ ИМ ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ БУДЕТ ПОДХОДИТЬ ИЛИ НЕ ПОДХОДИТЬ
|
||||
ДЛЯ КОНКРЕТНЫХ ЦЕЛЕЙ ПОЛЬЗОВАТЕЛЯ, ЧТО ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ БУДЕТ ОТВЕЧАТЬ ВСЕМ КОММЕРЧЕСКИМ
|
||||
И ЛИЧНЫМ СУБЪЕКТИВНЫМ ОЖИДАНИЯМ ПОЛЬЗОВАТЕЛЯ, ЧТО ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ БУДЕТ РАБОТАТЬ
|
||||
ИСПРАВНО, БЕЗ ТЕХНИЧЕСКИХ ОШИБОК, БЫСТРО И БЕСПЕРЕБОЙНО.
|
||||
|
||||
6. ОГРАНИЧЕНИЕ ОТВЕТСТВЕННОСТИ.
|
||||
НИ ПРИ КАКИХ ОБСТОЯТЕЛЬСТВАХ ПРАВООБЛАДАТЕЛЬ ИЛИ ЕГО АФФИЛЛИРОВАННЫЕ ЛИЦА НЕ НЕСУТ ПЕРЕД ПОЛЬЗОВАТЕЛЕМ
|
||||
ОТВЕТСТВЕННОСТИ ЗА ЛЮБЫЕ ПРЯМЫЕ ИЛИ КОСВЕННЫЕ УБЫТКИ ПОЛЬЗОВАТЕЛЯ, ЕГО РАСХОДЫ ИЛИ РЕАЛЬНЫЙ УЩЕРБ,
|
||||
ВКЛЮЧАЯ, ПОМИМО ПРОЧЕГО, ПРОСТОИ; УТРАТУ БИЗНЕСА; УПУЩЕННУЮ ВЫГОДУ; НЕДОПОЛУЧЕННУЮ ПРИБЫЛЬ;
|
||||
ПОТЕРЮ ИЛИ ПОВРЕЖДЕНИЕ ДАННЫХ, ИМУЩЕСТВА И ИНОЕ.
|
||||
ОГРАНИЧЕНИЯ ПРИМЕНЯЮТСЯ НЕЗАВИСИМО ОТ ОСНОВАНИЯ НАСТУПЛЕНИЯ ОТВЕТСТВЕННОСТИ; В ТОМ ЧИСЛЕ ВСЛЕДСТВИЕ
|
||||
ДЕЙСТВИЯ ИЛИ БЕЗДЕЙСТВИЯ, НЕБРЕЖНОСТИ, УМЫСЛА, ПРЯМОГО ИЛИ КОСВЕННОГО; НЕОСТОРОЖНОСТИ; ЗАБЛУЖДЕНИЯ;
|
||||
КЛЕВЕТЫ; НАРУШЕНИЯ КОНФИДЕНЦИАЛЬНОСТИ ИЛИ ПРАВА ИНТЕЛЛЕКТУАЛЬНОЙ СОБСТВЕННОСТИ; ИЛИ ЛЮБОЕ ДРУГОЕ
|
||||
ОСНОВАНИЕ НАСТУПЛЕНИЯ ОТВЕТСТВЕННОСТИ.
|
||||
|
||||
7. ОБЯЗАННОСТЬ ПОЛЬЗОВАТЕЛЯ:
|
||||
Не осуществлять самостоятельно и (или) с привлечением третьих лиц нижеследующие действия
|
||||
(включая, но не ограничиваясь) по:
|
||||
-дизассемблированию и (или) декомпилированию (преобразованию объектного кода в исходный код)
|
||||
Программного обеспечения;
|
||||
-модификации Программного обеспечения, в том числе вносить изменения в объектный код, исходный
|
||||
код Программного обеспечения, за исключением тех изменений, которые вносятся средствами,
|
||||
включёнными в Программное обеспечение и описанными непосредственно в документации к нему;
|
||||
-созданию условий для использования Программного обеспечения лицами, не имеющими прав на
|
||||
использование данного Программного обеспечения, включая (но не ограничиваясь) вмешательство
|
||||
третьих лиц в функционирование Программного обеспечения, предоставление третьим лицам доступа
|
||||
к исследованию и (или) замене настроек Программного обеспечения, включая его первичную установку;
|
||||
-распространению Программного обеспечения в целом или в части (включая приложенную к нему документацию).
|
||||
|
||||
8. БИБЛИОТЕКА ПО. ИСПОЛЬЗУЕМЫЕ ПРОГРАММНЫЕ СРЕДСТВА.
|
||||
|
||||
8.1. Настоящим, Правообладатель заверяет, что Библиотека программного обеспечения состоит из
|
||||
лицензионных продуктов, используемых на законных основаниях, а
|
||||
именно https://entaxy.ru/libs/licenses/root-aggregated.deps.
|
||||
8.2. Любые программные средства, применяемые Пользователем при работе с ПО, должны быть
|
||||
совместимы с библиотекой ПО, указанной в п.8.1. настоящего соглашения.
|
||||
8.3. Перечень внешних модулей ПО, указанный в п.8.1 настоящего соглашения, может изменяться
|
||||
Правообладателем в одностороннем порядке, в зависимости от выпуска релизов программного обеспечения,
|
||||
содержащих все изменения и дополнения программного обеспечения.
|
||||
|
||||
9. ВНЕСЕНИЕ ИЗМЕНЕНИЙ В ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ.
|
||||
|
||||
9.1. Программное обеспечение, интеграционная шина «ЭНТАКСИ» (ENTAXY) является свободно распространяемым
|
||||
программным обеспечением.
|
||||
9.2. Пользователь имеет право вносить изменения в исходный код программного обеспечения исключительно
|
||||
с согласия Правообладателя в порядке предложения изменений/правок/дополнений через механизм
|
||||
«Pull Requests» в открытом репозитории Правообладателя по адресу: https://git.entaxy.ru/entaxy/entaxy-public.
|
||||
9.3. Любые изменения программного обеспечения, осуществляемые Пользователем без соблюдения условий
|
||||
пункта 9.2. настоящего документа, являются нарушением авторских и смежных прав Правообладателя,
|
||||
прав интеллектуальной собственности Правообладателя и влекут применение к Пользователю мер
|
||||
ответственности в соответствии с условиями настоящей Лицензии, а также применимого законодательства
|
||||
Российской Федерации.
|
||||
|
||||
10. ЗАКЛЮЧИТЕЛЬНЫЕ ПОЛОЖЕНИЯ.
|
||||
|
||||
10.1. В случае нарушения Пользователем любого из условий настоящей Лицензии, Правообладатель имеет
|
||||
право взыскать с Пользователя любые причинённые таким нарушением убытки, реальный ущерб,
|
||||
недополученную прибыль, упущенную выгоду, а также в случае нарушения Пользователем условий
|
||||
пункта 9.2 настоящего соглашения, в том числе, взыскать с Пользователя штраф в размере
|
||||
2 000 000 (Два миллиона) рублей за каждый установленный случай несанкционированного изменения
|
||||
исходного или объектного кода Программного обеспечения «Энтакси» (Entaxy).
|
||||
10.2. В рамках исполнения Пользователем обязательств по настоящей Лицензии, применимое
|
||||
законодательство – Российской Федерации.
|
||||
10.3. Если какое-либо положение настоящей Лицензии будет признано судом недействительным,
|
||||
остальные положения будут продолжать своё действие, а Пользователь будет обязан продолжать
|
||||
исполнять свои обязанности в соответствии с этими положениями.
|
@ -0,0 +1,54 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>ru.entaxy.platform.integration</groupId>
|
||||
<artifactId>applications</artifactId>
|
||||
<version>1.10.0</version>
|
||||
</parent>
|
||||
<groupId>ru.entaxy.platform.integration.applications</groupId>
|
||||
<artifactId>resource-based-storage</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<name>ENTAXY :: PLATFORM :: INTEGRATION :: APPLICATIONS :: RESOURCE BASED STORAGE</name>
|
||||
<description>ENTAXY :: PLATFORM :: INTEGRATION :: APPLICATIONS :: RESOURCE BASED STORAGE</description>
|
||||
|
||||
<properties>
|
||||
<bundle.osgi.export.pkg>
|
||||
ru.entaxy.platform.integration.applications.storage.resource
|
||||
</bundle.osgi.export.pkg>
|
||||
<bundle.osgi.private.pkg>
|
||||
ru.entaxy.platform.integration.applications.storage.resource.impl,
|
||||
ru.entaxy.platform.integration.applications.storage.resource.impl.application,
|
||||
ru.entaxy.platform.integration.applications.storage.resource.impl.project,
|
||||
ru.entaxy.platform.integration.applications.storage.resource.internal
|
||||
</bundle.osgi.private.pkg>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ru.entaxy.esb.platform.runtime.base.resources</groupId>
|
||||
<artifactId>resources-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.entaxy.platform.integration.applications</groupId>
|
||||
<artifactId>application-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.entaxy.platform.integration.applications</groupId>
|
||||
<artifactId>application-impl</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,210 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import ru.entaxy.esb.resources.EntaxyResource;
|
||||
import ru.entaxy.esb.resources.EntaxyResourceMetadata;
|
||||
import ru.entaxy.esb.resources.EntaxyResourceService;
|
||||
import ru.entaxy.platform.base.support.CommonUtils;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplication;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplicationProject;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ApplicationException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ApplicationNotFoundException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ProjectAlreadyExistsException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ProjectException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ProjectNotFoundException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.StorageException;
|
||||
import ru.entaxy.platform.integration.applications.storage.AbstractApplicationStorage;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.ResourceContext;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.StorageComponent;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.application.ApplicationComponent;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.project.ProjectComponent;
|
||||
|
||||
public class ResourceBasedStorage extends AbstractApplicationStorage {
|
||||
|
||||
protected String resourceProvider;
|
||||
protected String path;
|
||||
|
||||
protected EntaxyResourceService entaxyResourceService;
|
||||
|
||||
protected EntaxyResource rootResourceFolder;
|
||||
protected EntaxyResourceMetadata rootResourceFolderMetadata;
|
||||
protected EntaxyResourceMetadata.MetadataSection rootMetaStorageSection;
|
||||
|
||||
protected String rootResourceFolderUrl;
|
||||
|
||||
boolean isInited = false;
|
||||
|
||||
protected StorageComponent storageComponent;
|
||||
|
||||
protected ResourceContext rootResourceContext;
|
||||
|
||||
protected interface RootMetaProps {
|
||||
String PROP_ENABLED = "enabled";
|
||||
}
|
||||
|
||||
public String getResourceProvider() {
|
||||
return resourceProvider;
|
||||
}
|
||||
|
||||
public void setResourceProvider(String resourceProvider) {
|
||||
this.resourceProvider = resourceProvider;
|
||||
updateResourceFolderUrl();
|
||||
setInfo("provider", this.resourceProvider);
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
updateResourceFolderUrl();
|
||||
setInfo("path", this.path);
|
||||
}
|
||||
|
||||
protected void updateResourceFolderUrl() {
|
||||
this.rootResourceFolderUrl =
|
||||
CommonUtils.getValid(resourceProvider, "").concat(":").concat(CommonUtils.getValid(path, ""));
|
||||
}
|
||||
|
||||
public void setEntaxyResourceService(EntaxyResourceService entaxyResourceService) {
|
||||
this.entaxyResourceService = entaxyResourceService;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
rootResourceContext = new ResourceContext();
|
||||
rootResourceContext.setEntaxyResourceService(entaxyResourceService);
|
||||
rootResourceContext.setRootResourceFolderUrl(rootResourceFolderUrl);
|
||||
rootResourceContext.init();
|
||||
storageComponent = new StorageComponent(rootResourceContext, name);
|
||||
storageComponent.init();
|
||||
isInited = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean isEnabled) {
|
||||
super.setEnabled(isEnabled);
|
||||
if (!isInited)
|
||||
return;
|
||||
rootMetaStorageSection.getContent().remove(RootMetaProps.PROP_ENABLED);
|
||||
rootMetaStorageSection.getContent().addProperty(RootMetaProps.PROP_ENABLED, isEnabled());
|
||||
rootResourceFolderMetadata.update();
|
||||
}
|
||||
|
||||
protected String getApplicationUrl(String applicationName) {
|
||||
return rootResourceFolderUrl.concat("/").concat(applicationName);
|
||||
}
|
||||
|
||||
protected boolean projectExists(String projectName) {
|
||||
return storageComponent.projectExists(projectName);
|
||||
}
|
||||
|
||||
protected boolean applicationExists(String applicationName) {
|
||||
return storageComponent.applicationExists(applicationName);
|
||||
}
|
||||
|
||||
/* ApplicationStorage implementation */
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return "resource";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntaxyApplicationProject> getProjects() {
|
||||
return storageComponent.getProjects().stream().map(cmp -> cmp.storage(this))
|
||||
.map(cmp -> (EntaxyApplicationProject) cmp).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addProject(EntaxyApplicationProject project) throws ProjectException, StorageException {
|
||||
if (projectExists(project.getName()))
|
||||
throw new ProjectAlreadyExistsException(project.getName());
|
||||
storageComponent.addProject(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeProject(EntaxyApplicationProject project)
|
||||
throws ProjectException, StorageException {
|
||||
if (project == null)
|
||||
throw new ProjectNotFoundException("Unknown");
|
||||
if (!projectExists(project.getName()))
|
||||
throw new ProjectNotFoundException(project.getName());
|
||||
storageComponent.removeProject(project);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyApplicationProject createProject(String applicationName)
|
||||
throws ProjectException, StorageException {
|
||||
if (projectExists(applicationName))
|
||||
throw new ProjectAlreadyExistsException(applicationName);
|
||||
return storageComponent.createProject(applicationName).storage(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyApplicationProject getProject(String applicationName) {
|
||||
ProjectComponent comp = storageComponent.getProject(applicationName);
|
||||
if (comp == null)
|
||||
return null;
|
||||
return comp.storage(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntaxyApplication> getApplications() {
|
||||
return storageComponent.getApplications().stream().map(cmp -> cmp.storage(this))
|
||||
.map(cmp -> (EntaxyApplication) cmp).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyApplication getApplication(String applicationName) {
|
||||
ApplicationComponent comp = storageComponent.getApplication(applicationName);
|
||||
if (comp == null)
|
||||
return null;
|
||||
return comp.storage(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeApplication(EntaxyApplication application) throws ApplicationException, StorageException {
|
||||
if (application == null)
|
||||
throw new ApplicationNotFoundException("unknown");
|
||||
if (!applicationExists(application.getName()))
|
||||
throw new ApplicationNotFoundException(application.getName());
|
||||
storageComponent.removeApplication(application);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyApplication createApplication(ApplicationImportContent content)
|
||||
throws ApplicationException, StorageException {
|
||||
return storageComponent.createApplication(content);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,185 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import ru.entaxy.esb.resources.EntaxyResource;
|
||||
import ru.entaxy.esb.resources.EntaxyResourceMetadata;
|
||||
import ru.entaxy.platform.base.support.JSONUtils;
|
||||
|
||||
public abstract class AbstractResourceComponent<T> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AbstractResourceComponent.class);
|
||||
|
||||
protected static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
protected ResourceContext resourceContext;
|
||||
|
||||
// protected EntaxyResourceService entaxyResourceService;
|
||||
|
||||
// protected EntaxyResource rootResourceFolder;
|
||||
protected EntaxyResourceMetadata rootResourceFolderMetadata;
|
||||
|
||||
protected EntaxyResource rootResource;
|
||||
|
||||
// protected String rootResourceFolderUrl;
|
||||
protected String rootResourceUrl;
|
||||
|
||||
protected boolean isInited = false;
|
||||
|
||||
protected T dataObject;
|
||||
|
||||
protected abstract Class<T> getDataObjectClass();
|
||||
|
||||
protected abstract String getRootResourceName();
|
||||
|
||||
protected abstract T createDataObject();
|
||||
|
||||
/*
|
||||
protected AbstractResourceComponent(EntaxyResourceService entaxyResourceService) {
|
||||
super();
|
||||
setEntaxyResourceService(entaxyResourceService);
|
||||
}
|
||||
*/
|
||||
|
||||
protected AbstractResourceComponent(ResourceContext resourceContext) {
|
||||
super();
|
||||
this.resourceContext = resourceContext;
|
||||
this.resourceContext.init();
|
||||
}
|
||||
|
||||
|
||||
protected T loadDataObject(JsonObject jsonObject) {
|
||||
return GSON.fromJson(jsonObject, getDataObjectClass());
|
||||
};
|
||||
|
||||
protected void initializeRootResource() throws Exception {
|
||||
dataObject = createDataObject();
|
||||
updateRootResource();
|
||||
}
|
||||
|
||||
protected void initializeDataObject() throws Exception {
|
||||
try (InputStream is = rootResource.getInputStream()) {
|
||||
String data = new String(is.readAllBytes());
|
||||
dataObject = GSON.fromJson(JSONUtils.getJsonRootObject(data), getDataObjectClass());
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateRootResource() throws Exception {
|
||||
JsonObject jsonObject = GSON.toJsonTree(dataObject).getAsJsonObject();
|
||||
String data = GSON.toJson(jsonObject);
|
||||
try (ByteArrayInputStream bis = new ByteArrayInputStream(data.getBytes())) {
|
||||
rootResource.save(bis);
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
protected EntaxyResource getResource(String relPath) {
|
||||
/*
|
||||
String targetUrl = rootResourceFolderUrl;
|
||||
if (rootResourceFolderUrl.charAt(rootResourceFolderUrl.length() - 1) != '/')
|
||||
targetUrl = targetUrl.concat("/");
|
||||
if (relPath.charAt(0) == '/')
|
||||
targetUrl = targetUrl.concat(relPath.substring(1));
|
||||
else
|
||||
targetUrl = targetUrl.concat(relPath);
|
||||
EntaxyResource result = entaxyResourceService.getResource(targetUrl);
|
||||
return result;
|
||||
*/
|
||||
return resourceContext.getResource(relPath);
|
||||
}
|
||||
|
||||
public void init() {
|
||||
|
||||
// rootResourceFolder = entaxyResourceService.getResource(rootResourceFolderUrl);
|
||||
|
||||
// rootResource = entaxyResourceService
|
||||
// .getResource(rootResourceFolder.getURL().concat("/").concat(getRootResourceName()));
|
||||
rootResource = resourceContext.getResource(getRootResourceName());
|
||||
if (!rootResource.exists()) {
|
||||
try {
|
||||
initializeRootResource();
|
||||
} catch (Exception ignore) {
|
||||
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
initializeDataObject();
|
||||
} catch (Exception e) {
|
||||
log.error("Error reading data from [" + rootResource.getURL() + "]", e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
rootResourceFolderMetadata = resourceContext.getRootResourceFolder().getMetadata(true);
|
||||
|
||||
isInited = true;
|
||||
|
||||
}
|
||||
|
||||
public ResourceContext getResourceContext() {
|
||||
return resourceContext;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
if (!isInited)
|
||||
return;
|
||||
resourceContext.getRootResourceFolder().delete();
|
||||
}
|
||||
|
||||
/*
|
||||
public void setEntaxyResourceService(EntaxyResourceService entaxyResourceService) {
|
||||
this.entaxyResourceService = entaxyResourceService;
|
||||
}
|
||||
*/
|
||||
|
||||
public String getRootResourceFolderUrl() {
|
||||
return resourceContext.getRootResourceFolderUrl();
|
||||
}
|
||||
|
||||
/*
|
||||
public void setRootResourceFolderUrl(String rootResourceFolderUrl) {
|
||||
this.rootResourceFolderUrl = rootResourceFolderUrl;
|
||||
}
|
||||
*/
|
||||
|
||||
public abstract String getComponentKey();
|
||||
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractResourceComponentWithChildren<T, C extends AbstractResourceComponent<?>>
|
||||
extends AbstractResourceComponent<T> {
|
||||
|
||||
|
||||
final protected ComponentCache<C> childrenCache = new ComponentCache<>();
|
||||
|
||||
final protected Object childrenCacheLock = new Object();
|
||||
|
||||
/*
|
||||
protected AbstractResourceComponentWithChildren(EntaxyResourceService entaxyResourceService) {
|
||||
super(entaxyResourceService);
|
||||
}
|
||||
*/
|
||||
|
||||
protected AbstractResourceComponentWithChildren(ResourceContext resourceContext) {
|
||||
super(resourceContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
initChildrenCache();
|
||||
}
|
||||
|
||||
protected void initChildrenCache() {
|
||||
synchronized (childrenCacheLock) {
|
||||
for (String key : getChildrenKeyList()) {
|
||||
try {
|
||||
C component = loadChild(key);
|
||||
if (component == null)
|
||||
continue;
|
||||
childrenCache.put(component);
|
||||
} catch (Exception e) {
|
||||
handleChildLoadException(key, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected C loadChild(String key) throws Exception {
|
||||
C component = createChildComponent(key);
|
||||
if (component == null)
|
||||
return null;
|
||||
component.init();
|
||||
return component;
|
||||
}
|
||||
|
||||
protected C createNewChild(String key) throws Exception {
|
||||
C component = createChildComponent(key);
|
||||
component.init();
|
||||
synchronized (childrenCacheLock) {
|
||||
addChildKey(key);
|
||||
updateRootResource();
|
||||
childrenCache.put(component);
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
||||
protected void removeChild(String key) throws Exception {
|
||||
synchronized (childrenCacheLock) {
|
||||
C component = childrenCache.get(key);
|
||||
if (component == null)
|
||||
return;
|
||||
component.delete();
|
||||
childrenCache.remove(key);
|
||||
removeChildKey(key);
|
||||
updateRootResource();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract C createChildComponent(String key) throws Exception;
|
||||
|
||||
protected abstract List<String> getChildrenKeyList();
|
||||
|
||||
protected abstract void addChildKey(String key);
|
||||
|
||||
protected abstract void removeChildKey(String key);
|
||||
|
||||
protected abstract void handleChildLoadException(String key, Exception e);
|
||||
}
|
@ -0,0 +1,246 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ru.entaxy.platform.integration.applications.ApplicationStorage.ApplicationImportContent;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplication;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplicationVersion;
|
||||
import ru.entaxy.platform.integration.applications.descriptor.ApplicationDescriptor;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ApplicationCausedException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ApplicationException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ApplicationImportCausedException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ApplicationVersionAlreadyExists;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.StorageException;
|
||||
import ru.entaxy.platform.integration.applications.impl.ExportImportHelper.ApplicationImporter;
|
||||
import ru.entaxy.platform.integration.applications.impl.StorageApplicationContentAdapter;
|
||||
import ru.entaxy.platform.integration.applications.impl.StorageImportAdapter;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.application.ApplicationComponent;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.application.ApplicationVersionComponent;
|
||||
|
||||
public class ApplicationStorageComponent extends AbstractResourceComponent<ApplicationStorageData>
|
||||
implements StorageImportAdapter {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ApplicationStorageComponent.class);
|
||||
|
||||
final protected Map<String, ApplicationComponent> applicationCache = new HashMap<>();
|
||||
|
||||
protected Object applicationCacheLock = new Object();
|
||||
|
||||
/*
|
||||
public ApplicationStorageComponent(EntaxyResourceService entaxyResourceService, String parentRootUrl) {
|
||||
super(entaxyResourceService);
|
||||
this.rootResourceFolderUrl = parentRootUrl.concat("/").concat("applications");
|
||||
}
|
||||
*/
|
||||
|
||||
public ApplicationStorageComponent(ResourceContext parentResourceContext) {
|
||||
super(parentResourceContext.subcontext("applications"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<ApplicationStorageData> getDataObjectClass() {
|
||||
return ApplicationStorageData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRootResourceName() {
|
||||
return ".applications";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ApplicationStorageData createDataObject() {
|
||||
return new ApplicationStorageData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentKey() {
|
||||
return "applications";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
initializeApplicationCache();
|
||||
}
|
||||
|
||||
protected void initializeApplicationCache() {
|
||||
synchronized (applicationCacheLock) {
|
||||
if (dataObject.applications == null)
|
||||
return;
|
||||
for (String applicationName : dataObject.applications) {
|
||||
ApplicationComponent comp = loadApplication(applicationName);
|
||||
if (comp != null)
|
||||
applicationCache.put(comp.getName(), comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected ApplicationComponent loadApplication(String applicationName) {
|
||||
try {
|
||||
ApplicationComponent component =
|
||||
new ApplicationComponent(resourceContext, applicationName);
|
||||
component.init();
|
||||
return component;
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error loading application [" + applicationName + "]", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean applicationExists(String applicationName) {
|
||||
return dataObject.hasApplication(applicationName);
|
||||
}
|
||||
|
||||
public List<ApplicationComponent> getApplications() {
|
||||
return new ArrayList<>(applicationCache.values());
|
||||
}
|
||||
|
||||
public ApplicationComponent getApplication(String applicationName) {
|
||||
return applicationCache.get(applicationName);
|
||||
}
|
||||
|
||||
protected ApplicationComponent getOrCreateApplication(String applicationName)
|
||||
throws ApplicationException, StorageException {
|
||||
ApplicationComponent result = getApplication(applicationName);
|
||||
if (result != null)
|
||||
return result;
|
||||
result = createApplication(applicationName);
|
||||
return result;
|
||||
}
|
||||
|
||||
public void addApplication(EntaxyApplication application) throws ApplicationException, StorageException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void removeApplication(EntaxyApplication application)
|
||||
throws ApplicationException, StorageException {
|
||||
synchronized (applicationCacheLock) {
|
||||
String applicationName = application.getName();
|
||||
ApplicationComponent comp = applicationCache.get(applicationName);
|
||||
if (comp == null)
|
||||
return;
|
||||
comp.delete();
|
||||
applicationCache.remove(applicationName);
|
||||
dataObject.removeApplication(applicationName);
|
||||
try {
|
||||
updateRootResource();
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error removing application [" + applicationName + "]", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected ApplicationComponent createApplication(String applicationName)
|
||||
throws ApplicationException, StorageException {
|
||||
try {
|
||||
ApplicationComponent component =
|
||||
new ApplicationComponent(resourceContext, applicationName);
|
||||
component.init();
|
||||
synchronized (applicationCacheLock) {
|
||||
dataObject.addApplication(applicationName);
|
||||
updateRootResource();
|
||||
applicationCache.put(component.getName(), component);
|
||||
}
|
||||
return component;
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error creating application [" + applicationName + "]", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ApplicationComponent createApplication(ApplicationImportContent importContent)
|
||||
throws ApplicationException, StorageException {
|
||||
|
||||
ApplicationImporter applicationImporter = new ApplicationImporter(this);
|
||||
String applicationName = "unknown";
|
||||
try {
|
||||
applicationImporter.executeImport(importContent);
|
||||
return getApplication(applicationImporter.getApplicationDescriptor().name);
|
||||
} catch (ApplicationException ae) {
|
||||
throw ae;
|
||||
} catch (StorageException se) {
|
||||
throw se;
|
||||
} catch (Exception e) {
|
||||
throw new ApplicationImportCausedException(applicationName, e);
|
||||
}
|
||||
}
|
||||
|
||||
// StorageImportAdapter implementation
|
||||
|
||||
@Override
|
||||
public void checkDescriptor(ApplicationDescriptor applicationDescriptor)
|
||||
throws ApplicationException, StorageException {
|
||||
String applicationName = applicationDescriptor.name;
|
||||
String applicationVersion = applicationDescriptor.version;
|
||||
ApplicationComponent appComponent = getApplication(applicationName);
|
||||
if (appComponent == null)
|
||||
return;
|
||||
if (appComponent.hasVersion(applicationVersion))
|
||||
throw new ApplicationVersionAlreadyExists(applicationName, applicationVersion);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageApplicationContentAdapter getContentAdapter(String applicationName,
|
||||
ApplicationDescriptor applicationDescriptor) throws ApplicationException, StorageException {
|
||||
String applicationVersion = applicationDescriptor.version;
|
||||
|
||||
ApplicationComponent applicationComponent = getOrCreateApplication(applicationName);
|
||||
try {
|
||||
if (applicationComponent.hasVersion(applicationVersion))
|
||||
throw new ApplicationVersionAlreadyExists(applicationName, applicationVersion);
|
||||
ApplicationVersionComponent versionComponent =
|
||||
applicationComponent.createVersion(applicationVersion);
|
||||
versionComponent.setDescriptor(applicationDescriptor);
|
||||
versionComponent.init();
|
||||
versionComponent.save();
|
||||
return versionComponent.adapt();
|
||||
} catch (ApplicationException | StorageException rethrow) {
|
||||
throw rethrow;
|
||||
} catch (Exception e) {
|
||||
throw new ApplicationCausedException(applicationName, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyApplicationVersion getVersion(String applicationName, String version)
|
||||
throws ApplicationException, StorageException {
|
||||
ApplicationComponent appComp = getApplication(applicationName);
|
||||
if (appComp == null)
|
||||
return null;
|
||||
return appComp.getVersion(version);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ApplicationStorageData {
|
||||
|
||||
List<String> applications;
|
||||
|
||||
public void addApplication(String applicationName) {
|
||||
if (applications == null)
|
||||
applications = new ArrayList<>();
|
||||
applications.add(applicationName);
|
||||
}
|
||||
|
||||
public void removeApplication(String applicationName) {
|
||||
if (applications != null)
|
||||
applications.remove(applicationName);
|
||||
}
|
||||
|
||||
public boolean hasApplication(String applicationName) {
|
||||
if (applications == null)
|
||||
return false;
|
||||
return applications.contains(applicationName);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class ComponentCache<T extends AbstractResourceComponent<?>> implements Map<String, T> {
|
||||
|
||||
final protected Map<String, T> cache = new HashMap<>();
|
||||
|
||||
synchronized public T put(T value) {
|
||||
return cache.put(value.getComponentKey(), value);
|
||||
}
|
||||
|
||||
public boolean has(T value) {
|
||||
return cache.containsKey(value.getComponentKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return cache.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return cache.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(Object key) {
|
||||
return cache.containsKey(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsValue(Object value) {
|
||||
return cache.containsValue(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get(Object key) {
|
||||
return cache.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
synchronized public T put(String key, T value) {
|
||||
return cache.put(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
synchronized public T remove(Object key) {
|
||||
return cache.remove(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
synchronized public void putAll(Map<? extends String, ? extends T> m) {
|
||||
cache.putAll(m);
|
||||
}
|
||||
|
||||
@Override
|
||||
synchronized public void clear() {
|
||||
cache.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> keySet() {
|
||||
return cache.keySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<T> values() {
|
||||
return cache.values();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Entry<String, T>> entrySet() {
|
||||
return cache.entrySet();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,164 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplicationProject;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ProjectException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.StorageException;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.project.ProjectComponent;
|
||||
|
||||
public class ProjectStorageComponent extends AbstractResourceComponent<ProjectStorageData> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ProjectStorageComponent.class);
|
||||
|
||||
final protected Map<String, ProjectComponent> projectCache = new HashMap<>();
|
||||
|
||||
protected Object projectCacheLock = new Object();
|
||||
|
||||
/*
|
||||
public ProjectStorageComponent(EntaxyResourceService entaxyResourceService, String parentRootUrl) {
|
||||
super(entaxyResourceService);
|
||||
this.rootResourceFolderUrl = parentRootUrl.concat("/").concat("projects");
|
||||
}
|
||||
*/
|
||||
|
||||
public ProjectStorageComponent(ResourceContext parentResourceContext) {
|
||||
super(parentResourceContext.subcontext("projects"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<ProjectStorageData> getDataObjectClass() {
|
||||
return ProjectStorageData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRootResourceName() {
|
||||
return ".projects";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ProjectStorageData createDataObject() {
|
||||
return new ProjectStorageData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentKey() {
|
||||
return "projects";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
initializeProjectCache();
|
||||
}
|
||||
|
||||
protected void initializeProjectCache() {
|
||||
synchronized (projectCacheLock) {
|
||||
if (dataObject.projects == null)
|
||||
return;
|
||||
for (String projectName : dataObject.projects) {
|
||||
ProjectComponent comp = loadProject(projectName);
|
||||
if (comp != null)
|
||||
projectCache.put(comp.getName(), comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected ProjectComponent loadProject(String projectName) {
|
||||
try {
|
||||
ProjectComponent component =
|
||||
new ProjectComponent(resourceContext, projectName);
|
||||
component.init();
|
||||
return component;
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error creating project [" + projectName + "]", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean projectExists(String projectName) {
|
||||
return dataObject.hasProject(projectName);
|
||||
}
|
||||
|
||||
public List<ProjectComponent> getProjects() {
|
||||
return new ArrayList<>(projectCache.values());
|
||||
}
|
||||
|
||||
public ProjectComponent getProject(String projectName) {
|
||||
return projectCache.get(projectName);
|
||||
}
|
||||
|
||||
public void addProject(EntaxyApplicationProject project) throws ProjectException, StorageException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void removeProject(EntaxyApplicationProject project)
|
||||
throws ProjectException, StorageException {
|
||||
synchronized (projectCacheLock) {
|
||||
String projectName = project.getName();
|
||||
ProjectComponent comp = projectCache.get(projectName);
|
||||
if (comp == null)
|
||||
return;
|
||||
comp.delete();
|
||||
projectCache.remove(projectName);
|
||||
dataObject.removeProject(projectName);
|
||||
try {
|
||||
updateRootResource();
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error removing project [" + projectName + "]", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ProjectComponent createProject(String projectName)
|
||||
throws ProjectException, StorageException {
|
||||
try {
|
||||
ProjectComponent component =
|
||||
new ProjectComponent(resourceContext, projectName);
|
||||
component.init();
|
||||
synchronized (projectCacheLock) {
|
||||
dataObject.addProject(component.getName());
|
||||
updateRootResource();
|
||||
projectCache.put(component.getName(), component);
|
||||
}
|
||||
return component;
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error creating project [" + projectName + "]", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ProjectStorageData {
|
||||
|
||||
List<String> projects;
|
||||
|
||||
public void addProject(String projectName) {
|
||||
if (projects == null)
|
||||
projects = new ArrayList<>();
|
||||
projects.add(projectName);
|
||||
}
|
||||
|
||||
public void removeProject(String projectName) {
|
||||
if (projects != null)
|
||||
projects.remove(projectName);
|
||||
}
|
||||
|
||||
public boolean hasProject(String projectName) {
|
||||
if (projects == null)
|
||||
return false;
|
||||
return projects.contains(projectName);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl;
|
||||
|
||||
import ru.entaxy.esb.resources.EntaxyResource;
|
||||
import ru.entaxy.esb.resources.EntaxyResourceService;
|
||||
|
||||
public class ResourceContext {
|
||||
|
||||
protected EntaxyResourceService entaxyResourceService;
|
||||
|
||||
protected EntaxyResource rootResourceFolder;
|
||||
|
||||
protected String rootResourceFolderUrl;
|
||||
|
||||
protected ResourceContext parent = null;
|
||||
|
||||
public ResourceContext() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ResourceContext(ResourceContext parent) {
|
||||
super();
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
EntaxyResourceService resourceService = getEntaxyResourceService();
|
||||
if (resourceService != null)
|
||||
this.rootResourceFolder = resourceService.getResource(rootResourceFolderUrl);
|
||||
}
|
||||
|
||||
public EntaxyResourceService getEntaxyResourceService() {
|
||||
if (entaxyResourceService != null)
|
||||
return entaxyResourceService;
|
||||
if (parent != null)
|
||||
return parent.getEntaxyResourceService();
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setEntaxyResourceService(EntaxyResourceService entaxyResourceService) {
|
||||
this.entaxyResourceService = entaxyResourceService;
|
||||
}
|
||||
|
||||
public EntaxyResource getRootResourceFolder() {
|
||||
return rootResourceFolder;
|
||||
}
|
||||
|
||||
public String getRootResourceFolderUrl() {
|
||||
return rootResourceFolderUrl;
|
||||
}
|
||||
|
||||
public void setRootResourceFolderUrl(String rootResourceFolderUrl) {
|
||||
this.rootResourceFolderUrl = rootResourceFolderUrl;
|
||||
}
|
||||
|
||||
public EntaxyResource getResource(String relPath) {
|
||||
String targetUrl = rootResourceFolderUrl;
|
||||
if (rootResourceFolderUrl.charAt(rootResourceFolderUrl.length() - 1) != '/')
|
||||
targetUrl = targetUrl.concat("/");
|
||||
if (relPath.charAt(0) == '/')
|
||||
targetUrl = targetUrl.concat(relPath.substring(1));
|
||||
else
|
||||
targetUrl = targetUrl.concat(relPath);
|
||||
EntaxyResource result = getEntaxyResourceService().getResource(targetUrl);
|
||||
return result;
|
||||
}
|
||||
|
||||
public ResourceContext subcontext(String subPath) {
|
||||
ResourceContext result = new ResourceContext(this);
|
||||
result.setRootResourceFolderUrl(rootResourceFolderUrl.concat("/").concat(subPath));
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ru.entaxy.platform.integration.applications.ApplicationStorage.ApplicationImportContent;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplication;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplicationProject;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ApplicationException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ProjectException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.StorageException;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.application.ApplicationComponent;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.project.ProjectComponent;
|
||||
|
||||
public class StorageComponent extends AbstractResourceComponent<StorageData> {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(StorageComponent.class);
|
||||
|
||||
String storageName;
|
||||
|
||||
protected ProjectStorageComponent projectStorageComponent;
|
||||
|
||||
protected ApplicationStorageComponent applicationStorageComponent;
|
||||
|
||||
/*
|
||||
public StorageComponent(EntaxyResourceService entaxyResourceService, String storageName, String rootFolderUrl) {
|
||||
super(entaxyResourceService);
|
||||
this.storageName = storageName;
|
||||
this.rootResourceFolderUrl = rootFolderUrl;
|
||||
projectStorageComponent = new ProjectStorageComponent(entaxyResourceService, rootResourceFolderUrl);
|
||||
applicationStorageComponent = new ApplicationStorageComponent(entaxyResourceService, rootResourceFolderUrl);
|
||||
}
|
||||
*/
|
||||
|
||||
public StorageComponent(ResourceContext resourceContext, String storageName) {
|
||||
super(resourceContext);
|
||||
this.storageName = storageName;
|
||||
projectStorageComponent = new ProjectStorageComponent(resourceContext);
|
||||
applicationStorageComponent = new ApplicationStorageComponent(resourceContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentKey() {
|
||||
return storageName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
projectStorageComponent.init();
|
||||
applicationStorageComponent.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<StorageData> getDataObjectClass() {
|
||||
return StorageData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRootResourceName() {
|
||||
return ".storage";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected StorageData createDataObject() {
|
||||
return new StorageData(storageName);
|
||||
}
|
||||
|
||||
public boolean applicationExists(String applicationName) {
|
||||
return applicationStorageComponent.applicationExists(applicationName);
|
||||
}
|
||||
|
||||
public List<ApplicationComponent> getApplications() {
|
||||
return applicationStorageComponent.getApplications();
|
||||
}
|
||||
|
||||
public ApplicationComponent getApplication(String applicationName) {
|
||||
return applicationStorageComponent.getApplication(applicationName);
|
||||
}
|
||||
|
||||
public void addApplication(EntaxyApplication application) throws ApplicationException, StorageException {
|
||||
applicationStorageComponent.addApplication(application);
|
||||
}
|
||||
|
||||
public void removeApplication(EntaxyApplication application)
|
||||
throws ApplicationException, StorageException {
|
||||
applicationStorageComponent.removeApplication(application);
|
||||
}
|
||||
|
||||
public ApplicationComponent createApplication(String applicationName)
|
||||
throws ApplicationException, StorageException {
|
||||
return applicationStorageComponent.createApplication(applicationName);
|
||||
}
|
||||
|
||||
public ApplicationComponent createApplication(ApplicationImportContent importContent)
|
||||
throws ApplicationException, StorageException {
|
||||
return applicationStorageComponent.createApplication(importContent);
|
||||
}
|
||||
|
||||
public boolean projectExists(String projectName) {
|
||||
return projectStorageComponent.projectExists(projectName);
|
||||
}
|
||||
|
||||
public List<ProjectComponent> getProjects() {
|
||||
return projectStorageComponent.getProjects();
|
||||
}
|
||||
|
||||
public ProjectComponent getProject(String projectName) {
|
||||
return projectStorageComponent.getProject(projectName);
|
||||
}
|
||||
|
||||
public void addProject(EntaxyApplicationProject project) throws ProjectException, StorageException {
|
||||
projectStorageComponent.addProject(project);
|
||||
}
|
||||
|
||||
public void removeProject(EntaxyApplicationProject project)
|
||||
throws ProjectException, StorageException {
|
||||
projectStorageComponent.removeProject(project);
|
||||
}
|
||||
|
||||
public ProjectComponent createProject(String projectName)
|
||||
throws ProjectException, StorageException {
|
||||
return projectStorageComponent.createProject(projectName);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl;
|
||||
|
||||
public class StorageData {
|
||||
|
||||
boolean enabled = true;
|
||||
String name;
|
||||
|
||||
public StorageData(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,173 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl.application;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ru.entaxy.platform.integration.applications.ApplicationStorage;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplication;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplicationVersion;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ApplicationVersionAlreadyExists;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.AbstractResourceComponentWithChildren;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.ResourceContext;
|
||||
|
||||
public class ApplicationComponent
|
||||
extends AbstractResourceComponentWithChildren<ApplicationData, ApplicationVersionComponent>
|
||||
implements EntaxyApplication {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ApplicationComponent.class);
|
||||
|
||||
protected String applicationName;
|
||||
|
||||
protected ApplicationStorage applicationStorage;
|
||||
|
||||
/*
|
||||
public ApplicationComponent(EntaxyResourceService resourceService, String applicationName, String parentRootUrl) {
|
||||
super(resourceService);
|
||||
setEntaxyResourceService(resourceService);
|
||||
this.applicationName = applicationName;
|
||||
this.rootResourceFolderUrl = parentRootUrl.concat("/").concat(applicationName);
|
||||
}
|
||||
*/
|
||||
|
||||
public ApplicationComponent(ResourceContext resourceContext, String applicationName) {
|
||||
super(resourceContext.subcontext(applicationName));
|
||||
this.applicationName = applicationName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<ApplicationData> getDataObjectClass() {
|
||||
return ApplicationData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRootResourceName() {
|
||||
return ".application";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ApplicationData createDataObject() {
|
||||
return new ApplicationData(applicationName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentKey() {
|
||||
return applicationName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ApplicationVersionComponent createChildComponent(String key) throws Exception {
|
||||
return new ApplicationVersionComponent(resourceContext, key, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getChildrenKeyList() {
|
||||
if (dataObject.versions == null)
|
||||
return Collections.emptyList();
|
||||
return new ArrayList<>(dataObject.versions.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addChildKey(String key) {
|
||||
dataObject.addVersion(key, Calendar.getInstance().getTimeInMillis() + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeChildKey(String key) {
|
||||
dataObject.removeVersion(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleChildLoadException(String key, Exception e) {
|
||||
log.error("Error loading version [" + key + "]", e);
|
||||
}
|
||||
|
||||
public ApplicationVersionComponent createVersion(String versionNumber) throws Exception {
|
||||
if (hasVersion(versionNumber))
|
||||
throw new ApplicationVersionAlreadyExists(applicationName, versionNumber);
|
||||
ApplicationVersionComponent result = createChildComponent(versionNumber);
|
||||
synchronized (childrenCacheLock) {
|
||||
dataObject.addVersion(versionNumber);
|
||||
updateRootResource();
|
||||
childrenCache.put(result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public ApplicationComponent storage(ApplicationStorage storage) {
|
||||
this.applicationStorage = storage;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasVersion(String versionNumber) {
|
||||
return dataObject.hasVersion(versionNumber);
|
||||
}
|
||||
|
||||
/* EntaxyApplication implementation */
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return applicationName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationStorage getStorage() {
|
||||
return this.applicationStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntaxyApplicationVersion> getVersions() {
|
||||
return new ArrayList<>(childrenCache.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyApplicationVersion getLatestVersion() {
|
||||
return childrenCache.get(dataObject.getLatestVersion());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyApplicationVersion getVersion(String version) {
|
||||
return childrenCache.get(version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeVersion(String version) {
|
||||
try {
|
||||
removeChild(version);
|
||||
} catch (Exception e) {
|
||||
log.error("Error removing version [" + version + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl.application;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
|
||||
public class ApplicationData {
|
||||
String name;
|
||||
|
||||
Map<String, String> versions;
|
||||
|
||||
public ApplicationData(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean hasVersion(String versionNumber) {
|
||||
return versions != null && versions.containsKey(versionNumber);
|
||||
}
|
||||
|
||||
public void addVersion(String version) {
|
||||
addVersion(version, Calendar.getInstance().getTimeInMillis() + "");
|
||||
}
|
||||
|
||||
public void addVersion(String version, String timestamp) {
|
||||
if (versions == null)
|
||||
versions = new HashMap<>();
|
||||
if (!versions.containsKey(version))
|
||||
versions.put(version, timestamp);
|
||||
}
|
||||
|
||||
public void removeVersion(String version) {
|
||||
if (versions == null)
|
||||
return;
|
||||
versions.remove(version);
|
||||
}
|
||||
|
||||
public String getLatestVersion() {
|
||||
Optional<Entry<String, String>> latest =
|
||||
versions.entrySet().stream().sorted(new Comparator<Map.Entry<String, String>>() {
|
||||
|
||||
@Override
|
||||
public int compare(Entry<String, String> o1, Entry<String, String> o2) {
|
||||
// reverse order
|
||||
return -1 * o1.getValue().compareTo(o2.getValue());
|
||||
}
|
||||
}).findFirst();
|
||||
if (!latest.isPresent())
|
||||
return null;
|
||||
return latest.get().getKey();
|
||||
}
|
||||
}
|
@ -0,0 +1,282 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl.application;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import ru.entaxy.esb.resources.EntaxyResource;
|
||||
import ru.entaxy.platform.integration.applications.ApplicationContent;
|
||||
import ru.entaxy.platform.integration.applications.ApplicationItem;
|
||||
import ru.entaxy.platform.integration.applications.ApplicationResource;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplication;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplicationRevision;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplicationVersion;
|
||||
import ru.entaxy.platform.integration.applications.descriptor.ApplicationDescriptor;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ApplicationVersionCausedException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ApplicationVersionException;
|
||||
import ru.entaxy.platform.integration.applications.impl.StorageApplicationContentAdapter;
|
||||
import ru.entaxy.platform.integration.applications.impl.StorageItemAdapter;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.AbstractResourceComponentWithChildren;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.ResourceContext;
|
||||
|
||||
public class ApplicationVersionComponent
|
||||
extends AbstractResourceComponentWithChildren<ApplicationVersionData, RevisionComponent>
|
||||
implements EntaxyApplicationVersion {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ApplicationVersionComponent.class);
|
||||
|
||||
protected String versionNumber;
|
||||
|
||||
protected ApplicationComponent applicationComponent;
|
||||
|
||||
protected ResourceApplicationContent applicationContent;
|
||||
|
||||
/*
|
||||
public ApplicationVersionComponent(EntaxyResourceService resourceService, String versionNumber,
|
||||
String parentRootUrl, ApplicationComponent applicationComponent) {
|
||||
super(resourceService);
|
||||
setEntaxyResourceService(resourceService);
|
||||
this.versionNumber = versionNumber;
|
||||
this.rootResourceFolderUrl = parentRootUrl.concat("/").concat(versionNumber);
|
||||
this.applicationComponent = applicationComponent;
|
||||
this.applicationContent = new ResourceApplicationContent(new ApplicationDescriptor());
|
||||
}
|
||||
*/
|
||||
|
||||
public ApplicationVersionComponent(ResourceContext parentResourceContext, String versionNumber,
|
||||
ApplicationComponent applicationComponent) {
|
||||
super(parentResourceContext.subcontext(versionNumber));
|
||||
this.versionNumber = versionNumber;
|
||||
this.applicationComponent = applicationComponent;
|
||||
this.applicationContent = ResourceApplicationContent.fromContext(this.resourceContext.subcontext(".content"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<ApplicationVersionData> getDataObjectClass() {
|
||||
return ApplicationVersionData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRootResourceName() {
|
||||
return ".version";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ApplicationVersionData createDataObject() {
|
||||
return new ApplicationVersionData(versionNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentKey() {
|
||||
return versionNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RevisionComponent createChildComponent(String key) throws Exception {
|
||||
// return new RevisionComponent(entaxyResourceService, this, key);
|
||||
return new RevisionComponent(resourceContext, this, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getChildrenKeyList() {
|
||||
if (dataObject.revisions == null)
|
||||
return Collections.emptyList();
|
||||
return dataObject.getRevisionKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addChildKey(String key) {
|
||||
dataObject.addRevision(key, Calendar.getInstance().getTimeInMillis() + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeChildKey(String key) {
|
||||
dataObject.removeRevision(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleChildLoadException(String key, Exception e) {
|
||||
log.error("Error loading revision [" + key + "]", e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
if (applicationContent != null && applicationContent.getDescriptor() != null) {
|
||||
JsonElement je = GSON.toJsonTree(applicationContent.getDescriptor());
|
||||
EntaxyResource descriptorResource =
|
||||
applicationContent.getResourceContext().getResource(EntaxyApplication.DESCRIPTOR_NAME);
|
||||
try (InputStream is = IOUtils.toInputStream(je.toString())) {
|
||||
descriptorResource.save(is);
|
||||
} catch (IOException e) {
|
||||
log.error("Error saving descriptor to [" + descriptorResource.getURL() + "]", e);
|
||||
}
|
||||
}
|
||||
super.save();
|
||||
}
|
||||
|
||||
public void setDescriptor(ApplicationDescriptor applicationDescriptor) {
|
||||
this.applicationContent.setDescriptor(applicationDescriptor);
|
||||
}
|
||||
|
||||
/* EntaxyApplicationVersion implementation */
|
||||
|
||||
@Override
|
||||
public String getVersionNumber() {
|
||||
return versionNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntaxyApplicationRevision> getRevisions() {
|
||||
return childrenCache.values().stream().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyApplicationRevision getLastRevision() {
|
||||
try {
|
||||
return getRevision(dataObject.getLastRevision());
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyApplicationRevision getRevision(int revision) {
|
||||
return childrenCache.get(revision + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyApplicationRevision createRevision(int fromRevision)
|
||||
throws ApplicationVersionException {
|
||||
RevisionComponent revisionComponent;
|
||||
try {
|
||||
int last = dataObject.getLastRevision();
|
||||
int revisionNumber = -1;
|
||||
ApplicationContent source = null;
|
||||
if (last == -1) {
|
||||
revisionNumber = 0;
|
||||
source = this;
|
||||
|
||||
} else {
|
||||
revisionNumber = last + 1;
|
||||
int sourceRevision = fromRevision;
|
||||
if (sourceRevision < 0)
|
||||
sourceRevision = last;
|
||||
RevisionComponent sourceComponent = childrenCache.get(sourceRevision + "");
|
||||
source = sourceComponent;
|
||||
}
|
||||
if (revisionNumber < 0)
|
||||
throw new InstantiationException("Failed defining new revision number");
|
||||
|
||||
ApplicationDescriptor sourceDescriptor = source.getDescriptor();
|
||||
|
||||
revisionComponent = createChildComponent(revisionNumber + "");
|
||||
revisionComponent.init();
|
||||
revisionComponent.setDescriptor(sourceDescriptor);
|
||||
revisionComponent.save();
|
||||
StorageApplicationContentAdapter adapted = revisionComponent.adapt();
|
||||
|
||||
ApplicationDescriptor revisionDescriptor = revisionComponent.getDescriptor();
|
||||
|
||||
// we copy only items, not resources
|
||||
Map<String, ApplicationItem> itemMap =
|
||||
source.getItems().stream().collect(Collectors.toMap(item -> item.getLocation(), item -> item));
|
||||
List<ru.entaxy.platform.integration.applications.descriptor.ApplicationComponent> components =
|
||||
new ArrayList<>();
|
||||
components.add(revisionDescriptor.getFeatures());
|
||||
components.addAll(revisionDescriptor.getComponents());
|
||||
|
||||
for (ru.entaxy.platform.integration.applications.descriptor.ApplicationComponent component : components) {
|
||||
if (!itemMap.containsKey(component.getInternalLocation()))
|
||||
continue;
|
||||
StorageItemAdapter itemAdapter = adapted.createItem(component);
|
||||
try (InputStream is = itemMap.get(component.getInternalLocation()).getInputStream()) {
|
||||
itemAdapter.write(is);
|
||||
}
|
||||
}
|
||||
|
||||
revisionComponent.save();
|
||||
|
||||
// finalize
|
||||
|
||||
synchronized (childrenCacheLock) {
|
||||
dataObject.addRevision(revisionNumber, Calendar.getInstance().getTimeInMillis() + "");
|
||||
updateRootResource();
|
||||
childrenCache.put(revisionComponent);
|
||||
}
|
||||
|
||||
} catch (ApplicationVersionException rethrow) {
|
||||
throw rethrow;
|
||||
} catch (Exception e) {
|
||||
throw new ApplicationVersionCausedException(applicationComponent.getName(), e, versionNumber);
|
||||
}
|
||||
|
||||
return revisionComponent;
|
||||
}
|
||||
|
||||
public StorageApplicationContentAdapter adapt() {
|
||||
return applicationContent;
|
||||
}
|
||||
|
||||
protected ApplicationDescriptor createCopy(ApplicationDescriptor origin) throws Exception {
|
||||
return GSON.fromJson(GSON.toJsonTree(origin, ApplicationDescriptor.class).deepCopy(),
|
||||
ApplicationDescriptor.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyApplication getApplication() {
|
||||
return applicationComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationDescriptor getDescriptor() {
|
||||
return applicationContent.getDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApplicationItem> getItems() {
|
||||
return applicationContent.getItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApplicationResource> getResources() {
|
||||
return applicationContent.getResources();
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl.application;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
|
||||
public class ApplicationVersionData {
|
||||
|
||||
String versionNumber;
|
||||
|
||||
Map<String, String> revisions;
|
||||
|
||||
public ApplicationVersionData(String versionNumber) {
|
||||
this.versionNumber = versionNumber;
|
||||
}
|
||||
|
||||
public void addRevision(int revisionNumber, String timestamp) {
|
||||
addRevision(revisionNumber + "", timestamp);
|
||||
}
|
||||
|
||||
public void addRevision(String revisionNumber, String timestamp) {
|
||||
if (revisions == null)
|
||||
revisions = new HashMap<>();
|
||||
if (!revisions.containsKey(revisionNumber))
|
||||
revisions.put(revisionNumber, timestamp);
|
||||
}
|
||||
|
||||
public void removeRevision(int revisionNumber) {
|
||||
removeRevision(revisionNumber + "");
|
||||
}
|
||||
|
||||
public void removeRevision(String revisionNumber) {
|
||||
if (revisions == null)
|
||||
return;
|
||||
revisions.remove(revisionNumber);
|
||||
}
|
||||
|
||||
public String getLatestRevision() {
|
||||
Optional<Entry<String, String>> latest =
|
||||
revisions.entrySet().stream().sorted(new Comparator<Map.Entry<String, String>>() {
|
||||
|
||||
@Override
|
||||
public int compare(Entry<String, String> o1, Entry<String, String> o2) {
|
||||
// reverse order
|
||||
return -1 * o1.getValue().compareTo(o2.getValue());
|
||||
}
|
||||
}).findFirst();
|
||||
if (!latest.isPresent())
|
||||
return null;
|
||||
return latest.get().getKey();
|
||||
}
|
||||
|
||||
public int getLastRevision() {
|
||||
if (revisions == null || revisions.isEmpty())
|
||||
return -1;
|
||||
return revisions.keySet().stream().mapToInt(v -> Integer.parseInt(v)).max().orElse(-1);
|
||||
}
|
||||
|
||||
public List<String> getRevisionKeys() {
|
||||
if (revisions == null)
|
||||
return Collections.emptyList();
|
||||
return new ArrayList<>(revisions.keySet());
|
||||
}
|
||||
}
|
@ -0,0 +1,141 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl.application;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
import ru.entaxy.esb.resources.EntaxyResource;
|
||||
import ru.entaxy.platform.base.support.JSONUtils;
|
||||
import ru.entaxy.platform.integration.applications.ApplicationResource;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplication;
|
||||
import ru.entaxy.platform.integration.applications.descriptor.ApplicationComponent;
|
||||
import ru.entaxy.platform.integration.applications.descriptor.ApplicationDescriptor;
|
||||
import ru.entaxy.platform.integration.applications.impl.StorageApplicationContentAdapter;
|
||||
import ru.entaxy.platform.integration.applications.impl.StorageItemAdapter;
|
||||
import ru.entaxy.platform.integration.applications.impl.application.ApplicationContentImpl;
|
||||
import ru.entaxy.platform.integration.applications.impl.application.ApplicationItemImpl;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.ResourceContext;
|
||||
|
||||
public class ResourceApplicationContent extends ApplicationContentImpl implements StorageApplicationContentAdapter {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ResourceApplicationContent.class);
|
||||
|
||||
private static Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
protected boolean isDirty = false;
|
||||
|
||||
public static ResourceApplicationContent fromContext(ResourceContext resourceContext) {
|
||||
|
||||
// check descriptor
|
||||
ApplicationDescriptor applicationDescriptor = null;
|
||||
EntaxyResource descriptorResource = resourceContext.getResource(EntaxyApplication.DESCRIPTOR_NAME);
|
||||
if (descriptorResource.exists()) {
|
||||
// try (InputStream is = descriptorResource.getInputStream()) {
|
||||
try {
|
||||
applicationDescriptor = GSON.fromJson(JSONUtils.getJsonRootObject(descriptorResource.getAsString()),
|
||||
ApplicationDescriptor.class);
|
||||
} catch (Exception ignore) {
|
||||
LOG.error("Error reading descriptor [" + descriptorResource.getURL() + "]", ignore);
|
||||
}
|
||||
}
|
||||
|
||||
if (applicationDescriptor == null)
|
||||
return new ResourceApplicationContent(new ApplicationDescriptor(), resourceContext);
|
||||
|
||||
ResourceApplicationContent result = new ResourceApplicationContent(applicationDescriptor, resourceContext);
|
||||
try {
|
||||
result.readDescriptor();
|
||||
} catch (Exception ignore) {
|
||||
LOG.error("Error processing descriptor [" + descriptorResource.getURL() + "]", ignore);
|
||||
return new ResourceApplicationContent(new ApplicationDescriptor(), resourceContext);
|
||||
}
|
||||
return result;
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected ResourceContext resourceContext;
|
||||
|
||||
public ResourceApplicationContent(ApplicationDescriptor descriptor, ResourceContext resourceContext) {
|
||||
super(descriptor);
|
||||
this.resourceContext = resourceContext;
|
||||
}
|
||||
|
||||
public void readDescriptor() throws Exception {
|
||||
createItem(descriptor.features);
|
||||
|
||||
for (ApplicationComponent comp : descriptor.getComponents())
|
||||
createItem(comp);
|
||||
}
|
||||
|
||||
public ResourceContext getResourceContext() {
|
||||
return resourceContext;
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
return isDirty;
|
||||
}
|
||||
|
||||
protected void setDirty(boolean isDirty) {
|
||||
this.isDirty = isDirty;
|
||||
}
|
||||
|
||||
public void save() {
|
||||
setDirty(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageItemAdapter createItem(ApplicationComponent applicationComponent) throws Exception {
|
||||
ResourceApplicationItem item = new ResourceApplicationItem(applicationComponent, resourceContext);
|
||||
this.items.put(item.getLocation(), item);
|
||||
setDirty(true);
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationResource createResource(String location, InputStream inputStream) throws Exception {
|
||||
ResourceApplicationResource res = new ResourceApplicationResource(resourceContext, location);
|
||||
res.write(inputStream);
|
||||
this.resources.put(location, res);
|
||||
setDirty(true);
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public StorageItemAdapter getItemAdapter(String location) throws Exception {
|
||||
ApplicationItemImpl item = this.items.get(location);
|
||||
if (item instanceof ResourceApplicationItem)
|
||||
return (ResourceApplicationItem) item;
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl.application;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import ru.entaxy.esb.resources.EntaxyResource;
|
||||
import ru.entaxy.platform.integration.applications.descriptor.ApplicationComponent;
|
||||
import ru.entaxy.platform.integration.applications.impl.StorageItemAdapter;
|
||||
import ru.entaxy.platform.integration.applications.impl.application.ApplicationItemImpl;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.ResourceContext;
|
||||
|
||||
public class ResourceApplicationItem extends ApplicationItemImpl implements StorageItemAdapter {
|
||||
|
||||
protected ResourceContext resourceContext;
|
||||
|
||||
public ResourceApplicationItem(ApplicationComponent applicationComponent, ResourceContext resourceContext) {
|
||||
super(applicationComponent, null);
|
||||
this.resourceContext = resourceContext;
|
||||
this.itemAdapter = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getInputStream() {
|
||||
EntaxyResource resource = resourceContext.getResource(getLocation());
|
||||
return resource.getInputStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(InputStream source) throws Exception {
|
||||
EntaxyResource resource = resourceContext.getResource(getLocation());
|
||||
resource.save(source);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl.application;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import ru.entaxy.esb.resources.EntaxyResource;
|
||||
import ru.entaxy.platform.integration.applications.impl.application.ApplicationResourceImpl;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.ResourceContext;
|
||||
|
||||
public class ResourceApplicationResource extends ApplicationResourceImpl {
|
||||
|
||||
protected ResourceContext resourceContext;
|
||||
|
||||
protected String location;
|
||||
|
||||
public ResourceApplicationResource(ResourceContext resourceContext, String location) {
|
||||
super();
|
||||
this.resourceContext = resourceContext;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public void write(InputStream source) {
|
||||
EntaxyResource resource = resourceContext.getResource(location);
|
||||
resource.save(source);
|
||||
}
|
||||
}
|
@ -0,0 +1,273 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl.application;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import ru.entaxy.esb.resources.EntaxyResource;
|
||||
import ru.entaxy.platform.core.artifact.ArtifactCoordinates;
|
||||
import ru.entaxy.platform.integration.applications.ApplicationItem;
|
||||
import ru.entaxy.platform.integration.applications.ApplicationResource;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplication;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplicationRevision;
|
||||
import ru.entaxy.platform.integration.applications.descriptor.ApplicationComponent;
|
||||
import ru.entaxy.platform.integration.applications.descriptor.ApplicationDescriptor;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.RevisionException;
|
||||
import ru.entaxy.platform.integration.applications.impl.StorageApplicationContentAdapter;
|
||||
import ru.entaxy.platform.integration.applications.impl.application.RevisionHelper;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.AbstractResourceComponent;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.ResourceContext;
|
||||
|
||||
public class RevisionComponent extends AbstractResourceComponent<RevisionData>
|
||||
implements EntaxyApplicationRevision, RevisionHelper.RevisionHelperAdapter {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RevisionComponent.class);
|
||||
|
||||
int revisionNumber;
|
||||
|
||||
ApplicationVersionComponent versionComponent;
|
||||
|
||||
ResourceApplicationContent applicationContent;
|
||||
|
||||
final String CONTENT_RESOURCE_NAME = "version.content";
|
||||
|
||||
// REVISION_STATUS status = REVISION_STATUS.NEW;
|
||||
|
||||
/*
|
||||
public RevisionComponent(EntaxyResourceService entaxyResourceService,
|
||||
ApplicationVersionComponent versionComponent,
|
||||
String revisionNumber) {
|
||||
super(entaxyResourceService);
|
||||
this.revisionNumber = revisionNumber;
|
||||
this.versionComponent = versionComponent;
|
||||
this.rootResourceFolderUrl =
|
||||
versionComponent.getRootResourceFolderUrl().concat("/").concat(this.revisionNumber);
|
||||
applicationContent.getProperties().put(STANDARD_PROPERTIES.APPLICATION, versionComponent.getVersionNumber());
|
||||
applicationContent.getProperties().put(STANDARD_PROPERTIES.VERSION, revisionNumber);
|
||||
|
||||
// buildComponent = new BuildComponent(entaxyResourceService, rootResourceFolderUrl);
|
||||
}
|
||||
*/
|
||||
|
||||
public RevisionComponent(ResourceContext resourceContext,
|
||||
ApplicationVersionComponent versionComponent,
|
||||
int revisionNumber) {
|
||||
super(resourceContext.subcontext(revisionNumber + ""));
|
||||
this.revisionNumber = revisionNumber;
|
||||
this.versionComponent = versionComponent;
|
||||
applicationContent = ResourceApplicationContent.fromContext(this.resourceContext.subcontext(".content"));
|
||||
}
|
||||
|
||||
public RevisionComponent(ResourceContext resourceContext,
|
||||
ApplicationVersionComponent versionComponent,
|
||||
String revisionNumber) {
|
||||
this(resourceContext, versionComponent, Integer.parseInt(revisionNumber));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<RevisionData> getDataObjectClass() {
|
||||
return RevisionData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRootResourceName() {
|
||||
return ".revision";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RevisionData createDataObject() {
|
||||
return new RevisionData(this.revisionNumber + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentKey() {
|
||||
return revisionNumber + "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
initContent();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
if (applicationContent != null)
|
||||
if (applicationContent.isDirty) {
|
||||
if (revisionNumber > 0) {
|
||||
try {
|
||||
RevisionHelper helper = new RevisionHelper(applicationContent, this);
|
||||
helper.update();
|
||||
} catch (Exception e) {
|
||||
LOG.error("ERROR saving revision", e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
applicationContent.save();
|
||||
}
|
||||
if (applicationContent != null && applicationContent.getDescriptor() != null) {
|
||||
JsonElement je = GSON.toJsonTree(applicationContent.getDescriptor());
|
||||
EntaxyResource descriptorResource =
|
||||
applicationContent.getResourceContext().getResource(EntaxyApplication.DESCRIPTOR_NAME);
|
||||
try (InputStream is = IOUtils.toInputStream(je.toString())) {
|
||||
descriptorResource.save(is);
|
||||
} catch (IOException e) {
|
||||
LOG.error("Error saving descriptor to [" + descriptorResource.getURL() + "]", e);
|
||||
}
|
||||
}
|
||||
super.save();
|
||||
}
|
||||
|
||||
protected void initContent() {}
|
||||
|
||||
public StorageApplicationContentAdapter adapt() {
|
||||
return applicationContent;
|
||||
}
|
||||
|
||||
public void setDescriptor(ApplicationDescriptor applicationDescriptor) {
|
||||
try {
|
||||
this.applicationContent.setDescriptor(createCopy(applicationDescriptor));
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error setting descriptor", e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
protected ApplicationDescriptor createCopy(ApplicationDescriptor origin) throws Exception {
|
||||
return GSON.fromJson(GSON.toJsonTree(origin, ApplicationDescriptor.class).deepCopy(),
|
||||
ApplicationDescriptor.class);
|
||||
}
|
||||
|
||||
protected void changeDescriptorComponentsVersion() {
|
||||
List<ApplicationComponent> components = new ArrayList<>();
|
||||
components.add(applicationContent.getDescriptor().features);
|
||||
|
||||
components.addAll(applicationContent.getDescriptor().getComponents());
|
||||
|
||||
List<String> revisionableIds = applicationContent.getItems().stream().filter(item -> item.isRevisionable())
|
||||
.map(item -> item.getId()).collect(Collectors.toList());
|
||||
|
||||
for (ApplicationComponent component : components) {
|
||||
|
||||
if (!revisionableIds.contains(component.id))
|
||||
continue;
|
||||
|
||||
ArtifactCoordinates coordinates = ArtifactCoordinates.fromUrl(component.mavenLocation);
|
||||
coordinates.qualifier(String.format("REV_%03d", revisionNumber));
|
||||
component.mavenLocation = coordinates.toMavenString();
|
||||
coordinates = ArtifactCoordinates.fromUrl(component.targetLocation);
|
||||
coordinates.qualifier(String.format("REV_%03d", revisionNumber));
|
||||
component.targetLocation = coordinates.toMavenString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* EntaxyApplicationRevision implementation */
|
||||
|
||||
|
||||
@Override
|
||||
public int getRevisionNumber() {
|
||||
return revisionNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public REVISION_STATUS getStatus() {
|
||||
return dataObject.getStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configure() throws RevisionException {
|
||||
RevisionHelper helper = new RevisionHelper(applicationContent, this);
|
||||
helper.configure();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deploy() throws RevisionException {
|
||||
RevisionHelper helper = new RevisionHelper(applicationContent, this);
|
||||
helper.deploy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void install() throws RevisionException {
|
||||
RevisionHelper helper = new RevisionHelper(applicationContent, this);
|
||||
helper.install();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uninstall() throws RevisionException {
|
||||
RevisionHelper helper = new RevisionHelper(applicationContent, this);
|
||||
helper.uninstall();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationDescriptor getDescriptor() {
|
||||
return applicationContent.getDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApplicationItem> getItems() {
|
||||
return applicationContent.getItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApplicationResource> getResources() {
|
||||
return applicationContent.getResources();
|
||||
}
|
||||
|
||||
// RevisionHelper.RevisionHelperAdapter implementation
|
||||
|
||||
@Override
|
||||
public REVISION_STATUS getCurrentStatus() {
|
||||
return getStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatus(REVISION_STATUS newStatus) {
|
||||
this.dataObject.status = newStatus;
|
||||
try {
|
||||
updateRootResource();
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error updating root resource", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeItem(String location, InputStream inputStream) throws Exception {
|
||||
applicationContent.getItemAdapter(location).write(inputStream);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl.application;
|
||||
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplicationRevision.REVISION_STATUS;
|
||||
|
||||
public class RevisionData {
|
||||
|
||||
int revisionNumber;
|
||||
|
||||
REVISION_STATUS status;
|
||||
|
||||
public RevisionData(String revisionNumber) {
|
||||
this.revisionNumber = Integer.parseInt(revisionNumber);
|
||||
}
|
||||
|
||||
public REVISION_STATUS getStatus() {
|
||||
if (status == null)
|
||||
return REVISION_STATUS.NEW;
|
||||
return status;
|
||||
}
|
||||
}
|
@ -0,0 +1,154 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl.project;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import ru.entaxy.esb.resources.EntaxyResource;
|
||||
import ru.entaxy.platform.base.support.CommonUtils;
|
||||
import ru.entaxy.platform.base.support.JSONUtils;
|
||||
import ru.entaxy.platform.core.artifact.ArtifactCoordinates;
|
||||
import ru.entaxy.platform.integration.applications.descriptor.ApplicationDescriptor;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.AbstractResourceComponent;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.ResourceContext;
|
||||
|
||||
public class BuildComponent extends AbstractResourceComponent<BuildData> {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BuildComponent.class);
|
||||
|
||||
protected EntaxyResource buildResource;
|
||||
protected EntaxyResource descriptorResource;
|
||||
|
||||
protected ApplicationDescriptor applicationDescriptor;
|
||||
|
||||
/*
|
||||
protected BuildComponent(EntaxyResourceService entaxyResourceService, String parentRootUrl) {
|
||||
super(entaxyResourceService);
|
||||
this.rootResourceFolderUrl = parentRootUrl.concat("/").concat(".build");
|
||||
}
|
||||
*/
|
||||
|
||||
protected BuildComponent(ResourceContext parentResourceContext) {
|
||||
super(parentResourceContext.subcontext(".build"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<BuildData> getDataObjectClass() {
|
||||
return BuildData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRootResourceName() {
|
||||
return "build-info";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected BuildData createDataObject() {
|
||||
return new BuildData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentKey() {
|
||||
return "build";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
descriptorResource = getResource("descriptor.json");
|
||||
refresh();
|
||||
}
|
||||
|
||||
public void refresh() {
|
||||
if (CommonUtils.isValid(dataObject.name)) {
|
||||
buildResource = getResource(dataObject.name);
|
||||
if (descriptorResource.exists())
|
||||
applicationDescriptor = GSON.fromJson(JSONUtils.getJsonRootObject(descriptorResource.getAsString()),
|
||||
ApplicationDescriptor.class);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBuild(URL resultUrl, ApplicationDescriptor descriptor, ArtifactCoordinates coordinates) {
|
||||
|
||||
if (isBuildAvailable())
|
||||
buildResource.delete();
|
||||
|
||||
dataObject.artifactId = coordinates.getArtifactId();
|
||||
dataObject.groupId = coordinates.getGroupId();
|
||||
dataObject.version = coordinates.getVersion();
|
||||
dataObject.name = coordinates.toAssetName();
|
||||
try {
|
||||
updateRootResource();
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error updateing root resource", e);
|
||||
return;
|
||||
}
|
||||
|
||||
applicationDescriptor = null;
|
||||
|
||||
// (re)init resources
|
||||
refresh();
|
||||
|
||||
JsonElement descriptorJe = GSON.toJsonTree(descriptor, ApplicationDescriptor.class);
|
||||
String descriptorJson = descriptorJe.toString();
|
||||
try (InputStream is = new ByteArrayInputStream(descriptorJson.getBytes())) {
|
||||
descriptorResource.save(is);
|
||||
} catch (IOException e) {
|
||||
LOG.error("Error saving resource [" + descriptorResource.getURL() + "]", e);
|
||||
}
|
||||
|
||||
try (InputStream is = resultUrl.openStream()) {
|
||||
buildResource.save(is);
|
||||
} catch (IOException e) {
|
||||
LOG.error("Error saving resource [" + descriptorResource.getURL() + "]", e);
|
||||
}
|
||||
|
||||
applicationDescriptor = GSON.fromJson(descriptorJe,
|
||||
ApplicationDescriptor.class);
|
||||
|
||||
}
|
||||
|
||||
public boolean isBuildAvailable() {
|
||||
return buildResource != null && buildResource.exists();
|
||||
}
|
||||
|
||||
public EntaxyResource getBuildResource() {
|
||||
return buildResource;
|
||||
}
|
||||
|
||||
public ApplicationDescriptor getApplicationDescriptor() {
|
||||
return applicationDescriptor;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl.project;
|
||||
|
||||
public class BuildData {
|
||||
|
||||
String groupId;
|
||||
String artifactId;
|
||||
String version;
|
||||
|
||||
String name;
|
||||
|
||||
String builtBy;
|
||||
String builtOn;
|
||||
|
||||
}
|
@ -0,0 +1,254 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl.project;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ru.entaxy.platform.base.support.CommonUtils;
|
||||
import ru.entaxy.platform.integration.applications.ApplicationProjectContent.STANDARD_PROPERTIES;
|
||||
import ru.entaxy.platform.integration.applications.ApplicationProjectInfo;
|
||||
import ru.entaxy.platform.integration.applications.ApplicationStorage;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplication;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplicationProject;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplicationProjectVersion;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ProjectVersionCausedException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ProjectVersionException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ProjectVersionNotFoundException;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.AbstractResourceComponentWithChildren;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.ResourceContext;
|
||||
|
||||
public class ProjectComponent extends AbstractResourceComponentWithChildren<ProjectData, ProjectVersionComponent>
|
||||
implements EntaxyApplicationProject {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(ProjectComponent.class);
|
||||
|
||||
protected static String extractProjectName(String projectFullName) {
|
||||
int index = projectFullName.indexOf('/');
|
||||
if (index < 0)
|
||||
return projectFullName;
|
||||
return projectFullName.substring(index + 1);
|
||||
}
|
||||
|
||||
protected String projectName;
|
||||
|
||||
protected String group;
|
||||
|
||||
protected ApplicationStorage applicationStorage;
|
||||
|
||||
/*
|
||||
public ProjectComponent(EntaxyResourceService resourceService, String projectName, String parentRootUrl) {
|
||||
super(resourceService);
|
||||
setEntaxyResourceService(resourceService);
|
||||
this.projectName = projectName;
|
||||
this.rootResourceFolderUrl = parentRootUrl.concat("/").concat(projectName);
|
||||
}
|
||||
*/
|
||||
|
||||
public ProjectComponent(ResourceContext parentResourceContext, String projectFullName) {
|
||||
super(parentResourceContext.subcontext(extractProjectName(projectFullName)));
|
||||
setProjectName(projectFullName);
|
||||
}
|
||||
|
||||
protected void setProjectName(String projectFullName) {
|
||||
int index = projectFullName.indexOf('/');
|
||||
if (index > 0) {
|
||||
this.projectName = projectFullName.substring(index + 1);
|
||||
setGroup(projectFullName.substring(0, index));
|
||||
} else {
|
||||
this.projectName = projectFullName;
|
||||
setGroup(null);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setGroup(String group) {
|
||||
if (!CommonUtils.isValid(group))
|
||||
this.group = EntaxyApplication.DEFAULT_GROUP_ID;
|
||||
else
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
this.group = dataObject.group;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<ProjectData> getDataObjectClass() {
|
||||
return ProjectData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRootResourceName() {
|
||||
return ".project";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ProjectData createDataObject() {
|
||||
return new ProjectData(projectName, group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentKey() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ProjectVersionComponent createChildComponent(String key) throws Exception {
|
||||
return new ProjectVersionComponent(resourceContext, this, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getChildrenKeyList() {
|
||||
if (dataObject.versions == null)
|
||||
return Collections.emptyList();
|
||||
return new ArrayList<>(dataObject.versions.keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addChildKey(String key) {
|
||||
dataObject.addVersion(key, Calendar.getInstance().getTimeInMillis() + "");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void removeChildKey(String key) {
|
||||
dataObject.removeVersion(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleChildLoadException(String key, Exception e) {
|
||||
log.error("Error loading version [" + key + "]", e);
|
||||
}
|
||||
|
||||
public ProjectComponent storage(ApplicationStorage storage) {
|
||||
this.applicationStorage = storage;
|
||||
return this;
|
||||
}
|
||||
|
||||
/* EntaxyApplicationProject implementation */
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return projectName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationStorage getStorage() {
|
||||
return this.applicationStorage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disgard() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EntaxyApplicationProjectVersion> getVersions() {
|
||||
return new ArrayList<>(childrenCache.values());
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyApplicationProjectVersion getLatestVersion() {
|
||||
String latest = dataObject.getLatestVersion();
|
||||
if (latest == null)
|
||||
return null;
|
||||
return getVersion(latest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyApplicationProjectVersion getVersion(String version) {
|
||||
return childrenCache.get(version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyApplicationProjectVersion createVersion(String version) throws ProjectVersionException {
|
||||
try {
|
||||
return createNewChild(version);
|
||||
} catch (Exception e) {
|
||||
log.error("Error creating version [" + version + "]", e);
|
||||
if (e instanceof ProjectVersionException)
|
||||
throw (ProjectVersionException) e;
|
||||
throw new ProjectVersionCausedException(projectName, version, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyApplicationProjectVersion createVersion(String version, String fromVersion)
|
||||
throws ProjectVersionException {
|
||||
ProjectVersionComponent sourceVersion = childrenCache.get(fromVersion);
|
||||
if (sourceVersion == null)
|
||||
throw new ProjectVersionNotFoundException(projectName, fromVersion);
|
||||
try {
|
||||
ProjectVersionComponent newVersion = createNewChild(version);
|
||||
newVersion.updateFromString(sourceVersion.getAsJsonString());
|
||||
newVersion.getProperties().put(STANDARD_PROPERTIES.CREATED_ON,
|
||||
Calendar.getInstance().getTimeInMillis() + "");
|
||||
newVersion.save();
|
||||
} catch (Exception e) {
|
||||
log.error("Error creating version [" + version + "]", e);
|
||||
if (e instanceof ProjectVersionException)
|
||||
throw (ProjectVersionException) e;
|
||||
throw new ProjectVersionCausedException(projectName, version, e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeVersion(String version) {
|
||||
try {
|
||||
removeChild(version);
|
||||
} catch (Exception e) {
|
||||
log.error("Error removing version [" + version + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationProjectInfo getInfo() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl.project;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
|
||||
public class ProjectData {
|
||||
|
||||
String name;
|
||||
String group;
|
||||
|
||||
Map<String, String> versions;
|
||||
|
||||
public ProjectData(String name, String group) {
|
||||
this.name = name;
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
public void addVersion(String version, String timestamp) {
|
||||
if (versions == null)
|
||||
versions = new HashMap<>();
|
||||
if (!versions.containsKey(version))
|
||||
versions.put(version, timestamp);
|
||||
}
|
||||
|
||||
public void removeVersion(String version) {
|
||||
if (versions == null)
|
||||
return;
|
||||
versions.remove(version);
|
||||
}
|
||||
|
||||
public String getLatestVersion() {
|
||||
Optional<Entry<String, String>> latest =
|
||||
versions.entrySet().stream().sorted(new Comparator<Map.Entry<String, String>>() {
|
||||
|
||||
@Override
|
||||
public int compare(Entry<String, String> o1, Entry<String, String> o2) {
|
||||
// reverse order
|
||||
return -1 * o1.getValue().compareTo(o2.getValue());
|
||||
}
|
||||
}).findFirst();
|
||||
if (!latest.isPresent())
|
||||
return null;
|
||||
return latest.get().getKey();
|
||||
}
|
||||
}
|
@ -0,0 +1,332 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl.project;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ru.entaxy.esb.resources.EntaxyResource;
|
||||
import ru.entaxy.esb.resources.EntaxyResourceURLFactory;
|
||||
import ru.entaxy.platform.integration.applications.ApplicationProjectItem;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplicationProject;
|
||||
import ru.entaxy.platform.integration.applications.EntaxyApplicationProjectVersion;
|
||||
import ru.entaxy.platform.integration.applications.descriptor.ApplicationDescriptor;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ItemException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ProjectVersionException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ProjectVersionIsDirtyException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ProjectVersionNotConsistentException;
|
||||
import ru.entaxy.platform.integration.applications.impl.build.ApplicationBuilder;
|
||||
import ru.entaxy.platform.integration.applications.impl.project.ApplicationProjectContentImpl;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.AbstractResourceComponent;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.impl.ResourceContext;
|
||||
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObject;
|
||||
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObjectResource;
|
||||
|
||||
public class ProjectVersionComponent extends AbstractResourceComponent<ProjectVersionData>
|
||||
implements EntaxyApplicationProjectVersion {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ProjectVersionComponent.class);
|
||||
|
||||
String versionNumber;
|
||||
|
||||
ProjectComponent applicationComponent;
|
||||
|
||||
ApplicationProjectContentImpl applicationContent = new ApplicationProjectContentImpl();
|
||||
|
||||
EntaxyResource contentResource;
|
||||
|
||||
BuildComponent buildComponent;
|
||||
|
||||
final String CONTENT_RESOURCE_NAME = "version.content";
|
||||
|
||||
VERSION_STATUS status = VERSION_STATUS.NEW;
|
||||
|
||||
private boolean isDirty = false;
|
||||
|
||||
protected void setDirty(boolean isDirty) {
|
||||
this.isDirty = isDirty;
|
||||
}
|
||||
|
||||
/*
|
||||
public ProjectVersionComponent(EntaxyResourceService entaxyResourceService, ProjectComponent applicationComponent,
|
||||
String versionNumber) {
|
||||
super(entaxyResourceService);
|
||||
this.versionNumber = versionNumber;
|
||||
this.applicationComponent = applicationComponent;
|
||||
this.rootResourceFolderUrl =
|
||||
applicationComponent.getRootResourceFolderUrl().concat("/").concat(this.versionNumber);
|
||||
applicationContent.getProperties().put(STANDARD_PROPERTIES.APPLICATION, applicationComponent.getName());
|
||||
applicationContent.getProperties().put(STANDARD_PROPERTIES.VERSION, versionNumber);
|
||||
|
||||
buildComponent = new BuildComponent(entaxyResourceService, rootResourceFolderUrl);
|
||||
}
|
||||
*/
|
||||
|
||||
public ProjectVersionComponent(ResourceContext parentResourceContext, ProjectComponent applicationComponent,
|
||||
String versionNumber) {
|
||||
super(parentResourceContext.subcontext(versionNumber));
|
||||
this.versionNumber = versionNumber;
|
||||
this.applicationComponent = applicationComponent;
|
||||
applicationContent.getProperties().put(STANDARD_PROPERTIES.APPLICATION, applicationComponent.getName());
|
||||
applicationContent.getProperties().put(STANDARD_PROPERTIES.GROUP, applicationComponent.getGroup());
|
||||
applicationContent.getProperties().put(STANDARD_PROPERTIES.VERSION, versionNumber);
|
||||
|
||||
buildComponent = new BuildComponent(resourceContext);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<ProjectVersionData> getDataObjectClass() {
|
||||
return ProjectVersionData.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRootResourceName() {
|
||||
return ".version";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ProjectVersionData createDataObject() {
|
||||
return new ProjectVersionData(this.versionNumber, this.status.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentKey() {
|
||||
return versionNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initializeDataObject() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
super.initializeDataObject();
|
||||
this.status = VERSION_STATUS.valueOf(dataObject.status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
initContent();
|
||||
buildComponent.init();
|
||||
}
|
||||
|
||||
protected void initContent() {
|
||||
if (contentResource == null) {
|
||||
contentResource = getResource(CONTENT_RESOURCE_NAME);
|
||||
if (!contentResource.exists()) {
|
||||
save();
|
||||
} else {
|
||||
applicationContent.unmarshall(contentResource.getAsString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String getAsJsonString() {
|
||||
return applicationContent.marshall();
|
||||
}
|
||||
|
||||
public void updateFromString(String jsonData) {
|
||||
applicationContent.unmarshall(jsonData);
|
||||
applicationContent.getProperties().put(STANDARD_PROPERTIES.APPLICATION, applicationComponent.getName());
|
||||
applicationContent.getProperties().put(STANDARD_PROPERTIES.GROUP, applicationComponent.getGroup());
|
||||
applicationContent.getProperties().put(STANDARD_PROPERTIES.VERSION, versionNumber);
|
||||
}
|
||||
|
||||
/* EntaxyApplicationProjectVersion implementation */
|
||||
|
||||
@Override
|
||||
public void disgard() {
|
||||
applicationContent.unmarshall(contentResource.getAsString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
String data = applicationContent.marshall();
|
||||
try (ByteArrayInputStream bis = new ByteArrayInputStream(data.getBytes())) {
|
||||
contentResource.save(bis);
|
||||
setDirty(false);
|
||||
} catch (IOException e) {
|
||||
LOG.error("Error saving resource [" + contentResource.getURL() + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersionNumber() {
|
||||
return versionNumber;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApplicationProjectItem> getItems() {
|
||||
return applicationContent.getItems();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends ApplicationProjectItem> List<T> getItems(Class<T> itemClass) {
|
||||
return applicationContent.getItems(itemClass);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItem(ApplicationProjectItem item) throws ItemException {
|
||||
try {
|
||||
applicationContent.addItem(item);
|
||||
setDirty(true);
|
||||
} catch (ItemException e) {
|
||||
e.setVersionNumber(versionNumber);
|
||||
e.setApplicationName(this.applicationComponent.getName());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ignoreItem(ApplicationProjectItem item) throws ItemException {
|
||||
try {
|
||||
applicationContent.ignoreItem(item);
|
||||
setDirty(true);
|
||||
} catch (ItemException e) {
|
||||
e.setVersionNumber(versionNumber);
|
||||
e.setApplicationName(this.applicationComponent.getName());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeItem(ApplicationProjectItem item) throws ItemException {
|
||||
try {
|
||||
applicationContent.removeItem(item);
|
||||
setDirty(true);
|
||||
} catch (ItemException e) {
|
||||
e.setVersionNumber(versionNumber);
|
||||
e.setApplicationName(this.applicationComponent.getName());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntaxyApplicationProject getApplication() {
|
||||
return this.applicationComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationProjectItem addObject(EntaxyRuntimeObject runtimeObject) {
|
||||
setDirty(true);
|
||||
return applicationContent.addObject(runtimeObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationProjectItem addResource(EntaxyRuntimeObjectResource runtimeObjectResource) {
|
||||
setDirty(true);
|
||||
return applicationContent.addResource(runtimeObjectResource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationProjectItem addResource(EntaxyResource entaxyResource) {
|
||||
setDirty(true);
|
||||
return applicationContent.addResource(entaxyResource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getProperties() {
|
||||
return applicationContent.getProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public VERSION_STATUS getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL build() throws ProjectVersionException {
|
||||
if (!isConsistent())
|
||||
throw new ProjectVersionNotConsistentException(applicationComponent.getName(), versionNumber);
|
||||
if (isDirty())
|
||||
throw new ProjectVersionIsDirtyException(applicationComponent.getName(), versionNumber);
|
||||
ApplicationBuilder builder = new ApplicationBuilder(applicationContent);
|
||||
builder.getCoordinates()
|
||||
.groupId(applicationComponent.getGroup())
|
||||
.artifactId(applicationComponent.getName())
|
||||
.version(versionNumber);
|
||||
URL result = builder.build();
|
||||
buildComponent.updateBuild(result, builder.getDescriptor(), builder.getCoordinates());
|
||||
builder.clear();
|
||||
if (isBuildAvailable()) {
|
||||
status = VERSION_STATUS.BUILT;
|
||||
dataObject.status = status.toString();
|
||||
try {
|
||||
updateRootResource();
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error updating root resource for project [" + applicationComponent.getName()
|
||||
+ "] version [" + versionNumber + "]", e);
|
||||
}
|
||||
try {
|
||||
return EntaxyResourceURLFactory.getGlobalUrl(buildComponent.getBuildResource());
|
||||
} catch (MalformedURLException e) {
|
||||
LOG.error("Error creating URL for [" + buildComponent.getBuildResource().getURL() + "]", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getBuild() {
|
||||
if (!isBuildAvailable())
|
||||
return null;
|
||||
return buildComponent.getBuildResource().getInputStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getBuildUrl() {
|
||||
if (!isBuildAvailable())
|
||||
return null;
|
||||
try {
|
||||
return EntaxyResourceURLFactory.getGlobalUrl(buildComponent.getBuildResource());
|
||||
} catch (MalformedURLException e) {
|
||||
LOG.error("Error getting global URL for resource [" + buildComponent.getBuildResource().getURL() + "]", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBuildAvailable() {
|
||||
return buildComponent.isBuildAvailable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationDescriptor getBuildInfo() {
|
||||
return buildComponent.getApplicationDescriptor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
return isDirty;
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.impl.project;
|
||||
|
||||
public class ProjectVersionData {
|
||||
|
||||
String versionNumber;
|
||||
String status;
|
||||
|
||||
public ProjectVersionData(String versionNumber, String status) {
|
||||
this.versionNumber = versionNumber;
|
||||
this.status = status;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* resource-based-storage
|
||||
* ==========
|
||||
* 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.integration.applications.storage.resource.internal;
|
||||
|
||||
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 ru.entaxy.esb.resources.EntaxyResourceService;
|
||||
import ru.entaxy.platform.integration.applications.ApplicationStorage;
|
||||
import ru.entaxy.platform.integration.applications.storage.ApplicationStorageInfo;
|
||||
import ru.entaxy.platform.integration.applications.storage.resource.ResourceBasedStorage;
|
||||
|
||||
@Component(service = ApplicationStorage.class, immediate = true)
|
||||
@ApplicationStorageInfo(name = "default")
|
||||
public class DefaultApplicationStorage extends ResourceBasedStorage {
|
||||
|
||||
public DefaultApplicationStorage() {
|
||||
super();
|
||||
setResourceProvider("entaxy-file-internal");
|
||||
setPath(".applications");
|
||||
}
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY, unbind = "unbindResourceService")
|
||||
public void bindResourceService(EntaxyResourceService resourceService) {
|
||||
this.entaxyResourceService = resourceService;
|
||||
}
|
||||
|
||||
public void unbindResourceService(EntaxyResourceService resourceService) {
|
||||
this.entaxyResourceService = null;
|
||||
}
|
||||
|
||||
@Activate
|
||||
public void activate() {
|
||||
init();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user