diff --git a/bom/application/pom.xml b/bom/application/pom.xml
index 1eae80e3ca5f..de35ba06259b 100644
--- a/bom/application/pom.xml
+++ b/bom/application/pom.xml
@@ -24,7 +24,7 @@
4.33.0
0.14.1
2.17.2
- 2.22.1
+ 2.28
22.3.3
@@ -84,11 +84,6 @@
*****************************
-->
-
- com.dotcms
- ant-tooling
- 1.3.2
-
com.dotcms.lib
dot.aopalliance-repackaged
@@ -1137,7 +1132,7 @@
javax.ws.rs
javax.ws.rs-api
- 2.0.1
+ 2.1.1
@@ -1152,6 +1147,51 @@
${swagger.version}
+
+
+
+ org.jboss.weld.servlet
+ weld-servlet-shaded
+ 3.1.9.Final
+
+
+
+ org.glassfish.hk2.external
+ bean-validator
+ 2.5.0-b06
+
+
+
+ org.glassfish.hk2
+ hk2-locator
+ 2.5.0
+
+
+
+ org.jboss.weld
+ weld-junit5
+ 2.0.2.Final
+ test
+
+
+ org.jboss.weld.se
+ weld-se-core
+
+
+
+
+
+ org.jboss.weld.se
+ weld-se-shaded
+ 3.1.9.Final
+ test
+
+
+
+ io.smallrye
+ jandex
+ 3.0.5
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ${javadoc.title}
-
-
- ${javadoc.bottom}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Deploying plugins to: ${plugin.root.dir} | ${plugin.jar.deploy.dir}
-
-
-
-
- Copying plugins to: ${plugin.root.dir}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Deploying plugins from: ${plugin.root.dir}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Undeploying plugins from: ${plugin.root.dir}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dotCMS/pom.xml b/dotCMS/pom.xml
index bc5557037e7f..c5aa707ecbb2 100644
--- a/dotCMS/pom.xml
+++ b/dotCMS/pom.xml
@@ -106,10 +106,6 @@
*****************************
-->
-
- com.dotcms
- ant-tooling
-
com.dotcms.lib
dot.aopalliance-repackaged
@@ -1199,12 +1195,11 @@
jersey-common
-
+
org.glassfish.jersey.core
jersey-server
@@ -1412,6 +1407,39 @@
+
+
+
+ org.jboss.weld.servlet
+ weld-servlet-shaded
+ 3.1.9.Final
+
+
+
+ org.glassfish.hk2.external
+ bean-validator
+ 2.5.0-b06
+
+
+
+ org.glassfish.hk2
+ hk2-locator
+
+
+
+ org.jboss.weld.se
+ weld-se-shaded
+ test
+
+
+
+
+
+ io.smallrye
+ jandex
+ 3.0.5
+
+
org.apache.tomcat
tomcat-catalina
diff --git a/dotCMS/src/main/java/com/dotcms/cdi/CDIUtils.java b/dotCMS/src/main/java/com/dotcms/cdi/CDIUtils.java
new file mode 100644
index 000000000000..296b09eeab28
--- /dev/null
+++ b/dotCMS/src/main/java/com/dotcms/cdi/CDIUtils.java
@@ -0,0 +1,35 @@
+package com.dotcms.cdi;
+
+import com.dotmarketing.util.Logger;
+import java.util.Optional;
+import javax.enterprise.inject.spi.CDI;
+
+/**
+ * Utility class to get beans from CDI container
+ */
+public class CDIUtils {
+
+ /**
+ * Private constructor to avoid instantiation
+ */
+ private CDIUtils() {
+ }
+
+ /**
+ * Get a bean from CDI container
+ * @param clazz the class of the bean
+ * @return an Optional with the bean if found, empty otherwise
+ */
+ public static Optional getBean(Class clazz) {
+ try {
+ return Optional.of(CDI.current().select(clazz).get());
+ } catch (Exception e) {
+ Logger.error(CDIUtils.class,
+ String.format("Unable to find bean of class [%s] [%s]", clazz, e.getMessage())
+ );
+ }
+ return Optional.empty();
+ }
+
+
+}
diff --git a/dotCMS/src/main/java/com/dotcms/rest/annotation/HeaderFilter.java b/dotCMS/src/main/java/com/dotcms/rest/annotation/HeaderFilter.java
index b6c2825188d2..4209dea526e6 100644
--- a/dotCMS/src/main/java/com/dotcms/rest/annotation/HeaderFilter.java
+++ b/dotCMS/src/main/java/com/dotcms/rest/annotation/HeaderFilter.java
@@ -22,6 +22,7 @@
import java.util.Collections;
import java.util.Map;
import java.util.Optional;
+import javax.ws.rs.ext.Provider;
/**
* This decorator reads the annotations on the resources and includes header based on it based on them.
@@ -31,6 +32,7 @@
*/
@Singleton
@Priority(Priorities.HEADER_DECORATOR)
+@Provider
public class HeaderFilter implements ContainerResponseFilter {
private final PermissionsUtil permissionsUtil = PermissionsUtil.getInstance();
diff --git a/dotCMS/src/main/java/com/dotcms/rest/api/CorsFilter.java b/dotCMS/src/main/java/com/dotcms/rest/api/CorsFilter.java
index f2b6bcca1e90..c55045fe7f3c 100644
--- a/dotCMS/src/main/java/com/dotcms/rest/api/CorsFilter.java
+++ b/dotCMS/src/main/java/com/dotcms/rest/api/CorsFilter.java
@@ -16,11 +16,13 @@
import com.dotmarketing.util.Logger;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
+import javax.ws.rs.ext.Provider;
/**
* @author Geoff M. Granum
*/
+@Provider
public class CorsFilter implements ContainerResponseFilter {
diff --git a/dotCMS/src/main/java/com/dotcms/rest/config/ContainerReloader.java b/dotCMS/src/main/java/com/dotcms/rest/config/ContainerReloader.java
index d0c116e64053..969420976ad0 100644
--- a/dotCMS/src/main/java/com/dotcms/rest/config/ContainerReloader.java
+++ b/dotCMS/src/main/java/com/dotcms/rest/config/ContainerReloader.java
@@ -2,6 +2,8 @@
import com.dotmarketing.util.Logger;
import java.util.concurrent.atomic.AtomicReference;
+import javax.enterprise.context.ApplicationScoped;
+import javax.ws.rs.ext.Provider;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.spi.AbstractContainerLifecycleListener;
import org.glassfish.jersey.server.spi.Container;
@@ -9,16 +11,12 @@
/**
* A new Reloader will get created on each reload there can only be one container at a time
*/
-class ContainerReloader extends AbstractContainerLifecycleListener {
-
- private static final ContainerReloader INSTANCE = new ContainerReloader();
+@Provider
+@ApplicationScoped
+public class ContainerReloader extends AbstractContainerLifecycleListener {
private static final AtomicReference containerRef = new AtomicReference<>();
- public static ContainerReloader getInstance() {
- return INSTANCE;
- }
-
@Override
public void onStartup(Container container) {
Logger.debug(ContainerReloader.class, "Jersey Container started");
diff --git a/dotCMS/src/main/java/com/dotcms/rest/config/DotRestApplication.java b/dotCMS/src/main/java/com/dotcms/rest/config/DotRestApplication.java
index 8ace717c0a88..77a4d860275c 100644
--- a/dotCMS/src/main/java/com/dotcms/rest/config/DotRestApplication.java
+++ b/dotCMS/src/main/java/com/dotcms/rest/config/DotRestApplication.java
@@ -1,136 +1,19 @@
package com.dotcms.rest.config;
-import com.dotcms.ai.rest.*;
-import com.dotcms.contenttype.model.field.FieldTypeResource;
-import com.dotcms.rendering.js.JsResource;
-import com.dotcms.rest.AuditPublishingResource;
-import com.dotcms.rest.BundlePublisherResource;
-import com.dotcms.rest.BundleResource;
-import com.dotcms.rest.CMSConfigResource;
-import com.dotcms.rest.ClusterResource;
-import com.dotcms.rest.EnvironmentResource;
-import com.dotcms.rest.IntegrityResource;
-import com.dotcms.rest.JSPPortlet;
-import com.dotcms.rest.LicenseResource;
-import com.dotcms.rest.OSGIResource;
-import com.dotcms.rest.PublishQueueResource;
-import com.dotcms.rest.RestExamplePortlet;
-import com.dotcms.rest.RulesEnginePortlet;
-import com.dotcms.rest.StructureResource;
-import com.dotcms.rest.TagResource;
-import com.dotcms.rest.WidgetResource;
-import com.dotcms.rest.annotation.HeaderFilter;
-import com.dotcms.rest.annotation.RequestFilter;
-import com.dotcms.rest.api.CorsFilter;
-import com.dotcms.rest.api.MyObjectMapperProvider;
-import com.dotcms.rest.api.v1.announcements.AnnouncementsResource;
-import com.dotcms.rest.api.v1.apps.AppsResource;
-import com.dotcms.rest.api.v1.asset.WebAssetResource;
-import com.dotcms.rest.api.v1.authentication.ApiTokenResource;
-import com.dotcms.rest.api.v1.authentication.AuthenticationResource;
-import com.dotcms.rest.api.v1.authentication.CreateJsonWebTokenResource;
-import com.dotcms.rest.api.v1.authentication.ForgotPasswordResource;
-import com.dotcms.rest.api.v1.authentication.LoginFormResource;
-import com.dotcms.rest.api.v1.authentication.LogoutResource;
-import com.dotcms.rest.api.v1.authentication.ResetPasswordResource;
-import com.dotcms.rest.api.v1.browser.BrowserResource;
-import com.dotcms.rest.api.v1.browsertree.BrowserTreeResource;
-import com.dotcms.rest.api.v1.categories.CategoriesResource;
-import com.dotcms.rest.api.v1.container.ContainerResource;
-import com.dotcms.rest.api.v1.content.ContentRelationshipsResource;
-import com.dotcms.rest.api.v1.content.ContentReportResource;
-import com.dotcms.rest.api.v1.content.ContentResource;
-import com.dotcms.rest.api.v1.content.ContentVersionResource;
-import com.dotcms.rest.api.v1.content.ResourceLinkResource;
-import com.dotcms.rest.api.v1.contenttype.ContentTypeResource;
-import com.dotcms.rest.api.v1.contenttype.FieldResource;
-import com.dotcms.rest.api.v1.contenttype.FieldVariableResource;
-import com.dotcms.rest.api.v1.ema.EMAResource;
-import com.dotcms.rest.api.v1.event.EventsResource;
-import com.dotcms.rest.api.v1.experiments.ExperimentsResource;
-import com.dotcms.rest.api.v1.fileasset.FileAssetsResource;
-import com.dotcms.rest.api.v1.folder.FolderResource;
-import com.dotcms.rest.api.v1.form.FormResource;
-import com.dotcms.rest.api.v1.index.ESIndexResource;
-import com.dotcms.rest.api.v1.languages.LanguagesResource;
-import com.dotcms.rest.api.v1.maintenance.JVMInfoResource;
-import com.dotcms.rest.api.v1.maintenance.MaintenanceResource;
-import com.dotcms.rest.api.v1.menu.MenuResource;
-import com.dotcms.rest.api.v1.notification.NotificationResource;
-import com.dotcms.rest.api.v1.page.NavResource;
-import com.dotcms.rest.api.v1.page.PageResource;
-import com.dotcms.rest.api.v1.personalization.PersonalizationResource;
-import com.dotcms.rest.api.v1.personas.PersonaResource;
-import com.dotcms.rest.api.v1.portlet.PortletResource;
-import com.dotcms.rest.api.v1.portlet.ToolGroupResource;
-import com.dotcms.rest.api.v1.pushpublish.PushPublishFilterResource;
-import com.dotcms.rest.api.v1.relationships.RelationshipsResource;
-import com.dotcms.rest.api.v1.site.SiteResource;
-import com.dotcms.rest.api.v1.sites.ruleengine.rules.RuleResource;
-import com.dotcms.rest.api.v1.sites.ruleengine.rules.actions.ActionResource;
-import com.dotcms.rest.api.v1.sites.ruleengine.rules.conditions.ConditionGroupResource;
-import com.dotcms.rest.api.v1.sites.ruleengine.rules.conditions.ConditionResource;
-import com.dotcms.rest.api.v1.sites.ruleengine.rules.conditions.ConditionValueResource;
-import com.dotcms.rest.api.v1.system.AppContextInitResource;
-import com.dotcms.rest.api.v1.system.ConfigurationResource;
-import com.dotcms.rest.api.v1.system.SystemTableResource;
-import com.dotcms.rest.api.v1.system.UpgradeTaskResource;
-import com.dotcms.rest.api.v1.system.cache.CacheResource;
-import com.dotcms.rest.api.v1.system.i18n.I18NResource;
-import com.dotcms.rest.api.v1.system.logger.LoggerResource;
-import com.dotcms.rest.api.v1.system.monitor.MonitorResource;
-import com.dotcms.rest.api.v1.system.permission.PermissionResource;
-import com.dotcms.rest.api.v1.system.role.RoleResource;
-import com.dotcms.rest.api.v1.system.ruleengine.actionlets.ActionletsResource;
-import com.dotcms.rest.api.v1.system.ruleengine.conditionlets.ConditionletsResource;
-import com.dotcms.rest.api.v1.system.storage.StorageResource;
-import com.dotcms.rest.api.v1.taillog.TailLogResource;
-import com.dotcms.rest.api.v1.temp.TempFileResource;
-import com.dotcms.rest.api.v1.template.TemplateResource;
-import com.dotcms.rest.api.v1.theme.ThemeResource;
-import com.dotcms.rest.api.v1.user.UserResource;
-import com.dotcms.rest.api.v1.variants.VariantResource;
-import com.dotcms.rest.api.v1.versionable.VersionableResource;
-import com.dotcms.rest.api.v1.vtl.VTLResource;
-import com.dotcms.rest.api.v1.workflow.WorkflowResource;
-import com.dotcms.rest.elasticsearch.ESContentResourcePortlet;
-import com.dotcms.rest.exception.mapper.DefaultDotBadRequestExceptionMapper;
-import com.dotcms.rest.exception.mapper.DoesNotExistExceptionMapper;
-import com.dotcms.rest.exception.mapper.DotBadRequestExceptionMapper;
-import com.dotcms.rest.exception.mapper.DotDataExceptionMapper;
-import com.dotcms.rest.exception.mapper.DotSecurityExceptionMapper;
-import com.dotcms.rest.exception.mapper.ElasticsearchStatusExceptionMapper;
-import com.dotcms.rest.exception.mapper.HttpStatusCodeExceptionMapper;
-import com.dotcms.rest.exception.mapper.InvalidFormatExceptionMapper;
-import com.dotcms.rest.exception.mapper.InvalidLicenseExceptionMapper;
-import com.dotcms.rest.exception.mapper.JsonMappingExceptionMapper;
-import com.dotcms.rest.exception.mapper.JsonParseExceptionMapper;
-import com.dotcms.rest.exception.mapper.NotAllowedExceptionMapper;
-import com.dotcms.rest.exception.mapper.NotFoundInDbExceptionMapper;
-import com.dotcms.rest.exception.mapper.ParamExceptionMapper;
-import com.dotcms.rest.exception.mapper.ResourceNotFoundExceptionMapper;
-import com.dotcms.rest.exception.mapper.RuntimeExceptionMapper;
-import com.dotcms.rest.exception.mapper.UnrecognizedPropertyExceptionMapper;
-import com.dotcms.rest.exception.mapper.WorkflowPortletAccessExceptionMapper;
-import com.dotcms.rest.personas.PersonasResourcePortlet;
-import com.dotmarketing.business.DotStateException;
-import com.dotmarketing.exception.AlreadyExistException;
-import com.dotmarketing.portlets.folders.exception.InvalidFolderNameException;
-import com.fasterxml.jackson.core.JsonProcessingException;
+import com.dotcms.cdi.CDIUtils;
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
-import com.google.common.collect.ImmutableSet;
import io.swagger.v3.jaxrs2.integration.resources.AcceptHeaderOpenApiResource;
import io.swagger.v3.jaxrs2.integration.resources.OpenApiResource;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.servers.Server;
import io.swagger.v3.oas.annotations.tags.Tag;
-import org.glassfish.jersey.media.multipart.MultiPartFeature;
-
-import javax.ws.rs.core.Application;
import java.util.Map;
-import java.util.Set;
+import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
+import javax.ws.rs.ApplicationPath;
+import org.glassfish.jersey.media.multipart.MultiPartFeature;
+import org.glassfish.jersey.server.ResourceConfig;
/**
* This class provides the list of all the REST end-points in dotCMS. Every new
@@ -160,151 +43,24 @@
@Tag(name = "Content Report")
}
)
-public class DotRestApplication extends Application {
- /**
- * these are system resources and should never change
- */
- private static final Set> INTERNAL_CLASSES = ImmutableSet.>builder()
- .add(MultiPartFeature.class)
- .add(ESIndexResource.class)
- .add(com.dotcms.rest.RoleResource.class)
- .add(BundleResource.class)
- .add(StructureResource.class)
- .add(com.dotcms.rest.ContentResource.class)
- .add(BundlePublisherResource.class)
- .add(JSPPortlet.class)
- .add(AuditPublishingResource.class)
- .add(WidgetResource.class)
- .add(CMSConfigResource.class)
- .add(OSGIResource.class)
- .add(com.dotcms.rest.api.v1.osgi.OSGIResource.class)
- .add(com.dotcms.rest.UserResource.class)
- .add(ClusterResource.class)
- .add(EnvironmentResource.class)
- .add(NotificationResource.class)
- .add(IntegrityResource.class)
- .add(LicenseResource.class)
- .add(RestExamplePortlet.class)
- .add(ESContentResourcePortlet.class)
- .add(PersonaResource.class)
- .add(UserResource.class)
- .add(TagResource.class)
- .add(RulesEnginePortlet.class)
- .add(RuleResource.class)
- .add(ConditionGroupResource.class)
- .add(ConditionResource.class)
- .add(ConditionValueResource.class)
- .add(PersonasResourcePortlet.class)
- .add(ConditionletsResource.class)
- .add(MonitorResource.class)
- .add(ActionResource.class)
- .add(ActionletsResource.class)
- .add(I18NResource.class)
- .add(LanguagesResource.class)
- .add(com.dotcms.rest.api.v2.languages.LanguagesResource.class)
- .add(MenuResource.class)
- .add(AuthenticationResource.class)
- .add(LogoutResource.class)
- .add(LoginFormResource.class)
- .add(ForgotPasswordResource.class)
- .add(ConfigurationResource.class)
- .add(AppContextInitResource.class)
- .add(SiteResource.class)
- .add(ContentTypeResource.class)
- .add(FieldResource.class)
- .add(com.dotcms.rest.api.v2.contenttype.FieldResource.class)
- .add(com.dotcms.rest.api.v3.contenttype.FieldResource.class)
- .add(FieldTypeResource.class)
- .add(FieldVariableResource.class)
- .add(ResetPasswordResource.class)
- .add(RoleResource.class)
- .add(CreateJsonWebTokenResource.class)
- .add(ApiTokenResource.class)
- .add(PortletResource.class)
- .add(EventsResource.class)
- .add(FolderResource.class)
- .add(BrowserTreeResource.class)
- .add(CategoriesResource.class)
- .add(PageResource.class)
- .add(ContentRelationshipsResource.class)
- .add(WorkflowResource.class)
- .add(ContainerResource.class)
- .add(ThemeResource.class)
- .add(NavResource.class)
- .add(RelationshipsResource.class)
- .add(VTLResource.class)
- .add(JsResource.class)
- .add(ContentVersionResource.class)
- .add(FileAssetsResource.class)
- .add(PersonalizationResource.class)
- .add(TempFileResource.class)
- .add(UpgradeTaskResource.class)
- .add(AppsResource.class)
- .add(EMAResource.class)
- .add(BrowserResource.class)
- .add(ResourceLinkResource.class)
- .add(PushPublishFilterResource.class)
- .add(LoggerResource.class)
- .add(TemplateResource.class)
- .add(MaintenanceResource.class)
- .add(PublishQueueResource.class)
- .add(ToolGroupResource.class)
- .add(VersionableResource.class)
- .add(PermissionResource.class)
- .add(ContentResource.class)
- .add(CacheResource.class)
- .add(JVMInfoResource.class)
- .add(FormResource.class)
- .add(OpenApiResource.class)
- .add(AcceptHeaderOpenApiResource.class)
- .add(ExperimentsResource.class)
- .add(TailLogResource.class)
- .add(VariantResource.class)
- .add(WebAssetResource.class)
- .add(SystemTableResource.class)
- .add(StorageResource.class)
- .add(com.dotcms.rest.api.v2.tags.TagResource.class)
- .add(AnnouncementsResource.class)
- .add(CompletionsResource.class)
- .add(EmbeddingsResource.class)
- .add(ImageResource.class)
- .add(SearchResource.class)
- .add(TextResource.class)
- .add(ContentReportResource.class)
- .build();
+@ApplicationPath("/api")
+public class DotRestApplication extends ResourceConfig {
+
+ public DotRestApplication() {
- private static final Set> PROVIDER_CLASSES = ImmutableSet.>builder()
- .add(ContainerReloader.class)
- .add(RequestFilter.class)
- .add(HeaderFilter.class)
- .add(CorsFilter.class)
- .add(MyObjectMapperProvider.class)
- .add(JacksonJaxbJsonProvider.class)
- .add(HttpStatusCodeExceptionMapper.class)
- .add(ResourceNotFoundExceptionMapper.class)
- .add(InvalidFormatExceptionMapper.class)
- .add(JsonParseExceptionMapper.class)
- .add(ParamExceptionMapper.class)
- .add(JsonMappingExceptionMapper.class)
- .add(UnrecognizedPropertyExceptionMapper.class)
- .add(InvalidLicenseExceptionMapper.class)
- .add(WorkflowPortletAccessExceptionMapper.class)
- .add(NotFoundInDbExceptionMapper.class)
- .add(DoesNotExistExceptionMapper.class)
- .add((new DotBadRequestExceptionMapper(){}).getClass())
- .add((new DotBadRequestExceptionMapper(){}).getClass())
- .add((new DotBadRequestExceptionMapper(){}).getClass())
- .add(DefaultDotBadRequestExceptionMapper.class)
- .add((new DotBadRequestExceptionMapper(){}).getClass())
- .add((new DotBadRequestExceptionMapper(){}).getClass())
- .add(DotSecurityExceptionMapper.class)
- .add(DotDataExceptionMapper.class)
- .add(ElasticsearchStatusExceptionMapper.class)
- .add((new DotBadRequestExceptionMapper(){}).getClass())
- .add(NotAllowedExceptionMapper.class)
- .add(RuntimeExceptionMapper.class)
- .build();
+ register(MultiPartFeature.class).
+ register(JacksonJaxbJsonProvider.class).
+ register(OpenApiResource.class).
+ register(AcceptHeaderOpenApiResource.class).
+ registerClasses(customClasses.keySet()).
+ packages(
+ "com.dotcms.rest",
+ "com.dotcms.contenttype.model.field",
+ "com.dotcms.rendering.js",
+ "com.dotcms.ai.rest"
+ );
+ }
/**
* This is the cheap way to create a concurrent set of user provided classes
@@ -316,10 +72,12 @@ public class DotRestApplication extends Application {
* @param clazz the class ot add
*/
public static synchronized void addClass(Class> clazz) {
- if(clazz==null)return;
- if (Boolean.TRUE.equals(customClasses.computeIfAbsent(clazz,c -> true)))
- {
- ContainerReloader.getInstance().reload();
+ if(clazz==null){
+ return;
+ }
+ if (Boolean.TRUE.equals(customClasses.computeIfAbsent(clazz,c -> true))) {
+ final Optional reloader = CDIUtils.getBean(ContainerReloader.class);
+ reloader.ifPresent(ContainerReloader::reload);
}
}
@@ -328,20 +86,13 @@ public static synchronized void addClass(Class> clazz) {
* @param clazz
*/
public static synchronized void removeClass(Class> clazz) {
- if(clazz==null)return;
+ if(clazz==null){
+ return;
+ }
if(customClasses.remove(clazz) != null){
- ContainerReloader.getInstance().reload();
+ final Optional reloader = CDIUtils.getBean(ContainerReloader.class);
+ reloader.ifPresent(ContainerReloader::reload);
}
}
- @Override
- public Set> getClasses() {
- return ImmutableSet.>builder()
- .addAll(customClasses.keySet())
- .addAll(INTERNAL_CLASSES)
- .addAll(PROVIDER_CLASSES)
- .build();
-
- }
-
}
diff --git a/dotCMS/src/main/java/com/dotcms/rest/config/JerseyApplicationEventListener.java b/dotCMS/src/main/java/com/dotcms/rest/config/JerseyApplicationEventListener.java
new file mode 100644
index 000000000000..0f0970bed5ab
--- /dev/null
+++ b/dotCMS/src/main/java/com/dotcms/rest/config/JerseyApplicationEventListener.java
@@ -0,0 +1,39 @@
+package com.dotcms.rest.config;
+
+import com.dotmarketing.util.Logger;
+import java.util.Objects;
+import java.util.Set;
+import javax.enterprise.context.ApplicationScoped;
+import javax.ws.rs.ext.Provider;
+import org.glassfish.jersey.server.monitoring.ApplicationEvent;
+import org.glassfish.jersey.server.monitoring.ApplicationEvent.Type;
+import org.glassfish.jersey.server.monitoring.ApplicationEventListener;
+import org.glassfish.jersey.server.monitoring.RequestEvent;
+import org.glassfish.jersey.server.monitoring.RequestEventListener;
+
+@Provider
+@ApplicationScoped
+public class JerseyApplicationEventListener implements ApplicationEventListener {
+
+ @Override
+ public void onEvent(ApplicationEvent event) {
+ if (Objects.requireNonNull(event.getType()) == Type.INITIALIZATION_FINISHED) {
+ logLoadedClasses(event);
+ }
+ }
+
+ private void logLoadedClasses(ApplicationEvent event) {
+ Set> resourceClasses = event.getResourceConfig().getClasses();
+ Logger.info(JerseyApplicationEventListener.class,"Loaded resource classes:");
+ resourceClasses.forEach(clazz -> Logger.info(JerseyApplicationEventListener.class,clazz.getName()));
+
+ Set
+
+ org.jboss.weld
+ weld-junit5
+ test
+
+
+ org.jboss.weld.se
+ weld-se-core
+
+
+
+
+
+ org.jboss.weld.se
+ weld-se-shaded
+ test
+
diff --git a/dotcms-integration/src/test/java/com/dotcms/IntegrationTestBase.java b/dotcms-integration/src/test/java/com/dotcms/IntegrationTestBase.java
index 72d7559084fb..01fc89e82008 100644
--- a/dotcms-integration/src/test/java/com/dotcms/IntegrationTestBase.java
+++ b/dotcms-integration/src/test/java/com/dotcms/IntegrationTestBase.java
@@ -31,7 +31,10 @@
import java.io.UnsupportedEncodingException;
import java.util.List;
import org.apache.commons.io.FileUtils;
+import org.jboss.weld.environment.se.Weld;
+import org.jboss.weld.environment.se.WeldContainer;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -53,6 +56,8 @@ public abstract class IntegrationTestBase extends BaseMessageResources {
private final static PrintStream stdout = System.out;
private final static ByteArrayOutputStream output = new ByteArrayOutputStream();
+ private static WeldContainer weld;
+
@Rule
public TestName name = new TestName();
@@ -256,7 +261,7 @@ public void cleanCategories(List categoriesToDelete) {
protected void initConnection() {
if (DbConnectionFactory.connectionExists()) {
- DbConnectionFactory.closeSilently(); // start always we a new one
+ DbConnectionFactory.closeSilently(); // start always with a new one
}
}
@@ -275,4 +280,16 @@ protected T wrapOnReadOnlyConn(final ReturnableDelegate supplier) throw
DbConnectionFactory.closeSilently();
}
}
+
+ @BeforeClass
+ public static void initWeld() {
+ weld = new Weld().containerId("IntegrationTestBase").initialize();
+ }
+
+ @AfterClass
+ public static void cleanupWeld() {
+ if( null != weld && weld.isRunning() ){
+ weld.shutdown();
+ }
+ }
}
diff --git a/dotcms-integration/src/test/java/com/dotcms/cdi/GreetingBean.java b/dotcms-integration/src/test/java/com/dotcms/cdi/GreetingBean.java
new file mode 100644
index 000000000000..3c56a1696ac5
--- /dev/null
+++ b/dotcms-integration/src/test/java/com/dotcms/cdi/GreetingBean.java
@@ -0,0 +1,17 @@
+package com.dotcms.cdi;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+
+@ApplicationScoped
+public class GreetingBean {
+
+ @Inject
+ MessageServiceBean injectedTestBean;
+
+ public String greet() {
+ return injectedTestBean.getMessage();
+ }
+
+}
diff --git a/dotcms-integration/src/test/java/com/dotcms/cdi/MessageServiceBean.java b/dotcms-integration/src/test/java/com/dotcms/cdi/MessageServiceBean.java
new file mode 100644
index 000000000000..100ce23fa143
--- /dev/null
+++ b/dotcms-integration/src/test/java/com/dotcms/cdi/MessageServiceBean.java
@@ -0,0 +1,12 @@
+package com.dotcms.cdi;
+
+import javax.enterprise.context.Dependent;
+
+@Dependent
+public class MessageServiceBean {
+
+ public String getMessage() {
+ return "Hello World";
+ }
+
+}
diff --git a/dotcms-integration/src/test/java/com/dotcms/cdi/SimpleInjectionIT.java b/dotcms-integration/src/test/java/com/dotcms/cdi/SimpleInjectionIT.java
new file mode 100644
index 000000000000..30e3112da561
--- /dev/null
+++ b/dotcms-integration/src/test/java/com/dotcms/cdi/SimpleInjectionIT.java
@@ -0,0 +1,31 @@
+package com.dotcms.cdi;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import com.dotcms.IntegrationTestBase;
+import java.util.Optional;
+import org.junit.Test;
+
+/**
+ * Integration test for simple CDI injection
+ */
+public class SimpleInjectionIT extends IntegrationTestBase {
+
+ /**
+ * Test CDI injection
+ * Given scenario: An annotated bean is injected
+ * Expected result: the bean is injected
+ */
+ @Test
+ public void testInjection() {
+
+ Optional optional = CDIUtils.getBean(GreetingBean.class);
+ assertTrue(optional.isPresent());
+ final GreetingBean greetingBean = optional.get();
+ assertEquals("Hello World", greetingBean.greet());
+
+ }
+
+}
diff --git a/dotcms-integration/src/test/java/com/dotcms/util/IntegrationTestInitService.java b/dotcms-integration/src/test/java/com/dotcms/util/IntegrationTestInitService.java
index e94f6a935605..2ea04111cde2 100644
--- a/dotcms-integration/src/test/java/com/dotcms/util/IntegrationTestInitService.java
+++ b/dotcms-integration/src/test/java/com/dotcms/util/IntegrationTestInitService.java
@@ -13,6 +13,9 @@
import com.dotmarketing.util.Logger;
import com.liferay.util.SystemProperties;
import org.awaitility.Awaitility;
+import org.jboss.weld.bootstrap.api.helpers.RegistrySingletonProvider;
+import org.jboss.weld.environment.se.Weld;
+import org.jboss.weld.environment.se.WeldContainer;
import org.mockito.Mockito;
import java.time.Duration;
@@ -29,6 +32,8 @@ public class IntegrationTestInitService {
private static final AtomicBoolean initCompleted = new AtomicBoolean(false);
+ private static WeldContainer weld;
+
static {
SystemProperties.getProperties();
}
@@ -44,6 +49,10 @@ public static IntegrationTestInitService getInstance() {
public void init() throws Exception {
try {
if (initCompleted.compareAndSet(false, true)) {
+
+ weld = new Weld().containerId(RegistrySingletonProvider.STATIC_INSTANCE)
+ .initialize();
+
System.setProperty(TestUtil.DOTCMS_INTEGRATION_TEST, TestUtil.DOTCMS_INTEGRATION_TEST);
Awaitility.setDefaultPollInterval(10, TimeUnit.MILLISECONDS);
diff --git a/dotcms-integration/src/test/resources/META-INF/beans.xml b/dotcms-integration/src/test/resources/META-INF/beans.xml
new file mode 100644
index 000000000000..1675ad7ab74c
--- /dev/null
+++ b/dotcms-integration/src/test/resources/META-INF/beans.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
\ No newline at end of file