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,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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 http://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>application-management</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<name>ENTAXY :: PLATFORM :: INTEGRATION :: APPLICATIONS :: MANAGEMENT</name>
|
||||
<description>ENTAXY :: PLATFORM :: INTEGRATION :: APPLICATIONS :: MANAGEMENT</description>
|
||||
|
||||
<properties>
|
||||
<bundle.osgi.export.pkg>ru.entaxy.platform.integration.applications.management</bundle.osgi.export.pkg>
|
||||
<bundle.osgi.private.pkg>ru.entaxy.platform.integration.applications.management.impl</bundle.osgi.private.pkg>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>ru.entaxy.esb.platform.runtime.core.management</groupId>
|
||||
<artifactId>object-management</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.osgi</groupId>
|
||||
<artifactId>org.osgi.service.component.annotations</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.scr</artifactId>
|
||||
<version>2.1.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.entaxy.esb.platform.runtime.base</groupId>
|
||||
<artifactId>base-support</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ru.entaxy.esb.platform.runtime.base</groupId>
|
||||
<artifactId>management-core</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>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,198 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* application-management
|
||||
* ==========
|
||||
* 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.management;
|
||||
|
||||
import ru.entaxy.esb.platform.base.management.core.Qualifier;
|
||||
import ru.entaxy.esb.platform.base.management.core.api.MBeanAnnotated;
|
||||
import ru.entaxy.esb.platform.base.management.core.api.MBeanExportPolicy;
|
||||
import ru.entaxy.esb.platform.base.management.core.api.Operation;
|
||||
import ru.entaxy.esb.platform.base.management.core.api.Parameter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@MBeanAnnotated(policy = MBeanExportPolicy.ANNOTATED_ONLY)
|
||||
public interface ApplicationsMBean {
|
||||
|
||||
public static final String MODULE_JMX_DOMAIN = "ru.entaxy.cicd";
|
||||
|
||||
public static final String MAIN_MODULE_KEY = "module";
|
||||
|
||||
public static final String MAIN_MODULE_KEY_VALUE = "applications";
|
||||
|
||||
public static final Qualifier Q_MAIN_MODULE = new Qualifier(MAIN_MODULE_KEY, MAIN_MODULE_KEY_VALUE);
|
||||
|
||||
public static final String Q_MAIN_MODULE_S = MODULE_JMX_DOMAIN + ":" + MAIN_MODULE_KEY + "=" + MAIN_MODULE_KEY_VALUE;
|
||||
|
||||
@Operation(desc = "Gets tree")
|
||||
String readAsTree() throws Exception;
|
||||
|
||||
@Operation(desc = "Import project from repository")
|
||||
void importFromRepository(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "mavenUrl", desc = "Maven URL of the application") String mavenUrl
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Import project from base64 string")
|
||||
void importFromBase64String(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "fileContentBase64String",
|
||||
desc = "The application file content encoded into base64 string") String fileContentBase64
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Remove application")
|
||||
void removeApplication(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "applicationName", desc = "Name of the application") String applicationName
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "List application items")
|
||||
List<Map<String, Object>> listApplicationItems(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "applicationName", desc = "Name of the application") String applicationName,
|
||||
@Parameter(name = "applicationVersion", desc = "Version of the application") String applicationVersion
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "List application requirements")
|
||||
List<Map<String, Object>> listApplicationRequirements(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "applicationName", desc = "Name of the application") String applicationName,
|
||||
@Parameter(name = "applicationVersion", desc = "Version of the application") String applicationVersion
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Read last and installed revision of the application version")
|
||||
Map<String, String> readApplicationVersionLastAndInstalledRevision(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "applicationName", desc = "Name of the application") String applicationName,
|
||||
@Parameter(name = "applicationVersion", desc = "Version of the application") String applicationVersion
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Read application item types")
|
||||
List<String> readApplicationItemTypes();
|
||||
|
||||
@Operation(desc = "Read project item scopes")
|
||||
List<String> readApplicationItemScopes();
|
||||
|
||||
@Operation(desc = "Remove application version")
|
||||
void removeVersion(@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "applicationName", desc = "Name of the application") String applicationName,
|
||||
@Parameter(name = "versionToRemove", desc = "Version to remove") String versionToRemove
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Create revision for application version")
|
||||
void createRevision(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "applicationName", desc = "Name of the application") String applicationName,
|
||||
@Parameter(name = "applicationVersion", desc = "Version of the application") String applicationVersion,
|
||||
@Parameter(name = "prototypeRevision", desc = "Existent revision to base on") int prototypeRevision
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Configure application revision")
|
||||
void configureRevision(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "applicationName", desc = "Name of the application") String applicationName,
|
||||
@Parameter(name = "applicationVersion", desc = "Version of the application") String applicationVersion,
|
||||
@Parameter(name = "applicationVersionRevision", desc = "Revision of the application version")
|
||||
String applicationVersionRevision
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Deploy application revision")
|
||||
void deployRevision(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "applicationName", desc = "Name of the application") String applicationName,
|
||||
@Parameter(name = "applicationVersion", desc = "Version of the application") String applicationVersion,
|
||||
@Parameter(name = "applicationVersionRevision", desc = "Revision of the application version")
|
||||
String applicationVersionRevision
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Install application revision")
|
||||
void installRevision(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "applicationName", desc = "Name of the application") String applicationName,
|
||||
@Parameter(name = "applicationVersion", desc = "Version of the application") String applicationVersion,
|
||||
@Parameter(name = "applicationVersionRevision", desc = "Revision of the application version")
|
||||
String applicationVersionRevision
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Uninstall application revision")
|
||||
void uninstallRevision(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "applicationName", desc = "Name of the application") String applicationName,
|
||||
@Parameter(name = "applicationVersion", desc = "Version of the application") String applicationVersion,
|
||||
@Parameter(name = "applicationVersionRevision", desc = "Revision of the application version")
|
||||
String applicationVersionRevision
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Get application revision status")
|
||||
String readRevisionStatus(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "applicationName", desc = "Name of the application") String applicationName,
|
||||
@Parameter(name = "applicationVersion", desc = "Version of the application") String applicationVersion,
|
||||
@Parameter(name = "applicationVersionRevision", desc = "Revision of the application version")
|
||||
String applicationVersionRevision
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "List application revision configurations")
|
||||
List<Map<String, String>> listRevisionConfigurations(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "applicationName", desc = "Name of the application") String applicationName,
|
||||
@Parameter(name = "applicationVersion", desc = "Version of the application") String applicationVersion,
|
||||
@Parameter(name = "applicationVersionRevision", desc = "Revision of the application version")
|
||||
String applicationVersionRevision
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Read application revision configuration")
|
||||
Map<String, Object> readRevisionConfiguration(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "applicationName", desc = "Name of the application") String applicationName,
|
||||
@Parameter(name = "applicationVersion", desc = "Version of the application") String applicationVersion,
|
||||
@Parameter(name = "applicationVersionRevision", desc = "Revision of the application version")
|
||||
String applicationVersionRevision,
|
||||
@Parameter(name = "configId", desc = "Configuration Id") String configId
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Fill in application revision configuration with local configuration values")
|
||||
void fillInRevisionConfigurationWithLocalValues(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "applicationName", desc = "Name of the application") String applicationName,
|
||||
@Parameter(name = "applicationVersion", desc = "Version of the application") String applicationVersion,
|
||||
@Parameter(name = "applicationVersionRevision", desc = "Revision of the application version")
|
||||
String applicationVersionRevision,
|
||||
@Parameter(name = "configId", desc = "Configuration Id") String configId
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Save application revision configuration changes")
|
||||
void saveRevisionConfiguration(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "applicationName", desc = "Name of the application") String applicationName,
|
||||
@Parameter(name = "applicationVersion", desc = "Version of the application") String applicationVersion,
|
||||
@Parameter(name = "applicationVersionRevision", desc = "Revision of the application version")
|
||||
String applicationVersionRevision,
|
||||
@Parameter(name = "configId", desc = "Configuration Id") String configId,
|
||||
@Parameter(name = "properties", desc = "Map of changed properties") Map<String, Object> properties
|
||||
) throws Exception;
|
||||
|
||||
}
|
@ -0,0 +1,198 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* application-management
|
||||
* ==========
|
||||
* 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.management;
|
||||
|
||||
import ru.entaxy.esb.platform.base.management.core.Qualifier;
|
||||
import ru.entaxy.esb.platform.base.management.core.api.MBeanAnnotated;
|
||||
import ru.entaxy.esb.platform.base.management.core.api.MBeanExportPolicy;
|
||||
import ru.entaxy.esb.platform.base.management.core.api.Operation;
|
||||
import ru.entaxy.esb.platform.base.management.core.api.Parameter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@MBeanAnnotated(policy = MBeanExportPolicy.ANNOTATED_ONLY)
|
||||
public interface ProjectsMBean {
|
||||
|
||||
public static final String MODULE_JMX_DOMAIN = "ru.entaxy.cicd";
|
||||
|
||||
public static final String MAIN_MODULE_KEY = "module";
|
||||
|
||||
public static final String MAIN_MODULE_KEY_VALUE = "projects";
|
||||
|
||||
public static final Qualifier Q_MAIN_MODULE = new Qualifier(MAIN_MODULE_KEY, MAIN_MODULE_KEY_VALUE);
|
||||
|
||||
public static final String Q_MAIN_MODULE_S = MODULE_JMX_DOMAIN + ":" + MAIN_MODULE_KEY + "=" + MAIN_MODULE_KEY_VALUE;
|
||||
|
||||
@Operation(desc = "Gets tree")
|
||||
String readAsTree() throws Exception;
|
||||
|
||||
@Operation(desc = "List project items")
|
||||
List<Map<String, Object>> listProjectItems(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName,
|
||||
@Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Read project item statuses")
|
||||
List<String> readProjectItemStatuses();
|
||||
|
||||
@Operation(desc = "Create project")
|
||||
void createProject(
|
||||
@Parameter(name = "projectName", desc = "Name of created project") String projectName,
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "initialVersion", desc = "Initial version for the created project") String initialVersion
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Remove project")
|
||||
void removeProject(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Add object to the project")
|
||||
List<Map<String, String>> addObject(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName,
|
||||
@Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion,
|
||||
@Parameter(name = "objectId", desc = "Id of the object") String objectId
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "List objects")
|
||||
List<Map<String, String>> listObjects() throws Exception;
|
||||
|
||||
@Operation(desc = "Get related objects")
|
||||
List<Map<String, String>> getRelatedObjects(
|
||||
@Parameter(name = "objectId", desc = "Id of the object") String objectId
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Add item to the project")
|
||||
void addItem(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName,
|
||||
@Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion,
|
||||
@Parameter(name = "itemId", desc = "Id of the item") String itemId
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Ignore item from the project")
|
||||
void ignoreItem(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName,
|
||||
@Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion,
|
||||
@Parameter(name = "itemId", desc = "Id of the item") String itemId
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Remove item from the project")
|
||||
void removeItem(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName,
|
||||
@Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion,
|
||||
@Parameter(name = "itemId", desc = "Id of the item") String itemId
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Remove items from the project")
|
||||
Map<String, List<String>> removeItems(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName,
|
||||
@Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion,
|
||||
@Parameter(name = "itemIds", desc = "Ids of the items") List<String> itemIds
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Create version")
|
||||
void createVersion(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName,
|
||||
@Parameter(name = "createdVersion", desc = "Created version") String createdVersion,
|
||||
@Parameter(name = "prototypeVersion", desc = "Existent version to base on") String prototypeVersion
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Remove version")
|
||||
void removeVersion(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName,
|
||||
@Parameter(name = "versionToRemove", desc = "Version to remove") String versionToRemove
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Save project version")
|
||||
void saveProjectVersion(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName,
|
||||
@Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Build project version")
|
||||
void buildProjectVersion(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName,
|
||||
@Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "List built project items")
|
||||
List<Map<String, String>> listBuiltProjectItems(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName,
|
||||
@Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "List built project requirements")
|
||||
List<Map<String, Object>> listBuiltProjectRequirements(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName,
|
||||
@Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "List built project components")
|
||||
List<Map<String, String>> listBuiltProjectComponents(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName,
|
||||
@Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Read build info")
|
||||
String readMavenUrl(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName,
|
||||
@Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "List repositories")
|
||||
List<String> listRepositories() throws Exception;
|
||||
|
||||
@Operation(desc = "Export project to repository")
|
||||
void exportToRepository(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName,
|
||||
@Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion,
|
||||
@Parameter(name = "repositoryName", desc = "Name of the repository") String repositoryName
|
||||
) throws Exception;
|
||||
|
||||
@Operation(desc = "Export project to file")
|
||||
String exportToFile(
|
||||
@Parameter(name = "storage", desc = "Name of the storage") String storage,
|
||||
@Parameter(name = "projectName", desc = "Name of the project") String projectName,
|
||||
@Parameter(name = "projectVersion", desc = "Version of the project") String projectVersion
|
||||
) throws Exception;
|
||||
}
|
@ -0,0 +1,521 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* application-management
|
||||
* ==========
|
||||
* 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.management.impl;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.karaf.features.FeaturesService;
|
||||
import org.osgi.service.component.annotations.*;
|
||||
import ru.entaxy.esb.platform.base.management.core.ManagementCore;
|
||||
import ru.entaxy.esb.platform.base.management.core.api.AnnotatedMBean;
|
||||
import ru.entaxy.esb.resources.EntaxyResource;
|
||||
import ru.entaxy.esb.resources.EntaxyResourceService;
|
||||
import ru.entaxy.platform.base.support.CommonUtils;
|
||||
import ru.entaxy.platform.base.support.JSONUtils;
|
||||
import ru.entaxy.platform.base.support.osgi.bundle.CapabilityDescriptor;
|
||||
import ru.entaxy.platform.base.support.osgi.feature.FeatureCapabilityHelper;
|
||||
import ru.entaxy.platform.config.runtime.ObjectConfigEditor;
|
||||
import ru.entaxy.platform.integration.applications.*;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ApplicationException;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.ItemNotFoundException;
|
||||
import ru.entaxy.platform.integration.applications.descriptor.ApplicationRequirement;
|
||||
import ru.entaxy.platform.integration.applications.exceptions.StorageException;
|
||||
import ru.entaxy.platform.integration.applications.management.ApplicationsMBean;
|
||||
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObject;
|
||||
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObjectService;
|
||||
|
||||
import javax.management.DynamicMBean;
|
||||
import javax.management.MBeanRegistration;
|
||||
import javax.management.NotCompliantMBeanException;
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component(
|
||||
service = {DynamicMBean.class, MBeanRegistration.class, ApplicationsMBean.class},
|
||||
property = {ManagementCore.JMX_OBJECTNAME + "=" + ApplicationsMBean.Q_MAIN_MODULE_S},
|
||||
scope = ServiceScope.SINGLETON,
|
||||
immediate = true
|
||||
)
|
||||
public class ApplicationsMBeanImpl extends AnnotatedMBean<ApplicationsMBean> implements ApplicationsMBean {
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY)
|
||||
public ApplicationManager applicationManager;
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY)
|
||||
EntaxyRuntimeObjectService entaxyRuntimeObjectService;
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY)
|
||||
EntaxyResourceService entaxyResourceService;
|
||||
|
||||
public ApplicationsMBeanImpl() throws NotCompliantMBeanException {
|
||||
super(ApplicationsMBean.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readAsTree() {
|
||||
final String TITLE = "title";
|
||||
final String CHILDREN = "children";
|
||||
|
||||
List<Map<String, Object>> applicationStorages = new ArrayList<>();
|
||||
applicationManager.getActiveStorages().forEach(storage -> {
|
||||
|
||||
Map<String, Object> applicationStorage = new HashMap<>();
|
||||
applicationStorage.put(TITLE, storage.getName());
|
||||
applicationStorage.put(CHILDREN, storage.getApplications().stream().map(application -> {
|
||||
Map<String, Object> applicationMap = new HashMap<>();
|
||||
applicationMap.put(TITLE, application.getName());
|
||||
applicationMap.put(CHILDREN, application.getVersions().stream().map(version -> {
|
||||
Map<String, Object> versionMap = new HashMap<>();
|
||||
versionMap.put(TITLE, version.getVersionNumber());
|
||||
versionMap.put(CHILDREN, version.getRevisions().stream().map(revision -> {
|
||||
Map<String, Object> revisionMap = new HashMap<>();
|
||||
String revisionTitle = revision.getRevisionNumber() +
|
||||
" [" + revision.getStatus().toString() + "]";
|
||||
revisionMap.put(TITLE, revisionTitle);
|
||||
return revisionMap;
|
||||
}).collect(Collectors.toList()));
|
||||
return versionMap;
|
||||
}).collect(Collectors.toList()));
|
||||
return applicationMap;
|
||||
}).collect(Collectors.toList()));
|
||||
|
||||
applicationStorages.add(applicationStorage);
|
||||
});
|
||||
|
||||
return JSONUtils.GSON.toJson(applicationStorages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importFromRepository(String storage, String mavenUrl) throws Exception {
|
||||
applicationManager.importApplicationFromRepository(storage, mavenUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importFromBase64String(String storage, String fileContentBase64) throws Exception {
|
||||
byte[] byteArray = Base64.getDecoder().decode(fileContentBase64);
|
||||
|
||||
Path temp;
|
||||
try {
|
||||
temp = Files.createTempFile("TEMP", null);
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
}
|
||||
|
||||
File tempFile = temp.toFile().getAbsoluteFile();
|
||||
tempFile.getParentFile().mkdirs();
|
||||
|
||||
try (FileOutputStream fileOutputStream = new FileOutputStream(tempFile)) {
|
||||
fileOutputStream.write(byteArray);
|
||||
|
||||
importFromFile(storage, tempFile.getPath());
|
||||
} catch (RuntimeException e) {
|
||||
throw e;
|
||||
} finally {
|
||||
FileUtils.deleteQuietly(tempFile);
|
||||
}
|
||||
}
|
||||
|
||||
private void importFromFile(String storage, String filePath) throws ApplicationException, StorageException {
|
||||
applicationManager.importApplicationFromFile(storage, filePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeApplication(String storage, String applicationName) throws Exception {
|
||||
applicationManager.getStorage(storage).removeApplication(getApplication(storage, applicationName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listApplicationItems(String storage,
|
||||
String applicationName,
|
||||
String applicationVersion) {
|
||||
return getApplicationVersion(storage, applicationName, applicationVersion).getLastRevision()
|
||||
.getItems().stream().map(item -> {
|
||||
Map<String, Object> itemMap = new HashMap<>();
|
||||
itemMap.put("id", item.getId());
|
||||
itemMap.put("type", item.getType().toString());
|
||||
itemMap.put("revisionable", item.isRevisionable());
|
||||
itemMap.put("editable", item.isEditable());
|
||||
return itemMap;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listApplicationRequirements(String storage,
|
||||
String applicationName,
|
||||
String applicationVersion) {
|
||||
return getApplicationVersion(storage, applicationName, applicationVersion).getLastRevision()
|
||||
.getDescriptor().getRequirements().stream().map(requirement -> {
|
||||
Map<String, Object> requirementMap = new HashMap<>();
|
||||
requirementMap.put("id", requirement.getId());
|
||||
requirementMap.put("type", requirement.getType().toString());
|
||||
requirementMap.put("scope", requirement.getScope().toString());
|
||||
requirementMap.put("status", checkRequirement(requirement));
|
||||
return requirementMap;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// copied from application-shell
|
||||
private boolean checkRequirement(ApplicationRequirement requirement) {
|
||||
switch (requirement.type) {
|
||||
case OBJECT:
|
||||
EntaxyRuntimeObject runtimeObject = entaxyRuntimeObjectService.getRuntimeObject(requirement.id);
|
||||
return runtimeObject != null && !runtimeObject.isGhost();
|
||||
case RESOURCE:
|
||||
EntaxyResource entaxyResource = entaxyResourceService.getResource(requirement.id);
|
||||
return entaxyResource.exists();
|
||||
case BUNDLE:
|
||||
case CONFIG:
|
||||
// TODO implement
|
||||
return true;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> readApplicationVersionLastAndInstalledRevision(String storage,
|
||||
String applicationName,
|
||||
String applicationVersion) {
|
||||
EntaxyApplicationVersion version = getApplicationVersion(storage, applicationName, applicationVersion);
|
||||
Map<String, String> revisions = new HashMap<>(2);
|
||||
revisions.put("lastRevision", String.valueOf(version.getLastRevision().getRevisionNumber()));
|
||||
revisions.put("installedRevision", getInstalledRevisionValue(version));
|
||||
return revisions;
|
||||
}
|
||||
|
||||
protected final static String APP_NAMESPACE = "entaxy.application";
|
||||
|
||||
@Reference
|
||||
FeaturesService featuresService;
|
||||
|
||||
// copied from application-shell
|
||||
protected String getInstalledRevisionValue(EntaxyApplicationVersion version) {
|
||||
try {
|
||||
List<FeatureCapabilityHelper> helpers = Arrays.asList(featuresService.listInstalledFeatures()).stream()
|
||||
.map(f -> new FeatureCapabilityHelper(f))
|
||||
.filter(h -> h.isCapabilityProvided(APP_NAMESPACE))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (FeatureCapabilityHelper helper : helpers) {
|
||||
List<CapabilityDescriptor> descriptors = helper.getProvidedCapabilities(APP_NAMESPACE);
|
||||
for (CapabilityDescriptor descriptor : descriptors) {
|
||||
String nameValue = descriptor.getAttributes()
|
||||
.getOrDefault("name", "").toString();
|
||||
String versionValue = descriptor.getAttributes()
|
||||
.getOrDefault("version", "").toString();
|
||||
if (version.getApplication().getName().equals(nameValue)
|
||||
&& version.getVersionNumber().equals(versionValue)) {
|
||||
String revision = descriptor.getAttributes()
|
||||
.getOrDefault("revision", "").toString();
|
||||
if (CommonUtils.isValid(revision))
|
||||
return revision;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
// NOOP
|
||||
// ignore.printStackTrace();
|
||||
}
|
||||
return "-";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> readApplicationItemTypes() {
|
||||
return Arrays.stream(EntaxyApplication.ITEM_TYPE.values())
|
||||
.map(itemType -> itemType.toString()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> readApplicationItemScopes() {
|
||||
return Arrays.stream(EntaxyApplication.ITEM_SCOPE.values())
|
||||
.map(scope -> scope.toString()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeVersion(String storage, String applicationName, String versionToRemove) {
|
||||
getApplication(storage, applicationName).removeVersion(versionToRemove);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createRevision(String storage,
|
||||
String applicationName,
|
||||
String applicationVersion,
|
||||
int prototypeRevision) throws Exception {
|
||||
if (prototypeRevision > -1) {
|
||||
getApplicationVersion(storage, applicationName, applicationVersion).createRevision(prototypeRevision);
|
||||
} else {
|
||||
getApplicationVersion(storage, applicationName, applicationVersion).createRevision();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureRevision(String storage,
|
||||
String applicationName,
|
||||
String applicationVersion,
|
||||
String applicationVersionRevision) throws Exception {
|
||||
getApplicationRevision(storage, applicationName, applicationVersion, applicationVersionRevision).configure();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deployRevision(String storage,
|
||||
String applicationName,
|
||||
String applicationVersion,
|
||||
String applicationVersionRevision) throws Exception {
|
||||
getApplicationRevision(storage, applicationName, applicationVersion, applicationVersionRevision).deploy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installRevision(String storage,
|
||||
String applicationName,
|
||||
String applicationVersion,
|
||||
String applicationVersionRevision) throws Exception {
|
||||
getApplicationRevision(storage, applicationName, applicationVersion, applicationVersionRevision).install();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uninstallRevision(String storage,
|
||||
String applicationName,
|
||||
String applicationVersion,
|
||||
String applicationVersionRevision) throws Exception {
|
||||
getApplicationRevision(storage, applicationName, applicationVersion, applicationVersionRevision).uninstall();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readRevisionStatus(String storage,
|
||||
String applicationName,
|
||||
String applicationVersion,
|
||||
String applicationVersionRevision) throws Exception {
|
||||
return getApplicationRevision(storage, applicationName, applicationVersion, applicationVersionRevision)
|
||||
.getStatus().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> listRevisionConfigurations(String storage,
|
||||
String applicationName,
|
||||
String applicationVersion,
|
||||
String applicationVersionRevision) throws Exception {
|
||||
return getApplicationRevision(storage, applicationName, applicationVersion, applicationVersionRevision)
|
||||
.getItems().stream()
|
||||
.filter(item -> EntaxyApplication.ITEM_TYPE.CONFIG.equals(item.getType()))
|
||||
.map(item -> {
|
||||
Map<String, String> itemMap = new HashMap<>();
|
||||
itemMap.put("id", item.getId());
|
||||
itemMap.put("location", item.getLocation());
|
||||
return itemMap;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> readRevisionConfiguration(String storage,
|
||||
String applicationName,
|
||||
String applicationVersion,
|
||||
String applicationVersionRevision,
|
||||
String configId) throws Exception {
|
||||
|
||||
ApplicationItem configItem = getConfigItem(storage, applicationName, applicationVersion,
|
||||
applicationVersionRevision, configId);
|
||||
|
||||
ObjectConfigEditor editor = getEditor(configId, configItem);
|
||||
|
||||
List<Map<String, Object>> fields = new ArrayList<>();
|
||||
|
||||
String configuredType = null;
|
||||
String configuredId = null;
|
||||
|
||||
try {
|
||||
for (String name : editor.getPropertiesNames()) {
|
||||
ObjectConfigEditor.ConfigProperty property = editor.getAsConfigProperty(name);
|
||||
|
||||
if (!property.hint.isInternal()) {
|
||||
Map<String, Object> field = new HashMap<>();
|
||||
|
||||
field.put("name", name);
|
||||
field.put("displayName", property.hint.getDisplayName());
|
||||
field.put("type", property.hint.getType());
|
||||
field.put("importedValue", property.configValue);
|
||||
field.put("localValue", property.currentValue);
|
||||
|
||||
fields.add(field);
|
||||
} else {
|
||||
if ("__entaxy_configuredId".equals(name)) {
|
||||
configuredId = property.configValue.toString();
|
||||
} else if ("__entaxy_configuredType".equals(name)) {
|
||||
configuredType = property.configValue.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} finally {
|
||||
editor.clear();
|
||||
}
|
||||
|
||||
Map<String, Object> configuration = new HashMap<>();
|
||||
configuration.put("id", configuredId);
|
||||
configuration.put("type", configuredType);
|
||||
configuration.put("fields", fields);
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fillInRevisionConfigurationWithLocalValues(String storage,
|
||||
String applicationName,
|
||||
String applicationVersion,
|
||||
String applicationVersionRevision,
|
||||
String configId) throws Exception {
|
||||
|
||||
ApplicationItem configItem = getConfigItem(storage, applicationName, applicationVersion,
|
||||
applicationVersionRevision, configId);
|
||||
|
||||
ObjectConfigEditor editor = getEditor(configId, configItem);
|
||||
|
||||
InputStream is = null;
|
||||
try {
|
||||
for (String propertyName : editor.getPropertiesNames()) {
|
||||
ObjectConfigEditor.ConfigProperty property = editor.getAsConfigProperty(propertyName);
|
||||
|
||||
if (property.currentValue != null) {
|
||||
editor.setValue(propertyName, property.currentValue.toString());
|
||||
} else {
|
||||
throw new RuntimeException("Cannot set local values to configuration [" + configId + "]");
|
||||
}
|
||||
}
|
||||
|
||||
editor.save();
|
||||
|
||||
is = new FileInputStream(editor.getConfigFile());
|
||||
configItem.update(is);
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} finally {
|
||||
editor.clear();
|
||||
if (is != null) {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveRevisionConfiguration(String storage,
|
||||
String applicationName,
|
||||
String applicationVersion,
|
||||
String applicationVersionRevision,
|
||||
String configId,
|
||||
Map<String, Object> properties) throws Exception {
|
||||
|
||||
ApplicationItem configItem = getConfigItem(storage, applicationName, applicationVersion,
|
||||
applicationVersionRevision, configId);
|
||||
|
||||
ObjectConfigEditor editor = getEditor(configId, configItem);
|
||||
|
||||
InputStream is = null;
|
||||
try {
|
||||
for (String propertyName : properties.keySet()) {
|
||||
ObjectConfigEditor.ConfigProperty property = editor.getAsConfigProperty(propertyName);
|
||||
|
||||
if (property == null) {
|
||||
throw new RuntimeException("Property [" + propertyName + "] is not found");
|
||||
}
|
||||
|
||||
Object propertyValue = properties.get(propertyName);
|
||||
|
||||
editor.setValue(propertyName, propertyValue == null ? "" : propertyValue.toString());
|
||||
}
|
||||
|
||||
editor.save();
|
||||
|
||||
is = new FileInputStream(editor.getConfigFile());
|
||||
configItem.update(is);
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} finally {
|
||||
editor.clear();
|
||||
if (is != null) {
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ApplicationItem getConfigItem(String storage,
|
||||
String applicationName,
|
||||
String applicationVersion,
|
||||
String applicationVersionRevision,
|
||||
String configId) throws Exception {
|
||||
Optional<ApplicationItem> configItemOpt =
|
||||
getApplicationRevision(storage, applicationName, applicationVersion, applicationVersionRevision)
|
||||
.getItems().stream().filter(item ->
|
||||
EntaxyApplication.ITEM_TYPE.CONFIG.equals(item.getType()) &&
|
||||
configId.equals(item.getId())).findFirst();
|
||||
if (configItemOpt.isEmpty()) {
|
||||
throw new ItemNotFoundException(applicationName, applicationVersion, configId);
|
||||
}
|
||||
|
||||
return configItemOpt.get();
|
||||
}
|
||||
|
||||
private ObjectConfigEditor getEditor(String configId, ApplicationItem configItem) throws Exception {
|
||||
|
||||
Path temp = Files.createTempFile(configId, null);
|
||||
File tempFile = temp.toFile().getAbsoluteFile();
|
||||
tempFile.getParentFile().mkdirs();
|
||||
|
||||
ObjectConfigEditor editor;
|
||||
try (InputStream is = configItem.getInputStream()) {
|
||||
Files.copy(is, tempFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
editor = ObjectConfigEditor.create(tempFile);
|
||||
editor.loadCurrent(configItem.getId());
|
||||
editor.setPid(configId);
|
||||
} catch (Exception e) {
|
||||
FileUtils.deleteQuietly(tempFile);
|
||||
throw e;
|
||||
}
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
private EntaxyApplication getApplication(String storage, String applicationName) {
|
||||
return applicationManager.getStorage(storage).getApplication(applicationName);
|
||||
}
|
||||
|
||||
private EntaxyApplicationVersion getApplicationVersion(String storage,
|
||||
String applicationName,
|
||||
String applicationVersion) {
|
||||
return getApplication(storage, applicationName).getVersion(applicationVersion);
|
||||
}
|
||||
|
||||
private EntaxyApplicationRevision getApplicationRevision(String storage,
|
||||
String applicationName,
|
||||
String applicationVersion,
|
||||
String applicationVersionRevision) throws Exception {
|
||||
return getApplicationVersion(storage, applicationName, applicationVersion)
|
||||
.getRevision(applicationVersionRevision);
|
||||
}
|
||||
}
|
@ -0,0 +1,437 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* application-management
|
||||
* ==========
|
||||
* 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.management.impl;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.osgi.service.component.annotations.*;
|
||||
import ru.entaxy.esb.platform.base.management.core.ManagementCore;
|
||||
import ru.entaxy.esb.platform.base.management.core.api.AnnotatedMBean;
|
||||
import ru.entaxy.esb.resources.EntaxyResource;
|
||||
import ru.entaxy.esb.resources.EntaxyResourceService;
|
||||
import ru.entaxy.platform.base.objects.EntaxyObject;
|
||||
import ru.entaxy.platform.base.support.CommonUtils;
|
||||
import ru.entaxy.platform.base.support.JSONUtils;
|
||||
import ru.entaxy.platform.core.artifact.service.ArtifactService;
|
||||
import ru.entaxy.platform.integration.applications.*;
|
||||
import ru.entaxy.platform.integration.applications.descriptor.ApplicationRequirement;
|
||||
import ru.entaxy.platform.integration.applications.item.project.EntaxyObjectItem;
|
||||
import ru.entaxy.platform.integration.applications.management.ProjectsMBean;
|
||||
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObject;
|
||||
import ru.entaxy.platform.objects.runtime.EntaxyRuntimeObjectService;
|
||||
|
||||
import javax.management.DynamicMBean;
|
||||
import javax.management.MBeanRegistration;
|
||||
import javax.management.NotCompliantMBeanException;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component(
|
||||
service = {DynamicMBean.class, MBeanRegistration.class, ProjectsMBean.class},
|
||||
property = {ManagementCore.JMX_OBJECTNAME + "=" + ProjectsMBean.Q_MAIN_MODULE_S},
|
||||
scope = ServiceScope.SINGLETON,
|
||||
immediate = true
|
||||
)
|
||||
public class ProjectsMBeanImpl extends AnnotatedMBean<ProjectsMBean> implements ProjectsMBean {
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY)
|
||||
public ApplicationManager applicationManager;
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY)
|
||||
EntaxyRuntimeObjectService entaxyRuntimeObjectService;
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY)
|
||||
EntaxyResourceService entaxyResourceService;
|
||||
|
||||
@Reference(cardinality = ReferenceCardinality.MANDATORY)
|
||||
ArtifactService artifactService;
|
||||
|
||||
public ProjectsMBeanImpl() throws NotCompliantMBeanException {
|
||||
super(ProjectsMBean.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readAsTree() {
|
||||
final String TITLE = "title";
|
||||
final String CHILDREN = "children";
|
||||
|
||||
List<Map<String, Object>> projectStorages = new ArrayList<>();
|
||||
applicationManager.getActiveStorages().forEach(storage -> {
|
||||
|
||||
Map<String, Object> projectStorage = new HashMap<>();
|
||||
projectStorage.put(TITLE, storage.getName());
|
||||
projectStorage.put(CHILDREN, storage.getProjects().stream().map(project -> {
|
||||
Map<String, Object> projectMap = new HashMap<>();
|
||||
projectMap.put(TITLE, project.getName());
|
||||
projectMap.put(CHILDREN, project.getVersions().stream().map(version -> {
|
||||
Map<String, Object> versionMap = new HashMap<>();
|
||||
versionMap.put(TITLE, version.getVersionNumber());
|
||||
|
||||
if (version.isBuildAvailable()) {
|
||||
Map<String, Object> buildInfo = new HashMap<>(1);
|
||||
List<Map<String, Object>> buildInfoList = new ArrayList<>(1);
|
||||
buildInfo.put(TITLE, "build info");
|
||||
buildInfoList.add(buildInfo);
|
||||
versionMap.put(CHILDREN, buildInfoList);
|
||||
}
|
||||
return versionMap;
|
||||
}).collect(Collectors.toList()));
|
||||
return projectMap;
|
||||
}).collect(Collectors.toList()));
|
||||
|
||||
projectStorages.add(projectStorage);
|
||||
});
|
||||
|
||||
return JSONUtils.GSON.toJson(projectStorages);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listProjectItems(String storage, String projectName, String projectVersion) {
|
||||
|
||||
return getProjectVersion(storage, projectName, projectVersion)
|
||||
.getItems().stream().map(item -> {
|
||||
Map<String, Object> itemMap = new HashMap<>();
|
||||
itemMap.put("status", getStatus(item));
|
||||
itemMap.put("id", item.getId());
|
||||
itemMap.put("type", item.getType().toString());
|
||||
itemMap.put("scope", item.getScope().toString());
|
||||
itemMap.put("required", item.isRequired());
|
||||
itemMap.put("ignored", item.isIgnored());
|
||||
if (EntaxyApplication.ITEM_TYPE.OBJECT.equals(item.getType())) {
|
||||
itemMap.put("displayName", ((EntaxyObjectItem) item).getObject().getDisplayName());
|
||||
itemMap.put("runtimeType", ((EntaxyObjectItem) item).getObject().getType());
|
||||
}
|
||||
return itemMap;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private enum STATUS {
|
||||
INCLUDED,
|
||||
IGNORED,
|
||||
REQUIRED,
|
||||
GHOST
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> readProjectItemStatuses() {
|
||||
return Arrays.stream(STATUS.values()).map(status -> status.toString()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// copied from application-shell
|
||||
private String getStatus(ApplicationProjectItem item) {
|
||||
String status = STATUS.INCLUDED.toString();
|
||||
if (item.isGhost()) {
|
||||
status = STATUS.GHOST.toString();
|
||||
}
|
||||
if (item.isRequired()) {
|
||||
if (item.isIgnored()) {
|
||||
status = STATUS.IGNORED.toString();
|
||||
} else {
|
||||
status = STATUS.REQUIRED.toString();
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createProject(String projectName, String storage, String initialVersion) throws Exception {
|
||||
String version = CommonUtils.isValid(initialVersion) ? initialVersion : "1.0.0";
|
||||
applicationManager.createProject(storage, projectName, version);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeProject(String storage, String projectName) throws Exception {
|
||||
applicationManager.getStorage(storage).removeProject(getProject(storage, projectName));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> addObject(String storage, String projectName, String projectVersion, String objectId) {
|
||||
EntaxyRuntimeObject object = entaxyRuntimeObjectService.getRuntimeObject(objectId);
|
||||
|
||||
getProjectVersion(storage, projectName, projectVersion)
|
||||
.addObject(object);
|
||||
|
||||
return getRelatedObjects(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> listObjects() {
|
||||
return entaxyRuntimeObjectService.getObjects().stream().map(object -> {
|
||||
return objectIntoMap(object);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> getRelatedObjects(String objectId) {
|
||||
EntaxyRuntimeObject object = entaxyRuntimeObjectService.getRuntimeObject(objectId);
|
||||
return getRelatedObjects(object);
|
||||
}
|
||||
|
||||
private List<Map<String, String>> getRelatedObjects(EntaxyRuntimeObject object) {
|
||||
return object.getSubordRelations().stream().filter(relation -> {
|
||||
return EntaxyObject.OBJECT_RELATION.AGGREGATION.equals(relation.getType()) &&
|
||||
!relation.getTarget().isColocatedWith(object);
|
||||
}).map(relation -> {
|
||||
EntaxyRuntimeObject relatedObject = relation.getTarget();
|
||||
return objectIntoMap(relatedObject);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private Map<String, String> objectIntoMap(EntaxyRuntimeObject object) {
|
||||
Map<String, String> objectMap = new HashMap<>();
|
||||
objectMap.put("fullId", object.getObjectFullId());
|
||||
objectMap.put("displayName", object.getDisplayName());
|
||||
objectMap.put("type", object.getType());
|
||||
return objectMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addItem(String storage, String projectName, String projectVersion, String itemId) throws Exception {
|
||||
ApplicationProjectItem projectItem = getProjectItem(storage, projectName, projectVersion, itemId);
|
||||
if (projectItem != null) {
|
||||
getProjectVersion(storage, projectName, projectVersion).addItem(projectItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ignoreItem(String storage, String projectName, String projectVersion, String itemId) throws Exception {
|
||||
ApplicationProjectItem projectItem = getProjectItem(storage, projectName, projectVersion, itemId);
|
||||
if (projectItem != null) {
|
||||
getProjectVersion(storage, projectName, projectVersion).ignoreItem(projectItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeItem(String storage, String projectName, String projectVersion, String itemId) throws Exception {
|
||||
ApplicationProjectItem projectItem = getProjectItem(storage, projectName, projectVersion, itemId);
|
||||
if (projectItem != null) {
|
||||
getProjectVersion(storage, projectName, projectVersion).removeItem(projectItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> removeItems(String storage, String projectName, String projectVersion, List<String> itemIds)
|
||||
throws Exception {
|
||||
EntaxyApplicationProjectVersion version = getProjectVersion(storage, projectName, projectVersion);
|
||||
|
||||
List<ApplicationProjectItem> items = version.getItems().stream()
|
||||
.filter(item -> itemIds.contains(item.getId())).collect(Collectors.toList());
|
||||
|
||||
List<ApplicationProjectItem> itemsToRemove = new ArrayList<>();
|
||||
Map<ApplicationProjectItem, List<ApplicationProjectItem>> itemsImpossibleToRemove = new HashMap<>();
|
||||
|
||||
for (ApplicationProjectItem item : items) {
|
||||
List<ApplicationProjectItem> requiredBy = item.getRequiredBy();
|
||||
if (requiredBy.isEmpty()) {
|
||||
itemsToRemove.add(item);
|
||||
} else {
|
||||
List<ApplicationProjectItem> requiredLeft = requiredBy.stream()
|
||||
.filter(requiredByItem -> !itemIds.contains(requiredByItem.getId()))
|
||||
.collect(Collectors.toList());
|
||||
if (requiredLeft.isEmpty()) {
|
||||
itemsToRemove.add(item);
|
||||
} else {
|
||||
itemsImpossibleToRemove.put(item, requiredLeft);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<String> itemIdsToRemove = itemsToRemove.stream()
|
||||
.map(itemToRemove -> itemToRemove.getId()).collect(Collectors.toList());
|
||||
|
||||
do {
|
||||
for (ApplicationProjectItem itemToRemove : itemsToRemove) {
|
||||
version.removeItem(itemToRemove);
|
||||
}
|
||||
itemsToRemove = version.getItems().stream()
|
||||
.filter(item -> itemIdsToRemove.contains(item.getId())).collect(Collectors.toList());
|
||||
} while (itemsToRemove.size() > 0);
|
||||
|
||||
if (itemsImpossibleToRemove.size() > 0) {
|
||||
Map<String, List<String>> result = new HashMap<>();
|
||||
for (ApplicationProjectItem itemToRemove : itemsImpossibleToRemove.keySet()) {
|
||||
if (itemIds.contains(itemToRemove.getId())) {
|
||||
version.removeItem(itemToRemove);
|
||||
}
|
||||
result.put(getIdOrDisplayName(itemToRemove),
|
||||
itemsImpossibleToRemove.get(itemToRemove).stream()
|
||||
.map(item -> getIdOrDisplayName(item)).collect(Collectors.toList()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
private String getIdOrDisplayName(ApplicationProjectItem item) {
|
||||
String displayName = "";
|
||||
if (EntaxyApplication.ITEM_TYPE.OBJECT.equals(item.getType())) {
|
||||
displayName = ((EntaxyObjectItem) item).getObject().getDisplayName();
|
||||
}
|
||||
return CommonUtils.isValid(displayName) ? displayName : item.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createVersion(String storage, String projectName, String createdVersion, String prototypeVersion)
|
||||
throws Exception {
|
||||
if (CommonUtils.isValid(prototypeVersion)) {
|
||||
getProject(storage, projectName).createVersion(createdVersion, prototypeVersion);
|
||||
} else {
|
||||
getProject(storage, projectName).createVersion(createdVersion);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeVersion(String storage, String projectName, String versionToRemove) {
|
||||
getProject(storage, projectName).removeVersion(versionToRemove);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveProjectVersion(String storage, String projectName, String projectVersion) {
|
||||
getProjectVersion(storage, projectName, projectVersion).save();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildProjectVersion(String storage, String projectName, String projectVersion) throws Exception {
|
||||
getProjectVersion(storage, projectName, projectVersion).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> listBuiltProjectItems(String storage, String projectName, String projectVersion) {
|
||||
return getProjectVersion(storage, projectName, projectVersion).getBuildInfo().getItems().stream().map(item -> {
|
||||
Map<String, String> itemMap = new HashMap<>();
|
||||
itemMap.put("id", item.getId());
|
||||
itemMap.put("type", item.getType().toString());
|
||||
itemMap.put("component", item.getComponentId());
|
||||
return itemMap;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listBuiltProjectRequirements(String storage,
|
||||
String projectName,
|
||||
String projectVersion) {
|
||||
return getProjectVersion(storage, projectName, projectVersion).getBuildInfo().getRequirements()
|
||||
.stream().map(requirement -> {
|
||||
Map<String, Object> requirementMap = new HashMap<>();
|
||||
requirementMap.put("id", requirement.getId());
|
||||
requirementMap.put("type", requirement.getType().toString());
|
||||
requirementMap.put("scope", requirement.getScope().toString());
|
||||
requirementMap.put("status", checkRequirement(requirement));
|
||||
return requirementMap;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// copied from application-shell
|
||||
private boolean checkRequirement(ApplicationRequirement requirement) {
|
||||
switch (requirement.type) {
|
||||
case OBJECT:
|
||||
EntaxyRuntimeObject runtimeObject = entaxyRuntimeObjectService.getRuntimeObject(requirement.id);
|
||||
return runtimeObject != null && !runtimeObject.isGhost();
|
||||
case RESOURCE:
|
||||
EntaxyResource entaxyResource = entaxyResourceService.getResource(requirement.id);
|
||||
return entaxyResource.exists();
|
||||
case BUNDLE:
|
||||
case CONFIG:
|
||||
// TODO implement
|
||||
return true;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, String>> listBuiltProjectComponents(String storage,
|
||||
String projectName,
|
||||
String projectVersion) {
|
||||
return getProjectVersion(storage, projectName, projectVersion).getBuildInfo().getComponents()
|
||||
.stream().map(component -> {
|
||||
Map<String, String> componentMap = new HashMap<>();
|
||||
componentMap.put("id", component.getId());
|
||||
componentMap.put("type", component.getType().toString());
|
||||
componentMap.put("priority", String.valueOf(component.getPriority()));
|
||||
return componentMap;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readMavenUrl(String storage, String projectName, String projectVersion) {
|
||||
EntaxyApplicationProjectVersion version = getProjectVersion(storage, projectName, projectVersion);
|
||||
if (version.isBuildAvailable()) {
|
||||
return version.getBuildInfo().getMavenUrl();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listRepositories() {
|
||||
return artifactService.getRepositories().stream()
|
||||
.map(repository -> repository.getName()).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportToRepository(String storage, String projectName, String projectVersion, String repositoryName)
|
||||
throws Exception {
|
||||
applicationManager.exportToRepository(getProjectVersion(storage, projectName, projectVersion), repositoryName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String exportToFile(String storage, String projectName, String projectVersion) throws Exception {
|
||||
try (InputStream is = getProjectVersion(storage, projectName, projectVersion)
|
||||
.getBuildUrl().openConnection().getInputStream()) {
|
||||
return Base64.getEncoder().encodeToString(readFromStream(is));
|
||||
}
|
||||
}
|
||||
|
||||
private byte[] readFromStream(InputStream stream) throws IOException {
|
||||
try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
|
||||
IOUtils.copy(stream, baos);
|
||||
return baos.toByteArray();
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private EntaxyApplicationProject getProject(String storage, String projectName) {
|
||||
return applicationManager.getStorage(storage).getProject(projectName);
|
||||
}
|
||||
|
||||
private EntaxyApplicationProjectVersion getProjectVersion(String storage,
|
||||
String projectName,
|
||||
String projectVersion) {
|
||||
return getProject(storage, projectName).getVersion(projectVersion);
|
||||
}
|
||||
|
||||
private ApplicationProjectItem getProjectItem(
|
||||
String storage, String projectName, String projectVersion, String itemId) {
|
||||
|
||||
return getProjectVersion(storage, projectName, projectVersion).getItems()
|
||||
.stream().filter(item -> item.getId().equals(itemId)).findFirst().orElse(null);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user